suneditor 3.3.0 → 3.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -1
- package/dist/suneditor.min.css +2 -2
- package/dist/suneditor.min.js +1 -1
- package/package.json +3 -2
- package/src/assets/suneditor.css +5117 -5105
- package/src/core/config/eventManager.js +24 -1
- package/src/core/editor.js +6 -1
- package/src/core/event/effects/keydown.registry.js +14 -9
- package/src/core/event/effects/ruleHelpers.js +119 -1
- package/src/core/event/eventOrchestrator.js +15 -6
- package/src/core/event/rules/keydown.rule.backspace.js +10 -47
- package/src/core/event/rules/keydown.rule.delete.js +28 -66
- package/src/core/logic/dom/format.js +2 -2
- package/src/core/logic/dom/html.js +85 -5
- package/src/core/logic/dom/nodeTransform.js +5 -3
- package/src/core/logic/panel/blockHandle.js +61 -24
- package/src/core/logic/panel/blockResolver.js +41 -4
- package/src/core/logic/shell/pluginManager.js +15 -2
- package/src/core/logic/shell/ui.js +38 -28
- package/src/core/schema/options.js +20 -3
- package/src/core/section/constructor.js +12 -8
- package/src/events.js +1 -1
- package/src/helper/dom/domQuery.js +10 -4
- package/src/helper/googleDocs.js +40 -0
- package/src/helper/index.js +3 -0
- package/src/modules/contract/Figure.js +5 -2
- package/src/modules/ui/CommandMenu.js +47 -5
- package/src/modules/ui/SelectMenu.js +97 -36
- package/src/plugins/dropdown/table/index.js +25 -8
- package/src/plugins/dropdown/table/shared/table.constants.js +2 -0
- package/src/plugins/field/slashCommand.js +59 -12
- package/types/core/event/effects/ruleHelpers.d.ts +56 -0
- package/types/core/logic/panel/blockHandle.d.ts +3 -16
- package/types/core/logic/shell/ui.d.ts +14 -5
- package/types/core/schema/options.d.ts +31 -5
- package/types/events.d.ts +2 -2
- package/types/helper/dom/domQuery.d.ts +4 -2
- package/types/helper/googleDocs.d.ts +19 -0
- package/types/helper/index.d.ts +5 -0
- package/types/modules/ui/CommandMenu.d.ts +11 -0
- package/types/modules/ui/SelectMenu.d.ts +13 -7
- package/types/plugins/dropdown/table/index.d.ts +11 -0
- package/types/plugins/dropdown/table/shared/table.constants.d.ts +1 -0
- package/types/plugins/field/slashCommand.d.ts +43 -2
package/dist/suneditor.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{var t={cfbI(t){var e,s;e="undefined"!=typeof window?window:this,s=function(t,e){const s={code:"en",align:"Align",alignBottom:"Align bottom",alignCenter:"Align center",alignJustify:"Align justify",alignLeft:"Align left",alignMiddle:"Align middle",alignRight:"Align right",alignTop:"Align top",anchor:"Anchor",asBlock:"As a block",asInline:"As a inline",asLink:"As a link",audio:"Audio",audioGallery:"Audio gallery",audio_modal_file:"Select from files",audio_modal_title:"Insert Audio",audio_modal_url:"Audio URL",autoSize:"Auto size",backgroundColor:"Background color",basic:"Basic",blockStyle:"Block style",bold:"Bold",border:"Border",border_all:"Border all",border_inside:"Border inside",border_horizontal:"Border horizontal",border_vertical:"Border vertical",border_outside:"Border outside",border_left:"Border left",border_top:"Border top",border_right:"Border right",border_bottom:"Border bottom",border_none:"Border none",bulletedList:"Bulleted list",cancel:"Cancel",caption:"Insert description",cellProperties:"Cell properties",center:"Center",close:"Close",codeView:"Code view",color:"Color",colorPicker:"Color picker",column:"Column",comment:"Comments",commentAdd:"Add comment",commentShow:"Show comments",copy:"Copy",copyFormat:"Paint Formatting",cut:"Cut",default:"Default",deleteColumn:"Delete column",deleteRow:"Delete row",dir_ltr:"Left to right",dir_rtl:"Right to left",download:"Download",drag:"Drag",drawing:"Drawing",drawing_modal_title:"Drawing",edit:"Edit",embed:"Embed",embed_modal_title:"Embed",embed_modal_source:"Embed Source / URL",exportPDF:"Export to PDF",exportWord:"Export to Word",find:"Find",decrease:"Decrease",increase:"Increase",fileBrowser:"File browser",fileGallery:"File gallery",fileUpload:"File upload",fixedColumnWidth:"Fixed column width",font:"Font",fontColor:"Font color",fontSize:"Size",formats:"Formats",fullScreen:"Full screen",height:"Height",horizontalLine:"Horizontal line",horizontalSplit:"Horizontal split",hr_dashed:"Dashed",hr_dotted:"Dotted",hr_solid:"Solid",id:"ID",image:"Image",imageGallery:"Image gallery",image_modal_altText:"Alternative text",image_modal_file:"Select from files",image_modal_title:"Insert image",image_modal_url:"Image URL",importWord:"Import from Word",indent:"Indent",inlineStyle:"Inline style",insertColumnAfter:"Insert column after",insertColumnBefore:"Insert column before",insertRowAbove:"Insert row above",insertRowBelow:"Insert row below",insertLine:"Insert line",italic:"Italic",layout:"Layout",left:"Left",lineHeight:"Line height",link:"Link",link_modal_bookmark:"Bookmark",link_modal_downloadLinkCheck:"Download link",link_modal_newWindowCheck:"Open in new window",link_modal_text:"Text to display",link_modal_title:"Insert Link",link_modal_url:"URL to link",link_modal_relAttribute:"Rel attribute",list:"List",markdownView:"Markdown view",math:"Math",math_modal_fontSizeLabel:"Font Size",math_modal_inputLabel:"Mathematical Notation",math_modal_previewLabel:"Preview",math_modal_title:"Math",maxSize:"Max size",mediaGallery:"Media gallery",menu_bordered:"Bordered",menu_code:"Code",menu_neon:"Neon",menu_shadow:"Shadow",menu_spaced:"Spaced",menu_translucent:"Translucent",mergeCells:"Merge cells",minSize:"Min size",mirrorHorizontal:"Mirror, Horizontal",mirrorVertical:"Mirror, Vertical",newDocument:"New document",numberedList:"Numbered list",outdent:"Outdent",pageBreak:"Page break",pageDown:"Page down",pageNumber:"Page number",pageUp:"Page up",paragraphStyle:"Paragraph style",preview:"Preview",print:"print",proportion:"Constrain proportions",ratio:"Ratio",redo:"Redo",remove:"Remove",removeFormat:"Remove Format",replace:"Replace",replaceAll:"Replace all",resize100:"Zoom 100%",resize25:"Zoom 25%",resize50:"Zoom 50%",resize75:"Zoom 75%",resize:"Resize",revert:"Revert",revisionHistory:"Revision History",right:"Right",rotateLeft:"Rotate left",rotateRight:"Rotate right",row:"Row",save:"Save",search:"Search",selectAll:"Select All",showBlocks:"Show blocks",size:"Size",splitCells:"Split cells",strike:"Strike",submitButton:"Submit",subscript:"Subscript",superscript:"Superscript",table:"Table",tableHeader:"Table header",tableProperties:"Table properties",tags:"Tags",tag_blockquote:"Quote",codeBlock:"Code Block",tag_div:"Normal (DIV)",tag_h:"Header",tag_p:"Paragraph",tag_pre:"Code",template:"Template",textStyle:"Text style",title:"Title",underline:"Underline",undo:"Undo",unmergeCells:"Unmerge cells",unlink:"Unlink",verticalSplit:"Vertical split",video:"Video",videoGallery:"Video gallery",video_modal_file:"Select from files",video_modal_title:"Insert Video",video_modal_url:"Media embed URL, YouTube/Vimeo",width:"Width",codeLanguage:"Language",codeLanguage_none:"None",finder_matchCase:"Match Case",finder_wholeWord:"Whole Word",finder_regex:"Regular Expression",finder_prev:"Previous Match",finder_next:"Next Match",message_copy_success:"Copied to clipboard",message_copy_fail:"Copy failed. Please copy manually."};return void 0===e&&(t.SUNEDITOR_LANG||Object.defineProperty(t,"SUNEDITOR_LANG",{enumerable:!0,writable:!1,configurable:!1,value:{}}),Object.defineProperty(t.SUNEDITOR_LANG,"en",{enumerable:!0,writable:!0,configurable:!0,value:s})),s},"object"==typeof t.exports?t.exports=e.document?s(e,!0):function(t){if(!t.document)throw new Error("SUNEDITOR_LANG a window with a document");return s(t)}:s(e)}},e={};function s(i){var n=e[i];if(void 0!==n)return n.exports;var o=e[i]={exports:{}};return t[i].call(o.exports,o,o.exports,s),o.exports}s.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return s.d(e,{a:e}),e},s.d=(t,e)=>{for(var i in e)s.o(e,i)&&!s.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},s.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),s.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},(()=>{"use strict";var t={};s.r(t),s.d(t,{Browser:()=>Dr,ColorPicker:()=>Sl,Controller:()=>Mi,Figure:()=>Wi,HueSlider:()=>kl,Modal:()=>Ml});var e={};s.r(e),s.d(e,{ApiManager:()=>zr,FileManager:()=>Bl});var i={};s.r(i),s.d(i,{CommandMenu:()=>cn,ModalAnchorEditor:()=>Al,SelectMenu:()=>Bi,_DragHandle:()=>yi});var n={};s.r(n),s.d(n,{EditorComponent:()=>fc,ModuleBrowser:()=>pc,ModuleColorPicker:()=>gc,ModuleController:()=>uc,ModuleHueSlider:()=>mc,ModuleModal:()=>dc,PluginBrowser:()=>zl,PluginCommand:()=>Pl,PluginDropdown:()=>Dl,PluginDropdownFree:()=>Fl,PluginField:()=>Hl,PluginInput:()=>ql,PluginModal:()=>Wl,PluginPopup:()=>Ul});const o=window,r=document,l=Symbol("noEventHandler"),a=Symbol("onOverComponent"),h=navigator.userAgent.toLowerCase();const c="function"==typeof ResizeObserver,d="function"==typeof navigator.clipboard?.write,u=/Edg/.test(navigator.userAgent),p=/(Mac|iPhone|iPod|iPad)/.test(navigator.userAgent),g=h.includes("chrome/")&&!h.includes("edge/"),m=!!h.match(/gecko\/\d+/),f=!!o.chrome,v=h.includes("applewebkit/")&&!h.includes("chrome"),b=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(h),y=navigator.maxTouchPoints>0&&"ontouchstart"in o,w=h.includes("android"),C=p?"⌘":"CTRL",_=p?"⇧":"+SHIFT",k=o.devicePixelRatio;let x=null;const $={_w:o,_d:r,NO_EVENT:l,ON_OVER_COMPONENT:a,getXMLHttpRequest:function(){return new XMLHttpRequest},getPageStyle:function(t){let e="";const s=(t||r).styleSheets;for(let t,i=0,n=s.length;i<n;i++){try{t=s[i].cssRules}catch{continue}if(t)for(let s=0,i=t.length;s<i;s++)e+=t[s].cssText}return e},getIncludePath:function(t,e){let s="";const i=[],n="js"===e?"script":"link",o="js"===e?"src":"href";let l="(?:";for(let e=0,s=t.length;e<s;e++)l+=t[e]+(e<s-1?"|":")");const a=new RegExp(`(^|.*[\\/])${l}(\\.[^\\/]+)?.${e}(?:\\?.*|;.*)?$`,"i"),h=new RegExp(`.+\\.${e}(?:\\?.*|;.*)?$`,"i");for(let t=r.getElementsByTagName(n),e=0;e<t.length;e++)h.test(t[e][o])&&i.push(t[e]);for(let t=0;t<i.length;t++){const e=i[t][o].match(a);if(e){s=e[0];break}}if(!s)throw new Error("[SUNEDITOR.helper.env.getIncludePath.fail] The SUNEDITOR installation path could not be automatically detected. (path: +"+s+", extension: "+e+")");return""===s&&(s=i.length>0?i[0][o]:""),s.includes(":/")||"//"===s.slice(0,2)||(s=!1===s.includes("/")?location.href.match(/^.*?:\/\/[^/]*/)[0]+s:location.href.match(/^[^?]*\/(?:)/)[0]+s),s},isResizeObserverSupported:c,isClipboardSupported:d,isEdge:u,isBlink:g,isGecko:m,isChromium:f,isSafari:v,isOSX_IOS:p,isAndroid:w,isMobile:b,isTouchDevice:y,canUseBeforeInput:function(){if(null!==x)return x;if(!r.body||"function"!=typeof r.execCommand)return!0;let t=!1;try{const e=r.createElement("div");e.setAttribute("contenteditable","true"),e.setAttribute("aria-hidden","true"),e.style.cssText="position: fixed; top: 0; left: -9999px; width: 1px; height: 1px; opacity: 0; pointer-events: none;";const s=r.activeElement;r.body.appendChild(e);const i=()=>{t=!0};e.addEventListener("beforeinput",i,!0),e.addEventListener("input",i,!0),e.focus({preventScroll:!0}),r.execCommand("insertText",!1,""),e.removeEventListener("beforeinput",i,!0),e.removeEventListener("input",i,!0),e.remove(),s&&s!==r.body&&"function"==typeof s.focus&&s.focus({preventScroll:!0})}catch{t=!0}return x=t},cmdIcon:C,shiftIcon:_,DPI:k,KATEX_WEBSITE:"https://katex.org/docs/supported.html",MATHJAX_WEBSITE:"https://www.mathjax.org/"},S=8203,E=String.fromCharCode(S),T=new RegExp(String.fromCharCode(S),"g"),M=new RegExp("^"+String.fromCharCode(S)+"+$");const N={zeroWidthSpace:E,zeroWidthRegExp:T,onlyZeroWidthRegExp:M,escapeStringRegexp:function(t){if("string"!=typeof t)throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}};function B(t,e=0){if(!t)return 0;const s=(t+"").match(/-?\d+(\.\d+)?/);if(!s||!s[0])return 0;const i=Number(s[0]);return e<0?i:0===e?Math.round(i):Number(i.toFixed(e))}const I={is:function(t){return/^-?\d+(\.\d+)?$/.test(t+"")},get:B,getOverlapRangeAtIndex:function(t,e,s,i){if(t<=i?e<s:e>s)return 0;const n=(t>s?t:s)-(e<i?e:i);return(n<0?-1*n:n)+1},isEven:function(t){return!(1&t)},isOdd:function(t){return!(1&~t)}},L=/&|\u00A0|'|"|<|>/g,A=/&| |'|"|<|>/g,O={"&":"&"," ":" ","'":"'",'"':""","<":"<",">":">"},R={"&":"&"," ":" ","'":"'",""":'"',"<":"<",">":">"},z=/[A-Z]/g,P=/-[a-zA-Z]/g,D={"xx-small":.5625,"x-small":.625,small:.8333,medium:1,large:1.125,"x-large":1.5,"xx-large":2,"xxx-large":2.5};function F(t){if(3===t.nodeType){const e=t.nodeValue.trim();return e?{type:"text",content:e}:null}if(1===t.nodeType){const e={type:"element",tag:t.tagName.toLowerCase(),attributes:{},children:[]};for(const s of t.attributes)e.attributes[s.name]=s.value;for(const s of t.childNodes){const t=F(s);t&&e.children.push(t)}return e}return null}function H(t){return t.replace(L,(t=>O[t]||t))}function q(t){return/^#[0-9a-f]{3}(?:[0-9a-f]{3})?$/i.test(t)}const W={htmlToJson:function(t){return F((new DOMParser).parseFromString(t,"text/html").body)},jsonToHtml:function t(e){if(!e)return"";if("text"===e.type)return H(e.content||"");if("element"===e.type){const{tag:s,attributes:i={},children:n=[]}=e,o=Object.entries(i).map((([t,e])=>`${t}="${H(e)}"`)).join(" "),r=`</${s}>`;return`${o?`<${s} ${o}>`:`<${s}>`}${n.map(t).join("")}${r}`}return""},htmlToEntity:H,entityToHTML:function(t){return t.replace(A,(t=>R[t]||t))},debounce:function(t,e){let s;function i(...i){o.clearTimeout(s),s=o.setTimeout((()=>{s=null,t(...i)}),e)}return i.cancel=()=>{o.clearTimeout(s),s=null},i},syncMaps:function(t,e){e.forEach(((e,s)=>{t.set(s,e)})),t.forEach(((s,i)=>{e.has(i)||t.delete(i)}))},mergeMaps:function(...t){const e=t.filter((t=>t instanceof Map)).flatMap((t=>[...t]));return new Map(e)},getValues:function(t){return t?Object.keys(t).map((function(e){return t[e]})):[]},camelToKebabCase:function t(e){return"string"==typeof e?e.replace(z,(t=>"-"+t.toLowerCase())):e.map((function(e){return t(e)}))},kebabToCamelCase:function t(e){return"string"==typeof e?e.replace(P,(t=>t.replace("-","").toUpperCase())):e.map((function(e){return t(e)}))},toFontUnit:function(t,e){const s=e.match(/(\d+(?:\.\d+)?)(.+)/),i=s?Number(s[1]):D[e],n=s?s[2]:"rem";let o=i;switch(/em/.test(n)?o=Math.round(i/.0625):"pt"===n?o=Math.round(1.333*i):"%"===n&&(o=i/100),t){case"em":case"rem":return(.0625*o).toFixed(2)+t;case"%":return 100*Number((.0625*o).toFixed(2))+t;case"pt":return Math.round(o/1.333)+t;default:return o+t}},nodeListToArray:function(t){return t?Array.prototype.slice.call(t):[]},swapKeyValue:function(t){const e={},s=Object.prototype.hasOwnProperty;for(const i in t)s.call(t,i)&&(e[t[i]]=i);return e},createElementWhitelist:function(t){return new RegExp(`<\\/?\\b(?!\\b${(t||"").replace(/\|/g,"\\b|\\b")}\\b)[^>]*>`,"gi")},createElementBlacklist:function(t){return new RegExp(`<\\/?\\b(?:\\b${(t||"^").replace(/\|/g,"\\b|\\b")}\\b)[^>]*>`,"gi")},isHexColor:q,rgb2hex:function(t){if(q(t)||!t)return t;const e=t.match(/^rgba?[\s+]?\(([\d]+)[\s+]?,[\s+]?([\d]+)[\s+]?,[\s+]?([\d]+)[\s+]?/i);if(e&&e.length>=4){const s=("0"+parseInt(e[1],10).toString(16)).slice(-2),i=("0"+parseInt(e[2],10).toString(16)).slice(-2),n=("0"+parseInt(e[3],10).toString(16)).slice(-2);let o="";if(t.includes("rgba")){const e=t.match(/,\s*([\d]+\.?[\d]*)\s*\)/);e&&(o=("0"+Math.round(255*parseFloat(e[1])).toString(16)).slice(-2))}return`#${s}${i}${n}${o}`}return t},getWidthInPercentage:function(t,e){const s=e||t.parentElement,i=o.getComputedStyle(s),n=B(i.paddingLeft,-1),r=B(i.paddingRight,-1),l=s.offsetWidth-s.clientWidth,a=s.offsetWidth-n-r-l;return t.offsetWidth/a*100},textToAnchor:function(t){const e=/https?:\/\/[^\s]+/g;if(3===t.nodeType&&e.test(t.textContent)&&!/^A$/i.test(t.parentNode?.nodeName)){const s=t.textContent,i=r.createDocumentFragment();let n=0;return s.replace(e,((t,e)=>{e>n&&i.appendChild(r.createTextNode(s.slice(n,e)));const o=r.createElement("a");return o.href=t,o.target="_blank",o.textContent=t,i.appendChild(o),n=e+t.length,t})),n<s.length&&i.appendChild(r.createTextNode(s.slice(n))),t.parentNode.replaceChild(i,t),!0}return!1},spanToStyleNode:function(t,e){if(1===e.nodeType&&/^SPAN$/i.test(e.nodeName)&&e.hasAttribute("style")){const s=e.getAttribute("style"),i=[];if(Object.keys(t).forEach((e=>{if(t[e].regex.test(s)){const s=r.createElement(t[e].tag);i.push(s)}})),i.length>0){const t=r.createElement("span");let s=e.firstChild;i.forEach(((e,s)=>{0===s?t.appendChild(e):i[s-1].appendChild(e)}));const n=i[i.length-1];for(;s;){const t=s.nextSibling;n.appendChild(s),s=t}e.appendChild(t)}}},addUrlQuery:function(t,e){if(e.length>0)if(/\?/.test(t)){const s=t.split("?");t=s[0]+"?"+e+"&"+s[1]}else t+="?"+e;return t},_setDefaultOptionStyle:function(t,e){let s="";t.get("height")&&(s+="height:"+t.get("height")+";"),t.get("minHeight")&&(s+="min-height:"+t.get("minHeight")+";"),t.get("maxHeight")&&(s+="max-height:"+t.get("maxHeight")+";"),t.get("width")&&(s+="width:"+t.get("width")+";"),t.get("minWidth")&&(s+="min-width:"+t.get("minWidth")+";"),t.get("maxWidth")&&(s+="max-width:"+t.get("maxWidth")+";");let i="",n="",o="";const r=(e=s+e).split(";");for(let e,s=0,l=r.length;s<l;s++)e=r[s].trim(),e&&(/^(min-|max-)?width\s*:/.test(e)||/^(z-index|position|display)\s*:/.test(e)?i+=e+";":/^(min-|max-)?height\s*:/.test(e)?(/^height/.test(e)&&"auto"===e.split(":")[1].trim()&&t.set("height","auto"),n+=e+";"):o+=e+";");return{top:i,frame:n,editor:o}},_setIframeStyleLinks:function(t){let e="";if(t){const s=r.getElementsByTagName("link");for(let i,n=0,o=t.length;n<o;n++){i=[];const o=t[n];if("*"===o)for(let t=0,e=s.length;t<e;t++)"stylesheet"===s[t].rel&&s[t].href&&i.push(s[t].href);else if(/(^https?:\/\/)|(^data:text\/css,)/.test(o))i.push(o);else{const t=new RegExp(`(^|.*[\\/])${o}(\\..+)?.css((\\??.+?)|\\b)$`,"i");for(let e,n=0,o=s.length;n<o;n++)e=s[n].href.match(t),e&&i.push(e[0])}if(!i||0===i.length)throw new Error('[SUNEDITOR.constructor.iframe.fail] The suneditor CSS files installation path could not be automatically detected. Please set the option property "iframe_cssFileName" before creating editor instances.');for(let t=0,s=i.length;t<s;t++)e+='<link href="'+i[t]+'" rel="stylesheet">'}}return e},_setAutoHeightStyle:function(t){return"auto"===t?"<style>\n/** Iframe height auto */\nbody{height: min-content; overflow: hidden;}\n</style>":""}},U=W,V=/(\s|^)(katex|MathJax|se-exclude-format)(\s|$)/;function j(t){if(null==t)return!1;if("string"!=typeof t){if(G(t)){const e=t.children;for(let t=0,s=e.length;t<s;t++){if(!J(e[t]))return!1}}t=t.textContent}return""===t||M.test(t)}function G(t){return 1===t?.nodeType}function K(t){return/^(OL|UL)$/i.test("string"==typeof t?t:t?.nodeName)}function Y(t){return/^TABLE$/i.test("string"==typeof t?t:t?.nodeName)}function X(t){return/^(TD|TH)$/i.test("string"==typeof t?t:t?.nodeName)}function Z(t){return/^BR$/i.test("string"==typeof t?t:t?.nodeName)}function J(t){return/^(BR|COLGROUP|COL|THEAD|TBODY|TFOOT|TR|AREA|BASE|EMBED|HR|IMG|INPUT|KEYGEN|LINK|META|PARAM|SOURCE|TRACK|WBR)$/i.test("string"==typeof t?t:t?.nodeName)}function Q(t){if(1!==t?.nodeType)return!1;const e=t.classList;return!!e&&(e.contains("se-component")||e.contains("se-flex-component"))}function tt(t){if(1!==t?.nodeType)return!1;const e=t.classList;return!!e&&("BODY"===t.nodeName.toUpperCase()||e.contains("se-wrapper-wysiwyg")||e.contains("sun-editor-carrier-wrapper")||e.contains("se-wrapper"))}function et(t){return t?.hasAttribute("data-important-disabled")}const st={isZeroWidth:j,isEdgePoint:function(t,e,s){return"end"!==s&&0===e||(!s||"front"!==s)&&!t.nodeValue&&e<=1||(!s||"end"===s)&&t.nodeValue&&e>=t.nodeValue.length},isText:function(t){return 3===t?.nodeType},isElement:G,isInputElement:function(t){return G(t)&&/^(INPUT|TEXTAREA|SELECT|OPTION)$/i.test(t.nodeName)},isButtonElement:function(t){return G(t)&&/^(BUTTON)$/i.test(t.nodeName)},isList:K,isListCell:function(t){return/^LI$/i.test("string"==typeof t?t:t?.nodeName)},isTable:Y,isTableElements:function(t){return/^(TABLE|THEAD|TBODY|TR|TH|TD|COL)$/i.test("string"==typeof t?t:t?.nodeName)},isTableCell:X,isTableRow:function(t){return/^TR$/i.test("string"==typeof t?t:t?.nodeName)},isBreak:Z,isAnchor:function(t){return/^A$/i.test("string"==typeof t?t:t?.nodeName)},isMedia:function(t){return/^(IMG|IFRAME|AUDIO|VIDEO|CANVAS)$/i.test("string"==typeof t?t:t?.nodeName)},isIFrame:function(t){return/^IFRAME$/i.test("string"==typeof t?t:t?.nodeName)},isFigure:function(t){return/^FIGURE$/i.test("string"==typeof t?t:t?.nodeName)},isContentLess:J,isEmptyLine:function(t){if(!t?.parentNode)return!0;const e=t;return!e.querySelector("IMG, IFRAME, AUDIO, VIDEO, CANVAS, TABLE")&&(e.children.length<=1||Z(e.firstElementChild))&&j(e.textContent)},isComponentContainer:Q,isWysiwygFrame:tt,isNonEditable:function(t){return 1===t?.nodeType&&"false"===t.getAttribute("contenteditable")},isSpanWithoutAttr:function(t){if(1!==t?.nodeType)return!1;const e=t;return/^SPAN$/i.test(e.nodeName)&&!e.className&&0===e.style.length},isSameAttributes:function(t,e){if(3===t.nodeType&&3===e.nodeType)return!0;if(3===t.nodeType||3===e.nodeType)return!1;const s=t,i=e,n=s.style,o=i.style;let r=0;for(let t=0,e=n.length;t<e;t++)n[n[t]]===o[n[t]]&&r++;const l=s.classList,a=i.classList;let h=0;for(let t=0,e=l.length;t<e;t++)a.contains(l[t])&&h++;return r===o.length&&r===n.length&&h===a.length&&h===l.length},isExcludeFormat:function(t){return V.test(t?.className)},isUneditable:function(t){return t?.classList.contains("__se__uneditable")},isImportantDisabled:et},it=st;function nt(t){const e=Object.prototype.toString.call(t);return"[object HTMLCollection]"===e||"[object NodeList]"===e||"[object Array]"===e}function ot(t,e,s){const i=r.createElement(t);if(e)for(const t in e)void 0!==e[t]&&null!==e[t]&&i.setAttribute(t,e[t]);return s&&("string"==typeof s?i.innerHTML=s:"object"==typeof s&&i.appendChild(s)),i}function rt(t){return r.createTextNode(t||"")}function lt(t,e){let s=-1;for(let i=0,n=t.length;i<n;i++)if(t[i]===e){s=i;break}return s}const at=/(\s|^)(se-block-hover|se-block-dragging)(?=\s|$)/g;function ht(t,e,s){const i=t,n=e;if(n.style.length>0){const t=n.style;for(let e=0,s=t.length;e<s;e++)i.style[t[e]]=t[t[e]]}const o=n.attributes;for(let t,e=0,n=o.length;e<n;e++)if(t=o[e].name.toLowerCase(),s?.includes(t)||!o[e].value)i.removeAttribute(t);else if("style"!==t)if("class"===t){const t=o[e].value.replace(at," ").replace(/\s+/g," ").trim();t?i.setAttribute("class",t):i.removeAttribute("class")}else i.setAttribute(o[e].name,o[e].value)}function ct(t,e){if(t&&1===t.nodeType)return e.split("|").some((e=>t.classList.contains(e)))}function dt(t,e){if(!t)return;const s=nt(t)?t:[t],i=e.split("|");for(let t=0,e=s.length;t<e;t++){const e=s[t];if(e&&1===e.nodeType)for(const t of i)t&&e.classList.add(t)}}function ut(t,e){if(!t)return;const s=nt(t)?t:[t],i=e.split("|");for(let t=0,e=s.length;t<e;t++){const e=s[t];if(e&&1===e.nodeType)for(const t of i)t&&e.classList.remove(t)}}function pt(t=r){return{w:t.documentElement.clientWidth,h:t.documentElement.clientHeight}}const gt={clone:function(t,e=!1){return t.cloneNode(e)},createElement:ot,createTextNode:rt,getAttributesToString:function(t,e){const s=t.attributes;if(!s)return"";let i="";for(let t=0,n=s.length;t<n;t++)e?.includes(s[t].name)||(i+=s[t].name+'="'+H(s[t].value)+'" ');return i},arrayFilter:function(t,e){if(!t||0===t.length)return null;e||=()=>!0;const s=[];for(let i,n=0,o=t.length;n<o;n++)i=t[n],e(i)&&s.push(i);return s},arrayFind:function(t,e){if(!t||0===t.length)return null;e||=()=>!0;for(let s,i=0,n=t.length;i<n;i++)if(s=t[i],e(s))return s;return null},arrayIncludes:function(t,e){for(let s=0;s<t.length;s++)if(t[s]===e)return!0;return!1},getArrayIndex:lt,nextIndex:function(t,e){const s=lt(t,e);return-1===s?-1:s+1},prevIndex:function(t,e){const s=lt(t,e);return-1===s?-1:s-1},copyTagAttributes:ht,copyFormatAttributes:function(t,e){const s=e.cloneNode(!1);s.className=s.className.replace(/(\s|^)__se__format__[^\s]+/g,""),ht(t,s)},removeItem:function(t){t&&("remove"in t&&"function"==typeof t.remove?t.remove():t.parentNode&&t.parentNode.removeChild(t))},changeElement:function(t,e){if(t)if("string"==typeof e)if("outerHTML"in t)t.outerHTML=e;else{const s=ot("DIV");s.innerHTML=e,t.parentNode.replaceChild(s.firstChild,t)}else 1===e?.nodeType&&t.parentNode.replaceChild(e,t)},changeTxt:function(t,e){t&&e&&(t.textContent=e)},setStyle:function(t,e,s){for(let i,n=0,o=(t=Array.isArray(t)?t:[t]).length;n<o;n++)i=t[n],i.style[e]=s,0===i.style.length&&i.removeAttribute("style")},getStyle:function(t,e){if(1===t?.nodeType)return t.style[e]},setDisabled:function(t,e,s){for(let i=0,n=t.length;i<n;i++){const n=t[i];!s&&et(n)||(n.disabled=e),s&&(e?n.setAttribute("data-important-disabled",""):n.removeAttribute("data-important-disabled"))}},hasClass:ct,addClass:dt,removeClass:ut,toggleClass:function(t,e,s){if(!t||1!==t.nodeType)return;const i=t;i.classList.toggle(e,s),i.className.trim()||i.removeAttribute("class")},flashClass:function(t,e,s=120){dt(t,e),o.setTimeout((()=>{ut(t,e)}),s)},getClientSize:pt,getViewportSize:function(){return"visualViewport"in o?{top:o.visualViewport.pageTop,left:o.visualViewport.pageLeft,scale:o.visualViewport.scale}:{top:0,left:0,scale:1}},applyInlineStylesAll:function(t,e,s){if(!t)return console.warn('"parentTarget" is not exist'),null;let i=t;const n=r.createElement("DIV");if(n.style.display="none",/body/i.test(i.nodeName)){const t=r.createElement("DIV"),e=i.attributes;for(let s=0,i=e.length;s<i;s++)t.setAttribute(e[s].name,e[s].value);t.innerHTML=i.innerHTML,i=t}else i=i.cloneNode(!0);n.appendChild(i),r.body.appendChild(n);const l=Array.from(i.querySelectorAll("*")),a=e?[i].concat(l):l;for(let t,e=0;t=a[e];e++){if(1!==t.nodeType)continue;const e=o.getComputedStyle(t),i=t.style;for(const t of s)i.setProperty(t,e.getPropertyValue(t)||"")}return r.body.removeChild(n),i},waitForMediaLoad:function(t,e=5e3){const s=t||r;return new Promise((t=>{const i=["img","video","audio","iframe"].flatMap((t=>Array.from(s.querySelectorAll(t))));if(0===i.length)return void t();const n=i.map((t=>{if(function(t){return"[object HTMLImageElement]"===Object.prototype.toString.call(t)}(t)){if(t.complete)return Promise.resolve()}else if(function(t){const e=Object.prototype.toString.call(t);return"[object HTMLVideoElement]"===e||"[object HTMLAudioElement]"===e}(t)){if(t.readyState>=2)return Promise.resolve()}else if(function(t){return"[object HTMLIFrameElement]"===Object.prototype.toString.call(t)}(t))try{if("complete"===t.contentDocument?.readyState)return Promise.resolve()}catch(t){console.warn(["[SUNEDITOR] Iframe load error",t])}return new Promise((e=>{t.addEventListener("load",e,{once:!0}),t.addEventListener("error",e,{once:!0})}))}));Promise.race([Promise.all(n),new Promise((t=>o.setTimeout(t,e)))]).then((()=>{t()}))}))},getRootCssVar:function(t){return r.documentElement.style.getPropertyValue(t)},setRootCssVar:function(t,e){r.documentElement.style.setProperty(t,e)},createTooltipInner:function(t){return`<span class="se-tooltip-inner"><span class="se-tooltip-text">${t}</span></span>`}};function mt(t){let e=0;for(;t=t.previousSibling;)e+=1;return e}function ft(t,e,s){const i=[];let n=!0;return wt(t,(t=>{if(t===e&&(n=!1),n&&!it.isWysiwygFrame(t)){if(s&&3===t.nodeType){let e=null,i=null;s.s=s.e=0;let n=t.previousSibling;for(;3===n?.nodeType;)i=n.textContent.replace(T,""),s.s+=i.length,t.textContent=i+t.textContent,e=n,n=n.previousSibling,gt.removeItem(e);let o=t.nextSibling;for(;3===o?.nodeType;)i=o.textContent.replace(T,""),s.e+=i.length,t.textContent+=i,e=o,o=o.nextSibling,gt.removeItem(e)}i.push(t)}return!1})),i.map(mt).reverse()}function vt(t,e){let s,i=e;for(let e=0,n=t.length;e<n&&(s=i.childNodes,0!==s.length);e++)i=s.length<=t[e]?s[s.length-1]:s[t[e]];return i}function bt(t,e,s){const i=[];return s??=1/0,!t||s<=0||0===t.childNodes.length||(e||=()=>!0,function t(n,o){if(o>s)return;if(o>0&&e(n)&&i.push(n),o===s)return;const r=n.childNodes;for(let e=0,s=r.length;e<s;e++)t(r[e],o+1)}(t,0)),i}function yt(t){if(!t||it.isWysiwygFrame(t))return-1;let e=0;for(t=t.parentNode;t&&!it.isWysiwygFrame(t);)e+=1,t=t.parentNode;return e}function wt(t,e,s){let i;if("function"==typeof e)i=e;else if("object"==typeof e)i=t=>t===e;else{let t;/^\./.test(e)?(t="className",e="(\\s|^)"+e.split(".")[1]+"(\\s|$)"):/^#/.test(e)?(t="id",e="^"+e.split("#")[1]+"$"):/^:/.test(e)?(t="name",e="^"+e.split(":")[1]+"$"):(t="nodeName",e="^"+e+"$");const s=new RegExp(e,"i");i=e=>s.test(e[t])}s||=1/0;let n=0;for(;t&&!i(t);){if(n>=s||it.isWysiwygFrame(t))return null;t=t.parentElement,n++}return t}const Ct={getPositionIndex:mt,getNodePath:ft,getNodeFromPath:vt,getChildNode:function(t,e){let s=null;if(!t)return s;const i=t;return i.children&&0!==i.children.length?(e||=()=>!0,function t(n){if(i!==n&&e(n))return s=n,!0;if(n.children)for(let e=0,s=n.children.length;e<s;e++)t(n.children[e])}(i),s):s},getListChildren:function(t,e,s){const i=[];if(s??=1/0,!t||s<=0)return i;const n=t;return n.children&&0!==n.children.length?(e||=()=>!0,function t(o,r){if(!(r>s)&&(r>0&&n!==o&&e(o)&&i.push(o),r!==s&&o.children))for(let e=0,s=o.children.length;e<s;e++)t(o.children[e],r+1)}(n,0),i):i},getListChildNodes:bt,getNodeDepth:yt,sortNodeByDepth:function(t,e){const s=e?1:-1,i=-1*s;t.sort((function(t,e){if(!it.isListCell(t)||!it.isListCell(e))return 0;const n=yt(t),o=yt(e);return n>o?s:n<o?i:0}))},compareElements:function(t,e){let s=t,i=e;const n=yt(t),o=yt(e);if(n>o){let t=n-o;for(;t>0&&s;)s=s.parentElement,t--}else if(o>n){let t=o-n;for(;t>0&&i;)i=i.parentElement,t--}for(;s&&i&&s.parentElement!==i.parentElement;)s=s.parentElement,i=i.parentElement;if(!s?.parentNode||!i?.parentNode)return{ancestor:null,a:t,b:e,result:0};const r=s.parentNode.childNodes,l=gt.getArrayIndex(r,s),a=gt.getArrayIndex(r,i);return{ancestor:s.parentElement,a:s,b:i,result:l>a?1:l<a?-1:0}},getParentElement:wt,getParentElements:function(t,e,s){let i;if("function"==typeof e)i=e;else if("object"==typeof e)i=t=>t===e;else{let t;/^\./.test(e)?(t="className",e="(\\s|^)"+e.split(".")[1]+"(\\s|$)"):/^#/.test(e)?(t="id",e="^"+e.split("#")[1]+"$"):/^:/.test(e)?(t="name",e="^"+e.split(":")[1]+"$"):(t="nodeName",e="^"+e+"$");const s=new RegExp(e,"i");i=e=>s.test(e[t])}const n=[];s||=1/0;let o=0;for(;o<=s&&t&&!it.isWysiwygFrame(t);)i(t)&&n.push(t),t=t.parentElement,o++;return n},getCommandTarget:function(t){let e=t;for(;e&&!/^(UL)$/i.test(e.nodeName)&&!gt.hasClass(e,"sun-editor");){if(e.hasAttribute("data-command"))return e;e=e.parentElement}return null},getEventTarget:function(t){return t.target},getEdgeChild:function(t,e,s){let i;if("function"==typeof e)i=e;else if("object"==typeof e)i=function(t){return t===e};else{let t;/^\./.test(e)?(t="className",e="(\\s|^)"+e.split(".")[1]+"(\\s|$)"):/^#/.test(e)?(t="id",e="^"+e.split("#")[1]+"$"):/^:/.test(e)?(t="name",e="^"+e.split(":")[1]+"$"):(t="nodeName",e="^"+("text"===e?"#"+e:e)+"$");const s=new RegExp(e,"i");i=function(e){return s.test(e[t])}}const n=bt(t,(t=>i(t)),null);return n[s?n.length-1:0]},getEdgeChildNodes:function(t,e){if(t){for(e||=t;t&&1===t.nodeType&&t.childNodes.length>0&&!it.isBreak(t);)t=t.firstChild;for(;e&&1===e.nodeType&&e.childNodes.length>0&&!it.isBreak(e);)e=e.lastChild;return{sc:t,ec:e||t}}},getPreviousDeepestNode:function(t,e){let s=t.previousSibling;if(!s){for(let i=t.parentNode;i;i=i.parentNode){if(i===e)return null;if(i.previousSibling){s=i.previousSibling;break}}if(!s)return null}if(it.isNonEditable(s))return s;for(;s.lastChild;)s=s.lastChild;return s},getNextDeepestNode:function(t,e){let s=t.nextSibling;if(!s){for(let i=t.parentNode;i;i=i.parentNode){if(i===e)return null;if(i.nextSibling){s=i.nextSibling;break}}if(!s)return null}if(it.isNonEditable(s))return s;for(;s.firstChild;)s=s.firstChild;return s},findTextIndexOnLine:function(t,e,s,i){if(!t)return 0;i||=()=>!0;let n=0,o=!1;return function t(r){if(!o&&8!==r.nodeType&&!i(r))if(3===r.nodeType){if(r===e)return n+=s,void(o=!0);n+=r.textContent.length}else if(1===r.nodeType){const e=r.childNodes;for(let s=0,i=e.length;s<i;s++)if(t(e[s]),o)return}}(t),n},findTabEndIndex:function(t,e,s){if(!t)return 0;const i=t.textContent,n=new RegExp(`((\\u00A0|\\s){${s},})`,"g");let o;for(n.lastIndex=e;null!==(o=n.exec(i));)if(o.index>=e){const t=o.index+o[0].length-1;return t+(i.slice(0,t+1).match(/[^\u00A0\s]/g)||[]).length+s}return 0},findVisualLastCell:function(t){if(!t||0===t.length)return null;const e={};let s=null,i=-1,n=-1;for(const o of t){const t=o.parentElement.rowIndex,r=o.rowSpan||1,l=o.colSpan||1;e[t]||=[];let a=0;const h=e[t];for(;h[a];)a++;for(let t=0;t<l;t++)h[a+t]=!0;for(let s=1;s<r;s++){const i=t+s;e[i]||=[];for(let t=0;t<l;t++)e[i][a+t]=!0}const c=t+r-1,d=a+l-1;(c>i||c===i&&d>n)&&(i=c,n=d,s=o)}return s},getScrollParents:function(t){const e=[];let s=t?.parentElement;for(;s&&!/^(body|html)$/i.test(s.nodeName);){const t=o.getComputedStyle(s),{overflow:i,overflowX:n,overflowY:r}=t;[i,n,r].some((t=>["auto","scroll","overlay"].includes(t)))&&e.push(s),s=s.parentElement}return e},getIframeDocument:function(t){return t.contentWindow?.document||t.contentDocument}};const _t={query:Ct,check:it,utils:gt},kt="ArrowLeft|ArrowUp|ArrowRight|ArrowDown",xt="F1|F2|F3|F4|F5|F6|F7|F8|F9|F10|F11|F12",$t=kt.split("|"),St="Backspace|Delete".split("|"),Et=`Backspace|Tab|Enter|ShiftLeft|ShiftRight|ControlLeft|ControlRight|AltLeft|AltRight|Pause|CapsLock|Escape|PageUp|PageDown|End|Home|${kt}|Insert|Delete|${xt}|NumLock|ScrollLock`.split("|"),Tt="Backspace|Enter|Delete".split("|"),Mt="Backspace|Enter|Delete".split("|"),Nt=`ControlLeft|ControlRight|AltLeft|AltRight|Pause|CapsLock|Escape|Insert|${xt}|NumLock|ScrollLock`.split("|");const Bt={write:async function(t){if(!d)return console.error("Clipboard is not supported in this browser."),!1;let e="",s="";"string"==typeof t?(e=t,s=t):G(t)?(t.querySelectorAll("iframe").forEach((t=>{const e=document.createElement("div"),s={};for(const e of Array.from(t.attributes))s[e.name]=e.value;e.setAttribute("data-se-iframe-holder","1"),e.setAttribute("data-se-iframe-holder-attrs",JSON.stringify(s)),e.innerText=`[iframe: ${t.src}]`,t.replaceWith(e)})),e=t.outerHTML,s=t.textContent):(e=t.textContent,s=t.textContent);try{await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([e],{type:"text/html"}),"text/plain":new Blob([s],{type:"text/plain"})})])}catch{console.warn("[SUNEDITOR.copy.warn] This browser is not supported Clipboard API");try{await navigator.clipboard.writeText(s||function(t){const e=document.createElement("div");return e.innerHTML=t,e.textContent||e.innerText||""}(e))}catch(t){console.error("[SUNEDITOR.copy.fail] "+t)}}}},It=/^(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/i,Lt=/^[\u200B\uFEFF]+$/;function At(t){const e=t.trim();return""===e||Lt.test(e)}const Ot={strong:"**",b:"**",em:"*",i:"*",del:"~~",s:"~~",mark:"=="};function Rt(t){if(!t||0===t.length)return"";const e=[];for(let s=0;s<t.length;s++){const i=qt(t[s],"",!1);if(i){if(e.length>0){const t=e[e.length-1];!t||t.endsWith(" ")||t.endsWith("\n")||i.startsWith(" ")||i.startsWith("\n")||e.push(" ")}e.push(i)}}return e.join("")}function zt(t){return t?"text"===t.type?t.content||"":t.children?t.children.map(zt).join(""):"":""}function Pt(t){if(!t)return"";if("text"===t.type)return t.content||"";const{tag:e,attributes:s={},children:i=[]}=t,n=Object.entries(s).map((([t,e])=>`${t}="${e}"`)).join(" "),o=n?`<${e} ${n}>`:`<${e}>`;if(It.test(e))return o;return`${o}${i.map(Pt).join("")}</${e}>`}function Dt(t,e){return t?t.split("\n").map((t=>t?e+t:"")).join("\n")+"\n":""}function Ft(t,e,s){const i=t.children||[];let n="",o=1;for(const t of i){if("element"!==t.type||"li"!==t.tag)continue;const i=s?`${o}. `:"- ",r=t.children||[];let l="",a="";const h=e+" ".repeat(i.length);let c="";const d=r[0];d&&"element"===d.type&&"input"===d.tag&&"checkbox"===d.attributes?.type&&(c=void 0!==d.attributes.checked?"[x] ":"[ ] ");for(let t=0;t<r.length;t++){const e=r[t];if(0===t&&c)continue;if("element"!==e.type){l+=qt(e,"",!1);continue}const s=e.tag;if("ul"===s||"ol"===s)a+=Ft(e,h,"ol"===s);else if("table"===s)a+=Dt(Ht(e),h);else if("figure"===s){const t=(e.children||[]).find((t=>"element"===t.type&&"table"===t.tag));a+=Dt(t?Ht(t):qt(e,"",!0),h)}else"blockquote"===s||"pre"===s?a+=Dt(qt(e,"",!0),h):l+=qt(e,"",!1)}n+=`${e}${i}${c}${l.trim()}\n`,a&&(n+=a),o++}return n}function Ht(t){const e=[];let s=!1;if(function t(i,n){for(const o of i.children||[])if("thead"===o.tag)t(o,!0);else if("tbody"===o.tag||"tfoot"===o.tag)t(o,!1);else if("tr"===o.tag){const t=[];for(const e of o.children||[])if("td"===e.tag||"th"===e.tag){const s=Rt(e.children).trim(),i=parseInt(e.attributes?.colspan,10)||1,n=parseInt(e.attributes?.rowspan,10)||1;t.push({content:s,colspan:i,rowspan:n})}const i=n||!s&&o.children?.some((t=>"th"===t.tag));i&&(s=!0),e.push({cells:t,isHeader:i})}}(t,!1),0===e.length)return"";const i=e.filter((t=>t.isHeader)),n=e.filter((t=>!t.isHeader)),o=[...i,...n];let r=0;for(const t of o){let e=0;for(const s of t.cells)e+=s.colspan;e>r&&(r=e)}const l=Array.from({length:o.length},(()=>new Array(r).fill(null)));for(let t=0;t<o.length;t++){let e=0;for(const s of o[t].cells){for(;e<r&&null!==l[t][e];)e++;if(e>=r)break;for(let i=0;i<s.rowspan&&t+i<o.length;i++)for(let n=0;n<s.colspan&&e+n<r;n++)l[t+i][e+n]=0===i&&0===n?s.content:"";e+=s.colspan}for(let e=0;e<r;e++)null===l[t][e]&&(l[t][e]="")}let a="";if(i.length>0){a+="| "+l[0].join(" | ")+" |\n",a+="| "+l[0].map((()=>"---")).join(" | ")+" |\n";for(let t=1;t<l.length;t++)a+="| "+l[t].join(" | ")+" |\n"}else{a+="| "+new Array(r).fill(" ").join(" | ")+" |\n",a+="| "+new Array(r).fill("---").join(" | ")+" |\n";for(let t=0;t<l.length;t++)a+="| "+l[t].join(" | ")+" |\n"}return a}function qt(t,e,s){if(!t)return"";if("text"===t.type)return(t.content||"").replace(/[\u200B\uFEFF]/g,"");if("element"!==t.type)return"";const{tag:i,attributes:n={},children:o=[]}=t;if("body"===i)return o.map((t=>qt(t,"",!0))).join("");const r=/^h([1-6])$/.exec(i);if(r){const t=Rt(o).trim();if(!t)return"\n";const e=parseInt(r[1],10);return`${"#".repeat(e)} ${t}\n\n`}if("p"===i){const t=Rt(o);return t.trim()?`${t.trim()}\n\n`:"\n"}if("br"===i)return"\n";if("hr"===i)return"---\n\n";const l=Ot[i];if(l){return`${l}${Rt(o)}${l}`}if("code"===i){const t=zt({children:o});return t.includes("`")?"`` "+t+" ``":"`"+t+"`"}if("kbd"===i){return`<kbd>${zt({children:o})}</kbd>`}if("sub"===i){return`<sub>${Rt(o)}</sub>`}if("sup"===i){return`<sup>${Rt(o)}</sup>`}if("a"===i){const t=n.href||"",e=Rt(o),s=n.title;return s?`[${e}](${t} "${s}")`:`[${e}](${t})`}if("img"===i){const t=n.src||"";return``}if("blockquote"===i){return o.map((t=>qt(t,"",!0))).join("").replace(/\n$/,"").split("\n").map((t=>`> ${t}`)).join("\n")+"\n\n"}if("pre"===i){let e="",s="";const i=o.find((t=>"element"===t.type&&"code"===t.tag));return i?(e=(i.attributes?.class||"").replace(/^language-/,""),s=zt(i)):(e=(t.attributes?.class||"").match(/language-(\S+)/)?.[1]||"",s=zt({children:o})),"```"+e+"\n"+s+"\n```\n\n"}if("details"===i)return Pt(t)+"\n\n";if("summary"===i)return Pt(t);if("ul"===i)return Ft(t,e,!1)+"\n";if("ol"===i)return Ft(t,e,!0)+"\n";if("table"===i)return Ht(t)+"\n";if("dl"===i){let t="";for(const e of o)"element"===e.type&&("dt"===e.tag?t+=Rt(e.children).trim()+"\n":"dd"===e.tag&&(t+=": "+Rt(e.children).trim()+"\n"));return t+"\n"}if("dt"===i||"dd"===i)return Rt(o).trim();if("div"===i){if(n.class&&/se-component/.test(n.class))return o.map((t=>qt(t,e,!0))).join("");const t=Rt(o);return s?t+"\n\n":t}if("span"===i)return n.style||n.class?Pt(t):Rt(o);if("figure"===i){const t=o.map((t=>qt(t,e,!0))).join("");return/\n$/.test(t)?t:t+"\n\n"}if("figcaption"===i){const t=Rt(o).trim();return t?t+"\n\n":""}return"video"===i||"audio"===i||"iframe"===i?Pt(t)+"\n\n":Pt(t)}function Wt(t){if(!t)return"";const e=[];function s(t){return e.push(t),""+(e.length-1)+""}return t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=t.replace(/\\([\\*_~`[\]()#!|{}<>+-])/g,((t,e)=>s(e)))).replace(/``\s(.+?)\s``/g,((t,e)=>s("<code>"+e+"</code>")))).replace(/`([^`]+)`/g,((t,e)=>s("<code>"+e+"</code>")))).replace(/!\[([^\]]*)\]\(([^)\s]+)(?:\s+"([^"]*)")?\)/g,((t,e,i,n)=>s(n?`<img src="${i}" alt="${e}" title="${n}">`:`<img src="${i}" alt="${e}">`)))).replace(/\[([^\]]+)\]\(([^)\s]+)(?:\s+"([^"]*)")?\)/g,((t,e,i,n)=>s(n?`<a href="${i}" title="${n}">${e}</a>`:`<a href="${i}">${e}</a>`)))).replace(/<(https?:\/\/[^>]+)>/g,((t,e)=>s(`<a href="${e}">${e}</a>`)))).replace(/<([a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,})>/g,((t,e)=>s(`<a href="mailto:${e}">${e}</a>`)))).replace(/(?<![="'\w/])(https?:\/\/[^\s<>\])"]+)/g,((t,e)=>s(`<a href="${e}">${e}</a>`)))).replace(/~~(.+?)~~/g,"<del>$1</del>")).replace(/\*{3}(.+?)\*{3}/g,"<strong><em>$1</em></strong>")).replace(/_{3}(.+?)_{3}/g,"<strong><em>$1</em></strong>")).replace(/\*{2}(.+?)\*{2}/g,"<strong>$1</strong>")).replace(/_{2}(.+?)_{2}/g,"<strong>$1</strong>")).replace(/\*(.+?)\*/g,"<em>$1</em>")).replace(/(?<![a-zA-Z0-9])_(.+?)_(?![a-zA-Z0-9])/g,"<em>$1</em>")).replace(/==(.+?)==/g,"<mark>$1</mark>")).replace(/\^([^\s^]+)\^/g,"<sup>$1</sup>")).replace(/(?<!~)~([^\s~]+)~(?!~)/g,"<sub>$1</sub>")).replace(/\uFFFC(\d+)\uFFFC/g,((t,s)=>e[parseInt(s,10)]))}function Ut(t){if(t.length<2)return"";const e=t=>t.replace(/^\|/,"").replace(/\|$/,"").split("|").map((t=>t.trim())),s=e(t[0]),i=e(t[1]).map((t=>{const e=t.trim();return/^:-+:$/.test(e)?"center":/^-+:$/.test(e)?"right":/^:-+$/.test(e)?"left":""})),n=t.slice(2).map(e),o=s.length,r=s.every((t=>""===t));let l="<table>";const a=t=>{const e=i[t];return e?` style="text-align: ${e};"`:""};if(!r){l+="<thead><tr>";for(let t=0;t<o;t++)l+=`<th${a(t)}>${Wt(s[t])}</th>`;l+="</tr></thead>"}if(n.length>0||r){l+="<tbody>";for(const t of n){l+="<tr>";for(let e=0;e<o;e++)l+=`<td${a(e)}>${Wt(t[e]||"")}</td>`;l+="</tr>"}l+="</tbody>"}return l+="</table>",l}function Vt(t,e,s){const i=s?"ol":"ul",n=s?/^(\s*)\d+\.\s+(.*)/:/^(\s*)([-*+])\s+(.*)/;let o=`<${i}>`,r=e;const l=(t[r].match(/^(\s*)/)[1]||"").length;for(;r<t.length;){const e=t[r];if(At(e)){r++;continue}const i=(e.match(/^(\s*)/)[1]||"").length;if(i<l)break;if(i!==l)break;{if(!n.exec(e))break;const i=s?e.replace(/^\s*\d+\.\s+/,""):e.replace(/^\s*[-*+]\s+/,"");r++;let a=!1,h=!1,c=i;const d=/^\[([ xX])\]\s*(.*)/.exec(i);d&&(a=!0,h=" "!==d[1],c=d[2]);let u="";for(;r<t.length;){const e=t[r];if(At(e)){r++;continue}if((e.match(/^(\s*)/)[1]||"").length<=l)break;if(/^\s*[-*+]\s+/.test(e)||/^\s*\d+\.\s+/.test(e)){const s=Vt(t,r,/^\s*\d+\.\s+/.test(e));u+=s.html,r=s.index;continue}const s=e.trimStart();if(!(/^\|.*\|/.test(s)&&r+1<t.length&&/^\s*\|[\s:]*-{3,}/.test(t[r+1])))break;{const e=[];for(;r<t.length;){const s=t[r];if(At(s)||(s.match(/^(\s*)/)[1]||"").length<=l)break;if(!/^\s*\|/.test(s))break;e.push(s.trimStart()),r++}u+=Ut(e)}}if(a){o+=`<li class="task-list-item">${h?'<input type="checkbox" checked disabled> ':'<input type="checkbox" disabled> '}${Wt(c)}${u}</li>`}else o+=`<li>${Wt(i)}${u}</li>`}}return o+=`</${i}>`,{html:o,index:r}}const jt={jsonToMarkdown:function(t){return t?qt(t,"",!0).replace(/\n{3,}/g,"\n\n").trim()+"\n":""},markdownToHtml:function t(e,s){if(!e)return"";s||(s="p");const i=e.split("\n"),n=[];let o=0;for(;o<i.length;){const e=i[o];if(At(e)){o++;continue}const l=/^(`{3,}|~{3,})(\w*)/.exec(e);if(l){const t=l[1].charAt(0),e=l[1].length,s=l[2],a=[];o++;const h=new RegExp("^"+("`"===t?"`":"~")+"{"+e+",}\\s*$");for(;o<i.length&&!h.test(i[o]);)a.push(i[o]),o++;o++;const c=s?` class="language-${s}"`:"";n.push(`<pre><code${c}>${r=a.join("\n"),r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}</code></pre>`);continue}const a=/^(#{1,6})\s+(.+)/.exec(e);if(a){const t=a[1].length;n.push(`<h${t}>${Wt(a[2].trim())}</h${t}>`),o++;continue}if(/^(\*{3,}|-{3,}|_{3,})\s*$/.test(e)){n.push("<hr>"),o++;continue}if(/^>\s?/.test(e)){const e=[];for(;o<i.length&&/^>\s?/.test(i[o]);)e.push(i[o].replace(/^>\s?/,"")),o++;const r=t(e.join("\n"),s);n.push(`<blockquote>${r}</blockquote>`);continue}if(/^\|.*\|/.test(e)&&o+1<i.length&&/^\|[\s:]*-{3,}[\s:]*/.test(i[o+1])){const t=[];for(;o<i.length&&/^\|.*\|/.test(i[o]);)t.push(i[o]),o++;n.push(Ut(t));continue}if(/^(\s*)([-*+])\s+/.test(e)){const t=Vt(i,o,!1);n.push(t.html),o=t.index;continue}if(/^(\s*)\d+\.\s+/.test(e)){const t=Vt(i,o,!0);n.push(t.html),o=t.index;continue}if(/^\s*<[a-zA-Z]/.test(e)){let t=e;if(o++,It.test(e.match(/<(\w+)/)?.[1]||"")){n.push(t);continue}for(;o<i.length&&!At(i[o]);)t+="\n"+i[o],o++;n.push(t);continue}const h=[];for(;o<i.length&&!At(i[o])&&!/^(#{1,6}\s|`{3,}|~{3,}|>|\||(\s*)([-*+]|\d+\.)\s|(\*{3,}|-{3,}|_{3,})\s*$)/.test(i[o]);)h.push(i[o]),o++;if(h.length>0){const t=Wt(h.join("\n"));n.push(`<${s}>${t}</${s}>`)}else n.push(`<${s}>${Wt(i[o])}</${s}>`),o++}var r;return n.join("")}},Gt=/<!--\[if[^>]*>[\s\S]*?<!\[endif\]-->/gi,Kt=/<\/?(?:\w+:)\w+[^>]*>/gi,Yt=/<xml>[\s\S]*?<\/xml>/gi,Xt=/<style[^>]*>[\s\S]*?<\/style>/gi,Zt=/\s*mso-[^:]+:[^;"]+;?/gi,Jt=/l(\d+)\s+level(\d+)\s+lfo(\d+)/i,Qt=/mso-list:\s*Ignore/i,te=/\bMso\w+/g,ee=/\bxl\d+/g,se=/\s*tab-stops:[^;"]+;?/gi,ie=/^[\s\u00a0]*[\u2022\u00b7\u00a7\u25cf\u25cb\u25aa\u25a0·o§]\s*/,ne=[/^\s*[0-9]+[.)]\s/,/^\s*[a-z][.)]\s/i,/^\s*[ivxlmcd]+[.)]\s/i],oe=/<span\s+style\s*=\s*["']?\s*mso-spacerun:\s*yes\s*;?\s*["']?\s*>([\s\u00a0]*)<\/span>/gi,re=/<span\s+style\s*=\s*["'][^"']*mso-tab-count:\s*\d+[^"']*["']\s*>[^<]*<\/span>/gi,le=/mso-outline-level:\s*(\d+)/i,ae=/mso-highlight:\s*([^;"]+)/i,he=/mso-level-number-format:\s*([^;\s]+)/i,ce=/mso-level-start-at:\s*(\d+)/i,de=/mso-level-text:\s*([^;\s]+)/i,ue={decimal:"decimal","alpha-upper":"upper-alpha","alpha-lower":"lower-alpha","roman-upper":"upper-roman","roman-lower":"lower-roman","arabic-leading-zero":"decimal-leading-zero"},pe=/\s*margin:\s*0[a-z]*\s+0[a-z]*\s+0[a-z]*\s*;?/gi,ge=/\s*text-indent:\s*-?[\d.]+[a-z]*\s*;?/gi,me=/\s*line-height:\s*normal\s*;?/gi,fe=/MsoHeading(\d)/i,ve=/^file:\/\/\//i,be=/^_(Toc|Ref|Hlt|Hlk)\d+$/i,ye=/^#_(Toc|Ref|Hlt|Hlk)\d+$/i,we=/page-break-before\s*:\s*always/i,Ce=/mso-break-type\s*:\s*section-break/i,_e=/mso-column-break-before\s*:\s*always/i,ke=/^(?:Word)?Section\d+$/i;function xe(t){const e=t.replace(/[\s\u00a0]+/g," ").trim();if(ie.test(e))return"ul";for(const t of ne)if(t.test(e))return"ol";return"ul"}function $e(t){const e=document.createTreeWalker(t,NodeFilter.SHOW_COMMENT,null),s=[];for(;e.nextNode();)s.push(e.currentNode);for(const t of s)t?.remove();const i=t.querySelectorAll("span");for(const t of i){const e=t.getAttribute("style")||"";Qt.test(e)&&t.remove()}t.firstChild&&3===t.firstChild.nodeType&&(t.firstChild.nodeValue=t.firstChild.nodeValue.replace(/^[\s\u00a0]+/,""))}function Se(t){const e=t.getAttribute("style");if(!e)return;let s=e;const i=ae.exec(s);!i||/background-color/i.test(s)||/background\s*:/i.test(s)||(s+=";background-color:"+i[1].trim()),s=s.replace(Zt,"").replace(se,"").replace(pe,"").replace(ge,"").replace(me,"").trim(),s=s.replace(/^;+|;+$/g,"").replace(/;{2,}/g,";").trim(),s?t.setAttribute("style",s):t.removeAttribute("style")}function Ee(t){const e=t.getAttribute("class");if(!e)return;const s=e.replace(te,"").replace(ee,"").trim();s?t.setAttribute("class",s):t.removeAttribute("class")}function Te(t){let e=t.previousSibling;for(;e;){if(1===e.nodeType)return e;if(3===e.nodeType&&e.nodeValue.trim())return null;e=e.previousSibling}return null}function Me(t,e){for(const s of t){const t=`l${s.listId}:level${s.level}`,i=e.get(t);if(i)s.type=i.type,s.listStyleType=i.listStyleType,s.startAt=i.startAt;else{const t=Be(s.el);s.type=xe(t),s.listStyleType="",s.startAt=1}}const s=t[0].el.parentNode,i=t[t.length-1].el.nextSibling,n=[];let o=null;for(const e of t){const{el:t,level:s,type:i,listStyleType:r,startAt:l}=e;$e(t),Se(t),Ee(t);const a=t.ownerDocument.createElement("li");for(;t.firstChild;)a.appendChild(t.firstChild);if(t.getAttribute("style")&&a.setAttribute("style",t.getAttribute("style")),0===n.length)o=Ne(t.ownerDocument,i,r,l),o.appendChild(a),n.push({listEl:o,level:s});else{const e=n[n.length-1].level;if(s>e){const e=n[n.length-1].listEl.lastElementChild,o=Ne(t.ownerDocument,i,r,l);o.appendChild(a),e?e.appendChild(o):n[n.length-1].listEl.appendChild(o),n.push({listEl:o,level:s})}else if(s<e){for(;n.length>1&&n[n.length-1].level>s;)n.pop();n[n.length-1].listEl.appendChild(a)}else n[n.length-1].listEl.appendChild(a)}t.remove()}o&&s.insertBefore(o,i)}function Ne(t,e,s,i){const n=t.createElement(e);return s&&(n.style.listStyleType=s),"ol"===e&&i>1&&n.setAttribute("start",String(i)),n}function Be(t){const e=t.querySelectorAll("span");for(const t of e){const e=t.getAttribute("style")||"";if(Qt.test(e))return t.textContent||""}return t.textContent?.substring(0,10)||""}const Ie={cleanHTML:function(t){if(!t)return"";const e=function(t){const e=new Map,s=t.match(/<style[^>]*>([\s\S]*?)<\/style>/i);if(!s)return e;const i=s[1],n=/@list\s+l(\d+):level(\d+)\s*\{([^}]*)\}/gi;let o;for(;null!==(o=n.exec(i));){const t=o[1],s=o[2],i=o[3],n=`l${t}:level${s}`,r=he.exec(i),l=ce.exec(i),a=de.exec(i);let h="ol",c="";if(r){const t=r[1].toLowerCase();if("bullet"===t||"image"===t){if(h="ul",a){const t=a[1].replace(/["%\\]/g,"");"·"===t||"·"===t?c="disc":"o"===t?c="circle":"§"!==t&&"§"!==t||(c="square")}}else c=ue[t]||""}e.set(n,{type:h,listStyleType:c,startAt:l?parseInt(l[1],10):1})}return e}(t);let s=t;s=s.replace(Xt,""),s=s.replace(Yt,""),s=s.replace(Gt,""),s=s.replace(Kt,""),s=s.replace(/<!--(?:Start|End)Fragment-->/gi,""),s=s.replace(/<(?:meta|link)[^>]*>/gi,""),s=s.replace(oe," "),s=s.replace(re," "),s=s.replace(/( ){2,}/g," "),s=s.replace(/\u00AD/g,"");const i=(new DOMParser).parseFromString(s,"text/html");!function(t){const e=t.body.querySelectorAll("del, .msoDel");for(const t of e)t.remove();const s=t.body.querySelectorAll("ins, .msoIns");for(let t=s.length-1;t>=0;t--){const e=s[t],i=e.parentNode;if(i){for(;e.firstChild;)i.insertBefore(e.firstChild,e);e.remove()}}const i=t.body.querySelectorAll('.MsoCommentReference, [style*="mso-comment-reference"]');for(const t of i)t.remove();const n=t.body.querySelectorAll(".MsoCommentText");for(const t of n)t.remove();const o=t.body.querySelectorAll('div[style*="mso-element:comment"]');for(const t of o)t.remove();const r=t.body.querySelectorAll('a[name^="_msocom"], a[name^="_msoanchor"]');for(const t of r)t.remove()}(i),function(t,e){const s=[],i=t.body.querySelectorAll("p, h1, h2, h3, h4, h5, h6");for(const t of i){const e=t.getAttribute("style")||"",i=t.getAttribute("class")||"",n=Jt.exec(e);(n||/MsoListParagraph/i.test(i))&&s.push({el:t,listId:n?n[1]:"0",level:n?parseInt(n[2],10):1,lfo:n?n[3]:"1"})}if(0===s.length)return;const n=[];let o=null;for(const t of s){const e=Te(t.el);o&&o.length>0&&e===o[o.length-1].el?o.push(t):(o=[t],n.push(o))}for(const t of n)Me(t,e)}(i,e),function(t){const e=t.body.querySelectorAll("p");for(const s of e){const e=s.getAttribute("style")||"",i=s.getAttribute("class")||"";let n=0;const o=le.exec(e);if(o&&(n=parseInt(o[1],10)),!n){const t=fe.exec(i);t&&(n=parseInt(t[1],10))}if(n>=1&&n<=6){const i=t.createElement("h"+n);for(;s.firstChild;)i.appendChild(s.firstChild);e&&i.setAttribute("style",e),s.replaceWith(i)}}}(i),function(t){const e=t.body.querySelectorAll("table");for(const t of e){Ee(t),t.removeAttribute("cellspacing"),t.removeAttribute("cellpadding");const e=t.querySelectorAll("col");for(const t of e)t.remove();const s=t.querySelectorAll("colgroup");for(const t of s)t.children.length||t.remove()}const s=t.body.querySelectorAll("tr");for(const t of s)t.removeAttribute("height");const i=t.body.querySelectorAll("td, th");for(const t of i){const e=t.getAttribute("valign");if(e){t.removeAttribute("valign");const s=t.getAttribute("style")||"";/vertical-align/i.test(s)||t.setAttribute("style",(s?s+";":"")+"vertical-align:"+e)}const s=t.children;if(1===s.length&&"P"===s[0].tagName){const e=s[0],i=e.getAttribute("class")||"";if(/MsoNormal/i.test(i)||!i){for(;e.firstChild;)t.insertBefore(e.firstChild,e);e.remove()}}}}(i),function(t){const e=t.body.querySelectorAll("a");for(let t=e.length-1;t>=0;t--){const s=e[t],i=s.getAttribute("href")||"",n=s.getAttribute("name")||"";if(ve.test(i)){const t=s.parentNode;if(t){for(;s.firstChild;)t.insertBefore(s.firstChild,s);s.remove()}}else if(be.test(n)){const t=s.parentNode;if(t){if(s.childNodes.length)for(;s.firstChild;)t.insertBefore(s.firstChild,s);s.remove()}}else if(ye.test(i)){const t=s.parentNode;if(t){for(;s.firstChild;)t.insertBefore(s.firstChild,s);s.remove()}}else s.removeAttribute("v:shapes")}}(i),function(t){const e=t.body.querySelectorAll("img");for(let t=e.length-1;t>=0;t--){const s=e[t],i=s.getAttribute("src")||"";ve.test(i)?s.remove():s.removeAttribute("v:shapes")}}(i),function(t){const e=t.body.querySelectorAll("br");for(let t=e.length-1;t>=0;t--){const s=e[t],i=s.getAttribute("style")||"";we.test(i)||Ce.test(i)||_e.test(i)?s.remove():(s.removeAttribute("style"),s.removeAttribute("clear"))}const s=t.body.querySelectorAll('div[class*="Section"]');for(let t=s.length-1;t>=0;t--){const e=s[t],i=e.getAttribute("class")||"";if(ke.test(i.trim())){const t=e.parentNode;if(t){for(;e.firstChild;)t.insertBefore(e.firstChild,e);e.remove()}}}}(i);const n=i.body.querySelectorAll("*");for(const t of n){Se(t),Ee(t),t.getAttribute("lang")&&t.removeAttribute("lang"),t.removeAttribute("v:shapes");const e=t.tagName.toLowerCase();"img"!==e&&"video"!==e&&"iframe"!==e&&"table"!==e&&"td"!==e&&"th"!==e&&(t.removeAttribute("width"),t.removeAttribute("height"))}!function(t){const e=t.querySelectorAll("span");for(let t=e.length-1;t>=0;t--){const s=e[t];if(!s.attributes.length||!s.getAttribute("style")&&!s.getAttribute("class")){const t=s.parentNode;if(t){for(;s.firstChild;)t.insertBefore(s.firstChild,s);t.removeChild(s)}}}}(i.body);const o=i.body.querySelectorAll("p");for(const t of o)t.textContent.trim()||t.querySelector("img, video, iframe, br, table")||t.remove();return i.body.innerHTML}},Le=$,Ae=N,Oe=U,Re=_t,ze=I,Pe={isShift:function(t){return t.shiftKey||16===t.keyCode},isCtrl:function(t){const e=t.code;return t.ctrlKey||t.metaKey||"MetaLeft"===e||"MetaRight"===e},isAlt:function(t){return t.altKey},isComposing:function(t){return t.isComposing||"Process"===t.key||229===t.keyCode},isBackspace:function(t){return"Backspace"===t},isTab:function(t){return"Tab"===t},isEnter:function(t){return"Enter"===t},isEsc:function(t){return"Escape"===t},isSpace:function(t){return"Space"===t},isDirectionKey:function(t){return $t.includes(t)},isRemoveKey:function(t){return St.includes(t)},isNonTextKey:function(t){return Et.includes(t)},isHistoryRelevantKey:function(t){return Tt.includes(t)},isDocumentTypeObserverKey:function(t){return Mt.includes(t)},isNonResponseKey:function(t){return Nt.includes(t)}},De=Bt,Fe=jt,He=Ie,qe={env:Le,unicode:Ae,converter:Oe,dom:Re,numbers:ze,keyCodeMap:Pe,clipboard:De,markdown:Fe,msOffice:He},We={redo:'<svg class="se-io" 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="m15 14 5-5-5-5" /><path d="M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13" /></svg>',undo:'<svg class="se-io" 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="M9 14 4 9l5-5" /><path d="M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11" /></svg>',bold:'<svg class="se-io" 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="M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8" /></svg>',underline:'<svg class="se-io" 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="M6 4v6a6 6 0 0 0 12 0V4" /><line x1="4" x2="20" y1="20" y2="20" /></svg>',italic:'<svg class="se-io" 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" ><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" /></svg>',strike:'<svg class="se-io" 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="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" /></svg>',subscript:'<svg class="se-io" 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="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" /></svg>',superscript:'<svg class="se-io" 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="m4 19 8-8" /><path d="m12 19-8-8" /><path d="M20 12h-4c0-1.5.442-2 1.5-2.5S20 8.334 20 7.002c0-.472-.17-.93-.484-1.29a2.105 2.105 0 0 0-2.617-.436c-.42.239-.738.614-.899 1.06" /></svg>',remove_color:'<svg class="se-io" 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="M10 2v2" /><path d="M14 2v4" /><path d="M17 2a1 1 0 0 1 1 1v9H6V3a1 1 0 0 1 1-1z" /><path d="M6 12a1 1 0 0 0-1 1v1a2 2 0 0 0 2 2h2a1 1 0 0 1 1 1v2.9a2 2 0 1 0 4 0V17a1 1 0 0 1 1-1h2a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1" /></svg>',remove_format:'<svg class="se-io" 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="M4 7V4h16v3" /><path d="M5 20h6" /><path d="M13 4 8 20" /><path d="m15 15 5 5" /><path d="m20 15-5 5" /></svg>',indent:'<svg class="se-io" 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 5H11" /><path d="M21 12H11" /><path d="M21 19H11" /><path d="m3 8 4 4-4 4" /></svg>',outdent:'<svg class="se-io" 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 5H11" /><path d="M21 12H11" /><path d="M21 19H11" /><path d="m7 8-4 4 4 4" /></svg>',expansion:'<svg class="se-io" 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="M8 3H5a2 2 0 0 0-2 2v3" /><path d="M21 8V5a2 2 0 0 0-2-2h-3" /><path d="M3 16v3a2 2 0 0 0 2 2h3" /><path d="M16 21h3a2 2 0 0 0 2-2v-3" /></svg>',reduction:'<svg class="se-io" 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="M8 3v3a2 2 0 0 1-2 2H3" /><path d="M21 8h-3a2 2 0 0 1-2-2V3" /><path d="M3 16h3a2 2 0 0 1 2 2v3" /><path d="M16 21v-3a2 2 0 0 1 2-2h3" /></svg>',code_block:'<svg class="se-io" 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="m10 9-3 3 3 3" /><path d="m14 15 3-3-3-3" /><rect x="3" y="3" width="18" height="18" rx="2" /></svg>',code_view:'<svg class="se-io" 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="m9 7-5 5 5 5" /><path d="m15 7 5 5-5 5" /></svg>',markdown_view:'<svg class="se-io" 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="M4 17V7l4 5 4-5v10" /><path d="M17 7v7" /><path d="M14 14l3 3l3-3" /></svg>',preview:'<svg class="se-io" 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="M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0" /><circle cx="12" cy="12" r="3" /></svg>',print:'<svg class="se-io" 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="M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2" /><path d="M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6" /><rect x="6" y="14" width="12" height="8" rx="1" /></svg>',template:'<svg class="se-io" 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="M8 2v4" /><path d="M12 2v4" /><path d="M16 2v4" /><rect width="16" height="18" x="4" y="4" rx="2" /><path d="M8 10h6" /><path d="M8 14h8" /><path d="M8 18h5" /></svg>',layout:'<svg class="se-io" 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" ><rect width="18" height="18" x="3" y="3" rx="2" /><path d="M3 9h18" /><path d="M9 21V9" /></svg>',ai:'<svg class="se-io" 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="M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z" /><path d="M20 2v4" /><path d="M22 4h-4" /><circle cx="4" cy="20" r="2" /></svg>',new_document:'<svg class="se-io" 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="M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z" /><path d="M14 2v5a1 1 0 0 0 1 1h5" /></svg>',select_all:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M8 9a1 1 0 0 1 1 -1h6a1 1 0 0 1 1 1v6a1 1 0 0 1 -1 1h-6a1 1 0 0 1 -1 -1l0 -6" /><path d="M12 20v.01" /><path d="M16 20v.01" /><path d="M8 20v.01" /><path d="M4 20v.01" /><path d="M4 16v.01" /><path d="M4 12v.01" /><path d="M4 8v.01" /><path d="M4 4v.01" /><path d="M8 4v.01" /><path d="M12 4v.01" /><path d="M16 4v.01" /><path d="M20 4v.01" /><path d="M20 8v.01" /><path d="M20 12v.01" /><path d="M20 16v.01" /><path d="M20 20v.01" /></svg>',line_height:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M3 8l3 -3l3 3" /><path d="M3 16l3 3l3 -3" /><path d="M6 5l0 14" /><path d="M13 6l7 0" /><path d="M13 12l7 0" /><path d="M13 18l7 0" /></svg>',paragraph_style:'<svg class="se-io" 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="M13 4v16" /><path d="M17 4v16" /><path d="M19 4H9.5a4.5 4.5 0 0 0 0 9H13" /></svg>',text_style:'<svg class="se-io" 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="M14 16.5a.5.5 0 0 0 .5.5h.5a2 2 0 0 1 0 4H9a2 2 0 0 1 0-4h.5a.5.5 0 0 0 .5-.5v-9a.5.5 0 0 0-.5-.5h-3a.5.5 0 0 0-.5.5V8a2 2 0 0 1-4 0V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v3a2 2 0 0 1-4 0v-.5a.5.5 0 0 0-.5-.5h-3a.5.5 0 0 0-.5.5Z" /></svg>',save:'<svg class="se-io" 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="M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z" /><path d="M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7" /><path d="M7 3v4a1 1 0 0 0 1 1h7" /></svg>',blockquote:'<svg class="se-io" 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="M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z" /><path d="M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z" /></svg>',arrow_down:'<svg class="se-io" 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="m6 9 6 6 6-6" /></svg>',align_justify:'<svg class="se-io" 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="M3 5h18" /><path d="M3 12h18" /><path d="M3 19h18" /></svg>',align_left:'<svg class="se-io" 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 5H3" /><path d="M15 12H3" /><path d="M17 19H3" /></svg>',align_right:'<svg class="se-io" 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 5H3" /><path d="M21 12H9" /><path d="M21 19H7" /></svg>',align_center:'<svg class="se-io" 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 5H3" /><path d="M17 12H7" /><path d="M19 19H5" /></svg>',align_top:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M4 4l16 0" /><path d="M9 10a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-2a2 2 0 0 1 -2 -2l0 -8" /></svg>',align_middle:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M4 12l5 0" /><path d="M15 12l5 0" /><path d="M9 8a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-2a2 2 0 0 1 -2 -2l0 -8" /></svg>',align_bottom:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M4 20l16 0" /><path d="M9 6a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-2a2 2 0 0 1 -2 -2l0 -8" /></svg>',format_float_none:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M4 6a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1l0 -4" /><path d="M4 15l16 0" /><path d="M4 19l16 0" /></svg>',format_float_left:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M4 6a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1l0 -4" /><path d="M14 7l6 0" /><path d="M14 11l6 0" /><path d="M4 15l16 0" /><path d="M4 19l16 0" /></svg>',format_float_right:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M14 6a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1l0 -4" /><path d="M4 7l6 0" /><path d="M4 11l6 0" /><path d="M4 15l16 0" /><path d="M4 19l16 0" /></svg>',format_float_center:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M9 6a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1l0 -4" /><path d="M4 7l1 0" /><path d="M4 11l1 0" /><path d="M19 7l1 0" /><path d="M19 11l1 0" /><path d="M4 15l16 0" /><path d="M4 19l16 0" /></svg>',font_color:'<svg class="se-io" 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="m6 16 6-12 6 12" /><path d="M8 12h8" /><path class="se-svg-color-helper" stroke-width="2.5" d="M4 20h16" /></svg>',background_color:'<svg class="se-io" 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" ><g transform="translate(1 -2) scale(0.9)" stroke-width="2.22"><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" /></g><path class="se-svg-color-helper" stroke-width="2.5" d="M4 20h16" /></svg>',list_bulleted:'<svg class="se-io" 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="M3 5h.01" /><path d="M3 12h.01" /><path d="M3 19h.01" /><path d="M8 5h13" /><path d="M8 12h13" /><path d="M8 19h13" /></svg>',list_numbered:'<svg class="se-io" 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="M11 5h10" /><path d="M11 12h10" /><path d="M11 19h10" /><path d="M4 4h1v5" /><path d="M4 9h2" /><path d="M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02" /></svg>',list_checked:'<svg class="se-io" 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="M13 5h8" /><path d="M13 12h8" /><path d="M13 19h8" /><path d="m3 17 2 2 4-4" /><rect x="3" y="4" width="6" height="6" rx="1" /></svg>',table:'<svg class="se-io" 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="M12 3v18" /><rect width="18" height="18" x="3" y="3" rx="2" /><path d="M3 9h18" /><path d="M3 15h18" /></svg>',table_header:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M3 5a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-14" /><path d="M9 3l-6 6" /><path d="M14 3l-7 7" /><path d="M19 3l-7 7" /><path d="M21 6l-4 4" /><path d="M3 10h18" /><path d="M10 10v11" /></svg>',table_properties:'<svg class="se-io" 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="M11.035 7.69a1 1 0 0 1 1.909.024l.737 1.452a1 1 0 0 0 .737.535l1.634.256a1 1 0 0 1 .588 1.806l-1.172 1.168a1 1 0 0 0-.282.866l.259 1.613a1 1 0 0 1-1.541 1.134l-1.465-.75a1 1 0 0 0-.912 0l-1.465.75a1 1 0 0 1-1.539-1.133l.258-1.613a1 1 0 0 0-.282-.866l-1.156-1.153a1 1 0 0 1 .572-1.822l1.633-.256a1 1 0 0 0 .737-.535z" /><rect x="3" y="3" width="18" height="18" rx="2" /></svg>',cell_properties:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M12 21h-7a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v7" /><path d="M3 10h18" /><path d="M10 3v18" /><path d="M17.001 19a2 2 0 1 0 4 0a2 2 0 1 0 -4 0" /><path d="M19.001 15.5v1.5" /><path d="M19.001 21v1.5" /><path d="M22.032 17.25l-1.299 .75" /><path d="M17.27 20l-1.3 .75" /><path d="M15.97 17.25l1.3 .75" /><path d="M20.733 20l1.3 .75" /></svg>',table_column:'<svg class="se-io" 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" ><rect width="18" height="18" x="3" y="3" rx="2" /><path d="M9 3v18" /><path d="M15 3v18" /></svg>',table_row:'<svg class="se-io" 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" ><rect width="18" height="18" x="3" y="3" rx="2" /><path d="M21 9H3" /><path d="M21 15H3" /></svg>',color_checked:'<svg class="se-io" 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="M20 6 9 17l-5-5" /></svg>',color_palette:'<svg class="se-io" 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="M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z" /><circle cx="13.5" cy="6.5" r=".5" fill="currentColor" /><circle cx="17.5" cy="10.5" r=".5" fill="currentColor" /><circle cx="6.5" cy="12.5" r=".5" fill="currentColor" /><circle cx="8.5" cy="7.5" r=".5" fill="currentColor" /></svg>',border_all:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M4 6a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2l0 -12" /><path d="M4 12l16 0" /><path d="M12 4l0 16" /></svg>',border_inside:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M4 12l16 0" /><path d="M12 4l0 16" /><path d="M4 4l0 .01" /><path d="M8 4l0 .01" /><path d="M16 4l0 .01" /><path d="M20 4l0 .01" /><path d="M4 8l0 .01" /><path d="M20 8l0 .01" /><path d="M4 16l0 .01" /><path d="M20 16l0 .01" /><path d="M4 20l0 .01" /><path d="M8 20l0 .01" /><path d="M16 20l0 .01" /><path d="M20 20l0 .01" /></svg>',border_horizontal:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M4 12l16 0" /><path d="M4 4l0 .01" /><path d="M8 4l0 .01" /><path d="M12 4l0 .01" /><path d="M16 4l0 .01" /><path d="M20 4l0 .01" /><path d="M4 8l0 .01" /><path d="M12 8l0 .01" /><path d="M20 8l0 .01" /><path d="M4 16l0 .01" /><path d="M12 16l0 .01" /><path d="M20 16l0 .01" /><path d="M4 20l0 .01" /><path d="M8 20l0 .01" /><path d="M12 20l0 .01" /><path d="M16 20l0 .01" /><path d="M20 20l0 .01" /></svg>',border_vertical:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M12 4l0 16" /><path d="M4 4l0 .01" /><path d="M8 4l0 .01" /><path d="M16 4l0 .01" /><path d="M20 4l0 .01" /><path d="M4 8l0 .01" /><path d="M20 8l0 .01" /><path d="M4 12l0 .01" /><path d="M8 12l0 .01" /><path d="M16 12l0 .01" /><path d="M20 12l0 .01" /><path d="M4 16l0 .01" /><path d="M20 16l0 .01" /><path d="M4 20l0 .01" /><path d="M8 20l0 .01" /><path d="M16 20l0 .01" /><path d="M20 20l0 .01" /></svg>',border_outside:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M4 6a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2l0 -12" /><path d="M12 8l0 .01" /><path d="M8 12l0 .01" /><path d="M12 12l0 .01" /><path d="M16 12l0 .01" /><path d="M12 16l0 .01" /></svg>',border_left:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M4 20l0 -16" /><path d="M8 4l0 .01" /><path d="M12 4l0 .01" /><path d="M16 4l0 .01" /><path d="M20 4l0 .01" /><path d="M12 8l0 .01" /><path d="M20 8l0 .01" /><path d="M8 12l0 .01" /><path d="M12 12l0 .01" /><path d="M16 12l0 .01" /><path d="M20 12l0 .01" /><path d="M12 16l0 .01" /><path d="M20 16l0 .01" /><path d="M8 20l0 .01" /><path d="M12 20l0 .01" /><path d="M16 20l0 .01" /><path d="M20 20l0 .01" /></svg>',border_top:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M4 4l16 0" /><path d="M4 8l0 .01" /><path d="M12 8l0 .01" /><path d="M20 8l0 .01" /><path d="M4 12l0 .01" /><path d="M8 12l0 .01" /><path d="M12 12l0 .01" /><path d="M16 12l0 .01" /><path d="M20 12l0 .01" /><path d="M4 16l0 .01" /><path d="M12 16l0 .01" /><path d="M20 16l0 .01" /><path d="M4 20l0 .01" /><path d="M8 20l0 .01" /><path d="M12 20l0 .01" /><path d="M16 20l0 .01" /><path d="M20 20l0 .01" /></svg>',border_right:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M20 4l0 16" /><path d="M4 4l0 .01" /><path d="M8 4l0 .01" /><path d="M12 4l0 .01" /><path d="M16 4l0 .01" /><path d="M4 8l0 .01" /><path d="M12 8l0 .01" /><path d="M4 12l0 .01" /><path d="M8 12l0 .01" /><path d="M12 12l0 .01" /><path d="M16 12l0 .01" /><path d="M4 16l0 .01" /><path d="M12 16l0 .01" /><path d="M4 20l0 .01" /><path d="M8 20l0 .01" /><path d="M12 20l0 .01" /><path d="M16 20l0 .01" /></svg>',border_bottom:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M20 20l-16 0" /><path d="M4 4l0 .01" /><path d="M8 4l0 .01" /><path d="M12 4l0 .01" /><path d="M16 4l0 .01" /><path d="M20 4l0 .01" /><path d="M4 8l0 .01" /><path d="M12 8l0 .01" /><path d="M20 8l0 .01" /><path d="M4 12l0 .01" /><path d="M8 12l0 .01" /><path d="M12 12l0 .01" /><path d="M16 12l0 .01" /><path d="M20 12l0 .01" /><path d="M4 16l0 .01" /><path d="M12 16l0 .01" /><path d="M20 16l0 .01" /></svg>',border_none:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M4 4l0 .01" /><path d="M8 4l0 .01" /><path d="M12 4l0 .01" /><path d="M16 4l0 .01" /><path d="M20 4l0 .01" /><path d="M4 8l0 .01" /><path d="M12 8l0 .01" /><path d="M20 8l0 .01" /><path d="M4 12l0 .01" /><path d="M8 12l0 .01" /><path d="M12 12l0 .01" /><path d="M16 12l0 .01" /><path d="M20 12l0 .01" /><path d="M4 16l0 .01" /><path d="M12 16l0 .01" /><path d="M20 16l0 .01" /><path d="M4 20l0 .01" /><path d="M8 20l0 .01" /><path d="M12 20l0 .01" /><path d="M16 20l0 .01" /><path d="M20 20l0 .01" /></svg>',horizontal_line:'<svg class="se-io" 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="M5 12h14" /></svg>',show_blocks:'<svg class="se-io" 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="M5 3a2 2 0 0 0-2 2" /><path d="M19 3a2 2 0 0 1 2 2" /><path d="M21 19a2 2 0 0 1-2 2" /><path d="M5 21a2 2 0 0 1-2-2" /><path d="M9 3h1" /><path d="M9 21h1" /><path d="M14 3h1" /><path d="M14 21h1" /><path d="M3 9v1" /><path d="M21 9v1" /><path d="M3 14v1" /><path d="M21 14v1" /></svg>',cancel:'<svg class="se-io" 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="M18 6 6 18" /><path d="m6 6 12 12" /></svg>',selection_remove:'<svg class="se-io" 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" ><rect width="18" height="18" x="3" y="3" rx="2" ry="2" /><path d="m15 9-6 6" /><path d="m9 9 6 6" /></svg>',image:'<svg class="se-io" 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" ><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.086-3.086a2 2 0 0 0-2.828 0L6 21" /></svg>',image_thumbnail:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M15 8h.01" /><path d="M3 6a3 3 0 0 1 3 -3h12a3 3 0 0 1 3 3v12a3 3 0 0 1 -3 3h-12a3 3 0 0 1 -3 -3v-12" /><path d="M3 16l5 -5c.928 -.893 2.072 -.893 3 0l5 5" /><path d="M14 14l1 -1c.928 -.893 2.072 -.893 3 0l3 3" /></svg>',video:'<svg class="se-io" 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="m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5" /><rect x="2" y="6" width="14" height="12" rx="2" /></svg>',video_thumbnail:'<svg class="se-io" 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" ><rect width="18" height="18" x="3" y="3" rx="2" /><path d="M7 3v18" /><path d="M3 7.5h4" /><path d="M3 12h18" /><path d="M3 16.5h4" /><path d="M17 3v18" /><path d="M17 7.5h4" /><path d="M17 16.5h4" /></svg>',link:'<svg class="se-io" 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="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" /></svg>',link_rel:'<svg class="se-io" 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="M9 17H7A5 5 0 0 1 7 7h2" /><path d="M15 7h2a5 5 0 1 1 0 10h-2" /><line x1="8" x2="16" y1="12" y2="12" /></svg>',math:'<svg class="se-io" 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="M18 7V5a1 1 0 0 0-1-1H6.5a.5.5 0 0 0-.4.8l4.5 6a2 2 0 0 1 0 2.4l-4.5 6a.5.5 0 0 0 .4.8H17a1 1 0 0 0 1-1v-2" /></svg>',unlink:'<svg class="se-io" 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="m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71" /><path d="m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71" /><line x1="8" x2="8" y1="2" y2="5" /><line x1="2" x2="5" y1="8" y2="8" /><line x1="16" x2="16" y1="19" y2="22" /><line x1="19" x2="22" y1="16" y2="16" /></svg>',merge_cell:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M3 7h1.948c1.913 0 3.705 .933 4.802 2.5a5.861 5.861 0 0 0 4.802 2.5h6.448" /><path d="M3 17h1.95a5.854 5.854 0 0 0 4.798 -2.5a5.854 5.854 0 0 1 4.798 -2.5h5.454" /><path d="M18 15l3 -3l-3 -3" /></svg>',split_cell:'<svg class="se-io se-io-sharp" 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="M8 19H5c-1 0-2-1-2-2V7c0-1 1-2 2-2h3"/><path d="M16 5h3c1 0 2 1 2 2v10c0 1-1 2-2 2h-3"/><line x1="12" x2="12" y1="4" y2="20"/></svg>',unmerge_cell:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M21 17h-5.397a5 5 0 0 1 -4.096 -2.133l-.514 -.734a5 5 0 0 0 -4.096 -2.133h-3.897" /><path d="M21 7h-5.395a5 5 0 0 0 -4.098 2.135l-.51 .73a5 5 0 0 1 -4.097 2.135h-3.9" /><path d="M18 10l3 -3l-3 -3" /><path d="M18 20l3 -3l-3 -3" /></svg>',caption:'<svg class="se-io" 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" ><rect width="18" height="14" x="3" y="5" rx="2" ry="2" /><path d="M7 15h4M15 15h2M7 11h2M13 11h4" /></svg>',edit:'<svg class="se-io" 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.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z" /><path d="m15 5 4 4" /></svg>',delete:'<svg class="se-io se-io-sharp" 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="M10 11v6"/><path d="M14 11v6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"/><path d="M3 6h18"/><path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></svg>',revert:'<svg class="se-io" 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="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" /><path d="M3 3v5h5" /><path d="M12 7v5l4 2" /></svg>',auto_size:'<svg class="se-io" 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="M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7" /><path d="M14 15H9v-5" /><path d="M16 3h5v5" /><path d="M21 3 9 15" /></svg>',resize:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M4 11v8a1 1 0 0 0 1 1h8m-9 -14v-1a1 1 0 0 1 1 -1h1m5 0h2m5 0h1a1 1 0 0 1 1 1v1m0 5v2m0 5v1a1 1 0 0 1 -1 1h-1" /><path d="M4 12h7a1 1 0 0 1 1 1v7" /></svg>',insert_row_below:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M20 6v4a1 1 0 0 1 -1 1h-14a1 1 0 0 1 -1 -1v-4a1 1 0 0 1 1 -1h14a1 1 0 0 1 1 1" /><path d="M12 15l0 4" /><path d="M14 17l-4 0" /></svg>',insert_row_above:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M4 18v-4a1 1 0 0 1 1 -1h14a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-14a1 1 0 0 1 -1 -1" /><path d="M12 9v-4" /><path d="M10 7l4 0" /></svg>',insert_column_left:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M14 4h4a1 1 0 0 1 1 1v14a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1v-14a1 1 0 0 1 1 -1" /><path d="M5 12l4 0" /><path d="M7 10l0 4" /></svg>',insert_column_right:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M6 4h4a1 1 0 0 1 1 1v14a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1v-14a1 1 0 0 1 1 -1" /><path d="M15 12l4 0" /><path d="M17 10l0 4" /></svg>',delete_row:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M20 6v4a1 1 0 0 1 -1 1h-14a1 1 0 0 1 -1 -1v-4a1 1 0 0 1 1 -1h14a1 1 0 0 1 1 1" /><path d="M10 16l4 4" /><path d="M10 20l4 -4" /></svg>',delete_column:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M6 4h4a1 1 0 0 1 1 1v14a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1v-14a1 1 0 0 1 1 -1" /><path d="M16 10l4 4" /><path d="M16 14l4 -4" /></svg>',fixed_column_width:'<svg class="se-io" 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="M4 12v-6a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v6" /><path d="M10 18h-7" /><path d="M21 18h-7" /><path d="M6 15l-3 3l3 3" /><path d="M18 15l3 3l-3 3" /></svg>',rotate_left:'<svg class="se-io" 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="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" /><path d="M3 3v5h5" /></svg>',rotate_right:'<svg class="se-io" 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 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8" /><path d="M21 3v5h-5" /></svg>',mirror_horizontal:'<svg class="se-io" 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="m3 7 5 5-5 5V7" /><path d="m21 7-5 5 5 5V7" /><path d="M12 20v2" /><path d="M12 14v2" /><path d="M12 8v2" /><path d="M12 2v2" /></svg>',mirror_vertical:'<svg class="se-io" 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="m17 3-5 5-5-5h10" /><path d="m17 21-5-5-5 5h10" /><path d="M4 12H2" /><path d="M10 12H8" /><path d="M16 12h-2" /><path d="M22 12h-2" /></svg>',checked:'<svg class="se-io" 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="M20 6 9 17l-5-5" /></svg>',line_break:'<svg class="se-io" 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="M20 4v7a4 4 0 0 1-4 4H4" /><path d="m9 10-5 5 5 5" /></svg>',audio:'<svg class="se-io" 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="M9 18V5l12-2v13" /><circle cx="6" cy="18" r="3" /><circle cx="18" cy="16" r="3" /></svg>',audio_thumbnail:'<svg class="se-io" 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="M4 6.835V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-.343" /><path d="M14 2v5a1 1 0 0 0 1 1h5" /><path d="M2 19a2 2 0 0 1 4 0v1a2 2 0 0 1-4 0v-4a6 6 0 0 1 12 0v4a2 2 0 0 1-4 0v-1a2 2 0 0 1 4 0" /></svg>',image_gallery:'<svg class="se-io" 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="m22 11-1.296-1.296a2.4 2.4 0 0 0-3.408 0L11 16" /><path d="M4 8a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2" /><circle cx="13" cy="7" r="1" fill="currentColor" /><rect x="8" y="2" width="14" height="14" rx="2" /></svg>',audio_gallery:'<svg class="se-io" 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="M16 5H3" /><path d="M11 12H3" /><path d="M11 19H3" /><path d="M21 16V5" /><circle cx="18" cy="16" r="3" /></svg>',video_gallery:'<svg class="se-io" 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="m12.296 3.464 3.02 3.956" /><path d="M20.2 6 3 11l-.9-2.4c-.3-1.1.3-2.2 1.3-2.5l13.5-4c1.1-.3 2.2.3 2.5 1.3z" /><path d="M3 11h18v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z" /><path d="m6.18 5.276 3.1 3.899" /></svg>',file_gallery:'<svg class="se-io" 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="M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8" /><path d="M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z" /><path d="M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1" /></svg>',file_browser:'<svg class="se-io" 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="m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2" /></svg>',bookmark:'<svg class="se-io" 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="M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z" /></svg>',bookmark_anchor:'<svg class="se-io" 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="M12 6v16" /><path d="m19 13 2-1a9 9 0 0 1-18 0l2 1" /><path d="M9 11h6" /><circle cx="12" cy="4" r="2" /></svg>',download:'<svg class="se-io" 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="M12 15V3" /><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" /><path d="m7 10 5 5 5-5" /></svg>',dir_ltr:'<svg class="se-io" 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="M10 3v11" /><path d="M10 9H7a1 1 0 0 1 0-6h8" /><path d="M14 3v11" /><path d="m18 14 4 4H2" /><path d="m22 18-4 4" /></svg>',dir_rtl:'<svg class="se-io" 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="M14 3v11" /><path d="M14 9h-3a3 3 0 0 1 0-6h9" /><path d="M18 3v11" /><path d="M22 18H2l4-4" /><path d="m6 22-4-4" /></svg>',dragHandle:'<svg class="se-io" 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" ><circle cx="9" cy="12" r="1" /><circle cx="9" cy="5" r="1" /><circle cx="9" cy="19" r="1" /><circle cx="15" cy="12" r="1" /><circle cx="15" cy="5" r="1" /><circle cx="15" cy="19" r="1" /></svg>',file_upload:'<svg class="se-io" 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="M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z" /><path d="M14 2v5a1 1 0 0 0 1 1h5" /><path d="M12 12v6" /><path d="m15 15-3-3-3 3" /></svg>',file_thumbnail:'<svg class="se-io" 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="M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z" /><path d="M14 2v5a1 1 0 0 0 1 1h5" /></svg>',file_plus:'<svg class="se-io" 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="M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z" /><path d="M14 2v5a1 1 0 0 0 1 1h5" /><path d="M9 15h6" /><path d="M12 18v-6" /></svg>',upload_tray:'<svg class="se-io" 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="M12 3v12" /><path d="m17 8-5-5-5 5" /><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" /></svg>',folder:'<svg class="se-io" 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="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z" /></svg>',plus:'<svg class="se-io" 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="M5 12h14" /><path d="M12 5v14" /></svg>',minus:'<svg class="se-io" 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="M5 12h14" /></svg>',selection:'<svg class="se-io" 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="M5 3a2 2 0 0 0-2 2" /><path d="M19 3a2 2 0 0 1 2 2" /><path d="M21 19a2 2 0 0 1-2 2" /><path d="M5 21a2 2 0 0 1-2-2" /><path d="M9 3h1" /><path d="M9 21h1" /><path d="M14 3h1" /><path d="M14 21h1" /><path d="M3 9v1" /><path d="M21 9v1" /><path d="M3 14v1" /><path d="M21 14v1" /></svg>',copy:'<svg class="se-io se-io-sharp" 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" ><rect width="14" height="14" x="8" y="8" rx="2" ry="2" /><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" /></svg>',cut:'<svg class="se-io" 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" ><circle cx="6" cy="6" r="3" /><path d="M8.12 8.12 12 12" /><path d="M20 4 8.12 15.88" /><circle cx="6" cy="18" r="3" /><path d="M14.8 14.8 20 20" /></svg>',PDF:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M14 3v4a1 1 0 0 0 1 1h4" /><path d="M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4" /><path d="M5 18h1.5a1.5 1.5 0 0 0 0 -3h-1.5v6" /><path d="M17 18h2" /><path d="M20 15h-3v6" /><path d="M11 15v6h1a2 2 0 0 0 2 -2v-2a2 2 0 0 0 -2 -2h-1" /></svg>',format_paint:'<svg class="se-io" 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="m14.622 17.897-10.68-2.913" /><path d="M18.376 2.622a1 1 0 1 1 3.002 3.002L17.36 9.643a.5.5 0 0 0 0 .707l.944.944a2.41 2.41 0 0 1 0 3.408l-.944.944a.5.5 0 0 1-.707 0L8.354 7.348a.5.5 0 0 1 0-.707l.944-.944a2.41 2.41 0 0 1 3.408 0l.944.944a.5.5 0 0 0 .707 0z" /><path d="M9 8c-1.804 2.71-3.97 3.46-6.583 3.948a.507.507 0 0 0-.302.819l7.32 8.883a1 1 0 0 0 1.185.204C12.735 20.405 16 16.792 16 15" /></svg>',drawing:'<svg class="se-io" 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="m11 10 3 3" /><path d="M6.5 21A3.5 3.5 0 1 0 3 17.5a2.62 2.62 0 0 1-.708 1.792A1 1 0 0 0 3 21z" /><path d="M9.969 17.031 21.378 5.624a1 1 0 0 0-3.002-3.002L6.967 14.031" /></svg>',eraser:'<svg class="se-io" 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 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21" /><path d="m5.082 11.09 8.828 8.828" /></svg>',search:'<svg class="se-io" 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 21-4.34-4.34" /><circle cx="11" cy="11" r="8" /></svg>',selection_search:'<svg class="se-io" 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="M3 7V5a2 2 0 0 1 2-2h2" /><path d="M17 3h2a2 2 0 0 1 2 2v2" /><path d="M21 17v2a2 2 0 0 1-2 2h-2" /><path d="M7 21H5a2 2 0 0 1-2-2v-2" /><circle cx="12" cy="12" r="3" /><path d="m16 16-1.9-1.9" /></svg>',embed:'<svg class="se-io" 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="M12 12h.01" /><path d="M16 12h.01" /><path d="m17 7 5 5-5 5" /><path d="m7 7-5 5 5 5" /><path d="M8 12h.01" /></svg>',finder:'<svg class="se-io" 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 5H3" /><path d="M10 12H3" /><path d="M10 19H3" /><circle cx="17" cy="15" r="3" /><path d="m21 19-1.9-1.9" /></svg>',regex:'<svg class="se-ci" xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M197-199q-56-57-86.5-130T80-482q0-80 30-153t87-130l57 57q-46 45-70 103.5T160-482q0 64 24.5 122.5T254-256l-57 57Zm140.5-58.5Q320-275 320-300t17.5-42.5Q355-360 380-360t42.5 17.5Q440-325 440-300t-17.5 42.5Q405-240 380-240t-42.5-17.5ZM519-440v-71l-61 36-40-70 61-35-61-35 40-70 61 36v-71h80v71l61-36 40 70-61 35 61 35-40 70-61-36v71h-80Zm244 241-57-57q46-45 70-103.5T800-482q0-64-24.5-122.5T706-708l57-57q56 57 86.5 130T880-482q0 80-30 153t-87 130Z"/></svg>',match_case:'<svg class="se-ci" xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="m131-252 165-440h79l165 440h-76l-39-112H247l-40 112h-76Zm139-176h131l-64-182h-4l-63 182Zm395 186q-51 0-81-27.5T554-342q0-44 34.5-72.5T677-443q23 0 45 4t38 11v-12q0-29-20.5-47T685-505q-23 0-42 9.5T610-468l-47-35q24-29 54.5-43t68.5-14q69 0 103 32.5t34 97.5v178h-63v-37h-4q-14 23-38 35t-53 12Zm12-54q35 0 59.5-24t24.5-56q-14-8-33.5-12.5T689-393q-32 0-50 14t-18 37q0 20 16 33t40 13Z"/></svg>',whole_word:'<svg class="se-ci" xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M40-199v-200h80v120h720v-120h80v200H40Zm342-161v-34h-3q-13 20-35 31.5T294-351q-49 0-77-25.5T189-446q0-42 32.5-68.5T305-541q23 0 42.5 3.5T381-526v-14q0-27-18.5-43T312-599q-21 0-39.5 9T241-564l-43-32q19-27 48-41t67-14q62 0 95 29.5t33 85.5v176h-59Zm-66-134q-32 0-49 12.5T250-446q0 20 15 32.5t39 12.5q32 0 54.5-22.5T381-478q-14-8-32-12t-33-4Zm185 134v-401h62v113l-3 40h3q3-5 24-25.5t66-20.5q64 0 101 46t37 106q0 60-36.5 105.5T653-351q-41 0-62.5-18T563-397h-3v37h-59Zm143-238q-40 0-62 29.5T560-503q0 37 22 66t62 29q40 0 62.5-29t22.5-66q0-37-22.5-66T644-598Z"/></svg>',swap_vert:'<svg class="se-io" 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 16-4 4-4-4" /><path d="M17 20V4" /><path d="m3 8 4-4 4 4" /><path d="M7 4v16" /></svg>',arrow_down_small:'<svg class="se-io" 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="m6 9 6 6 6-6" /></svg>',arrow_up_small:'<svg class="se-io" 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="m18 15-6-6-6 6" /></svg>',replaceText:'<svg class="se-ci" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" ><g stroke-width="0"></g><g stroke-linecap="round" stroke-linejoin="round"></g><g><path fill-rule="evenodd" clip-rule="evenodd" d="M3.221 3.739l2.261 2.269L7.7 3.784l-.7-.7-1.012 1.007-.008-1.6a.523.523 0 0 1 .5-.526H8V1H6.48A1.482 1.482 0 0 0 5 2.489V4.1L3.927 3.033l-.706.706zm6.67 1.794h.01c.183.311.451.467.806.467.393 0 .706-.168.94-.503.236-.335.353-.78.353-1.333 0-.511-.1-.913-.301-1.207-.201-.295-.488-.442-.86-.442-.405 0-.718.194-.938.581h-.01V1H9v4.919h.89v-.386zm-.015-1.061v-.34c0-.248.058-.448.175-.601a.54.54 0 0 1 .445-.23.49.49 0 0 1 .436.233c.104.154.155.368.155.643 0 .33-.056.587-.169.768a.524.524 0 0 1-.47.27.495.495 0 0 1-.411-.211.853.853 0 0 1-.16-.532zM9 12.769c-.256.154-.625.231-1.108.231-.563 0-1.02-.178-1.369-.533-.349-.355-.523-.813-.523-1.374 0-.648.186-1.158.56-1.53.374-.376.875-.563 1.5-.563.433 0 .746.06.94.179v.998a1.26 1.26 0 0 0-.792-.276c-.325 0-.583.1-.774.298-.19.196-.283.468-.283.816 0 .338.09.603.272.797.182.191.431.287.749.287.282 0 .558-.092.828-.276v.946zM4 7L3 8v6l1 1h7l1-1V8l-1-1H4zm0 1h7v6H4V8z"></path></g></svg>',relaceTextAll:'<svg class="se-ci" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><g stroke-width="0"></g><g stroke-linecap="round" stroke-linejoin="round"></g><g><path fill-rule="evenodd" clip-rule="evenodd" d="M11.6 2.677c.147-.31.356-.465.626-.465.248 0 .44.118.573.353.134.236.201.557.201.966 0 .443-.078.798-.235 1.067-.156.268-.365.402-.627.402-.237 0-.416-.125-.537-.374h-.008v.31H11V1h.593v1.677h.008zm-.016 1.1a.78.78 0 0 0 .107.426c.071.113.163.169.274.169.136 0 .24-.072.314-.216.075-.145.113-.35.113-.615 0-.22-.035-.39-.104-.514-.067-.124-.164-.187-.29-.187-.12 0-.219.062-.297.185a.886.886 0 0 0-.117.48v.272zM4.12 7.695L2 5.568l.662-.662 1.006 1v-1.51A1.39 1.39 0 0 1 5.055 3H7.4v.905H5.055a.49.49 0 0 0-.468.493l.007 1.5.949-.944.656.656-2.08 2.085zM9.356 4.93H10V3.22C10 2.408 9.685 2 9.056 2c-.135 0-.285.024-.45.073a1.444 1.444 0 0 0-.388.167v.665c.237-.203.487-.304.75-.304.261 0 .392.156.392.469l-.6.103c-.506.086-.76.406-.76.961 0 .263.061.473.183.631A.61.61 0 0 0 8.69 5c.29 0 .509-.16.657-.48h.009v.41zm.004-1.355v.193a.75.75 0 0 1-.12.436.368.368 0 0 1-.313.17.276.276 0 0 1-.22-.095.38.38 0 0 1-.08-.248c0-.222.11-.351.332-.389l.4-.067zM7 12.93h-.644v-.41h-.009c-.148.32-.367.48-.657.48a.61.61 0 0 1-.507-.235c-.122-.158-.183-.368-.183-.63 0-.556.254-.876.76-.962l.6-.103c0-.313-.13-.47-.392-.47-.263 0-.513.102-.75.305v-.665c.095-.063.224-.119.388-.167.165-.049.315-.073.45-.073.63 0 .944.407.944 1.22v1.71zm-.64-1.162v-.193l-.4.068c-.222.037-.333.166-.333.388 0 .1.027.183.08.248a.276.276 0 0 0 .22.095.368.368 0 0 0 .312-.17c.08-.116.12-.26.12-.436zM9.262 13c.321 0 .568-.058.738-.173v-.71a.9.9 0 0 1-.552.207.619.619 0 0 1-.5-.215c-.12-.145-.181-.345-.181-.598 0-.26.063-.464.189-.612a.644.644 0 0 1 .516-.223c.194 0 .37.069.528.207v-.749c-.129-.09-.338-.134-.626-.134-.417 0-.751.14-1.001.422-.249.28-.373.662-.373 1.148 0 .42.116.764.349 1.03.232.267.537.4.913.4zM2 9l1-1h9l1 1v5l-1 1H3l-1-1V9zm1 0v5h9V9H3zm3-2l1-1h7l1 1v5l-1 1V7H6z"></path></g></svg>',menu_arrow_down:'<svg class="se-io" 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="m6 9 6 6 6-6" /></svg>',menu_arrow_up:'<svg class="se-io" 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="m18 15-6-6-6 6" /></svg>',menu_arrow_right:'<svg class="se-io" 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="m9 18 6-6-6-6" /></svg>',menu_arrow_left:'<svg class="se-io" 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="m15 18-6-6 6-6" /></svg>',side_menu_hamburger:'<svg class="se-io" 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="M4 5h16" /><path d="M4 12h16" /><path d="M4 19h16" /></svg>',side_menu_folder:'<svg class="se-io" 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="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z" /></svg>',side_menu_folder_item:'<svg class="se-io" 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="m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2" /></svg>',side_menu_item:'<svg class="se-io" 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="M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z" /><path d="M14 2v5a1 1 0 0 0 1 1h5" /></svg>',side_menu_folder_plus:'<svg class="se-io" 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="M12 10v6" /><path d="M9 13h6" /><path d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z" /></svg>',alert_outline:'<svg class="se-io" 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" ><circle cx="12" cy="12" r="10" /><line x1="12" x2="12" y1="8" y2="12" /><line x1="12" x2="12.01" y1="16" y2="16" /></svg>',more_media:'<svg class="se-io" 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" ><rect width="18" height="18" x="3" y="3" rx="2" /><path d="M7 3v18" /><path d="M3 7.5h4" /><path d="M3 12h18" /><path d="M3 16.5h4" /><path d="M17 3v18" /><path d="M17 7.5h4" /><path d="M17 16.5h4" /></svg>',more_gallery:'<svg class="se-io" 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" ><rect width="7" height="7" x="3" y="3" rx="1" /><rect width="7" height="7" x="14" y="3" rx="1" /><rect width="7" height="7" x="14" y="14" rx="1" /><rect width="7" height="7" x="3" y="14" rx="1" /></svg>',more_folder:'<svg class="se-io" 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="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z" /></svg>',more_list:'<svg class="se-io" 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="M3 5h.01" /><path d="M3 12h.01" /><path d="M3 19h.01" /><path d="M8 5h13" /><path d="M8 12h13" /><path d="M8 19h13" /></svg>',more_file:'<svg class="se-io" 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="M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z" /><path d="M14 2v5a1 1 0 0 0 1 1h5" /></svg>',more_view:'<svg class="se-io" 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="M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0" /><circle cx="12" cy="12" r="3" /></svg>',more_page:'<svg class="se-io" 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="M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z" /><path d="M14 2v5a1 1 0 0 0 1 1h5" /><path d="M10 9H8" /><path d="M16 13H8" /><path d="M16 17H8" /></svg>',more_text:'<svg class="se-io" 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="M12 4v16" /><path d="M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2" /><path d="M9 20h6" /></svg>',more_paragraph:'<svg class="se-io" 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="M13 4v16" /><path d="M17 4v16" /><path d="M19 4H9.5a4.5 4.5 0 0 0 0 9H13" /></svg>',more_plus:'<svg class="se-io" 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="M5 12h14" /><path d="M12 5v14" /></svg>',more_horizontal:'<svg class="se-io" 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" ><circle cx="12" cy="12" r="1" /><circle cx="19" cy="12" r="1" /><circle cx="5" cy="12" r="1" /></svg>',more_vertical:'<svg class="se-io" 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" ><circle cx="12" cy="12" r="1" /><circle cx="12" cy="5" r="1" /><circle cx="12" cy="19" r="1" /></svg>',more_flag:'<svg class="se-io" 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="M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528" /></svg>',as_inline:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M8,7L13,17H3L8,7M3,3H21V5H3V3M21,15V17H14V15H21M3,19H21V21H3V19Z" /></svg>',as_block:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12,7L17,17H7L12,7M3,3H21V5H3V3M3,19H21V21H3V19Z" /></svg>',page_break:'<svg class="se-io" 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="m16 16-4 4-4-4" /><path d="M3 12h18" /><path d="m8 8 4-4 4 4" /></svg>',page_down:'<svg class="se-io" 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="M12 17V3" /><path d="m6 11 6 6 6-6" /><path d="M19 21H5" /></svg>',page_up:'<svg class="se-io" 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="M5 3h14" /><path d="m18 13-6-6-6 6" /><path d="M12 7v14" /></svg>',collapse_left:'<svg class="se-io" 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" ><rect width="18" height="18" x="3" y="3" rx="2" /><path d="M9 3v18" /><path d="m16 15-3-3 3-3" /></svg>',collapse_right:'<svg class="se-io" 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" ><rect width="18" height="18" x="3" y="3" rx="2" /><path d="M15 3v18" /><path d="m8 9 3 3-3 3" /></svg>',map:'<svg class="se-io" 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="M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z" /><path d="M15 5.764v15" /><path d="M9 3.236v15" /></svg>',magic_stick:'<svg class="se-io" 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.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72" /><path d="m14 7 3 3" /><path d="M5 6v4" /><path d="M19 14v4" /><path d="M10 2v2" /><path d="M7 8H3" /><path d="M21 16h-4" /><path d="M11 3H9" /></svg>',open_in_new:'<svg class="se-io" 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="M15 3h6v6" /><path d="M10 14 21 3" /><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6" /></svg>'};var Ue=s("cfbI"),Ve=s.n(Ue);function je(t,e,s,i,n){const o=new Map([["menuTray",s],["toolbar_main",t],["toolbar_buttonTray",t.querySelector(".se-btn-tray")],["toolbar_arrow",t.querySelector(".se-arrow")]]);return i&&(o.set("toolbar_sub_main",i),o.set("toolbar_sub_buttonTray",i.querySelector(".se-btn-tray")),o.set("toolbar_sub_arrow",i.querySelector(".se-arrow")),o.set("toolbar_sub_wrapper",i.parentElement.parentElement)),e&&(o.set("toolbar_wrapper",e.querySelector(".sun-editor")),o.set("_stickyDummy",e.querySelector(".se-toolbar-sticky-dummy"))),n&&o.set("statusbar_wrapper",n.querySelector(".sun-editor")),o}function Ge(t,e,s,i,n,o,r,l,a,h,c){const d=new Map([["key",c],["options",t.options],["originElement",t.target],["topArea",e],["container",e.querySelector(".se-container")],["wrapper",e.querySelector(".se-wrapper")],["wysiwygFrame",s],["wysiwyg",s],["codeWrapper",i],["code",n],["codeNumbers",i?.querySelector(".se-code-view-line")],["markdownWrapper",o],["markdown",r],["markdownNumbers",o?.querySelector(".se-markdown-view-line")],["lineBreaker_t",e.querySelector(".se-line-breaker-component-t")],["lineBreaker_b",e.querySelector(".se-line-breaker-component-b")],["blockHandleArea",h],["blockHandle",h?.querySelector(".se-block-handle")||null],["blockHandlePlus",h?.querySelector(".se-block-handle-plus")||null],["blockHandleDrag",h?.querySelector(".se-block-handle-drag")||null],["_stickyDummy",e.querySelector(".se-toolbar-sticky-dummy")],["_toolbarShadow",e.querySelector(".se-toolbar-shadow")],["_minHeight",B(s.style.minHeight||"65",0)],["isCodeView",!1],["isMarkdownView",!1],["isFullScreen",!1],["isReadOnly",!1],["isDisabled",!1],["isChanged",!1],["historyIndex",-1],["savedIndex",-1],["documentTypeInner",a.inner],["documentTypePage",a.page],["documentTypePageMirror",a.pageMirror]]);l&&Ke(l,d);const u=e.querySelector(".se-placeholder");u&&d.set("placeholder",u);const p=t.options.get("placeholder_line");return p&&d.set("placeholder_line",p),d}function Ke(t,e){t?e.set("statusbar",t):e.delete("statusbar");const s=t?t.querySelector(".se-navigation"):null,i=t?t.querySelector(".se-char-counter-wrapper"):null,n=t?t.querySelector(".se-char-counter-wrapper .se-char-counter"):null;s?e.set("navigation",s):e.delete("navigation"),i?e.set("charWrapper",i):e.delete("charWrapper"),n?e.set("charCounter",n):e.delete("charCounter");const o=t?t.querySelector(".se-word-counter-wrapper"):null,r=t?t.querySelector(".se-word-counter-wrapper .se-word-counter"):null;o?e.set("wordWrapper",o):e.delete("wordWrapper"),r?e.set("wordCounter",r):e.delete("wordCounter")}const Ye={BUTTON_LIST:[["undo","redo"],"|",["bold","underline","italic","strike","|","subscript","superscript"],"|",["removeFormat"],"|",["outdent","indent"],"|",["fullScreen","showBlocks","codeView"],"|",["preview","print"]],REQUIRED_FORMAT_LINE:"div",REQUIRED_ELEMENT_WHITELIST:"br|div",ELEMENT_WHITELIST:"p|pre|blockquote|h1|h2|h3|h4|h5|h6|ol|ul|li|hr|figure|figcaption|img|iframe|audio|video|source|table|colgroup|col|thead|tbody|tr|th|td|caption|a|b|strong|var|i|em|u|ins|s|span|strike|del|sub|sup|code|svg|path|details|summary",TEXT_STYLE_TAGS:"strong|span|font|b|var|i|em|u|ins|s|strike|del|sub|sup|mark|a|label|code|summary",SCOPE_SELECTION_TAGS:["td","table","li","ol","ul","pre","figcaption","blockquote","dl","dt","dd"],ATTRIBUTE_WHITELIST:"contenteditable|target|href|title|download|rel|src|alt|class|type|colspan|rowspan|width|height|controls|autoplay|loop|muted|poster|preload|playsinline|volume|crossorigin|disableRemotePlayback|controlsList|allowfullscreen|sandbox|loading|allow|referrerpolicy|frameborder|scrolling",FORMAT_LINE:"P|H[1-6]|LI|TH|TD|DETAILS",FORMAT_BR_LINE:"PRE",FORMAT_CLOSURE_BR_LINE:"",FORMAT_BLOCK:"BLOCKQUOTE|OL|UL|FIGCAPTION|TABLE|THEAD|TBODY|TR|CAPTION|DETAILS",FORMAT_CLOSURE_BLOCK:"TH|TD",ALLOWED_EMPTY_NODE_LIST:".se-component, pre, blockquote, hr, li, table, img, iframe, video, audio, canvas, details",SIZE_UNITS:["px","pt","em","rem"],CLASS_NAME:"^__se__|^se-|^katex|^MathJax|^language-",CLASS_MJX:"mjx-container|mjx-math|mjx-mrow|mjx-mi|mjx-mo|mjx-mn|mjx-msup|mjx-mfrac|mjx-munderover",EXTRA_TAG_MAP:{script:!1,style:!1,meta:!1,link:!1,"[a-z]+:[a-z]+":!1},CONTENT_STYLES:"background|background-clip|background-color|border|border-bottom|border-collapse|border-color|border-image|border-left-width|border-radius|border-right-width|border-spacing|border-style|border-top|border-width|box-shadow|box-sizing|caption-side|color|content|direction|display|position|float|font|font-family|font-size|font-style|font-weight|height|min-height|max-height|width|min-width|max-width|left|letter-spacing|line-height|list-style-position|list-style-type|margin|margin-block-end|margin-block-start|margin-bottom|margin-inline-end|margin-inline-start|margin-left|margin-right|margin-top|padding|padding-bottom|padding-inline-start|padding-left|padding-right|padding-top|outline|overflow|page-break-before|page-break-after|page-break-inside|rotate|rotateX|rotateY|table-layout|text-align|text-decoration|text-shadow|text-transform|top|text-indent|text-rendering|vertical-align|visibility|white-space|word-break|word-wrap",TAG_STYLES:{"@text":"font-family|font-size|color|background-color|width|height","@line":"text-align|margin|margin-left|margin-right|line-height","@component":"width|height|min-width","table|th|td":"border|border-[a-z]+|color|background-color|text-align|float|font-weight|text-decoration|font-style|vertical-align","table|td":"width",tr:"height",col:"width",caption:"text-align|caption-side","ol|ul":"list-style-type",figure:"display|width|height|padding|padding-bottom",figcaption:"margin|margin-top|margin-bottom|text-align","img|video|iframe":"transform|transform-origin|width|min-width|max-width|height|min-height|max-height|float|margin|margin-top",hr:""},RETAIN_STYLE_MODE:["repeat","always","none"]},Xe={value:"fixed",placeholder:!0,placeholder_line:!0,editableFrameAttributes:!0,width:!0,minWidth:!0,maxWidth:!0,innerWidth:"fixed",height:!0,minHeight:!0,maxHeight:!0,editorStyle:!0,iframe:"fixed",iframe_fullPage:"fixed",iframe_attributes:!0,iframe_cssFileName:!0,statusbar:!0,statusbar_showPathLabel:!0,statusbar_resizeEnable:"fixed",charCounter:!0,charCounter_max:!0,charCounter_label:!0,charCounter_type:!0,wordCounter:!0,wordCounter_label:!0},Ze={plugins:"fixed",excludedPlugins:"fixed",buttonList:"fixed",v2Migration:"fixed",strictMode:"fixed",mode:"fixed",blockHandle:"fixed",type:"fixed",theme:!0,lang:"fixed",fontSizeUnits:"fixed",allowedClassName:"fixed",closeModalOutsideClick:"fixed",copyFormatKeepOn:!0,syncTabIndent:!0,tabDisable:!0,autoLinkify:!0,autoStyleify:!0,retainStyleMode:!0,allowedExtraTags:"fixed",events:!0,__textStyleTags:"fixed",textStyleTags:"fixed",convertTextTags:"fixed",__tagStyles:"fixed",tagStyles:"fixed",textDirection:!0,reverseButtons:"fixed",historyStackDelayTime:!0,historyStackSize:"fixed",lineAttrReset:!0,printClass:!0,defaultLine:"fixed",defaultLineBreakFormat:!0,lineBreakClearStyle:!0,scopeSelectionTags:!0,__defaultElementWhitelist:"fixed",elementWhitelist:"fixed",elementBlacklist:"fixed",__defaultAttributeWhitelist:"fixed",attributeWhitelist:"fixed",attributeBlacklist:"fixed",__defaultFormatLine:"fixed",formatLine:"fixed",__defaultFormatBrLine:"fixed",formatBrLine:"fixed",__defaultFormatClosureBrLine:"fixed",formatClosureBrLine:"fixed",__defaultFormatBlock:"fixed",formatBlock:"fixed",__defaultFormatClosureBlock:"fixed",formatClosureBlock:"fixed",allowedEmptyTags:!0,toolbar_width:!0,toolbar_innerWidth:"fixed",toolbar_container:"fixed",toolbar_sticky:!0,toolbar_hide:!0,subToolbar:"fixed",statusbar_container:"fixed",shortcutsHint:!0,shortcutsDisable:"fixed",shortcuts:"fixed",fullScreenOffset:!0,previewTemplate:!0,printTemplate:!0,componentInsertBehavior:!0,defaultUrlProtocol:!0,allUsedStyles:"fixed",toastMessageTime:!0,icons:"fixed",freeCodeViewMode:!0,finder_panel:"fixed",finder_liveSearch:!0,__lineFormatFilter:!0,__pluginRetainFilter:!0,__listCommonStyle:"fixed",externalLibs:"fixed"},Je=Le._d;let Qe=0;function ts(t,e,s,i,n,o){if(!s||s.length<2)return;const r=e?.querySelector(".se-tooltip-text");for(let l,a,h,c,d,u,p,g,m,f,v,b,y,w,C=0;C<s.length;C+=2+w){if(w=0,l=s[C].split("+"),m=null,f=l.at(-1).trim?.(),f.startsWith("~"))m=t,f=l.pop().trim().substring(1);else if(f.startsWith("$~")){const t=l.pop().trim().substring(2).split(".");m=t[0],f=t[1]}else f.startsWith("$")?(w=1,f=s[C+2]):f="";h=c=d=u=p=g=a=null;for(const t of l)switch(t.trim()){case"c":h=!0;break;case"!":d=!0;break;case"s":c=!0;break;case"_":u=!0;break;case"=":g=!0;break;case"/":p=!0;break;default:a=t}a=a.split("|");for(let s=0,r=a.length;s<r;s++)b=h?a[s]+(c?"1000":""):a[s],i.has(b)||(y=n.indexOf(t),y=-1===y?"":ze.isOdd(y)?n[y+1]:n[y-1],y&&o.add(b),i.set(b,{c:h,s:c,edge:d,space:u,enter:p,textTrigger:g,plugin:m,command:t,method:f,r:y,type:e?.getAttribute("data-type"),button:e,key:b}));(v=s[C+1])&&(r&&es(r,c,v))}}function es(t,e,s){const i=Re.utils.createElement("SPAN",{class:"se-shortcut"},Le.cmdIcon+(e?Le.shiftIcon:"")+'+<span class="se-shortcut-key">'+s+"</span>"),n=t.querySelector(".se-shortcut");n?t.replaceChild(i,n):t.appendChild(i)}function ss(t,e){return[t,e].reduce(((t,e)=>{for(const s in e)t[s]=(e[s]||"").toLowerCase();return t}),{})}function is(t,e,s){const i=t.buttonList||Ye.BUTTON_LIST,n=new Map;if(e.length>1&&!t.toolbar_container&&!/inline|balloon/i.test(t.mode))throw Error('[SUNEDITOR.create.fail] In multi root, The "mode" option cannot be "classic" without using the "toolbar_container" option.');n.set("v2Migration",!!t.v2Migration),n.set("buttons",new Set(i.toString().split(","))),n.set("strictMode",{tagFilter:!0,formatFilter:!0,classFilter:!0,textStyleTagFilter:!0,attrFilter:!0,styleFilter:!0,..."boolean"==typeof t.strictMode?{}:t.strictMode}),n.set("freeCodeViewMode",!!t.freeCodeViewMode),n.set("finder_panel",!1!==t.finder_panel),n.set("finder_liveSearch",!1!==t.finder_liveSearch),n.set("__lineFormatFilter",t.__lineFormatFilter??!0),n.set("__pluginRetainFilter",t.__pluginRetainFilter??!0);const[o,r]=(t.mode||"classic").split(":");n.set("mode",o),n.set("_toolbar_bottom","bottom"===r&&/^(classic|inline)$/i.test(o)),n.set("blockHandle",t.blockHandle?"object"==typeof t.blockHandle?t.blockHandle:{}:null),n.set("type",t.type?.split(":")[0]||""),n.set("theme",t.theme||""),n.set("_themeClass",t.theme?` se-theme-${t.theme}`:""),n.set("_type_options",t.type?.split(":")[1]||""),n.set("externalLibs",t.externalLibs||{}),n.set("fontSizeUnits",Array.isArray(t.fontSizeUnits)&&t.fontSizeUnits.length>0?t.fontSizeUnits.map((t=>t.toLowerCase())):Ye.SIZE_UNITS),n.set("allowedClassName",new RegExp(`${t.allowedClassName&&"string"==typeof t.allowedClassName?t.allowedClassName+"|":""}${Ye.CLASS_NAME}`)),n.set("closeModalOutsideClick",!!t.closeModalOutsideClick),n.set("copyFormatKeepOn",!!t.copyFormatKeepOn),n.set("syncTabIndent",t.syncTabIndent??!0),n.set("autoLinkify",t.autoLinkify??!!s.link),n.set("autoStyleify",Array.isArray(t.autoStyleify)?t.autoStyleify:["bold","underline","italic","strike"]);let l=t.retainStyleMode||"repeat";"string"!=typeof l||Ye.RETAIN_STYLE_MODE.includes(l)||(console.error(`Invalid retainStyleMode: ${l}. Valid options are ${Ye.RETAIN_STYLE_MODE.join(", ")}. Using default 'repeat'.`),l="repeat"),n.set("retainStyleMode",l);const a={...Ye.EXTRA_TAG_MAP,...t.allowedExtraTags,"-":!0},h=Object.keys(a),c=h.filter((t=>a[t])).join("|"),d=h.filter((t=>!a[t])).join("|");n.set("_allowedExtraTag",c),n.set("_disallowedExtraTag",d),n.set("events",t.events||{}),n.set("textStyleTags",("string"==typeof t.__textStyleTags?t.__textStyleTags:Ye.TEXT_STYLE_TAGS)+(t.textStyleTags?"|"+t.textStyleTags:""));const u=ss({bold:"strong",underline:"u",italic:"em",strike:"del",subscript:"sub",superscript:"sup"},t.convertTextTags||{});n.set("convertTextTags",u),n.set("_textStyleTags",Object.values(u).concat(["span","li"])),n.set("tagStyles",[{...Ye.TAG_STYLES,...t.__tagStyles||{}},t.tagStyles||{}].reduce(((t,e)=>{for(const s in e)t[s]=e[s];return t}),{})),n.set("_defaultStyleTagMap",{strong:u.bold,b:u.bold,u:u.underline,ins:u.underline,em:u.italic,i:u.italic,del:u.strike,strike:u.strike,s:u.strike,sub:u.subscript,sup:u.superscript}),n.set("_styleCommandMap",ss(Oe.swapKeyValue(u),{strong:"bold",b:"bold",u:"underline",ins:"underline",em:"italic",i:"italic",del:"strike",strike:"strike",s:"strike",sub:"subscript",sup:"superscript"})),n.set("_defaultTagCommand",{bold:u.bold,underline:u.underline,italic:u.italic,strike:u.strike,subscript:u.sub,superscript:u.sup}),n.set("textDirection",t.textDirection??"ltr"),n.set("_rtl","rtl"===n.get("textDirection")),n.set("reverseCommands",["indent-outdent"].concat(t.reverseButtons||[])),n.set("_reverseCommandArray",("-"+n.get("reverseCommands").join("-")).split("-")),ze.isEven(n.get("_reverseCommandArray").length)&&console.warn('[SUNEDITOR.create.warning] The "reverseCommands" option is invalid, Shortcuts key may not work properly.'),n.set("historyStackDelayTime","number"==typeof t.historyStackDelayTime?t.historyStackDelayTime:400),n.set("historyStackSize","number"==typeof t.historyStackSize&&t.historyStackSize>0?t.historyStackSize:100),n.set("_editableClass","sun-editor-editable"+n.get("_themeClass")+(n.get("_rtl")?" se-rtl":"")+("document"===n.get("type")?" se-type-document-editable-a4":"")),n.set("lineAttrReset",["id"].concat(t.lineAttrReset&&"string"==typeof t.lineAttrReset?t.lineAttrReset.toLowerCase().split("|"):[])),n.set("printClass","string"==typeof t.printClass?t.printClass+" "+n.get("_editableClass"):null),n.set("defaultLine","string"==typeof t.defaultLine&&t.defaultLine.length>0?t.defaultLine:"p"),n.set("defaultLineBreakFormat",t.defaultLineBreakFormat||"line"),n.set("lineBreakClearStyle",!!t.lineBreakClearStyle),n.set("scopeSelectionTags",t.scopeSelectionTags||Ye.SCOPE_SELECTION_TAGS);const p=("string"==typeof t.elementWhitelist?t.elementWhitelist:"").toLowerCase(),g=n.get("externalLibs").mathjax?Ye.CLASS_MJX+"|":"";n.set("elementWhitelist",p+(p?"|":"")+g+n.get("_allowedExtraTag"));const m=(f=("string"==typeof t.elementBlacklist?t.elementBlacklist:"").toLowerCase(),v=(v=n.get("defaultLine")).toLowerCase(),f.split("|").filter((function(t){return t!==v||(console.warn(`[SUNEDITOR.constructor.createBlacklist.warn] defaultLine("<${v}>") cannot be included in the blacklist and will be removed.`),!1)})).join("|"));var f,v;if(n.set("elementBlacklist",m+(m?"|":"")+n.get("_disallowedExtraTag")),n.set("attributeWhitelist",t.attributeWhitelist&&"object"==typeof t.attributeWhitelist?t.attributeWhitelist:null),n.set("attributeBlacklist",t.attributeBlacklist&&"object"==typeof t.attributeBlacklist?t.attributeBlacklist:null),n.set("formatClosureBrLine",as(t.formatClosureBrLine,(t.__defaultFormatClosureBrLine="string"==typeof t.__defaultFormatClosureBrLine?t.__defaultFormatClosureBrLine:Ye.FORMAT_CLOSURE_BR_LINE).toLowerCase(),n.get("elementBlacklist"))),n.set("formatBrLine",as((t.formatBrLine||"")+"|"+n.get("formatClosureBrLine").str,(t.__defaultFormatBrLine="string"==typeof t.__defaultFormatBrLine?t.__defaultFormatBrLine:Ye.FORMAT_BR_LINE).toLowerCase(),n.get("elementBlacklist"))),n.set("formatLine",as(Ye.REQUIRED_FORMAT_LINE+"|"+(t.formatLine||"")+"|"+n.get("formatBrLine").str,(t.__defaultFormatLine="string"==typeof t.__defaultFormatLine?t.__defaultFormatLine:Ye.FORMAT_LINE).toLowerCase(),n.get("elementBlacklist"))),!n.get("formatLine").reg.test(n.get("defaultLine")))throw Error(`[SUNEDITOR.create.fail] The "defaultLine(${n.get("defaultLine")})" option must be included in the "formatLine(${n.get("formatLine").str})" option.`);n.set("formatClosureBlock",as(t.formatClosureBlock,(t.__defaultFormatClosureBlock="string"==typeof t.__defaultFormatClosureBlock?t.__defaultFormatClosureBlock:Ye.FORMAT_CLOSURE_BLOCK).toLowerCase(),n.get("elementBlacklist"))),n.set("formatBlock",as((t.formatBlock||"")+"|"+n.get("formatClosureBlock").str,(t.__defaultFormatBlock="string"==typeof t.__defaultFormatBlock?t.__defaultFormatBlock:Ye.FORMAT_BLOCK).toLowerCase(),n.get("elementBlacklist"))),n.set("allowedEmptyTags",Ye.ALLOWED_EMPTY_NODE_LIST+(t.allowedEmptyTags?", "+t.allowedEmptyTags:"")),n.set("__defaultElementWhitelist",Ye.REQUIRED_ELEMENT_WHITELIST+"|"+("string"==typeof t.__defaultElementWhitelist?t.__defaultElementWhitelist:Ye.ELEMENT_WHITELIST).toLowerCase()),n.set("__defaultAttributeWhitelist",("string"==typeof t.__defaultAttributeWhitelist?t.__defaultAttributeWhitelist:Ye.ATTRIBUTE_WHITELIST).toLowerCase()),n.set("_editorElementWhitelist","*"===n.get("elementWhitelist")?"*":function(t){const e=t.get("elementBlacklist").split("|"),s=(t.get("__defaultElementWhitelist")+"|"+t.get("elementWhitelist")+"|"+t.get("formatLine").str+"|"+t.get("formatBrLine").str+"|"+t.get("formatClosureBlock").str+"|"+t.get("formatClosureBrLine").str).replace(/(^\||\|$)/g,"").split("|").filter(((t,s,i)=>t&&i.indexOf(t)===s&&!e.includes(t)));return s.join("|")}(n)),n.set("toolbar_width",t.toolbar_width?ze.is(t.toolbar_width)?t.toolbar_width+"px":t.toolbar_width:"auto"),n.set("toolbar_innerWidth",t.toolbar_innerWidth?ze.is(t.toolbar_innerWidth)?t.toolbar_innerWidth+"px":t.toolbar_innerWidth:""),n.set("toolbar_container",t.toolbar_container&&!/inline/i.test(n.get("mode"))?"string"==typeof t.toolbar_container?Je.querySelector(t.toolbar_container):t.toolbar_container:null);const b=t.toolbar_sticky;/balloon/i.test(n.get("mode"))?(n.set("_toolbar_sticky",-1),n.set("_toolbar_sticky_offset",0),n.set("_toolbar_sticky_fixed",!1)):null!==b&&"object"==typeof b?(n.set("_toolbar_sticky",ze.get(b.top,0)),n.set("_toolbar_sticky_offset",ze.get(b.offset,0)),n.set("_toolbar_sticky_fixed","fixed"===b.position)):(n.set("_toolbar_sticky",void 0===b?0:ze.is(b)?b:-1),n.set("_toolbar_sticky_offset",0),n.set("_toolbar_sticky_fixed",!1)),n.set("toolbar_hide",!!t.toolbar_hide);let y=null;const w=t.subToolbar;w?.buttonList?.length>0&&(/balloon/.test(n.get("mode"))?console.warn('[SUNEDITOR.create.subToolbar.fail] When the "mode" option is "balloon-*", the "subToolbar" option is omitted.'):(n.set("_subMode",w.mode||"balloon"),n.set("toolbar_sub_width",w.width?ze.is(w.width)?w.width+"px":w.width:"auto"),y=n.get("_rtl")?w.buttonList.reverse():w.buttonList,n.set("buttons_sub",new Set(y.toString().split(",")))));const C=new Map;for(let s=0,i=e.length;s<i;s++)C.set(e[s].key,os(e[s].options||{},t));n.set("tabDisable",!!t.tabDisable),n.set("shortcutsHint",void 0===t.shortcutsHint||!!t.shortcutsHint);const _=void 0!==t.shortcutsDisable&&t.shortcutsDisable?{}:[{selectAll:["c+KeyA","A"],bold:["c+KeyB","B"],strike:["c+s+KeyS","S"],underline:["c+KeyU","U"],italic:["c+KeyI","I"],redo:["c+KeyY","Y","c+s+KeyZ","Z"],undo:["c+KeyZ","Z"],indent:["c+BracketRight","]"],outdent:["c+BracketLeft","["],save:["c+KeyS","S"],...n.get("finder_panel")?{finder:["c+KeyF","F"]}:{},link:["c+KeyK","K"],hr:["!+---+=+~shortcut",""],list_numbered:["!+1.+_+~shortcut",""],list_bulleted:["!+*.+_+~shortcut",""],_h1:["c+s+Digit1|Numpad1+$~blockStyle.applyHeaderByShortcut",""],_h2:["c+s+Digit2|Numpad2+$~blockStyle.applyHeaderByShortcut",""],_h3:["c+s+Digit3|Numpad3+$~blockStyle.applyHeaderByShortcut",""]},t.shortcuts||{}].reduce(((t,e)=>{for(const s in e)t[s]=e[s];return t}),{});n.set("shortcuts",_),n.set("fullScreenOffset",void 0===t.fullScreenOffset?0:ze.is(t.fullScreenOffset)?ze.get(t.fullScreenOffset,0):0),n.set("previewTemplate","string"==typeof t.previewTemplate?t.previewTemplate:null),n.set("printTemplate","string"==typeof t.printTemplate?t.printTemplate:null),n.set("componentInsertBehavior",["auto","select","line","none"].includes(t.componentInsertBehavior)?t.componentInsertBehavior:"auto"),n.set("defaultUrlProtocol","string"==typeof t.defaultUrlProtocol?t.defaultUrlProtocol:null);const k=n.get("externalLibs").codeMirror;k&&(n.set("codeMirror",k),k.src?n.set("codeMirrorEditor",!0):(console.warn("[SUNEDITOR.options.externalLibs.codeMirror.fail] The codeMirror option is set incorrectly. See: https://github.com/ARA-developer/suneditor/blob/develop/guide/external-libraries.md"),n.set("codeMirror",null))),n.set("__listCommonStyle",t.__listCommonStyle||["fontSize","color","fontFamily","fontWeight","fontStyle"]);const x=t.icons&&"object"==typeof t.icons?[We,t.icons].reduce(((t,e)=>{for(const s in e)t[s]=e[s];return t}),{}):We;n.set("icons",x);const $=new Set(Ye.CONTENT_STYLES.split("|")),S=n.get("__listCommonStyle");for(const t of Object.values(n.get("tagStyles"))){const e=t.split("|");for(let t=0,s=e.length;t<s;t++)$.add(e[t])}for(let t=0,e=S.length;t<e;t++)$.add(S[t]);const E=("string"==typeof t.allUsedStyles?t.allUsedStyles.split("|"):t.allUsedStyles)||[];for(let t=0,e=E.length;t<e;t++)$.add(E[t]);return n.set("allUsedStyles",$),n.set("toastMessageTime",{copy:1500,...t.toastMessageTime}),{o:n,i:x,l:t.lang||Ve(),v:t.value="string"==typeof t.value?t.value:null,buttons:n.get("_rtl")?i.reverse():i,subButtons:y,statusbarContainer:"string"==typeof t.statusbar_container?Je.querySelector(t.statusbar_container):t.statusbar_container,frameMap:C}}function ns(t,e){let s=null,i=null,n=null,o=null,r=null;if(t.get("statusbar")){if(e||=Re.utils.createElement("DIV",{class:"se-status-bar sun-editor-common"}),s=e.querySelector(".se-navigation")||Re.utils.createElement("DIV",{class:"se-navigation sun-editor-common"}),e.appendChild(s),t.get("wordCounter")){if(o=e.querySelector(".se-word-counter-wrapper")||Re.utils.createElement("DIV",{class:"se-word-counter-wrapper"}),t.get("wordCounter_label")){const e=o.querySelector(".se-word-label")||Re.utils.createElement("SPAN",{class:"se-word-label"});e.textContent=t.get("wordCounter_label"),o.appendChild(e)}r=o.querySelector(".se-word-counter")||Re.utils.createElement("SPAN",{class:"se-word-counter"}),r.textContent="0",o.appendChild(r),e.appendChild(o)}if(t.get("charCounter")){if(i=e.querySelector(".se-char-counter-wrapper")||Re.utils.createElement("DIV",{class:"se-char-counter-wrapper"}),t.get("wordCounter")&&-1===i.className.indexOf("se-with-word-counter")&&(i.className+=" se-with-word-counter"),t.get("charCounter_label")){const e=i.querySelector(".se-char-label")||Re.utils.createElement("SPAN",{class:"se-char-label"});e.textContent=t.get("charCounter_label"),i.appendChild(e)}if(n=i.querySelector(".se-char-counter")||Re.utils.createElement("SPAN",{class:"se-char-counter"}),n.textContent="0",i.appendChild(n),t.get("charCounter_max")>0){const e=i.querySelector(".se-char-max")||Re.utils.createElement("SPAN",{class:"se-char-max"});e.textContent=" / "+t.get("charCounter_max"),i.appendChild(e)}e.appendChild(i)}}return{statusbar:e,navigation:s,charWrapper:i,charCounter:n,wordWrapper:o,wordCounter:r}}function os(t,e){const s=new Map;s.set("_origin",t);const i=e.statusbar_container,n=void 0===t.value?e.value:t.value,o=void 0===t.placeholder?e.placeholder:t.placeholder,r=void 0===t.placeholder_line?e.placeholder_line:t.placeholder_line,l=void 0===t.editableFrameAttributes?e.editableFrameAttributes:t.editableFrameAttributes,a=void 0===t.width?e.width:t.width,h=void 0===t.minWidth?e.minWidth:t.minWidth,c=void 0===t.maxWidth?e.maxWidth:t.maxWidth,d=void 0===t.innerWidth?e.innerWidth:t.innerWidth,u=void 0===t.height?e.height:t.height,p=void 0===t.minHeight?e.minHeight:t.minHeight,g=void 0===t.maxHeight?e.maxHeight:t.maxHeight,m=void 0===t.editorStyle?e.editorStyle:t.editorStyle,f=void 0===t.iframe?e.iframe:t.iframe,v=void 0===t.iframe_fullPage?e.iframe_fullPage:t.iframe_fullPage,b=void 0===t.iframe_attributes?e.iframe_attributes:t.iframe_attributes,y=void 0===t.iframe_cssFileName?e.iframe_cssFileName:t.iframe_cssFileName,w=i||void 0===t.statusbar?e.statusbar:t.statusbar,C=i||void 0===t.statusbar_showPathLabel?e.statusbar_showPathLabel:t.statusbar_showPathLabel,_=!i&&(void 0===t.statusbar_resizeEnable?e.statusbar_resizeEnable:t.statusbar_resizeEnable),k=i||void 0===t.charCounter?e.charCounter:t.charCounter,x=i||void 0===t.charCounter_max?e.charCounter_max:t.charCounter_max,$=i||void 0===t.charCounter_label?e.charCounter_label:t.charCounter_label,S=i||void 0===t.charCounter_type?e.charCounter_type:t.charCounter_type,E=i||void 0===t.wordCounter?e.wordCounter:t.wordCounter,T=i||void 0===t.wordCounter_label?e.wordCounter_label:t.wordCounter_label;s.set("value",n),s.set("placeholder",o),s.set("placeholder_line",r),s.set("editableFrameAttributes",{spellcheck:"false",...l}),s.set("width",a?String(ze.is(a)?a+"px":a):"100%"),s.set("minWidth",h?String(ze.is(h)?h+"px":h):""),s.set("maxWidth",c?String(ze.is(c)?c+"px":c):""),s.set("innerWidth",d?String(ze.is(d)?d+"px":d):""),s.set("height",u?String(ze.is(u)?u+"px":u):"auto"),s.set("minHeight",p?String(ze.is(p)?p+"px":p):""),s.set("maxHeight",g?String(ze.is(g)?g+"px":g):""),s.set("editorStyle",m),s.set("_defaultStyles",Oe._setDefaultOptionStyle(s,"string"==typeof m?m:"")),s.set("iframe",!(!v&&!f)),s.set("iframe_fullPage",!!v),s.set("iframe_attributes",b||{}),s.set("iframe_cssFileName",f?("string"==typeof y?[y]:y)||["suneditor"]:null);const M=void 0===w||!!w;return s.set("statusbar",M),s.set("statusbar_showPathLabel",!!M&&("boolean"!=typeof C||C)),s.set("statusbar_resizeEnable",!!M&&(void 0===_||!!_)),s.set("charCounter",x>0||"boolean"==typeof k&&k),s.set("charCounter_max",ze.is(x)&&x>-1?1*x:null),s.set("charCounter_label","string"==typeof $?$.trim():null),s.set("charCounter_type","string"==typeof S?S:"char"),s.set("wordCounter","boolean"==typeof E&&E),s.set("wordCounter_label","string"==typeof T?T.trim():null),s}function rs(t,e,s,i,n){const o=i.get("_defaultStyles");s.style.cssText=o.top;const r=Re.utils.createElement(i.get("iframe")?"IFRAME":"DIV",{class:"se-wrapper-inner se-wrapper-wysiwyg"+("document"===e.get("type")?" se-type-document-iframe-a4":""),"data-root-key":t});if(i.get("iframe")){const t=r,e=i.get("iframe_attributes");let s=e.sandbox;if(s){const t=["allow-same-origin","allow-scripts"],e=s.split(/\s+/),i=t.filter((t=>!e.includes(t)));i.length>0&&(s=e.concat(i).join(" "))}else s="allow-same-origin allow-scripts";t.setAttribute("sandbox",s),t.setAttribute("frameBorder","0");for(const s in e)"sandbox"!==s&&t.setAttribute(s,e[s]);t.allowFullscreen=!0,t.setAttribute("scrolling","auto"===i.get("height")?"no":"auto"),t.style.cssText=o.frame}else r.setAttribute("contenteditable","true"),e.get("_rtl")&&(r.dir="rtl"),r.className+=" "+e.get("_editableClass"),r.style.cssText=o.frame+o.editor;const l=Re.utils.createElement("TEXTAREA",{id:n+"-code-viewer-"+(t||"default"),class:"se-wrapper-inner se-code-viewer",style:o.frame,autocomplete:"off"}),a=Re.utils.createElement("TEXTAREA",{id:n+"-markdown-viewer-"+(t||"default"),class:"se-wrapper-inner se-markdown-viewer",style:o.frame,autocomplete:"off"}),h=Re.utils.createElement("SPAN",{class:"se-placeholder"});return i.get("placeholder")&&(h.textContent=i.get("placeholder")),{bottomBar:ns(i,null),wysiwygFrame:r,codeView:l,markdownView:a,placeholder:h}}function ls(t,e,s){let i=null,n=!1;if(t.get("codeMirrorEditor")){const o=t.get("codeMirror"),r=[{mode:"htmlmixed",htmlMode:!0,lineNumbers:!0,lineWrapping:!1},o.options||{}].reduce(((t,e)=>{for(const s in e)t[s]=e[s];return t}),{});"auto"===e.get("height")&&(r.viewportMargin=1/0,r.height="auto");const l=s.style.cssText,a=o.src.fromTextArea(s,r);e.set("codeMirrorEditor",a),i=a.display.wrapper,i.style.cssText=l,n=!0}return t.set("hasCodeMirror",n),i?(Re.utils.removeItem(s),i.className+=" se-code-viewer-mirror",i):s}function as(t,e,s){const i=s.split("|"),n=(e+"|"+("string"==typeof t?t.toLowerCase():"")).replace(/^\||\|$/g,"").split("|").filter((t=>t&&!i.includes(t))).join("|");return{reg:new RegExp(`^(${n})$`,"i"),str:n}}function hs(t,e,s,i,n){const o=e?.[t];if(o){const e="function"==typeof o?o:o.constructor;return{className:o.className||e.className||"",title:n[o.title]||o.title||n[e.title]||e.title||t,command:t,type:o.type||e.type||"",icon:i[o.icon]||o.icon||i[e.icon]||e.icon||""}}const r=cs(s.get("_rtl"),i,n)[t];return r?{className:r[0],title:r[1],command:r[2],type:r[3],icon:r[4]}:null}function cs(t,e,s){return{bold:["",s.bold,"bold","",e.bold],underline:["",s.underline,"underline","",e.underline],italic:["",s.italic,"italic","",e.italic],strike:["",s.strike,"strike","",e.strike],subscript:["",s.subscript,"subscript","",e.subscript],superscript:["",s.superscript,"superscript","",e.superscript],removeFormat:["",s.removeFormat,"removeFormat","",e.remove_format],copyFormat:["",s.copyFormat,"copyFormat","",e.format_paint],indent:["se-icon-flip-rtl",s.indent,"indent","",t?e.outdent:e.indent],outdent:["se-icon-flip-rtl",s.outdent,"outdent","",t?e.indent:e.outdent],fullScreen:["se-code-view-enabled se-component-enabled",s.fullScreen,"fullScreen","",e.expansion],showBlocks:["",s.showBlocks,"showBlocks","",e.show_blocks],codeView:["se-code-view-enabled se-component-enabled",s.codeView,"codeView","",e.code_view],markdownView:["se-code-view-enabled se-component-enabled",s.markdownView,"markdownView","",e.markdown_view],undo:["se-component-enabled",s.undo,"undo","",e.undo],redo:["se-component-enabled",s.redo,"redo","",e.redo],preview:["se-component-enabled",s.preview,"preview","",e.preview],print:["se-component-enabled",s.print,"print","",e.print],copy:["",s.copy,"copy","",e.copy],dir:["",s[t?"dir_ltr":"dir_rtl"],"dir","",e[t?"dir_ltr":"dir_rtl"]],dir_ltr:["",s.dir_ltr,"dir_ltr","",e.dir_ltr],dir_rtl:["",s.dir_rtl,"dir_rtl","",e.dir_rtl],finder:["se-component-enabled",s.find,"finder","",e.finder],save:["se-component-enabled",s.save,"save","",e.save],newDocument:["se-component-enabled",s.newDocument,"newDocument","",e.new_document],selectAll:["se-component-enabled",s.selectAll,"selectAll_full","",e.select_all],pageBreak:["se-component-enabled",s.pageBreak,"pageBreak","",e.page_break],pageUp:["se-component-enabled",s.pageUp,"pageUp","",e.page_up],pageDown:["se-component-enabled",s.pageDown,"pageDown","",e.page_down],pageNavigator:["se-component-enabled","","pageNavigator","input",""]}}function ds(){const t=Re.utils.createElement("UL",{class:"se-menu-list"});return{div:Re.utils.createElement("DIV",{class:"se-btn-module se-btn-module-border"},t),ul:t}}function us(t,e,s,i,n,o,r){n||="";const l=Re.utils.createElement("LI"),a=e||"",h=/^INPUT|FIELD$/i.test(i),c="se-toolbar-separator-vertical"===t?Re.utils.createElement("DIV",{class:t,tabindex:"-1"},null):Re.utils.createElement(h?"DIV":"BUTTON",{class:"se-toolbar-btn se-btn se-tooltip"+(t?" "+t:""),"data-command":s,"data-type":i,"aria-label":a.replace(/<span .+<\/span>/,""),tabindex:"-1"});return h||c.setAttribute("type","button"),/^default\./i.test(n)&&(n=r[n.replace(/^default\./i,"")]),/^text\./i.test(n)&&(n=n.replace(/^text\./i,""),c.className+=" se-btn-more-text"),o&&(c.disabled=!0),/^FIELD$/i.test(i)&&Re.utils.addClass(l,"se-toolbar-hidden-btn"),a&&(n+=Re.utils.createTooltipInner(a)),n&&(c.innerHTML=n),l.appendChild(c),{li:l,button:c}}function ps(t,e,s,i){if(!t)return;const n=!1===e.inner;if(1===e.inner?.nodeType?t.appendChild(e.inner):t.innerHTML=n?"":(e.inner||s[e.icon]||e.icon||'<span class="se-icon-text">!</span>')+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+(i[e.title]||e.title)+"</span></span>",t.setAttribute("aria-label",e.title),e.type&&t.setAttribute("data-type",e.type),e.className&&(t.className+=" "+e.className),e.afterItem&&(Re.utils.addClass(e.afterItem,"se-toolbar-btn"),t.parentElement.appendChild(e.afterItem),Re.utils.addClass(t,"se-side-btn-a"),Re.utils.addClass(e.afterItem,"se-side-btn-after")),e.beforeItem&&(Re.utils.addClass(e.beforeItem,"se-toolbar-btn"),t.parentElement.insertBefore(e.beforeItem,t),e.afterItem?(Re.utils.addClass(t,"se-side-btn"),Re.utils.removeClass(t,"se-side-btn-a")):Re.utils.addClass(t,"se-side-btn-b"),Re.utils.addClass(e.beforeItem,"se-side-btn-before")),e.replaceButton&&(t.parentElement.appendChild(e.replaceButton),t.style.display="none"),!e.replaceButton&&/^INPUT$/i.test(t.getAttribute("data-type"))){const e=t.querySelector("input");e&&(Re.utils.addClass(e,"se-toolbar-btn"),e.setAttribute("data-command",t.getAttribute("data-command")),e.setAttribute("data-type",t.getAttribute("data-type")),t.hasAttribute("disabled")&&(e.disabled=!0))}}function gs(t,e,s,i,n,o){t=JSON.parse(JSON.stringify(t));const r=cs(s.get("_rtl"),i,n),l={},a=[],h=[];let c=null,d=null,u=null,p=null,g=null;const m=Re.utils.createElement("DIV",{class:"se-toolbar-more-layer"}),f=Re.utils.createElement("DIV",{class:"se-btn-tray"}),v=Re.utils.createElement("DIV",{class:"se-toolbar-separator-vertical"});t:for(let s,b,y,w,C,_=0;_<t.length;_++)if(s=!1,C="",w=t[_],p=ds(),"object"==typeof w){for(let f,v=0;v<w.length;v++){if(d=w[v],f=!1,u=e[d],/^%\d+/.test(d)&&0===v){w[0]=d.replace(/[^\d]/g,""),a.push(w),t.splice(_--,1);continue t}if("function"==typeof u)c=[u.className,u.title,d,u.type,u.innerHTML,u._disabled];else if("object"==typeof u){const t=u.constructor;c=[u.className||t.className,u.title||t.title,d,u.type||t.type,u.innerHTML||t.innerHTML,u._disabled||t._disabled]}else{if(/^-/.test(d)){C=d.substring(1),p.div.className+=" module-float-"+C;continue}if(/^#/.test(d)){"fix"===d.substring(1)&&(p.ul.className+=" se-menu-dir-fix");continue}if(/^:/.test(d)){f=!0;const t=d.match(/^:([^-]+)-([^-]+)/);y="__se__more_"+_;const e=t[1].trim(),s=t[2].trim();c=["se-btn-more",/^lang\./i.test(e)?n[e.replace(/^lang\./i,"")]:e,y,"MORE",s]}else"|"===d?c=["se-toolbar-separator-vertical","","","separator",""]:("copy"!==d||Le.isClipboardSupported||console.warn("[SUNEDITOR.constructor.warn] Clipboard is not supported in this browser. : [copy] button is not rendered."),c=r[d]);if(!c){if(!u)throw Error(`[SUNEDITOR.create.toolbar.fail] The button name of a plugin that does not exist. [${d}]`);u="object"==typeof u?u.constructor:u,c=[u.className,u.title,u.key,u.type,u.innerHTML,u._disabled]}}g=us(c[0],c[1],c[2],c[3],c[4],c[5],i),(s?b:p.ul).appendChild(g.li),u&&(l[d]?l[d].push(g.button):l[d]=[g.button],o&&h.push({button:g.button,plugin:u,key:d})),f&&(s=!0,b=Re.utils.createElement("DIV"),b.className="se-more-layer "+y,b.setAttribute("data-ref",y),b.innerHTML='<div class="se-more-form"><ul class="se-menu-list"'+(C?' style="float: '+C+';"':"")+"></ul></div>",m.appendChild(b),b=b.firstElementChild.firstElementChild)}f.appendChild(p.div)}else{if("|"===w){const t=v.cloneNode(!1);f.appendChild(t);continue}if(/^\/$/.test(w)){const t=Re.utils.createElement("DIV",{class:"se-btn-module-enter"});f.appendChild(t)}}switch(f.children.length){case 0:f.style.display="none";break;case 1:Re.utils.removeClass(f.firstElementChild,"se-btn-module-border")}var b,y;m.children.length>0&&f.appendChild(m),a.length>0&&a.unshift(t),b=f,y=s.get("toolbar_innerWidth"),b&&y&&("auto"!==y&&(b.style.maxWidth=y),b.style.width="max-content",b.style.marginLeft="auto",b.style.marginRight="auto");const w=Re.utils.createElement("DIV",{class:"se-toolbar sun-editor-common"+(s.get("shortcutsHint")?"":" se-shortcut-hide")},f);return s.get("toolbar_hide")&&(w.style.display="none"),{element:w,pluginCallButtons:l,responsiveButtons:a,buttonTray:f,updateButtons:h}}const ms=function(t,e){"object"!=typeof e&&(e={});const s={};if(e.plugins){const t=e.excludedPlugins||[],i=e.plugins,n=(Array.isArray(i)?i:Object.keys(i)).filter((e=>!t.includes(e))).map((t=>i[t]));for(let t,e=0,i=n.length;e<i;e++)t=n[e].default||n[e],s[t.key]=t}const i=is(e,t,s),n=i.o,o=i.i,r=i.l,l=Re.utils.createElement("DIV",{class:"se-loading-box sun-editor-common"},'<div class="se-loading-effect"></div>'),a="suneditor-"+ ++Qe,h=Re.utils.createElement("DIV",{class:"sun-editor sun-editor-carrier-wrapper sun-editor-common"+n.get("_themeClass")+(n.get("_rtl")?" se-rtl":"")}),c=Re.utils.createElement("DIV",{class:"se-menu-tray",popover:"manual"});h.appendChild(c);const d=Re.utils.createElement("INPUT",{type:"text",id:a+"-focus-temp",class:"__se__focus__temp__",autocomplete:"off","aria-hidden":"true",style:"position: fixed !important; top: -10000px !important; left: -10000px !important; display: block !important; width: 0 !important; height: 0 !important; margin: 0 !important; padding: 0 !important;"});d.tabIndex=-1,h.appendChild(d);const u=Re.utils.createElement("DIV",{class:"se-modal se-modal-area sun-editor-common",popover:"manual"}),p=Re.utils.createElement("DIV",{class:"se-modal-back"}),g=Re.utils.createElement("DIV",{class:"se-modal-inner"});u.appendChild(p),u.appendChild(g),h.appendChild(u);const m=Re.utils.createElement("DIV",{class:"se-alert se-modal-area sun-editor-common",style:"display: none;",popover:"manual"}),f=Re.utils.createElement("DIV",{class:"se-modal-back"}),v=Re.utils.createElement("DIV",{class:"se-modal-inner"});m.appendChild(f),m.appendChild(v),h.appendChild(m),h.appendChild(Re.utils.createElement("DIV",{class:"se-back-wrapper",popover:"manual"}));const b=l.cloneNode(!0);b.setAttribute("popover","manual"),h.appendChild(b);const y=Re.utils.createElement("DIV",{class:"se-drag-cursor",popover:"manual"});h.appendChild(y),Je.body.appendChild(h);let w=null,C=null;const _=gs(i.buttons,s,n,o,r,!1),k=_.element;k.style.visibility="hidden",/inline/i.test(n.get("mode"))?(k.className+=" se-toolbar-inline",k.style.width=n.get("toolbar_width")):/balloon/i.test(n.get("mode"))&&(k.className+=" se-toolbar-balloon",k.style.width=n.get("toolbar_width"),k.appendChild(Re.utils.createElement("DIV",{class:"se-arrow"}))),n.get("_toolbar_bottom")&&(k.className+=" se-toolbar-bottom"),i.subButtons&&(C=gs(i.subButtons,s,n,o,r,!1),w=C.element,w.style.visibility="hidden",w.className+=" se-toolbar-balloon se-toolbar-sub",w.style.width=n.get("toolbar_sub_width"),w.appendChild(Re.utils.createElement("DIV",{class:"se-arrow"})));const x=t[0].key||null,$=[],S=new Map,E=i.statusbarContainer;let T=null;for(let e=0,s=t.length;e<s;e++){const s=t[e],h=i.frameMap.get(s.key),c=Re.utils.createElement("DIV",{class:"sun-editor"+n.get("_themeClass")+(n.get("_rtl")?" se-rtl":"")}),d=Re.utils.createElement("DIV",{class:"se-container"}),u=!!n.get("blockHandle"),p=Re.utils.createElement("DIV",{class:"se-wrapper"+(u?" se-mode-block":"")+("document"===n.get("type")?" se-type-document":"")+(n.get("_type_options").includes("header")?" se-type-document-header":"")}),g=h.get("innerWidth");g&&"auto"!==g&&p.style.setProperty("--se-editor-inner-width",g),d.appendChild(Re.utils.createElement("DIV",{class:"se-toolbar-shadow"}));const m=rs(s.key,n,c,h,a),f=m.bottomBar.statusbar,v=m.wysiwygFrame,b=m.placeholder;let y=m.codeView;const w=Re.utils.createElement("DIV",{class:"se-line-breaker-component se-line-breaker-component-t",title:r.insertLine},o.line_break),C=Re.utils.createElement("DIV",{class:"se-line-breaker-component se-line-breaker-component-b",title:r.insertLine},o.line_break);p.appendChild(w),p.appendChild(C),b&&p.appendChild(b),d.appendChild(Re.utils.createElement("DIV",{class:"se-toolbar-sticky-dummy"})),d.appendChild(p),f&&(E?T||(E.appendChild(Re.utils.createElement("DIV",{class:"sun-editor"+n.get("_themeClass")},f)),T=f):d.appendChild(f)),d.appendChild(l.cloneNode(!0));const _=s.key||null;let k=null;if(n.get("buttons").has("codeView")){k=Re.utils.createElement("DIV",{class:"se-code-wrapper"},y),k.style.setProperty("display","none","important"),p.appendChild(k);const t=ls(n,h,y);if(y===t){const t=Re.utils.createElement("TEXTAREA",{id:a+"-code-view-line-"+(_||"default"),class:"se-code-view-line",readonly:"true",autocomplete:"off","aria-hidden":"true",tabindex:"-1"},null);k.insertBefore(t,y)}else y=t}let x=null,M=null;if(n.get("buttons").has("markdownView")){M=m.markdownView;const t=Re.utils.createElement("TEXTAREA",{id:a+"-markdown-view-line-"+(_||"default"),class:"se-markdown-view-line",readonly:"true",autocomplete:"off","aria-hidden":"true",tabindex:"-1"},null);x=Re.utils.createElement("DIV",{class:"se-markdown-wrapper"}),x.appendChild(t),x.appendChild(M),x.style.setProperty("display","none","important"),p.appendChild(x)}const N={inner:null,page:null,pageMirror:null};n.get("_type_options").includes("header")&&(N.inner=Re.utils.createElement("DIV",{class:"se-document-lines",style:`height: ${h.get("height")};`},'<div class="se-document-lines-inner"></div>')),n.get("_type_options").includes("page")&&(N.page=Re.utils.createElement("DIV",{class:"se-document-page"},null),N.pageMirror=Re.utils.createElement("DIV",{class:"sun-editor-editable se-document-page-mirror-a4",style:"position: absolute; width: 21cm; columns: 21cm; border: 0; overflow: hidden; height: auto; top: -10000px; left: -10000px;"},null));let B=null;if(u){B=Re.utils.createElement("DIV",{class:"se-block-handle-area"});const t=Re.utils.createElement("DIV",{class:"se-block-handle",popover:"manual"}),e=Re.utils.createElement("DIV",{class:"se-block-handle-btn se-block-handle-plus"},o.plus),s=Re.utils.createElement("DIV",{class:"se-block-handle-btn se-block-handle-drag"},o.dragHandle);t.appendChild(e),t.appendChild(s),B.appendChild(t)}c.appendChild(d),$.push(_),S.set(_,Ge({target:s.target,key:s.key,options:h},c,v,k,y,x,M,T||f,N,B,_))}const M=n.get("toolbar_container");if(M){const t=Re.utils.createElement("DIV",{class:"sun-editor"+n.get("_themeClass")+(n.get("_rtl")?" se-rtl":"")}),e=Re.utils.createElement("DIV",{class:"se-container"});e.appendChild(k),w&&e.appendChild(w),t.appendChild(e),M.appendChild(t),M.appendChild(Re.utils.createElement("DIV",{class:"se-toolbar-sticky-dummy"}))}else{const t=S.get(x).get("container");if(n.get("_toolbar_bottom")){const e=t.querySelector(".se-statusbar");t.insertBefore(k,e),w&&t.insertBefore(w,k)}else t.insertBefore(k,t.firstElementChild),w&&t.insertBefore(w,t.firstElementChild)}return{context:je(k,M,c,w,E),carrierWrapper:h,options:n,plugins:s,icons:o,lang:r,value:i.v,rootId:x,rootKeys:$,frameRoots:S,pluginCallButtons:_.pluginCallButtons,responsiveButtons:_.responsiveButtons,pluginCallButtons_sub:C?C.pluginCallButtons:[],responsiveButtons_sub:C?C.responsiveButtons:[]}},{_w:fs}=Le,vs=Math.floor(96/72*841.89105);const bs=class{#t;#e;#s;#i;#n;#o;#r;#l;#a;#h;#c;#d;#u;#p;#g;#m;#f=-1;#v=-1;#b=null;#y=null;#w=0;#C=0;#_=-1;#k=0;#x=[];#$=null;#S=0;#E=0;#T=new Map;#M=null;constructor(t,e){const s=t.$;if(this.#t=s.store,this.#e=s.context,this.#s=this.#t.get("isScrollable"),this.#i=s.offset,this.#n=s.selection,this.#o=s.toolbar,this.useHeader=s.options.get("_type_options").includes("header"),this.usePage=s.options.get("_type_options").includes("page"),this.#r=e,this.#l=e.get("wysiwyg"),this.#a=e.get("wysiwygFrame"),this.#h=e.get("documentTypeInner"),this.#p=e.get("documentTypePageMirror"),this.#p){const t=fs.getComputedStyle(this.#p);this.#g=ze.get(t.paddingTop),this.#m=ze.get(t.paddingBottom)}if(this.useHeader){const t=this._getHeaders(),e=this.#c=this.#h.querySelector(".se-document-lines-inner");let i="";for(let e,s=0,n=t.length;s<n;s++)e=t[s],i+=`<div class="se-doc-item se-doc-h${ze.get(e.nodeName)}" title="${e.textContent}">${e.textContent}</div>`;e.innerHTML=i,this.#b=e.querySelectorAll("div"),s.eventManager.addEvent(e,"click",this.#N.bind(this,this.#l))}this.usePage&&(this.#d=e.get("documentTypePage"),this.#u=s.plugins.pageNavigator)}reHeader(){if(!this.useHeader)return;const t=this._getHeaders(),e=this.#c,s=this.#b;for(let i,n,o,r=0,l=t.length;r<l;r++)if(i=t[r],n=`se-doc-h${ze.get(i.nodeName)}`,o=s[r],r<s.length)o.classList.contains(n)&&o.textContent===i.textContent||(o.textContent=o.title=i.textContent,o.className=`se-doc-item ${n}`);else{const t=document.createElement("div");t.className=`se-doc-item ${n}`,t.textContent=t.title=i.textContent,e.appendChild(t)}if(s.length>t.length)for(let i=t.length;i<s.length;i++)e.removeChild(s[i]);this.#b=e.querySelectorAll("div")}async rePage(t){this.#d&&(this.#M&&fs.clearTimeout(this.#M),this.#M=fs.setTimeout((async()=>{await Re.utils.waitForMediaLoad(this.#p,1500);const e=this.#l.scrollHeight>this.#p.scrollHeight?this.#l.scrollHeight-this.#p.scrollHeight:0,s=this.#p.scrollHeight+e,i=this.#l.querySelectorAll(".se-page-break");if(!t&&this.#_===s&&this.#k===i.length)return;this.#_=s,this.#k=i.length;let n=0;const o=[];if(i.length>0){n=i[0].offsetHeight;for(let t=0;t<i.length;t++)o.push({top:i[t].offsetTop,end:i[t].offsetTop+n/2})}const r=this.#s(this.#r)?this._getWWScrollTop():0,l=[{number:0,top:0}];for(let t=0;t<o.length;t++)l.push({number:0,top:o[t].top+n/2,isBreak:!0});this.#E=0;const a=this.#l.children,h=this.#p.children;this._initializeCache(h);const c=[0,...o.map((t=>t.end))],d=[...o.map((t=>t.top)),s];for(let t=0;t<c.length;t++){const e=d[t];let s=c[t],i=0===t;for(;s+=vs+(i?this.#g+this.#m:this.#g),i=!1,!(s>=e);)if(!l.some((t=>Math.abs(t.top-s)<3))){const t=this._calcPageBreakTop(s,a,h,l);if(null===t)break;l.push({number:0,top:t})}}if(0===l.length)return this.#$=null,this.#w=1,void this._displayCurrentPage();l.sort(((t,e)=>t.top-e.top)),this.#d.innerHTML="",this.#x=[];const u=this.#a.offsetWidth+1;for(let t,e=0;e<l.length&&(t=l[e].top,!(s<t));e++){const s=Re.utils.createElement("DIV",{style:`top:${t-r}px`,innerHTML:String(e+1)},`<div class="se-document-page-line" style="width: ${u}px;"></div>${e+1}`);this.#d.appendChild(s),this.#x.push(s)}this.#$=this.#d.querySelectorAll(".se-document-page-line"),this.#w=this.#x.length,this.#B(),this._displayCurrentPage()}),400))}_getDisplayPage(){return this.#s(this.#r)?this.#r.get("wysiwyg"):fs}_calcPageBreakTop(t,e,s,i){const{ci:n}=this._getElementAtPosition(t,s,i),o=s[n],r=e[n];if(!o||!r)return null;const l=t+(r.offsetTop-o.offsetTop)+(r.offsetHeight-o.offsetHeight)/2;return Math.round(l)}_initializeCache(t){this.#T.clear();for(let e=0,s=t.length;e<s;e++){const s=t[e],i=s.offsetTop,n=s.offsetHeight,o=i+n;this.#T.set(e,{top:i,height:n,bottom:o})}}_getElementAtPosition(t,e,s){let i=this.#E,n=e.length-1;if(i>0){const e=this.#T.get(i);e&&t<e.top&&(i=0)}for(;i<=n;){const o=Math.floor((i+n)/2),{top:r,height:l,bottom:a}=this.#T.get(o);if(t>=r&&t<=a){let i=o;if(s&&Re.utils.hasClass(e[i],"se-page-break")){i=i+1<e.length?i+1:Math.max(0,i-1);const s=this.#T.get(i);return this.#E=i,{ci:i,cm:t-s.bottom,ch:s.height}}return this.#E=i,{ci:i,cm:t-a,ch:l}}t<r?n=o-1:i=o+1}let o=e[i]?i:n;s&&Re.utils.hasClass(e[o],"se-page-break")&&(o=o+1<e.length?o+1:Math.max(0,o-1)),this.#E=o;const r=this.#T.get(o);return{ci:o,cm:t-r.bottom,ch:r.height}}resizePage(){const t=this.#a.offsetWidth+1,e=this.#a.offsetHeight+1;let s=!1;if(t===this.#f&&(s=e===this.#v))return;t>800?Re.utils.removeClass(this.#h,"se-document-responsible"):Re.utils.addClass(this.#h,"se-document-responsible"),this.#f=t,this.#v=e;const i=this.#$;for(let e=0,s=i?.length;e<s;e++)i[e].style.width=`${t}px`;s||this.rePage(!0),this._displayCurrentPage()}scrollPage(){const t=this.#S,e=this._getWWScrollTop();if(t===e)return;const s=this.#x,i=e-t;for(let t=0,e=s.length;t<e;t++)s[t].style.top=ze.get(s[t].style.top)-i+"px";this.#B(),this.#S=e,this._displayCurrentPage()}#B(){const t=this.#x;if(!t?.length)return;const e=this.#a.offsetHeight;for(let s=0,i=t.length;s<i;s++){const i=ze.get(t[s].style.top);t[s].style.display=i<0||i>e?"none":""}}scrollWindow(){this.#s(this.#r)||this._displayCurrentPage()}getCurrentPageNumber(){if(this.#w<=1)return 1;let t=0;if(this.#s(this.#r))t=this.#v/2;else{const e=this._getGlobalTop();if(t=fs.scrollY-e+vs/2,t<=0)return 1}const e=this.#x;for(let s=0,i=e.length;s<i;s++)if(e[s].offsetTop>=t)return this.#C=s;return this.#C=this.#w}pageUp(){const t=this.#C-1<=1?1:this.#C-1;this._movePage(t,!1)}pageDown(){const t=this.#C+1>this.#x.length?this.#x.length:this.#C+1;this._movePage(t,!1)}pageGo(t){t<1?t=1:t>this.#x.length&&(t=this.#x.length),this._movePage(t,!0)}on(t){if(!this.useHeader)return;if(this._is(t)||(t=this._findLinesHeader(t)),!t)return;const e=this._findItem(t);e&&(Re.utils.removeClass(this.#b,"active"),Re.utils.addClass(e,"active"))}onChangeText(t){if(!this.useHeader)return;if(!this._is(t))return;const e=this._findItem(t);e&&(e.textContent=t.textContent)}_displayCurrentPage(){const t=this.getCurrentPageNumber();this.#u?.display(t,this.#w)}_getWWScrollTop(){const t=this._getDisplayPage();return t.scrollTop||t.scrollY||0}_movePage(t,e){const s=this._getGlobalTop(),i=this.#s(this.#r),n=Oe.nodeListToArray(this.#l.children),o=this.#d.offsetTop+ze.get(this.#x[t-1].style.top)+(i?this._getWWScrollTop():0);for(let r,l=0,a=n.length;l<a;l++)if(r=n[l],r.offsetTop>=o){e||this.#n.setRange(r,0,r,0);const n=0===l&&i?0:r.offsetTop-this.#d.offsetTop-r.offsetHeight+s;this._applyPageScroll(n,(()=>{this.#o.isSticky&&!this.#t.mode.isBottom&&this._getDisplayPage().scrollTo({top:n-this.#e.get("toolbar_main").offsetHeight,behavior:"smooth"})})),this.#C=t;break}}_applyPageScroll(t,e){const s=this._getDisplayPage();s.scrollTo({top:t,behavior:"smooth"});const i=()=>{Math.abs((s.scrollY??s.scrollTop)-t)<1?e():fs.requestAnimationFrame(i)};fs.requestAnimationFrame(i)}_getGlobalTop(){return this.#s(this.#r)?0:this.#i.getGlobal(this.#a).top}_findItem(t){const e=this.#y,s=Array.prototype.indexOf.call(e,t);return-1!==s&&this.#b[s]?this.#b[s]:null}_findLinesHeader(t){for(;t&&t!==this.#l;){if(this._is(t))return t;t=t.previousElementSibling||t.parentElement}return null}_is(t){return/^h[1-6]$/i.test(t?.nodeName)}_getHeaders(){return this.#y=this.#l.querySelectorAll("h1, h2, h3, h4, h5, h6")}#N(t,e){e.preventDefault();try{this.#t.set("_preventBlur",!0);const t=Re.query.getEventTarget(e);if(Re.utils.hasClass(t,"se-doc-item")){const e=Array.prototype.indexOf.call(this.#b,t);if(-1===e)return;const s=this.#y[e];s&&this.#n.scrollTo(s)}}finally{this.#t.set("_preventBlur",!1)}}_destroy(){this.#M&&(fs.clearTimeout(this.#M),this.#M=null),this.#T&&(this.#T.clear(),this.#T=null),this.#r=null,this.#l=null,this.#a=null,this.#h=null,this.#c=null,this.#d=null,this.#x=null,this.#$=null,this.#b=null,this.#y=null,this.#u=null,this.#p=null}};const ys=class{#I;#L=new Map;constructor(t){const e=t.options,s=e.get("mode"),i=e.get("_subMode");this._editorInitFinished=!1,this.mode={isClassic:/classic/i.test(s),isInline:/inline/i.test(s),isBalloon:/balloon/i.test(s),isBalloonAlways:/balloon-always/i.test(s),isSubBalloon:/balloon/i.test(i),isSubBalloonAlways:/balloon-always/i.test(i),isBottom:!!e.get("_toolbar_bottom")},this.#I={rootKey:t.rootId,hasFocus:!1,tabSize:4,indentSize:25,codeIndentSize:2,currentNodes:[],currentNodesMap:[],initViewportHeight:0,currentViewportHeight:0,controlActive:!1,_lastSelectionNode:null,isScrollable:t=>{const e=t.get("options"),s=e.get("height"),i=e.get("maxHeight");return"auto"!==s||!!i&&t.get("wysiwyg").offsetHeight>=ze.get(i)},_range:null,_mousedown:!1,_preventBlur:!1,_preventFocus:!1,_canUseBeforeInput:!0}}get(t){return this.#I[t]}set(t,e){const s=this.#I[t];this.#I[t]=e,this.#A(t,e,s)}subscribe(t,e){return this.#L.has(t)||this.#L.set(t,new Set),this.#L.get(t).add(e),()=>this.#L.get(t).delete(e)}#A(t,e,s){const i=this.#L.get(t);if(i)for(const n of i)try{n(e,s)}catch(e){console.error(`[Store] Subscriber error for "${t}":`,e)}}_reset(){}_destroy(){this.#L.clear(),this.#I=null}},{_w:ws,_d:Cs}=Le;class _s{#O;#R;#z;constructor(t){this.#O=t.frameRoots,this.#R=this.#P(t.context),this.#z=this.#D({value:new Map}),this.rootKeys=t.rootKeys,this.carrierWrapper=t.carrierWrapper,this.icons=t.icons,this.lang=t.lang,this.shadowRoot=null}get frameRoots(){return this.#O}get context(){return this.#R}get frameContext(){return this.#z}init(){this.applyToRoots((t=>{this.#F(t)}))}reset(t){this.#z.reset(t)}applyToRoots(t){this.#O.forEach(t)}#F(t){const e=t.get("options");if(t.set("wwComputedStyle",ws.getComputedStyle(t.get("wysiwyg"))),!e.get("iframe")&&"function"==typeof ShadowRoot){let e=t.get("wysiwygFrame");for(;e;){if(e.shadowRoot){this.shadowRoot=e.shadowRoot;break}if(e instanceof ShadowRoot){this.shadowRoot=e;break}e=e.parentNode}}e.get("iframe")?(t.set("_ww",t.get("wysiwygFrame").contentWindow),t.set("_wd",t.get("wysiwygFrame").contentDocument),t.set("wysiwyg",t.get("_wd").body),e.get("_defaultStyles").editor&&(t.get("wysiwyg").style.cssText=e.get("_defaultStyles").editor),"auto"===e.get("height")&&t.set("_iframeAuto",t.get("_wd").body)):(t.set("_ww",ws),t.set("_wd",Cs));const s=e.get("editableFrameAttributes");for(const e in s)t.get("wysiwyg").setAttribute(e,s[e])}#P(t){const e=t;return{get:t=>e.get(t),set:(t,s)=>e.set(t,s),has:t=>e.has(t),delete:t=>e.delete(t),getAll:()=>Object.fromEntries(e.entries()),get size(){return e.size},clear(){e.clear()}}}#D(t){let e=t.value;return{get:t=>e.get(t),set:(t,s)=>e.set(t,s),has:t=>e.has(t),delete:t=>e.delete(t),getAll:()=>Object.fromEntries(e.entries()),reset(s){e=t.value=s},get size(){return e.size},clear(){e.clear()}}}_destroy(){this.applyToRoots((t=>{const e=t.get("documentType");e&&e._destroy(),Re.utils.removeItem(t.get("topArea")),t.get("options").clear(),t.clear()})),this.#R.clear(),this.#z.clear(),this.#O.clear(),Re.utils.removeItem(this.carrierWrapper),this.rootKeys=null,this.carrierWrapper=null,this.icons=null,this.lang=null,this.shadowRoot=null}}class ks{#H;#q;#W;#U;constructor(t,e,s){this.#H=t,this.#q=s,this.#W=this.#V({value:e.options}),this.#U=this.#j({value:new Map})}get options(){return this.#W}get frameOptions(){return this.#U}reset(t){const{$:e}=this.#H,s=e.frameRoots,i=e.context,n=e.eventManager,o=e.format,r=e.html,l=e.char,a=e.viewer,h=e.plugins,c=e.history,d=e.ui,u=this.#H._eventOrchestrator;a.codeView(!1),a.showBlocks(!1);const p=new Map,g=[],m=new Map,f={};for(const e in t)void 0!==Xe[e]&&(f[e]=t[e],delete t[e]);for(const e of s.keys())t[e||""]={...f,...t[e||""]};const v=Object.keys(t);if(this.#G(v,h,""),0===v.length)return;1===s.size&&v.unshift(null);const b=[this.#q,t].reduce(((t,e)=>{for(const i in e)s.has(i||null)?this.#K(i,e,s,p,m,g):t[i]=e[i];return t}),{}),y=this.#W,w=is(b,g,h),C=w.o,_=w.frameMap;for(let t,e=0,i=v.length;e<i;e++)if(t=v[e]||null,m.has(t)){const e=p.get(t),i=s.get(t),o=i.get("options"),r=_.get(t);for(const[t,e]of r.entries())o.set(t,e);if(e.has("statusbar-changed")){if(Re.utils.removeItem(i.get("statusbar")),r.get("statusbar")){const t=ns(r,null).statusbar;i.get("container").appendChild(t),Ke(t,i),u.__addStatusbarEvent(i,r)}else n.removeEvent(o.get("__statusbarEvent")),r.set("__statusbarEvent",null),Ke(null,i);i.get("statusbar")&&l.display(i)}if(e.has("iframe_attributes")){const t=i.get("wysiwygFrame"),e=o.get("iframe_attributes"),s=r.get("iframe_attributes");for(const s in e)t.removeAttribute(s);for(const e in s)t.setAttribute(e,s[e])}if(e.has("iframe_cssFileName")){const t=i.get("_wd").head,e=t.getElementsByTagName("link");for(;e[0];)t.removeChild(e[0]);const s=(new DOMParser).parseFromString(Oe._setIframeStyleLinks(r.get("iframe_cssFileName")),"text/html").head.children,n=t.querySelector("style");for(;s[0];)t.insertBefore(s[0],n)}if(e.has("placeholder")&&(i.get("placeholder").textContent=r.get("placeholder")),e.has("placeholder_line")){const t=r.get("placeholder_line");i.set("placeholder_line",t);const e=i.get("wysiwyg").querySelector(".se-placeholder-line");if(e){const s=d.resolveLinePlaceholder(e,t);s?e.setAttribute("data-se-placeholder-line",s):(e.classList.remove("se-placeholder-line"),e.removeAttribute("data-se-placeholder-line"),e.getAttribute("class")||e.removeAttribute("class"))}}d.setEditorStyle(r.get("editorStyle"),i);const a=i.get("wysiwyg"),h=o.get("editableFrameAttributes"),c=r.get("editableFrameAttributes");for(const t in h)a.removeAttribute(t);for(const t in c)a.setAttribute(t,c[t])}else switch(t){case"theme":d.setTheme(C.get("theme"));break;case"events":{const t=C.get("events");for(const e in t)n.events[e]=t[e];break}case"autoStyleify":r.__resetAutoStyleify(C.get("autoStyleify"));break;case"textDirection":d.setDir("rtl"===C.get("textDirection")?"rtl":"ltr");break;case"historyStackDelayTime":c.resetDelayTime(C.get("historyStackDelayTime"));break;case"defaultLineBreakFormat":o.__resetBrLineBreak(C.get("defaultLineBreakFormat"))}y.setMany(C),this.#q=b;const k=i.get("toolbar_main");/inline|balloon/i.test(y.get("mode"))&&v.includes("toolbar_width")&&(k.style.width=y.get("toolbar_width")),y.get("toolbar_hide")?k.style.display="none":k.style.display="",y.get("shortcutsHint")?Re.utils.removeClass(k,"se-shortcut-hide"):Re.utils.addClass(k,"se-shortcut-hide")}resetFrame(t){this.#U.reset(t)}#K(t,e,s,i,n,o){const r=e[t],l=Object.keys(r);if(this.#G(l,null,t+"."),0===l.length)return!1;const a=t||null;i.set(a,new Map);const h=s.get(a).get("options").get("_origin"),c={},d=Object.prototype.hasOwnProperty;for(const t in r){if(!d.call(Xe,t))continue;const e=r[t];l.includes(t)&&h[t]!==e&&(i.get(a).set(this.#Y(t),!0),c[t]=e)}const u={...h,...c};n.set(a,new Map(Object.entries(u))),o.push({key:a,options:u})}#Y(t){return/^statusbar|^charCounter|^wordCounter/.test(t)?"statusbar-changed":t}#G(t,e,s){for(let i,n=0,o=t.length;n<o;n++)i=t[n],("fixed"===Ze[i]||"fixed"===Xe[i]||e&&e[i])&&(console.warn(`[SUNEDITOR.warn.resetOptions] The "[${s+i}]" option cannot be changed after the editor is created.`),t.splice(n--,1),o--)}#V(t){let e=t.value;return{get:t=>e.get(t),set:(t,s)=>e.set(t,s),has:t=>e.has(t),getAll:()=>Object.fromEntries(e.entries()),setMany(t){t.forEach(((t,s)=>e.set(s,t)))},reset(s){e=t.value=s},size:()=>e.size,clear(){e.clear()},entries:()=>e.entries(),keys:()=>e.keys(),values:()=>e.values(),forEach(t){e.forEach(t)}}}#j(t){let e=t.value;return{get:t=>e.get(t),set:(t,s)=>e.set(t,s),has:t=>e.has(t),getAll:()=>Object.fromEntries(e.entries()),setMany(t){t.forEach(((t,s)=>e.set(s,t)))},reset(s){e=t.value=s},size:()=>e.size,clear(){e.clear()},entries:()=>e.entries(),keys:()=>e.keys(),values:()=>e.values(),forEach(t){e.forEach(t)}}}_destroy(){this.#q=null,this.#W.clear(),this.#U.clear()}}const xs=class{#X;constructor(t){this.#X=t}isNode(t){return t&&"number"==typeof t.nodeType||t instanceof this.#Z().Node}isElement(t){return t&&1===t.nodeType||t instanceof this.#Z().Element}isRange(t){return t&&"Range"===t.constructor?.name||t instanceof this.#Z().Range}isSelection(t){return t&&"Selection"===t.constructor?.name||t instanceof this.#Z().Selection}#Z(){return this.#X.get("_ww")}},{_w:$s,_d:Ss,NO_EVENT:Es}=Le;const Ts=class{#J;#X;#Q;#tt=null;#et=null;#st=[];constructor(t,e,s){this.#J=s,this.#X=t.frameContext,this.#Q=e.frameOptions,this.events=e.options.get("events")||{},this.triggerEvent=async(t,e)=>{if(Re.check.isNonEditable(e?.frameContext?.get("wysiwyg")))return!1;const s=this.events[t];if("function"==typeof s)try{return await s({$:this.#J,...e})}catch(e){return console.error(`[SUNEDITOR.triggerEvent.${t}]`,e),!1}return Es}}_bindOrchestrator(t){this.#tt=t}applyTagEffect(t){return this.#tt?.applyTagEffect(t)}addEvent(t,e,s,i){if(!t)return null;if((t===$s||t===Ss||"number"!=typeof t.length||t.nodeType||!Array.isArray(t)&&t.length<1)&&(t=[t]),0===t.length)return null;const n=t.length;for(let o=0;o<n;o++)t[o].addEventListener(e,s,i),this.#st.push({target:t[o],type:e,listener:s,useCapture:i});return{target:t,type:e,listener:s,useCapture:i}}removeEvent(t){if(!t)return;let e=t.target;const s=t.type,i=t.listener,n=t.useCapture;if(e&&((e===$s||e===Ss||"number"!=typeof e.length||e.nodeType||!Array.isArray(e)&&e.length<1)&&(e=[e]),0!==e.length)){for(let t=0,o=e.length;t<o;t++)e[t].removeEventListener(s,i,n);return null}}addGlobalEvent(t,e,s){return this.#Q.get("iframe")&&this.#X.get("_ww").addEventListener(t,e,s),$s.addEventListener(t,e,s),{type:t,listener:e,useCapture:s}}removeGlobalEvent(t,e,s){if(t)return"object"==typeof t&&(e=t.listener,s=t.useCapture,t=t.type),this.#Q.get("iframe")&&this.#X.get("_ww").removeEventListener(t,e,s),$s.removeEventListener(t,e,s),null}_injectActiveEvent(t){Re.utils.addClass(t,"__se__active"),this.#et=this.addGlobalEvent("mouseup",(()=>{Re.utils.removeClass(t,"__se__active"),this.#et=this.removeGlobalEvent(this.#et)}))}_init(){for(let t,e=0,s=this.#st.length;e<s;e++)t=this.#st[e],t.target.removeEventListener(t.type,t.listener,t.useCapture);this.#st=null,this.#et&&=this.removeGlobalEvent(this.#et)}};const Ms=class{#J;#t;#it;#nt;#e;#X;#ot;#Q;constructor(t){this.#J=t.$,this.#t=t.store,this.#it=this.#J.contextProvider.shadowRoot,this.#nt=this.#J.contextProvider.carrierWrapper,this.#e=this.#J.context,this.#X=this.#J.frameContext,this.#ot=this.#J.options,this.#Q=this.#J.frameOptions}get(t){const e=this.#X.get("wysiwygFrame"),s=/iframe/i.test(e?.nodeName),i=this.getLocal(t);return{left:i.left+(s?e.parentElement.offsetLeft:0),top:i.top+(s?e.parentElement.offsetTop:0)}}getLocal(t){const e=t;let s=0,i=0,n=0,o=0,r=0,l=3===e.nodeType?e.parentElement:e;const a=e.offsetWidth,h=wt(e,tt.bind(this)),c=l;for(;l&&!ct(l,"se-wrapper")&&l!==h;)s+=l.offsetLeft-(c!==l?l.scrollLeft:0),i+=l.offsetTop+(c!==l?l.scrollTop:0),l=l.offsetParent;const d=this.#X.get("wysiwygFrame");this.#X.get("wysiwyg").contains(e)&&(n=d.offsetLeft,o=d.offsetTop,r=d.parentElement.offsetWidth-(d.offsetLeft+d.offsetWidth));const u=this.#X.get("eventWysiwyg");return s+=n-(h?h.scrollLeft:0),i+=o-(h?h.scrollTop:0),{left:s,top:i,right:l?.offsetWidth?l.offsetWidth-(s-n+a)+r:0,scrollX:u.scrollLeft||u.scrollX||0,scrollY:u.scrollTop||u.scrollY||0,scrollH:this.#X.get("wysiwyg").scrollHeight||0}}getGlobal(t){const e=this.#X.get("topArea"),s=this.#X.get("wysiwygFrame");if(t||=e,!G(t))return{top:0,left:0,fixedTop:0,fixedLeft:0,width:0,height:0};const i=t,n=i.getBoundingClientRect();let r=n.top,l=n.left;if(/^iframe$/i.test(s.nodeName)&&s.contentDocument.contains(i)){const t=s.getBoundingClientRect();r+=t.top,l+=t.left}return{top:r+o.scrollY,left:l+o.scrollX,fixedTop:r,fixedLeft:l,width:i.offsetWidth,height:i.offsetHeight}}getGlobalScroll(t){const e=this.#X.get("topArea");let s=!1,i=!1;t||=e,t===e&&(s=!0),!s&&G(t)&&(i="absolute"===o.getComputedStyle(t).position);let n=0,r=0,l=0,a=0,h=0,c=0,d=0,u=0,p=null,g=null,m=null,f=null,v=t;for(;v;)n+=v.scrollTop,r+=v.scrollLeft,l+=v.scrollHeight,a+=v.scrollWidth,v.scrollTop>0&&(c+=v.offsetTop),v.scrollHeight>=v.clientHeight&&(d=/^html$/i.test(v.nodeName)?d||v.clientHeight:v.clientHeight+(m?-m.clientTop:0),p=m||p||v,m=v),v.scrollLeft>0&&(h+=v.offsetLeft),v.scrollWidth>=v.clientWidth&&(u=/^html$/i.test(v.nodeName)?u||v.clientWidth:v.clientWidth+(f?-f.clientLeft:0),g=f||g||v,f=v),v=v.parentElement;if(!i&&!s&&/^iframe$/i.test(this.#X.get("wysiwygFrame").nodeName))for(v=this.#X.get("wrapper"),p=g=e;v;)n+=v.scrollTop,r+=v.scrollLeft,l+=v.scrollHeight,a+=v.scrollWidth,v.scrollTop>0&&(c+=v.offsetTop),v.scrollHeight>=v.clientHeight&&(d=/^html$/i.test(v.nodeName)?d||v.clientHeight:v.clientHeight+(m?-m.clientTop:0),m=v),v.scrollLeft>0&&(h+=v.offsetLeft),v.scrollWidth>=v.clientWidth&&(u=/^html$/i.test(v.nodeName)?u||v.clientWidth:v.clientWidth+(f?-f.clientLeft:0),f=v),v=v.parentElement;for(v=this.#it?.host,v&&(p=g=e);v;)n+=v.scrollTop,r+=v.scrollLeft,l+=v.scrollHeight,a+=v.scrollWidth,v.scrollTop>0&&(c+=v.offsetTop),v.scrollHeight>=v.clientHeight&&(d=/^html$/i.test(v.nodeName)?d||v.clientHeight:v.clientHeight+(m?-m.clientTop:0),m=v),v.scrollLeft>0&&(h+=v.offsetLeft),v.scrollWidth>=v.clientWidth&&(u=/^html$/i.test(v.nodeName)?u||v.clientWidth:v.clientWidth+(f?-f.clientLeft:0),f=v),v=v.parentElement;const b=e.contains(p),y=e.contains(g);p=b?e:p,g=y?e:g;const w=p?p.getBoundingClientRect().top+(!p.parentElement||/^html$/i.test(p.parentElement.nodeName)?o.scrollY:0):0,C=g?g.getBoundingClientRect().left+(!g.parentElement||/^html$/i.test(g.parentElement.nodeName)?o.scrollX:0):0;d=b?e.clientHeight:d,u=y?e.clientWidth:u;const _=pt(this.#X.get("_wd"));return{top:n,left:r,ts:w,ls:C,width:a,height:l,x:h,y:c,ohOffsetEl:i?window:p,owOffsetEl:i?window:g,oh:i?_.h:d,ow:i?_.w:u,heightEditorRefer:b,widthEditorRefer:y}}getWWScroll(){const t=this.#X.get("eventWysiwyg"),e=t.scrollTop||t.scrollY||0,s=t.scrollHeight||t.document?.documentElement.scrollHeight||0;return{top:e,left:t.scrollLeft||t.scrollX||0,width:t.scrollWidth||t.document?.documentElement.scrollWidth||0,height:s,bottom:e+s}}setRelPosition(t,e,s,i,{preferUp:n}={}){const l=/^fixed$/i.test(o.getComputedStyle(i).position),a=this.getGlobal(s);if(l)t.style.position="fixed",t.style.top=n?a.fixedTop-t.offsetHeight+"px":`${a.fixedTop+a.height}px`;else{t.style.position="";const l=i.contains(t)?this.getGlobal(e).top:0,h=t.offsetHeight,c=o.scrollY,d=a.top;if(n){const e=l-c+d;if(e<h){const i=pt(r).h-(l-c+d+s.offsetHeight);i>=h?t.style.top=`${d+s.offsetHeight}px`:i>e?(t.style.height=`${i}px`,t.style.top=`${d+s.offsetHeight}px`):(t.style.height=`${e}px`,t.style.top=-1*(e-d+3)+"px")}else t.style.top=d-h+"px"}else{const e=pt(r).h-(l-c+d+s.offsetHeight);if(e<h){let i=-1*(h-d+3);const n=l-c+i,o=h+(n<0?n:0);o>e?(t.style.height=`${o}px`,i=-1*(o-d+3)):(t.style.height=`${e}px`,i=d+s.offsetHeight),t.style.top=`${i}px`}else t.style.top=`${d+s.offsetHeight}px`}}const h=t.offsetWidth,c=a.left,d=this.getGlobal(i).left;if(this.#ot.get("_rtl")){const e=s.getBoundingClientRect(),n=o.innerWidth;let r=n-e.right;if(h>0){const t=i.getBoundingClientRect();n-r-h<t.left&&(r=n-t.left-h)}t.style.left="auto",t.style.right=`${Math.max(0,r)}px`}else{const e=i.offsetWidth+d,s=e<=h?0:e-(c+h);t.style.right="",t.style.left=s<0?`${c+s}px`:`${c}px`}}setAbsPosition(t,e,s){const i={left:0,right:0,top:0,...s.addOffset},n=s.position||"bottom",l=s.inst,a=!this.#ot.get("_rtl");a||(i.left*=-1);const h=this.#Q.get("iframe"),c=this.#X.get("wrapper").contains(e)||s.isWWTarget||!!h&&this.#X.get("wysiwyg").contains(e),d=Boolean(wt(e,".se-toolbar")),u=1===e.nodeType,p=c&&!u,g=u&&/inline/.test(o.getComputedStyle(e).display),m=pt(r),f=p?this.getWWScroll():this.#rt(),v=!c||!h&&u?e.getBoundingClientRect():this.#J.selection.getRects(e,"start").rects,b=this.getGlobal(e),y=ct(t.firstElementChild,"se-arrow")?t.firstElementChild:null,w=s.sibling?.offsetHeight||0,C=y?y.offsetHeight:0,_=t.offsetHeight,k=e.offsetHeight,x=v.top,$=m.h-v.bottom,S=this.getGlobal(this.#X.get("topArea")).top,E=o.scrollY,T=this.#e.get("toolbar_main").offsetHeight,M=this.#ot.get("toolbar_container"),N=this.#t.mode.isBalloon||this.#t.mode.isInline||M,B=M&&S-E-T>0||!this.#J.toolbar.isSticky&&N?0:T+(this.#J.toolbar.isSticky?this.#ot.get("_toolbar_sticky"):0),I=this.#X.get("statusbar")?.offsetHeight||0,{rmt:L,rmb:A,bMargin:O,rt:R}=this.#lt(x,$,B,m,v,p,d);if(c&&(A-I+k<=0||L+R+k-(this.#J.toolbar.isSticky&&g?B:0)<=0)||L+k<0)return;const z=this.#X.get("topArea").getBoundingClientRect(),P=this.#t.mode.isBottom?z.bottom>=o.innerHeight-T:z.top<=T,D=this.#J.toolbar.isSticky&&"none"!==this.#e.get("toolbar_main").style.display&&(!N||P);let F=i.top,H=0,q="";"bottom"===n?(q="up",F+=v.bottom+C+E,H=A-(_+C),H-w<0&&(q="down",F-=k+_+2*C,H=L-(_+C),H-w<0&&(q="",F-=H-w-Math.max(1,H+_+C)))):(q="down",F+=v.top-_-C+E,H=(D&&!this.#t.mode.isBottom?v.top-B:L)-_-C,H-w<0&&(q="up",F+=k+_+2*C,H=(A>0?O:A)-(_+C)-I,H-w<0&&(q="",F+=H-2))),this.#at(y,q),t.style.top=`${F}px`;const W=(1===t.nodeType?ze.get(o.getComputedStyle(t).borderRadius):0)||0,U=b.width,V=t.offsetWidth,j=y?y.offsetWidth:0,G=v.left,K=m.w-v.right;if(c&&(G+U<=0||K+U<=0))return;y&&(y.style.left="",y.style.right="");let Y=i.left||(i.right?a?i.right-t.offsetWidth:t.offsetWidth-i.right:0),X=0,Z=0,J=0;return a?(Y+=v.left+o.scrollX-(G<0?G:0),X=U+G,X<j&&(J=j/2-1+(W<=2?0:W-2),Z=J),X=U+K-V,X<0&&(Y+=X,J=V-1-(j/2+(W<=2?0:W-2)),Z=-(X-j/2),Z=Z>J?J:Z),y&&Z>0&&(y.style.left=Z+"px")):(Y+=v.right-V+o.scrollX+(K<0?K:0),X=U+K,X<j&&(J=j/2-1+(W<=2?0:W-2),Z=J),X=U+G-V,X<0&&(Y-=X,J=j/2-1+(W<=2?0:W-2),Z=-(X-j/2),Z=Z<J?J:Z>V-J?V-J:Z),y&&Z>0&&(y.style.right=Z+"px")),t.style.left=`${Y}px`,l.__offset={left:t.offsetLeft+f.left,top:t.offsetTop+f.top,addOffset:i},{position:"up"===q?"bottom":"top"}}setRangePosition(t,e,{position:s,addTop:i}={}){t.style.top="-10000px",t.style.visibility="hidden",t.style.display="block";let n="top"===s;e||=this.#J.selection.getRange();const l=this.#J.selection.getRects(e,n?"start":"end");if(n="start"===l.position,l.rects.noText){let t=e.startContainer;1===t.nodeType&&(t=t.childNodes[e.startOffset]||t);const s=t.parentNode;if(s){const e=rt(E);s.insertBefore(e,t);const i=r.createRange();i.setStart(e,1),i.setEnd(e,1);const n=i.getClientRects()[0];n&&(l.rects=n,l.scrollLeft=o.scrollX,l.scrollTop=o.scrollY),s.removeChild(e)}}const a=this.#X.get("isFullScreen"),h=this.#X.get("topArea"),c=this.#nt.contains(t),d=l.rects,u=a?0:l.scrollLeft,p=a?0:l.scrollTop,g=c?pt(r).w:h.offsetWidth,m=this.getGlobal(h),f=c?0:m.left,v=t.offsetWidth,b=t.offsetHeight;this.#ht(n,d,t,f,g,u,p,i),this.getGlobal(t).top-m.top<0&&(n=!n,this.#ht(n,d,t,f,g,u,p,i)),v===t.offsetWidth&&b===t.offsetHeight||this.#ht(n,d,t,f,g,u,p,i);const y=!this.#nt.contains(t),w=pt(r),C=d.height,_=d.top,k=w.h-d.bottom,x=this.#J.toolbar.isSticky||!this.#t.mode.isBalloon&&!this.#t.mode.isInline?this.#e.get("toolbar_main").offsetHeight:0,{rmt:$,rmb:S,rt:T}=this.#lt(_,k,x,w,d,y,!1);if(!(S+C<=0||$+T+C<=0))return t.style.visibility="",!0}#ht(t,e,s,i,n,o,l,a=0){const h=s.querySelector(".se-arrow "),c=Math.round(h.offsetWidth/2),d=s.offsetWidth,u=e.noText&&!t?0:s.offsetHeight,p=(t?e.left:e.right)-i-d/2+o,g=p+d-n;let m=(t?e.top-u-c:e.bottom+c)-(e.noText?0:a)+l;const f=p<0?1:g<0?p:p-g-1-1;let v=!1;const b=m+(t?this.getGlobal(this.#X.get("topArea")).top:s.offsetHeight-this.#X.get("wysiwyg").offsetHeight);!t&&b>0&&this.#ct()<b?(t=!0,v=!0):t&&r.documentElement.offsetTop>b&&(t=!1,v=!0),v&&(m=(t?e.top-u-c:e.bottom+c)-(e.noText?0:a)+l),s.style.left=Math.floor(f)+"px",s.style.top=Math.floor(m)+"px",t?(ut(h,"se-arrow-up"),dt(h,"se-arrow-down")):(ut(h,"se-arrow-down"),dt(h,"se-arrow-up"));const y=Math.floor(d/2+(p-f));h.style.left=(y+c>s.offsetWidth?s.offsetWidth-c:y<c?c:y)+"px"}#ct(){const t=this.#X.get("topArea");return r.documentElement.scrollHeight-(this.getGlobal(t).top+t.offsetHeight)}#lt(t,e,s,i,n,r,l){const a=this.#J.selection.getRects(this.#X.get("wysiwyg"),"start").rects;let h=0,c=0,d=0,u=0,p=0;const g=this.#Q.get("iframe");u=n.top,p=i.h-n.bottom;const m=this.getGlobal(),f=this.#t.mode.isBottom;if(r){d=l||this.#J.toolbar.isSticky||this.#ot.get("toolbar_container")?0:s;const t=g?0:m.top-o.scrollY+d,e=g?0:this.#t.get("currentViewportHeight")-(m.top+m.height-o.scrollY);let i=t,r=e;f?(s>e?r=this.#J.toolbar.isSticky?s:e+s:this.#ot.get("toolbar_container")&&!this.#J.toolbar.isSticky?s=0:r=e+s,h=n.top-(a.top-t),c=a.bottom-(n.bottom-r)+s,c=c>0?c:c-s):(s>t?i=this.#J.toolbar.isSticky?s:t+s:this.#ot.get("toolbar_container")&&!this.#J.toolbar.isSticky?s=0:i=t+s,h=n.top-(a.top-i)+s,c=a.bottom-(n.bottom-e),h=h>0?h:h-s)}else{const t=m.fixedTop>0?m.fixedTop:0,e=o.innerHeight-(m.fixedTop+m.height);d=l||!this.#J.toolbar.isSticky&&this.#J.toolbar.isBalloonMode?0:s,f?(h=u-(l?0:t),c=p-(e>0?e:0)-d):(h=u-(l?0:t)-d,c=p-(e>0?e:0))}return{rmt:h,rmb:c,rt:d,tMargin:u,bMargin:p}}#at(t,e){"up"===e?(t&&(t.style.visibility=""),dt(t,"se-arrow-up"),ut(t,"se-arrow-down")):"down"===e?(t&&(t.style.visibility=""),dt(t,"se-arrow-down"),ut(t,"se-arrow-up")):t&&(t.style.visibility="hidden")}#rt(){const t=pt(r);return{top:o.scrollY,left:o.scrollX,width:t.w,height:t.h,bottom:o.scrollY+t.h,rects:{left:0,top:0,right:o.innerWidth,bottom:this.#t.get("currentViewportHeight")||o.innerHeight,noText:!0}}}},{_w:Ns}=Le;const Bs=class{#H;#J;#t;#it;#dt;#e;#X;#ot;#Q;#ut=0;#pt=!1;constructor(t){this.#H=t,this.#J=t.$,this.#t=t.store,this.#it=this.#J.contextProvider.shadowRoot,this.#dt=this.#J.instanceCheck,this.#e=this.#J.context,this.#X=this.#J.frameContext,this.#ot=this.#J.options,this.#Q=this.#J.frameOptions,this.range=null,this.selectionNode=null,this.__iframeFocus=!1}get(){let t=null;return t="function"==typeof this.#it?.getSelection?this.#it.getSelection():this.#X.get("_ww").getSelection(),t?(this.#t.get("_range")||this.#X.get("wysiwyg").contains(t.focusNode)||(t.removeAllRanges(),t.addRange(this.#gt())),t):null}isRange(t){return this.#dt.isRange(t)}getRange(){const t=this.#t.get("_range")||this.#gt(),e=this.get();if(t.collapsed===e.isCollapsed||!this.#X.get("wysiwyg").contains(e.focusNode)){if(this.#J.component.is(t.startContainer)){const e=this.#J.component.get(t.startContainer),s=e?.container;return s?this.setRange(s,0,s,1):t}return t}if(e.rangeCount>0){const t=e.getRangeAt(0);return this.#t.set("_range",t),t}{const t=e.anchorNode,s=e.focusNode,i=e.anchorOffset,n=e.focusOffset,o=Re.query.compareElements(t,s),r=o.ancestor&&(0===o.result?i<=n:o.result>1);return this.setRange(r?t:s,r?i:n,r?s:t,r?n:i)}}setRange(t,e,s,i){let n,o,r,l;if(this.isRange(t)){const e=t;n=e.startContainer,o=e.startOffset,r=e.endContainer,l=e.endOffset}else n=t,o=e,r=s,l=i;if(!n||!r)return;(Re.check.isBreak(n)||3===n.nodeType)&&o>n.textContent.length&&(o=n.textContent.length),(Re.check.isBreak(r)||3===r.nodeType)&&l>r.textContent.length&&(l=r.textContent.length),this.#J.format.isLine(n)&&(n=n.childNodes[o>0?n.childNodes.length-1:0]||n,o=o>0?1!==n.nodeType||Re.check.isBreak(n)?n.textContent?n.textContent.length:0:1:0),this.#J.format.isLine(r)&&(r=r.childNodes[l>0?r.childNodes.length-1:0]||r,l=l>0?1!==r.nodeType||Re.check.isBreak(r)?r.textContent?r.textContent.length:0:1:0);const a=this.#X.get("_wd").createRange();try{o=Math.min(o,n.textContent?.length||0),l=l>0&&0===(r.textContent?.length||0)&&1===r.nodeType?1:Math.min(Math.max(l,0),r.textContent?.length||0),a.setStart(n,o),a.setEnd(r,l),this.#t.set("hasFocus",!0)}catch(t){return console.warn("[SUNEDITOR.selection.focus.warn]",t.message),void this.#J.focusManager.nativeFocus()}const h=this.get();return h.removeAllRanges&&h.removeAllRanges(),h.addRange(a),this.#t.set("_range",a),this.#mt(a,this.get()),this.#Q.get("iframe")&&this.__focus(),a}removeRange(){this.#t.set("_range",null),this.#t.set("_lastSelectionNode",null),this.selectionNode=null,this.#t.get("hasFocus")&&this.get().removeAllRanges(),this.#H._eventOrchestrator.selectionState.reset()}getNearRange(t){const e=t.nextSibling,s=t.previousSibling;return e?{container:e,offset:0}:s?{container:s,offset:1}:null}getRangeAndAddLine(t,e){if(this.#ft(t)){const s=e?.parentElement||this.#X.get("wysiwyg"),i=Re.utils.createElement(this.#ot.get("defaultLine"),null,"<br>");s.insertBefore(i,e&&e!==s?e.previousElementSibling?e.nextElementSibling:e:s.firstElementChild),this.setRange(i.firstElementChild,0,i.firstElementChild,1),t=this.#t.get("_range")}return t}getNode(){if(this.#X.get("wysiwyg").contains(this.selectionNode)||this.init(),!this.selectionNode){const t=Re.query.getEdgeChild(this.#X.get("wysiwyg").firstChild,(t=>0===t.childNodes.length||3===t.nodeType),!1);if(t)return this.selectionNode=t,t;this.init()}return this.selectionNode}getRects(t,e){const s=!!Re.check.isElement(t)&&"absolute"===Ns.getComputedStyle(t).position;t=!t||Re.check.isText(t)?this.getRange():t;let i="start"===e,n=Ns.scrollX,o=Ns.scrollY,r=t.getClientRects();if(r=r[i?0:r.length-1],!r){const t=this.getNode();if(this.#J.format.isLine(t)){const t=Re.utils.createTextNode(Ae.zeroWidthSpace);this.#J.html.insertNode(t,{afterNode:null,skipCharCount:!0}),this.setRange(t,1,t,1),this.init(),r=this.getRange().getClientRects(),r=r[i?0:r.length-1]}if(!r){const e=this.#J.offset.get(t);r={left:e.left,top:e.top,right:e.left+t.offsetWidth,bottom:e.top+t.offsetHeight,noText:!0},n=0,o=0}i=!0}const l=/^iframe$/i.test(this.#X.get("wysiwygFrame").nodeName)?this.#X.get("wysiwygFrame").getClientRects()[0]:null;return!s&&l&&(r={left:r.left+l.left,top:r.top+l.top,right:r.right+l.right-l.width,bottom:r.bottom+l.bottom-l.height}),{rects:r,position:i?"start":"end",scrollLeft:n,scrollTop:o}}getDragEventLocationRange(t){const e=this.#X.get("_wd");let s,i,n,o,r;return e.caretPositionFromPoint?(s=e.caretPositionFromPoint(t.clientX,t.clientY),i=s.offsetNode,n=s.offset,o=s.offsetNode,r=s.offset):e.caretRangeFromPoint&&(s=e.caretRangeFromPoint(t.clientX,t.clientY),i=s.startContainer,n=s.startOffset,o=s.endContainer,r=s.endOffset),{sc:i,so:n,ec:o,eo:r}}scrollTo(t,e){const s=e?.noFocus;if(this.#dt.isSelection(t))t=t.getRangeAt(0);else if(this.#dt.isNode(t))if(s){const e=this.#X.get("_wd").createRange();e.selectNodeContents(t),t=e}else t=this.setRange(t,1,t,1);else void 0===t?.startContainer&&console.warn('[SUNEDITOR.html.scrollTo.warn] "selectionRange" must be Selection or Range or Node object.',t);const i=Re.query.getParentElement(t?.startContainer,(t=>1===t.nodeType));if(!i)return;delete(e={behavior:"smooth",block:"nearest",inline:"nearest",...e}).noFocus;const n=this.#X.get("_ww"),o=this.#X.get("wysiwygFrame"),r=this.#Q.get("iframe"),l=!this.#t.get("isScrollable")(this.#X),a=this.#t.get("currentViewportHeight"),h=l?Ns.scrollY:r?n.scrollY:o.scrollTop,c=this.#t.mode.isBottom,d=this.#e.get("toolbar_main").offsetHeight,u=this.#J.toolbar.isSticky?d:0,p=this.#J.toolbar.isSticky?u+this.#ot.get("_toolbar_sticky"):u,g=this.#X.get("statusbar")?.offsetHeight||0;if(this.#pt){const s=this.#J.format.isBrLine(i)?t?.getBoundingClientRect?.():null;if(s?.height>0?this.#vt(s,e.behavior):i?.scrollIntoView(e),"auto"===e?.behavior)if(p&&!c){const e=t?.getBoundingClientRect?.();e?.height>0&&e.top>=0&&e.top<p&&Ns.scrollBy(0,-(p-e.top))}else h!==Ns.scrollY&&(p?h<Ns.scrollY&&Ns.scrollBy(0,p):l&&Ns.scrollBy(0,g));return}const m=this.#ut,f=l?a-(c?p:0):o.offsetHeight,v=t?.getBoundingClientRect?.(),b=(v?.height>0?v.height:i.offsetHeight)||0,y=e?.behavior,w=c?0:p;if(l)if(r){const e=this.getRects(t,"end").rects,s=e.top+b-w,i=f-m-(e.top+b);if(s>=0&&i>=0)return;const n=h-(s<0?-(s-m):i),o=w>0&&s<0;Ns.scrollTo({top:o?n-w:n,behavior:y})}else{const t=v?.height>0?v.top+h:this.#J.offset.getGlobal(i).top,e=f+h-t-b,s=w>0?t-h>=w:f>e+m;if(e-m>0&&s)return;const n=e<=m?h-e+m+g:h-e+(f-b-m),o=w>0&&!s;Ns.scrollTo({top:o?n-w:n,behavior:y})}else{const t=v?.height>0?v.top:i.getBoundingClientRect().top,e=r?t:t-o.getBoundingClientRect().top,s=e>=(c?0:u)&&e+m<=f;let l=h+(c?e-m>0?e+m-f+u:e-b:e-m>0?e+m-f:e-(u+b));const p=Ns.scrollY,w=this.#J.offset.getGlobal(),C=c?0:d,_=c?d:0,k=p-w.top+C,x=w.top+w.height-(p+a)+_;if(k>0){const t=(s?e:e+h-l)-b-m-k;t<0&&(l+=C,Ns.scrollTo({top:p+t,behavior:"smooth"}))}if(x>0){const t=(s?e:e+h-l)+b+m-(w.height-x);t>0&&(l+=c?_:g,Ns.scrollTo({top:p+t,behavior:"smooth"}))}s||(r?n:o).scrollTo({top:l,behavior:y})}}#vt(t,e){let{top:s,bottom:i}=t;const n=[...this.#H._eventOrchestrator.scrollparents||[],Ns];for(const t of n){const n=t===Ns,o=n?0:t.getBoundingClientRect().top,r=n?this.#t.get("currentViewportHeight"):t.getBoundingClientRect().bottom;let l=0;s<o?l=s-o:i>r&&(l=i-r),0!==l&&(t.scrollBy({top:l,behavior:e}),s-=l,i-=l)}}resetRangeToTextNode(){let t=this.getRange();if(this.#ft(t)){if(!Re.check.isWysiwygFrame(t.startContainer)||!Re.check.isWysiwygFrame(t.endContainer))return!1;const e=t.commonAncestorContainer,s=e.children[t.startOffset],i=e.children[t.endOffset];if(!(t=this.setRange(s,0,i,s===i?0:1)))return!1}const e=t,s=e.collapsed;let i,n,o,r=e.startContainer,l=e.startOffset,a=e.endContainer,h=e.endOffset;if(this.#J.format.isLine(r))for(r.childNodes[l]?(r=r.childNodes[l]||r,l=0):(r=r.lastChild||r,l=r.textContent.length);1===r?.nodeType&&r.firstChild;)r=r.firstChild||r,l=0;if(this.#J.format.isLine(a)){for(a=a.childNodes[h]||a.lastChild||a;1===a?.nodeType&&a.lastChild;)a=a.lastChild;s?h=0:h>0&&(h=a.textContent.length)}if(i=Re.check.isWysiwygFrame(r)?this.#X.get("wysiwyg").firstChild:r,n=l,Re.check.isBreak(i)||1===i.nodeType&&i.childNodes.length>0){const t=Re.check.isBreak(i);if(!t){const t=i;for(;i&&!Re.check.isBreak(i)&&1===i.nodeType&&(o=i.childNodes,0!==o.length);)i=o[n>0?n-1:n]||!/FIGURE/i.test(o[0].nodeName)?o[0]:i.previousElementSibling||i.previousSibling||r,n=n>0?i.textContent.length:n;let e=this.#J.format.getLine(i,null);e===this.#J.format.getBlock(e,null)&&(i||=t,e=Re.utils.createElement(Re.query.getParentElement(i,Re.check.isTableCell)?"DIV":this.#ot.get("defaultLine")),i.parentNode.insertBefore(e,i),i!==t&&e.appendChild(i))}if(Re.check.isBreak(i)||this.#J.component.is(i)){const e=Re.utils.createTextNode(Ae.zeroWidthSpace);i.parentNode.insertBefore(e,i),i=e,t&&r===a&&(a=i,h=1)}}if(r=i,l=n,i=Re.check.isWysiwygFrame(a)?this.#X.get("wysiwyg").lastChild:a,n=h,Re.check.isBreak(i)||1===i.nodeType&&i.childNodes.length>0){const t=Re.check.isBreak(i);if(!t){for(;i&&!Re.check.isBreak(i)&&1===i.nodeType&&(o=i.childNodes,0!==o.length);)i=o[n>0?n-1:n]||!/FIGURE/i.test(o[0].nodeName)?o[0]:i.previousElementSibling||i.previousSibling||r,n=n>0?i.textContent.length:n;let t=this.#J.format.getLine(i,null);t===this.#J.format.getBlock(t,null)&&(t=Re.utils.createElement(Re.check.isTableCell(t)?"DIV":this.#ot.get("defaultLine")),i.parentNode.insertBefore(t,i),t.appendChild(i))}if(Re.check.isBreak(i)){const e=Re.utils.createTextNode(Ae.zeroWidthSpace);i.parentNode.insertBefore(e,i),i=e,n=1,t&&!i.previousSibling&&Re.utils.removeItem(a)}}return a=i,h=n,this.setRange(r,l,a,h),!0}init(){const t=this.#X.get("_wd").activeElement;if(Re.check.isInputElement(t))return this.selectionNode=t,t;const e=this.get();if(!e)return null;let s=null;s=e.rangeCount>0?e.getRangeAt(0):this.#gt(),this.#mt(s,e)}#mt(t,e){let s=null;this.#t.set("_range",t),s=t.collapsed?Re.check.isWysiwygFrame(t.commonAncestorContainer)&&t.commonAncestorContainer.children[t.startOffset]||t.commonAncestorContainer:e.anchorNode,this.selectionNode=s}#ft(t){const e=t.commonAncestorContainer;return Re.check.isWysiwygFrame(t.startContainer)&&Re.check.isWysiwygFrame(t.endContainer)||/FIGURE/i.test(e.nodeName)||this.#J.pluginManager.fileInfo.regExp.test(e.nodeName)&&(!this.#J.pluginManager.fileInfo.tagAttrs[e.nodeName]||this.#J.pluginManager.fileInfo.tagAttrs[e.nodeName]?.every((t=>e.hasAttribute(t))))||this.#J.component.is(e)}#gt(){const t=this.#X.get("wysiwyg"),e=this.#X.get("_wd").createRange();let s=t.firstElementChild,i=null;return s?(i=s.firstChild,i||(i=Re.utils.createElement("BR"),s.appendChild(i))):(i=Re.utils.createElement("BR"),s=Re.utils.createElement(this.#ot.get("defaultLine"),null,i),t.appendChild(s)),e.setStart(i,0),e.setEnd(i,0),e}__focus(){try{this.__iframeFocus=!0;const t=Re.query.getParentElement(this.getNode(),"figcaption");t?t.focus():this.#X.get("wysiwyg").focus()}finally{Ns.setTimeout((()=>this.__iframeFocus=!1),0)}}__init(){this.#pt=this.#H._eventOrchestrator.scrollparents?.length>0,this.#ut=this.#X?.get("wysiwyg")?(ze.get(Ns.getComputedStyle(this.#X.get("wysiwyg")).scrollMargin,0)||40)+ze.get(Ns.getComputedStyle(this.#X.get("wrapper")).paddingBottom,0):40}};function Is(t,e,s){const i=[];for(let n,o,r=0,l=t.length;r<l;r++)n=t[r],Re.check.isListCell(n)?(e<0||n.previousElementSibling)&&i.push(n):(o=/\d+/.test(n.style[s])?ze.get(n.style[s],0):0,o+=e,Re.utils.setStyle(n,s,o<=0?"":o+"px"));return i}const Ls=class{#J;#t;#ot;#X;#bt;#yt;#wt;#Ct;#_t;#kt;#xt=null;constructor(t){this.#J=t.$,this.#t=t.store,this.#ot=this.#J.options,this.#X=this.#J.frameContext,this.#bt=this.#ot.get("formatLine").reg,this.#yt=this.#ot.get("formatBrLine").reg,this.#wt=this.#ot.get("formatBlock").reg,this.#Ct=this.#ot.get("formatClosureBlock").reg,this.#_t=this.#ot.get("formatClosureBrLine").reg,this.#kt=new RegExp("^("+this.#ot.get("textStyleTags")+")$","i"),this.__resetBrLineBreak(this.#ot.get("defaultLineBreakFormat"))}setLine(t){if(!this.isLine(t))throw new Error('[SUNEDITOR.format.setLine.fail] The "element" must satisfy "format.isLine()".');const e=this.#$t(),s=e.lines,i=t.className,n=t.nodeName;let o=e.firstNode,r=e.lastNode;for(let e,l,a=0,h=s.length;a<h;a++)e=s[a],e.nodeName===n&&(e.className.match(/(\s|^)__se__format__[^\s]+/)||[""])[0].trim()===i||this.#J.component.is(e)||(l=t.cloneNode(!1),Re.utils.copyFormatAttributes(l,e),l.innerHTML=e.innerHTML,e.parentNode.replaceChild(l,e)),0===a&&(o=l||e),a===h-1&&(r=l||e),l=null;this.#J.selection.setRange(Re.query.getNodeFromPath(e.firstPath,o),e.startOffset,Re.query.getNodeFromPath(e.lastPath,r),e.endOffset),this.#J.history.push(!1),this.#X.has("documentType_use_header")&&this.#X.get("documentType").reHeader()}getLine(t,e){if(!t)return null;for(e||=()=>!0;t;){if(Re.check.isWysiwygFrame(t))return null;if(this.isBlock(t)){if(this.isLine(t.firstElementChild))return t.firstElementChild;if(this.isLine(t))return t}if(this.isLine(t)&&e(t))return t;t=t.parentNode}return null}setBrLine(t){if(!this.isBrLine(t))throw new Error('[SUNEDITOR.format.setBrLine.fail] The "element" must satisfy "format.isBrLine()".');const e=this.#$t().lines,s=e.length-1;let i=e[s].parentNode,n=t.cloneNode(!1);const o=n;for(let o,r,l,a,h,c,d=s,u=!0;d>=0;d--)if(o=e[d],o!==(e[d+1]?e[d+1].parentNode:null)){if(c=this.#J.component.is(o),r=c?"":o.innerHTML.replace(/(?!>)\s+(?=<)|\n/g," "),l=Re.query.getParentElement(o,(t=>t.parentNode===i)),(i!==o.parentNode||c)&&(this.isLine(i)?(i.parentNode.insertBefore(n,i.nextSibling),i=i.parentNode):(i.insertBefore(n,l?l.nextSibling:null),i=o.parentNode),a=n.nextSibling,a&&n.nodeName===a.nodeName&&Re.check.isSameAttributes(n,a)&&(n.innerHTML+="<BR>"+a.innerHTML,Re.utils.removeItem(a)),n=t.cloneNode(!1),u=!0),h=n.innerHTML,n.innerHTML=(u||!r||!h||/<br>$/i.test(r)?r:r+"<BR>")+h,0===d){i.insertBefore(n,o),a=o.nextSibling,a&&n.nodeName===a.nodeName&&Re.check.isSameAttributes(n,a)&&(n.innerHTML+="<BR>"+a.innerHTML,Re.utils.removeItem(a));const t=n.previousSibling;t&&n.nodeName===t.nodeName&&Re.check.isSameAttributes(n,t)&&(t.innerHTML+="<BR>"+n.innerHTML,Re.utils.removeItem(n))}c||Re.utils.removeItem(o),r&&(u=!1)}this.#J.selection.setRange(o,0,o,0),this.#J.history.push(!1)}getBrLine(t,e){if(!t)return null;for(e||=()=>!0;t;){if(Re.check.isWysiwygFrame(t))return null;if(this.isBrLine(t)&&e(t))return t;t=t.parentNode}return null}addLine(t,e){if(!t||!t.parentNode)return null;const s=this.getLine(this.#J.selection.getNode(),null);let i=null;if(this.isBrLine(t)||!this.isBrLine(s||t.parentNode)||this.#J.component.is(t)){const t=e?"string"==typeof e?e:e.nodeName:this.isNormalLine(s)?s.nodeName:this.#ot.get("defaultLine");i=Re.utils.createElement(t,null,"<br>"),(e&&"string"!=typeof e||!e&&this.isLine(s))&&Re.utils.copyTagAttributes(i,e||s,["id"])}else i=Re.utils.createElement("BR");return Re.check.isTableCell(t)?t.insertBefore(i,t.nextElementSibling):t.parentNode.insertBefore(i,t.nextElementSibling),i}addLineAfter(t){if(!t||!t.parentNode)return null;const e=t.nodeName,s=this.#ot.get("lineAttrReset");let i;return/^H[1-6]$|^HR$/i.test(e)||this.isBrLine(t)?i=Re.utils.createElement(this.#ot.get("defaultLine"),null,"<br>"):(i=Re.utils.createElement(e,null,"<br>"),Re.utils.copyTagAttributes(i,t,s)),Re.check.isTableCell(t)?t.insertBefore(i,t.nextElementSibling):t.parentNode.insertBefore(i,t.nextElementSibling),i}getBlock(t,e){if(!t)return null;for(e||=()=>!0;t;){if(Re.check.isWysiwygFrame(t))return null;if(this.isBlock(t)&&!/^(THEAD|TBODY|TR)$/i.test(t.nodeName)&&e(t))return t;t=t.parentNode}return null}applyBlock(t){this.#J.selection.getRangeAndAddLine(this.#J.selection.getRange(),null);const e=this.getLinesAndComponents(!1);if(!e||0===e.length)return;t:for(let t,s,i,n,o,r,l=0,a=e.length;l<a;l++)if(t=e[l],Re.check.isListCell(t))if(s=t.lastElementChild,s&&Re.check.isListCell(t.nextElementSibling)&&e.includes(t.nextElementSibling)&&(n=s.lastElementChild,e.includes(n))){let t=null;for(;t=n.lastElementChild;)if(Re.check.isList(t)){if(!e.includes(t.lastElementChild))continue t;n=t.lastElementChild}i=s.firstElementChild,o=e.indexOf(i),r=e.indexOf(n),e.splice(o,r-o+1),a=e.length}else;const s=e.at(-1);let i,n,o;i=this.isBlock(s)||this.isLine(s)?s:this.getBlock(s,null)||this.getLine(s,null),Re.check.isTableCell(i)?(n=null,o=i):(n=i.nextSibling,o=i.parentNode);const r=t.cloneNode(!1);let l=Re.query.getNodeDepth(i),a=null;const h=[],c=(t,e,s)=>{let i=null;if(t!==e&&!Re.check.isTableElements(e)){if(e&&Re.query.getNodeDepth(t)===Re.query.getNodeDepth(e))return s;i=this.#J.nodeTransform.removeAllParents(e,null,t)}return i?i.ec:s};for(let t,s,i,d,u,p,g,m=0,f=e.length;m<f;m++)if(t=e[m],s=t.parentNode,s&&!r.contains(s))if(i=Re.query.getNodeDepth(t),Re.check.isList(s)){if(null===a&&(p?(a=p,g=!0,p=null):a=s.cloneNode(!1)),h.push(t),u=e[m+1],m===f-1||u?.parentNode!==s){t.contains(u?.parentNode)&&(p=u.parentNode.cloneNode(!1));let e,m=s.parentNode;for(;Re.check.isList(m);)e=Re.utils.createElement(m.nodeName),e.appendChild(a),a=e,m=m.parentNode;const f=this.removeBlock(s,{selectedFormats:h,newBlockElement:null,shouldDelete:!0,skipHistory:!0});l>=i?(l=i,o=f.cc,n=c(o,s,f.ec),n&&(o=n.parentNode)):o===f.cc&&(n=f.ec),o!==f.cc&&(d=c(o,f.cc,d),n=void 0!==d?d:f.cc);for(let t=0,e=f.removeArray.length;t<e;t++)a.appendChild(f.removeArray[t]);g||r.appendChild(a),p&&f.removeArray.at(-1).appendChild(p),a=null,g=!1}}else l>=i&&(l=i,o=s,n=t.nextSibling),r.appendChild(t),o!==s&&(d=c(o,s),void 0!==d&&(n=d));if(this.#t.set("_lastSelectionNode",null),this.#J.nodeTransform.mergeSameTags(r,null,!1),this.#J.nodeTransform.mergeNestedTags(r,(t=>Re.check.isList(t))),n&&Re.query.getNodeDepth(n)>0&&(Re.check.isList(n.parentNode)||Re.check.isList(n.parentNode.parentNode))){const t=Re.query.getParentElement(n,(t=>this.isBlock(t)&&!Re.check.isList(t))),e=this.#J.nodeTransform.split(n,null,t?Re.query.getNodeDepth(t)+1:0);e.parentNode.insertBefore(r,e)}else o.insertBefore(r,n),c(r,n);const d=Re.query.getEdgeChildNodes(r.firstElementChild,r.lastElementChild);e.length>1?this.#J.selection.setRange(d.sc,0,d.ec,d.ec.textContent.length):this.#J.selection.setRange(d.ec,d.ec.textContent.length,d.ec,d.ec.textContent.length),this.#J.history.push(!1)}removeBlock(t,{selectedFormats:e,newBlockElement:s,shouldDelete:i,skipHistory:n}={}){const o=this.#J.selection.getRange();let r=o.startOffset,l=o.endOffset,a=Re.query.getListChildNodes(t,null,1),h=t.parentNode,c=null,d=null,u=t.cloneNode(!1);const p=[],g=Re.check.isList(s);let m=!1,f=!1,v=!1;const b=(e,s,i,n)=>{if(1===s.childNodes.length&&Re.check.isZeroWidth(s)&&(s.innerHTML=Ae.zeroWidthSpace,r=l=1),3===s.nodeType)return e.insertBefore(s,i),s;const o=(v?s:n).childNodes;let a=s.cloneNode(!1),h=null,c=null;for(;o[0];)c=o[0],!this._isNotTextNode(c)||Re.check.isBreak(c)||Re.check.isListCell(a)?a.appendChild(c):(a.childNodes.length>0&&(h||=a,e.insertBefore(a,i),a=s.cloneNode(!1)),e.insertBefore(c,i),h||=c);if(a.childNodes.length>0){if(Re.check.isListCell(e)&&Re.check.isListCell(a)&&Re.check.isList(i))if(g){for(h=i;i;)a.appendChild(i),i=i.nextSibling;e.parentNode.insertBefore(a,e.nextElementSibling)}else{const e=n.nextElementSibling,s=this.#J.listFormat.removeNested(n,!1);if(t!==s||e!==n.nextElementSibling){const e=a.childNodes;for(;e[0];)n.appendChild(e[0]);t=s,f=!0}}else e.insertBefore(a,i);h||=a}return h};for(let n,o,r,l=0,y=a.length;l<y;l++)if(n=a[l],3!==n.nodeType||!Re.check.isList(u))if(v=!1,i&&0===l&&(c=e&&e.length!==y&&e[0]!==n?u:t.previousSibling),e&&(o=e.indexOf(n)),e&&-1===o)u||=t.cloneNode(!1),u.appendChild(n);else{if(e&&(r=e[o+1]),u&&u.children.length>0&&(h.insertBefore(u,t),u=null),!g&&Re.check.isListCell(n))if(r&&Re.query.getNodeDepth(n)!==Re.query.getNodeDepth(r)&&(Re.check.isListCell(h)||Re.utils.arrayFind(n.children,Re.check.isList))){const e=n.nextElementSibling,s=this.#J.listFormat.removeNested(n,!1);t===s&&e===n.nextElementSibling||(t=s,f=!0)}else{const e=n;n=Re.utils.createElement(i?e.nodeName:Re.check.isList(t.parentNode)||Re.check.isListCell(t.parentNode)?"LI":Re.check.isTableCell(t.parentNode)?"DIV":this.#ot.get("defaultLine"));const s=Re.check.isListCell(n),o=e.childNodes;for(;o[0]&&(!Re.check.isList(o[0])||s);)n.appendChild(o[0]);Re.utils.copyFormatAttributes(n,e),v=!0}else n=n.cloneNode(!1);if(!f&&(i?(p.push(n),Re.utils.removeItem(a[l])):(s?(m||(h.insertBefore(s,t),m=!0),n=b(s,n,null,a[l])):n=b(h,n,t,a[l]),f||(e?(d=n,c||=n):c||(c=d=n))),f)){f=v=!1,a=Re.query.getListChildNodes(t,null,1),u=t.cloneNode(!1),h=t.parentNode,l=-1,y=a.length;continue}}const y=t.parentNode;let w=t.nextSibling;u?.children.length>0&&y.insertBefore(u,w),s?c=s.previousSibling:c||=t.previousSibling,w=t.nextSibling!==u?t.nextSibling:u?u.nextSibling:null,0===t.children.length||0===t.textContent.length?Re.utils.removeItem(t):this.#J.nodeTransform.removeEmptyNode(t,null,!1);let C=null;if(this.#t.set("_lastSelectionNode",null),i)C={cc:y,sc:c,so:r,ec:w,eo:l,removeArray:p};else{c||=d,d||=c;const t=Re.query.getEdgeChildNodes(c,d?.parentNode?c:d);t?C={cc:(t.sc||t.ec).parentNode,sc:t.sc,so:r,ec:t.ec,eo:l,removeArray:null}:this.#J.focusManager.focus()}if(n)return C;!i&&C&&(e?this.#J.selection.setRange(C.sc,r,C.ec,l):this.#J.selection.setRange(C.sc,0,C.sc,0)),this.#J.history.push(!1)}indent(){const t=this.#J.selection.getRange(),e=t.startContainer,s=t.endContainer,i=t.startOffset,n=t.endOffset,o=Is(this.getLines(null),this.#t.get("indentSize"),this.#ot.get("_rtl")?"marginRight":"marginLeft");o.length>0&&this.#J.listFormat.applyNested(o,!1),this.#t.set("_lastSelectionNode",null),this.#J.selection.setRange(e,i,s,n),this.#J.history.push(!1)}outdent(){const t=this.#J.selection.getRange(),e=t.startContainer,s=t.endContainer,i=t.startOffset,n=t.endOffset,o=Is(this.getLines(null),-1*this.#t.get("indentSize"),this.#ot.get("_rtl")?"marginRight":"marginLeft");o.length>0&&this.#J.listFormat.applyNested(o,!0),this.#t.set("_lastSelectionNode",null),this.#J.selection.setRange(e,i,s,n),this.#J.history.push(!1)}isEdgeLine(t,e,s){if("front"===s){if(e>0)return!1}else if(t?.textContent?.length>e)return!1;let i=!1;const n="front"===s?"previousSibling":"nextSibling";for(;t&&!this.isLine(t)&&!Re.check.isWysiwygFrame(t);){if(t[n]&&(!Re.check.isBreak(t[n])||t[n][n]))return!1;i=!0,t=t.parentNode}return i}isTextStyleNode(t){return"string"==typeof t?this.#kt.test(t):1===t?.nodeType&&this.#kt.test(t.nodeName)}isLine(t){return"string"==typeof t?this.#bt.test(t):1===t?.nodeType&&(this.#bt.test(t.nodeName)||Re.utils.hasClass(t,"__se__format__line_.+|__se__format__br_line_.+"))&&!this.#St(t)}isNormalLine(t){return this.isLine(t)&&(this.#xt||!this.isBrLine(t))&&!this.isBlock(t)}isBrLine(t){return this.#xt&&this.isLine(t)||("string"==typeof t?this.#yt.test(t):1===t?.nodeType&&(this.#yt.test(t.nodeName)||Re.utils.hasClass(t,"__se__format__br_line_.+"))&&!this.#St(t))}isBlock(t){return"string"==typeof t?this.#wt.test(t):1===t?.nodeType&&(this.#wt.test(t.nodeName)||Re.utils.hasClass(t,"__se__format__block_.+"))&&!this.#St(t)}isClosureBlock(t){return"string"==typeof t?this.#Ct.test(t):1===t?.nodeType&&(this.#Ct.test(t.nodeName)||Re.utils.hasClass(t,"__se__format__block_closure_.+"))&&!this.#St(t)}isClosureBrLine(t){return"string"==typeof t?this.#_t.test(t):1===t?.nodeType&&(this.#_t.test(t.nodeName)||Re.utils.hasClass(t,"__se__format__br_line__closure_.+"))&&!this.#St(t)}getLines(t){if(!this.#J.selection.resetRangeToTextNode())return[];let e=this.#J.selection.getRange();if(Re.check.isWysiwygFrame(e.startContainer)){const t=this.#X.get("wysiwyg").children,s=t.length;if(0===s)return[];this.#J.selection.setRange(t[0],0,t[s-1],t[s-1].textContent.trim().length),e=this.#J.selection.getRange()}const s=e.startContainer,i=e.endContainer,n=e.commonAncestorContainer;t||=this.isLine.bind(this);const o=Re.query.getListChildren(n,(e=>t(e)),null);if(3!==n.nodeType&&(Re.check.isWysiwygFrame(n)||this.isBlock(n))||o.unshift(this.getLine(n,null)),s===i||1===o.length)return o;const r=this.getLine(s,null),l=this.getLine(i,null);let a=null,h=null;const c=function(t){return!Re.check.isTableElements(t)||/^TABLE$/i.test(t.nodeName)};let d=this.getBlock(r,c),u=this.getBlock(l,c);Re.check.isTableElements(d)&&Re.check.isListCell(d.parentNode)&&(d=d.parentNode),Re.check.isTableElements(u)&&Re.check.isListCell(u.parentNode)&&(u=u.parentNode);const p=d===u;for(let t,e=0,s=o.length;e<s;e++)if(t=o[e],r===t||!p&&t===d)a=e;else if(l===t||!p&&t===u){h=e;break}return null===a&&(a=0),null===h&&(h=o.length-1),o.slice(a,h+1)}getLinesAndComponents(t){const e=this.#J.selection.getRange().commonAncestorContainer,s=Re.query.getParentElement(e,this.#J.component.is.bind(this.#J.component)),i=Re.check.isTableElements(e)?this.getLines(null):this.getLines((t=>{const e=Re.query.getParentElement(t,this.#J.component.is.bind(this.#J.component));return this.isLine(t)&&(!e||e===s)||Re.check.isComponentContainer(t)&&!this.getLine(t)}));if(t)for(let t=0,e=i.length;t<e;t++)for(let s=t-1;s>=0;s--)if(i[s].contains(i[t])){i.splice(t,1),t--,e--;break}return i}_isNotTextNode(t){if(!t)return!1;const e=/^(br|input|select|canvas|img|iframe|audio|video)$/i;return"string"==typeof t?e.test(t):1===t.nodeType&&(this.#J.component.is(t)||e.test(t.nodeName))}_isExcludeSelectionElement(t){return!/FIGCAPTION/i.test(t.nodeName)&&(this.#J.component.is(t)||/FIGURE/i.test(t.nodeName))}#St(t){return Re.check.isExcludeFormat(t)||this.#J.component.is(t)||Re.check.isWysiwygFrame(t)}#$t(){let t=this.#J.selection.getRange(),e=this.getLinesAndComponents(!1);if(0===e.length&&(t=this.#J.selection.getRangeAndAddLine(t,null),e=this.getLinesAndComponents(!1),0===e.length))return;const s=t.startOffset,i=t.endOffset;let n=e[0],o=e.at(-1);const r=Re.query.getNodePath(t.startContainer,n,null),l=Re.query.getNodePath(t.endContainer,o,null),a=this.#J.listFormat.remove(e,!1);return a.sc&&(n=a.sc),a.ec&&(o=a.ec),this.#J.selection.setRange(Re.query.getNodeFromPath(r,n),s,Re.query.getNodeFromPath(l,o),i),{lines:this.getLinesAndComponents(!1),firstNode:n,lastNode:o,firstPath:r,lastPath:l,startOffset:s,endOffset:i}}__resetBrLineBreak(t){return this.#xt="br"===t}};function As(t){const e=t.parentNode;if(!t||3===t.nodeType||!e)return;const s=t.childNodes;for(;s[0];)e.insertBefore(s[0],t);e.removeChild(t)}const Os=class{#J;#ot;#Et;#Tt;constructor(t){this.#J=t.$,this.#ot=this.#J.options,this.#Et=this.#ot.get("__listCommonStyle"),this.#Tt=Oe.camelToKebabCase(this.#ot.get("__listCommonStyle"))}apply(t,{stylesToModify:e,nodesToRemove:s,strictRemove:i}={}){if(Re.query.getParentElement(this.#J.selection.getNode(),Re.check.isNonEditable))return;this.#J.selection.resetRangeToTextNode();let n=this.#J.selection.getRangeAndAddLine(this.#J.selection.getRange(),null);e=e?.length>0?e:null,s=s?.length>0?s:null;const o=!t,r=o&&!s&&!e;let l=n.startContainer,a=n.startOffset,h=n.endContainer,c=n.endOffset;if(r&&n.collapsed&&this.#J.format.isLine(l.parentNode)&&this.#J.format.isLine(h.parentNode)||l===h&&1===l.nodeType&&Re.check.isNonEditable(l)){const t=l.parentNode;if(!Re.check.isListCell(t)||!Oe.getValues(t.style).some((t=>this.#Tt.includes(t))))return}if(n.collapsed&&!r&&1===l.nodeType&&!Re.check.isBreak(l)&&!this.#J.component.is(l)){let t=null;const e=l.childNodes[a];e&&(t=e.nextSibling?Re.check.isBreak(e)?e:e.nextSibling:null);const s=Re.utils.createTextNode(Ae.zeroWidthSpace);l.insertBefore(s,t),this.#J.selection.setRange(s,1,s,1),n=this.#J.selection.getRange(),l=n.startContainer,a=n.startOffset,h=n.endContainer,c=n.endOffset}this.#J.format.isLine(l)&&(l=l.childNodes[a]||l.firstChild,a=0),this.#J.format.isLine(h)&&(h=h.childNodes[c]||h.lastChild,c=h.textContent.length),o&&(t=Re.utils.createElement("DIV"));const d=RegExp,u=t.nodeName;if(!r&&l===h&&!s&&t){let e=l,s=0;const i=[],n=t.style;for(let t=0,e=n.length;t<e;t++)i.push(n[t]);const r=t.className,a=t.classList;for(let t=0,e=a.length;t<e;t++)i.push("."+a[t]);if(i.length>0){for(;!this.#J.format.isLine(e)&&!Re.check.isWysiwygFrame(e);){for(let t=0;t<i.length;t++)if(1===e.nodeType){const l=i[t],a=!!/^\./.test(l)&&new d("\\s*"+l.replace(/^\./,"")+"(\\s+|$)","ig"),h=e.style,c=e.className,u=o?!!h[l]:!!h[l]&&!!n[l]&&h[l]===n[l],p=!1!==a&&(o?!!c.match(a):!!c.match(a)&&!!r.match(a));(u||p)&&s++}e=e.parentNode}if(s>=i.length)return}}let p,g,m={},f={},v="",b="";if(e){for(let t,s=0,i=e.length;s<i;s++)t=e[s],/^\./.test(t)?b+=(b?"|":"\\s*(?:")+t.replace(/^\./,""):v+=(v?"|":"(?:;|^|\\s)(?:")+t;v&&(v+=")\\s*:[^;]*\\s*(?:;|$)",v=new d(v,"ig")),b&&(b+=")(?=\\s+|$)",b=new d(b,"ig"))}if(s){g="^(?:"+s[0];for(let t=1;t<s.length;t++)g+="|"+s[t];g+=")$",g=new d(g,"i")}const y={v:!1},w=function(t){const e=t.cloneNode(!1);if(3===e.nodeType||Re.check.isBreak(e))return e;if(r)return null;const s=!g&&o||g?.test(e.nodeName);if(s&&!i)return y.v=!0,null;const n=e.style.cssText;let l="";v&&n.length>0&&(l=n.replace(v,"").trim(),l!==n&&(y.v=!0));const a=e.className;let h="";return b&&a.length>0&&(h=a.replace(b,"").trim(),h!==a&&(y.v=!0)),(!o||!b&&a||!v&&n||l||h||!s)&&(l||h||e.nodeName!==u||Boolean(v)!==Boolean(n)||Boolean(b)!==Boolean(a))?(v&&n.length>0&&(e.style.cssText=l),e.style.cssText||e.removeAttribute("style"),b&&a.length>0&&(e.className=h.trim()),e.className.trim()||e.removeAttribute("class"),e.style.cssText||e.className||e.nodeName!==u&&!s?e:(y.v=!0,null)):(y.v=!0,null)},C=this.#J.format.getLines(null);if(0===C.length)return void console.warn("[SUNEDITOR.inline.apply.warn] There is no line to apply.");n=this.#J.selection.getRange(),l=n.startContainer,a=n.startOffset,h=n.endContainer,c=n.endOffset,this.#J.format.getLine(l,null)||(l=Re.query.getEdgeChild(C[0],(function(t){return 3===t.nodeType}),!1),a=0),this.#J.format.getLine(h,null)||(h=Re.query.getEdgeChild(C.at(-1),(function(t){return 3===t.nodeType}),!1),c=h.textContent.length);const _=this.#J.format.getLine(l,null)===this.#J.format.getLine(h,null),k=C.length-(_?0:1);p=t.cloneNode(!1);const x=r||o&&(t=>{for(let e=0,s=t?.length;e<s;e++)if(this._isNonSplitNode(t[e]))return!0;return!1})(s),$=o||this.#Mt(p),S=this.#Nt.bind(this,x,$),E=this.#Bt.bind(this,x,$);if(_){this.#It(C[0],e)&&(n=this.#J.selection.setRange(l,a,h,c));const t=this.#Lt(C[0],p,w,l,a,h,c,r,o,n.collapsed,y,S,E);m.container=t.startContainer,m.offset=t.startOffset,f.container=t.endContainer,f.offset=t.endOffset,m.container===f.container&&Re.check.isZeroWidth(m.container)&&(m.offset=f.offset=1),this.#At(t.ancestor,null)}else{let s=!1;k>0&&this.#It(C[k],e)&&(s=!0),this.#It(C[0],e)&&(s=!0),s&&this.#J.selection.setRange(l,a,h,c),k>0&&(p=t.cloneNode(!1),f=this.#Ot(C[k],p,w,h,c,r,o,y,S,E));for(let s,i=k-1;i>0;i--)this.#It(C[i],e),p=t.cloneNode(!1),s=this.#Rt(C[i],p,w,r,o,y,f.container),s.endContainer&&s.ancestor.contains(s.endContainer)&&(f.ancestor=null,f.container=s.endContainer),this.#At(s.ancestor,null);p=t.cloneNode(!1),m=this.#zt(C[0],p,w,l,a,r,o,y,S,E,f.container),m.endContainer&&(f.ancestor=null,f.container=m.endContainer),k<=0?f=m:f.container||(f.ancestor=null,f.container=m.container,f.offset=m.container.textContent.length),this.#At(m.ancestor,null),this.#At(f.ancestor||this.#J.format.getLine(f.container),null)}return this.#J.ui.offCurrentController(),this.#J.selection.setRange(m.container,m.offset,f.container,f.offset),this.#J.history.push(!1),p}remove(){this.apply(null,{stylesToModify:null,nodesToRemove:null,strictRemove:null})}_isNonSplitNode(t){if(!t)return!1;const e=/^(a|label|code|summary)$/i;return"string"==typeof t?e.test(t):1===t.nodeType&&e.test(t.nodeName)}_isIgnoreNodeChange(t){return t&&1===t.nodeType&&(Re.check.isNonEditable(t)||!this.#J.format.isTextStyleNode(t)||this.#J.component.is(t))}#Lt(t,e,s,i,n,o,r,l,a,h,c,d,u){let p=i.parentNode;for(;!(p.nextSibling||p.previousSibling||this.#J.format.isLine(p.parentNode)||Re.check.isWysiwygFrame(p.parentNode))&&p.nodeName!==e.nodeName;)p=p.parentNode;if(!a&&!l&&p===o.parentNode&&p.nodeName===e.nodeName&&Re.check.isZeroWidth(i.textContent.slice(0,n))&&Re.check.isZeroWidth(o.textContent.slice(r))){const s=p.childNodes;let l=!0;for(let t,e,n,r,a=0,h=s.length;a<h;a++)if(t=s[a],r=!Re.check.isZeroWidth(t),t!==i&&t!==o){if(!e&&r||e&&n&&r){l=!1;break}}else t===i&&(e=!0),t===o&&(n=!0);if(l)return Re.utils.copyTagAttributes(p,e),{ancestor:t,startContainer:i,startOffset:n,endContainer:o,endOffset:r}}c.v=!1;const g=this,m=t,f=[e],v=t.cloneNode(!1),b=i===o;let y,w,C,_,k,x=i,$=n,S=o,E=r,T=!1,M=!1;const N=RegExp;function B(t){const e=new N("(?:;|^|\\s)(?:"+_+"null)\\s*:[^;]*\\s*(?:;|$)","ig");let s=!1;return e&&t.style.cssText.length>0&&(s=e.test(t.style.cssText)),!s}if(function t(i,n){const o=i.childNodes;for(let i,r=0,a=o.length;r<a;r++){const a=o[r];if(!a)continue;let c,p=n;if(!T&&a===x){let t=v;k=d(a);let o="",r="";if(3===x.nodeType){const t=x;o=t.substringData(0,$),r=t.substringData($,b&&E>=$?E-$:t.data.length-$)}const l=Re.utils.createTextNode(o),h=Re.utils.createTextNode(r);if(k){const e=d(n);if(e.parentNode!==t){let s=e,i=null;for(;s.parentNode!==t;){for(n=i=s.parentNode.cloneNode(!1);s.childNodes[0];)i.appendChild(s.childNodes[0]);s.appendChild(i),s=s.parentNode}s.parentNode.appendChild(e)}k=k.cloneNode(!1)}Re.check.isZeroWidth(l)||n.appendChild(l);const c=d(n);for(c&&(k=c),k&&(t=k),w=a,y=[],_="";w!==t&&w!==m&&null!==w;)i=u(w)?null:s(w),i&&1===w.nodeType&&B(w)&&(y.push(i),_+=w.style.cssText.substring(0,w.style.cssText.indexOf(":"))+"|"),w=w.parentElement;const p=y.pop()||h;for(C=w=p;y.length>0;)w=y.pop(),C.appendChild(w),C=w;if(e.appendChild(p),t.appendChild(e),k&&!d(S)&&(e=e.cloneNode(!1),v.appendChild(e),f.push(e)),x=h,$=0,T=!0,w!==h&&w.appendChild(x),!b)continue}if(M||a!==S){if(T){if(1===a.nodeType&&!Re.check.isBreak(a)){g._isIgnoreNodeChange(a)?(v.appendChild(a.cloneNode(!0)),h||(e=e.cloneNode(!1),v.appendChild(e),f.push(e))):t(a,a);continue}w=a,y=[],_="";const o=[];for(;null!==w.parentNode&&w!==m&&w!==e;)i=M?w.cloneNode(!1):s(w),1===w.nodeType&&!Re.check.isBreak(a)&&i&&B(w)&&(u(w)?k||o.push(i):y.push(i),_+=w.style.cssText.substring(0,w.style.cssText.indexOf(":"))+"|"),w=w.parentElement;y=y.concat(o);const r=y.pop()||a;for(C=w=r;y.length>0;)w=y.pop(),C.appendChild(w),C=w;if(!u(e.parentNode)||u(r)||Re.check.isZeroWidth(e)||(e=e.cloneNode(!1),v.appendChild(e),f.push(e)),M||k||!u(r))r===a?n=M?v:e:M?(v.appendChild(r),n=w):(e.appendChild(r),n=w);else{e=e.cloneNode(!1);const t=r.childNodes;for(let s=0,i=t.length;s<i;s++)e.appendChild(t[s]);r.appendChild(e),v.appendChild(r),f.push(e),n=e.children.length>0?w:e}if(k&&3===a.nodeType)if(d(a)){const t=Re.query.getParentElement(n,(t=>g._isNonSplitNode(t.parentNode)||t.parentNode===v));k.appendChild(t),e=t.cloneNode(!1),f.push(e),v.appendChild(e)}else k=null}c=a.cloneNode(!1),n.appendChild(c),1!==a.nodeType||Re.check.isBreak(a)||(p=c),t(a,p)}else{k=d(a);let t="",n="";if(3===S.nodeType){const e=S;t=e.substringData(E,e.length-E),n=b?"":e.substringData(0,E)}const o=Re.utils.createTextNode(t),r=Re.utils.createTextNode(n);if(k?k=k.cloneNode(!1):u(e.parentNode)&&!k&&(e=e.cloneNode(!1),v.appendChild(e),f.push(e)),!Re.check.isZeroWidth(o)){w=a,_="",y=[];const t=[];for(;w!==v&&w!==m&&null!==w;)1===w.nodeType&&B(w)&&(u(w)?t.push(w.cloneNode(!1)):y.push(w.cloneNode(!1)),_+=w.style.cssText.substring(0,w.style.cssText.indexOf(":"))+"|"),w=w.parentElement;for(y=y.concat(t),c=C=w=y.pop()||o;y.length>0;)w=y.pop(),C.appendChild(w),C=w;v.appendChild(c),w.textContent=o.data}if(k&&c){const t=d(c);t&&(k=t)}for(w=a,y=[],_="";w!==v&&w!==m&&null!==w;)i=u(w)?null:s(w),i&&1===w.nodeType&&B(w)&&(y.push(i),_+=w.style.cssText.substring(0,w.style.cssText.indexOf(":"))+"|"),w=w.parentElement;const p=y.pop()||r;for(C=w=p;y.length>0;)w=y.pop(),C.appendChild(w),C=w;k?((e=e.cloneNode(!1)).appendChild(p),k.insertBefore(e,k.firstChild),v.appendChild(k),f.push(e),k=null):e.appendChild(p),S=r,E=r.data.length,M=!0,!l&&h&&(e=r,r.textContent=Ae.zeroWidthSpace),w!==r&&w.appendChild(S)}}}(t,v),a&&!l&&!c.v)return{ancestor:t,startContainer:i,startOffset:n,endContainer:o,endOffset:r};if(l&&=a,l)for(let t=0;t<f.length;t++){const e=f[t];let s,i,n;if(h)s=Re.utils.createTextNode(Ae.zeroWidthSpace),v.replaceChild(s,e);else{const t=e.childNodes;for(i=t[0];t[0];)n=t[0],v.insertBefore(n,e);Re.utils.removeItem(e)}0===t&&(h?x=S=s:(x=i,S=n))}else{if(a)for(let t=0;t<f.length;t++)As(f[t]);h&&(x=S=e)}this.#J.nodeTransform.removeEmptyNode(v,e,!1),h&&($=x.textContent.length,E=S.textContent.length);const I=l||0===S.textContent.length;Re.check.isBreak(S)||0!==S.textContent.length||(Re.utils.removeItem(S),S=x),E=I?S.textContent.length:E;const L={s:0,e:0},A=Re.query.getNodePath(x,v,L),O=!S.parentNode;O&&(S=x);const R={s:0,e:0},z=Re.query.getNodePath(S,v,O||I?null:R);$+=L.s,E=h?$:O?x.textContent.length:I?E+L.s:E+R.s;const P=this.#J.nodeTransform.mergeSameTags(v,[A,z],!0);return t.parentNode.replaceChild(v,t),x=Re.query.getNodeFromPath(A,v),S=Re.query.getNodeFromPath(z,v),{ancestor:v,startContainer:x,startOffset:$+P[0],endContainer:S,endOffset:E+P[1]}}#zt(t,e,s,i,n,o,r,l,a,h,c){let d=i.parentNode;for(;!(d.nextSibling||d.previousSibling||this.#J.format.isLine(d.parentNode)||Re.check.isWysiwygFrame(d.parentNode))&&d.nodeName!==e.nodeName;)d=d.parentNode;if(!r&&!o&&d.nodeName===e.nodeName&&!this.#J.format.isLine(d)&&!d.nextSibling&&Re.check.isZeroWidth(i.textContent.slice(0,n))){let s=!0,o=i.previousSibling;for(;o;){if(!Re.check.isZeroWidth(o)){s=!1;break}o=o.previousSibling}if(s)return Re.utils.copyTagAttributes(d,e),{ancestor:t,container:i,offset:n}}l.v=!1;const u=this,p=t,g=[e],m=t.cloneNode(!1);let f,v,b,y,w=i,C=n,_=!1;if(function t(i,n){const o=i.childNodes;for(let i,r,l=0,d=o.length;l<d;l++){const d=o[l];if(!d)continue;let k=n;if(_&&!Re.check.isBreak(d)){if(1===d.nodeType){if(u._isIgnoreNodeChange(d)){if(e=e.cloneNode(!1),r=d.cloneNode(!0),m.appendChild(r),m.appendChild(e),g.push(e),c&&d.contains(c)){const t=Re.query.getNodePath(c,d);c=Re.query.getNodeFromPath(t,r)}}else t(d,d);continue}v=d,f=[];const o=[];for(;null!==v.parentNode&&v!==p&&v!==e;)i=s(v),1===v.nodeType&&i&&(h(v)?y||o.push(i):f.push(i)),v=v.parentNode;f=f.concat(o);const l=f.length>0,w=f.pop()||d;for(b=v=w;f.length>0;)v=f.pop(),b.appendChild(v),b=v;if(h(e.parentNode)&&!h(w)&&(e=e.cloneNode(!1),m.appendChild(e),g.push(e)),!y&&h(w)){e=e.cloneNode(!1);const t=w.childNodes;for(let s=0,i=t.length;s<i;s++)e.appendChild(t[s]);w.appendChild(e),m.appendChild(w),n=h(v)?e:v,g.push(e)}else l?(e.appendChild(w),n=v):n=e;if(y&&3===d.nodeType)if(a(d)){const t=Re.query.getParentElement(n,(t=>u._isNonSplitNode(t.parentNode)||t.parentNode===m));y.appendChild(t),e=t.cloneNode(!1),g.push(e),m.appendChild(e)}else y=null}if(_||d!==w)i=_?s(d):d.cloneNode(!1),i&&(n.appendChild(i),1!==d.nodeType||Re.check.isBreak(d)||(k=i)),t(d,k);else{let t=m;y=a(d);let o="",r="";if(3===w.nodeType){const t=w;o=t.substringData(0,C),r=t.substringData(C,t.length-C)}const l=Re.utils.createTextNode(o),h=Re.utils.createTextNode(r);if(y){const e=a(n);if(e&&e.parentNode!==t){let s=e,i=null;for(;s.parentNode!==t;){for(n=i=s.parentNode.cloneNode(!1);s.childNodes[0];)i.appendChild(s.childNodes[0]);s.appendChild(i),s=s.parentNode}s.parentNode.appendChild(e)}y=y.cloneNode(!1)}Re.check.isZeroWidth(l)||n.appendChild(l);const c=a(n);for(c&&(y=c),y&&(t=y),v=n,f=[];v!==t&&null!==v;)i=s(v),1===v.nodeType&&i&&f.push(i),v=v.parentNode;const u=f.pop()||n;for(b=v=u;f.length>0;)v=f.pop(),b.appendChild(v),b=v;u!==n?(e.appendChild(u),n=v):n=e,Re.check.isBreak(d)&&e.appendChild(d.cloneNode(!1)),t.appendChild(e),w=h,C=0,_=!0,n.appendChild(w)}}}(t,m),r&&!o&&!l.v)return{ancestor:t,container:i,offset:n,endContainer:c};if(o&&=r,o)for(let t=0;t<g.length;t++){const e=g[t],s=e.childNodes,i=s[0];for(;s[0];)m.insertBefore(s[0],e);Re.utils.removeItem(e),0===t&&(w=i)}else if(r){e=e.firstChild;for(let t=0;t<g.length;t++)As(g[t])}if(o||0!==m.childNodes.length){this.#J.nodeTransform.removeEmptyNode(m,e,!1),Re.check.isZeroWidth(m.textContent)&&(w=m.firstChild,C=0);const s={s:0,e:0},i=Re.query.getNodePath(w,m,s);C+=s.s;const n=this.#J.nodeTransform.mergeSameTags(m,[i],!0);t.parentNode.replaceChild(m,t),w=Re.query.getNodeFromPath(i,m),C+=n[0]}else t.childNodes?w=t.childNodes[0]:(w=Re.utils.createTextNode(Ae.zeroWidthSpace),t.appendChild(w));return{ancestor:m,container:w,offset:C,endContainer:c}}#Rt(t,e,s,i,n,o,r){if(!n){let s=null;r&&t.contains(r)&&(s=Re.query.getNodePath(r,t));const i=t.cloneNode(!0),n=e.nodeName,o=e.style.cssText,l=e.className;let a=i.childNodes,h=0,c=a.length;for(let t;h<c&&(t=a[h],3!==t.nodeType);h++){if(t.nodeName!==n){if(!Re.check.isBreak(t)&&this._isIgnoreNodeChange(t))continue;if(1===c){a=t.childNodes,c=a.length,h=-1;continue}break}t.style.cssText+=o,Re.utils.addClass(t,l)}if(c>0&&h===c)return t.innerHTML=i.innerHTML,{ancestor:t,endContainer:s?Re.query.getNodeFromPath(s,t):null}}o.v=!1;const l=this,a=t.cloneNode(!1),h=[e];let c=!0;if(function t(i,n){const o=i.childNodes;for(let i,d,u=0,p=o.length;u<p;u++){const p=o[u];if(!p)continue;let g=n;if(Re.check.isBreak(p)||!l._isIgnoreNodeChange(p))i=s(p),i&&(c=!1,n.appendChild(i),1===p.nodeType&&(g=i)),Re.check.isBreak(p)||t(p,g);else if(e.childNodes.length>0&&(a.appendChild(e),e=e.cloneNode(!1)),d=p.cloneNode(!0),a.appendChild(d),a.appendChild(e),h.push(e),n=e,r&&p.contains(r)){const t=Re.query.getNodePath(r,p);r=Re.query.getNodeFromPath(t,d)}}}(t,e),c||n&&!i&&!o.v)return{ancestor:t,endContainer:r};if(a.appendChild(e),i&&n)for(let t=0;t<h.length;t++){const e=h[t],s=e.childNodes;for(;s[0];)a.insertBefore(s[0],e);Re.utils.removeItem(e)}else if(n){e=e.firstChild;for(let t=0;t<h.length;t++)As(h[t])}return this.#J.nodeTransform.removeEmptyNode(a,e,!1),this.#J.nodeTransform.mergeSameTags(a,null,!0),t.parentNode.replaceChild(a,t),{ancestor:a,endContainer:r}}#Ot(t,e,s,i,n,o,r,l,a,h){let c=i.parentNode;for(;!(c.nextSibling||c.previousSibling||this.#J.format.isLine(c.parentNode)||Re.check.isWysiwygFrame(c.parentNode))&&c.nodeName!==e.nodeName;)c=c.parentNode;if(!r&&!o&&c.nodeName===e.nodeName&&!this.#J.format.isLine(c)&&!c.previousSibling&&Re.check.isZeroWidth(i.textContent.slice(n))){let s=!0,o=i.nextSibling;for(;o;){if(!Re.check.isZeroWidth(o)){s=!1;break}o=o.nextSibling}if(s)return Re.utils.copyTagAttributes(c,e),{ancestor:t,container:i,offset:n}}l.v=!1;const d=this,u=t,p=[e],g=t.cloneNode(!1);let m,f,v,b,y=i,w=n,C=!1;if(function t(i,n){const o=i.childNodes;for(let i,r=o.length-1;0<=r;r--){const l=o[r];if(!l)continue;let c=n;if(C&&!Re.check.isBreak(l)){if(1===l.nodeType){if(d._isIgnoreNodeChange(l)){e=e.cloneNode(!1);const t=l.cloneNode(!0);g.insertBefore(t,n),g.insertBefore(e,t),p.push(e)}else t(l,l);continue}f=l,m=[];const o=[];for(;null!==f.parentNode&&f!==u&&f!==e;)i=s(f),i&&1===f.nodeType&&(h(f)?b||o.push(i):m.push(i)),f=f.parentNode;m=m.concat(o);const r=m.length>0,c=m.pop()||l;for(v=f=c;m.length>0;)f=m.pop(),v.appendChild(f),v=f;if(h(e.parentNode)&&!h(c)&&(e=e.cloneNode(!1),g.insertBefore(e,g.firstChild),p.push(e)),!b&&h(c)){e=e.cloneNode(!1);const t=c.childNodes;for(let s=0,i=t.length;s<i;s++)e.appendChild(t[s]);c.appendChild(e),g.insertBefore(c,g.firstChild),p.push(e),n=e.children.length>0?f:e}else r?(e.insertBefore(c,e.firstChild),n=f):n=e;if(b&&3===l.nodeType)if(a(l)){const t=Re.query.getParentElement(n,(t=>d._isNonSplitNode(t.parentNode)||t.parentNode===g));b.appendChild(t),e=t.cloneNode(!1),p.push(e),g.insertBefore(e,g.firstChild)}else b=null}if(C||l!==y)i=C?s(l):l.cloneNode(!1),i&&(n.insertBefore(i,n.firstChild),1!==l.nodeType||Re.check.isBreak(l)||(c=i)),t(l,c);else{b=a(l);let t="",o="";if(3===y.nodeType){const e=y;t=e.substringData(w,e.length-w),o=e.substringData(0,w)}const r=Re.utils.createTextNode(t),c=Re.utils.createTextNode(o);if(b){b=b.cloneNode(!1);const t=a(n);if(t.parentNode!==g){let e=t,s=null;for(;e.parentNode!==g;){for(n=s=e.parentNode.cloneNode(!1);e.childNodes[0];)s.appendChild(e.childNodes[0]);e.appendChild(s),e=e.parentNode}e.parentNode.insertBefore(t,e.parentNode.firstChild)}b=b.cloneNode(!1)}else h(e.parentNode)&&!b&&(e=e.cloneNode(!1),g.appendChild(e),p.push(e));for(Re.check.isZeroWidth(r)||n.insertBefore(r,n.firstChild),f=n,m=[];f!==g&&null!==f;)i=h(f)?null:s(f),i&&1===f.nodeType&&m.push(i),f=f.parentNode;const d=m.pop()||n;for(v=f=d;m.length>0;)f=m.pop(),v.appendChild(f),v=f;d!==n?(e.insertBefore(d,e.firstChild),n=f):n=e,Re.check.isBreak(l)&&e.appendChild(l.cloneNode(!1)),b?(b.insertBefore(e,b.firstChild),g.insertBefore(b,g.firstChild),b=null):g.insertBefore(e,g.firstChild),y=c,w=c.data.length,C=!0,n.insertBefore(y,n.firstChild)}}}(t,g),r&&!o&&!l.v)return{ancestor:t,container:i,offset:n};if(o&&=r,o)for(let t=0;t<p.length;t++){const e=p[t],s=e.childNodes;let i=null;for(;s[0];)i=s[0],g.insertBefore(i,e);Re.utils.removeItem(e),t===p.length-1&&(y=i,w=i.textContent.length)}else if(r){e=e.firstChild;for(let t=0;t<p.length;t++)As(p[t])}if(o||0!==g.childNodes.length){if(!r&&0===e.textContent.length)return this.#J.nodeTransform.removeEmptyNode(g,null,!1),{ancestor:null,container:null,offset:0};this.#J.nodeTransform.removeEmptyNode(g,e,!1),Re.check.isZeroWidth(g.textContent)?(y=g.firstChild,w=y.textContent.length):Re.check.isZeroWidth(y)&&(y=e,w=1);const s={s:0,e:0},i=Re.query.getNodePath(y,g,s);w+=s.s;const n=this.#J.nodeTransform.mergeSameTags(g,[i],!0);t.parentNode.replaceChild(g,t),y=Re.query.getNodeFromPath(i,g),w+=n[0]}else t.childNodes?y=t.childNodes[0]:(y=Re.utils.createTextNode(Ae.zeroWidthSpace),t.appendChild(y));return{ancestor:g,container:y,offset:1===y.nodeType&&1===w?y.childNodes.length:w}}#Mt(t){return t&&"string"!=typeof t&&3!==t.nodeType&&this.#J.format.isTextStyleNode(t)&&!!t.style.fontSize}#Nt(t,e,s){return!s||t?null:Re.query.getParentElement(s,this._isNonSplitNode.bind(this))||(e?null:Re.query.getParentElement(s,this.#Mt.bind(this)))}#Bt(t,e,s){if(!s||t||1!==s.nodeType)return!1;const i=this._isNonSplitNode(s);return Re.query.getParentElement(s,this._isNonSplitNode.bind(this))?i:i||!e&&this.#Mt(s)}#At(t,e){if(!Re.check.isListCell(t))return;const s=Re.utils.arrayFilter((e||t).childNodes,(t=>!Re.check.isBreak(t)));if(e=s[0],!Re.check.isElement(e)||s.length>1)return;const i=e.style,n=t.style,o=e.nodeName.toLowerCase();let r=!1;this.#ot.get("_defaultStyleTagMap")[o]===this.#ot.get("_defaultTagCommand").bold.toLowerCase()&&(n.fontWeight="bold"),this.#ot.get("_defaultStyleTagMap")[o]===this.#ot.get("_defaultTagCommand").italic.toLowerCase()&&(n.fontStyle="italic");const l=Oe.getValues(i);if(l.length>0)for(let t=0,e=this.#Et.length;t<e;t++)l.includes(this.#Tt[t])&&(n[this.#Et[t]]=i[this.#Et[t]],i.removeProperty(this.#Tt[t]),r=!0);if(this.#At(t,e),r&&0===i.length){const t=e.childNodes,s=e.parentNode,i=e.nextSibling;for(;t.length>0;)s.insertBefore(t[0],i);Re.utils.removeItem(e)}}#It(t,e){if(!Re.check.isListCell(t))return;e||=this.#Tt;const s=Re.utils.arrayFilter(t.childNodes,(t=>!Re.check.isBreak(t))),i=t.style,n=[],o=[],r=Oe.getValues(i);for(let t=0,s=this.#Tt.length;t<s;t++)r.includes(this.#Tt[t])&&e.includes(this.#Tt[t])&&(n.push(this.#Et[t]),o.push(this.#Tt[t]));if(0===n.length)return;const l=Re.utils.createElement("SPAN");for(let t=0,e=n.length;t<e;t++)l.style[n[t]]=i[o[t]],i.removeProperty(o[t]);let a=l.cloneNode(!1),h=null,c=!1;for(let e,i,o=0,r=s.length;o<r;o++)e=s[o],this.#ot.get("_defaultStyleTagMap")[e.nodeName.toLowerCase()]||(i=Oe.getValues(e.style),0===i.length||n.some((function(t){return!i.includes(t)}))&&i.some((function(t){return n.includes(t)}))?(h=e.nextSibling,a.appendChild(e)):a.childNodes.length>0&&(t.insertBefore(a,h),a=l.cloneNode(!1),h=null,c=!0));return a.childNodes.length>0&&(t.insertBefore(a,h),c=!0),0===i.length&&t.removeAttribute("style"),c}};function Rs(t){const e=t.parentNode;let s,i,n,o,r,l=e.parentNode,a=e;for(;Re.check.isListCell(l);){for(o=Re.query.getPositionIndex(t),s=l.nextElementSibling,i=l.parentNode,n=a;n;){if(a=a.nextSibling,Re.check.isList(n)){for(r=n.childNodes;r[o];)i.insertBefore(r[o],s);0===r.length&&Re.utils.removeItem(n)}else i.appendChild(n);n=a}l=i.parentNode}return 0===e.children.length&&Re.utils.removeItem(e),i}const zs=class{#J;#t;constructor(t){this.#J=t.$,this.#t=t.store}apply(t,e,s){const i=(t.split(":")[0]||"ol").toUpperCase(),n=t.split(":")[1]||"";let o=this.#J.selection.getRange(),r=e||this.#J.format.getLinesAndComponents(!1);if(0===r.length){if(e)return;if(o=this.#J.selection.getRangeAndAddLine(o,null),r=this.#J.format.getLinesAndComponents(!1),0===r.length)return}Re.query.sortNodeByDepth(r,!0);const l=r[0],a=r.at(-1);let h=!Re.check.isListCell(l)&&!this.#J.component.is(l)||l.previousElementSibling?l.previousElementSibling:l.parentElement.previousElementSibling,c=!Re.check.isListCell(a)&&!this.#J.component.is(a)||a.nextElementSibling?a.nextElementSibling:a.parentElement.nextElementSibling;const d=o.collapsed,u={sc:o.startContainer,so:o.startContainer===o.endContainer&&Re.check.isZeroWidth(o.startContainer)&&0===o.startOffset&&1===o.endOffset?o.endOffset:o.startOffset,ec:o.endContainer,eo:o.endOffset};let p=null,g=!0;for(let t=0,e=r.length;t<e;t++)if(!Re.check.isList(this.#J.format.getBlock(r[t],(e=>this.#J.format.getBlock(e)&&e!==r[t])))){g=!1;break}if(!g||h&&l.tagName===h.tagName&&i===h.tagName.toUpperCase()||c&&a.tagName===c.tagName&&i===c.tagName.toUpperCase()){const t=h?h.parentNode:h,e=c?c.parentNode:c;h=t&&!Re.check.isWysiwygFrame(t)&&t.nodeName===i?t:h,c=e&&!Re.check.isWysiwygFrame(e)&&e.nodeName===i?e:c;const s=h?.tagName===i,o=c?.tagName===i;let l=s?h:Re.utils.createElement(i,{style:"list-style-type: "+n}),a=null,d=null;const u=t=>!Re.check.isComponentContainer(t)&&!Re.check.isList(t);for(let t,e,o,h,c,p,g,m,f,v=0,b=r.length;v<b;v++)if(e=r[v],0!==e.childNodes.length||this.#J.inline._isIgnoreNodeChange(e)){if(h=r[v+1],c=e.parentNode,p=h?h.parentNode:null,o=Re.check.isListCell(e),f=this.#J.format.isBlock(c)?c:null,g=o&&!Re.check.isWysiwygFrame(c)?c.parentNode:c,m=o&&!Re.check.isWysiwygFrame(c)?!h||Re.check.isListCell(g)?c:c.nextSibling:e.nextSibling,t=Re.utils.createElement("LI"),this.#J.component.is(e)){const s=/^HR$/i.test(e.nodeName);s||(t.innerHTML="<br>"),t.innerHTML+=e.outerHTML,s&&(t.innerHTML+="<br>")}else{Re.utils.copyFormatAttributes(t,e);const s=e.childNodes;for(;s[0];)t.appendChild(s[0])}l.appendChild(t),h&&g===p&&!this.#J.format.isBlock(m)||(a||=l,s&&h&&g===p||h&&Re.check.isList(p)&&p===c||l.parentNode!==g&&g.insertBefore(l,m)),Re.utils.removeItem(e),s&&null===d&&(d=l.children.length-1),h&&(this.#J.format.getBlock(p,u)!==this.#J.format.getBlock(c,u)||Re.check.isList(p)&&Re.check.isList(c)&&Re.query.getNodeDepth(p)!==Re.query.getNodeDepth(c))&&(l=Re.utils.createElement(i,{style:"list-style-type: "+n})),0===f?.children.length&&Re.utils.removeItem(f)}else Re.utils.removeItem(e);d&&(a=a.children[d]),o&&(l.innerHTML+=c.innerHTML,Re.utils.removeItem(c))}else{if(s)for(let t=0,e=r.length;t<e;t++)for(let s=t-1;s>=0;s--)if(r[s].contains(r[t])){r.splice(t,1),t--,e--;break}const t=this.#J.format.getBlock(l),e=t?.tagName===i;let o,a;const h=t=>!Re.check.isComponentContainer(t);e||(a=Re.utils.createElement(i,{style:"list-style-type: "+n}));for(let t,l,c=0,d=r.length;c<d;c++)l=this.#J.format.getBlock(r[c],h),l&&Re.check.isList(l)&&(t?t!==l?(s&&Re.check.isListCell(l.parentNode)?this.#Pt(o.f):p=this.#J.format.removeBlock(o.f[0].parentElement,{selectedFormats:o.f,newBlockElement:a,shouldDelete:!1,skipHistory:!0}),l=r[c].parentNode,e||(a=Re.utils.createElement(i,{style:"list-style-type: "+n})),t=l,o={r:t,f:[Re.query.getParentElement(r[c],"LI")]}):o.f.push(Re.query.getParentElement(r[c],"LI")):(t=l,o={r:t,f:[Re.query.getParentElement(r[c],"LI")]}),c===d-1&&(s&&Re.check.isListCell(l.parentNode)?this.#Pt(o.f):p=this.#J.format.removeBlock(o.f[0].parentElement,{selectedFormats:o.f,newBlockElement:a,shouldDelete:!1,skipHistory:!0})))}return this.#t.set("_lastSelectionNode",null),g&&d&&p||u}remove(t,e){let s={},i=!1,n=!1,o=null,r=null;const l=t=>!Re.check.isComponentContainer(t);for(let a,h,c,d,u=0,p=t.length;u<p;u++){if(c=u===p-1,h=this.#J.format.getBlock(t[u],l),d=Re.check.isList(h),!a&&d)a=h,s={r:a,f:[Re.query.getParentElement(t[u],"LI")]},0===u&&(i=!0);else if(a&&d)if(a!==h){const l=this.#J.format.removeBlock(s.f[0].parentNode,{selectedFormats:s.f,newBlockElement:null,shouldDelete:e,skipHistory:!0});h=t[u].parentNode,i&&(o=l.sc,i=!1),c&&(r=l.ec),d?(a=h,s={r:a,f:[Re.query.getParentElement(t[u],"LI")]},c&&(n=!0)):a=null}else s.f.push(Re.query.getParentElement(t[u],"LI")),c&&(n=!0);if(c&&Re.check.isList(a)){const t=this.#J.format.removeBlock(s.f[0].parentNode,{selectedFormats:s.f,newBlockElement:null,shouldDelete:e,skipHistory:!0});(n||1===p)&&(r=t.ec),i&&(o=t.sc||r)}}return{sc:o,ec:r}}applyNested(t,e){const s=(t=t||this.#J.format.getLines().filter((function(t){return Re.check.isListCell(t)}))).length;if(0===s||!e&&!Re.check.isListCell(t[0].previousElementSibling)&&!Re.check.isListCell(t.at(-1).nextElementSibling))return{sc:t[0],so:0,ec:t.at(-1),eo:1};let i=t[0].parentElement,n=t.at(-1),o=null;if(e){if(i!==n.parentElement&&Re.check.isList(n.parentElement?.parentElement)&&n.nextElementSibling)for(n=n.nextElementSibling;n;)t.push(n),n=n.nextElementSibling;o=this.apply(i.nodeName+":"+i.style.listStyleType,t,!0)}else{let e=Re.utils.createElement(i.nodeName),r=t[0].previousElementSibling,l=n.nextElementSibling;const a={s:null,e:null,sl:i,el:i},{startContainer:h,startOffset:c,endContainer:d,endOffset:u}=this.#J.selection.getRange();for(let n,o=0,h=s;o<h;o++)n=t[o],n.parentElement!==i&&(this.#Dt(i,e,r,l,a),i=n.parentElement,e=Re.utils.createElement(i.nodeName)),r=n.previousElementSibling,l=n.nextElementSibling,e.appendChild(n);if(this.#Dt(i,e,r,l,a),s>1){const t=Re.query.getNodeFromPath(a.s,a.sl),e=Re.query.getNodeFromPath(a.e,a.el);o={sc:t,so:0,ec:e,eo:e.textContent.length}}else o={sc:h,so:c,ec:d,eo:u}}return o}removeNested(t,e){const s=Rs(t);let i,n,o;if(s){i=s.cloneNode(!1),n=s.childNodes;const e=Re.query.getPositionIndex(t);for(;n[e];)i.appendChild(n[e])}else i=t;if(e)o=Re.query.getListChildren(i,(t=>Re.check.isListCell(t)&&!t.previousElementSibling),null);else{const e=Re.query.getNodeDepth(t)+2;o=Re.query.getListChildren(t,(t=>Re.check.isListCell(t)&&!t.previousElementSibling&&Re.query.getNodeDepth(t)===e),null)}for(let t=0,e=o.length;t<e;t++)Rs(o[t]);return s&&(s.parentNode.insertBefore(i,s.nextSibling),0===n?.length&&Re.utils.removeItem(s)),i===t?i.parentNode:i}#Dt(t,e,s,i,n){let o=!1;if(e.tagName===s?.tagName){const t=e.children;for(;t[0];)s.appendChild(t[0]);e=s,o=!0}if(e.tagName===i?.tagName){const t=i.children;for(;t[0];)e.appendChild(t[0]);const s=i.nextElementSibling;i.parentNode.removeChild(i),i=s}if(!o){Re.check.isListCell(s)&&(t=s,i=null),t.insertBefore(e,i),n.s||(n.s=Re.query.getNodePath(e.firstElementChild.firstChild,t,null),n.sl=t);const o=t.contains(n.sl)?Re.query.getNodePath(n.sl,t):null;n.e=Re.query.getNodePath(e.lastElementChild.firstChild,t,null),n.el=t,this.#J.nodeTransform.mergeSameTags(t,[n.s,n.e,o],!1),this.#J.nodeTransform.mergeNestedTags(t),o&&(n.sl=Re.query.getNodeFromPath(o,t))}return e}#Pt(t){const e=t[0],s=t.at(-1),i=s.nextElementSibling,n=e.parentElement,o=n.parentElement.nextElementSibling,r=n.parentElement.parentElement;for(let e=0,s=t.length;e<s;e++)r.insertBefore(t[e],o);if(i&&n.children.length>0){const t=n.cloneNode(!1),e=n.childNodes,o=Re.query.getPositionIndex(i);for(;e[o];)t.appendChild(e[o]);s.appendChild(t)}0===n.children.length&&Re.utils.removeItem(n),this.#J.nodeTransform.mergeSameTags(r);const l=Re.query.getEdgeChildNodes(e,s);return{cc:e.parentNode,sc:l.sc,ec:l.ec}}},{_d:Ps}=Le,Ds=new RegExp(Ae.zeroWidthSpace+"+","g");const Fs=/^<[a-z0-9]+:[a-z0-9]+/i,Hs=/(?!<)[a-zA-Z0-9-]+/,qs=/\s(?:on[a-z]+)\s*=\s*(?:(["'])[^"']*\1|\S+)/gi,Ws=/style=/i,Us=/style\s*=\s*(?:"|')[^"']*(?:"|')/,Vs=/class\s*=\s*("|')(?:[^"']*\s)?se-component(?=[\s"'])/i,js=/^\s/,Gs=/<[^\s]+\s(.+)/,Ks=/^[ \t\n\r\f\v]+$/,Ys=/\ssize="([^"]+)"/i,Xs=/\sface="([^"]+)"/i,Zs=/\scolor="([^"]+)"/i,Js=/"/g,Qs=/([a-zA-Z0-9-]+)(:)([^"']+)/,ti=/inherit|initial|revert|unset/i,ei=/"/g,si=/:\s*([^;]+)/,ii=/rgba\(([0-9]+\s*,\s*){3}0\)|windowtext/i,ni=/[^;]+;/g,oi=/^span$/i,ri=/^(?:https?|ftps?|mailto|tel|blob|sms|geo|webcal|callto):|^[#/]|^data:image\//i,li=/^(?:href|src)\s*=/i,ai=/=\s*(?:"([^"]*)"|'([^']*)'|(\S+))/,hi=/:/i;function ci(t){const e=function(t){let e,s=5;do{e=t,t=t.replace(/&(#x([0-9a-f]+)|#([0-9]+)|([a-z]+));/gi,((t,e,s,i)=>s?String.fromCharCode(parseInt(s,16)):i?String.fromCharCode(parseInt(i,10)):""))}while(t!==e&&--s);try{t=decodeURIComponent(t)}catch{}return t.replace(/[\u0000-\u0020]+/g,"")}(t);return ri.test(e)||!hi.test(e)}function di(t){if(!li.test(t))return!0;const e=t.match(ai);if(!e)return!0;return ci(e[1]??e[2]??e[3]??"")}function ui(t,e){return t?"*"===t?"[a-z-]+":e?t+"|"+e:t:"^"}const pi=class{#J;#t;#X;#Q;#ot;#dt;#Ft;#Ht;#qt;#Wt;#Ut;#Vt;#jt;#Gt;#Kt;#Yt;#Xt;#Zt;#Jt;#Qt;#te;#ee;#se;#ie;#ne;constructor(t){this.#J=t.$,this.#t=t.store;const e=this.#ot=this.#J.options;this.#Q=this.#J.frameOptions,this.#X=this.#J.frameContext,this.#dt=this.#J.instanceCheck,this.#Ht=function(t){return this.test(t)?t:""}.bind(e.get("allowedClassName")),this.#Jt=e.get("_textStyleTags");const s=e.get("tagStyles"),i={};for(const t in s){const e=t.split("|");for(let n,o=0,r=e.length;o<r;o++)n=e[o],i[n]?i[n]+="|":i[n]="",i[n]+=s[t]}for(const t in i)i[t]=new RegExp(`\\s*[^-a-zA-Z](${i[t]})\\s*:[^;]+(?!;)*`,"gi");const n=new Map;for(const t in i)n.set(new RegExp(`^(${t})$`),i[t]);this.#Xt=new RegExp(`^(${Object.keys(i).join("|")})$`,"i"),this.#Zt=n,this.#Ft=new RegExp("\\d+("+e.get("fontSizeUnits").join("|")+")$","i");const o=e.get("_allowedExtraTag"),r=e.get("_disallowedExtraTag");this.#Qt=new RegExp(`<(${r})[^>]*>([\\s\\S]*?)<\\/\\1>|<(${r})[^>]*\\/?>`,"gi"),this.#te=new RegExp(`^(${r})$`,"i"),this.#ee=new RegExp(`^(${o})$`,"i");const l=Object.keys(e.get("_defaultStyleTagMap")),a=e.get("elementWhitelist")?e.get("elementWhitelist").split("|").filter((t=>/b|i|ins|s|strike/i.test(t))):[];for(let t=0;t<a.length;t++)l.splice(l.indexOf(a[t].toLowerCase()),1);this.#Wt=0===l.length?null:new RegExp("(<\\/?)("+l.join("|")+")\\b\\s*([^>^<]+)?\\s*(?=>)","gi");const h=e.get("__defaultAttributeWhitelist");this.#qt=e.get("_editorElementWhitelist").includes("//")||"*"===e.get("_editorElementWhitelist"),this.#Ut=new RegExp("^("+ui(e.get("_editorElementWhitelist").replace("|//",""),"")+")$","i"),this.#Vt=new RegExp("^("+(e.get("elementBlacklist")||"^")+")$","i"),this.#jt=Oe.createElementWhitelist(ui(e.get("_editorElementWhitelist").replace("|//","|\x3c!--|--\x3e"),"")),this.#Gt=Oe.createElementBlacklist(e.get("elementBlacklist").replace("|//","|\x3c!--|--\x3e"));const c='\\s*=\\s*(")[^"]*\\1',d=e.get("attributeWhitelist");let u={},p="";if(d)for(const t in d)/^on[a-z]+$/i.test(d[t])||("*"===t?p=ui(d[t],h):u[t]=new RegExp("\\s(?:"+ui(d[t],h)+")"+c,"ig"));this.#Kt=new RegExp("\\s(?:"+(p||h)+"|data-se-[^\\s]+"+(e.get("v2Migration")?"|data-index|data-file-size|data-file-name|data-exp|data-font-size":"")+")"+c,"ig"),this.#se=u;const g=e.get("attributeBlacklist");if(u={},p="",g)for(const t in g)"*"===t?p=ui(g[t],""):u[t]=new RegExp("\\s(?:"+ui(g[t],"")+")"+c,"ig");this.#Yt=new RegExp("\\s(?:"+(p||"^")+")"+c,"ig"),this.#ie=u,this.__resetAutoStyleify(e.get("autoStyleify"))}filter(t,{tagWhitelist:e,tagBlacklist:s,validate:i,validateAll:n}){if(e&&(t=t.replace(Oe.createElementWhitelist(e),"")),s&&(t=t.replace(Oe.createElementBlacklist(s),"")),i){const e=(new DOMParser).parseFromString(t,"text/html");e.body.querySelectorAll("*").forEach((t=>{if(n||!t.closest(".se-component")&&!t.closest(".se-flex-component")){const e=i(t);null===e?t.remove():this.#dt.isNode(e)?t.replaceWith(e):"string"==typeof e&&(t.outerHTML=e)}})),t=e.body.innerHTML}return t}clean(t,{forceFormat:e,whitelist:s,blacklist:i,_freeCodeViewMode:n}={}){const{tagFilter:o,formatFilter:r,classFilter:l,textStyleTagFilter:a,attrFilter:h,styleFilter:c}=this.#ot.get("strictMode");let d="";if(t=this.compress(t),o&&(t=t.replace(this.#Qt,""),t=this.#oe(t,this.#jt,this.#Gt).replace(/<br\/?>$/i,"")),this.#ne){const e=(new DOMParser).parseFromString(t,"text/html");Re.query.getListChildNodes(e.body,Oe.spanToStyleNode.bind(null,this.#ne),null),t=e.body.innerHTML}(h||c)&&(t=t.replace(/(<[a-zA-Z0-9-]+)[^>]*(?=>)/g,this.#re.bind(this,h,c)));const u=Ps.createRange().createContextualFragment(t);if(o)try{this.#le(u,this.#Ut,this.#Vt,o,r,l,n)}catch(t){console.warn("[SUNEDITOR.html.clean.fail]",t.message)}const p=u.querySelectorAll("[data-se-iframe-holder]");for(let t=0,e=p.length;t<e;t++){const e=Re.utils.createElement("iframe"),s=JSON.parse(p[t].getAttribute("data-se-iframe-holder-attrs"));for(const[t,i]of Object.entries(s))/^on/i.test(t)||("src"!==t||ci(String(i)))&&e.setAttribute(t,i);p[t].replaceWith(e)}if(this.#J.pluginManager.applyRetainFormat(u),r){let t=u.childNodes;e||=this.#ae(t),e&&(t=this.#he(u).childNodes);for(let s,i=0,n=t.length;i<n;i++)s=t[i],this.#ee.test(s.nodeName)?d+=s.outerHTML:d+=this.#ce(s,e)}return d||=t,o&&(s&&(d=d.replace("string"==typeof s?Oe.createElementWhitelist(s):s,"")),i&&(d=d.replace("string"==typeof i?Oe.createElementBlacklist(i):i,""))),a&&(d=this.#de(d)),!n&&d.includes(Ae.zeroWidthSpace)&&(d=d.replace(Ds,((t,e,s)=>{const i=0===e||">"===s[e-1],n=e+t.length===s.length||"<"===s[e+t.length];return i&&n?t:""}))),d}insert(t,{selectInserted:e,skipCharCount:s,skipCleaning:i}={}){this.#X.get("wysiwyg").contains(this.#J.selection.get().focusNode)||this.#J.focusManager.focus(),this.remove(),this.#J.focusManager.focus();let n=null;if("string"==typeof t){i||(t=this.clean(t,{forceFormat:!1,whitelist:null,blacklist:null}));try{if(Re.check.isListCell(this.#J.format.getLine(this.#J.selection.getNode(),null))){const e=Ps.createRange().createContextualFragment(t).childNodes;this.#ae(e)&&(t=this.#ue(e))}const i=Ps.createRange().createContextualFragment(t).childNodes;if(!s){const t="byte-html"===this.#Q.get("charCounter_type")?"outerHTML":"textContent";let e="";for(let s=0,n=i.length;s<n;s++)e+=i[s][t];if(!this.#J.char.check(e))return}let o,r,l,a,h;for(;o=i[0];)3===a?.nodeType&&1===r?.nodeType&&Re.check.isBreak(o)?(a=o,Re.utils.removeItem(o)):(l=this.insertNode(o,{afterNode:r,skipCharCount:!0}),r=l.container||l,h||=l,a=o);3===a?.nodeType&&1===r?.nodeType&&(r=a);const c=3===r.nodeType?l.endOffset||r.textContent.length:r.childNodes.length;n=r,e?this.#J.selection.setRange(h.container||h,h.startOffset||0,r,c):this.#J.component.is(r)||this.#J.selection.setRange(r,c,r,c)}catch(t){if(this.#X.get("isReadOnly")||this.#X.get("isDisabled"))return;throw Error(`[SUNEDITOR.html.insert.error] ${t.message}`)}}else if(this.#J.component.is(t))this.#J.component.insert(t,{skipCharCount:s,insertBehavior:"none"});else{let e=null;(this.#J.format.isLine(t)||Re.check.isMedia(t))&&(e=this.#J.format.getLine(this.#J.selection.getNode(),null)),this.insertNode(t,{afterNode:e,skipCharCount:s})}if(this.#t.set("_lastSelectionNode",null),n){const t=Re.query.getListChildNodes(n,null,null);if(t.length>0){n=t.at(-1);const e=3===n?.nodeType?n.textContent.length:1;this.#J.selection.setRange(n,e,n,e)}else this.#J.focusManager.focus()}else this.#J.focusManager.focus();this.#J.history.push(!1)}insertNode(t,{afterNode:e,skipCharCount:s}={}){let i=null;if(this.#X.get("isReadOnly")||!s&&!this.#J.char.check(t))return i;let n=null,o=null;if(e){const t=this.#J.format.isLine(e)||this.#J.format.isBlock(e)||this.#J.component.is(e)?this.#J.format.addLine(e,null):e;o=this.#J.selection.setRange(t,1,t,1)}else o=this.#J.selection.getRange();let r,l,a,h=Re.check.isListCell(o.commonAncestorContainer)?o.commonAncestorContainer:this.#J.format.getLine(this.#J.selection.getNode(),null),c=Re.check.isListCell(h)&&(Re.check.isListCell(t)||Re.check.isList(t)),d=null;const u=this.#J.format.isBrLine(h),p=this.#J.format.isLine(t)||this.#J.format.isBlock(t)||this.#J.component.isBasic(t);if(c&&(a=e||Re.check.isList(t)?h.lastChild:h.nextElementSibling,d=Re.check.isList(t)?h:(a||h).parentNode),!e&&(p||this.#J.component.isBasic(t)||Re.check.isMedia(t))){const t=Re.check.isEdgePoint(o.endContainer,o.endOffset,"end"),s=this.remove(),i=s.container,n=i===s.prevContainer&&o.collapsed?null:s.prevContainer;if(c&&n)if(d=3===n.nodeType?n.parentNode:n,d.contains(i)){let t=!0;for(a=i;a.parentNode&&a.parentNode!==d;)a=a.parentNode,t=!1;t&&i===n&&(a=a.nextSibling)}else a=null;else if(c&&Re.check.isListCell(i)&&!h.parentElement)h=Re.utils.createElement("LI"),d.appendChild(h),i.appendChild(d),a=null;else if(3===i.nodeType||Re.check.isBreak(i)||c){const n=Re.query.getParentElement(i,(t=>this.#J.format.isBlock(t)||Re.check.isListCell(t)));if(e=this.#J.nodeTransform.split(i,s.offset,n?Re.query.getNodeDepth(n)+1:0))if(c){if(h.contains(i)){const s=Re.check.isList(h.lastElementChild);let i=null;t||(i=h.cloneNode(!1),i.appendChild(e.textContent.trim()?e:Re.utils.createTextNode(Ae.zeroWidthSpace))),s&&(i||(i=h.cloneNode(!1),i.appendChild(Re.utils.createTextNode(Ae.zeroWidthSpace))),i.appendChild(h.lastElementChild)),i&&(h.parentNode.insertBefore(i,h.nextElementSibling),a=e=i)}}else e=e.previousSibling;else Re.check.isListCell(h)||(a=e=h)}}o=e||p?this.#J.selection.getRange():this.#J.selection.getRangeAndAddLine(this.#J.selection.getRange(),null);const g=o.commonAncestorContainer,m=o.startOffset,f=o.endOffset,v=o.startContainer===g&&this.#J.format.isLine(g),b=v&&(g.childNodes[m]||g.childNodes[0])||o.startContainer,y=v&&(g.childNodes[f]||g.childNodes[g.childNodes.length-1])||o.endContainer;if(!c)if(e)r=e.parentNode,e=e.nextSibling,l=!0;else if(r=b,3===b.nodeType&&(r=b.parentNode),o.collapsed)if(3===g.nodeType)e=g.textContent.length>f?g.splitText(f):g.nextSibling;else if(Re.check.isBreak(r))e=r,r=r.parentNode;else{const s=r.childNodes[m],i=3===s?.nodeType&&Re.check.isZeroWidth(s)&&Re.check.isBreak(s.nextSibling)?s.nextSibling:s;i?!i.nextSibling&&Re.check.isBreak(i)?(r.removeChild(i),e=null):e=Re.check.isBreak(i)&&!Re.check.isBreak(t)?i:i.nextSibling:e=null}else{if(b===y){e=Re.check.isEdgePoint(y,f)?y.nextSibling:y.splitText(f);let t=b;Re.check.isEdgePoint(b,m)||(t=b.splitText(m)),r.removeChild(t),0===r.childNodes.length&&p&&(r.innerHTML="<br>")}else{const s=this.remove(),i=s.container,n=s.prevContainer;if(0===i?.childNodes.length&&p&&(this.#J.format.isLine(i)?i.innerHTML="<br>":this.#J.format.isBlock(i)&&(i.innerHTML="<"+this.#ot.get("defaultLine")+"><br></"+this.#ot.get("defaultLine")+">")),Re.check.isListCell(i)&&3===t.nodeType)r=i,e=null;else if(!p&&n)if(r=3===n.nodeType?n.parentNode:n,r.contains(i)){let t=!0;for(e=i;e.parentNode&&e.parentNode!==r;)e=e.parentNode,t=!1;t&&i===n&&(e=e.nextSibling)}else e=null;else Re.check.isWysiwygFrame(i)&&!this.#J.format.isLine(t)?(r=i.appendChild(Re.utils.createElement(this.#ot.get("defaultLine"))),e=null):r=(e=p?y:i===n?i.nextSibling:i)&&e.parentNode?e.parentNode:g;for(;e&&!this.#J.format.isLine(e)&&e.parentNode!==g;)e=e.parentNode}}try{const s=this.#X.get("wysiwyg");if(!c){if((Re.check.isWysiwygFrame(e)||r===s.parentNode)&&(r=s,e=null),this.#J.format.isLine(t)||this.#J.format.isBlock(t)||!Re.check.isListCell(r)&&this.#J.component.isBasic(t)){const t=r;if(Re.check.isListCell(e))r=e.previousElementSibling||e;else if(!l&&!e){const t=this.remove(),s=3===t.container.nodeType?Re.check.isListCell(this.#J.format.getLine(t.container,null))?t.container:this.#J.format.getLine(t.container,null)||t.container.parentNode:t.container,i=Re.check.isWysiwygFrame(s)||this.#J.format.isBlock(s);r=i?s:s.parentNode,e=i?null:s.nextSibling}0===t.childNodes.length&&r!==t&&Re.utils.removeItem(t)}if(!p||u||this.#J.format.isBlock(r)||Re.check.isListCell(r)||Re.check.isWysiwygFrame(r)||(e=r.nextElementSibling,r=r.parentNode),Re.check.isWysiwygFrame(r)&&(3===t.nodeType||Re.check.isBreak(t))){const e=Re.utils.createElement(this.#ot.get("defaultLine"),null,t);n=t,t=e}}if(c?d.parentNode?(r=d,e=a):(r=s,e=null):e=r===e?r.lastChild:e,Re.check.isListCell(t)&&!Re.check.isList(r)){if(Re.check.isListCell(r))e=r.nextElementSibling,r=r.parentNode;else{const t=Re.utils.createElement("ol");r.insertBefore(t,e),r=t,e=null}c=!0}if(this.#pe(t,r),r.insertBefore(t,e),c)if(Re.check.isZeroWidth(h.textContent.trim()))Re.utils.removeItem(h),t=t.lastChild;else{const e=Re.utils.arrayFind(h.children,Re.check.isList);e&&(t!==e?(t.appendChild(e),t=e.previousSibling):(r.appendChild(t),t=r),Re.check.isZeroWidth(h.textContent.trim())&&Re.utils.removeItem(h))}}catch(e){r.appendChild(t),console.warn("[SUNEDITOR.html.insertNode.warn]",e)}finally{n&&(t=n);const e=r.querySelectorAll("[data-duple]");if(e.length>0)for(let s,i,n,o,r=0,l=e.length;r<l;r++){for(s=e[r],n=s.childNodes,o=s.parentNode;n[0];)i=n[0],o.insertBefore(i,s);s===t&&(t=i),Re.utils.removeItem(s)}if((this.#J.format.isLine(t)||this.#J.component.isBasic(t))&&b===y){const t=this.#J.format.getLine(g,null);1===t?.nodeType&&Re.check.isEmptyLine(t)&&Re.utils.removeItem(t)}if(u&&!Re.check.isList(t)&&(this.#J.format.isLine(t)||this.#J.format.isBlock(t))&&(t=this.#ge(t)),!this.#J.component.isBasic(t)){let e=1;if(3===t.nodeType)e=t.textContent.length,this.#J.selection.setRange(t,e,t,e);else if(!Re.check.isBreak(t)&&!Re.check.isListCell(t)&&this.#J.format.isLine(r)){let s=null;t.previousSibling&&!Re.check.isBreak(t.previousSibling)||(s=Re.utils.createTextNode(Ae.zeroWidthSpace),t.parentNode.insertBefore(s,t)),t.nextSibling&&!Re.check.isBreak(t.nextSibling)||(s=Re.utils.createTextNode(Ae.zeroWidthSpace),t.parentNode.insertBefore(s,t.nextSibling)),this.#J.inline._isIgnoreNodeChange(t)&&(t=t.nextSibling,e=0),this.#J.selection.setRange(t,e,t,e)}}i=t}return i}remove(){this.#J.selection.resetRangeToTextNode();const t=this.#J.selection.getRange(),e=0===t.startOffset,s=Re.check.isEdgePoint(t.endContainer,t.endOffset,"end");let i=null,n=null,o=null;e&&(n=this.#J.format.getLine(t.startContainer),i=n?n.previousElementSibling:null,n=n?i:n),s&&(o=this.#J.format.getLine(t.endContainer),o=o?o.nextElementSibling:o);let r,l=0,a=t.startContainer,h=t.endContainer,c=t.startOffset,d=t.endOffset;const u=3===t.commonAncestorContainer.nodeType&&t.commonAncestorContainer.parentNode===a.parentNode?a.parentNode:t.commonAncestorContainer;if(Re.check.isWysiwygFrame(a)&&Re.check.isWysiwygFrame(h)){this.set("");return{container:this.#J.selection.getNode(),offset:0,commonCon:u}}if(u===a&&u===h){if(this.#J.component.isBasic(u)){const t=this.#J.component.get(u).container,e=t.parentElement,s=t.nextSibling||t.previousSibling,i=s===t.previousSibling?s?.textContent?.length||1:0,n=e.nextElementSibling||e.previousElementSibling,o=n===e.previousElementSibling?n?.textContent?.length||1:0;return Re.utils.removeItem(t),this.#J.format.isLine(e)?0===e.childNodes.length?(Re.utils.removeItem(e),{container:n,offset:o,commonCon:u}):{container:s,offset:i,commonCon:u}:{container:n,offset:o,commonCon:u}}if(1===u.nodeType&&0===c&&1===d||3===u.nodeType&&0===c&&d===u.textContent.length){const t=Re.query.getNextDeepestNode(u,this.#X.get("wysiwyg")),e=Re.query.getPreviousDeepestNode(u,this.#X.get("wysiwyg")),s=this.#J.format.getLine(u);Re.utils.removeItem(u);let i=t||e,n=t?0:3===i?.nodeType?i.textContent.length:1;const o=this.#J.format.getLine(i)||this.#J.component.get(i);return s!==o&&(i=o,n=0===n?0:1),Re.check.isZeroWidth(s)&&!s.contains(i)&&Re.utils.removeItem(s),{container:i,offset:n,commonCon:u}}a=u.children[c],h=u.children[d],c=d=0}if(!a||!h)return{container:u,offset:0,commonCon:u};if(a===h&&t.collapsed&&Re.check.isZeroWidth(a.textContent?.substring(c)))return{container:a,offset:c,prevContainer:a&&a.parentNode?a:null,commonCon:u};let p=null,g=null;const m=Re.query.getListChildNodes(u,null,null);let f=Re.utils.getArrayIndex(m,a),v=Re.utils.getArrayIndex(m,h);if(m.length>0&&f>-1&&v>-1){for(let t=f+1,e=a;t>=0;t--)m[t]===e.parentNode&&m[t].firstChild===e&&0===c&&(f=t,e=e.parentNode);for(let t=v-1,e=h;t>f;t--)m[t]===e.parentNode&&1===m[t].nodeType&&(m.splice(t,1),e=e.parentNode,--v)}else{if(0===m.length){if(this.#J.format.isLine(u)||this.#J.format.isBlock(u)||Re.check.isWysiwygFrame(u)||Re.check.isBreak(u)||Re.check.isMedia(u))return{container:u,offset:0,commonCon:u};if(Re.check.isText(u))return{container:u,offset:d,commonCon:u};m.push(u),a=h=u}else if(a=h=m[0],Re.check.isBreak(a)||Re.check.isZeroWidth(a))return{container:Re.check.isMedia(u)?u:a,offset:0,commonCon:u};f=v=0}const b=Re.check.isText,y=Re.check.isElement,w=f===v;let C=null;for(let t=f;t<=v;t++){const e=m[t];if(!b(e)||void 0!==e.data&&0!==e.length)if(e!==a)if(e!==h)C=this.#me(e,w);else{if(b(h))g=Re.utils.createTextNode(h.substringData(d,h.length-d));else{if(this.#J.component.is(h))continue;g=Re.utils.createTextNode(h.textContent)}g.length>0?h.data=g.data:C=this.#me(h,w)}else{if(y(a)){if(this.#J.component.is(a))continue;p=Re.utils.createTextNode(a.textContent)}else{const t=a,s=h;e===h?(p=Re.utils.createTextNode(t.substringData(0,c)+s.substringData(d,s.length-d)),l=c):p=Re.utils.createTextNode(t.substringData(0,c))}if(p.length>0?a.data=p.data:C=this.#me(a,w),e===h)break}else C=this.#me(e,w)}const _=Re.query.getParentElement(h,"ul"),k=Re.query.getParentElement(a,"li");if(_&&k&&k.contains(_)?(r=_.previousSibling,l=r.textContent.length):(r=h&&h.parentNode?h:a&&a.parentNode?a:t.endContainer||t.startContainer,(e||s)&&(s?1===r.nodeType&&0===r.childNodes.length?(r.appendChild(Re.utils.createElement("BR")),l=1):l=r.textContent.length:l=0)),this.#J.format.getLine(r)||a&&a.parentNode||(o?(r=o,l=0):n&&(r=n,l=1)),!Re.check.isWysiwygFrame(r)&&0===r.childNodes.length){const t=this.#J.nodeTransform.removeAllParents(r,null,null);t&&(r=t.sc||t.ec||this.#X.get("wysiwyg"))}return r&&(1!==r.nodeType||this.#J.format.isLine(r)||Re.check.isBreak(r))||(r=C?.sc||C?.ec,l=3===r?.nodeType?r.textContent.length:1),this.#J.selection.setRange(r,l,r,l),{container:r,offset:l,prevContainer:i,commonCon:u?.parentElement?u:null}}get({withFrame:t,includeFullPage:e,rootKey:s}={}){s?Array.isArray(s)||(s=[s]):s=[this.#t.get("rootKey")];const i=this.#t.get("rootKey"),n={};for(let i,o=0,r=s.length;o<r;o++){this.#J.facade.changeFrameContext(s[o]);const r=Re.utils.createElement("DIV",null,this._convertToCode(this.#X.get("wysiwyg"),!0)),l=r.querySelectorAll(".se-placeholder-line");for(let t=0,e=l.length;t<e;t++)l[t].classList.remove("se-placeholder-line"),l[t].removeAttribute("data-se-placeholder-line"),l[t].getAttribute("class")||l[t].removeAttribute("class");const a=Re.check.isTableCell,h=Re.check.isEmptyLine,c=[],d=[];Re.query.getListChildren(r,(t=>{t.hasAttribute("contenteditable")&&c.push(t);const e=t.parentElement;return a(e)&&e.children.length<=1&&h(t)&&d.push(e),!1}),null);for(let t=0,e=c.length;t<e;t++)c[t].removeAttribute("contenteditable");for(let t=0,e=d.length;t<e;t++)d[t].innerHTML="<br>";this.#fe(r);const u=r.innerHTML;if(this.#Q.get("iframe_fullPage"))if(e){const t=Re.utils.getAttributesToString(this.#X.get("_wd").body,["contenteditable"]);i=`<!DOCTYPE html><html>${this.#X.get("_wd").head.outerHTML}<body ${t}>${u}</body></html>`}else i=u;else i=t?`<div class="${this.#ot.get("_editableClass")+""+(this.#ot.get("_rtl")?" se-rtl":"")}">${u}</div>`:r.innerHTML;n[s[o]]=i}return this.#J.facade.changeFrameContext(i),s.length>1?n:n[s[0]]}set(t,{rootKey:e}={}){this.#J.ui.offCurrentController(),this.#J.selection.removeRange();const s=null==t?"":this.clean(t,{forceFormat:!0,whitelist:null,blacklist:null});e?Array.isArray(e)||(e=[e]):e=[this.#t.get("rootKey")];for(let t=0;t<e.length;t++)if(this.#J.facade.changeFrameContext(e[t]),this.#X.get("isMarkdownView")){const t=Oe.htmlToJson(s);this.#X.get("markdown").value=Fe.jsonToMarkdown(t)}else if(this.#X.get("isCodeView")){const t=this._convertToCode(s,!1);this.#J.viewer._setCodeView(t)}else this.#X.get("wysiwyg").innerHTML=s,this.#J.pluginManager.resetFileInfo(),this.#J.history.push(!1,e[t])}add(t,{rootKey:e}={}){this.#J.ui.offCurrentController(),e?Array.isArray(e)||(e=[e]):e=[this.#t.get("rootKey")];for(let s=0;s<e.length;s++){this.#J.facade.changeFrameContext(e[s]);const i=this.clean(t,{forceFormat:!0,whitelist:null,blacklist:null});if(this.#X.get("isMarkdownView")){const t=Oe.htmlToJson(i);this.#X.get("markdown").value+="\n"+Fe.jsonToMarkdown(t)}else if(this.#X.get("isCodeView"))this.#J.viewer._setCodeView(this.#J.viewer._getCodeView()+"\n"+this._convertToCode(i,!1));else{const t=Re.utils.createElement("DIV",null,i),n=Array.from(t.children);for(let t=0,e=n.length;t<e;t++)this.#X.get("wysiwyg").appendChild(n[t]);this.#J.history.push(!1,e[s]),this.#J.selection.scrollTo(n.at(-1))}}}getJson({withFrame:t,rootKey:e}={}){return Oe.htmlToJson(this.get({withFrame:t,rootKey:e}))}setJson(t,{rootKey:e}={}){this.set(Oe.jsonToHtml(t),{rootKey:e})}async copy(t){try{return!("string"!=typeof t&&!Re.check.isElement(t)&&!Re.check.isText(t))&&(!1===await De.write(t)?(this.#J.ui.showToast(this.#J.lang.message_copy_fail,this.#ot.get("toastMessageTime").copy,"error"),!1):(this.#J.ui.showToast(this.#J.lang.message_copy_success,this.#ot.get("toastMessageTime").copy),!0))}catch(t){return console.error("[SUNEDITOR.html.copy.fail] :",t),this.#J.ui.showToast(this.#J.lang.message_copy_fail,this.#ot.get("toastMessageTime").copy,"error"),!1}}setFullPage(t,{rootKey:e}={}){if(!this.#Q.get("iframe"))return!1;e?Array.isArray(e)||(e=[e]):e=[this.#t.get("rootKey")];for(let s=0;s<e.length;s++)this.#J.facade.changeFrameContext(e[s]),t.head&&(this.#X.get("_wd").head.innerHTML=t.head.replace(this.#Qt,"")),t.body&&(this.#X.get("_wd").body.innerHTML=this.clean(t.body,{forceFormat:!0,whitelist:null,blacklist:null})),this.#J.pluginManager.resetFileInfo()}compress(t){return t.replace(/>\s+</g,"> <").replace(/\n/g,"").trim()}_convertToCode(t,e){let s="";const i=RegExp,n=new i("^(BLOCKQUOTE|PRE|TABLE|THEAD|TBODY|TR|TH|TD|OL|UL|IMG|IFRAME|VIDEO|AUDIO|FIGURE|FIGCAPTION|HR|BR|CANVAS|SELECT)$","i"),o="string"==typeof t?Ps.createRange().createContextualFragment(t):t,r=t=>this.#J.format.isLine(t)||this.#J.component.is(t),l=e?"":"\n",a=e?0:1*this.#t.get("codeIndentSize"),h=a>0?new Array(a+1).join(" "):"";return function t(e,o){const a=e?.childNodes;if(!a)return;const c=n.test(e.nodeName),d=c?o:"";for(let u,p,g,m,f,v,b=0,y=a.length;b<y;b++)u=a[b],m=n.test(u.nodeName),p=m?l:"",g=!r(u)||c||/^(TH|TD)$/i.test(e.nodeName)?"":l,8!==u.nodeType?3!==u.nodeType?0!==u.childNodes.length?u.outerHTML?(f=u.nodeName.toLowerCase(),v=d||m?o:"",s+=(g||(c?"":p))+v+u.outerHTML.match(i("<"+f+"[^>]*>","i"))[0]+p,t(u,o+h+""),s+=(/\n$/.test(s)?v:"")+"</"+f+">"+(g||p||c||/^(TH|TD)$/i.test(u.nodeName)?l:"")):s+=(new XMLSerializer).serializeToString(u):s+=(/^HR$/i.test(u.nodeName)?l:"")+(/^PRE$/i.test(u.parentElement.nodeName)&&/^BR$/i.test(u.nodeName)?"":d)+u.outerHTML+p:Re.check.isList(u.parentElement)||(s+=Oe.htmlToEntity(/^\n+$/.test(u.data)?"":u.data)):s+="\n\x3c!-- "+u.textContent.trim()+" --\x3e"+p}(o,""),s.trim()+l}#me(t,e){const s=this.#J.format.getLine(t,null);if(Re.utils.removeItem(t),!Re.check.isListCell(s)||e)return;const i=this.#J.nodeTransform.removeAllParents(s,null,null);return Re.check.isList(s?.firstChild)&&s.insertBefore(Re.utils.createTextNode(Ae.zeroWidthSpace),s.firstChild),i?{sc:i.sc,ec:i.ec}:null}#ge(t){const e=t.parentNode;let s,i;for(;this.#J.format.isLine(t)||this.#J.format.isBlock(t);){for(s=t.childNodes,i=null;s[0];)if(i=s[0],this.#J.format.isLine(i)||this.#J.format.isBlock(i)){if(this.#ge(i),!t.parentNode)break;s=t.childNodes}else e.insertBefore(i,t);0===t.childNodes.length&&Re.utils.removeItem(t),t=Re.utils.createElement("BR"),e.insertBefore(t,i.nextSibling)}return t}#ce(t,e){const s=this.#ot.get("defaultLine");if(1===t.nodeType){if(this.#te.test(t.nodeName))return"";if(Re.check.isExcludeFormat(t))return t.outerHTML;const i=Re.query.getListChildNodes(t,(t=>Re.check.isSpanWithoutAttr(t)&&!Re.query.getParentElement(t,Re.check.isExcludeFormat)),null)||[];for(let t,e=i.length-1;e>=0;e--)t=i[e],t.outerHTML=t.innerHTML;if(!e||this.#J.format.isLine(t)||this.#J.format.isBlock(t)||this.#J.component.is(t)||Re.check.isMedia(t)||Re.check.isFigure(t)||Re.check.isAnchor(t)&&Re.check.isMedia(t.firstElementChild)){const e=t;return Re.check.isSpanWithoutAttr(t)?e.innerHTML:e.outerHTML}{const e=t;return"<"+s+">"+(Re.check.isSpanWithoutAttr(t)?e.innerHTML:e.outerHTML)+"</"+s+">"}}if(3===t.nodeType){if(!e)return Oe.htmlToEntity(t.textContent);const i=t.textContent.split(/\n/g);let n="";for(let t,e=0,o=i.length;e<o;e++)t=i[e].trim(),t.length>0&&(n+="<"+s+">"+Oe.htmlToEntity(t)+"</"+s+">");return n}return 8===t.nodeType&&this.#qt?"\x3c!--"+t.textContent.trim()+"--\x3e":""}#ve(t){return!t||11===t.nodeType||Re.check.isWysiwygFrame(t)||Re.check.isList(t)||Re.check.isTableElements(t)||this.#J.format.isBlock(t)}#le(t,e,s,i,n,o,r){const l=[],a=[],h=[],c=[],d=Re.query.getListChildNodes(t,(d=>{if(1!==d.nodeType)return n&&Re.check.isList(d.parentElement)&&l.push(d),3===d.nodeType&&(!d.textContent||Ks.test(d.textContent)&&(this.#ve(d.parentNode)||!d.previousSibling!=!d.nextSibling))&&l.push(d),!1;if(i&&(s.test(d.nodeName)||!e.test(d.nodeName)&&0===d.childNodes.length&&Re.check.isExcludeFormat(d)))return l.push(d),!1;"PRE"===d.nodeName&&this.#be(d);const u=!Re.query.getParentElement(d,Re.check.isExcludeFormat);if(n){if(!Re.check.isTableElements(d)&&!Re.check.isListCell(d)&&!Re.check.isAnchor(d)&&(this.#J.format.isLine(d)||this.#J.format.isBlock(d)||this.#J.format.isTextStyleNode(d))&&0===d.childNodes.length&&u)return a.push(d),!1;if(Re.check.isList(d.parentNode)&&!Re.check.isList(d)&&!Re.check.isListCell(d))return h.push(d),!1;if(Re.check.isTableCell(d)){const t=d.firstElementChild;if(!this.#J.format.isLine(t)&&!this.#J.format.isBlock(t)&&!this.#J.component.is(t))return c.push(d),!1}}if(o&&u&&d.className){const t=Array.from(d.classList).map(this.#Ht).join(" ").trim();t?d.className=t:d.removeAttribute("class")}if(!n)return!1;return!r&&d.parentNode!==t&&u&&(Re.check.isListCell(d)&&!Re.check.isList(d.parentNode)||(this.#J.format.isLine(d)||this.#J.component.is(d))&&!this.#J.format.isBlock(d.parentNode)&&!Re.query.getParentElement(d,this.#J.component.is.bind(this.#J.component)))}),null);for(let t=0,e=l.length;t<e;t++)Re.utils.removeItem(l[t]);const u=[];for(let t,e,s=0,i=d.length;s<i;s++)if(t=d[s],e=t.parentNode,e&&e.parentNode)if(Re.query.getParentElement(t,Re.check.isListCell)){const s=t.childNodes;for(let i=s.length-1;i>=0;i--)e.insertBefore(s[i],t);u.push(t)}else e.parentNode.insertBefore(t,e),u.push(e);for(let t,e=0,s=u.length;e<s;e++)t=u[e],Re.check.isZeroWidth(t.textContent.trim())&&Re.utils.removeItem(t);for(let t=0,e=a.length;t<e;t++)Re.utils.removeItem(a[t]);for(let t,e,s,i,n=0,o=h.length;n<o;n++)if(t=h[n],i=t.parentNode,i)if(e=Re.utils.createElement("LI"),this.#J.format.isLine(t)){for(s=t.childNodes;s[0];)e.appendChild(s[0]);i.insertBefore(e,t),Re.utils.removeItem(t)}else t=t.nextSibling,e.appendChild(h[n]),i.insertBefore(e,t);for(let t,e,s=0,i=c.length;s<i;s++){if(t=c[s],e=Re.utils.createElement("DIV"),e.innerHTML=t.innerHTML,0===t.textContent.trim().length&&this.#ye(t)){let t=e;for(;t.firstElementChild;)t=t.firstElementChild;t.innerHTML="<br>"}t.innerHTML=e.outerHTML}}#ye(t){const e=t.querySelectorAll("*"),s=this.#J.format;for(let t=0;t<e.length;t++)if(!s.isTextStyleNode(e[t]))return!1;return!0}#de(t){if(!this.#Wt)return t;const e=this.#ot.get("_defaultStyleTagMap");return t.replace(this.#Wt,((t,s,i,n)=>s+("string"==typeof e[i]?e[i]:i)+(n?" "+n:"")))}#he(t){let e,s="";const i=t.childNodes;for(let t,n=0,o=i.length;n<o;n++)t=i[n],this.#ee.test(t.nodeName)?s+=t.outerHTML:8===t.nodeType?s+="\x3c!-- "+t.textContent+" --\x3e":/meta/i.test(t.nodeName)||this.#J.format.isLine(t)||this.#J.format.isBlock(t)||this.#J.component.is(t)||Re.check.isExcludeFormat(t)?(e&&(s+=e.outerHTML,e=null),s+=t.outerHTML):(e||=Re.utils.createElement(this.#ot.get("defaultLine")),this.#J.format.isTextStyleNode(t)&&t.removeAttribute("style"),e.appendChild(t),n--,o--);return e&&(s+=e.outerHTML),Ps.createRange().createContextualFragment(s)}#ue(t){let e="";for(let s,i=0,n=t.length;i<n;i++)s=t[i],1===s.nodeType?Re.check.isList(s)?e+=s.innerHTML:Re.check.isListCell(s)?e+=s.outerHTML:this.#J.format.isLine(s)?e+="<li>"+(s.innerHTML.trim()||"<br>")+"</li>":this.#J.format.isBlock(s)&&!Re.check.isTableElements(s)?e+=this.#ue(s.children):e+="<li>"+s.outerHTML+"</li>":e+="<li>"+(s.textContent||"<br>")+"</li>";return e}#ae(t){let e=!1;for(let s,i=0,n=t.length;i<n;i++)if(s=t[i],1===s.nodeType&&!this.#J.format.isTextStyleNode(s)&&!Re.check.isBreak(s)&&!this.#te.test(s.nodeName)){e=!0;break}return e}#we(t,e,s){let i=(t.match(Us)||[])[0];if(this.#Jt.includes(s)&&!i&&(t.match(Gs)||[])[1]){const e=(t.match(Ys)||[])[1],s=(t.match(Xs)||[])[1],n=(t.match(Zs)||[])[1];(e||s||n)&&(i='style="'+(e?"font-size:"+ze.get(Number(e)/3.333,1)+"rem;":"")+(s?"font-family:"+s+";":"")+(n?"color:"+n+";":"")+'"')}if(i){let t;e||=[];for(const[e,i]of this.#Zt)if(e.test(s)){t=i;break}if(!t)return e;const n=i.replace(Js,"").match(t);if(!n)return e;const o=[];for(let t,e=0,s=n.length;e<s;e++)if(t=n[e].match(Qs),t&&!ti.test(t[3])){const e=Oe.kebabToCamelCase(t[1].trim()),s=this.#X.get("wwComputedStyle")[e]?.replace(ei,""),i=t[3].trim();switch(e){case"fontFamily":if(!this.#J.plugins.font||!this.#J.plugins.font.fontArray.includes(i))continue;break;case"fontSize":if(!this.#J.plugins.fontSize)continue;this.#Ft.test(t[0])||(t[0]=t[0].replace((t[0].match(si)||[])[1],Oe.toFontUnit.bind(null,this.#ot.get("fontSizeUnits")[0])));break;case"color":if(!this.#J.plugins.fontColor||ii.test(i))continue;break;case"backgroundColor":if(!this.#J.plugins.backgroundColor||ii.test(i))continue}s!==i&&o.push(t[0])}o.length>0&&e.push('style="'+o.join(";")+'"')}return e}#oe(t,e,s){return e.test("<font>")&&(t=t.replace(/(<\/?)font(\s?)/gi,"$1span$2")),t.replace(e,"").replace(s,"")}#pe(t,e){const s=t=>{this.#Ce(t,e);const i=t.childNodes;for(let t=0,e=i.length;t<e;t++)s(i[t])};s(t)}#Ce(t,e){if(!this.#J.format.isTextStyleNode(t))return;const s=(t.style.cssText.match(ni)||[]).map((function(t){return t.trim()})),i=t.nodeName;if(oi.test(i)&&0===s.length)return t;const n=this.#J.format;let o=!1;return function e(r){if(!Re.check.isWysiwygFrame(r)&&n.isTextStyleNode(r)){if(r.nodeName===i){o=!0;const e=r.style.cssText.match(ni)||[];for(let t,i=0,n=e.length;i<n;i++)(t=s.indexOf(e[i].trim()))>-1&&s.splice(t,1);for(let e=0,s=r.classList.length;e<s;e++)t.classList.remove(r.classList[e])}e(r.parentElement)}}(e),o&&((t.style.cssText=s.join(" "))||(t.setAttribute("style",""),t.removeAttribute("style")),0===t.attributes.length&&t.setAttribute("data-duple","true")),t}#re(t,e,s,i){if(Fs.test(s))return s;let n=null;const o=i.match(Hs)[0].toLowerCase();if(t){const t=this.#ie[o];s=s.replace(qs,""),s=t?s.replace(t,""):s.replace(this.#Yt,"");const e=this.#se[o];n=e?s.match(e):s.match(this.#Kt)}if(!e)return s;if("a"===o){const t=s.match(/(?:(?:id|name)\s*=\s*(?:"|')[^"']*(?:"|'))/g);t&&(n||=[],n.push(t[0]))}else n&&Ws.test(n.toString())||(Vs.test(s)?n=this.#we(s,n,"@component"):this.#Xt.test(o)?n=this.#we(s,n,o):this.#J.format.isLine(o)?n=this.#we(s,n,"@line"):this.#Jt.includes(o)&&(n=this.#we(s,n,"@text")));if(Re.check.isMedia(o)||Re.check.isFigure(o)){const t=s.match(Us);n||=[],t&&n.push(t[0])}if(n)for(let t,e=0,s=n.length;e<s;e++)t=di(n[e].trim())?n[e]:"",i+=(js.test(t)?"":" ")+t;return i}__resetAutoStyleify(t){if(t.length>0){const e=this.#ot.get("convertTextTags"),s={};t.forEach((t=>{switch(t){case"bold":s.bold={regex:/font-weight\s*:\s*bold/i,tag:e.bold};break;case"italic":s.italic={regex:/font-style\s*:\s*italic/i,tag:e.italic};break;case"underline":s.underline={regex:/text-decoration\s*:\s*underline/i,tag:e.underline};break;case"strike":s.strike={regex:/text-decoration\s*:\s*line-through/i,tag:e.strike}}})),this.#ne=s}else this.#ne=null}_destroy(){this.#Zt&&this.#Zt.clear()}#be(t){if(1!==t.children.length||"CODE"!==t.firstElementChild?.nodeName)return;const e=t.firstElementChild,s=(e.className||"").match(/language-(\S+)/);for(s&&(Re.utils.addClass(t,"language-"+s[1]),t.setAttribute("data-se-lang",s[1]));e.firstChild;)t.insertBefore(e.firstChild,e);t.removeChild(e)}#fe(t){const e=t.querySelectorAll('pre[class*="language-"]');for(let t,s,i,n=0,o=e.length;n<o;n++)if(t=e[n],s=(t.className.match(/language-(\S+)/)||[])[1],s){for(i=Re.utils.createElement("CODE",{class:"language-"+s});t.firstChild;)i.appendChild(t.firstChild);t.appendChild(i),t.className=t.className.replace(/\s*language-\S+/g,"").trim(),t.removeAttribute("data-se-lang")}}};const gi=class{#J;#ot;constructor(t){this.#J=t.$,this.#ot=this.#J.options}split(t,e,s){if(Re.check.isWysiwygFrame(t)||this.#J.component.is(t)||!t)return t;if(e&&!ze.is(e)){const s=t.childNodes;let i=Re.query.getPositionIndex(e);const n=t.cloneNode(!1),o=t.cloneNode(!1);for(let t=0,e=s.length;t<e;t++){if(t<i)n.appendChild(s[t]);else{if(!(t>i))continue;o.appendChild(s[t])}t--,e--,i--}return n.childNodes.length>0&&t.parentNode.insertBefore(n,t),o.childNodes.length>0&&t.parentNode.insertBefore(o,t.nextElementSibling),t}const i=t.parentNode;let n,o,r,l=0,a=1,h=!0;if((!s||s<0)&&(s=0),Re.check.isText(t)){if(l=Re.query.getPositionIndex(t),(e=Number(e))>=0&&t.length!==e){t.splitText(e);const s=Re.query.getNodeFromPath([l+1],i);Re.check.isZeroWidth(s)&&(s.data=Ae.zeroWidthSpace)}}else if(1===t.nodeType){if(0===e){for(;t.firstChild;)t=t.firstChild;if(3===t.nodeType){const e=Re.utils.createTextNode(Ae.zeroWidthSpace);t.parentNode.insertBefore(e,t),t=e}}t.previousSibling?t=t.previousSibling:Re.query.getNodeDepth(t)===s&&(h=!1)}1===t.nodeType&&(a=0);let c=t;for(;Re.query.getNodeDepth(c)>s;)for(l=Re.query.getPositionIndex(c)+a,c=c.parentNode,r=n,n=c.cloneNode(!1),o=c.childNodes,r&&(Re.check.isListCell(n)&&Re.check.isList(r)&&r.firstElementChild?(n.innerHTML=r.firstElementChild.innerHTML,Re.utils.removeItem(r.firstElementChild),r.children.length>0&&n.appendChild(r)):n.appendChild(r));o[l];)n.appendChild(o[l]);1===c.nodeType&&c.childNodes.length<=1&&!c.firstChild?.textContent?.length&&(c.innerHTML="<br>");const d=c.parentNode;return h&&(c=c.nextSibling),n?(this.mergeSameTags(n,null,!1),this.mergeNestedTags(n,Re.check.isList),n.childNodes.length>0?d.insertBefore(n,c):n=c,Re.check.isListCell(n)&&n.children&&Re.check.isList(n.children[0])&&n.insertBefore(Re.utils.createElement("BR"),n.children[0]),0===i.childNodes.length&&Re.utils.removeItem(i),n):c}mergeSameTags(t,e,s){const i=e?e.length:0;let n=null;i&&(n=Array.apply(null,new Array(i)).map(Number.prototype.valueOf,0));const o=(t,r,l)=>{const a=t.childNodes;for(let h,c,d=0,u=a.length;d<u&&(h=a[d],c=a[d+1],h);d++)if(!(Re.check.isBreak(h)||Re.check.isMedia(h)||Re.check.isInputElement(h)))if(s&&this.#J.inline._isIgnoreNodeChange(h)||!s&&(Re.check.isTableElements(h)||Re.check.isListCell(h)||this.#J.format.isLine(h)&&!this.#J.format.isBrLine(h)))(Re.check.isTableElements(h)||Re.check.isListCell(h))&&o(h,r+1,d);else{if(1===u&&t.nodeName===h.nodeName&&t.parentNode){if(i){let s,n,o,l,a;for(let c=0;c<i;c++)if(s=e[c],s&&s[r]===d){for(n=h,o=t,l=r,a=!0;l>=0;){if(Re.utils.getArrayIndex(o.childNodes,n)!==s[l]){a=!1;break}n=h.parentNode,o=n.parentNode,l--}a&&(s.splice(r,1),s[r]=d)}}Re.utils.copyTagAttributes(h,t),t.parentNode.insertBefore(h,t),Re.utils.removeItem(t)}if(!c){1===h.nodeType&&o(h,r+1,d);break}if(h.nodeName===c.nodeName&&Re.check.isSameAttributes(h,c)&&h.getAttribute?.("href")===c.getAttribute?.("href")){const t=h.childNodes;let s=0;for(let e=0,i=t.length;e<i;e++)t[e].textContent.length>0&&s++;const o=h.lastChild,a=c.firstChild;let u=0;if(o&&a){const t=3===o.nodeType&&3===a.nodeType;u=o.textContent.length;let h=o.previousSibling;for(;h&&3===h.nodeType;)u+=h.textContent.length,h=h.previousSibling;if(s>0&&3===o.nodeType&&3===a.nodeType&&(o.textContent.length>0||a.textContent.length>0)&&s--,i){let h=null;for(let c=0;c<i;c++)if(h=e[c],h&&h[r]>d){if(r>0&&h[r-1]!==l)continue;h[r]-=1,h[r+1]>=0&&h[r]===d&&(h[r+1]+=s,t&&o&&3===o.nodeType&&a&&3===a.nodeType&&(n[c]+=u))}}}if(3===h.nodeType){if(u=h.textContent.length,h.textContent+=c.textContent,i){let t=null;for(let o=0;o<i;o++)if(t=e[o],t&&t[r]>d){if(r>0&&t[r-1]!==l)continue;t[r]-=1,t[r+1]>=0&&t[r]===d&&(t[r+1]+=s,n[o]+=u)}}}else h.innerHTML+=c.innerHTML;Re.utils.removeItem(c),d--}else 1===h.nodeType&&o(h,r+1,d)}};return o(t,0,0),n}mergeNestedTags(t,e){if("string"==typeof e){const t=new RegExp(`^(${e||".+"})$`,"i");e=e=>t.test(e.nodeName)}else"function"!=typeof e&&(e=()=>!0);!function t(s){let i=s.children;if(1===i.length&&i[0].nodeName===s.nodeName&&e(s)){const t=i[0];for(i=t.children;i[0];)s.appendChild(i[0]);s.removeChild(t)}for(let e=0,i=s.children.length;e<i;e++)t(s.children[e])}(t)}removeAllParents(t,e,s){if(!t)return null;let i=null;return e||=t=>{if(t===s||this.#J.component.is(t))return!1;const e=t.textContent.trim();return 0===e.length||/^(\n|\u200B)+$/.test(e)},function t(s){if(!Re.check.isWysiwygFrame(s)){const n=s.parentNode;n&&e(s)&&(i={sc:s.previousElementSibling,ec:s.nextElementSibling},Re.utils.removeItem(s),t(n))}}(t),i}removeEmptyNode(t,e,s){const i=this.#ot.get("allowedEmptyTags");e&&=Re.query.getParentElement(e,(e=>t===e.parentElement));const n=s=>{if(this.#J.format._isNotTextNode(s)||s===e||Re.check.isNonEditable(s))return 0;if(s===t||!Re.check.isZeroWidth(s.textContent)||s.firstChild&&Re.check.isBreak(s.firstChild)||s.querySelector(i)){const t=s.children;for(let e=0,s=t.length,i=0;e<s;e++)t[e+i]&&!this.#J.component.is(t[e+i])&&(i+=n(t[e+i]))}else if(s.parentNode)return s.parentNode.removeChild(s),-1;return 0};n(t),0===t.childNodes.length&&(s?Re.utils.removeItem(t):t.innerHTML="<br>")}createNestedNode(t,e){"function"!=typeof e&&(e=()=>!0);const s=t[0].cloneNode(!1);let i=s;for(let s,n=1,o=t.length;n<o;n++)e(t[n])&&(s=t[n].cloneNode(!1),i.appendChild(s),i=s);return i.innerHTML="",{parent:s,inner:i}}};function mi(t){t&&!ct(t,"se-blink")&&(dt(t,"se-blink"),o.setTimeout((()=>{ut(t,"se-blink")}),600))}const fi=class{#J;#X;#Q;constructor(t){this.#J=t.$,this.#X=this.#J.frameContext,this.#Q=this.#J.frameOptions}check(t){const e=this.#Q.get("charCounter_max");if(e){const s=this.getLength("string"==typeof t?t:"byte-html"===this.#Q.get("charCounter_type")&&1===t.nodeType?t.outerHTML:t.textContent);if(s>0&&s+this.getLength()>e)return mi(this.#X.get("charWrapper")),!1}return!0}getLength(t){return"string"!=typeof t&&(t="byte-html"===this.#Q.get("charCounter_type")?this.#X.get("wysiwyg").innerHTML:this.#X.get("wysiwyg").textContent),/byte/.test(this.#Q.get("charCounter_type"))?this.getByteLength(t):t.length}getByteLength(t){if(!t||!t.toString)return 0;let e,s;return t=t.toString(),u?(s=decodeURIComponent(encodeURIComponent(t)).length,e=0,null!==encodeURIComponent(t).match(/(%0A|%0D)/gi)&&(e=encodeURIComponent(t).match(/(%0A|%0D)/gi).length),s+e):(s=(new TextEncoder).encode(t).length,e=0,null!==encodeURIComponent(t).match(/(%0A|%0D)/gi)&&(e=encodeURIComponent(t).match(/(%0A|%0D)/gi).length),s+e)}getWordCount(t){"string"!=typeof t&&(t=this.#X.get("wysiwyg").innerText);const e=t.trim();return e?e.split(/\s+/).length:0}display(t){const e=t||this.#X,s=e.get("charCounter"),i=e.get("wordCounter");(s||i)&&o.setTimeout((()=>{s&&(s.textContent=String(this.getLength())),i&&(i.textContent=String(this.getWordCount()))}),0)}test(t,e){let s=0;t&&(s=this.getLength(t)),this.display();const i=this.#Q.get("charCounter_max");if(i>0){let t=!1;const n=this.getLength();if(n>i){if(t=!0,s>0&&e){this.#J.selection.init();const t=this.#J.selection.getRange(),e=t.endOffset-1,s=this.#J.selection.getNode().textContent,i=t.endOffset-1;this.#J.selection.getNode().textContent=s.slice(0,i<0?0:i)+s.slice(t.endOffset,s.length),this.#J.selection.setRange(t.endContainer,e,t.endContainer,e)}}else n+s>i&&(t=!0);if(t&&(mi(this.#X.get("charWrapper")),s>0))return!1}return!0}};const vi=class{#J;#ot;#_e=!1;constructor(t){this.#J=t.$,this.#ot=this.#J.options,this.keyMap=new Map,this.reverseKeys=new Set}command(t,e,s,i,n,o,r,l){if(this.#_e)return!1;let a=null;return a=e?this.keyMap.get(i+(s?"1000":"")):this.keyMap.get(n)||this.keyMap.get(n+t.key),!(!a||!s&&a.s||a.space&&!Pe.isSpace(i)||a.enter&&!Pe.isEnter(i)||a.textTrigger&&!t.key.trim()||a.edge&&!o)&&(a.plugin&&"string"==typeof a.method?this.#J.plugins[a.plugin][a.method]?.({range:l,line:r,info:a,event:t,keyCode:i}):"function"==typeof a.method?a.method({range:l,line:r,info:a,event:t,keyCode:i}):this.#J.commandDispatcher.run(a.command,a.type,a.button),!0)}disable(){this.#_e=!0}enable(){this.#_e=!1}_registerShortcuts(){const t=this.#ot.get("shortcuts"),e=this.#ot.get("_reverseCommandArray"),s=this.keyMap=new Map,i=this.reverseKeys;for(const n of Object.keys(t)){if(this.#J.plugins[n])continue;ts(n.startsWith("_")?"":n,null,t[n],s,e,i)}}_destroy(){this.keyMap.clear(),this.reverseKeys.clear()}},bi=new Map([["__figureInst",null],["__dragInst",null],["__dragHandler",null],["__dragContainer",null],["__dragCover",null],["__dragMove",null],["__overInfo",null]]),yi=bi,{_w:wi,isMobile:Ci,ON_OVER_COMPONENT:_i}=Le,ki="2147483646",xi="2147483645",$i="2147483642",Si="2147483641",Ei={left:0,right:0,top:0};let Ti=null;const Mi=class{#J;#ke;#xe;#$e;#Se=Ei;#Ee=!1;#Te=!1;#Me=null;#Ne=null;#Be=null;#Ie=[];#Le=new Map;constructor(t,e,s,i,n){this.#J=e,this.kind=n||t.constructor.key||t.constructor.name,this.host=t,this.form=s,this.isOpen=!1,this.currentTarget=null,this.currentPositionTarget=null,this.isWWTarget=i.isWWTarget??!0,this.position=i.position||"bottom",this.disabled=!!i.disabled,this.parents=i.parents||[],this.parentsForm=[],this.parentsHide=!!i.parentsHide,this.sibling=i.sibling||null,this.siblingMain=!!i.siblingMain,this.isInsideForm=!!i.isInsideForm,this.isOutsideForm=!!i.isOutsideForm,this.toTop=!1,this.__offset={},this.#ke="function"==typeof i.initMethod?i.initMethod:null,this.#xe="function"==typeof i.escGuard?i.escGuard:null,this.#$e={keydown:this.#Ae.bind(this),mousedown:this.#Oe.bind(this)};for(const t of this.parents)Re.check.isElement(t)?this.parentsForm.push(t):(t.#Ie.push(this),this.parentsForm.push(t.form));this.form.setAttribute("popover","manual"),this.#J.contextProvider.carrierWrapper.appendChild(s),this.#J.eventManager.addEvent(s,"click",this.#Re.bind(this)),this.#J.eventManager.addEvent(s,"mouseenter",this.#ze.bind(this)),this.#J.eventManager.addEvent(s,"mouseleave",this.#Pe.bind(this))}open(t,e,{isWWTarget:s,passive:i,initMethod:n,disabled:o,addOffset:r}={}){if(bi.get("__overInfo")===_i&&(i=!0),!t)return void console.warn("[SUNEDITOR.Controller.open.fail] The target element is required.");if(this.form.removeAttribute("data-se-hidden-by-parent"),this.form.removeAttribute("data-se-hidden-by-children"),this.#Le.clear(),i||(this.#J.store.mode.isBalloon?this.#J.toolbar.hide():this.#J.store.mode.isSubBalloon&&this.#J.subToolbar.hide(),this.#J.store.get("hasFocus")||(o??this.disabled?this.#J.ui.setControllerOnDisabledButtons(!0):this.#J.ui.setControllerOnDisabledButtons(!1))),this.currentPositionTarget=e||t,this.isWWTarget=s??this.isWWTarget,"function"==typeof n&&(this.#ke=n),i||(this.#J.ui.currentControllerName=this.kind),this.#Se={left:0,right:0,top:0,...r},!i){const t=this.isOutsideForm?this.parentsForm:[];this.#J.ui.opendControllers?.forEach((e=>{t.includes(e.form)||(e.form.style.zIndex=Si)})),this.parentsHide&&this.parentsForm.forEach((t=>{t.style.display="none",t.setAttribute("data-se-hidden-by-children","1")}))}this.#De(),this.#Fe(this.form,this.currentPositionTarget,!1);const l=this.#J.instanceCheck.isRange(t);this.currentTarget=l?null:t,this.#He(this.form,t,l,i),wi.setTimeout((()=>bi.set("__overInfo",!1)),0)}close(t){(t||this.isOpen&&!this.#Te)&&(this.form.removeAttribute("data-se-hidden-by-parent"),this.form.removeAttribute("data-se-hidden-by-children"),this.#Le.clear(),this.#qe("close"),this.toTop=!1,this.isOpen=!1,this.#Te=!1,this.__offset={},this.#Se=Ei,this.#We(),this.#ke?.(),this.#Ue(),this.parentsHide&&!t&&this.parentsForm.forEach((t=>{t.style.display="block",t.removeAttribute("data-se-hidden-by-children")})),this.host.controllerClose?.(),this.parentsForm.length>0||this.#J.component.deselect())}hide(){this.#qe("hide"),this.form.style.display="none"}show(){this.#Fe(this.form,this.currentPositionTarget,!1)}bringToTop(t){this.toTop=t,this.form.style.zIndex=t?ki:xi}resetPosition(t){this.#Fe(this.form,t||this.currentPositionTarget,!0)}_scrollReposition(){this.form.hasAttribute("data-se-hidden-by-parent")||this.form.hasAttribute("data-se-hidden-by-children")||this.#Fe(this.form,this.currentPositionTarget,!1)&&wi.setTimeout((()=>{this.#qe("show")}),0)}#qe(t){for(const e of this.#Ie)if("hide"===t&&"none"!==e.form.style.display){const t=this.#Ve(e);e.#Le.set(this,!0);const s=this.#Ve(e);!t&&s&&(e.form.setAttribute("data-se-hidden-by-parent","1"),e.hide())}else if("show"===t){if(e.form.hasAttribute("data-se-hidden-by-children")){e.#qe("show");continue}const t=this.#Ve(e);e.#Le.set(this,!1);const s=this.#Ve(e);t&&!s&&(e.form.removeAttribute("data-se-hidden-by-parent"),e.show())}else e[t]?.(!0)}#Ve(t){for(const e of t.#Le.values())if(!0===e)return!0;return!1}async#He(t,e,s,i){const n={position:this.position,inst:this,form:t,target:e,isRangeTarget:s,notInCarrier:!this.#J.contextProvider.carrierWrapper.contains(t)};!1!==await this.#J.eventManager.triggerEvent("onBeforeShowController",{caller:this.kind,frameContext:this.#J.frameContext,info:n})&&(t.style.display="block",this.#J.contextProvider.shadowRoot&&(this.#Me=this.#J.eventManager.addEvent(t,"mousedown",(t=>t.stopPropagation()))),i||(this.#J.ui.onControllerContext(),this.#J.store.set("controlActive",!0),this.#J.store.set("_preventBlur",!0)),this.isOpen||this.#J.ui.opendControllers.push(n),this.isOpen=!0,this.host.controllerOn?.(t,e),this.#J.eventManager.triggerEvent("onShowController",{caller:this.kind,frameContext:this.#J.frameContext,info:n}))}#Ue(){Ti===this&&(Ti=null),this.form.hidePopover?.(),this.form.style.display="none",this.#J.ui.opendControllers=this.#J.ui.opendControllers.filter((t=>t.form!==this.form)),this.#J.ui.currentControllerName!==this.kind&&this.#J.ui.opendControllers.length>0||(this.#J.ui.setControllerOnDisabledButtons(!1),this.#J.ui.offControllerContext(),this.#J.frameContext.get("lineBreaker_t").style.display=this.#J.frameContext.get("lineBreaker_b").style.display="none",this.#J.store.set("_lastSelectionNode",null),this.#J.ui.currentControllerName="",this.#J.store.set("_preventBlur",!1),wi.setTimeout((()=>{this.#J.store.set("controlActive",!1)}),0),this.#Me&&=this.#J.eventManager.removeEvent(this.#Me))}#Fe(t,e,s){if(!e)return!1;if(t.style.visibility="hidden",t.style.display="block",this.sibling&&"block"!==this.sibling.style.display&&(this.sibling.style.visibility="hidden",this.sibling.style.display="block"),this.#J.selection.isRange(e)){if(!this.#J.offset.setRangePosition(this.form,e,{position:"bottom"}))return this.hide(),!1}else{const i=this.#J.offset.setAbsPosition(t,e,{addOffset:this.#Se,position:this.position,isWWTarget:this.isWWTarget,inst:this,sibling:this.sibling});if(!i)return this.hide(),!1;if(s||!this.sibling||this.siblingMain)this.#Ee=!1;else{const e=t.offsetTop-this.#Se.top;"bottom"===i.position?(this.#Ee=!0,t.style.top=e+this.sibling.offsetHeight-1+"px"):(this.#Ee=!1,t.style.top=e-this.sibling.offsetHeight+2+"px")}}return t.style.zIndex=this.toTop?xi:this.#Ee?$i:Si,t.style.visibility="",t.showPopover?.(),!0}#De(){this.#We(),this.#Ne=this.#J.eventManager.addGlobalEvent("keydown",this.#$e.keydown,!0),this.#Be=this.#J.eventManager.addGlobalEvent(Ci?"click":"mousedown",this.#$e.mousedown,!0)}#We(){this.#J.component.__removeGlobalEvent(),this.#Ne&&=this.#J.eventManager.removeGlobalEvent(this.#Ne),this.#Be&&=this.#J.eventManager.removeGlobalEvent(this.#Be)}#je(){if(this.#J.ui.selectMenuOn)return!0;const t=this.#J.ui.opendControllers;for(let e=0;e<t.length;e++)if(t[e].inst===this&&t[e].fixed)return!0;return!1}#Ge(t){if(Re.check.isWysiwygFrame(t)||t.contains(this.form))return!1;if(Re.utils.hasClass(t,"se-drag-handle"))return!0;let e=!1;this.isInsideForm&&this.parentsForm?.length>0&&this.parentsForm.some((s=>{if(s.contains(t))return e=!0,!0}));const s=this.host._element;return!e&&(!!Re.query.getParentElement(t,".se-controller")||(this.#J.component.isInline(s)?t===s:t?.contains(s)))}#Re(t){const e=Re.query.getEventTarget(t),s=Re.query.getCommandTarget(e);s&&(t.stopPropagation(),t.preventDefault(),"close"!==s.getAttribute("data-command")?this.host.controllerAction(s):this.close())}#ze(t){if(this.#J.ui.currentControllerName=this.kind,this.parentsForm.length>0&&this.isInsideForm)return;Re.query.getEventTarget(t).style.zIndex=this.toTop?ki:xi,this.sibling&&Ti!==this&&this.form.matches?.(":popover-open")&&(Ti=this,this.form.hidePopover(),this.form.showPopover())}#Pe(t){if(this.parentsForm.length>0&&this.isInsideForm)return;Re.query.getEventTarget(t).style.zIndex=this.toTop?xi:this.#Ee?$i:Si}#Ae(t){if(this.#je())return;const e=t.code;if(Pe.isCtrl(t)||!Pe.isNonResponseKey(e))return;const s=Re.query.getEventTarget(t);if(Pe.isEsc(e)){if(this.#Ie.some((({isOpen:t})=>t)))return;if(this.#xe?.())return}else{if(this.form.contains(s)||this.#Ge(s))return;if(this.#J.pluginManager.fileInfo.pluginRegExp.test(this.kind))return}this.#Ke(s),this.close()}#Oe(t){const e=Re.query.getEventTarget(t);this.host?._element?.contains(e)?this.#Te=!0:(this.#Te=!1,e===this.host._element||e===this.currentTarget||this.#je()||this.form.contains(e)||this.#Ge(e)||Re.query.getParentElement(e,".se-line-breaker-component")||(this.#Ke(e),this.close(!0)))}#Ke(t){this.#J.frameContext.get("wysiwyg").contains(t)||(this.#J.component.__prevent=!1)}},{_w:Ni}=Le;const Bi=class{#J;#Ye;#Xe;#Ze;#Je;#$e;#Qe=null;#ts=null;#es=null;#ss=null;#Ne=null;#is=null;#ns=null;#os=null;#st=null;#rs=null;#ls=null;#as=new Map;#hs=-1;#cs=-1;#ds=!1;#us=null;constructor(t,e){this.#J=t;const s=e.position.split("-");this.form=null,this.items=[],this.menus=null,this.menuLen=0,this.index=-1,this.item=null,this.isOpen=!1,this.checkList=!!e.checkList,this.position=s[0],this.subPosition=s[1],this.splitNum=e.splitNum||0,this.horizontal=!!this.splitNum,this.openMethod=e.openMethod,this.closeMethod=e.closeMethod,this.subEscMethod=e.subEscMethod||null,this.maxHeight=e.maxHeight||"",this.minWidth=e.minWidth||"",this.#es=e.keydownTarget||null,this.#Ye=/^(left|right)$/.test(this.position)?"left"===this.position?"right":"left":this.position,this.#Xe=/^(left|right)$/.test(this.subPosition)?"left"===this.subPosition?"right":"left":this.subPosition,this.#Ze="ltr"!==e.dir&&("rtl"===e.dir||null),this.#Je={mousedown:this.#ps.bind(this),mousemove:this.#gs.bind(this),click:this.#ms.bind(this),keydown:this.#fs.bind(this)},this.#$e={keydown:this.#vs.bind(this),mousedown:this.#Oe.bind(this),click:this.#bs.bind(this),submenuReposition:this.#ys.bind(this)}}create(t,e){this.form.firstElementChild.innerHTML="";for(const[,t]of this.#as)t.element?.remove();this.#as.clear(),e||=t;let s="";for(let i=0,n=e.length;i<n;i++){i>0&&i%this.splitNum==0&&(this.#ws(s),s="");const n=t[i],o="string"==typeof e[i]?e[i]:e[i].outerHTML,r=n&&"object"==typeof n?n:{};if(r.children?.length>0){let t="";const e=r.childMenus||r.children;for(let s=0;s<e.length;s++)t+=`<li class="se-select-item" data-parent-index="${i}" data-child-index="${s}">${"string"==typeof e[s]?e[s]:e[s].outerHTML}</li>`;s+=`<li class="se-select-item se-has-submenu" data-index="${i}">${o}<span class="se-submenu-arrow">${this.#J.icons.menu_arrow_right}</span></li>`;const n=Re.utils.createElement("DIV",{class:"se-select-submenu",popover:"manual","data-parent-index":String(i)},`<ul class="se-list-basic se-list-checked">${t}</ul>`);this.#as.set(i,{items:r.children,menus:e,element:n})}else s+=`<li class="se-select-item" data-index="${i}">${o}</li>`}this.#ws(s);for(const[,t]of this.#as)this.form.appendChild(t.element);this.items=t,this.menus=Array.from(this.form.querySelectorAll("li[data-index]")),this.menuLen=this.menus.length}on(t,e,s={}){this.#Qe=t,this.#ts=this.#es||(Re.check.isInputElement(t)?t:this.#J.frameContext.get("_ww")),this.#ss=e;let i="";this.maxHeight&&(i+="max-height:"+this.maxHeight+";overflow-y:auto;"),this.minWidth&&(i+="min-width:"+this.minWidth+";"),this.form=Re.utils.createElement("DIV",{class:"se-select-menu"+(!0===this.#Ze?" se-rtl":"")+(s.class?" "+s.class:""),style:s.style||""},'<div class="se-list-inner"'+(i?' style="'+i+'"':"")+"></div>"),t.parentNode.insertBefore(this.form,t)}open(t,e){this.#J.ui.selectMenuOn=!0,this.openMethod?.(),this.#Cs(),this.#De();const s=t?t.split("-"):[],i=s[0]||(null!==this.#Ze&&this.#Ze!==this.#J.options.get("_rtl")?this.#Ye:this.position),n=s[1]||(null!==this.#Ze&&this.#Ze!==this.#J.options.get("_rtl")?this.#Xe:this.subPosition);this.#rs=i,this.#ls=n,this.#_s(i,n,e),this.isOpen=!0}reposition(){this.isOpen&&this.#rs&&this.#_s(this.#rs,this.#ls)}setHidden(t){this.isOpen&&(t?(this.#ks(),this.form.style.display="none"):this.reposition())}close(){this.#J.ui.selectMenuOn=!1,Re.utils.removeClass(this.#Qe,"on"),this.#xs(),this.form?.removeAttribute("style"),this.isOpen=!1,this.closeMethod?.()}getItem(t){return this.items[t]}setItem(t){this.#$s(t)}hasOpenSubmenu(){return this.#hs>-1}#Ss(t){if(this.#hs===t)return;this.#ks();const e=this.menus[t];if(!e||!Re.utils.hasClass(e,"se-has-submenu"))return;Re.utils.addClass(e,"se-submenu-open"),this.#hs=t,this.#cs=-1,this.#ds=!1;const s=this.#as.get(t),i=s?.element;if(i){const t="function"==typeof i.showPopover;i.style.visibility="hidden",t?i.matches(":popover-open")||i.showPopover():i.style.display="block",this.#Es(e,i,t),i.style.visibility="",this.#os=this.#J.eventManager.addGlobalEvent("scroll",this.#$e.submenuReposition,!0)}}#Es(t,e,s){const i=s?{top:0,left:0}:this.form.getBoundingClientRect(),n=t.getBoundingClientRect(),o=e.offsetWidth,r=e.offsetHeight,l=Ni.innerWidth,a=Ni.innerHeight,h=n.right,c=n.left-o,d=Math.max(0,h+o-l),u=Math.max(0,-c);let p;p=!0===this.#Ze?0===u?c:0===d?h:u<=d?c+u:h-d:0===d?h:0===u?c:d<=u?h-d:c+u,e.style.left=p-i.left+"px",e.style.right="";const g=n.top,m=n.bottom-r,f=Math.max(0,g+r-a),v=Math.max(0,-m);let b;b=0===f?g:0===v?m:f<=v?g-f:m+v,e.style.top=b-i.top+"px"}#ys(){if(this.#hs<0)return;const t=this.#as.get(this.#hs),e=t?.element,s=this.menus[this.#hs];e&&s&&this.#Es(s,e,"function"==typeof e.showPopover)}#ks(){if(this.#us&&(Ni.clearTimeout(this.#us),this.#us=null),this.#os&&=this.#J.eventManager.removeGlobalEvent(this.#os),this.#hs>-1){const t=this.menus[this.#hs];t&&Re.utils.removeClass(t,"se-submenu-open");const e=this.#as.get(this.#hs);e?.element&&("function"==typeof e.element.hidePopover?e.element.matches(":popover-open")&&e.element.hidePopover():e.element.style.display="",Re.utils.removeClass(e.element.querySelectorAll(".se-select-item"),"se-select-cursor"))}this.#hs=-1,this.#cs=-1,this.#ds=!1}#Ts(t,e){const s=this.#as.get(t);if(s){if(this.checkList){const t=s.element?.querySelectorAll(".se-select-item")[e];t&&Re.utils.toggleClass(t,"se-checked")}this.#ss(s.items[e])}}#Ms(t){const e=this.#as.get(this.#hs);if(!e?.element)return;const s=e.element.querySelectorAll(".se-select-item"),i=s.length;if(!i)return;t=this.#cs+t;const n=this.#cs=t>=i?0:t<0?i-1:t;Re.utils.removeClass(this.form,"se-select-menu-mouse-move");for(let t=0;t<i;t++)t===n?Re.utils.addClass(s[t],"se-select-cursor"):Re.utils.removeClass(s[t],"se-select-cursor")}#ws(t){this.form.firstElementChild.innerHTML+=`<ul class="se-list-basic se-list-checked${this.horizontal?" se-list-horizontal":""}">${t}</ul>`}#xs(){this.#Ns(),this.#We(),this.#ks(),this.index=-1,this.item=null,this._onItem&&(Re.utils.removeClass(this._onItem,"se-select-on"),this._onItem=null)}#Bs(t){t=this.index+t;const e=this.menuLen,s=this.index=t>=e?0:t<0?e-1:t;this.#$s(s)}#$s(t){Re.utils.removeClass(this.form,"se-select-menu-mouse-move");const e=this.menuLen;for(let s=0;s<e;s++)s===t?Re.utils.addClass(this.menus[s],"se-select-cursor"):Re.utils.removeClass(this.menus[s],"se-select-cursor");this.index=t,this.item=this.items[t]}#_s(t,e,s,i){const n=t,o=this.form,r=this.#Qe;o.style.visibility="hidden",o.style.display="block",Re.utils.removeClass(o,"se-select-menu-scroll"),Re.utils.addClass(r,"on");const l=o.offsetWidth,a=r.offsetWidth,h=r.offsetLeft;let c=!1,d=0,u=0;"left"===t?(d=h-l-1,t=e,c=!0):"right"===t&&(d=h+a+1,t=e,c=!0);const p=this.#J.offset.get(r),g=r.offsetTop,m=p.top,f=r.offsetHeight,v=Re.utils.getClientSize().h-(m-Ni.scrollY+f),b=c?f:0;let y=1e4;switch(t){case"middle":{let t=o.offsetHeight;const e=f/2;u=g-t/2+e,m<t/2&&(u+=t/2-m-e+4,o.style.top=u+"px");let s=this.#J.offset.getGlobal(o).top;const i=t-(m-s)-v-f;i>0&&(u-=i+4,o.style.top=u+"px"),s=this.#J.offset.getGlobal(o).top,s<0&&(t+=s-4,u-=s-4),o.style.height=t+"px";break}case"top":if(m<o.offsetHeight-b){if(!i){y=0;break}y=m-4+b,y>=38&&(o.style.height=y+"px")}u=g-o.offsetHeight+b;break;case"bottom":if(v<o.offsetHeight+b){if(!i){y=0;break}y=v-4+b,y>=38&&(o.style.height=y+"px")}u=g+(c?0:f)}if(y<38&&!i&&"middle"!==t)return void this.#_s("top"===t?"bottom":"top",e,s,!0);if(!c)switch(e){case"center":d=h+a/2-l/2;break;case"left":d=h;break;case"right":d=h-(l-a)}o.style.left=d+"px";let w=this.#J.offset.getGlobal(o).fixedLeft,C=0;switch(c+"-"+(c?n:e)){case"true-left":w<0&&(d=h+a+1);break;case"true-right":w+l>Ni.innerWidth&&(d=h-l-1);break;case"false-center":C=Ni.innerWidth-(w+l),C<0&&(d+=C-4),o.style.left=d+"px",w=this.#J.offset.getGlobal(o).fixedLeft,w<0&&(d-=w-4);break;case"false-left":C=Ni.innerWidth-(w+l),C<0&&(d+=C-4);break;case"false-right":w<0&&(d-=w-4)}if(s){const t=o.firstElementChild.querySelector(s);t&&(this._onItem=t,Re.utils.addClass(t,"se-select-on"))}o.style.left=d+"px",o.style.top=u+"px",o.style.visibility=""}#Is(t){this.checkList&&Re.utils.toggleClass(this.menus[t],"se-checked"),this.#ss(this.getItem(t))}#Cs(){this.#Ns(),this.#st={mousedown:this.#J.eventManager.addEvent(this.form,"mousedown",this.#Je.mousedown),mousemove:this.#J.eventManager.addEvent(this.form,"mousemove",this.#Je.mousemove),click:this.#J.eventManager.addEvent(this.form,"click",this.#Je.click),keydown:this.#J.eventManager.addEvent(this.#ts,"keydown",this.#Je.keydown)}}#Ns(){this.#st&&(this.#J.eventManager.removeEvent(this.#st.mousedown),this.#J.eventManager.removeEvent(this.#st.mousemove),this.#J.eventManager.removeEvent(this.#st.click),this.#J.eventManager.removeEvent(this.#st.keydown),this.#st=null)}#De(){this.#We(),this.#Ne=this.#J.eventManager.addGlobalEvent("keydown",this.#$e.keydown,!0),this.#is=this.#J.eventManager.addGlobalEvent("mousedown",this.#$e.mousedown,!0)}#We(){this.#Ne&&=this.#J.eventManager.removeGlobalEvent(this.#Ne),this.#is&&=this.#J.eventManager.removeGlobalEvent(this.#is),this.#ns&&=this.#J.eventManager.removeGlobalEvent(this.#ns)}#fs(t){if(this.#ds)switch(t.code){case"ArrowUp":return t.preventDefault(),t.stopPropagation(),void this.#Ms(-1);case"ArrowDown":return t.preventDefault(),t.stopPropagation(),void this.#Ms(1);case"ArrowLeft":t.preventDefault(),t.stopPropagation(),this.#ds=!1,this.#cs=-1;{const t=this.#as.get(this.#hs);t?.element&&Re.utils.removeClass(t.element.querySelectorAll(".se-select-item"),"se-select-cursor")}return;case"Enter":case"Space":return void(this.#cs>-1&&(t.preventDefault(),t.stopPropagation(),this.#Ts(this.#hs,this.#cs)))}let e;switch(t.code){case"ArrowUp":if(t.preventDefault(),t.stopPropagation(),this.horizontal&&this.index>-1){const t=this.splitNum;e=this.index-t<0?t:-t}else e=-1;break;case"ArrowDown":if(t.preventDefault(),t.stopPropagation(),this.horizontal&&this.index>-1){const t=this.splitNum;e=this.index+t>this.menuLen?-t:t}else e=1;break;case"ArrowLeft":t.preventDefault(),t.stopPropagation(),e=-1;break;case"ArrowRight":if(t.preventDefault(),t.stopPropagation(),this.index>-1&&this.#as.has(this.index))return this.#Ss(this.index),this.#ds=!0,void this.#Ms(1);e=1;break;case"Enter":case"Space":this.index>-1&&(t.preventDefault(),t.stopPropagation(),this.#as.has(this.index)?(this.#Ss(this.index),this.#ds=!0,this.#Ms(1)):this.#Is(this.index))}e&&(this.#ks(),this.#Bs(e))}#ps(t){if(Le.isGecko){const e=Re.query.getEventTarget(t),s=Re.query.getParentElement(e,".se-select-item");s&&this.#J.eventManager._injectActiveEvent(s)}}#gs(t){const e=Re.query.getEventTarget(t);Re.utils.addClass(this.form,"se-select-menu-mouse-move");const s=e.closest?.("[data-child-index]"),i=s?.getAttribute("data-child-index");if(null!=i){this.#cs=Number(i);const t=this.#as.get(this.#hs);if(t?.element){const e=t.element.querySelectorAll(".se-select-item");Re.utils.removeClass(e,"se-select-cursor"),Re.utils.addClass(e[this.#cs],"se-select-cursor")}return}const n=e.closest?.("[data-index]"),o=n?.getAttribute("data-index");if(!o)return;const r=Number(o);if(this.index=r,this.#as.has(r))this.#us&&Ni.clearTimeout(this.#us),this.#Ss(r);else if(this.#hs>-1){const t=this.#as.get(this.#hs);t?.element?.contains(e)||this.#ks()}}#ms(t){let e=Re.query.getEventTarget(t),s=null,i=null;for(;!(s||i||/UL/i.test(e.tagName)||Re.utils.hasClass(e,"se-select-menu"));)i=e.getAttribute("data-child-index"),i||(s=e.getAttribute("data-index")),e=e.parentElement;if(null!==i){let t=e,s=null;for(;!s&&t;)s=t.getAttribute("data-parent-index")||t.getAttribute("data-index"),t=t.parentElement;return void(null!==s&&this.#Ts(Number(s),Number(i)))}if(!s)return;const n=Number(s);this.#as.has(n)?this.#hs===n?this.#ks():this.#Ss(n):this.#Is(n)}#vs(t){if(Pe.isEsc(t.code)){if(this.#hs>-1){t.preventDefault(),t.stopPropagation();const e=this.#hs;return this.#ks(),void this.#$s(e)}if(this.subEscMethod?.())return t.preventDefault(),void t.stopPropagation();this.close()}}#Oe(t){const e=Re.query.getEventTarget(t);this.form.contains(e)||this.#J.ui.opendControllers?.some((({form:t})=>t?.contains?.(e)&&!t.contains(this.#Qe)))||(this.#Qe.contains(e)?Re.check.isInputElement(e)||(this.#ns=this.#J.eventManager.addGlobalEvent("click",this.#$e.click,!0)):this.close())}#bs(t){this.#ns=this.#J.eventManager.removeGlobalEvent(this.#ns),t.target===this.#Qe&&(t.stopPropagation(),this.close())}},{_w:Ii,ON_OVER_COMPONENT:Li}=Le,Ai={tl:"nwse-resize",tr:"nesw-resize",bl:"nesw-resize",br:"nwse-resize",lw:"ew-resize",th:"ns-resize",rw:"ew-resize",bh:"ns-resize"};let Oi=!1,Ri=!1,zi=0,Pi=0;class Di{#J;#Ls;#As;#Os="";#Rs="";#zs=0;#Ps=0;#Ds=0;#Fs=0;#Hs="__se__float-none|__se__float-left|__se__float-center|__se__float-right";#qs=!1;#Ws={w:"",h:""};#Us=null;constructor(t,e,s,i){this.#J=e,this.kind=t.constructor.key||t.constructor.name,this._alignIcons={none:this.#J.icons.format_float_none,left:this.#J.icons.format_float_left,right:this.#J.icons.format_float_right,center:this.#J.icons.format_float_center},this._action={};const n=function(t,e,s){let i=null;if(s?.length>0){const{lang:n,icons:o}=e;i='<div class="se-arrow se-arrow-up"></div>';for(let e,r=0;r<s.length;r++){e=s[r],i+='<div class="se-btn-group">';for(let s,r=0,l=e.length;r<l;r++){if(s=e[r],"function"==typeof s?.action){const e=s;s={c:`__c__${e.command}`,v:e.value||"",l:e.title,i:e.icon},t._action[s.c]=e.action}else if(s=qi(s),!s)continue;i+=`\n\t\t\t\t\t<button type="button" data-command="${s.c}" data-value="${s.v}" class="se-btn se-tooltip">\n\t\t\t\t\t\t${o[s.i]||s.i}\n\t\t\t\t\t\t<span class="se-tooltip-inner"><span class="se-tooltip-text">${n[s.l]||s.l}</span></span>\n\t\t\t\t\t</button>`}i+="</div>"}}return i?Re.utils.createElement("DIV",{class:"se-controller se-controller-resizing"},i):null}(this,e,s||[]);if(this.controller=n?new Mi(this,e,n,{position:"bottom",disabled:!0},this.kind):null,n){this.alignButton=n.querySelector('[data-command="onalign"]');const t=function(t,e,s){if(!s)return null;const i=[t._alignIcons.none,t._alignIcons.left,t._alignIcons.center,t._alignIcons.right],n=[e.lang.basic,e.lang.left,e.lang.center,e.lang.right],o=["none","left","center","right"],r=[],l=[];for(let t=0;t<o.length;t++)r.push(`\n\t\t<button type="button" class="se-btn-list se-tooltip" data-command="${o[t]}" data-type="selectMenu" >\n\t\t\t${i[t]}\n\t\t\t<span class="se-tooltip-inner">\n\t\t\t\t<span class="se-tooltip-text">${n[t]}</span>\n\t\t\t</span>\n\t\t</button>`),l.push(o[t]);return{html:r,items:l}}(this,e,this.alignButton);t&&(this.selectMenu_align=new Bi(e,{checkList:!1,position:"bottom-center"}),this.selectMenu_align.on(this.alignButton,this.#Vs.bind(this),{class:"se-figure-select-list"}),this.selectMenu_align.create(t.items,t.html)),this.asButton=n.querySelector('[data-command="onas"]');const s=function(t,e){if(!e)return null;const s=[t.icons.as_block,t.icons.as_inline],i=[t.lang.asBlock,t.lang.asInline],n=["block","inline"],o=[],r=[];for(let t=0;t<n.length;t++)o.push(`\n\t\t<button type="button" class="se-btn-list se-tooltip" data-command="${n[t]}" data-type="selectMenu" >\n\t\t\t${s[t]}\n\t\t\t<span class="se-tooltip-inner">\n\t\t\t\t<span class="se-tooltip-text">${i[t]}</span>\n\t\t\t</span>\n\t\t</button>`),r.push(n[t]);return{html:o,items:r}}(e,this.asButton);s&&(this.selectMenu_as=new Bi(e,{checkList:!1,position:"bottom-center"}),this.selectMenu_as.on(this.asButton,this.#js.bind(this),{class:"se-figure-select-list"}),this.selectMenu_as.create(s.items,s.html)),this.resizeButton=n.querySelector('[data-command="onresize"]');const i=function(t,e){if(!e)return null;const s=e.getAttribute("data-value").split(","),i=[];for(let e,n,o,r,l=0;l<s.length;l++)o=s[l],e=ze.is(o),n=e?"resize_percent"+o:"auto",r=e?o+"%":t.lang.autoSize,i.push('<button type="button" class="se-btn-list" data-command="'+n+'" data-value="'+o+'"><span>'+r+"</span></button>");return{html:i,items:s}}(e,this.resizeButton);i&&(this.selectMenu_resize=new Bi(e,{checkList:!1,position:"bottom-left",dir:"ltr"}),this.selectMenu_resize.on(this.resizeButton,this.#Gs.bind(this)),this.selectMenu_resize.create(i.items,i.html))}this.inst=t,this.sizeUnit=i.sizeUnit||"px",this.autoRatio=i.autoRatio,this.isVertical=!1,this.percentageButtons=n?.querySelectorAll('[data-command="resize_percent"]')||[],this.captionButton=n?.querySelector('[data-command="caption"]'),this.align="none",this.as="block",this.__offset={},this._element=null,this._cover=null,this._inlineCover=null,this._container=null,this._caption=null,this._resizeClientX=0,this._resizeClientY=0,this._resize_direction="",this.__containerResizingOff=this.#Ks.bind(this),this.__containerResizing=this.#Ys.bind(this),this.__onContainerEvent=null,this.__offContainerEvent=null,this.#Ls=this.#Xs.bind(this),this.#As=this.#Zs.bind(this),this.#J.eventManager.addEvent(this.alignButton,"click",this.#Js.bind(this)),this.#J.eventManager.addEvent(this.asButton,"click",this.#Qs.bind(this)),this.#J.eventManager.addEvent(this.resizeButton,"click",this.#ti.bind(this)),this.#J.contextProvider.applyToRoots((t=>{if(!t.get("wrapper").querySelector(".se-controller.se-resizing-container")){const e=function(){const t='\n\t\t<div class="se-resize-dot">\n\t\t\t<span class="tl"></span>\n\t\t\t<span class="tr"></span>\n\t\t\t<span class="bl"></span>\n\t\t\t<span class="br"></span>\n\t\t\t<span class="lw"></span>\n\t\t\t<span class="th"></span>\n\t\t\t<span class="rw"></span>\n\t\t\t<span class="bh"></span>\n\t\t\t<div class="se-resize-display"></div>\n\t\t</div>';return Re.utils.createElement("DIV",{class:"se-controller se-resizing-container",style:"display: none;"},t)}(),s=e.querySelectorAll(".se-resize-dot > span");t.set("_figure",{main:e,border:e.querySelector(".se-resize-dot"),display:e.querySelector(".se-resize-display"),handles:s}),t.get("wrapper").appendChild(e),this.#J.eventManager.addEvent(s,"mousedown",this.#ei.bind(this))}}))}static CreateContainer(t,e){return Re.utils.createElement("DIV",{class:"se-component"+(e?" "+e:"")},Re.utils.createElement("FIGURE",null,t)),Di.GetContainer(t)}static CreateInlineContainer(t,e){return Re.utils.createElement("SPAN",{class:"se-component se-inline-component"+(e?" "+e:"")},t),Di.GetContainer(t)}static CreateCaption(t,e){const s=Re.utils.createElement("FIGCAPTION",null,"<div>"+e+"</div>");return t.appendChild(s),s}static GetContainer(t){const e=Re.query.getParentElement(t,"FIGURE",2),s=Re.query.getParentElement(t,"SPAN",2),i=e||s;let n=Re.query.getParentElement(t,(t=>t.parentElement===i),0)||t;if(Re.check.isAnchor(n)){const t=n.querySelector(":scope > img");t&&(n=t)}return{target:n,container:Re.query.getParentElement(n,Di.is,3)||e,cover:e,inlineCover:Re.utils.hasClass(s,"se-inline-component")?s:null,caption:Re.query.getEdgeChild(n.parentElement,"FIGCAPTION",!1),isVertical:Hi(n)}}static GetRatio(t,e,s){let i=0,n=0;if(/\d+/.test(t+"")&&/\d+/.test(e+"")){if((!ze.is(t)&&String(t).replace(/\d+|\./g,"")||s||"px")===(!ze.is(e)&&String(e).replace(/\d+|\./g,"")||s||"px")){const s=ze.get(t,4),o=ze.get(e,4);i=s/o,n=o/s}}return{w:ze.get(i,4),h:ze.get(n,4)}}static CalcRatio(t,e,s,i){if(i?.w&&i?.h&&/\d+/.test(t+"")&&/\d+/.test(e+"")){const n=!ze.is(t)&&String(t).replace(/\d+|\./g,"")||s||"px",o=!ze.is(e)&&String(e).replace(/\d+|\./g,"")||s||"px";if(n===o){const s="%"===n?2:0,r=t,l=e;e=ze.get(i.h*ze.get(r,s),s)+o,t=ze.get(i.w*ze.get(l,s),s)+n}}return{w:t,h:e}}static is(t){return Re.check.isComponentContainer(t)||/^(HR)$/.test(t?.nodeName)}close(){this.#J.store.set("_preventBlur",!1),Re.utils.removeClass(this._cover,"se-figure-selected"),this.#J.component.__removeDragEvent(),this.#si(),this.controller?.close()}open(t,{nonResizing:e,nonSizeInfo:s,nonBorder:i,figureTarget:n,infoOnly:o}){if(!t)return void console.warn('[SUNEDITOR.modules.Figure.open] The "targetNode" is null.');bi.get("__overInfo")===Li&&(i=!0);const r=Di.GetContainer(t),l=r.target;let a=!1;if(!r.container){if(this.#J.options.get("strictMode").formatFilter)return{container:null,cover:null,width:l.style.width||l.width||"",height:l.style.height||l.height||"",isVertical:this.isVertical};r.container=l,r.cover=l,a=!0}bi.set("__figureInst",this),this.#ii(r);const h=n&&(this._cover||this._container)||l,c=h.offsetWidth||null,d=h.offsetHeight||null,{top:u,left:p,scrollX:g,scrollY:m}=this.#J.offset.getLocal(h),f=(l.getAttribute("data-se-size")||"").split(",");let v=ze.get(l.style.width,2)||c,b=ze.get(l.style.height,2)||d;this.isVertical&&([v,b]=[b,v]);const y=Di.GetRatio(v,b,this.sizeUnit),w={container:r.container,cover:r.cover,caption:r.caption,align:this.align,ratio:y,isVertical:this.isVertical,w:c||"",h:d||"",t:u,l:p,width:f[0]||"auto",height:f[1]||"auto",originWidth:l.naturalWidth||l.offsetWidth,originHeight:l.naturalHeight||l.offsetHeight};if(this.#Os=w.width,this.#Rs=w.height,o)return w;const C=this.#J.frameContext.get("_figure");this.#J.ui.setFigureContainer(C.main),this.#J.ui.opendControllers=this.#J.ui.opendControllers.filter((t=>t.form!==C.main)),C.main.style.top=u+"px",C.main.style.left=p+"px",C.main.style.width=(this.isVertical?d:c)+"px",C.main.style.height=(this.isVertical?c:d)+"px",C.border.style.top="0px",C.border.style.left="0px",C.border.style.width=(this.isVertical?d:c)+"px",C.border.style.height=(this.isVertical?c:d)+"px",this.__offset={left:p+g,top:u+m},this.#J.ui.opendControllers.push({position:"none",form:C.main,target:h,inst:this,notInCarrier:!0});const _=/%$/.test(l.style.width)&&/%$/.test(r.container.style.width)?ze.get(r.container.style.width,0)/100+"":"";for(let t=0,e=this.percentageButtons.length;t<e;t++)this.percentageButtons[t].getAttribute("data-value")===_?Re.utils.addClass(this.percentageButtons[t],"active"):Re.utils.removeClass(this.percentageButtons[t],"active");if(this.captionButton&&(r.caption?Re.utils.addClass(this.captionButton,"active"):Re.utils.removeClass(this.captionButton,"active")),C.display.style.display=s||this._inlineCover?"none":"",C.border.style.display=i?"none":"",C.main.style.display="block",bi.get("__overInfo")!==Li){const t=e?"none":"flex",s=C.handles;for(let e=0,i=s.length;e<i;e++)s[e].style.display=t;if(this.controller){const t=this.getSize(l);Re.utils.changeTxt(C.display,this.#J.lang["none"===this.align?"basic":this.align]+" ("+t.dw+", "+t.dh+")"),this.#ni(),this.#oi(),this.#J.ui._visibleControllers(!0,!0);const e=this.controller.form.querySelectorAll('[data-command="rotate"][data-value="90"], [data-command="rotate"][data-value="-90"], [data-command="caption"], [data-command="onalign"], [data-command="onresize"]'),s=this._inlineCover||a?"none":"";e?.forEach((t=>{t.style.display=s}));const i=this.controller.form.querySelector('[data-command="onas"]');i&&(i.style.display=a?"none":"")}Re.utils.removeClass(this._cover,"se-figure-over-selected"),this.controller?.open(C.main,null,{initMethod:this.#Ls,isWWTarget:!1,addOffset:null}),Ii.setTimeout((()=>bi.set("__overInfo",!1)),0)}else Re.utils.addClass(this._cover,"se-figure-over-selected");return Re.utils.addClass(this._cover,"se-figure-selected"),this.#Ds=this.#zs=c,this.#Fs=this.#Ps=d,this._inlineCover||bi.get("__overInfo")===Li&&!Re.utils.hasClass(r.container,"se-input-component")||this.#ri(C.main),w}controllerHide(){this.controller?.hide()}controllerShow(){this.controller?.show()}controllerOpen(t,e){this._element=t,this.controller?.open(t,null,e)}setFigureSize(t,e){/%$/.test(t+"")?this._setPercentSize(t,e):t&&"auto"!==t||e&&"auto"!==e?this._applySize(t,e,""):this.autoRatio?this._setPercentSize(100,this.autoRatio.default||this.autoRatio.current):this._setAutoSize()}setSize(t,e){const s=this.isVertical;s&&([t,e]=[e,t]),this.setFigureSize(t,e),s&&this.setTransform(this._element,t,e,0)}getSize(t){t||=this._element;const e=Hi(t);let s="",i="",n="",o="";if(!t)return{w:s,h:i,dw:n,dh:o};const r=Di.GetContainer(t),l=r.target;return r.container?(s=/%$/.test(l.style.width)?(r.container&&ze.get(r.container.style.width,2)||100)+"%":l.style.width,i=r.inlineCover?r.inlineCover.style.height||t.style.height||String(t.height||""):ze.get(r.cover?.style.paddingBottom,0)>0&&!e?r.cover?.style.height:/%$/.test(l.style.height)&&/%$/.test(l.style.width)?(r.container&&ze.get(r.container.style.height,2)||100)+"%":l.style.height,s||="auto",i||="auto"):this.#J.options.get("strictMode").formatFilter?(s="",i=l.style.height):(s=l.style.width||"auto",i=l.style.height||"auto"),n=e?i:s,o=e?s:i,{w:s,h:i,dw:n,dh:o}}setAlign(t,e){t||=this._element,this.align=e||="none";const s=Di.GetContainer(t);if(!s.cover)return;const i=s.target,n=s.container,o=s.cover;if(/%$/.test(i.style.width)&&"center"===e&&!this.#J.component.isInline(n)?(n.style.minWidth="100%",o.style.width=n.style.width):(n.style.minWidth="",o.style.width=this.isVertical?i.style.height||i.offsetHeight+"px":i.style.width&&"auto"!==i.style.width?i.style.width||"100%":""),Re.utils.hasClass(n,"__se__float-"+e)||(Re.utils.removeClass(n,this.#Hs),Re.utils.addClass(n,"__se__float-"+e)),this.autoRatio){const{w:t,h:e}=this.getSize(this._element);this.__setCoverPaddingBottom(t,e)}this.#ni()}convertAsFormat(t,e){t||=this._element,this.as=e||"block";const{container:s,inlineCover:i,target:n}=Di.GetContainer(t),{w:o,h:r}=this.getSize(n),l=Re.check.isAnchor(n.parentNode)?n.parentNode:null,a=n.cloneNode(!1);a.style.width="",a.style.height="",a.removeAttribute("width"),a.removeAttribute("height");let h=a;if(l){const t=l.cloneNode(!1);t.appendChild(a),h=t}switch(e){case"inline":{if(i)break;this.#J.component.deselect();const t=s.nextElementSibling,e=s.parentElement,n=Di.CreateInlineContainer(h);Re.utils.addClass(n.container,s.className.split(" ").filter((t=>"se-figure-selected"!==t&&"se-component-selected"!==t)).join("|")),this.#li(n,o,r);const l=Re.utils.createElement(this.#J.options.get("defaultLine"),null,n.container);e.insertBefore(l,t),Re.utils.removeItem(s);break}case"block":{if(!i)break;this.#J.component.deselect(),this.#J.selection.setRange(s,0,s,1);const t=this.#J.html.remove(),e=this.#J.nodeTransform.split(t.container,t.offset,0);e?.previousElementSibling&&Re.check.isZeroWidth(e.previousElementSibling)&&Re.utils.removeItem(e.previousElementSibling);const n=Di.CreateContainer(h);Re.utils.addClass(n.container,s.className.split(" ").filter((t=>"se-inline-component"!==t&&"se-figure-selected"!==t&&"se-component-selected"!==t)).join("|")),this.#li(n,o,r),(e||t.container).parentElement.insertBefore(n.container,e);break}}return a}controllerAction(t){const e=t.getAttribute("data-command"),s=t.getAttribute("data-value"),i=t.getAttribute("data-type"),n=this._element;if(!/^on.+/.test(e)&&"selectMenu"!==i){switch(e){case"mirror":{const t=Fi(n);let e=t.x,i=t.y;"h"===s&&!this.isVertical||"v"===s&&this.isVertical?i=i?"":"180":e=e?"":"180",this._setRotate(n,t.r,e,i);break}case"rotate":this.setTransform(n,null,null,Number(s));break;case"caption":if(this._caption)Re.utils.removeItem(this._caption),Ii.setTimeout(this.#J.component.select.bind(this.#J.component,n,this.kind),0),this._caption=null;else{const t=Di.CreateCaption(this._cover,this.#J.lang.caption),e=Re.query.getEdgeChild(t,(t=>3===t.nodeType),!1);e?this.#J.selection.setRange(e,0,e,e.textContent.length):t.focus(),this._caption=t,this.controller.close()}(/\d+/.test(n.style.height)||this.isVertical&&this._caption)&&(/%$/.test(n.style.width)||/auto/.test(n.style.height)?this.deleteTransform():this.setTransform(n,n.style.width,n.style.height,0));break;case"revert":this._setRevert();break;case"edit":this.inst.componentEdit(n);break;case"copy":this.#J.component.copy(this._container);break;case"remove":this.inst.componentDestroy(n),this.controller.close()}/^__c__/.test(e)?this._action[e](n,s,t):"edit"!==e&&(this.#J.history.push(!1),/^remove|caption$/.test(e)||this.#J.component.select(n,this.kind))}}retainFigureFormat(t,e,s,i){const n=this.#J.component.isInline(t),o=e.parentNode;let r=this.#J.format.isBlock(o)||Re.check.isWysiwygFrame(o)||o.nodeType>=9?e:Di.GetContainer(e)?.container||o||e;if(Re.query.getParentElement(e,Re.check.isExcludeFormat))r=s&&s!==e?s:e,r.parentNode.replaceChild(t,r);else if(n&&this.#J.format.isLine(r)){const s=n&&/^SPAN$/i.test(e.parentElement.nodeName)?e.parentElement:e;s.parentElement.replaceChild(t,s)}else if(Re.check.isListCell(r)){const s=Re.query.getParentElement(e,(t=>t.parentNode===r));r.insertBefore(t,s),Re.utils.removeItem(e),this.#J.nodeTransform.removeEmptyNode(s,null,!0)}else if(this.#J.format.isLine(r)){const s=Re.query.getParentElement(e,(t=>t.parentNode===r));r=this.#J.nodeTransform.split(r,s),r.parentNode.insertBefore(t,r),Re.utils.removeItem(e),this.#J.nodeTransform.removeEmptyNode(r,null,!0)}else if(this.#J.format.isLine(r.parentNode)){const e=r.parentNode;e.parentNode.insertBefore(t,r.previousSibling?e.nextElementSibling:e),(0===i?.__updateTags.map((t=>r.contains(t))).length||Re.check.isZeroWidth(r))&&Re.utils.removeItem(r)}else r=Re.check.isFigure(r.parentNode)?Re.query.getParentElement(r.parentNode,Di.is):r,r.parentNode.replaceChild(t,r)}deleteTransform(t){t||=this._element;const e=t,s=(e.getAttribute("data-se-size")||"").split(",");this.isVertical=!1,e.style.maxWidth="",e.style.transform="",e.style.transformOrigin="",this.#ai(e),this._applySize(s[0]||"auto",s[1]||"","")}setTransform(t,e,s,i){try{this.#qs=!0;const n=Fi(t),o=n.r+1*(i||0);i=Math.abs(o)>=360?0:o;const r=this.isVertical=Hi(i);e=ze.get(e,0),s=ze.get(s,0);const l=t,a=(l.getAttribute("data-se-size")||"auto,auto").split(",");r&&this._setRotate(l,i,n.x,n.y);let h="";if(/auto|%$/.test(a[0])&&!r)"auto"===a[0]&&"auto"===a[1]?this._setAutoSize():this._setPercentSize(a[0],a[1]);else{const t=Di.GetContainer(l),n=t.cover||t.inlineCover,o=e||l.offsetWidth,a=s||l.offsetHeight,c=(r?a:o)+"px",d=(r?o:a)+"px";if(this.#hi(),this._applySize(o+"px",a+"px",""),n&&(n.style.width=c,n.style.height=t.caption||t.inlineCover?"":d),r){h=90===i||-270===i?a/2+"px "+a/2+"px 0":o/2+"px "+o/2+"px 0"}}l.style.transformOrigin=h,r||this._setRotate(l,i,n.x,n.y),l.style.maxWidth=r?"none":"",this.#ci(l)}finally{this.#qs=!1}}_displayResizeHandles(t){const e=t?"flex":"none";this.controller&&(this.controller.form.style.display=e);const s=this.#J.frameContext.get("_figure"),i=s.handles;for(let t=0,s=i.length;t<s;t++)i[t].style.display=e;"none"===e?(Re.utils.addClass(s.main,"se-resize-ing"),this.#Us=this.#J.eventManager.addGlobalEvent("keydown",this.#As)):Re.utils.removeClass(s.main,"se-resize-ing")}#li(t,e,s){const i=this.kind;t.target.onload=()=>this.#J.component.select(t.target,i),this.#ii(t),t.inlineCover&&(this.setAlign(t.target,"none"),this.deleteTransform()),this.setFigureSize(e,s)}#ii(t){this._inlineCover=t.inlineCover,this._cover=t.cover||this._inlineCover,this._container=t.container,this._caption=t.caption,this._element=t.target,this.align=(this._container.className.match(/(?:^|\s)__se__float-(none|left|center|right)(?:$|\s)/)||[])[1]||t.target.style.float||"none",this.as=this._inlineCover?"inline":"block",this.isVertical=Hi(t.target)}_setRotate(t,e,s,i){let n=(t.offsetWidth-t.offsetHeight)*(/^-/.test(e+"")?1:-1),o="";if(/[1-9]/.test(e+"")&&(s||i))switch(o=s?"Y":"X",e+""){case"90":o=s&&i?"X":i?o:"";break;case"270":n*=-1,o=s&&i?"Y":s?o:"";break;case"-90":o=s&&i?"Y":s?o:"";break;case"-270":n*=-1,o=s&&i?"X":i?o:"";break;default:o=""}e%180==0&&(t.style.maxWidth=""),t.style.transform="rotate("+e+"deg)"+(s?" rotateX("+s+"deg)":"")+(i?" rotateY("+i+"deg)":"")+(o?" translate"+o+"("+n+"px)":"")}_applySize(t,e,s){const i=/^(rw|lw)$/.test(s)&&/\d+/.test(this._element.style.height),n=/^(th|bh)$/.test(s)&&/\d+/.test(this._element.style.width);e=e||(this.autoRatio?this.autoRatio.current||this.autoRatio.default:e),t=ze.is(t)?t+this.sizeUnit:t,/%$/.test(t)||/%$/.test(e)||i||n||this.#hi();const o=this._cover||this._element;this.autoRatio&&this._cover&&(this._cover.style.width=t),n||(o.style.width=this._element.style.width=t),i||(e=ze.is(e)?e+this.sizeUnit:e,o.style.height=this._element.style.height=this.autoRatio&&!this.isVertical?"100%":e,this.autoRatio&&this._cover&&(this._cover.style.height=e,this.__setCoverPaddingBottom(t,e))),"center"===this.align&&this.setAlign(this._element,this.align),this.#di()}__setCoverPaddingBottom(t,e){this._inlineCover!==this._cover&&(this.isVertical&&([t,e]=[e,t]),this._cover.style.height=e,/%$/.test(t)&&"center"===this.align?this._cover.style.paddingBottom=/%$/.test(e)?ze.get(ze.get(e,2)/100*ze.get(t,2),2)+"%":e:this._cover.style.paddingBottom=e)}_setAutoSize(){this._caption&&(this._caption.style.marginTop=""),this.deleteTransform(),this.#hi(),this.autoRatio?this._setPercentSize("100%",this.autoRatio.current||this.autoRatio.default):(this._element.style.maxWidth="",this._element.style.width="",this._element.style.height="",this._cover&&(this._cover.style.width="",this._cover.style.height="")),this.setAlign(this._element,this.align),this.#di()}_setPercentSize(t,e){e||=this.autoRatio?/%$/.test(this.autoRatio.current)?this.autoRatio.current:this.autoRatio.default:e,e=!e||/%$/.test(e+"")||ze.get(e,0)?ze.is(e)?e+this.sizeUnit:e||(this.autoRatio?this.autoRatio.default:""):ze.is(e)?e+"%":e;const s=/%$/.test(e+"");this._container.style.width=String(ze.is(t)?t+"%":t),this._container.style.height="",this._element!==this._cover||this.#J.options.get("strictMode").formatFilter?(this._inlineCover!==this._cover&&this._cover&&(this._cover.style.width="100%",this._cover.style.height=String(e)),this._element.style.width="100%",this._element.style.maxWidth="",this._element.style.height=String(this.autoRatio?"100%":s?"":e),"center"===this.align&&this.setAlign(this._element,this.align),this.autoRatio&&this.__setCoverPaddingBottom(String(t),String(e)),this.#ci(this._element),this.#di()):this.#di()}#hi(){this._cover&&(this._cover.style.width="",this._cover.style.height=""),this._container.style.width="",this._container.style.height="",Re.utils.removeClass(this._container,this.#Hs),Re.utils.addClass(this._container,"__se__float-"+this.align),"center"===this.align&&this.setAlign(this._element,this.align)}_setRevert(){this.setFigureSize(this.#Ws.w,this.#Ws.h)}#ni(){this.alignButton&&Re.utils.changeElement(this.alignButton.firstElementChild,this._alignIcons[this.align])}#oi(){this.asButton&&Re.utils.changeElement(this.asButton.firstElementChild,this.#J.icons[`as_${this.as}`])}#di(){if(this.#qs)return;const t=(this._element.getAttribute("data-se-size")||",").split(",");this.#Ws.w=t[0],this.#Ws.h=t[1];const e=this.getSize(this._element);this._element.setAttribute("width",e.w.replace("px","")),this._element.setAttribute("height",e.h.replace("px","")),this._element.setAttribute("data-se-size",e.w+","+e.h),this.autoRatio&&(this.autoRatio.current=/%$/.test(e.h)?e.h:"")}#ci(t){const e=Re.query.getEdgeChild(Re.query.getParentElement(t,"FIGURE"),"FIGCAPTION",!1);e&&(e.style.marginTop=(this.isVertical&&!this.autoRatio?t.offsetWidth-t.offsetHeight:0)+"px",this.isVertical&&this.autoRatio?t.style.marginTop=e.offsetHeight+"px":t.style.marginTop="")}#ai(t){const e=Re.query.getEdgeChild(Re.query.getParentElement(t,"FIGURE"),"FIGCAPTION",!1);e&&(e.style.marginTop="")}#ui(){this.#J.component.__removeDragEvent(),this.#si(),this._displayResizeHandles(!0),this.#J.ui.offCurrentController(),this.#J.ui.disableBackWrapper()}#si(){this.#J.eventManager.removeGlobalEvent(this.__onContainerEvent),this.#J.eventManager.removeGlobalEvent(this.__offContainerEvent),this.#J.eventManager.removeGlobalEvent(this.#Us)}#ri(t){const e=this.#J.frameContext.get("wrapper").querySelector(".se-drag-handle");Re.utils.removeClass(e,"se-drag-handle-full"),e.style.opacity="",e.style.width="",e.style.height="",bi.set("__dragHandler",e),bi.set("__dragContainer",this._container),bi.set("__dragCover",this._cover),bi.set("__dragMove",this.#pi.bind(this,e,t)),bi.get("__dragMove")(),e.style.display="block"}#pi(t,e){t.style.display="block",t.style.left=e.offsetLeft+(this.#J.options.get("_rtl")?t.offsetWidth:e.offsetWidth-1.5*t.offsetWidth)+"px",t.style.top=e.offsetTop-t.offsetHeight+.5+"px"}#ei(t){t.stopPropagation(),t.preventDefault();const e=bi.get("__figureInst");if(!e)return;const s=Re.query.getEventTarget(t),i=e._resize_direction=s.classList[0];e._resizeClientX=t.clientX,e._resizeClientY=t.clientY,this.#J.frameContext.get("_figure").main.style.float=/l/.test(i)?"right":/r/.test(i)?"left":"none",this.#J.ui.enableBackWrapper(Ai[i]);const{w:n,h:o,dw:r,dh:l}=this.getSize(e._element);if(Oi=Ri=!1,zi=Pi=0,!this.isVertical){const t=!n||/auto|%$/.test(n),s=!o||/auto|%$/.test(o);if("tl|bl|tr|br".includes(i)&&t&&s?Oi=!0:"lw|rw".includes(i)&&t&&(Ri=!0),Oi||Ri){const t=e._cover||e._element;Pi=t.offsetWidth,zi=Oe.getWidthInPercentage(t,this.#J.frameContext.get("wysiwygFrame"))/100}}e.__onContainerEvent=this.#J.eventManager.addGlobalEvent("mousemove",e.__containerResizing),e.__offContainerEvent=this.#J.eventManager.addGlobalEvent("mouseup",e.__containerResizingOff),e._displayResizeHandles(!1);const a=this.#J.frameContext.get("_figure").display;a.style.display="block",Re.utils.changeTxt(a,r+" * "+l)}#Ys(t){const e=this._resize_direction,s=t.clientX,i=t.clientY,n=this.isVertical;let o=n?this.#Fs:this.#Ds,r=n?this.#Ds:this.#Fs;const l=o+(/r/.test(e)?s-this._resizeClientX:this._resizeClientX-s),a=r+(/b/.test(e)?i-this._resizeClientY:this._resizeClientY-i),h=r/o*l,c=this.#J.frameContext.get("_figure").border;/t/.test(e)&&(c.style.top=r-(/h/.test(e)?a:h)+"px"),/l/.test(e)&&(c.style.left=o-l+"px"),/r|l/.test(e)&&(c.style.width=l+"px",o=l),/^(t|b)[^h]$/.test(e)?(c.style.height=h+"px",r=h):/^(t|b)h$/.test(e)&&(c.style.height=a+"px",r=a);const d=!n&&/h$/.test(e)?this.#Os:Math.round(o),u=!n&&/w$/.test(e)?this.#Rs:Math.round(r),p=zi?d/Pi*zi*100:d;Re.utils.changeTxt(this.#J.frameContext.get("_figure").display,zi?ze.get(p>100?100:p,2).toFixed(2)+"%":p+" * "+u),this.#zs=d,this.#Ps=u}#Ks(){this.#ui();let t=this.isVertical?this.#Ps:this.#zs,e=this.isVertical?this.#zs:this.#Ps;if(t=Math.round(t)||t,e=Math.round(e)||e,!this.isVertical&&!/%$/.test(t+"")){const s=this.#J.frameContext.get("wysiwygFrame").clientWidth-ze.get(this.#J.frameContext.get("wwComputedStyle").getPropertyValue("padding-left"))+ze.get(this.#J.frameContext.get("wwComputedStyle").getPropertyValue("padding-right"))-2;ze.get(t,0)>s&&(e=Math.round(e/t*s),t=s)}if(Oi||Ri){t=t/(this._cover||this._element).offsetWidth*zi*100;const e=ze.get(t>100?100:t,2)+"%";this._setPercentSize(e,Ri?this.getSize(this._element).h:"")}else this._applySize(t,e,this._resize_direction),this.isVertical&&this.setTransform(this._element,t,e,0);this.#J.history.push(!1),this.#J.component.select(this._element,this.kind)}#Zs(t){Pe.isEsc(t.code)&&(this.#ui(),this.#J.component.select(this._element,this.kind))}#Vs(t){this.setAlign(this._element,t),this.selectMenu_align.close(),this.#J.component.select(this._element,this.kind),this.#J.history.push(!1)}#js(t){this.convertAsFormat(this._element,t),this.selectMenu_as.close(),this.#J.history.push(!1)}#Gs(t){if("auto"===t)this.deleteTransform(),this._setAutoSize();else{let e=this.getSize(this._element).h;if(this.isVertical){const t=(this._element.getAttribute("data-se-size")||",").split(",");t[1]&&(e=t[1])}this.deleteTransform(),this._setPercentSize(1*t,null!==ze.get(e,0)&&/%$/.test(e)?e:"")}this.selectMenu_resize.close(),this.#J.component.select(this._element,this.kind),this.#J.history.push(!1)}#Xs(){const t=this.#J.frameContext.get("_figure");t.main.style.display="none",this.#J.ui.setFigureContainer(null),this.#J.ui.opendControllers=this.#J.ui.opendControllers.filter((e=>e.form!==t.main))}#Js(){this.selectMenu_align.open("",'[data-command="'+this.align+'"]')}#Qs(){this.selectMenu_as.open("",'[data-command="'+this.as+'"]')}#ti(){const t=this.getSize(this._element),e=t.w,s=t.h;let i="";if(this.autoRatio){if(s===this.autoRatio.default&&/%$/.test(e)){const t=ze.get(e);i=100===t?"auto":"resize_percent"+t}}else"auto"===s&&("auto"===e?i="auto":/%$/.test(e)&&(i="resize_percent"+ze.get(e)));this.selectMenu_resize.open("",'[data-command="'+i+'"]')}}function Fi(t){const e=t.style.transform;return e?{r:Number((e.match(/rotate\(([-0-9]+)deg\)/)||[])[1]||0),x:(e.match(/rotateX\(([-0-9]+)deg\)/)||[])[1]||"",y:(e.match(/rotateY\(([-0-9]+)deg\)/)||[])[1]||""}:{r:0,x:"",y:""}}function Hi(t){return/^(90|270)$/.test(Math.abs(ze.is(t)?t:Fi(t).r).toString())}function qi(t){const e=t.split("_"),s=e[0],i=e[1];let n,o,r,l;switch(s){case"resize":n="onresize",o=i,r="resize",l="resize";break;case"auto":n="auto",r="autoSize",l="auto_size";break;case"rotate":n="rotate",o="l"===i?-90:"r"===i?90:ze.get(i),r=o<0?"rotateLeft":"rotateRight",l=o<0?"rotate_left":"rotate_right";break;case"mirror":n="mirror",o=i,r="h"===i?"mirrorHorizontal":"mirrorVertical",l="h"===i?"mirror_horizontal":"mirror_vertical";break;case"align":n="onalign",r="align",l="align_justify";break;case"caption":n="caption",r="caption",l="caption";break;case"revert":n="revert",r="revert",l="revert";break;case"edit":n="edit",r="edit",l="edit";break;case"as":n="onas",r="blockStyle",l="as_block";break;case"copy":n="copy",r="copy",l="copy";break;case"remove":n="remove",r="remove",l="delete"}return n?{c:n,v:o,l:r,t:undefined,i:l}:null}const Wi=Di,{_w:Ui,ON_OVER_COMPONENT:Vi,isMobile:ji}=Le,Gi=/^Arrow(Left|Up|Right|Down)$/,Ki=/^Arrow(Left|Up)$/;function Yi(t,e,s){t.preventDefault(),t.stopPropagation(),Xi(e),s.setData("text/html",e.outerHTML)}function Xi(t){Re.utils.removeClass(t,"se-component-selected"),Re.utils.removeClass(t.querySelectorAll(".se-figure-selected"),"se-figure-selected"),Re.utils.removeClass(t.querySelectorAll(".se-selected-table-cell"),"se-selected-table-cell"),Re.utils.removeClass(t.querySelector(".se-selected-cell-focus"),"se-selected-cell-focus")}const Zi=class{#H;#J;#t;#gi;#nt;#ot;#X;#mi;#fi;#vi=null;#bi=null;#yi=null;#is=null;constructor(t){this.#H=t,this.#J=t.$,this.#t=t.store,this.#gi=this.#J.contextProvider,this.#nt=this.#gi.carrierWrapper,this.#ot=this.#J.options,this.#X=this.#J.frameContext,this.#mi=this.#J.eventManager,this.info=null,this.isSelected=!1,this.currentTarget=null,this.currentPlugin=null,this.currentPluginName="",this.currentInfo=null,this.#fi={copy:this.#wi.bind(this),cut:this.#Ci.bind(this),keydown:this.#_i.bind(this),mousedown:this.#Oe.bind(this)},this.__selectionSelected=!1,this.__prevent=!1}_init(){this.#gi.applyToRoots((t=>{const e=Re.utils.createElement("DIV",{class:"se-drag-handle",draggable:"true"},this.#gi.icons.selection);t.get("wrapper").appendChild(e),this.#mi.addEvent(e,"mouseenter",this.#ki.bind(this)),this.#mi.addEvent(e,"mouseleave",this.#xi.bind(this)),this.#mi.addEvent(e,"dragstart",this.#$i.bind(this)),this.#mi.addEvent(e,"dragend",this.#Si.bind(this)),this.#mi.addEvent(e,"click",this.#Ei.bind(this))}))}insert(t,{skipCharCount:e=!1,skipHistory:s=!1,scrollTo:i=!0,insertBehavior:n}={}){if(this.#X.get("isReadOnly")||!e&&!this.#J.char.check(t))return null;void 0===n&&(n=this.#ot.get("componentInsertBehavior"));const o=this.#J.html.remove(),r=this.isInline(t);this.#J.selection.getRangeAndAddLine(this.#J.selection.getRange(),o.container);const l=this.#J.selection.getNode();let a=null,h=this.#J.format.getLine(l,null);try{if(Re.check.isListCell(h))this.#J.html.insertNode(t,{afterNode:r?null:Re.check.isZeroWidth(l)?(l||o.container||{}).nextSibling:null,skipCharCount:!0}),r||t.nextSibling||t.parentNode.appendChild(Re.utils.createElement("BR"));else{if(!r&&this.#J.selection.getRange().collapsed&&(3===o.container?.nodeType||Re.check.isBreak(o.container))){const t=Re.query.getParentElement(o.container,this.#J.format.isBlock.bind(this.#J.format));a=this.#J.nodeTransform.split(o.container,o.offset,t?Re.query.getNodeDepth(t)+1:0),a&&(h=a.previousSibling)}this.#J.html.insertNode(t,{afterNode:r||this.#J.format.isBlock(h)?null:h,skipCharCount:!0}),!r&&h&&Re.check.isZeroWidth(h)&&Re.utils.removeItem(h)}if(r){const e=Re.utils.createTextNode(Ae.zeroWidthSpace);t.parentNode.insertBefore(e,t.nextSibling)}}catch(t){console.error("Component insert error:",t)}s||this.#J.history.push(!1),this.#X.has("documentType_use_header")&&this.#X.get("documentType").reHeader();const c=a||t;return i&&this.#J.selection.scrollTo(c,{behavior:"auto"}),null!==n&&this.applyInsertBehavior(t,a,n),c}applyInsertBehavior(t,e,s){const i=this.get(t);if(this.isInline(t)){const e=this.#J.selection.getNearRange(t);e?this.#J.selection.setRange(e.container,e.offset,e.container,e.offset):this.select(i.target,i.pluginName)}else switch(s){case"auto":this.#Ti(t)||this.select(i.target,i.pluginName);break;case"select":this.#J.selection.setRange(t,0,t,0),i?this.select(i.target,i.pluginName):e&&(e=Re.query.getEdgeChildNodes(e,null).sc||e,this.#J.selection.setRange(e,0,e,0));break;case"line":if(!this.#Ti(t)){const e=this.#J.format.addLine(t,null);e&&this.#J.selection.setRange(e,0,e,0)}}}get(t){if(!t)return null;let e,s="",i={},n=!1,o=null;if(this.is(t)){if(Re.check.isComponentContainer(t)&&!Re.utils.hasClass(t,"se-inline-component")&&(t=t.firstElementChild||t),/^FIGURE$/i.test(t.nodeName)&&(t=t.firstElementChild),!t)return null;const n=this.#J.pluginManager.findComponentInfo(t);if(!n)return null;e=n.target,s=n.pluginName,i=n.options,o=n.launcher}if(!e&&t.nodeName){this.#Mi(t)&&(n=!0);const r=this.#J.pluginManager.findComponentInfo(t);if(!r)return null;e=r.target,s=r.pluginName,i=r.options,o=r.launcher}if(!e)return null;const r=Wi.GetContainer(e),l=r.container||r.cover||e;return this.info={target:r.target,pluginName:s,options:i,container:l,cover:r.cover,inlineCover:r.inlineCover,caption:r.caption,isFile:n,launcher:o,isInputType:Re.utils.hasClass(l,"se-input-component")}}select(t,e,{isInput:s=!1}={}){const i=this.get(t);if(!i||Re.check.isUneditable(Re.query.getParentElement(t,this.is.bind(this)))||Re.check.isUneditable(t))return!1;const n=i.launcher||this.#J.plugins[e];if(!n)return;const o=yi.get("__overInfo")!==Vi;if(!s&&o){if(this.#t.get("_mousedown"))return;this.#t.set("_preventBlur",!0),this.__selectionSelected=!0,this.isInline(i.container)&&this.#J.selection.setRange(i.container,0,i.container,0),this.#J.focusManager.blur(),Ui.setTimeout((()=>{this.__selectionSelected=!1}))}let r;this.isSelected=!0,this.__prevent=!0,"function"==typeof n.componentSelect&&(r=n.componentSelect(t));const l=Re.utils.hasClass(i.target,"se-component-line-break");(l||!r&&!Re.utils.hasClass(i.container,"se-inline-component"))&&this._setComponentLineBreaker(i.container||i.cover||t),this.currentTarget=t,this.currentPlugin=n,this.currentPluginName=e,this.currentInfo=i,yi.set("__dragInst",this);const a=yi.get("__overInfo");if(Ui.setTimeout((()=>{yi.set("__overInfo",a===Vi&&void 0),a!==Vi&&this.#De(),i.isFile||this.#Ni(),Re.utils.addClass(i.container,"se-component-selected")}),0),!o||this.#t.get("hasFocus")||this.#t.get("_preventFocus")||(this.#H._eventOrchestrator.__postFocusEvent(this.#X,null),this.#t.set("_preventFocus",!0)),l||a===Vi){if(l||!Re.utils.hasClass(i.container,"se-input-component")){const t=this.#X.get("wrapper").querySelector(".se-drag-handle");Re.utils.addClass(t,"se-drag-handle-full"),this.#J.ui._visibleControllers(!1,!1);const e=i.caption?i.target:i.cover||i.container||i.target,s=e.offsetWidth,n=e.offsetHeight,{top:o,left:r}=this.#J.offset.getLocal(e);t.style.opacity="0",t.style.width=s+"px",t.style.height=n+"px",t.style.top=o+"px",t.style.left=r+"px",yi.set("__dragHandler",t),yi.set("__dragContainer",i.container),yi.set("__dragCover",i.cover),t.style.display="block"}}else{if(!this.isInline(i.container))return;const t=i.container;let e=null;t.previousSibling&&!Re.check.isBreak(t.previousSibling)||(e=Re.utils.createTextNode(Ae.zeroWidthSpace),t.parentNode.insertBefore(e,t)),t.nextSibling&&!Re.check.isBreak(t.nextSibling)||(e=Re.utils.createTextNode(Ae.zeroWidthSpace),t.parentNode.insertBefore(e,t.nextSibling)),this.#t.set("controlActive",!0)}}deselect(){Ui.setTimeout((()=>{this.#t.set("controlActive",!1)}),0),this.__deselect(),this.#J.ui.setControllerOnDisabledButtons(!1),!this.#t.get("_preventFocus")||this.#t.get("hasFocus")||this.__prevent||(this.#H._eventOrchestrator.__postBlurEvent(this.#X,null),this.#t.set("_preventFocus",!1))}is(t){return!!t&&(!(!/^FIGURE$/i.test(t.nodeName)&&!Re.check.isComponentContainer(t))||!!this.#J.pluginManager.findComponentInfo(t))}isInline(t){if(!t)return!1;if(/^FIGURE$/i.test(t.nodeName)&&(t=t.parentElement),Re.utils.hasClass(t,"se-inline-component"))return!0;return!(!this.#J.pluginManager.findComponentInfo(t)||!Re.utils.hasClass(t,"se-inline-component")&&!Re.utils.hasClass(t.parentElement,"se-inline-component"))}isBasic(t){return this.is(t)&&!this.isInline(t)}async copy(t){const e=Re.utils.clone(t,!0);Xi(e),!1!==await this.#J.html.copy(e)&&Re.utils.flashClass(t,"se-copy")}hoverSelect(t){const e=Re.query.getParentElement(t,Re.check.isFigure);let s=this.get(t);s||e?(s||=this.get(e),s&&!Re.utils.hasClass(s.container,"se-component-selected")&&(this.#J.ui.offCurrentController(),yi.set("__overInfo",Vi),this.select(s.target,s.pluginName))):null===yi.get("__overInfo")||Re.utils.hasClass(t,"se-drag-handle")||(this.__deselect(),yi.set("__overInfo",null))}__deselect(){if(this.#t.set("_preventBlur",!1),yi.set("__overInfo",null),this.__removeDragEvent(),this.currentInfo){const t=this.currentInfo.container,e=this.currentInfo.cover;Ui.setTimeout((()=>{Xi(t),Re.utils.removeClass(e,"se-figure-over-selected")}),0)}this.#X.get("lineBreaker_t")&&(this.#X.get("lineBreaker_t").style.display=this.#X.get("lineBreaker_b").style.display="none"),this.currentPlugin&&this.currentPlugin.componentDeselect?.(this.currentTarget),this.isSelected=!1,this.currentPlugin=null,this.currentTarget=null,this.currentPluginName="",this.currentInfo=null,this.__removeGlobalEvent(),this.#J.ui._offControllers()}_setComponentLineBreaker(t){const e=yi.get("__overInfo")===Vi;this.#H._eventOrchestrator._lineBreakComp=null;const s=this.get(t);if(!s)return;const i=this.#X,n=s.container,o=Re.utils.hasClass(n,"se-flex-component"),r=i.get("lineBreaker_t"),l=i.get("lineBreaker_b"),a=r.style,h=l.style,c=n.offsetWidth<t.offsetWidth?n:t,d=this.#J.ui.getVisibleFigure()||c,u=Re.check.isListCell(n.parentNode);let p,g;const m=this.#ot.get("_rtl"),f=m?["right","left"]:["left","right"],{top:v,left:b,right:y,scrollX:w,scrollY:C}=this.#J.offset.getLocal(c),_=m?y:b;if(u?!Re.check.isBreak(n.previousElementSibling)&&!n.previousSibling?.textContent?.trim()||this.is(n.previousElementSibling):!this.#J.format.isLine(n.previousElementSibling)){const t=Ui.getComputedStyle(r),s=ze.get(t.height,1),i=ze.get(t.width,1);this.#H._eventOrchestrator._lineBreakComp=n,p=v,g=d.offsetWidth/2/2,a.top=p-s/2+"px",a[f[0]]=(o?_-i/2:_+g)+"px",a[f[1]]="",r.setAttribute("data-offset",C+","+w),e?Re.utils.removeClass(r,"se-on-selected"):Re.utils.addClass(r,"se-on-selected"),a.display="block",a.visibility=""}else a.display="none";if(u?!Re.check.isBreak(n.nextElementSibling)&&!n.nextSibling?.textContent?.trim()||this.is(n.nextElementSibling):!this.#J.format.isLine(n.nextElementSibling)){const t=Ui.getComputedStyle(l),s=ze.get(t.height,1),i=ze.get(t.width,1);p||(this.#H._eventOrchestrator._lineBreakComp=n,p=v,g=d.offsetWidth/2/2),h.top=p+d.offsetHeight-s/2+"px",h[f[0]]=_+d.offsetWidth-(o?0:g)-(o?i/2:i)+"px",h[f[1]]="",l.setAttribute("data-offset",C+","+f[0]+","+w),e?Re.utils.removeClass(l,"se-on-selected"):Re.utils.addClass(l,"se-on-selected"),h.display="block",h.visibility=""}else h.display="none"}__removeGlobalEvent(){this.#Bi(),this.#vi&&=this.#mi.removeGlobalEvent(this.#vi),this.#bi&&=this.#mi.removeGlobalEvent(this.#bi),this.#yi&&=this.#mi.removeGlobalEvent(this.#yi)}__removeDragEvent(){this.#nt.querySelector(".se-drag-cursor").style.left="-10000px",yi.get("__dragHandler")&&(yi.get("__dragHandler").style.display="none"),Re.utils.removeClass([yi.get("__dragHandler"),yi.get("__dragContainer")],"se-dragging"),Re.utils.removeClass([yi.get("__dragCover"),yi.get("__dragContainer")],"se-drag-over"),yi.set("__figureInst",null),yi.set("__dragInst",null),yi.set("__dragHandler",null),yi.set("__dragContainer",null),yi.set("__dragCover",null),yi.set("__dragMove",null),yi.set("__overInfo",null)}#De(){this.__removeGlobalEvent(),this.#vi=this.#mi.addGlobalEvent("copy",this.#fi.copy),this.#bi=this.#mi.addGlobalEvent("cut",this.#fi.cut),this.#yi=this.#mi.addGlobalEvent("keydown",this.#fi.keydown)}#Ni(){this.#Bi(),this.#is=this.#mi.addGlobalEvent(ji?"click":"mousedown",this.#fi.mousedown,!0)}#Bi(){this.#is&&=this.#mi.removeGlobalEvent(this.#is)}#Ti(t){const e=t.nextElementSibling;if(!e){const e=this.#J.format.addLine(t,null);return e&&this.#J.selection.setRange(e,0,e,0),!0}return!!this.#J.format.isLine(e)&&(this.#J.selection.setRange(e,0,e,0),!0)}#Mi(t){const e=t.nodeName.toLowerCase();return this.#J.pluginManager.fileInfo.regExp.test(e)&&(!this.#J.pluginManager.fileInfo.tagAttrs[e]||this.#J.pluginManager.fileInfo.tagAttrs[e]?.every((e=>t.hasAttribute(e))))}#ki(){this.#t.set("_preventBlur",!0),this.#J.ui._visibleControllers(!1,Re.utils.hasClass(yi.get("__dragHandler"),"se-drag-handle-full")),Re.utils.addClass(yi.get("__dragCover")||yi.get("__dragContainer"),"se-drag-over")}#xi(){this.#t.set("_preventBlur",!1),Re.utils.hasClass(yi.get("__dragHandler"),"se-drag-handle-full")||this.#J.ui._visibleControllers(!0,!0),Re.utils.removeClass([yi.get("__dragCover"),yi.get("__dragContainer")],"se-drag-over")}#$i(t){const e=yi.get("__dragCover")||yi.get("__dragContainer");e?(this.#t.set("_preventBlur",!1),Re.utils.addClass(yi.get("__dragHandler"),"se-dragging"),Re.utils.addClass(yi.get("__dragContainer"),"se-dragging"),t.dataTransfer.setDragImage(e,this.#ot.get("_rtl")?e.offsetWidth:-5,-5)):t.preventDefault()}#Si(){this.#t.set("_preventBlur",!1),Re.utils.removeClass([yi.get("__dragHandler"),yi.get("__dragContainer")],"se-dragging"),this.__removeDragEvent()}#Ei(t){const e=Re.query.getEventTarget(t);if(!Re.utils.hasClass(e,"se-drag-handle-full"))return;const s=yi.get("__dragInst");s&&(this.__removeDragEvent(),this.select(s.currentTarget,s.currentPluginName))}#Oe(t){const e=Re.query.getEventTarget(t);this.currentTarget?.contains(e)||Re.query.getParentElement(e,".se-controller")||Re.utils.hasClass(e,"se-drag-handle")||this.currentPluginName===this.#J.ui.currentControllerName&&this.#J.ui.opendControllers.some((({form:t})=>t.contains(e)))||this.deselect()}#wi(t){const e=Re.query.getEventTarget(t);if(Re.check.isInputElement(e)&&Re.query.getParentElement(e,".se-modal"))return;const s=this.info;if(!s)return;const i=s.container.cloneNode(!0);"function"==typeof this.#J.plugins[s.pluginName]?.componentCopy&&!1!==this.#J.plugins[s.pluginName].componentCopy({event:t,cloneContainer:i,info:s})||Yi(t,i,t.clipboardData),Re.utils.flashClass(s.container,"se-copy")}#Ci(t){const e=this.info;if(!e)return;const s=e.container.cloneNode(!0);Re.utils.removeClass(s,"se-component-selected"),Yi(t,s,t.clipboardData),this.deselect(),Re.utils.removeItem(e.container)}async#_i(t){if(this.#J.ui.selectMenuOn)return;const e=t.code;if(Pe.isCtrl(t)){if("ControlRight"!==e&&"ControlLeft"!==e){const s=this.#J.shortcuts.keyMap.get(e+(t.shiftKey?"1000":""));/^(redo|undo)$/.test(s?.command)&&(t.preventDefault(),t.stopPropagation(),this.#J.commandDispatcher.run(s.command,s.type,s.button))}}else if(!Pe.isRemoveKey(e)||(t.preventDefault(),t.stopPropagation(),"function"!=typeof this.currentPlugin?.componentDestroy||this.info.isInputType&&this.#t.get("hasFocus"))){if(Pe.isEnter(e)){t.preventDefault();const e=this.currentInfo||this.get(this.currentTarget),s=e.container||e.target,i=s.previousElementSibling||s.nextElementSibling;let n=null;n=Re.check.isListCell(s.parentNode)?Re.utils.createElement("BR"):Re.utils.createElement(this.#J.format.isLine(i)?i.nodeName:this.#ot.get("defaultLine"),null,"<br>");const o=this.currentPluginName;return this.deselect(),s.parentNode.insertBefore(n,s),!1===this.select(e.target,o)&&this.#J.focusManager.blur(),void this.#J.history.push(!1)}if(Gi.lastIndex=0,Gi.test(e)){const{container:s}=this.get(this.currentTarget);let i=null,n=1;if(this.isInline(s||this.currentTarget))switch(e){case"ArrowLeft":i=s.previousSibling,n=3===i?.nodeType?i.textContent.length:1;break;case"ArrowRight":i=s.nextSibling,n=0;break;case"ArrowUp":{const t=this.#J.format.getLine(s,null);i=t?.previousElementSibling,n=0;break}case"ArrowDown":{const t=this.#J.format.getLine(s,null);i=t?.nextElementSibling;break}}else Ki.lastIndex=0,Ki.test(e)?i=s.previousElementSibling:(i=s.nextElementSibling,n=0);if(!i)return;this.deselect();const o=this.get(i);if(o?.container)t.stopPropagation(),t.preventDefault(),this.select(o.target,o.pluginName);else try{this.#t.set("_preventBlur",!0),t.stopPropagation(),t.preventDefault(),this.#J.selection.setRange(i,n,i,n)}finally{this.#t.set("_preventBlur",!1)}}else Pe.isEsc(e)&&this.deselect()}else{const t=this.info.container.previousSibling;if(await this.currentPlugin.componentDestroy(this.currentTarget),this.deselect(),t){const e=3===t.nodeType?t.textContent.length:1;this.#J.selection.setRange(t,e,t,e)}else this.#J.focusManager.focus()}}_destroy(){this.__removeGlobalEvent(),this.__removeDragEvent()}};const Ji=class{#H;#J;#Ii;#gi;#ot;#Li;#Ai;#Oi=[];#Ri=[];#zi={tags:null,regExp:null,pluginRegExp:null,pluginMap:null};#Pi=[];#Di=new Map;#Fi=new Map([["onMouseMove",[]],["onMouseLeave",[]],["onMouseDown",[]],["onMouseUp",[]],["onScroll",[]],["onClick",[]],["onBeforeInput",[]],["onInput",[]],["onKeyDown",[]],["onKeyUp",[]],["onFocus",[]],["onBlur",[]],["onPaste",[]],["onFilePasteAndDrop",[]]]);constructor(t,e){this.#H=t,this.#J=t.$,this.#Ii=e.plugins||{},this.#gi=this.#J.contextProvider,this.#ot=this.#J.options,this.#Li=e.pluginCallButtons,this.#Ai=e.pluginCallButtons_sub}get plugins(){return this.#Ii}get fileInfo(){return this.#zi}findComponentInfo(t){for(const e of this.#Pi){const s=e(t);if(s)return s}return null}applyRetainFormat(t){let e;(e=this.#ot.get("__pluginRetainFilter"))&&this.#Di.forEach(((s,i)=>{const n=t.querySelectorAll(i);for(let t=0,i=n.length;t<i;t++)!0!==e&&!1===e[s.key]||s.method(n[t])}))}emitEvent(t,e){const s=this.#Fi.get(t);for(let t,i=0;i<s.length;i++)if(t=s[i](e),"boolean"==typeof t)return t}async emitEventAsync(t,e){const s=this.#Fi.get(t);for(let t,i=0;i<s.length;i++)if(t=await s[i](e),"boolean"==typeof t)return t}checkFileInfo(t){for(let e=0,s=this.#Oi.length;e<s;e++)this.#Oi[e](t)}resetFileInfo(){for(let t=0,e=this.#Ri.length;t<e;t++)this.#Ri[t]()}register(t,e,s){let i=this.#Ii[t];if(!i)throw Error(`[SUNEDITOR.registerPlugin.fail] The called plugin does not exist or is in an invalid format. (pluginName: "${t}")`);if("function"==typeof this.#Ii[t]&&(i=this.#Ii[t]=new this.#Ii[t](this.#H,s||{})),e){const{icons:s,lang:n}=this.#gi;for(let t=0,o=e.length;t<o;t++)ps(e[t],i,s,n);this.#J.commandDispatcher.activeCommands.includes(t)||"function"!=typeof this.#Ii[t].active||this.#J.commandDispatcher.activeCommands.push(t)}}init(t){this.#zi.tags=[],this.#zi.pluginMap={},this.#zi.tagAttrs={};const e=this.#Ii,s=[];let i;for(const n in e){if(this.register(n,this.#Li[n],t[n]),this.register(n,this.#Ai[n],t[n]),i=this.#Ii[n],"object"==typeof i.__fileManagement){const t=i.__fileManagement;if(this.#Oi.push(t._checkInfo.bind(t)),this.#Ri.push(t._resetInfo.bind(t)),Array.isArray(t.tagNames)){const e=t.tagNames;this.#zi.tags=this.#zi.tags.concat(e),s.push(n);for(let s,i=0,o=e.length;i<o;i++)s=e[i].toLowerCase(),this.#zi.pluginMap[s]=n,t.tagAttrs&&(this.#zi.tagAttrs[s]=t.tagAttrs)}}"function"==typeof i.constructor.component&&this.#Pi.push(function(t,e){return e&&(e=t.component?.(e))?{target:e,pluginName:t.key,options:t.options}:null}.bind(null,i.constructor));const e=i.constructor.options||{};if(this.#Fi.forEach(((t,s)=>{if("function"==typeof i[s]){const n=i[s].bind(i);n.index=e[`eventIndex_${s}`]||e.eventIndex||0,t.push(n)}})),i.retainFormat){const t=i.retainFormat();this.#Di.set(t.query,{key:i.constructor.key,method:t.method})}}for(const t of this.#Fi.values())t.sort(((t,e)=>t.index-e.index));(this.#ot.get("buttons").has("pageBreak")||this.#ot.get("buttons_sub")?.has("pageBreak"))&&this.#Pi.push(function(t,e,s){if(!s||!Re.utils.hasClass(s,"se-page-break"))return null;return{target:s,launcher:{componentDestroy:s=>{const i=s.previousElementSibling||s.nextElementSibling;Re.utils.removeItem(s),t.focusEdge(i),e.push(!1)}}}}.bind(null,this.#J.focusManager,this.#J.history)),this.#zi.regExp=new RegExp(`^(${this.#zi.tags.join("|")||"\\^"})$`,"i"),this.#zi.pluginRegExp=new RegExp(`^(${0===s.length?"\\^":s.join("|")})$`,"i"),this.#Li=null,this.#Ai=null}get(t){return this.#Ii[t]}_destroy(){for(const t in this.#Ii){const e=this.#Ii[t];e._destroy?.(),e.editor=null}this.#Ii=null,this.#zi=null,this.#Pi=null,this.#Fi?.clear(),this.#Di?.clear()}};class Qi{#H;#J;#t;#ot;#X;#Q;constructor(t){this.#H=t,this.#J=t.$,this.#t=t.store,this.#ot=this.#J.options,this.#X=this.#J.frameContext,this.#Q=this.#J.frameOptions}focus(t){if(t&&this.#J.facade.changeFrameContext(t),"none"!==this.#X.get("wysiwygFrame").style.display){if(this.#t.set("_preventBlur",!1),this.#Q.get("iframe")||!this.#X.get("wysiwyg").contains(this.#J.selection.getNode()))this.nativeFocus();else try{const t=this.#J.selection.getRange();if(t.startContainer===t.endContainer&&Re.check.isWysiwygFrame(t.startContainer)){const e=t.commonAncestorContainer.children[t.startOffset];if(!this.#J.format.isLine(e)&&!this.#J.component.is(e)){const t=Re.utils.createElement("BR"),s=Re.utils.createElement(this.#ot.get("defaultLine"),null,t);return this.#X.get("wysiwyg").insertBefore(s,e),void this.#J.selection.setRange(t,0,t,0)}}this.#J.selection.setRange(t.startContainer,t.startOffset,t.endContainer,t.endOffset)}catch(t){console.warn("[SUNEDITOR.focus.warn] ",t),this.nativeFocus()}this.#t.mode.isBalloon&&this.#H._eventOrchestrator._toggleToolbarBalloon()}}focusEdge(t){this.#t.set("_preventBlur",!1),t||=this.#X.get("wysiwyg").lastElementChild;const e=this.#J.component.get(t);e?this.#J.component.select(e.target,e.pluginName):t?(3!==t.nodeType&&(t=Re.query.getEdgeChild(t,(function(t){return 0===t.childNodes.length||3===t.nodeType}),!0)),t?this.#J.selection.setRange(t,t.textContent.length,t,t.textContent.length):this.nativeFocus()):this.focus()}nativeFocus(){this.#J.selection.__focus(),this.#J.selection.init()}blur(){this.#Q.get("iframe")?this.#X.get("wysiwygFrame").blur():this.#X.get("wysiwyg").blur()}}const tn=/^H[1-6]$/,en=/^(UL|OL)$/,sn=/^LI$/,nn=/^(THEAD|TBODY|TR|TD|TH)$/;function on(t){let e=t;for(;e&&!tt(e);){if("TABLE"===e.nodeName)return e;e=e.parentNode}return null}function rn(t){let e=t;for(;e&&!tt(e);){if(1===e.nodeType&&Q(e))return!0;e=e.parentNode}return!1}function ln(t,e){const s=t.querySelector(":scope > ul, :scope > ol");if(!s)return null;if(e<s.getBoundingClientRect().top)return null;const i=s.children;let n=null,o=1/0;for(let t=0;t<i.length;t++){const s=i[t];if(!sn.test(s.nodeName))continue;const r=s.getBoundingClientRect();if(e>=r.top&&e<=r.bottom)return ln(s,e)||s;const l=Math.min(Math.abs(e-r.top),Math.abs(e-r.bottom));l<o&&(o=l,n=s)}return n}function an(t,e,s,i){if(!t||!s)return null;if(3===t.nodeType&&!(t=t.parentNode))return null;if(tt(t))return null;if(rn(t))return null;let n=null;if(nn.test(t.nodeName))n=on(t);else if(en.test(t.nodeName))n=t;else if(sn.test(t.nodeName))n=t;else if(X(t.parentNode))n=on(t);else{const s=e.getLine(t,null);if(s&&(n=s),!n){const s=e.getBlock(t,null);s&&(n=nn.test(s.nodeName)?on(s):s)}}if(!n){let e=t;for(;e&&!tt(e);){if(1===e.nodeType&&e.parentNode&&tt(e.parentNode)){n=e;break}e=e.parentNode}}if(!n)return null;if(rn(n))return null;if(void 0!==i)if(en.test(n.nodeName)){const t=function(t,e){const s=t.children;let i=null,n=1/0;for(let t=0;t<s.length;t++){const o=s[t];if(!sn.test(o.nodeName))continue;const r=o.getBoundingClientRect();if(e>=r.top&&e<=r.bottom)return ln(o,e)||o;const l=Math.min(Math.abs(e-r.top),Math.abs(e-r.bottom));l<n&&(n=l,i=o)}return i}(n,i);t&&(n=t)}else if(sn.test(n.nodeName)){const t=ln(n,i);t&&(n=t)}const{depth:o,parent:r}=function(t,e){let s=0,i=null,n=t.parentNode;for(;n&&!tt(n);)1===n.nodeType&&(e.isBlock(n)||e.isLine(n))&&(i||(i=n),s++),n=n.parentNode;return{depth:s,parent:i}}(n,e),l={prev:(a=n).previousElementSibling,next:a.nextElementSibling};var a;return{element:n,type:function(t){const e=t.nodeName;return"P"===e||"DIV"===e?"p":tn.test(e)?"heading":"LI"===e?"list-item":en.test(e)?"list":"BLOCKQUOTE"===e?"blockquote":"PRE"===e?"pre":"FIGURE"===e?"figure":"TABLE"===e?"table":"p"}(n),depth:o,parent:r,siblings:l,rect:n.getBoundingClientRect()}}const{_w:hn}=Le;const cn=class{#J;#Hi;#qi;#Wi=null;#Ui;#Vi=new Map;#ji=null;#Gi=[];#Ki=[];selectMenu;constructor(t,e,s){this.#J=e,this.#Hi=s.resolveButton,this.#qi=Array.isArray(s.items)?s.items:[],this.#Ui="function"==typeof s.renderCustomItem?s.renderCustomItem:null;const i=s.selectMenuParams?.closeMethod;this.selectMenu=new Bi(e,{...s.selectMenuParams,closeMethod:()=>{this.#Yi(),this.#Xi(),i?.()},subEscMethod:()=>{if(!this.#ji)return!1;const t=this.#ji.anchorLi;this.#Yi();const e=t?Number(t.getAttribute("data-index")):NaN;return Number.isNaN(e)||this.selectMenu.setItem(e),!0}})}attach(t,e,s={}){this.selectMenu.on(t,e,s),this.#J.eventManager.addEvent(this.selectMenu.form,"mousedown",(t=>{Le.isMobile?this.#J.store.set("_preventBlur",!0):t.preventDefault()})),this.#J.eventManager.addEvent(this.selectMenu.form,"mousemove",this.#Zi.bind(this))}setItems(t){this.#qi=Array.isArray(t)?t:[],this.#Wi=null}getItems(){if(this.#Wi)return this.#Wi;const t=[];for(const i of this.#qi)if("string"==typeof i){const e=this.#Hi(i,this.#J.plugins,this.#J.options,this.#J.icons,this.#J.lang);if(!e)continue;const s=e.type||"";if(/dropdown-free/.test(s)){t.push({kind:"dropdownFree",title:e.title,iconHTML:e.icon||"",search:(e.title+" "+i).toLowerCase(),name:i,type:s});continue}if(/dropdown/.test(s)){const s=this.#J.menu?.itemsMap?.[i]||[];if(s.length>0){t.push({kind:"submenu",title:e.title,iconHTML:e.icon||"",search:(e.title+" "+i).toLowerCase(),name:i,children:s.map((t=>({pluginName:i,element:t._element}))),childMenus:s.map((t=>{const e=t._element?.querySelector(".se-list-icon")||t._element?.querySelector("svg"),s=e?e.outerHTML:"";return`<span class="se-block-submenu-item">${s?`${s}<span>${t.title}</span>`:t.title}</span>`}))});continue}}t.push({kind:"plugin",title:e.title,iconHTML:e.icon||"",search:(e.title+" "+i).toLowerCase(),name:i,type:s,command:e.command})}else if(i&&"object"==typeof i&&"function"==typeof i.action){const n=i.title||i.key||"",o=Array.isArray(i.keywords)?i.keywords.join(" "):"";t.push({kind:"custom",title:n,iconHTML:(e=i.icon,s=this.#J.icons,e&&"string"==typeof e?"<"===e.charAt(0)?e:s[e]||"":""),search:(n+" "+o).toLowerCase(),raw:i})}var e,s;return this.#Wi=t,t}filter(t,e=1/0){const s=this.getItems(),i=(t||"").toLowerCase().trim(),n=[];for(const t of s)if(i&&-1===t.search.indexOf(i)||n.push(t),n.length>=e)break;return n}renderRows(t){const e={icons:this.#J.icons},s=`<span class="se-submenu-arrow">${this.#J.icons.menu_arrow_right}</span>`;return t.map((t=>{if("custom"===t.kind&&this.#Ui)return this.#Ui(t.raw,e);const i=(n=t.title,`<button type="button" class="se-cmd-row">${(o=t.iconHTML)?`<span class="se-block-menu-icon">${o}</span><span class="se-block-menu-label">${n}</span>`:`<span class="se-block-menu-label se-block-menu-label-full">${n}</span>`}</button>`);var n,o;return"dropdownFree"===t.kind?i+s:i}))}createRows(t){this.#Xi();const e=t.map((t=>"submenu"===t.kind?{children:t.children,childMenus:t.childMenus}:t));this.selectMenu.create(e,this.renderRows(t)),this.#Vi.clear(),this.#Gi.length=0,t.forEach(((t,e)=>{"dropdownFree"===t.kind&&this.#Vi.set(e,{name:t.name,plugin:this.#J.plugins[t.name],li:this.selectMenu.menus[e]}),"plugin"!==t.kind&&"dropdownFree"!==t.kind||this.#Gi.push({name:t.name,idx:e})})),this.selectMenu.isOpen&&this.#Ji()}open(t){this.selectMenu.open(t),0===this.#Ki.length&&this.#Ji()}close(){this.#Xi(),this.selectMenu.close()}hasOpenSubPanel(){return this.selectMenu.hasOpenSubmenu()||!!this.#ji}#Ji(){const t=this.#J.commandDispatcher;for(const{name:e,idx:s}of this.#Gi){const i=this.#Qi(s);i&&(t.registerTargets(e,i),this.#Ki.push({name:e,target:i}))}this.#J.store.set("_lastSelectionNode",null),this.#J.eventManager.applyTagEffect()}#Xi(){if(0===this.#Ki.length)return;const t=this.#J.commandDispatcher;for(const{name:e,target:s}of this.#Ki)t.unregisterTargets(e,s);this.#Ki.length=0}#Qi(t){const e=this.selectMenu.menus[t];return e?e.querySelector("button.se-cmd-row")||e:null}setItem(t){this.selectMenu.setItem(t)}setHidden(t){this.selectMenu.setHidden(t)}get isOpen(){return this.selectMenu.isOpen}dispatch(t,e){if(!t)return!1;const s=t;if(s.pluginName&&s.element){const t=this.#J.plugins[s.pluginName];return t?.action?.(s.element),this.#J.history.push(!1),!0}const i=t;if("custom"===i.kind){try{i.raw.action(this.#J,e)}catch(t){console.error("[SUNEDITOR.commandMenu.customAction]",t)}return!1}if("dropdownFree"===i.kind){const t=this.#J.plugins[i.name];if(!t)return!1;if(this.#ji?.plugin===t)return this.#Yi(),!1;const e=this.selectMenu.items.indexOf(i),s=e>=0?this.selectMenu.menus[e]:null;return s&&this.#tn(i.name,t,s),!1}const n=i.name?this.#J.plugins[i.name]:null;if(n){const t=i.type||"";return/modal/.test(t)?n.open?.():/browser/.test(t)?n.open?.(null):/popup/.test(t)?n.show?.():n.action?.(Re.utils.createElement("BUTTON",{type:"button","data-command":i.name})),this.#J.history.push(!1),!0}return i.command&&this.#J.commandDispatcher.run(i.command,null,null),!1}#Zi(t){if(0===this.#Vi.size)return;const e=t.target;if(this.#ji?.dropdown?.contains(e))return;const s=e.closest?.("li[data-index]");if(!s)return;const i=Number(s.getAttribute("data-index")),n=this.#Vi.get(i);n?this.#ji?.plugin!==n.plugin&&this.#tn(n.name,n.plugin,n.li):this.#ji&&this.#Yi()}#tn(t,e,s){this.#ji&&this.#Yi();const i=this.#J.menu?.targetMap?.[t];if(!i||!this.selectMenu.form)return;const n=i.parentNode;this.selectMenu.form.appendChild(i),this.#en(i,s,this.selectMenu.form),Re.utils.addClass(s,"se-submenu-open"),e.on?.(s);const o=this.#J.menu.subscribeDropdownOff((()=>{this.#Yi(),this.selectMenu.close()}));this.#ji={dropdown:i,plugin:e,originalParent:n,anchorLi:s,unsub:o}}#Yi(){const t=this.#ji;t&&(this.#ji=null,t.unsub?.(),t.dropdown.style.cssText="",t.dropdown.style.display="none",t.anchorLi&&Re.utils.removeClass(t.anchorLi,"se-submenu-open"),t.originalParent&&t.originalParent!==t.dropdown.parentNode&&t.originalParent.appendChild(t.dropdown),t.plugin?.off?.())}#en(t,e,s){const i=e.getBoundingClientRect(),n=s.getBoundingClientRect(),o=!!this.#J.options.get("_rtl");t.style.position="absolute",t.style.right="",t.style.visibility="hidden",t.style.display="block";const r=t.offsetWidth,l=t.offsetHeight,a=hn.innerWidth,h=hn.innerHeight,c=i.right+4,d=i.left-r-4,u=Math.max(0,c+r-a),p=Math.max(0,-d);let g;g="right"===(o?"left":"right")?0===u?c:0===p?d:u<=p?c-u:d+p:0===p?d:0===u?c:p<=u?d+p:c-u,t.style.left=g-n.left+"px";const m=i.top,f=i.bottom-l,v=Math.max(0,m+l-h),b=Math.max(0,-f);let y;y=0===v?m:0===b?f:v<=b?m-v:f+b,t.style.top=y-n.top+"px",t.style.visibility=""}},{_w:dn,_d:un}=Le;const pn=class{#J;#sn;#in;#nn;#on;#rn;#ln=null;#an=null;#hn=null;#cn=null;#dn=void 0;#un=null;#pn=[];#gn=!1;#mn=null;#fn=null;#vn=null;#bn=null;#yn=null;constructor(t,e,s,i,n,o){this.#J=t,this.#sn=e,this.#in=s,this.#nn=i,this.#on=n,this.#rn=o||null,this.#J.contextProvider.carrierWrapper.appendChild(this.#in);const r=this.#J.eventManager;r.addEvent(this.#in,"mousedown",this.#wn.bind(this)),this.#mn=Re.utils.createElement("DIV",{class:"se-block-drag-indicator"}),this.#mn.style.display="none",this.#sn.parentElement?.appendChild(this.#mn),r.addEvent(this.#nn,"click",this.#Cn.bind(this)),this.#on.draggable=!0,r.addEvent(this.#on,"dragstart",this.#_n.bind(this)),r.addEvent(this.#on,"dragend",this.#kn.bind(this)),r.addEvent(this.#on,"click",this.#xn.bind(this)),r.addEvent(this.#sn,"mousemove",this.#$n.bind(this)),r.addEvent(this.#sn,"mouseleave",this.#Sn.bind(this));const l=this.#sn.parentElement;l&&(r.addEvent(l,"mouseleave",this.#En.bind(this)),r.addEvent(l,"dragover",this.#Tn.bind(this)),r.addEvent(l,"drop",this.#Mn.bind(this))),r.addEvent(this.#J.frameContext.get("eventWysiwyg"),"keydown",this.#Nn.bind(this),!0)}#Bn(){this.#in.style.display="flex";try{this.#in.showPopover?.()}catch{}}#In(){try{this.#in.hidePopover?.()}catch{}this.#in.style.display="none"}positionForTarget(t,e){this.#Ln(),this.#ln?.isOpen||this.#gn||(this.#cn=t,this.#dn=e,this.#hn||(this.#hn=dn.requestAnimationFrame((()=>{this.#hn=null,this.#cn&&this.#An(this.#cn,this.#dn)}))))}hide(t){if(this.#ln?.isOpen)return;const e=t?.relatedTarget;e&&(this.#sn.contains(e)||this.#in?.contains(e))||this.#On()}hideNow(){this.#Ln(),this.#In(),this.#ln?.close(),this.#Rn(null)}syncScroll(){this.#an&&(Re.utils.addClass(this.#in,"se-no-transition"),this.#zn(this.#an),this.#in.offsetHeight,Re.utils.removeClass(this.#in,"se-no-transition"),this.#ln?.isOpen&&this.#ln.setHidden("none"===this.#in.style.display))}destroy(){this.#hn&&(dn.cancelAnimationFrame(this.#hn),this.#hn=null),this.#gn=!1,this.#Ln(),this.#on&&(this.#on.draggable=!1),this.#mn?.remove(),this.#in?.remove(),this.#ln?.close(),this.#ln=null,this.#Rn(null),this.#cn=null,this.#dn=void 0,this.#J=null,this.#sn=null,this.#in=null,this.#nn=null,this.#on=null}#Rn(t){if(this.#Pn(),this.#an=t,!t)return;const e=this.#Dn(t);if(e){this.#pn=e;for(let t=0;t<e.length;t++)Re.utils.addClass(e[t],"se-block-hover")}else Re.utils.addClass(t,"se-block-hover")}#Dn(t){try{const e=this.#J.selection.getRange();if(!e||e.collapsed)return null;const s=this.#J.format.getLine(e.startContainer,null),i=this.#J.format.getLine(e.endContainer,null);if(!s||!i||s===i)return null;const n=Re.query.getListChildren(e.commonAncestorContainer,(t=>this.#J.format.isLine(t)),null),o=n.indexOf(s),r=n.indexOf(i);if(-1===o||-1===r)return null;const l=n.slice(Math.min(o,r),Math.max(o,r)+1);return-1===l.indexOf(t)?null:l}catch{}return null}#Fn(t){this.#Pn(),this.#pn=t||[];for(let t=0;t<this.#pn.length;t++)Re.utils.addClass(this.#pn[t],"se-block-hover")}#Pn(){this.#an&&Re.utils.removeClass(this.#an,"se-block-hover");for(let t=0;t<this.#pn.length;t++)Re.utils.removeClass(this.#pn[t],"se-block-hover");this.#pn=[]}#On(){this.#un||(this.#un=dn.setTimeout((()=>{this.#un=null,this.#In(),this.#ln?.close(),this.#Rn(null)}),200))}#Ln(){this.#un&&(dn.clearTimeout(this.#un),this.#un=null)}#$n(t){if(!this.#J)return;if(this.#gn)return;if(this.#Ln(),this.#ln?.isOpen)return;const e=this.#J.frameContext.get("wysiwyg");if(!e)return;const s=this.#J.frameContext.get("wysiwygFrame");let i;if(s&&"IFRAME"===s.nodeName){const e=s.getBoundingClientRect(),n=s.contentDocument;n&&(i=n.elementFromPoint(e.width/2,t.clientY-e.top))}else{const s=e.getBoundingClientRect();i=document.elementFromPoint(s.left+s.width/2,t.clientY)}i&&e.contains(i)&&this.#An(i,t.clientY)}#Sn(t){this.#ln?.isOpen||this.#Hn(t?.relatedTarget)||this.hideNow()}#En(t){this.#ln?.isOpen||this.#Hn(t?.relatedTarget)||this.hideNow()}#Hn(t){if(!t)return!1;const e=this.#sn?.parentElement;return!(!this.#in?.contains(t)&&!e?.contains(t))}#An(t,e){if(!this.#J)return;const s=this.#J.format,i=this.#J.frameContext.get("wysiwyg");if(!i)return;let n=t;if(n===i&&void 0!==e){const t=i.getBoundingClientRect(),s=document.elementFromPoint(t.left+t.width/2,e);s&&i.contains(s)&&s!==i&&(n=s)}const o=an(n,{getLine:(t,e)=>s.getLine(t,e),getBlock:(t,e)=>s.getBlock(t,e),isLine:t=>s.isLine(t),isBlock:t=>s.isBlock(t)},i,e);if(o){if(o.element!==this.#an||"flex"!==this.#in.style.display){if(this.#an?.isConnected&&"flex"===this.#in.style.display&&void 0!==e&&!this.#an.contains(o.element)){const t=this.#an.getBoundingClientRect();if(e>=t.top&&e<=t.bottom)return}this.#Rn(o.element),this.#zn(o.element)}}else this.#On()}#zn(t){if(!t.isConnected)return void this.hideNow();const e=t.getBoundingClientRect(),s=this.#sn.getBoundingClientRect(),i=this.#J.frameContext.get("wysiwygFrame"),n=/^iframe$/i.test(i.nodeName),o=n?i.getBoundingClientRect():null;if(n){const t=i.clientHeight||0;if(e.bottom<=0||e.top>=t)return void this.#In()}else{const t=i.getBoundingClientRect();if(e.bottom<=t.top||e.top>=t.bottom)return void this.#In()}const r=dn.scrollX,l=dn.scrollY,a="flex"!==this.#in.style.display;a&&(Re.utils.addClass(this.#in,"se-no-transition"),this.#in.style.display="flex");const h=this.#in.offsetHeight||0,c=this.#qn(t,e),d=(n?c+o.top:c)+l-h/2,u=!!this.#J.options.get("_rtl"),p=this.#Wn(t,u);let g=0;if(this.#J.frameOptions.get("innerWidth")){const t=this.#J.frameContext.get("wysiwyg");if(t){const e=dn.getComputedStyle(t),s=ze.get(u?e.paddingRight:e.paddingLeft,-1)||0,i=function(t,e){const s=(t||"").trim(),i=ze.get(s,-1);return i?/rem$/.test(s)?i*(ze.get(dn.getComputedStyle(un.documentElement).fontSize,-1)||16):/em$/.test(s)?i*(ze.get(e.fontSize,-1)||16):i:0}(e.getPropertyValue("--se-edit-inner-padding"),e);g=Math.max(0,s-i)}}const m=p+g;this.#in.style.top=d+"px",u?(this.#in.style.left="",this.#in.style.right=dn.innerWidth-s.right-r+m+"px"):(this.#in.style.right="",this.#in.style.left=s.left+r+m+"px"),this.#Bn(),a&&(this.#in.offsetHeight,Re.utils.removeClass(this.#in,"se-no-transition"))}#qn(t,e){try{const e=t.ownerDocument,s=e.createTreeWalker(t,NodeFilter.SHOW_TEXT,null);let i=null;for(;(i=s.nextNode())&&!i.textContent?.trim(););if(i){const t=e.createRange();t.setStart(i,0),t.setEnd(i,Math.min(1,i.length));const s=t.getClientRects();if(s.length)return(s[0].top+s[0].bottom)/2}}catch{}const s=ze.get(dn.getComputedStyle(t).lineHeight,-1)||e.height;return e.top+Math.min(s,e.height)/2}#Wn(t,e){const s=this.#J.frameContext.get("wysiwyg");if(!s)return 0;const i=this.#J.format,n=e?"marginRight":"marginLeft",o=e?"paddingRight":"paddingLeft";let r=0;r+=ze.get(dn.getComputedStyle(t)[n],-1)||0;let l=t.parentElement;for(;l&&l!==s;){if(i.isBlock(l)){const t=dn.getComputedStyle(l);r+=(ze.get(t[o],-1)||0)+(ze.get(t[n],-1)||0)}l=l.parentElement}return r}#Un(){if(!this.#an)return;const t=this.#an,e=this.#Dn(t),s=e?e[0]:t,i=e?e[e.length-1]:t;this.#J.selection.setRange(s,0,i,i.childNodes.length)}#Cn(t){if(t.preventDefault(),t.stopPropagation(),!this.#an)return;const e=this.#J.format.addLineAfter(this.#an);e&&(this.#J.selection.setRange(e,1,e,1),this.#J.history.push(!1))}#wn(t){const e=this.#on&&(t.target===this.#on||this.#on.contains(t.target));Le.isMobile?this.#J.store.set("_preventBlur",!0):e||t.preventDefault()}#Nn(){this.#Pn()}#_n(t){if(!this.#an)return void t.preventDefault();this.#fn=this.#an,this.#gn=!0,this.#ln?.close(),Re.utils.addClass(this.#fn,"se-block-dragging");const e=this.#J.frameContext.get("wysiwyg");this.#bn=e||null,this.#yn=e?Array.from(e.children):null;const s=!!this.#J.options.get("_rtl"),i=this.#fn;t.dataTransfer.setDragImage(i,s?i.offsetWidth:-5,-5),t.dataTransfer.effectAllowed="move",t.dataTransfer.setData("application/x-suneditor-block-drag","1")}#Tn(t){this.#gn&&(t.preventDefault(),t.stopPropagation(),t.dataTransfer.dropEffect="move",this.#Vn(t.clientY))}#Mn(t){this.#gn&&(t.preventDefault(),t.stopPropagation(),this.#jn())}#kn(){if(this.#fn&&Re.utils.removeClass(this.#fn,"se-block-dragging"),this.#mn.style.display="none",this.#gn=!1,this.#fn=null,this.#vn=null,this.#bn=null,this.#yn=null,this.#on?.parentNode){const t=this.#on.parentNode,e=this.#on.nextSibling;t.removeChild(this.#on),t.insertBefore(this.#on,e)}}#Vn(t){if(!this.#J||!this.#fn)return;const e=this.#bn,s=this.#yn;if(!e||!s)return;const i=e.getBoundingClientRect(),n=this.#sn.parentElement.getBoundingClientRect();let o=null,r="after",l=0,a=1/0;for(let e=0;e<s.length;e++){const i=s[e],n=i.getBoundingClientRect(),h=Math.abs(t-n.top);h<a&&(a=h,o=i,r="before",l=n.top);const c=Math.abs(t-n.bottom);c<a&&(a=c,o=i,r="after",l=n.bottom)}if(o&&o!==this.#fn){this.#vn={element:o,position:r};const t=this.#mn;t.style.display="block",t.style.top=l-n.top+"px",t.style.left=i.left-n.left+"px",t.style.width=i.width+"px"}else this.#vn=null,this.#mn.style.display="none"}#jn(){const t=this.#fn,e=this.#vn;if(!t||!e||e.element===t)return;t.parentNode&&("before"===e.position?e.element.parentNode.insertBefore(t,e.element):e.element.parentNode.insertBefore(t,e.element.nextSibling),this.#Rn(t),this.#zn(t),this.#J.history.push(!1))}#xn(t){if(t.preventDefault(),t.stopPropagation(),!this.#gn&&this.#rn)if(this.#ln||(this.#ln=this.#Gn()),this.#ln.isOpen)this.#ln.close();else{this.#Un();const t=this.#J.format.getLines(null);t.length>0&&this.#Fn(t);const e=this.#J.offset.getGlobal(this.#on),s=Re.utils.getClientSize().h-(e.top-dn.scrollY+e.height),i=e.top-dn.scrollY,n=`${this.#J.options.get("_rtl")?"left":"right"}-${s>=i?"bottom":"top"}`;this.#ln.open(n)}}#Gn(){const t=new cn(this,this.#J,{items:this.#rn,resolveButton:hs,selectMenuParams:{position:"right-top",dir:this.#J.options.get("_rtl")?"rtl":"ltr",minWidth:"200px",keydownTarget:dn,closeMethod:()=>{Re.utils.removeClass(this.#on,"on"),this.#Pn()},openMethod:()=>{Re.utils.addClass(this.#on,"on")}}});return t.attach(this.#on,this.#Kn.bind(this),{class:"se-block-action-menu"}),t.createRows(t.getItems()),t}#Kn(t){this.#an&&this.#J&&t&&(this.#ln?.dispatch(t,{block:this.#an}),"dropdownFree"!==t.kind&&this.#ln?.close())}},{NO_EVENT:gn}=Le,mn={bold:["font-weight"],underline:["text-decoration"],italic:["font-style"],strike:["text-decoration"]};class fn{#H;#J;#t;#X;#ot;#mi;#Yn=null;#Xn=null;#Zn=null;#Jn=null;constructor(t){this.#H=t,this.#J=t.$,this.#t=t.store,this.#X=this.#J.frameContext,this.#ot=this.#J.options,this.#mi=this.#J.eventManager}async execute(t,e){if(!this.#X.get("isReadOnly")||/copy|cut|selectAll|selectAll_full|codeView|markdownView|fullScreen|print|preview|showBlocks|finder/.test(t))switch(t){case"selectAll":this.#Qn();break;case"selectAll_full":this.#to();break;case"copy":{const t=this.#J.selection.getRange();if(t.collapsed)break;const e=Re.utils.createElement("div",null,t.cloneContents());await this.#J.html.copy(e.innerHTML);break}case"newDocument":this.#J.html.set(`<${this.#ot.get("defaultLine")}><br></${this.#ot.get("defaultLine")}>`),this.#J.focusManager.focus(),this.#J.history.push(!1),this.#X.has("documentType_use_header")&&this.#X.get("documentType").reHeader();break;case"finder":this.#J.finder.isOpen?this.#J.finder.close():this.#J.finder.open(!0);break;case"codeView":this.#J.viewer.codeView(!this.#X.get("isCodeView"));break;case"markdownView":this.#J.viewer.markdownView(!this.#X.get("isMarkdownView"));break;case"fullScreen":this.#J.viewer.fullScreen(!this.#X.get("isFullScreen"));break;case"indent":this.#J.format.indent();break;case"outdent":this.#J.format.outdent();break;case"undo":this.#J.history.undo();break;case"redo":this.#J.history.redo();break;case"removeFormat":this.#J.inline.remove(),this.#J.focusManager.focus();break;case"print":this.#J.viewer.print();break;case"preview":this.#J.viewer.preview();break;case"showBlocks":this.#J.viewer.showBlocks(!this.#X.get("isShowBlocks"));break;case"dir":this.#J.ui.setDir(this.#ot.get("_rtl")?"ltr":"rtl");break;case"dir_ltr":this.#J.ui.setDir("ltr");break;case"dir_rtl":this.#J.ui.setDir("rtl");break;case"save":await this.#eo();break;case"copyFormat":this.#so(e);break;case"pageBreak":this.#io();break;case"pageUp":this.#X.get("documentType").pageUp();break;case"pageDown":this.#X.get("documentType").pageDown();break;default:this.#no(t)}}copyFormat(){if(this.#Zn?.length)try{const t=[...this.#Zn],e=t.pop();if(this.#J.inline.remove(),e){const s=this.#J.inline.apply(e,{stylesToModify:null,nodesToRemove:[e.nodeName],strictRemove:!1}),{parent:i,inner:n}=this.#J.nodeTransform.createNestedNode(t);s.parentNode.insertBefore(i,s),n.appendChild(s),this.#J.selection.setRange(s,Re.check.isZeroWidth(s)?1:0,s,1)}if(this.#ot.get("copyFormatKeepOn"))return;this.#Jn()}catch(t){console.warn("[SUNEDITOR.copyFormat.error] ",t),this.#Jn?.()||(this.#Zn=null,this.#Jn=null)}}#Qn(){this.#J.ui.offCurrentController(),this.#J.menu.containerOff();const t=this.#X.get("wysiwyg");let e=null,s="";const i=this.#ot.get("scopeSelectionTags"),n=this.#J.selection.getRange();if(!n.collapsed){let o=e=n.commonAncestorContainer,r=s=o.nodeName?.toLowerCase();if(0===n.startOffset&&n.endOffset===n.endContainer.textContent?.length){const t=o.parentElement;(Re.check.isList(t)||Re.check.isListCell(t))&&t.firstChild.contains?.(n.startContainer)&&t.lastChild?.contains(n.endContainer)&&(e=o=t.parentElement,s=o.nodeName?.toLowerCase())}for(r=o.nodeName?.toLowerCase();o&&(!o.nextSibling&&!o.previousSibling&&!i.includes(r)||Re.check.isContentLess(r))&&o!==t;)o=o.parentElement,r=o.nodeName?.toLowerCase();i.includes(r)&&(e=o,s=r)}const o=i.filter((t=>t!==s));let r=Re.query.getParentElement(e||this.#J.selection.getNode(),(t=>o.includes(t.nodeName?.toLowerCase())))||t,{first:l,last:a}=vn(r);if(!l||!a)return;const h=Re.check.isZeroWidth;for(;h(l)&&h(a)&&r!==t;)r=r.parentElement,({first:l,last:a}=vn(Re.query.getParentElement(r,(t=>o.includes(t.nodeName?.toLowerCase())))||t));if(!l||!a)return;let c=null;if(Re.check.isMedia(l)||(c=this.#J.component.get(l))||Re.check.isTableElements(l)){c||=this.#J.component.get(l);const t=Re.utils.createElement("BR"),e=Re.utils.createElement(this.#ot.get("defaultLine"),null,t);l=c?c.container||c.cover:l,l.parentElement.insertBefore(e,l),l=t}if(Re.check.isMedia(a)||(c=this.#J.component.get(a))||Re.check.isTableElements(a)){c||=this.#J.component.get(a);const t=Re.utils.createElement("BR"),e=Re.utils.createElement(this.#ot.get("defaultLine"),null,t);a=c?c.container||c.cover:a,a.parentElement.appendChild(e),a=t}this.#J.toolbar._showBalloon(this.#J.selection.setRange(l,0,a,a.textContent.length))}#to(){this.#J.ui.offCurrentController(),this.#J.menu.containerOff();const t=this.#X.get("wysiwyg");let{first:e,last:s}=vn(t);if(!e||!s)return;let i=null;if(Re.check.isMedia(e)||(i=this.#J.component.get(e))||Re.check.isTableElements(e)){i||=this.#J.component.get(e);const t=Re.utils.createElement("BR"),s=Re.utils.createElement(this.#ot.get("defaultLine"),null,t);e=i?i.container||i.cover:e,e.parentElement.insertBefore(s,e),e=t}if(Re.check.isMedia(s)||(i=this.#J.component.get(s))||Re.check.isTableElements(s)){i||=this.#J.component.get(s);const t=Re.utils.createElement("BR"),e=Re.utils.createElement(this.#ot.get("defaultLine"),null,t);s=i?i.container||i.cover:s,s.parentElement.appendChild(e),s=t}this.#J.toolbar._showBalloon(this.#J.selection.setRange(e,0,s,s.textContent.length))}async#eo(){const t=this.#X;if(!t.get("isChanged"))return;const e=this.#J.html.get(),s=await this.#mi.triggerEvent("onSave",{frameContext:t,data:e});if(s===gn){const s=t.get("originElement");/^TEXTAREA$/i.test(s.nodeName)?s.value=e:s.innerHTML=e}else if(!1===s)return;t.set("isChanged",!1),t.set("savedIndex",this.#J.history.getRootStack()[this.#t.get("rootKey")].index),this.#J.commandDispatcher.applyTargets("save",(t=>{t.disabled=!0}))}#so(t){if("function"==typeof this.#Jn)return void this.#Jn();const e=this.#X.get("wysiwyg");this.#Zn=[...this.#H._eventOrchestrator.__cacheStyleNodes],this.#Jn=this.#oo.bind(this,this.#mi,e,t),Re.utils.addClass(e,"se-copy-format-cursor"),Re.utils.addClass(t,"on"),this.#Yn=this.#mi.addGlobalEvent("keydown",(t=>{Pe.isEsc(t.code)&&this.#Jn?.()})),this.#Xn=this.#mi.addGlobalEvent("mousedown",(s=>{e.contains(s.target)||s.target===t||this.#Jn?.()}))}#oo(t,e,s){return this.#Yn=t.removeGlobalEvent(this.#Yn),this.#Xn=t.removeGlobalEvent(this.#Xn),this.#Zn=null,this.#Jn=null,Re.utils.removeClass(e,"se-copy-format-cursor"),Re.utils.removeClass(s,"on"),!0}#no(t){t=this.#ot.get("_defaultTagCommand")[t.toLowerCase()]||t;let e=this.#ot.get("convertTextTags")[t]||t;const s=this.#t.get("currentNodesMap"),i=s.includes(this.#ot.get("_styleCommandMap")[e])?null:Re.utils.createElement(e);/^sub$/i.test(e)&&s.includes("superscript")?e="sup":/^sup$/i.test(e)&&s.includes("subscript")&&(e="sub"),this.#J.inline.apply(i,{stylesToModify:mn[t]||null,nodesToRemove:[e],strictRemove:!1}),this.#J.focusManager.focus()}#io(){const t=Re.utils.createElement("DIV",{class:"se-component se-component-line-break se-page-break"});this.#J.component.insert(t,{skipCharCount:!0,insertBehavior:"line"});const e=t.nextElementSibling||this.#J.format.addLine(t);this.#J.selection.setRange(e,1,e,1),this.#J.history.push(!1)}}const vn=function(t){const e=Re.check.isContentLess;return{first:Re.query.getEdgeChild(Re.query.getEdgeChild(t,(t=>!e(t)),!1),(t=>0===t.childNodes.length||3===t.nodeType||Y(t)||K(t)),!1)||t.firstChild,last:Re.query.getEdgeChild(t.lastChild,(t=>0===t.childNodes.length||3===t.nodeType||Y(t)||K(t)),!0)||t.lastChild}},bn=".se-menu-list .se-toolbar-btn[data-command]",yn=["bold","underline","italic","strike","subscript","superscript","indent","outdent"],wn=yn.concat(["undo","redo","save","fullScreen","showBlocks","codeView","markdownView","finder","dir","dir_ltr","dir_rtl"]);class Cn{#J;#e;#ot;#ro;#lo=new Map;#ao=yn;constructor(t){this.#J=t.$,this.#e=this.#J.context,this.#ot=this.#J.options,this.#ro=new fn(t),this.allCommandButtons=new Map,this.subAllCommandButtons=new Map}get targets(){return this.#lo}get activeCommands(){return this.#ao}run(t,e,s){if(e){if(/more/i.test(e)){const e=Re.query.getParentElement(s,".se-toolbar"),i=Re.utils.hasClass(e,"se-toolbar-sub")?this.#J.subToolbar:this.#J.toolbar;if(s!==i.currentMoreLayerActiveButton){const n=e.querySelector("."+t);n&&(i._moreLayerOn(s,n),i._showBalloon(),i._showInline()),Re.utils.addClass(s,"on")}else i.currentMoreLayerActiveButton&&(i._moreLayerOff(),i._showBalloon(),i._showInline());return void this.#J.viewer._resetFullScreenHeight()}if(/container/.test(e)&&(null===this.#J.menu.targetMap[t]||s!==this.#J.menu.currentContainerActiveButton))return void this.#J.menu.containerOn(s);if(this.#J.ui.isButtonDisabled(s))return;if(/dropdown/.test(e)&&(null===this.#J.menu.targetMap[t]||s!==this.#J.menu.currentDropdownActiveButton))return void this.#J.menu.dropdownOn(s);if(/modal/.test(e))return void this.#J.plugins[t].open(s);/command/.test(e)?this.#J.plugins[t].action(s):/browser/.test(e)?this.#J.plugins[t].open(null):/popup/.test(e)&&this.#J.plugins[t].show()}else t&&this.#ro.execute(t,s);/dropdown/.test(e)?this.#J.menu.dropdownOff():/command/.test(e)||(this.#J.menu.dropdownOff(),this.#J.menu.containerOff())}runFromTarget(t){if(Re.check.isInputElement(t))return;const e=Re.query.getCommandTarget(t);if(!e)return;const s=e.getAttribute("data-command"),i=e.getAttribute("data-type");(s||i)&&(e.disabled||this.run(s,i,t))}applyTargets(t,e){this.#lo.has(t)&&this.#lo.get(t).forEach(e)}registerTargets(t,e){if(!t||!e)return;(wn.includes(t)||this.#J.plugins[t])&&(this.#lo.get(t)?this.#lo.get(t).includes(e)||this.#lo.get(t).push(e):this.#lo.set(t,[e]))}unregisterTargets(t,e){const s=this.#lo.get(t);if(!s)return;const i=s.indexOf(e);-1!==i&&s.splice(i,1),0===s.length&&this.#lo.delete(t)}resetTargets(){this.#lo=new Map,this._initCommandButtons()}_initCommandButtons(){const t=this.#e;this.#ho(this.allCommandButtons,t.get("toolbar_buttonTray")),this.#ho(this.subAllCommandButtons,t.get("toolbar_sub_buttonTray"))}_copyFormat(){this.#ro.copyFormat()}#ho(t,e){if(!e)return;const s=e.querySelectorAll(bn),i=this.#ot.get("shortcuts"),n=this.#ot.get("_reverseCommandArray"),o=this.#J.shortcuts.keyMap,r=this.#J.shortcuts.reverseKeys;for(let e,l,a=0,h=s.length;a<h;a++)e=s[a],l=e.getAttribute("data-command"),t.set(l,e),this.registerTargets(l,e),ts(l,e,i[l],o,n,r)}_destroy(){this.#lo.clear(),this.allCommandButtons.clear(),this.subAllCommandButtons.clear(),this.#ao=null}}const _n=`${bn}:not([class~="se-code-view-enabled"]):not([data-type="MORE"])`,kn=`${bn}:not([class~="se-component-enabled"]):not([data-type="MORE"])`,{_w:xn}=Le;const $n=class{#H;#J;#t;#gi;#nt;#ot;#e;#O;#X;#mi;#co;#do;#uo;#po;#go=null;#mo;#fo=!1;#vo=null;#bo=null;#yo=[];#wo=[];#Co=!1;#_o=null;#ko=null;#xo=null;constructor(t){this.#H=t,this.#J=t.$,this.#t=t.store,this.#gi=this.#J.contextProvider,this.#nt=this.#gi.carrierWrapper,this.#ot=this.#J.options,this.#e=this.#J.context,this.#O=this.#J.frameRoots,this.#X=this.#J.frameContext,this.#mi=this.#J.eventManager;const e=function({lang:t,icons:e}){const s='<div><button type="button" class="close" data-command="close" title="'+t.close+'">'+e.cancel+"</button></div><div><span></span></div>";return Re.utils.createElement("DIV",{class:"se-alert-content"},s)}(this.#gi);this.alertModal=e,this.alertMessage=e.querySelector("span");const s=function(){const t='<div class="se-toast-container"><span></span></div>';return Re.utils.createElement("DIV",{class:"se-toast"},t)}();s.setAttribute("popover","manual"),this.toastPopup=s,this.toastContainer=s.querySelector(".se-toast-container"),this.toastMessage=s.querySelector("span"),this.#nt.appendChild(s),this.#co=this.#nt.querySelector(".se-alert"),this.#do=this.#nt.querySelector(".se-alert .se-modal-inner"),this.#do.appendChild(e),this.#uo=[this.#$o.bind(this),this.#So.bind(this)],this.#po=!1,this.#mo=this.#nt.querySelector(".se-back-wrapper"),this.selectMenuOn=!1,this.opendControllers=[],this.controllerTargetContext=null,this._figureContainer=null}setEditorStyle(t,e){e||=this.#X;const s=e.get("options");s.set("editorStyle",t);const i=Oe._setDefaultOptionStyle(s,t);s.set("_defaultStyles",i),e.get("topArea").style.cssText=i.top;const n=e.get("code");if(this.#ot.get("hasCodeMirror")){const t=s.get("_defaultStyles").frame.split(";");for(let e,s=0,i=t.length;s<i;s++){if(e=t[s].trim(),!e)continue;const[i,o]=e.split(":");n.style.setProperty(i.trim(),o.trim())}}else n.style.cssText=s.get("_defaultStyles").frame;s.get("iframe")?(e.get("wysiwygFrame").style.cssText=i.frame,e.get("wysiwyg").style.cssText=i.editor):e.get("wysiwygFrame").style.cssText=i.frame+i.editor}setTheme(t){if("string"!=typeof t)return;const e=this.#ot,s=e.get("_themeClass").trim();e.set("theme",t||""),e.set("_themeClass",t?` se-theme-${t}`:""),t=e.get("_themeClass").trim();const i=e=>{e&&(s&&Re.utils.removeClass(e,s),t&&Re.utils.addClass(e,t))};i(this.#nt),this.#gi.applyToRoots((t=>{i(t.get("topArea")),i(t.get("wysiwyg"))})),i(this.#e.get("statusbar_wrapper")),i(this.#e.get("toolbar_wrapper"))}setDir(t){const e="rtl"===t;if(this.#ot.get("_rtl")===e)return;const s=this.#ot.get("textDirection"),i=this.#ot.get("_editableClass"),n=this.#ot.get("printClass");try{this.#ot.set("_rtl",e),this.#ot.set("textDirection",t);const s=e?this.#ot.get("_editableClass").replace(/\s*se-rtl/,"")+" se-rtl":this.#ot.get("_editableClass").replace(/\s*se-rtl/,"");this.#ot.set("_editableClass",s),this.#ot.get("printClass")&&this.#ot.set("printClass",e?this.#ot.get("printClass").replace(/\s*se-rtl/,"")+" se-rtl":this.#ot.get("printClass").replace(/\s*se-rtl/,"")),this.offCurrentController();const i=this.#X,n=this.#J.pluginManager.plugins;for(const e in n)n[e].setDir?.(t);const o=this.#e.get("toolbar_wrapper"),r=this.#e.get("statusbar_wrapper");e?(this.#gi.applyToRoots((t=>{Re.utils.addClass([t.get("topArea"),t.get("wysiwyg"),t.get("documentTypePageMirror")],"se-rtl"),t.get("wysiwyg").dir="rtl"})),Re.utils.addClass([this.#nt,o,r],"se-rtl")):(this.#gi.applyToRoots((t=>{Re.utils.removeClass([t.get("topArea"),t.get("wysiwyg"),t.get("documentTypePageMirror")],"se-rtl"),t.get("wysiwyg").removeAttribute("dir")})),Re.utils.removeClass([this.#nt,o,r],"se-rtl"));const l=Re.query.getListChildren(i.get("wysiwyg"),(t=>this.#J.format.isLine(t)&&!!(t.style.marginRight||t.style.marginLeft||t.style.textAlign)),null);for(let t,e,s,i=0;t=l[i];i++)t=l[i],s=t.style.marginRight,e=t.style.marginLeft,(s||e)&&(t.style.marginRight=e,t.style.marginLeft=s),s=t.style.textAlign,"left"===s?t.style.textAlign="right":"right"===s&&(t.style.textAlign="left");this.#Eo(e),this.#To(this.#e.get("toolbar_buttonTray")),this.#e.has("toolbar_sub_buttonTray")&&this.#To(this.#e.get("toolbar_sub_buttonTray")),this.#t.mode.isBalloon?this.#J.toolbar._showBalloon():this.#t.mode.isSubBalloon&&this.#J.subToolbar._showBalloon()}catch(t){this.#ot.set("_rtl",!e),this.#ot.set("textDirection",s),this.#ot.set("_editableClass",i),null!==n&&this.#ot.set("printClass",n),console.warn(`[SUNEDITOR.ui.setDir.fail] ${t.toString()}`)}this.#t.set("_lastSelectionNode",null),this.#H._eventOrchestrator.applyTagEffect()}readOnly(t,e){const s=e?this.#O.get(e):this.#X;s.set("isReadOnly",!!t),this._toggleControllerButtons(!!t),t?(this.offCurrentController(),this.offCurrentModal(),this.#J.toolbar?.currentMoreLayerActiveButton?.disabled&&this.#J.toolbar._moreLayerOff(),this.#J.subToolbar?.currentMoreLayerActiveButton?.disabled&&this.#J.subToolbar._moreLayerOff(),this.#J.menu?.currentDropdownActiveButton?.disabled&&this.#J.menu.dropdownOff(),this.#J.menu?.currentContainerActiveButton?.disabled&&this.#J.menu.containerOff(),s.get("code").setAttribute("readOnly","true"),Re.utils.addClass(s.get("wysiwyg"),"se-read-only")):(s.get("code").removeAttribute("readOnly"),Re.utils.removeClass(s.get("wysiwyg"),"se-read-only")),this.#ot.get("hasCodeMirror")&&this.#J.viewer._codeMirrorEditor("readonly",!!t,e)}disable(t){const e=t?this.#O.get(t):this.#X;this.#J.toolbar.disable(),this.offCurrentController(),this.offCurrentModal(),e.get("wysiwyg").setAttribute("contenteditable","false"),e.set("isDisabled",!0),this.#ot.get("hasCodeMirror")?this.#J.viewer._codeMirrorEditor("readonly",!0,t):e.get("code").disabled=!0}enable(t){const e=t?this.#O.get(t):this.#X;this.#J.toolbar.enable(),e.get("wysiwyg").setAttribute("contenteditable","true"),e.set("isDisabled",!1),this.#ot.get("hasCodeMirror")?this.#J.viewer._codeMirrorEditor("readonly",!1,t):e.get("code").disabled=!1}show(t){const e=(t?this.#O.get(t):this.#X).get("topArea").style;"none"===e.display&&(e.display="block")}hide(t){(t?this.#O.get(t):this.#X).get("topArea").style.display="none"}showLoading(t){const e=(t?this.#O.get(t).get("container"):this.#nt).querySelector(".se-loading-box");e.style.display="block",e.showPopover?.()}hideLoading(t){const e=(t?this.#O.get(t).get("container"):this.#nt).querySelector(".se-loading-box");e.hidePopover?.(),e.style.display="none"}alertOpen(t,e){this.alertMessage.textContent=t,Re.utils.removeClass(this.alertModal,"se-alert-error|se-alert-success"),e&&Re.utils.addClass(this.alertModal,`se-alert-${e}`),this.#po&&(this.#go=this.#mi.addEvent(this.#do,"click",this.#uo[1])),this.#vo&&=this.#mi.removeGlobalEvent(this.#vo),this.#vo=this.#mi.addGlobalEvent("keydown",this.#uo[0]),this.#co.style.display="block",this.#co.showPopover?.(),Re.utils.addClass(this.alertModal,"se-modal-show")}alertClose(){Re.utils.removeClass(this.alertModal,"se-modal-show"),Re.utils.removeClass(this.alertModal,"se-alert-*"),this.#co.hidePopover?.(),this.#co.style.display="none",this.#go&&=this.#mi.removeEvent(this.#go),this.#vo&&=this.#mi.removeGlobalEvent(this.#vo)}showToast(t,e=1e3,s){Re.utils.hasClass(this.toastContainer,"se-toast-show")&&this.closeToast(),Re.utils.removeClass(this.toastPopup,"se-toast-error|se-toast-success"),s&&Re.utils.addClass(this.toastPopup,`se-toast-${s}`),this.toastPopup.style.display="block",this.toastPopup.showPopover?.(),this.toastMessage.textContent=t,Re.utils.addClass(this.toastContainer,"se-toast-show"),this.#bo=xn.setTimeout((()=>{this.closeToast()}),e)}closeToast(){this.#bo&&xn.clearTimeout(this.#bo),this.#bo=null,Re.utils.removeClass(this.toastContainer,"se-toast-show"),this.toastPopup.hidePopover?.(),this.toastPopup.style.display="none"}setControllerOnDisabledButtons(t){return t&&!this.#fo?(this._toggleControllerButtons(!0),this.#fo=!0):!t&&this.#fo&&(this._toggleControllerButtons(!1),this.#fo=!1),this.#fo}onControllerContext(){this.controllerTargetContext=this.#X.get("topArea")}offControllerContext(){this.controllerTargetContext=null}enableBackWrapper(t){this.#mo.style.cursor=t,this.#mo.style.display="block",this.#mo.showPopover?.()}disableBackWrapper(){this.#mo.hidePopover?.(),this.#mo.style.display="none",this.#mo.style.cursor="default"}offCurrentController(){this.#J.component.__deselect()}offCurrentModal(){this.opendModal?.close()}getVisibleFigure(){return"block"===this._figureContainer?.style.display?this._figureContainer:null}setFigureContainer(t){this._figureContainer=t}preventToolbarHide(t){this.#Co=t}get isPreventToolbarHide(){return this.#Co}get blockHandle(){return this.#xo}reset(t){t.set("_editorHeight",t.get("wysiwygFrame").offsetHeight),this.#_o=t.get("lineBreaker_t"),this.#ko=t.get("lineBreaker_b");const e=this.#ot.get("blockHandle");e&&t.get("blockHandleArea")&&!this.#xo&&(this.#xo=new pn(this.#J,t.get("blockHandleArea"),t.get("blockHandle"),t.get("blockHandlePlus"),t.get("blockHandleDrag"),e.menu))}_offControllers(){const t=this.opendControllers,e=[];for(let s,i=0;i<t.length;i++)s=t[i],s.fixed?e.push(s):(s.inst.controllerClose?.(),s.form&&(s.form.style.display="none"));this.opendControllers=e,this.currentControllerName="",this.#t.set("_preventBlur",!1)}_syncScrollPosition(t){const e=t.scrollTop||t.scrollY||0,s=t.scrollLeft||t.scrollX||0;this.#t.mode.isBalloon&&"block"===this.#e.get("toolbar_main").style.display?(this.#e.get("toolbar_main").style.top=this.#J.toolbar.balloonOffset.top-e+"px",this.#e.get("toolbar_main").style.left=this.#J.toolbar.balloonOffset.left-s+"px"):this.#t.mode.isSubBalloon&&"block"===this.#e.get("toolbar_sub_main").style.display&&(this.#e.get("toolbar_sub_main").style.top=this.#J.subToolbar.balloonOffset.top-e+"px",this.#e.get("toolbar_sub_main").style.left=this.#J.subToolbar.balloonOffset.left-s+"px"),this.#xo?.syncScroll(),this.controllerTargetContext!==this.#X.get("topArea")&&this.offCurrentController(),this.#Mo(s,e)}_repositionControllers(){const t=this.opendControllers;if(0!==t.length){yi.get("__dragMove")&&yi.get("__dragMove")();for(let e=0;e<t.length;e++)t[e].notInCarrier||t[e].inst?._scrollReposition()}}#Mo(t,e){if(this.#_o){const s=this.#_o.style;if("none"!==s.display){const i=(this.#_o.getAttribute("data-offset")||",").split(",");s.top=ze.get(s.top,0)-(e-ze.get(i[0],0))+"px",s.left=ze.get(s.left,0)-(t-ze.get(i[1],0))+"px",this.#_o.setAttribute("data-offset",e+","+t)}}if(this.#ko){const s=this.#ko.style;if("none"!==s.display){const i=(this.#ko.getAttribute("data-offset")||",").split(",");s.top=ze.get(s.top,0)-(e-ze.get(i[0],0))+"px",s[i[1]]=ze.get(s[i[1]],0)-(t-ze.get(i[2],0))+"px",this.#ko.setAttribute("data-offset",e+","+i[1]+","+t)}}const s=this.opendControllers;for(let i=0;i<s.length;i++)s[i].notInCarrier&&(s[i].form.style.top=s[i].inst.__offset.top-e+"px",s[i].form.style.left=s[i].inst.__offset.left-t+"px")}_visibleControllers(t,e){const s=t?"":"hidden",i=e??s?"":"hidden",n=this.opendControllers;for(let t,e=0;e<n.length;e++)t=n[e],t.form&&(t.form.style.visibility=s);this.#_o.style.visibility=i,this.#ko.style.visibility=i}setCurrentControllerContext;#Eo(t){const e=this.#gi.icons,s=this.#J.commandDispatcher?.targets;if(!s)return;const i=this.#J.shortcuts?.keyMap;this.#J.shortcuts?.reverseKeys?.forEach((t=>{const e=i?.get(t);e&&([e.command,e.r]=[e.r,e.command])})),this.#J.commandDispatcher.applyTargets("dir",(s=>{Re.utils.changeTxt(s.querySelector(".se-tooltip-text"),this.#gi.lang[t?"dir_ltr":"dir_rtl"]),Re.utils.changeElement(s.firstElementChild,e[t?"dir_ltr":"dir_rtl"])})),t?(Re.utils.addClass(s.get("dir_rtl"),"active"),Re.utils.removeClass(s.get("dir_ltr"),"active")):(Re.utils.addClass(s.get("dir_ltr"),"active"),Re.utils.removeClass(s.get("dir_rtl"),"active"))}#To(t){if(!t)return;const e=t.querySelector(".se-toolbar-more-layer"),s=Array.from(t.children).filter((t=>t!==e));for(let e=s.length-1;e>=0;e--)t.appendChild(s[e]);e&&t.appendChild(e)}_initToggleButtons(){const t=this.#e;this.#wo=Oe.nodeListToArray(t.get("toolbar_buttonTray").querySelectorAll(_n)),this.#yo=Oe.nodeListToArray(t.get("toolbar_buttonTray").querySelectorAll(kn)),this.#ot.has("_subMode")&&(this.#wo=this.#wo.concat(Oe.nodeListToArray(t.get("toolbar_sub_buttonTray").querySelectorAll(_n))),this.#yo=this.#yo.concat(Oe.nodeListToArray(t.get("toolbar_sub_buttonTray").querySelectorAll(kn))))}_toggleCodeViewButtons(t){Re.utils.setDisabled(this.#wo,t)}_toggleControllerButtons(t){Re.utils.setDisabled(this.#yo,t)}isButtonDisabled(t){return!(!this.#X.get("isReadOnly")||!Re.utils.arrayIncludes(this.#yo,t))}_updatePlaceholder(t){t||=this.#X;const e=t.get("isMarkdownView")||t.get("isCodeView"),s=!e&&this.#No(t),i=t.get("placeholder");i&&(i.style.display=e||s||!this.#J.facade.isEmpty(t)?"none":"block")}resolveLinePlaceholder(t,e){if(!t||!e)return"";if("object"!=typeof e)return Re.check.isListCell(t)||Re.query.getParentElement(t,Re.check.isTableCell)?"":e;const s=this.#J.format,i=t.nodeName.toLowerCase();if("string"==typeof e[i])return e[i];if(Re.check.isListCell(t)&&"string"==typeof e["@list"])return e["@list"];if(s.isClosureBrLine(t)&&"string"==typeof e["@closureBrLine"])return e["@closureBrLine"];if(s.isBrLine(t)&&"string"==typeof e["@brLine"])return e["@brLine"];const n=s.getBlock(t);if(n&&n!==t){const t=n.nodeName.toLowerCase();if("string"==typeof e[t])return e[t];if(s.isClosureBlock(n)&&"string"==typeof e["@closureBlock"])return e["@closureBlock"];if("string"==typeof e["@block"])return e["@block"]}return s.isNormalLine(t)&&"string"==typeof e["@normalLine"]?e["@normalLine"]:"string"==typeof e["@line"]?e["@line"]:""}#No(t){const e=t.get("placeholder_line");if(!e)return!1;const s=t.get("wysiwyg"),i=this.#t.get("hasFocus")?this.#J.format.getLine(this.#J.selection.selectionNode):null,n=Re.check.isEmptyLine(i)?this.resolveLinePlaceholder(i,e):"",o=n?i:null,r=s.querySelectorAll(".se-placeholder-line");for(let t=0;t<r.length;t++){const e=r[t];e!==o&&(e.classList.remove("se-placeholder-line"),e.removeAttribute("data-se-placeholder-line"),e.getAttribute("class")||e.removeAttribute("class"))}return!!o&&(o.classList.add("se-placeholder-line"),o.setAttribute("data-se-placeholder-line",n),!0)}_syncFrameState(t){t&&(this._iframeAutoHeight(t),this._updatePlaceholder(t),t.has("documentType_use_page")&&(t.get("documentTypePageMirror").innerHTML=t.get("wysiwyg").innerHTML,t.get("documentType").rePage(!0)))}_iframeAutoHeight(t){if(!t)return;const e=t.get("_iframeAuto");if(e)xn.setTimeout((()=>{const s=e.offsetHeight,i=t.get("wysiwygFrame");if(!i)return;i.style.height=s+"px";const n=t.get("options");if(n?.get("iframe")){const t=n.get("maxHeight");t&&i.setAttribute("scrolling",s>ze.get(t)?"auto":"no")}Le.isResizeObserverSupported||this._emitResizeEvent(t,s,null)}),0);else if(!Le.isResizeObserverSupported){const e=t.get("wysiwygFrame");e&&this._emitResizeEvent(t,e.offsetHeight,null)}}_emitResizeEvent(t,e,s){e=-1===e?s?.borderBoxSize&&s.borderBoxSize[0]?s.borderBoxSize[0].blockSize:s.contentRect.height+ze.get(t.get("wwComputedStyle").getPropertyValue("padding-left"))+ze.get(t.get("wwComputedStyle").getPropertyValue("padding-right")):e,t.get("_editorHeight")!==e&&(this.#mi.triggerEvent("onResizeEditor",{height:e,prevHeight:t.get("_editorHeight"),frameContext:t,observerEntry:s}),t.set("_editorHeight",e)),t.has("documentType_use_page")&&t.get("documentType").resizePage()}init(){this.#po=!this.#mi.addEvent(this.alertModal.querySelector('[data-command="close"]'),"click",this.alertClose.bind(this)),this._initToggleButtons()}#So(t){const e=Re.query.getEventTarget(t);(/close/.test(e.getAttribute("data-command"))||e===this.#do)&&this.alertClose()}#$o(t){Pe.isEsc(t.code)&&this.alertClose()}_destroy(){this.#bo&&xn.clearTimeout(this.#bo),this.#vo&&=this.#mi.removeGlobalEvent(this.#vo),this.#go&&=this.#mi.removeEvent(this.#go),this.opendModal=null,this.opendBrowser=null,this.#_o=null,this.#ko=null,this.#xo?.destroy(),this.#xo=null,this.#yo=null,this.#wo=null}};function Sn(t){const e=t.$,s=t.store,i=e.contextProvider,n=e.eventManager,r=i.frameRoots,l=i.context,a=i.frameContext;let h=e.options.get("historyStackDelayTime");const c=e.options.get("historyStackSize");let d,u,p,g,m=null,f=!1,v=null;function b(i,o,r){r&&s.get("hasFocus")&&t._eventOrchestrator.applyTagEffect(),e.history.resetButtons(i.get("key"),o),n.triggerEvent("onChange",{frameContext:i,data:i.get("wysiwyg").innerHTML}),"block"===l.get("toolbar_main").style.display?e.toolbar._showBalloon():s.mode.isSubBalloon&&"block"===l.get("toolbar_sub_main").style.display&&e.subToolbar._showBalloon()}function y(t){const s=u[d],i=p[s];d+=t;const n=t<0&&s!==u[d]&&i.index>0?s:u[d],o=p[n];o.index+=t;const l=o.value[o.index];if(!l)return console.warn("[SunEditor.history.setContent.fail] History state desynchronized. Aborting undo/redo operation."),o.index-=t,void(d-=t);r.get(n).get("wysiwyg").innerHTML=l.content,s!==n&&t<0&&1===d?d=0:s!==n&&t>0&&1===o.index?d++:(t<0&&o.index<1||t>0&&o.index>o.value.length)&&(d+=t);let h=n,c=l;if(t<0&&d>0&&0===o.index){const e=u[d+t];if(e!==n){const t=p[e];h=e,c=t.value[t.index]}}e.facade.changeFrameContext(h),e.selection.setRange(vt(c.s.path,c.frame),c.s.offset,vt(c.e.path,c.frame),c.e.offset),e.focusManager.focus(),d<0?d=0:d>=u.length&&(d=u.length-1),e.ui.offCurrentController(),e.pluginManager.checkFileInfo(!1),e.char.display(),e.ui._syncFrameState(a),a.has("documentType_use_header")&&a.get("documentType").reHeader(),b(a,o.index,!0)}function w(t,e,s,i){let n,o;e?(n={path:ft(e.startContainer,null,null),offset:e.startOffset},o={path:ft(e.endContainer,null,null),offset:e.endOffset}):(n={path:[0,0],offset:[0,0]},o={path:0,offset:0}),d+=i,u[d]=s;const l=p[s];l.index+=i,l.value[l.index]={content:t,s:n,e:o,frame:r.get(s).get("wysiwyg")}}function C(t){p[t]={value:[],index:-1},g[t]=r.get(t).get("wysiwyg").innerHTML}function _(t,s){e.pluginManager.checkFileInfo(!1);const i=r.get(t),n=i.get("wysiwyg").innerHTML,o=p[t];if(n&&(!o.value[o.index]||n!==o.value[o.index].content)){if(u.length>d+1&&function(t){const s=[];for(let t=d+1,e=u.length;t<e;t++)s.includes(u[t])||s.push(u[t]);u=u.slice(0,d+1),t.value.splice(t.index+1),e.commandDispatcher.applyTargets("redo",(t=>{t.disabled=!0}));for(let t=0,e=s.length;t<e;t++)u.includes(s[t])||C(s[t])}(o),0===o.value.length&&function(t){d++,u[d]=t;const e=p[t];e.index=0,e.value[0]={content:g[t],s:{path:[0,0],offset:[0,0]},e:{path:0,offset:0},frame:r.get(t).get("wysiwyg")}}(t),w(n,s,t,1),o.value.length>c){const e=o.value.length-c;o.value.splice(0,e),o.index-=e;let s=0;for(let i=u.length-1;i>=0&&s<e;i--)if(u[i]===t)for(let e=0;e<u.length;e++)if(u[e]===t){u.splice(e,1),s++;break}d-=e}1===d&&e.commandDispatcher.applyTargets("undo",(t=>{t.disabled=!1})),e.char.display(),b(i,o.index,!1)}}return{push(t,i){if(f)return;i=i||null===i?i:s.get("rootKey");const n=s.get("_range");o.setTimeout(e.ui._syncFrameState.bind(e.ui,r.get(i)),0);const l="number"==typeof t?t>0?t:0:t?h:0;l&&!m||(o.clearTimeout(m),l)?m=o.setTimeout((()=>{o.clearTimeout(m),m=null,_(i,n)}),l):_(i,n)},check(t,e){m&&(o.clearTimeout(m),m=null,_(t,e))},undo(){d>0&&y(-1)},redo(){u.length-1>d&&y(1)},overwrite(t){w(r.get(t||s.get("rootKey")).get("wysiwyg").innerHTML,null,s.get("rootKey"),0)},pause(){f=!0,v&&(o.clearTimeout(v),v=null),v=o.setTimeout((()=>{f=!1}),5e3)},resume(){v&&(o.clearTimeout(v),v=null),f=!1},reset(){e.commandDispatcher.applyTargets("undo",(t=>t.disabled=!0)),e.commandDispatcher.applyTargets("redo",(t=>t.disabled=!0)),e.commandDispatcher.applyTargets("save",(t=>t.disabled=!0)),i.applyToRoots((t=>t.set("historyIndex",-1))),i.applyToRoots((t=>t.set("isChanged",!1))),d=-1,u=[],p={},g={},f=!1;const t=i.rootKeys;for(let e=0,s=t.length;e<s;e++)C(t[e])},resetButtons(t,s){const i=!ze.is(s),o=p[void 0===t?u[d]:t];s=i?o.index:s;const l=r.get(t),a=o.value.length-1;e.commandDispatcher.applyTargets("undo",(t=>{t.disabled=!(s>0&&s<=a)})),e.commandDispatcher.applyTargets("redo",(t=>{t.disabled=!(s>-1&&s<a)}));const h=l.get("savedIndex"),c=l.get("historyIndex"),g=h>-1?h!==s:i?o.index>0:s>0&&c!==s;l.set("historyIndex",s),l.set("isChanged",g),e.commandDispatcher.applyTargets("save",(t=>{t.disabled=!g})),n.triggerEvent("onResetButtons",{rootKey:t})},getRootStack:()=>p,resetDelayTime(t){h=t},_destroy(){m&&o.clearTimeout(m),v&&o.clearTimeout(v),d=u=p=g=null}}}const{_w:En}=Le;const Tn=class{#H;#J;#t;#Bo;#Io;#e;#X;#ot;#mi;#Lo;#Ao;#Oo;#Ro="default";#zo=null;#Po=null;#Do=!1;#Fo=!1;#Ho=!1;constructor(t,{keyName:e,balloon:s,inline:i,balloonAlways:n,res:o}){this.#H=t,this.#J=t.$,this.#t=t.store,this.#Bo=this.#J.icons,this.#Io=this.#J.lang,this.#e=this.#J.context,this.#X=this.#J.frameContext,this.#ot=this.#J.options,this.#mi=this.#J.eventManager,this.isSub="toolbar_sub"===e,this.keyName={main:this.isSub?"toolbar_sub_main":"toolbar_main",buttonTray:this.isSub?"toolbar_sub_buttonTray":"toolbar_buttonTray",width:this.isSub?"toolbar_sub_width":"toolbar_width"},this.currentMoreLayerActiveButton=null,this.isBalloonMode=s,this.isInlineMode=i,this.isBalloonAlwaysMode=n,this.inlineToolbarAttr={top:"",width:"",isShow:!1},this.balloonOffset={top:0,left:0},this.#Lo=o,this.#Ao=o,this.#Oo="visualViewport"in En;const r=!this.isSub&&!s&&!i,l=this.#ot.get("_toolbar_sticky");if(this.#Do=r&&l>=0&&!this.#ot.get("toolbar_container")&&!this.#ot.get("_toolbar_sticky_fixed")&&"undefined"!=typeof CSS&&CSS.supports("position","sticky"),this.isBottomMode=this.#t.mode.isBottom,this.#Do){const t=this.#e.get(this.keyName.main);this.isBottomMode?(t.style.bottom=l+"px",t.style.top="auto"):l>0&&(t.style.top=l+"px")}else r&&Re.utils.addClass(this.#e.get(this.keyName.main),"se-toolbar-relative");this._setResponsive()}get isSticky(){if(this.isSub)return!1;const t=this.#ot.get("_toolbar_sticky");if(t<0)return!1;if(this.#Do){const e=this.#e.get(this.keyName.main);if(!e||0===e.offsetWidth||"none"===e.style.display)return!1;if(this.isBottomMode){const s=this.#Oo?En.visualViewport.height:En.innerHeight;return e.getBoundingClientRect().bottom>=s-t-1}return e.getBoundingClientRect().top<=t+1}return this.#Fo}get isCSSSticky(){return this.#Do}disable(){this._moreLayerOff(),this.#J.menu.dropdownOff(),this.#J.menu.containerOff(),Re.utils.setDisabled(this.#e.get(this.keyName.buttonTray).querySelectorAll(".se-menu-list .se-toolbar-btn[data-type]"),!0)}enable(){Re.utils.setDisabled(this.#e.get(this.keyName.buttonTray).querySelectorAll(".se-menu-list .se-toolbar-btn[data-type]"),!1)}show(){this.isInlineMode?this._showInline():this.isBalloonMode?this._showBalloon():(this.#e.get(this.keyName.main).style.display="",this.isSub||(this.#X.get("_stickyDummy").style.display="")),this.isSub||this.resetResponsiveToolbar()}hide(){this.isInlineMode?(this.#e.get(this.keyName.main).style.display="none",this.#e.get(this.keyName.main).style.top="0px",this.inlineToolbarAttr.isShow=!1):(this.#e.get(this.keyName.main).style.display="none",this.isSub||(this.#X.get("_stickyDummy").style.display="none"),this.isBalloonMode&&(this.balloonOffset={top:0,left:0}))}resetResponsiveToolbar(){this.#J.menu.containerOff();const t=this.#Po;if(t){let e=0;e=(this.isBalloonMode||this.isInlineMode)&&"auto"===this.#ot.get("toolbar_width")||this.#t.mode.isSubBalloon&&"auto"===this.#ot.get("toolbar_sub_width")?this.#X.get("topArea").offsetWidth:this.#e.get(this.keyName.main).offsetWidth;let s="default";for(let i=1,n=t.length;i<n;i++)if(e<t[i]){s=t[i]+"";break}this.#Ro!==s&&(this.#Ro=s,this.setButtons(this.#zo[s]))}}setButtons(t){this._moreLayerOff(),this.#J.menu.dropdownOff(),this.#J.menu.containerOff();const e=gs(t,this.#J.plugins,this.#ot,this.#Bo,this.#Io,!0);e.updateButtons.forEach((t=>ps(t.button,t.plugin,this.#Bo,this.#Io))),this.#e.get(this.keyName.main).replaceChild(e.buttonTray,this.#e.get(this.keyName.buttonTray)),this.#e.set(this.keyName.buttonTray,e.buttonTray),this.#qo(),this.#mi.triggerEvent("onSetToolbarButtons",{buttonTray:e.buttonTray,frameContext:this.#X})}_resetSticky(){if(this.#Do)return void this.#Wo();const t=this.#X.get("wrapper");if(!t)return;const e=this.#e.get(this.keyName.main),s=this.#ot.get("_toolbar_sticky");if(this.#X.get("isFullScreen")||0===e.offsetWidth||s<0)return;const i=this.#Oo?En.visualViewport.pageTop:En.scrollY,n=this.#X.get("_minHeight"),o=t.offsetHeight,r=this.#J.offset.getGlobal(this.#X.get("topArea"));if(this.isBottomMode){const t=i+En.innerHeight,l=r.top+o,a=t-s-(this.isInlineMode?e.offsetHeight:0),h=this.#ot.get("toolbar_container")?t-s-r.top-n-e.offsetHeight:a-r.top-n;a>l?this.#Uo():h<0?(this.isSticky||this.#Vo(1),e.style.bottom=1+h+this.#jo()+"px",e.style.top="auto"):this.#Vo(1)}else{const t=i+s,l=(this.isBalloonMode||this.isInlineMode?r.top:this.#J.offset.getGlobal(this.#ot.get("toolbar_container")).top)-(this.isInlineMode?e.offsetHeight:0),a=this.#ot.get("toolbar_container")?r.top-i+o-n-s-e.offsetHeight:o+l+s-t-n;t<l?this.#Uo():a<0?(this.isSticky||this.#Vo(1),e.style.top=1+a+this.#jo()+"px"):this.#Vo(1)}}#qo(){this.#J.shortcuts._registerShortcuts(),this.#J.commandDispatcher.resetTargets(),this.#J.ui._initToggleButtons(),this.#J.history.resetButtons(this.#X.get("key"),null),this._resetSticky(),this.#t.set("_lastSelectionNode",null),this.#J.viewer._setButtonsActive(),this.#t.get("hasFocus")&&this.#H._eventOrchestrator.applyTagEffect(),this.#X.get("isReadOnly")&&this.#J.ui.setControllerOnDisabledButtons(!0)}_setResponsive(){if(0===this.#Ao?.length)return void(this.#Ao=null);this.#Ro="default";const t=this.#Po=[],e=this.#Lo,s=this.#zo={default:e[0]};for(let i,n,o=1,r=e.length;o<r;o++)n=e[o],i=1*n[0],t.push(i),s[i]=n[1];t.sort(((t,e)=>t-e)).unshift("default")}_showBalloon(t){if(!this.isBalloonMode)return;this.isSub&&this.resetResponsiveToolbar();const e=t||this.#J.selection.getRange(),s=this.#e.get(this.keyName.main),i=this.#J.selection.get();let n;if(this.isBalloonAlwaysMode&&e.collapsed)n=!0;else if(i.focusNode===i.anchorNode)n=i.focusOffset<i.anchorOffset;else{const t=Re.query.getListChildNodes(e.commonAncestorContainer,null,null);n=Re.utils.getArrayIndex(t,i.focusNode)<Re.utils.getArrayIndex(t,i.anchorNode)}this._setBalloonOffset(n,e),this.#mi.triggerEvent("onShowToolbar",{toolbar:s,mode:"balloon",frameContext:this.#X})}_setBalloonOffset(t,e){const s=this.#e.get(this.keyName.main),i=this.#X.get("topArea"),n=this.#J.offset.getGlobal(i).top;if(!this.#J.offset.setRangePosition(s,e,{position:t?"top":"bottom",addTop:n}))return void this.hide();if(this.#ot.get("toolbar_container")){const t=i.parentElement;let e=this.#ot.get("toolbar_container"),n=e.offsetLeft,o=e.offsetTop;for(;!e.parentElement.contains(t)&&!/^(BODY|HTML)$/i.test(e.parentElement.nodeName);)e=e.offsetParent,n+=e.offsetLeft,o+=e.offsetTop;s.style.left=s.offsetLeft-n+i.offsetLeft+"px",s.style.top=s.offsetTop-o+i.offsetTop+"px"}const o=this.#J.offset.getWWScroll();this.balloonOffset={top:s.offsetTop+o.top,left:s.offsetLeft+o.left,position:t?"top":"bottom"}}_showInline(){if(!this.isInlineMode)return;const t=this.#e.get(this.keyName.main);if(t.style.visibility="hidden",t.style.display="block",this.#Uo(),t.style.top="0px",this.inlineToolbarAttr.width=t.style.width=this.#ot.get(this.keyName.width),this.isBottomMode){const e=this.#X.get("topArea");this.inlineToolbarAttr.top=t.style.top=this.#J.offset.getGlobal(e).top+e.offsetHeight-this.#J.offset.getGlobal(t).top+"px"}else this.inlineToolbarAttr.top=t.style.top=this.#J.offset.getGlobal(this.#X.get("topArea")).top-this.#J.offset.getGlobal(t).top-t.offsetHeight-1+"px";this._resetSticky(),this.inlineToolbarAttr.isShow=!0,this.#mi.triggerEvent("onShowToolbar",{toolbar:t,mode:"inline",frameContext:this.#X}),t.style.visibility=""}_moreLayerOn(t,e){this._moreLayerOff(),this.currentMoreLayerActiveButton=t,e.style.display="block"}_moreLayerOff(){if(this.currentMoreLayerActiveButton){this.#e.get(this.keyName.main).querySelector("."+this.currentMoreLayerActiveButton.getAttribute("data-command")).style.display="none",Re.utils.removeClass(this.currentMoreLayerActiveButton,"on"),this.currentMoreLayerActiveButton=null}}#Vo(t){const e=this.#e.get(this.keyName.main);if(!this.isInlineMode){const t=this.#ot.get("toolbar_container")?this.#e.get("_stickyDummy"):this.#X.get("_stickyDummy");t.style.height=e.offsetHeight+"px",t.style.display="block"}if(this.isBottomMode){const t=this.#ot.get("_toolbar_sticky")+this.#jo();e.style.bottom=`${t}px`,e.style.top="auto"}else{const s=this.#ot.get("_toolbar_sticky")+t+this.#jo();e.style.top=`${s}px`}e.style.width=this.isInlineMode?this.inlineToolbarAttr.width:e.offsetWidth+"px",Re.utils.addClass(e,"se-toolbar-sticky"),this.#Fo=!0}#jo(){return this.#Oo?En.visualViewport.offsetTop:0}#Wo(){if(!this.#Oo)return;if(this.#H._eventOrchestrator.scrollparents.length>0)return;const t=Math.round(En.visualViewport.offsetTop);if(0===t&&!this.#Ho)return;const e=this.#e.get(this.keyName.main),s=this.#ot.get("_toolbar_sticky_offset");if(t>0)if(this.#Ho=!0,this.isBottomMode){const i=Math.round(En.innerHeight-En.visualViewport.height-t);e.style.bottom=s+i+"px",e.style.top="auto"}else e.style.top=s+t+"px";else{this.#Ho=!1;const t=this.#ot.get("_toolbar_sticky");this.isBottomMode?(e.style.bottom=t+"px",e.style.top="auto"):e.style.top=t>0?t+"px":""}}#Uo(){(this.#ot.get("toolbar_container")?this.#e.get("_stickyDummy"):this.#X.get("_stickyDummy")).style.display="none";const t=this.#e.get(this.keyName.main);this.isBottomMode?(t.style.bottom=this.isInlineMode?-t.offsetHeight+"px":"",t.style.top="auto",this.#X.get("wrapper").style.marginBottom=""):(t.style.top=this.isInlineMode?this.inlineToolbarAttr.top:"",this.#X.get("wrapper").style.marginTop=""),t.style.width=this.isInlineMode?this.inlineToolbarAttr.width:"",Re.utils.removeClass(t,"se-toolbar-sticky"),this.#Fo=!1}_destroy(){this._moreLayerOff()}},{isMobile:Mn,_w:Nn}=Le;function Bn(t){return/free$/.test(t)}const In=class{#J;#t;#gi;#e;#mi;#Go;#Ko=[];#Yo=null;#Xo=null;#Zo=null;#Jo=null;#Qo=null;#tr=null;#er=null;#sr=null;#ir=null;#nr=null;#or=null;#rr=new Set;constructor(t){this.#J=t.$,this.#t=t.store,this.#gi=this.#J.contextProvider,this.#e=this.#J.context,this.#mi=this.#J.eventManager,this.targetMap={},this.itemsMap={},this.index=-1,this.menus=[],this.currentButton=null,this.currentDropdown=null,this.currentDropdownActiveButton=null,this.currentDropdownName="",this.currentDropdownType="",this.currentContainer=null,this.currentContainerActiveButton=null,this.currentContainerName="",this.currentDropdownPlugin=null,this.#Go={mousedown:this.#lr.bind(this),containerDown:this.containerOff.bind(this),keydown:this.#ar.bind(this),esc:this.#hr.bind(this),mousemove:this.#cr.bind(this),mouseout:this.#dr.bind(this)},this.#Yo=null,this.#Xo=null,this.#Zo=null,this.#Jo=null,this.#er=null,this.#sr=null,this.#or=Nn.visualViewport||null}initDropdownTarget({key:t,type:e},s,i){if(!t)throw Error("[SUNEDITOR.init.fail] The plugin's key is not added.");let n;if(Array.isArray(s)){n=function(t,e={}){let s="";for(let e=0,i=t.length;e<i;e++){const i=t[e];let n="";if(i.attrs){const t=Object.keys(i.attrs);for(let e=0;e<t.length;e++)n+=` ${t[e]}="${i.attrs[t[e]]}"`}s+=`\n\t\t<li>\n\t\t\t<button type="button" class="se-btn se-btn-list${i.className?" "+i.className:""}" data-command="${i.command}"${void 0!==i.value?` data-value="${i.value}"`:""} title="${i.title}" aria-label="${i.title}"${n}>${i.innerHTML}</button>\n\t\t</li>`}return Re.utils.createElement("DIV",{class:"se-dropdown se-list-layer"+(e.className?" "+e.className:"")},`<div class="se-list-inner"><ul class="se-list-basic">${e.prependHTML||""}${s}</ul></div>`)}(s,i);const e=n.querySelectorAll(".se-list-inner li > button"),o=e.length-s.length;for(let t=0;t<s.length;t++)s[t]._element=e[o+t]||null;this.itemsMap[t]=s}else n=s;return Bn(e)||(n.setAttribute("data-key",t),this.#Ko.push(t)),this.#e.get("menuTray").appendChild(n),this.targetMap[t]=n,n}dropdownOn(t){this.#We();const e=this.#ur(t);if(e){const s=Re.query.getParentElement(e,".se-btn-tray").querySelector('[data-command="'+e.getAttribute("data-ref")+'"]');if(s)return this.#J.commandDispatcher.runFromTarget(s),void this.dropdownOn(t)}const s=this.currentButton=t,i=this.currentDropdownName=s.getAttribute("data-command");this.currentDropdownType=s.getAttribute("data-type");const n=this.currentDropdown=this.targetMap[i];this.currentDropdownActiveButton=s,Mn?this.#pr(s,n):this.#gr(s,n),this.#e.get("menuTray").showPopover?.(),this.#Yo=this.#mi.addGlobalEvent("mousedown",this.#Go.mousedown,!1),this.#Zo=this.#mi.addGlobalEvent("keydown",this.#Go.esc,!0),this.#Ko.includes(i)&&(this.menus=Oe.nodeListToArray(n.querySelectorAll("[data-command]")),this.menus.length>0&&(this.#Xo=this.#mi.addGlobalEvent("keydown",this.#Go.keydown,!1),this.#Qo=this.#mi.addEvent(n,"mousemove",this.#Go.mousemove,!1),this.#tr=this.#mi.addEvent(n,"mouseout",this.#Go.mouseout,!1))),this.currentDropdownPlugin=this.#J.plugins[i],this.currentDropdownPlugin?.on(s),this.#t.set("_preventBlur",!0)}dropdownOff(){this.#mr(),this.#We(),Bn(this.currentDropdownType)&&this.currentDropdownPlugin?.off?.(),this.index=-1,this.menus=[],this.#er=null,this.#sr=null,this.currentButton=null,this.currentDropdown&&(this.currentDropdownName="",this.currentDropdownType="",this.currentDropdown.style.display="none",this.currentDropdown=null,this.currentDropdownActiveButton&&Re.utils.removeClass(this.currentDropdownActiveButton.parentElement.children,"on"),this.currentDropdownActiveButton=null,this.#J.ui.preventToolbarHide(!1),this.#e.get("menuTray").hidePopover?.()),this.#t.set("_preventBlur",!1),this.currentDropdownPlugin=null;for(const t of[...this.#rr])t()}subscribeDropdownOff(t){return this.#rr.add(t),()=>this.#rr.delete(t)}dropdownShow(){this.currentButton&&this.dropdownOn(this.currentButton)}dropdownHide(){this.currentDropdown&&(this.currentDropdown.style.display="none")}containerOn(t){this.#We(),this.currentContainerActiveButton=t;const e=this.currentContainerName=this.currentContainerActiveButton.getAttribute("data-command");this.currentContainer=this.targetMap[e],Mn?this.#pr(t,this.currentContainer):this.#gr(t,this.currentContainer),this.#e.get("menuTray").showPopover?.(),this.#Jo=this.#mi.addGlobalEvent("mousedown",this.#Go.containerDown,!1),this.#J.plugins[e].on&&this.#J.plugins[e].on(t),this.#t.set("_preventBlur",!0)}containerOff(){this.#mr(),this.#We(),this.currentContainer&&(this.currentContainerName="",this.currentContainer.style.display="none",this.currentContainer=null,Re.utils.removeClass(this.currentContainerActiveButton,"on"),this.currentContainerActiveButton=null,this.#J.ui.preventToolbarHide(!1),this.#e.get("menuTray").hidePopover?.()),this.#t.set("_preventBlur",!1)}__resetMenuPosition(t,e){this.#J.offset.setRelPosition(e,this.#gi.carrierWrapper,t.parentElement,Re.query.getParentElement(t,".se-toolbar"),{preferUp:this.#t.mode.isBottom})}__restoreMenuPosition(){this.#er&&this.#sr&&(this.#nr||this.#ir||this.#gr(this.#er,this.#sr))}#gr(t,e){e.style.visibility="hidden",e.style.display="block",e.style.height="",Re.utils.addClass(t.parentElement.children,"on"),this.#J.offset.setRelPosition(e,this.#gi.carrierWrapper,t.parentElement,Re.query.getParentElement(t,".se-toolbar"),{preferUp:this.#t.mode.isBottom}),e.style.visibility="",this.#er=t,this.#sr=e}#pr(t,e){this.#mr(),e.style.display="none",Re.utils.addClass(t.parentElement.children,"on"),this.#er=t,this.#sr=e;let s=!1;const i=i=>{s||(s=!0,this.#mr(),this.#ir=Nn.setTimeout((()=>{this.#ir=null,this.#er===t&&this.#gr(t,e)}),i))};this.#or&&(this.#nr=()=>i(10),this.#or.addEventListener("resize",this.#nr,{once:!0})),this.#ir=Nn.setTimeout((()=>i(0)),50)}#mr(){this.#ir&&(Nn.clearTimeout(this.#ir),this.#ir=null),this.#nr&&(this.#or?.removeEventListener("resize",this.#nr),this.#nr=null)}#ur(t){const e=Re.query.getParentElement(t,".se-more-layer");return e&&"block"!==e.style.display&&e.getAttribute("data-ref")?e:null}#Bs(t){Re.utils.removeClass(this.currentDropdown,"se-select-menu-mouse-move"),Re.utils.addClass(this.currentDropdown,"se-select-menu-key-action"),t=this.index+t;const e=this.menus.length,s=this.index=t>=e?0:t<0?e-1:t;for(let t=0;t<e;t++)t===s?Re.utils.addClass(this.menus[t],"on"):Re.utils.removeClass(this.menus[t],"on")}#We(){this.#Yo&&=this.#mi.removeGlobalEvent(this.#Yo),this.#Zo&&=this.#mi.removeGlobalEvent(this.#Zo),this.#Jo&&=this.#mi.removeGlobalEvent(this.#Jo),this.#Xo&&(this.#Xo=this.#mi.removeGlobalEvent(this.#Xo),this.#Qo&&=this.#mi.removeEvent(this.#Qo),this.#tr&&=this.#mi.removeEvent(this.#tr),Re.utils.removeClass(this.menus,"on"),Re.utils.removeClass(this.currentDropdown,"se-select-menu-key-action|se-select-menu-mouse-move"))}#lr(t){const e=Re.query.getEventTarget(t);Re.query.getParentElement(e,".se-dropdown")||this.dropdownOff()}#dr(){this.index=-1}#ar(t){switch(t.code){case"ArrowUp":case"ArrowLeft":t.preventDefault(),t.stopPropagation(),this.#Bs(-1);break;case"ArrowDown":case"ArrowRight":t.preventDefault(),t.stopPropagation(),this.#Bs(1);break;case"Enter":case"Space":{if(this.index<0)break;const e=this.menus[this.index];if(!e||"function"!=typeof this.#J.plugins[this.currentDropdownName].action)return;t.preventDefault(),t.stopPropagation(),this.#J.plugins[this.currentDropdownName].action(e),this.dropdownOff();break}}}#hr(t){Pe.isEsc(t.code)&&(this.#J.ui.opendControllers?.some((({form:t})=>t&&Re.utils.hasClass(t,"se-dropdown")))||(t.preventDefault(),t.stopPropagation(),this.dropdownOff()))}#cr(t){Re.utils.addClass(this.currentDropdown,"se-select-menu-mouse-move"),Re.utils.removeClass(this.currentDropdown,"se-select-menu-key-action");const e=this.menus.indexOf(t.target);-1!==e&&(this.index=1*e)}_destroy(){this.#We()}},{_w:Ln,_d:An}=Le;function On(t,e){const s="markdown"===e?"markdownNumbers":"codeNumbers",i="markdown"===e?"markdown":"code",n=t.get(s);if(!n)return;const o=t.get(i),r=(o.value.match(/\n/g)||[]).length+1;let l="";for(let t=1;t<=r;t++)l+=`${t}\n`;const a=Ln.getComputedStyle(o);n.style.lineHeight=a.lineHeight,n.style.fontSize=a.fontSize,n.style.fontFamily=a.fontFamily,n.style.paddingTop=a.paddingTop,n.style.paddingBottom=a.paddingBottom,n.value=l}const Rn=class{#H;#J;#t;#Bo;#Io;#O;#e;#X;#ot;#Q;#mi;#te;#fr="";#vr="";#br="";#yr="";#wr="";#Cr="";#_r="";#kr="";#xr="";#$r="";#Sr="";#Er=0;#Tr=!1;#Mr=!1;#Nr=!1;#Br=null;#Ir="";constructor(t){this.#H=t,this.#J=t.$,this.#t=t.store,this.#Bo=this.#J.icons,this.#Io=this.#J.lang,this.#O=this.#J.frameRoots,this.#e=this.#J.context,this.#X=this.#J.frameContext,this.#ot=this.#J.options,this.#Q=this.#J.frameOptions,this.#mi=this.#J.eventManager,this.#te=new RegExp(`^(${this.#ot.get("_disallowedExtraTag")})$`,"i")}codeView(t){const e=this.#X;if(!e.get("codeWrapper"))return;if(void 0===t&&(t=!e.get("isCodeView")),t===e.get("isCodeView"))return;t&&e.get("isMarkdownView")&&this.markdownView(!1),e.set("isCodeView",t),this.#J.ui.offCurrentController(),this.#J.ui.offCurrentModal();const s=e.get("codeWrapper"),i=e.get("code"),n=e.get("wysiwygFrame"),o=e.get("wrapper");t?(this.#J.finder.close(),this.#Lr(),s.style.setProperty("display","flex","important"),n.style.display="none",e.get("isFullScreen")?i.style.height="100%":"auto"!==this.#Q.get("height")||this.#ot.get("hasCodeMirror")||(i.style.height=i.scrollHeight>0?i.scrollHeight+"px":"auto"),this.#ot.get("hasCodeMirror")&&this._codeMirrorEditor("refresh",null,null),e.get("isFullScreen")||(this.#J.ui.preventToolbarHide(!0),this.#t.mode.isBalloon&&(this.#e.get("toolbar_arrow").style.display="none",this.#e.get("toolbar_main").style.left="",this.#t.mode.isInline=this.#J.toolbar.isInlineMode=!0,this.#t.mode.isBalloon=this.#J.toolbar.isBalloonMode=!1,this.#J.toolbar._showInline())),this.#t.mode.isBalloon&&this.#J.subToolbar.hide(),On(e),this.#t.set("_range",null),i.focus(),Re.utils.addClass(this.#J.commandDispatcher.targets.get("codeView"),"active"),Re.utils.addClass(o,"se-source-view-status")):(Re.check.isNonEditable(n)||this.#Ar(),n.scrollTop=0,s.style.setProperty("display","none","important"),n.style.display="block","auto"!==this.#Q.get("height")||this.#ot.get("hasCodeMirror")||(e.get("code").style.height="0px"),e.get("isFullScreen")||(this.#J.ui.preventToolbarHide(!1),/balloon/.test(this.#ot.get("mode"))&&(this.#e.get("toolbar_arrow").style.display="",this.#t.mode.isInline=this.#J.toolbar.isInlineMode=!1,this.#t.mode.isBalloon=this.#J.toolbar.isBalloonMode=!0,this.#H._eventOrchestrator._hideToolbar())),this.#J.focusManager.nativeFocus(),Re.utils.removeClass(this.#J.commandDispatcher.targets.get("codeView"),"active"),Re.check.isNonEditable(n)||(this.#J.history.push(!1),this.#J.history.resetButtons(e.get("key"),null)),Re.utils.removeClass(o,"se-source-view-status")),this.#J.ui._updatePlaceholder(e),this.#J.ui._toggleCodeViewButtons(t),e.has("documentType_use_header")&&(t?e.get("documentTypeInner").style.display="none":(e.get("documentTypeInner").style.display="",e.get("documentType").reHeader())),this.#mi.triggerEvent("onToggleCodeView",{frameContext:e,is:e.get("isCodeView")})}markdownView(t){const e=this.#X;if(!e.get("markdownWrapper"))return;if(void 0===t&&(t=!e.get("isMarkdownView")),t===e.get("isMarkdownView"))return;t&&e.get("isCodeView")&&this.codeView(!1),e.set("isMarkdownView",t),this.#J.ui.offCurrentController(),this.#J.ui.offCurrentModal();const s=e.get("markdownWrapper"),i=e.get("markdown"),n=e.get("wysiwygFrame"),o=e.get("wrapper");t?(this.#J.finder.close(),this.#Or(),s.style.setProperty("display","flex","important"),n.style.display="none",e.get("isFullScreen")?i.style.height="100%":"auto"===this.#Q.get("height")&&(i.style.height=i.scrollHeight>0?i.scrollHeight+"px":"auto"),e.get("isFullScreen")||(this.#J.ui.preventToolbarHide(!0),this.#t.mode.isBalloon&&(this.#e.get("toolbar_arrow").style.display="none",this.#e.get("toolbar_main").style.left="",this.#t.mode.isInline=this.#J.toolbar.isInlineMode=!0,this.#t.mode.isBalloon=this.#J.toolbar.isBalloonMode=!1,this.#J.toolbar._showInline())),this.#t.mode.isBalloon&&this.#J.subToolbar.hide(),On(e,"markdown"),this.#t.set("_range",null),i.focus(),Re.utils.addClass(this.#J.commandDispatcher.targets.get("markdownView"),"active"),Re.utils.addClass(o,"se-source-view-status")):(Re.check.isNonEditable(n)||this.#Rr(),n.scrollTop=0,s.style.setProperty("display","none","important"),n.style.display="block","auto"===this.#Q.get("height")&&(i.style.height="0px"),e.get("isFullScreen")||(this.#J.ui.preventToolbarHide(!1),/balloon/.test(this.#ot.get("mode"))&&(this.#e.get("toolbar_arrow").style.display="",this.#t.mode.isInline=this.#J.toolbar.isInlineMode=!1,this.#t.mode.isBalloon=this.#J.toolbar.isBalloonMode=!0,this.#H._eventOrchestrator._hideToolbar())),this.#J.focusManager.nativeFocus(),Re.utils.removeClass(this.#J.commandDispatcher.targets.get("markdownView"),"active"),Re.check.isNonEditable(n)||(this.#J.history.push(!1),this.#J.history.resetButtons(e.get("key"),null)),Re.utils.removeClass(o,"se-source-view-status")),this.#J.ui._updatePlaceholder(e),this.#J.ui._toggleCodeViewButtons(t),e.has("documentType_use_header")&&(t?e.get("documentTypeInner").style.display="none":(e.get("documentTypeInner").style.display="",e.get("documentType").reHeader())),this.#mi.triggerEvent("onToggleMarkdownView",{frameContext:e,is:e.get("isMarkdownView")})}fullScreen(t){const e=this.#X;if(void 0===t&&(t=!e.get("isFullScreen")),t===e.get("isFullScreen"))return;e.set("isFullScreen",t);const s=e.get("topArea"),i=this.#e.get("toolbar_main"),n=e.get("wrapper"),o=e.get("wysiwygFrame"),r=e.get("codeWrapper"),l=e.get("code"),a=e.get("codeNumbers"),h=e.get("markdownWrapper"),c=e.get("markdown"),d=e.get("markdownNumbers"),u=this.#X.get("isCodeView"),p=this.#X.get("isMarkdownView"),g=this.#e.get("toolbar_arrow");this.#J.ui.offCurrentController();const m="none"===i.style.display||this.#t.mode.isInline&&!this.#J.toolbar.inlineToolbarAttr.isShow;if(t){this.#Ir=s.style.cssText,this.#vr=n.style.cssText,this.#br=o.style.cssText,this.#yr=r?.style.cssText,this.#wr=l.style.cssText,this.#Cr=a?.style.cssText,this.#_r=h?.style.cssText,this.#kr=c?.style.cssText,this.#xr=d?.style.cssText,this.#$r=i.style.cssText,g&&(this.#Sr=g.style.cssText),(this.#t.mode.isBalloon||this.#t.mode.isInline)&&(g&&(g.style.display="none"),this.#Nr=this.#t.mode.isInline,this.#Mr=this.#t.mode.isBalloon,this.#t.mode.isInline=this.#J.toolbar.isInlineMode=!1,this.#t.mode.isBalloon=this.#J.toolbar.isBalloonMode=!1),this.#ot.get("toolbar_container")&&(this.#Br=i.parentElement,e.get("container").insertBefore(i,n)),s.style.position="fixed",s.style.top="0",s.style.left="0",s.style.width="100%",s.style.maxWidth="100%",s.style.height="100%",s.style.zIndex="2147483639","none"!==e.get("_stickyDummy").style.display&&""!==e.get("_stickyDummy").style.display&&(this.#Tr=!0,e.get("_stickyDummy").style.display="none",Re.utils.removeClass(i,"se-toolbar-sticky")),this.#fr=An.body.style.overflow,An.body.style.overflow="hidden",n.style.cssText=i.style.cssText="",o.style.cssText=(o.style.cssText.match(/\s?display(\s+)?:(\s+)?[a-zA-Z]+;/)||[""])[0]+this.#Q.get("_defaultStyles").editor+(u||p?"display: none;":""),r&&(r.style.cssText=(r.style.cssText.match(/\s?display(\s+)?:(\s+)?[a-zA-Z]+;/)||[""])[0]+`display: ${u?"flex":"none"} !important;`,r.style.overflow="auto",r.style.height="100%"),h&&(h.style.cssText=(h.style.cssText.match(/\s?display(\s+)?:(\s+)?[a-zA-Z]+;/)||[""])[0]+`display: ${p?"flex":"none"} !important;`,h.style.overflow="auto",h.style.height="100%"),l.style.height="",c&&(c.style.height=""),i.style.width=o.style.height="100%",i.style.position="relative",i.style.display="block",this.#Er=Ln.innerHeight-i.offsetHeight,n.style.height=this.#Er-(e.has("statusbar")?e.get("statusbar").offsetHeight:0)-this.#ot.get("fullScreenOffset")+"px",this.#Q.get("iframe")&&"auto"===this.#Q.get("height")&&(n.style.overflow="auto",this.#J.ui._iframeAutoHeight(e)),e.get("topArea").style.marginTop=this.#ot.get("fullScreenOffset")+"px";const t=this.#Bo.reduction;this.#J.commandDispatcher.applyTargets("fullScreen",(e=>{Re.utils.changeElement(e.firstElementChild,t),Re.utils.addClass(e,"active")}))}else{o.style.cssText=this.#br.replace(/\s?display(\s+)?:(\s+)?[a-zA-Z]+;/,"")+(u||p?"display: none;":""),r&&(r.style.cssText=this.#yr.replace(/\s?display(\s+)?:(\s+)?[a-zA-Z]+;/,"")+`display: ${u?"flex":"none"} !important;`),l.style.cssText=this.#wr,a&&(a.style.cssText=this.#Cr),h&&(h.style.cssText=this.#_r.replace(/\s?display(\s+)?:(\s+)?[a-zA-Z]+;/,"")+`display: ${p?"flex":"none"} !important;`),c&&(c.style.cssText=this.#kr),d&&(d.style.cssText=this.#xr),i.style.cssText=this.#$r,n.style.cssText=this.#vr,s.style.cssText=this.#Ir,g&&(g.style.cssText=this.#Sr),An.body.style.overflow=this.#fr,"auto"!==this.#Q.get("height")||this.#ot.get("hasCodeMirror")||this._codeViewAutoHeight(e.get("code"),e.get("codeNumbers"),!0),this.#Br&&(this.#Br.appendChild(i),this.#Br=null),this.#ot.get("_toolbar_sticky")>-1&&Re.utils.removeClass(i,"se-toolbar-sticky"),this.#Tr&&!this.#ot.get("toolbar_container")&&(this.#Tr=!1,e.get("_stickyDummy").style.display="block",Re.utils.addClass(i,"se-toolbar-sticky")),this.#t.mode.isInline=this.#J.toolbar.isInlineMode=this.#Nr,this.#t.mode.isBalloon=this.#J.toolbar.isBalloonMode=this.#Mr,e.get("isCodeView")||(this.#t.mode.isInline?this.#J.toolbar._showInline():this.#t.mode.isBalloon&&this.#J.toolbar._showBalloon()),this.#J.toolbar._resetSticky(),e.get("topArea").style.marginTop="";const t=this.#Bo.expansion;this.#J.commandDispatcher.applyTargets("fullScreen",(e=>{Re.utils.changeElement(e.firstElementChild,t),Re.utils.removeClass(e,"active")}))}!m||e.get("isCodeView")||e.get("isMarkdownView")||this.#J.toolbar.hide(),this.#mi.triggerEvent("onToggleFullScreen",{frameContext:e,is:e.get("isFullScreen")})}showBlocks(t){const e=this.#X;void 0===t&&(t=!e.get("isShowBlocks")),e.set("isShowBlocks",!!t),t?(Re.utils.addClass(e.get("wysiwyg"),"se-show-block"),Re.utils.addClass(this.#J.commandDispatcher.targets.get("showBlocks"),"active")):(Re.utils.removeClass(e.get("wysiwyg"),"se-show-block"),Re.utils.removeClass(this.#J.commandDispatcher.targets.get("showBlocks"),"active")),this.#J.ui._syncFrameState(e)}_setButtonsActive(){const t=this.#X;if(t.get("isCodeView")?Re.utils.addClass(this.#J.commandDispatcher.targets.get("codeView"),"active"):Re.utils.removeClass(this.#J.commandDispatcher.targets.get("codeView"),"active"),t.get("isFullScreen")){const t=this.#Bo.reduction;this.#J.commandDispatcher.applyTargets("fullScreen",(e=>{Re.utils.changeElement(e.firstElementChild,t),Re.utils.addClass(e,"active")}))}else{const t=this.#Bo.expansion;this.#J.commandDispatcher.applyTargets("fullScreen",(e=>{Re.utils.changeElement(e.firstElementChild,t),Re.utils.removeClass(e,"active")}))}t.get("isMarkdownView")?Re.utils.addClass(this.#J.commandDispatcher.targets.get("markdownView"),"active"):Re.utils.removeClass(this.#J.commandDispatcher.targets.get("markdownView"),"active"),t.get("isShowBlocks")?Re.utils.addClass(this.#J.commandDispatcher.targets.get("showBlocks"),"active"):Re.utils.removeClass(this.#J.commandDispatcher.targets.get("showBlocks"),"active")}print(){const t=Re.utils.createElement("IFRAME",{style:"display: none;"});An.body.appendChild(t);const e=Ln.getComputedStyle(this.#X.get("wysiwyg")).padding,s=this.#ot.get("printTemplate")?this.#ot.get("printTemplate").replace(/\{\{\s*contents\s*\}\}/i,this.#J.html.get()):this.#J.html.get(),i=Re.query.getIframeDocument(t),n=this.#X.get("_wd"),o=this.#ot.get("_rtl")?" se-rtl":"",r=(this.#ot.get("_themeClass")||"").trim(),l=t=>r?t.replace(r,"").trim():t,a=`\n\t\t\t<style>\n\t\t\t\t@page {\n\t\t\t\t\tsize: A4;\n\t\t\t\t\tmargin: ${e};\n\t\t\t\t}\n\t\t\t</style>`;if(this.#Q.get("iframe")){const t=this.#ot.get("printClass")?'class="'+l(this.#ot.get("printClass"))+o+'"':this.#Q.get("iframe_fullPage")?Re.utils.getAttributesToString(n.body,["contenteditable"]).replace(r,""):'class="'+l(this.#ot.get("_editableClass"))+o+'"';i.write(`\n\t\t\t\t<!DOCTYPE html>\n\t\t\t\t<html>\n\t\t\t\t\t<head>\n\t\t\t\t\t\t${n.head.innerHTML}\n\t\t\t\t\t\t${a}\n\t\t\t\t\t</head>\n\t\t\t\t\t<body ${t} style="padding: 0; padding-left: 0; padding-top: 0; padding-right: 0; padding-bottom: 0;">\n\t\t\t\t\t\t${s}\n\t\t\t\t\t</body>\n\t\t\t\t</html>`)}else{const t=An.head.getElementsByTagName("link"),e=An.head.getElementsByTagName("style");let n="";for(let e=0,s=t.length;e<s;e++)n+=t[e].outerHTML;for(let t=0,s=e.length;t<s;t++)n+=e[t].outerHTML;i.write(`\n\t\t\t\t<!DOCTYPE html>\n\t\t\t\t<html>\n\t\t\t\t\t<head>\n\t\t\t\t\t\t${n}\n\t\t\t\t\t\t${a}\n\t\t\t\t\t</head>\n\t\t\t\t\t<body class="${l(this.#ot.get("printClass")||this.#ot.get("_editableClass"))+o}" style="padding: 0; padding-left: 0; padding-top: 0; padding-right: 0; padding-bottom: 0;">\n\t\t\t\t\t\t${s}\n\t\t\t\t\t</body>\n\t\t\t\t</html>`)}this.#J.ui.showLoading(),Ln.setTimeout((()=>{try{if(t.focus(),Le.isEdge||Le.isChromium||"StyleMedia"in Le._w)try{t.contentWindow.document.execCommand("print",!1,null)}catch(e){console.warn("[SUNEDITOR.print.warn]",e),t.contentWindow.print()}else t.contentWindow.print()}catch(t){throw Error(`[SUNEDITOR.print.fail] error: ${t.message}`)}finally{this.#J.ui.hideLoading(),Re.utils.removeItem(t)}}),1e3)}preview(){this.#J.menu.dropdownOff(),this.#J.menu.containerOff(),this.#J.ui.offCurrentController(),this.#J.ui.offCurrentModal();const t=this.#ot.get("previewTemplate")?this.#ot.get("previewTemplate").replace(/\{\{\s*contents\s*\}\}/i,this.#J.html.get({withFrame:!0})):this.#J.html.get({withFrame:!0}),e=Ln.open("","_blank"),s=this.#X.get("_wd"),i=this.#ot.get("_rtl")?" se-rtl":"";if(this.#Q.get("iframe")){const n=this.#ot.get("printClass")?'class="'+this.#ot.get("printClass")+i+'"':this.#Q.get("iframe_fullPage")?Re.utils.getAttributesToString(s.body,["contenteditable"]):'class="'+this.#ot.get("_editableClass")+i+'"';e.document.write(`<!DOCTYPE html>\n\t\t\t\t<html>\n\t\t\t\t\t<head>\n\t\t\t\t\t\t${s.head.innerHTML}\n\t\t\t\t\t\t<style>\n\t\t\t\t\t\t\tbody {overflow:auto !important; height:auto !important;}\n\t\t\t\t\t\t</style>\n\t\t\t\t\t</head>\n\t\t\t\t\t<body ${n}>\n\t\t\t\t\t\t${t}\n\t\t\t\t\t</body>\n\t\t\t\t</html>`)}else{const s=An.head.getElementsByTagName("link"),n=An.head.getElementsByTagName("style");let o="";for(let t=0,e=s.length;t<e;t++)o+=s[t].outerHTML;for(let t=0,e=n.length;t<e;t++)o+=n[t].outerHTML;e.document.write(`<!DOCTYPE html>\n\t\t\t\t<html>\n\t\t\t\t\t<head>\n\t\t\t\t\t\t<meta charset="utf-8" />\n\t\t\t\t\t\t<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">\n\t\t\t\t\t\t<title>${this.#Io.preview}</title>\n\t\t\t\t\t\t${o}\n\t\t\t\t\t</head>\n\t\t\t\t\t<body class="${(this.#ot.get("printClass")?this.#ot.get("printClass"):this.#ot.get("_editableClass"))+i}" style="height:auto">\n\t\t\t\t\t\t${t}\n\t\t\t\t\t</body>\n\t\t\t\t</html>`)}}_resetFullScreenHeight(){if(this.#X.get("isFullScreen"))return this.#Er+=Ln.innerHeight-this.#e.get("toolbar_main").offsetHeight-(this.#X.has("statusbar")?this.#X.get("statusbar").offsetHeight:0)-this.#Er,this.#X.get("wrapper").style.height=this.#Er+"px",!0}_codeMirrorEditor(t,e,s){const i=s?this.#O.get(s).get("options"):this.#Q;switch(t){case"set":i.get("codeMirrorEditor").getDoc().setValue(e);break;case"get":return i.get("codeMirrorEditor").getDoc().getValue();case"readonly":i.get("codeMirrorEditor").setOption("readOnly",e);break;case"refresh":i.get("codeMirrorEditor").refresh()}}_setCodeView(t){this.#ot.get("hasCodeMirror")?this._codeMirrorEditor("set",t,null):this.#X.get("code").value=t}_getCodeView(){return this.#ot.get("hasCodeMirror")?this._codeMirrorEditor("get",null,null):this.#X.get("code").value}_codeViewAutoHeight(t,e,s){s&&(t.style.height=t.scrollHeight+"px"),this.#zr(e,t)}_scrollLineNumbers(t){t.scrollTop=this.scrollTop,t.scrollLeft=this.scrollLeft}_markdownViewAutoHeight(t,e,s){s&&(t.style.height=t.scrollHeight+"px"),this.#zr(e,t)}_scrollMarkdownLineNumbers(t){t.scrollTop=this.scrollTop,t.scrollLeft=this.scrollLeft}#Ar(){const t=this._getCodeView();if(this.#Q.get("iframe_fullPage")){const e=this.#X.get("_wd"),s=(new DOMParser).parseFromString(t,"text/html");if(!this.#te.test("script")){const t=s.head.children;for(let e=0,i=t.length;e<i;e++)/^script$/i.test(t[e].tagName)&&(s.head.removeChild(t[e]),e--,i--)}let i=s.head.innerHTML;s.head.querySelector('link[rel="stylesheet"]')&&("auto"!==this.#Q.get("height")||s.head.querySelector("style"))||(i+=Oe._setIframeStyleLinks(this.#Q.get("iframe_cssFileName"))+Oe._setAutoHeightStyle(this.#Q.get("height"))),e.head.innerHTML=i,e.body.innerHTML=this.#J.html.clean(s.body.innerHTML,{forceFormat:!0,whitelist:null,blacklist:null,_freeCodeViewMode:this.#ot.get("freeCodeViewMode")});const n=s.body.attributes;for(let t=0,s=n.length;t<s;t++)"contenteditable"!==n[t].name&&e.body.setAttribute(n[t].name,n[t].value);if(!Re.utils.hasClass(e.body,"sun-editor-editable")){const t=this.#ot.get("_editableClass").split(" ");for(let s=0;s<t.length;s++)Re.utils.addClass(e.body,t[s])}}else this.#X.get("wysiwyg").innerHTML=t.length>0?this.#J.html.clean(t,{forceFormat:!0,whitelist:null,blacklist:null,_freeCodeViewMode:this.#ot.get("freeCodeViewMode")}):"<"+this.#ot.get("defaultLine")+"><br></"+this.#ot.get("defaultLine")+">"}#Lr(){const t=this.#J.html._convertToCode(this.#X.get("wysiwyg"),!1);let e="";if(this.#Q.get("iframe_fullPage")){const s=Re.utils.getAttributesToString(this.#X.get("_wd").body,null);e="<!DOCTYPE html>\n<html>\n"+this.#X.get("_wd").head.outerHTML.replace(/>(?!\n)/g,">\n")+"<body "+s+">\n"+t+"</body>\n</html>"}else e=t;this._setCodeView(e)}#Or(){const t=Oe.htmlToJson(this.#X.get("wysiwyg").innerHTML),e=Fe.jsonToMarkdown(t);this.#X.get("markdown").value=e}#Rr(){const t=this.#X.get("markdown").value,e=Fe.markdownToHtml(t,this.#ot.get("defaultLine"));this.#X.get("wysiwyg").innerHTML=e.length>0?this.#J.html.clean(e,{forceFormat:!0,whitelist:null,blacklist:null}):"<"+this.#ot.get("defaultLine")+"><br></"+this.#ot.get("defaultLine")+">"}#zr(t,e){if(!t)return;const s=(e.value.match(/\n/g)||[]).length+1;if(s!==(t.value.match(/\n/g)||[]).length){let e="";for(let t=1;t<=s;t++)e+=`${t}\n`;t.value=e}}_destroy(){}},{_d:zn,_w:Pn}=Le;class Dn{#J;#t;#Pr;#Dr;#Fr;#Hr;#qr;#Wr;#Ur;#Vr;#jr;#Gr;#Kr;#Yr;#Xr=!1;#Zr=!0;#Jr=[];#Qr=-1;#tl="";#el={matchCase:!1,wholeWord:!1,regex:!1};#sl;#il=[];#nl=null;#ol=null;#rl=null;#ll=null;#al=null;#hl=!1;static#cl=!1;static#dl(){if(Dn.#cl)return;Dn.#cl=!0;const t=zn.createElement("style");t.textContent="::highlight(se-find-match){background-color:var(--se-find-match-color,rgba(255,213,0,.4));color:inherit}::highlight(se-find-current){background-color:var(--se-find-current-color,rgba(255,150,50,.7));color:inherit}",zn.head.appendChild(t)}constructor(t){if(this.#J=t.$,this.#t=t.store,this.#sl=!!Pn.Highlight&&!!CSS?.highlights,this.#J.options.get("finder_panel")){const t=function({lang:t,icons:e}){const s=`\n\t<div class="se-find-replace-row">\n\t\t<div class="se-find-input-wrapper">\n\t\t\t<input class="se-find-replace-input" type="text" placeholder="${t.find||"Find"}" spellcheck="false" autocomplete="off" />\n\t\t\t<div class="se-find-replace-toggle">\n\t\t\t\t<div class="se-find-replace-info">\n\t\t\t\t\t<span class="se-find-replace-count"></span>\n\t\t\t\t</div>\n\t\t\t\t<button class="se-btn se-find-replace-btn se-find-opt-case" type="button" data-command="opt-case" title="${t.finder_matchCase}">\n\t\t\t\t\t${e.match_case}\n\t\t\t\t</button>\n\t\t\t\t<button class="se-btn se-find-replace-btn se-find-opt-word" type="button" data-command="opt-word" title="${t.finder_wholeWord}">\n\t\t\t\t\t${e.whole_word}\n\t\t\t\t</button>\n\t\t\t\t<button class="se-btn se-find-replace-btn se-find-opt-regex" type="button" data-command="opt-regex" title="${t.finder_regex}">\n\t\t\t\t\t${e.regex}\n\t\t\t\t</button>\n\t\t\t</div>\n\t\t</div>\n\t\t<div class="se-find-replace-buttons">\n\t\t\t<button class="se-btn se-find-replace-btn" type="button" data-command="prev" title="${t.finder_prev}\n(${Le.shiftIcon} + Enter)">\n\t\t\t\t${e.arrow_up_small}\n\t\t\t</button>\n\t\t\t<button class="se-btn se-find-replace-btn" type="button" data-command="next" title="${t.finder_next}\n(Enter)">\n\t\t\t\t${e.arrow_down_small}\n\t\t\t</button>\n\t\t\t<button class="se-btn se-find-replace-btn se-find-toggle-replace" type="button" data-command="toggle-replace" title="${t.replace}">\n\t\t\t\t${e.swap_vert}\n\t\t\t</button>\n\t\t\t<button class="se-btn se-find-replace-btn" type="button" data-command="close" title="${t.close}">\n\t\t\t\t${e.cancel}\n\t\t\t</button>\n\t\t</div>\n\t</div>\n\t<div class="se-find-replace-row se-find-replace-row-replace">\n\t\t<div class="se-find-input-wrapper">\n\t\t\t<input class="se-find-replace-input se-replace-input" type="text" placeholder="${t.replace}" spellcheck="false" autocomplete="off" />\n\t\t</div>\n\t\t<div class="se-find-replace-buttons">\n\t\t\t<button class="se-btn se-find-replace-btn" type="button" data-command="replace" title="${t.replace}\n(Enter)">\n\t\t\t\t${e.replaceText}\n\t\t\t</button>\n\t\t\t<button class="se-btn se-find-replace-btn" type="button" data-command="replace-all" title="${t.replaceAll}">\n\t\t\t\t${e.relaceTextAll}\n\t\t\t</button>\n\t\t</div>\n\t</div>`,i=Re.utils.createElement("DIV",{class:"se-find-replace"},s);return{panel:i,findInput:i.querySelector(".se-find-replace-input"),replaceInput:i.querySelector(".se-replace-input"),countDisplay:i.querySelector(".se-find-replace-count"),replaceRow:i.querySelector(".se-find-replace-row-replace"),btnCase:i.querySelector(".se-find-opt-case"),btnWord:i.querySelector(".se-find-opt-word"),btnRegex:i.querySelector(".se-find-opt-regex"),btnPrev:i.querySelector('[data-command="prev"]'),btnNext:i.querySelector('[data-command="next"]'),btnReplace:i.querySelector('[data-command="replace"]'),btnReplaceAll:i.querySelector('[data-command="replace-all"]')}}(this.#J);this.#Pr=t.panel,this.#Dr=t.findInput,this.#Fr=t.replaceInput,this.#Hr=t.countDisplay,this.#qr=t.replaceRow,this.#Wr=t.btnCase,this.#Ur=t.btnWord,this.#Vr=t.btnRegex,this.#jr=t.btnPrev,this.#Gr=t.btnNext,this.#Kr=t.btnReplace,this.#Yr=t.btnReplaceAll,this.#ul();const e=this.#J.frameRoots.values().next().value.get("container");if(this.#t.mode.isBottom){const t=this.#J.context.get("toolbar_main");e.insertBefore(this.#Pr,t)}else{const t=e.querySelector(".se-wrapper");e.insertBefore(this.#Pr,t)}Le.isResizeObserverSupported&&(this.#rl=new ResizeObserver((()=>this.#pl())).observe(this.#J.context.get("toolbar_main")))}}get isOpen(){return this.#Xr}open(t=!0){const e=this.#J.frameContext;if(!e.get("isCodeView")&&!e.get("isMarkdownView")&&(this.#Xr=!0,Re.utils.addClass(this.#J.commandDispatcher.targets.get("finder"),"active"),this.#gl(),this.#Pr)){this.#jr.disabled=!0,this.#Gr.disabled=!0,this.#Kr.disabled=!0,this.#Yr.disabled=!0,this.#pl();const e=this.#J.selection.get(),s=e&&!e.isCollapsed?e.toString().trim():"";Re.utils.addClass(this.#Pr,"se-find-replace-open"),this.#t.set("_preventBlur",!0),this.#ml(),t&&this.#fl(t),s&&(this.#Dr.value=s),this.#Dr.focus(),this.#Dr.select(),this.#Dr.value&&this.#vl()}}#pl(){if(!this.#Xr||!this.#Pr)return;const t=this.#J.options.get("_toolbar_sticky");this.#t.mode.isBottom?(this.#Pr.style.top="auto",this.#Pr.style.bottom=t>=0?t+this.#J.context.get("toolbar_main").offsetHeight+"px":"0px"):this.#Pr.style.top=t>=0?t+this.#J.context.get("toolbar_main").offsetHeight+"px":"0px"}close(){this.#Xr&&(this.#Xr=!1,Re.utils.removeClass(this.#J.commandDispatcher.targets.get("finder"),"active"),this.#bl(),this.#Jr=[],this.#Qr=-1,this.#yl(),this.#wl(),this.#Pr&&(Re.utils.removeClass(this.#Pr,"se-find-replace-open"),this.#Cl(),this.#t.set("_preventBlur",!1),this.#J.focusManager.nativeFocus()))}findNext(){this.#Xr&&0!==this.#Jr.length&&(this.#Qr=(this.#Qr+1)%this.#Jr.length,this.#_l())}findPrev(){this.#Xr&&0!==this.#Jr.length&&(this.#Qr=(this.#Qr-1+this.#Jr.length)%this.#Jr.length,this.#_l())}search(t,{matchCase:e,wholeWord:s,regex:i}={}){return this.#Xr||this.open(),void 0!==e&&(this.#el.matchCase=e),void 0!==s&&(this.#el.wholeWord=s),void 0!==i&&(this.#el.regex=i),this.#tl=t||"",this.#Dr&&(this.#Dr.value=this.#tl),this.#vl(),this.#Jr.length}replace(t){this.#kl(t)}replaceAll(t){this.#xl(t)}get matchInfo(){return{current:this.#Qr+1,total:this.#Jr.length}}refresh(){this.#Xr&&this.#tl&&!this.#hl&&(this.#hl=!0,this.#$l(),this.#il=[],this.#hl=!1,clearTimeout(this.#ol),this.#ol=setTimeout((()=>this.#vl()),300))}#ml(){this.#Cl(),this.#ll=this.#J.eventManager.addGlobalEvent("keydown",(t=>{"Escape"===t.key&&(t.preventDefault(),t.stopPropagation(),this.close())}),!0)}#Cl(){this.#ll&&=this.#J.eventManager.removeGlobalEvent(this.#ll)}#gl(){this.#wl();const t=this.#J.frameContext.get("wysiwyg");this.#al=new MutationObserver((()=>this.refresh())),this.#al.observe(t,{childList:!0,subtree:!0,characterData:!0})}#wl(){this.#al&&(this.#al.disconnect(),this.#al=null)}#ul(){const t=this.#J.eventManager;t.addEvent(this.#Dr,"input",this.#Sl.bind(this)),t.addEvent(this.#Dr,"keydown",this.#El.bind(this)),t.addEvent(this.#Fr,"keydown",this.#Tl.bind(this)),t.addEvent(this.#Pr,"click",this.#Ml.bind(this)),Le.isGecko&&t.addEvent(this.#Pr,"mousedown",(t=>{if("BUTTON"===t.target.tagName){t.preventDefault();const e=Re.query.getCommandTarget(t.target);e&&this.#J.eventManager._injectActiveEvent(e)}this.#t.set("_preventBlur",!0)}))}#Sl(){this.#J.options.get("finder_liveSearch")&&(clearTimeout(this.#ol),this.#ol=setTimeout((()=>this.#vl()),120))}#El(t){"Escape"===t.key?(t.preventDefault(),this.close()):"Enter"===t.key&&(t.preventDefault(),this.#J.options.get("finder_liveSearch")||this.#Dr.value===this.#tl?t.shiftKey?this.findPrev():this.findNext():this.#vl())}#Tl(t){"Escape"===t.key?(t.preventDefault(),this.close()):"Enter"===t.key&&(t.preventDefault(),this.#kl())}#Ml(t){const e=Re.query.getEventTarget(t),s=Re.query.getCommandTarget(e);if(!s)return;t.preventDefault();switch(s.getAttribute("data-command")){case"prev":this.findPrev();break;case"next":this.findNext();break;case"toggle-replace":this.#fl(!this.#Zr);break;case"close":this.close();break;case"replace":this.#kl();break;case"replace-all":this.#xl();break;case"opt-case":this.#el.matchCase=!this.#el.matchCase,Re.utils.toggleClass(this.#Wr,"on",this.#el.matchCase),this.#vl();break;case"opt-word":this.#el.wholeWord=!this.#el.wholeWord,Re.utils.toggleClass(this.#Ur,"on",this.#el.wholeWord),this.#vl();break;case"opt-regex":this.#el.regex=!this.#el.regex,Re.utils.toggleClass(this.#Vr,"on",this.#el.regex),this.#vl()}}#fl(t){this.#Zr=t,this.#qr.style.display=t?"":"none",Re.utils.toggleClass(this.#Pr.querySelector(".se-find-toggle-replace"),"on",t),t&&this.#Fr.focus()}#vl(){const t=this.#Dr?this.#Dr.value:this.#tl;if(this.#hl=!0,this.#bl(),this.#Jr=[],this.#Qr=-1,!t)return this.#tl="",this.#yl(),void Re.utils.removeClass(this.#Dr,"se-find-no-match");this.#tl=t;const e=this.#J.frameContext.get("wysiwyg");this.#nl=this.#Nl(),this.#Jr=this.#Bl(t,e),this.#Jr.length>0?(this.#Qr=0,this.#Il(),this.#_l(),Re.utils.removeClass(this.#Dr,"se-find-no-match")):this.#Dr&&Re.utils.toggleClass(this.#Dr,"se-find-no-match",t.length>0),this.#yl(),this.#hl=!1}#Bl(t,e){const s=[];if(!t||!e)return s;const i=this.#el.matchCase?"g":"gi";let n;if(this.#el.regex)try{n=new RegExp(t,i)}catch{return s}else{const e=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");n=this.#el.wholeWord?new RegExp(`\\b${e}\\b`,i):new RegExp(e,i)}const o=this.#nl,r=this.#J.format,l=o.createTreeWalker(e,NodeFilter.SHOW_TEXT,null),a=[];let h,c,d="",u=null;for(;h=l.nextNode();){const t=r.getLine(h,null)||e;u&&t!==u&&(d+="\n"),u=t,a.push({node:h,start:d.length}),d+=h.textContent.replace(/\u00A0/g," ")}if(!d)return s;n.lastIndex=0;let p=0;for(;null!==(c=n.exec(d));){if(0===c[0].length){n.lastIndex++;continue}const t=c.index,e=t+c[0].length,i=o.createRange();let r=!1;for(let s=p;s<a.length;s++){const n=a[s],o=n.start+n.node.textContent.length;if(!r&&t>=n.start&&t<o&&(i.setStart(n.node,t-n.start),r=!0,p=s),r&&e>n.start&&e<=o){i.setEnd(n.node,e-n.start);break}}r&&s.push(i)}return s}#Il(){if(0===this.#Jr.length)return;const t=this.#J.frameContext.get("options").get("iframe");this.#sl&&!t?this.#Ll():this.#Al()}#Ll(){Dn.#dl();const t=new Highlight(...this.#Jr);CSS.highlights.set("se-find-match",t),this.#Ol()}#Ol(){if(this.#Qr>=0&&this.#Qr<this.#Jr.length){const t=new Highlight(this.#Jr[this.#Qr]);CSS.highlights.set("se-find-current",t)}else CSS.highlights.delete("se-find-current")}#Al(){this.#$l();const t=this.#nl;for(let e=this.#Jr.length-1;e>=0;e--){const s=this.#Jr[e],i=this.#Rl(t,s,e);for(let t=0;t<i.length;t++)this.#il.push(i[t])}this.#il.reverse(),this.#zl()}#Rl(t,e,s){const i=e.startContainer,n=e.endContainer,o=[];if(i===n)o.push(this.#Pl(t,i,e.startOffset,e.endOffset,s));else{const r=[i];let l=i;for(;l&&l!==n;)l=this.#Dl(l,e.commonAncestorContainer),l&&r.push(l);for(let l=r.length-1;l>=0;l--){const a=r[l],h=a===i?e.startOffset:0,c=a===n?e.endOffset:a.textContent.length;h>=c||o.push(this.#Pl(t,a,h,c,s))}}return o}#Pl(t,e,s,i,n){const o=s>0?e.splitText(s):e;i-s<o.textContent.length&&o.splitText(i-s);const r=t.createElement("mark");return r.className="se-find-mark",r.setAttribute("data-se-find-idx",String(n)),o.parentNode.insertBefore(r,o),r.appendChild(o),r}#Dl(t,e){let s=t;for(;s;){if(s.firstChild)s=s.firstChild;else{for(;s&&!s.nextSibling;)if(s=s.parentNode,s===e)return null;if(!s)return null;s=s.nextSibling}if(3===s.nodeType)return s}return null}#zl(){for(const t of this.#il)Re.utils.removeClass(t,"se-find-current");if(this.#Qr>=0)for(const t of this.#il)t.getAttribute("data-se-find-idx")===String(this.#Qr)&&Re.utils.addClass(t,"se-find-current")}#bl(){const t=this.#J.frameContext.get("options").get("iframe");this.#sl&&!t&&(CSS.highlights.delete("se-find-match"),CSS.highlights.delete("se-find-current")),this.#$l()}#$l(){const t=this.#J.frameContext.get("wysiwyg").querySelectorAll("mark.se-find-mark");if(0!==t.length){for(const e of t){const t=e.parentNode;if(t){for(;e.firstChild;)t.insertBefore(e.firstChild,e);t.removeChild(e),t.normalize()}}this.#il=[]}}#_l(){if(this.#Qr<0||this.#Qr>=this.#Jr.length)return;const t=this.#J.frameContext.get("options").get("iframe");if(this.#sl&&!t){this.#Ol();const t=this.#Jr[this.#Qr];this.#J.selection.scrollTo(t,{behavior:"auto"})}else{this.#zl();const t=this.#il.find((t=>t.getAttribute("data-se-find-idx")===String(this.#Qr)));t&&this.#J.selection.scrollTo(t,{behavior:"auto",noFocus:!0})}this.#yl()}#kl(t){if(this.#Qr<0||0===this.#Jr.length)return;this.#bl();const e=this.#J.frameContext.get("wysiwyg"),s=this.#Bl(this.#tl,e);this.#Qr>=s.length||(this.#Fl(s[this.#Qr],t??(this.#Fr?this.#Fr.value:"")),this.#J.history.push(!1),this.#vl(),this.#Qr>=this.#Jr.length&&this.#Jr.length>0&&(this.#Qr=0,this.#_l()))}#xl(t){if(0===this.#Jr.length)return;this.#bl();const e=this.#J.frameContext.get("wysiwyg"),s=this.#Bl(this.#tl,e);if(0!==s.length){t=t??(this.#Fr?this.#Fr.value:"");for(let e=s.length-1;e>=0;e--)this.#Fl(s[e],t);e.normalize(),this.#J.history.push(!1),this.#vl()}}#Fl(t,e){const s=t.startContainer,i=this.#nl.createTextNode(e);if(s===t.endContainer)return t.deleteContents(),t.insertNode(i),void s.parentNode?.normalize();t.deleteContents(),3===s.nodeType?s.parentNode&&(s.parentNode.insertBefore(i,s.nextSibling),s.parentNode.normalize()):(t.insertNode(i),i.parentNode?.normalize())}#yl(){if(!this.#Pr)return;const t=this.#Jr.length>0;this.#Hr.textContent=t?`${this.#Qr+1}/${this.#Jr.length}`:this.#tl?"0":"",this.#jr.disabled=!t,this.#Gr.disabled=!t,this.#Kr.disabled=!t,this.#Yr.disabled=!t}#Nl(){const t=this.#J.frameContext;return t.get("options").get("iframe")?t.get("_wd"):zn}_destroy(){this.#Cl(),this.#wl(),this.#rl&&=this.#rl.disconnect(),clearTimeout(this.#ol)}}const Fn=Dn;const Hn=class{$;constructor(t){this.$=t.$}},{isMobile:qn,_w:Wn}=Le;function Un(t){const e=Re.query.getEventTarget(t);let s=e;this.$.store.mode.isBalloon&&!this.$.context.get("toolbar_sub_main")?.contains(s)&&this._hideToolbar_sub();const i=Re.check.isInputElement(s);if(i?this.$.store.set("_preventBlur",!1):this.$.frameContext.get("wysiwyg").contains(this.$.selection.getNode())||this.$.focusManager.focus(),Re.query.getParentElement(s,".se-dropdown"))t.stopPropagation(),this.$.ui.preventToolbarHide(!0);else{let n=s.getAttribute("data-command"),o=s.className;for(;s&&!n&&!/(se-menu-list|sun-editor-common|se-menu-tray)/.test(o);)s=s.parentElement,n=s.getAttribute("data-command"),o=s.className;if(i&&/^INPUT$/i.test(s?.getAttribute("data-type"))){if(this.$.store.set("_preventBlur",!0),this._inputFocus=!0,this.$.store.get("hasFocus")||this.applyTagEffect(),!Re.check.isInputElement(e)||e.disabled)return;const t=this.$.plugins[n];if(!t)return;if(this.__inputBlurEvent&&this.__removeInput(),"function"==typeof t.toolbarInputChange&&(this.__inputPlugin={obj:t,target:e,value:e.value}),this.__inputBlurEvent=this.$.eventManager.addEvent(e,"blur",(s=>{if(!t.isInputActive)try{const i=e.value.trim();"function"==typeof t.toolbarInputChange&&i!==this.__inputPlugin.value&&t.toolbarInputChange({target:e,value:i,event:s})}finally{Wn.setTimeout((()=>this._inputFocus=!1),0),this.__removeInput()}})),!t)return;"function"==typeof t.toolbarInputKeyDown&&(this.__inputKeyEvent=this.$.eventManager.addEvent(e,"keydown",(s=>{t.toolbarInputKeyDown({target:e,event:s})})))}else{if(this.__inputBlurEvent&&this.__inputPlugin){const e=this.__inputPlugin.target.value.trim();return e!==this.__inputPlugin.value&&this.__inputPlugin.obj.toolbarInputChange({target:this.__inputPlugin.target,value:e,event:t}),void this.__removeInput()}this.$.frameContext.get("isCodeView")||(qn?this.$.store.set("_preventBlur",!0):(t.preventDefault(),Le.isGecko&&n&&this.$.eventManager._injectActiveEvent(s)))}n!==this.$.menu.currentDropdownName&&n!==this.$.menu.currentContainerName||t.stopPropagation()}}function Vn(t){const e=Re.query.getEventTarget(t),s=Re.query.getCommandTarget(e);if(!s)return;let i=s,n="";for(;i&&!/se-menu-tray/.test(i.className)&&!n;)i=i.parentElement,n=i?.getAttribute("data-key");if(!n)return;const o=this.$.plugins[n];o&&"function"==typeof o.action&&(t.stopPropagation(),o.action(s))}function jn(t){const e=Re.query.getEventTarget(t);this.$.commandDispatcher.runFromTarget(e)}const{_w:Gn}=Le,Kn=new WeakMap;async function Yn(t,e){const s=Re.query.getEventTarget(e);this.$.store.set("_mousedown",!0),this.__onDownEv&&Xn.call(this),this.__onDownEv=this.$.eventManager.addGlobalEvent("mouseup",Xn.bind(this)),t.get("isReadOnly")||Re.check.isNonEditable(t.get("wysiwyg"))||(this.$.format._isExcludeSelectionElement(s)?e.preventDefault():(this._setSelectionSync(),Gn.setTimeout(this.$.selection.init.bind(this.$.selection),0),!1!==await this.$.eventManager.triggerEvent("onMouseDown",{frameContext:t,event:e})&&!1!==await this._callPluginEventAsync("onMouseDown",{frameContext:t,event:e})&&(this.$.store.mode.isBalloon?this._hideToolbar():this.$.store.mode.isSubBalloon&&this._hideToolbar_sub(),/FIGURE/i.test(s?.nodeName)&&e.preventDefault())))}function Xn(){this.$.store.set("_mousedown",!1),this.__onDownEv=this.$.eventManager.removeGlobalEvent(this.__onDownEv)}async function Zn(t,e){!1!==await this.$.eventManager.triggerEvent("onMouseUp",{frameContext:t,event:e})&&await this._callPluginEventAsync("onMouseUp",{frameContext:t,event:e})}async function Jn(t,e){const s=Re.query.getEventTarget(e);if(t.get("isReadOnly"))return e.preventDefault(),Re.check.isAnchor(s)&&Gn.open(s.href,s.target),!1;if(Re.check.isNonEditable(t.get("wysiwyg")))return;if(!1===await this.$.eventManager.triggerEvent("onClick",{frameContext:t,event:e}))return;if(!1===await this._callPluginEventAsync("onClick",{frameContext:t,event:e}))return;const i=this.$.component.get(s);if(i)return e.preventDefault(),void this.$.component.select(i.target,i.pluginName);if(this.$.selection.init(),3===e.detail){const t=this.$.selection.getRange();this.$.format.isLine(t.endContainer)&&0===t.endOffset&&this.$.selection.setRange(t.startContainer,t.startOffset,t.startContainer,t.startContainer.textContent.length)}const n=this.$.selection.getNode(),o=this.$.format.getLine(n,null),r=this.$.format.getBlock(n,null);if(!o&&!Re.check.isNonEditable(s)&&!Re.check.isList(r)){const t=this.$.selection.getRange();if(this.$.format.getLine(t.startContainer)===this.$.format.getLine(t.endContainer))if(Re.check.isList(r)){e.preventDefault();const t=n.nextElementSibling,s=Re.utils.createElement("LI",null,n);r.insertBefore(s,t),this.$.focusManager.focus()}else Re.check.isWysiwygFrame(n)||this.$.component.is(n)||Re.check.isTableElements(n)&&!Re.check.isTableCell(n)||null===this._setDefaultLine(this.$.format.isBlock(r)?"DIV":this.$.options.get("defaultLine"))||(e.preventDefault(),this.$.focusManager.focus())}this.$.commandDispatcher._copyFormat(),(this.$.store.mode.isBalloon||this.$.store.mode.isSubBalloon)&&Gn.setTimeout(this._toggleToolbarBalloon.bind(this),0)}function Qn(t,e){if(t.get("isReadOnly")||t.get("isDisabled"))return!1;let s=Kn.get(t);s||(s={rafId:null,event:null},Kn.set(t,s)),s.event=e,null===s.rafId&&(s.rafId=Gn.requestAnimationFrame((()=>{const e=s.event;if(s.rafId=null,s.event=null,!e)return;const i=Re.query.getEventTarget(e);!1===yi.get("__overInfo")||this.$.ui.selectMenuOn||this.$.component.hoverSelect(i),this.$.ui.blockHandle?.positionForTarget(i,e.clientY),this._callPluginEvent("onMouseMove",{frameContext:t,event:e})})))}async function to(t,e){this.$.ui.blockHandle?.hide(e),!1!==await this.$.eventManager.triggerEvent("onMouseLeave",{frameContext:t,event:e})&&await this._callPluginEventAsync("onMouseLeave",{frameContext:t,event:e})}const eo={"event.prevent":({ctx:t})=>t.e.preventDefault(),"event.stop":({ctx:t})=>t.e.stopPropagation(),"event.prevent.stop":({ctx:t})=>{t.e.preventDefault(),t.e.stopPropagation()},"cache.styleNode":({ports:t})=>t.styleNodeCache(),"cache.formatAttrsTemp":({ports:t},{attrs:e})=>t.formatAttrsTempCache(e),"focusManager.nativeFocus":({ports:t})=>t.focusManager.nativeFocus(),"history.push":({ports:t},e)=>t.history.push(e),"documentType.refreshHeader":({ctx:t})=>{o.setTimeout((()=>{t.fc.get("documentType").reHeader()}),0)},"component.deselect":({ports:t})=>t.component.deselect(),"selection.setRange":({ports:t},{sc:e,so:s,ec:i,eo:n})=>t.selection.setRange(e,s,i,n),"format.removeBlock":({ports:t},{rangeEl:e,selectedFormats:s,newBlockElement:i,shouldDelete:n,skipHistory:o})=>t.format.removeBlock(e,{selectedFormats:s,newBlockElement:i,shouldDelete:n,skipHistory:o}),"dom.utils.removeItem":(t,{item:e})=>Re.utils.removeItem(e),"select.component.fallback":({ports:t},{cmponentInfo:e})=>{!1===t.component.select(e.target,e.pluginName)&&t.focusManager.blur()}},so={"del.format.removeAndMove":({ports:t},{container:e,formatEl:s})=>{const i=t.html.remove();if(i.commonCon!==i.container&&s.parentElement)if(s.contains(e)){const e=function(t){const e=t.lastChild,s=t.nextElementSibling;if(!s)return e;if(Re.check.isZeroWidth(s))return Re.utils.removeItem(s),e;const i=s.childNodes;for(;i[0];)t.appendChild(i[0]);return Re.utils.removeItem(s),e}(s);t.selection.setRange(e,e.textContent.length,e,e.textContent.length)}else{const{focusNode:e,focusOffset:i}=function(t){const e=t.childNodes,s=t.previousElementSibling;let i=e[0],n=0;if(!s)return{focusNode:i,focusOffset:n};if(Re.check.isZeroWidth(s))return Re.utils.removeItem(s),{focusNode:i,focusOffset:n};if(e.length>1||e[0]?.textContent.length>0)for(;e[0];)s.appendChild(e[0]);else i=s.lastChild,n=i.textContent.length;return Re.utils.removeItem(t),{focusNode:i,focusOffset:n}}(s);t.selection.setRange(e,i,e,i)}},"backspace.brline.strip":({ctx:t,ports:e},{formatEl:s})=>{const i=t.options.get("defaultLine"),n=s.parentNode,o=Re.utils.createElement(i);for(;s.firstChild&&!Re.check.isBreak(s.firstChild);)o.appendChild(s.firstChild);s.firstChild&&Re.check.isBreak(s.firstChild)&&s.removeChild(s.firstChild),o.firstChild||(o.innerHTML="<br>"),n.insertBefore(o,s),s.firstChild&&(s.textContent.trim()||s.querySelector("br"))||n.removeChild(s);const r=o.firstChild;e.selection.setRange(r,0,r,0)},"backspace.format.maintain":({ctx:t},{formatEl:e})=>{if(e.nodeName.toUpperCase()===t.options.get("defaultLine").toUpperCase()){e.innerHTML="<br>";const t=e.attributes;for(;t[0];)e.removeAttribute(t[0].name)}else e.parentNode.replaceChild(Re.utils.createElement(t.options.get("defaultLine"),null,"<br>"),e)},"backspace.component.select":({ports:t},{selectionNode:e,range:s,fileComponentInfo:i})=>{let n=null;Re.check.isBreak(e)?Re.utils.removeItem(e):Re.check.isBreak(n=s.startContainer.childNodes?.[s.startOffset])&&Re.utils.removeItem(n),!1===t.component.select(i.target,i.pluginName)&&t.focusManager.blur()},"backspace.component.remove":({ports:t},{isList:e,sel:s,formatEl:i,fileComponentInfo:n})=>{e&&Re.utils.removeItem(s),0===i.textContent.length&&Re.utils.removeItem(i),!1===t.component.select(n.target,n.pluginName)&&t.focusManager.blur()},"backspace.list.mergePrev":({ports:t},{prev:e,formatEl:s,rangeEl:i})=>{let n=e===i.parentNode?i.previousSibling:e.lastChild;n||(n=Re.utils.createTextNode(Ae.zeroWidthSpace),i.parentNode.insertBefore(n,i.parentNode.firstChild));const o=3===n.nodeType?n.textContent.length:1,r=s.childNodes;let l=n,a=r[0];for(;a=r[0];)e.insertBefore(a,l.nextSibling),l=a;Re.utils.removeItem(s),0===i.children.length&&Re.utils.removeItem(i),t.selection.setRange(n,o,n,o)},"backspace.list.removeNested":({ports:t},{range:e})=>{t.html.remove(),3===e.startContainer.nodeType&&t.selection.setRange(e.startContainer,e.startContainer.textContent.length,e.startContainer,e.startContainer.textContent.length)},"backspace.emptyLine.mergePrev":({ports:t},{formatEl:e,prev:s})=>{Re.utils.removeItem(e),io(t,s,!0)},"backspace.brline.rowMerge":({ports:t},{rowEndBr:e,rowStartBr:s})=>{const i=s.nextSibling;i!==e&&3===i?.nodeType&&Re.check.isZeroWidth(i)&&Re.utils.removeItem(i);const n=s.previousSibling;if(Re.utils.removeItem(s),n&&3===n.nodeType)t.selection.setRange(n,n.textContent.length,n,n.textContent.length);else if(Re.check.isBreak(n))t.selection.setRange(e,0,e,0);else{const s=e.parentNode;t.selection.setRange(s,0,s,0)}},"backspace.softBreak.merge":({ports:t},{zws:e})=>{const s=e.previousSibling,i=e.parentNode,n=s?.previousSibling;Re.utils.removeItem(e),s&&Re.utils.removeItem(s),n?no(t,n):i&&t.selection.setRange(i,0,i,0)},"delete.component.select":({ports:t},{formatEl:e,fileComponentInfo:s})=>{if(Re.check.isListCell(e)){const t=s.container.previousSibling;Re.check.isZeroWidth(t)&&Re.utils.removeItem(t)}else Re.check.isZeroWidth(e)&&Re.utils.removeItem(e);!1===t.component.select(s.target,s.pluginName)&&t.focusManager.blur()},"delete.component.selectNext":({ports:t,ctx:e},{formatEl:s,nextEl:i})=>{if(Re.check.isZeroWidth(s)&&(Re.utils.removeItem(s),Re.check.isTable(i))){let e=Re.query.getEdgeChild(i,Re.check.isTableCell,!1);return e=e.firstElementChild||e,void t.selection.setRange(e,0,e,0)}const n=t.component.get(i);n?(e.e.stopPropagation(),!1===t.component.select(n.target,n.pluginName)&&t.focusManager.blur()):t.component.is(i)&&(e.e.stopPropagation(),Re.utils.removeItem(i))},"delete.list.removeNested":({ports:t,ctx:e},{range:s,formatEl:i,rangeEl:n})=>{s.startContainer!==s.endContainer&&t.html.remove();const o=Re.utils.arrayFind(i.children,Re.check.isList)||i.nextElementSibling||n.parentElement.nextElementSibling;if(o&&(Re.check.isList(o)||Re.utils.arrayFind(o.children,Re.check.isList))){let s,n;if(e.e.preventDefault(),Re.check.isList(o)){const t=o.firstElementChild;for(n=t.childNodes,s=n[0];n[0];)i.insertBefore(n[0],o);Re.utils.removeItem(t)}else{for(s=o.firstChild,n=o.childNodes;n[0];)i.appendChild(n[0]);Re.utils.removeItem(o)}t.selection.setRange(s,0,s,0),t.history.push(!0)}},"delete.emptyLine.mergeNext":({ports:t},{formatEl:e,next:s})=>{Re.utils.removeItem(e),io(t,s,!1)},"line.merge":({ports:t},{into:e,from:s})=>{const i=t.format,n=s.parentElement;oo(e);const o=e.lastChild;for(oo(s);s.firstChild;)e.appendChild(s.firstChild);Re.utils.removeItem(s);let r=n;for(;r&&r!==e.parentElement&&i.isBlock(r)&&!i.isClosureBlock(r)&&Re.check.isZeroWidth(r);){const t=r.parentElement;Re.utils.removeItem(r),r=t}e.firstChild||e.appendChild(Re.utils.createElement("BR")),o?no(t,o):t.selection.setRange(e,0,e,0)},"delete.brline.rowMerge":({ports:t},{rowEndBr:e})=>{let s=e.nextSibling;3===s?.nodeType&&Re.check.isZeroWidth(s)&&(s=s.nextSibling);const i=e.parentNode;Re.utils.removeItem(e),s&&(3===s.nodeType||Re.check.isBreak(s))?t.selection.setRange(s,0,s,0):t.selection.setRange(i,i.childNodes.length,i,i.childNodes.length)},"delete.softBreak.merge":({ports:t},{br:e})=>{const s=e.previousSibling,i=e.parentNode,n=e.nextSibling;n&&3===n.nodeType&&Re.check.isZeroWidth(n.textContent)&&Re.utils.removeItem(n),Re.utils.removeItem(e),s?no(t,s):i&&t.selection.setRange(i,0,i,0)},"tab.format.indent":({ports:t,ctx:e},{range:s,formatEl:i,shift:n})=>{const o=t.format.getLines(null),r=[],l=[],a=Re.check.isListCell(o[0]),h=Re.check.isListCell(o.at(-1));let c={sc:s.startContainer,so:s.startOffset,ec:s.endContainer,eo:s.endOffset};for(let t,e=0,s=o.length;e<s;e++)if(t=o[e],Re.check.isListCell(t)){if(!t.previousElementSibling&&!n)continue;r.push(t)}else l.push(t);if(r.length>0&&(c=t.listFormat.applyNested(r,n)),l.length>0)if(n){const t=l.length-1;for(let e,s=0;s<=t;s++){e=l[s].childNodes;for(let t,s=0,i=e.length;s<i&&(t=e[s],t);s++)if(!Re.check.isZeroWidth(t)){/^\s{1,4}$/.test(t.textContent)?Re.utils.removeItem(t):/^\s{1,4}/.test(t.textContent)&&(t.textContent=t.textContent.replace(/^\s{1,4}/,""));break}}const e=Re.query.getEdgeChild(l[0],"text",!1),s=Re.query.getEdgeChild(l[t],"text",!0);!a&&e&&(c.sc=e,c.so=0),!h&&s&&(c.ec=s,c.eo=s.textContent.length)}else if(1===l.length){let n=e.store.get("tabSize")+1;if(e.options.get("syncTabIndent")){const e=Re.query.findTextIndexOnLine(i,s.startContainer,s.startOffset,(e=>t.component.is(e))),o=t.format.isLine(i.previousElementSibling)?Re.query.findTabEndIndex(i.previousElementSibling,e,2):0;o>e&&(n=o-e)}const o=Re.utils.createTextNode(new Array(n).join(" "));if(!t.html.insertNode(o,{afterNode:null,skipCharCount:!1}))return!1;a||(c.sc=o,c.so=o.length),h||(c.ec=o,c.eo=o.length)}else{const t=Re.utils.createTextNode(new Array(e.store.get("tabSize")+1).join(" ")),s=l.length-1;for(let e,i=0;i<=s;i++)e=l[i].firstChild,e&&(Re.check.isBreak(e)?l[i].insertBefore(t.cloneNode(!1),e):e.textContent=t.textContent+e.textContent);const i=Re.query.getEdgeChild(l[0],"text",!1),n=Re.query.getEdgeChild(l[s],"text",!0);!a&&i&&(c.sc=i,c.so=0),!h&&n&&(c.ec=n,c.eo=n.textContent.length)}t.selection.setRange(c.sc,c.so,c.ec,c.eo)},"caret.scrollTo":({ports:t},{range:e})=>{t.caretScrollTo(e)},"enter.line.addDefault":({ports:t},{formatEl:e})=>{const s=t.format.addLineAfter(e).firstChild;t.selection.setRange(s,0,s,0)},"enter.list.addItem":({ports:t},{formatEl:e,selectionNode:s})=>{const i=Re.utils.createElement("BR"),n=Re.utils.createElement("LI",null,i);e.parentNode.insertBefore(n,e.nextElementSibling),n.appendChild(s.nextSibling),t.selection.setRange(i,1,i,1)},"enter.format.exitEmpty":({ports:t,ctx:e},{formatEl:s,rangeEl:i})=>{let n=null;if(Re.check.isListCell(i.parentElement)){const t=s.parentNode.parentElement;i=t.parentElement;const o=Re.utils.createElement("LI");o.innerHTML="<br>",Re.utils.copyTagAttributes(o,s,e.options.get("lineAttrReset")),n=o,i.insertBefore(n,t.nextElementSibling)}else{let o;o=Re.check.isTableCell(i.parentElement)?"DIV":Re.check.isList(i.parentElement)?"LI":t.format.isLine(i.nextElementSibling)?i.nextElementSibling.nodeName:t.format.isLine(i.previousElementSibling)?i.previousElementSibling.nodeName:e.options.get("defaultLine"),n=Re.utils.createElement(o);const r=t.format.removeBlock(i,{selectedFormats:[s],newBlockElement:null,shouldDelete:!0,skipHistory:!0});r.cc.insertBefore(n,r.sc?r.sc.nextSibling:r.cc.firstChild)}n.innerHTML="<br>",t.nodeTransform.removeAllParents(s,null,null),t.selection.setRange(n,1,n,1)},"enter.format.cleanBrAndZWS":({ports:t},{selectionNode:e,selectionFormat:s,brBlock:i,children:n,offset:o})=>{s?Re.utils.removeItem(n[o-1]):Re.utils.removeItem(e);const r=i.nextElementSibling,l=t.format.addLine(i,t.format.isLine(r)?r:null);Re.utils.copyFormatAttributes(l,i),t.selection.setRange(l,1,l,1)},"enter.format.insertBrHtml":({ports:t},{brBlock:e,range:s,wSelection:i,offset:n})=>{t.html.insert(s.collapsed&&Re.check.isBreak(s.startContainer.childNodes[s.startOffset-1])?"<br>":"<br><br>",{selectInserted:!1,skipCharCount:!0,skipCleaning:!0});let o=i.focusNode;const r=i.focusOffset;e===o&&(o=o.childNodes[r-n>1?r-1:r]),t.selection.setRange(o,1,o,1),t.setOnShortcutKey(!0)},"enter.brline.insert":({ports:t},{range:e})=>{t.selection.setRange(e.startContainer,e.startOffset,e.endContainer,e.endOffset),e.collapsed||t.html.remove();const s=Re.utils.createElement("BR");t.html.insertNode(s,{afterNode:null,skipCharCount:!0}),s.nextSibling||s.parentNode.appendChild(Re.utils.createElement("BR"));const i=s.nextSibling;t.selection.setRange(i,0,i,0),t.setOnShortcutKey(!0)},"enter.shift.br":({ports:t,ctx:e},{range:s})=>{const i=e.fc.get("_wd"),n=t.selection.get(),o=n?.rangeCount>0&&e.fc.get("wysiwyg").contains(n.focusNode)?n.getRangeAt(0):s,r=i.createRange();if(r.setStart(o.startContainer,o.startOffset),r.setEnd(o.endContainer,o.endOffset),o.collapsed||(r.deleteContents(),r.collapse(!0)),1===r.startContainer.nodeType&&Re.check.isBreak(r.startContainer)){const t=r.startContainer;r.setStart(t.parentNode,Re.utils.getArrayIndex(t.parentNode.childNodes,t)+r.startOffset),r.collapse(!0)}const l=Re.utils.createElement("BR");r.insertNode(l);const a=l.nextSibling;if(a&&3===a.nodeType&&!Re.check.isZeroWidth(a.textContent))t.selection.setRange(a,0,a,0);else{const e=Re.utils.createTextNode(Ae.zeroWidthSpace);l.parentNode.insertBefore(e,l.nextSibling),t.selection.setRange(e,1,e,1)}t.history.push(!1)},"enter.brline.exit":({ports:t},{brBlock:e})=>{const s=e.lastChild;s&&(Re.check.isBreak(s)||Re.check.isZeroWidth(s.textContent))&&Re.utils.removeItem(s);const i=e.nextElementSibling,n=t.format.addLine(e,t.format.isLine(i)?i:null);Re.utils.copyFormatAttributes(n,e),t.selection.setRange(n,1,n,1)},"enter.format.insertBrNode":({ports:t},{wSelection:e})=>{const s=e.focusNode.nextSibling,i=Re.utils.createElement("BR");t.html.insertNode(i,{afterNode:null,skipCharCount:!0});const n=i.previousSibling,o=i.nextSibling;Re.check.isBreak(s)||Re.check.isBreak(n)||o&&!Re.check.isZeroWidth(o)?t.selection.setRange(o,0,o,0):(i.parentNode.insertBefore(i.cloneNode(!1),i),t.selection.setRange(i,1,i,1)),t.setOnShortcutKey(!0)},"enter.format.breakAtEdge":({ports:t,ctx:e},{formatEl:s,selectionNode:i,formatStartEdge:n,formatEndEdge:o,bidiSwapped:r})=>{const l=Re.utils.createElement("BR"),a=Re.utils.createElement(s.nodeName,null,l);Re.utils.copyTagAttributes(a,s,e.options.get("lineAttrReset"));let h=l;if(!o||!e.options.get("lineBreakClearStyle")){let t=i;do{if(!Re.check.isBreak(t)&&1===t.nodeType){const e=t.cloneNode(!1);e.appendChild(h),h=e}t=t.parentElement}while(s!==t&&s.contains(t))}if(a.appendChild(h),s.parentNode.insertBefore(a,n&&!o?s:s.nextElementSibling),o)t.selection.setRange(l,1,l,1);else if(r)t.selection.setRange(s,1,s,1);else{const e=s.firstChild||s;t.selection.setRange(e,0,e,0)}},"enter.format.breakWithSelection":({ports:t,ctx:e},{formatEl:s,range:i,formatStartEdge:n,formatEndEdge:o})=>{const r=t.format.getLine(i.startContainer,null)!==t.format.getLine(i.endContainer,null),l=s.cloneNode(!1);l.innerHTML="<br>";const a=i.commonAncestorContainer,h=a===i.startContainer&&a===i.endContainer&&Re.check.isZeroWidth(a)?{container:a,offset:i.endOffset,prevContainer:a.previousElementSibling,commonCon:a}:t.html.remove();let c=t.format.getLine(h.container,null),d=0;if(!c)return void(Re.check.isWysiwygFrame(h.container)&&(t.enterPrevent(e.e),e.fc.get("wysiwyg").appendChild(l),c=l,Re.utils.copyTagAttributes(c,s,e.options.get("lineAttrReset")),t.selection.setRange(c,d,c,d)));const u=t.format.getBlock(h.container);c=c.contains(u)?Re.query.getEdgeChild(u,(e=>Boolean(t.format.getLine(e))),!1):c,r?o&&!n?(c.parentNode.insertBefore(l,h.prevContainer&&h.container!==h.prevContainer?c:c.nextElementSibling),c=l,d=0):(d=h.offset,n&&(c.parentNode.insertBefore(l,c),o&&(d=0))):o&&n?(c.parentNode.insertBefore(l,c),d=0):o?(c=c.parentNode.insertBefore(l,c.nextElementSibling),c=l,d=0):c=t.nodeTransform.split(h.container,h.offset,Re.query.getNodeDepth(s)),t.enterPrevent(e.e),Re.utils.copyTagAttributes(c,s,e.options.get("lineAttrReset")),t.selection.setRange(c,d,c,d)},"enter.format.breakAtCursor":({ports:t,ctx:e},{formatEl:s,range:i})=>{let n=null;n=Re.check.isZeroWidth(s)?t.format.addLine(s,s.cloneNode(!1)):t.nodeTransform.split(i.endContainer,i.endOffset,Re.query.getNodeDepth(s)),t.enterPrevent(e.e),Re.utils.copyTagAttributes(n,s,e.options.get("lineAttrReset")),t.selection.setRange(n,0,n,0)},"enter.figcaption.exitInList":({ports:t},{formatEl:e})=>{const s=t.format.addLine(e,null);t.selection.setRange(s,0,s,0)},"keydown.input.insertNbsp":({ports:t})=>{const e=t.html.insertNode(Re.utils.createTextNode(" "),{afterNode:null,skipCharCount:!0});e&&t.selection.setRange(e,e.length,e,e.length)},"keydown.input.insertZWS":({ports:t})=>{const e=Re.utils.createTextNode(Ae.zeroWidthSpace);t.html.insertNode(e,{afterNode:null,skipCharCount:!0}),t.selection.setRange(e,1,e,1)}};function io(t,e,s){const i=s?e.childNodes.length:0;t.selection.setRange(e,i,e,i)}function no(t,e){const s=3===e.nodeType?e.textContent.length:e.childNodes.length;t.selection.setRange(e,s,e,s)}function oo(t){let e=t.lastChild;for(;e&&(Re.check.isBreak(e)||3===e.nodeType&&Re.check.isZeroWidth(e));){const t=e.previousSibling;Re.utils.removeItem(e),e=t}}async function ro(t,e){const s={...eo,...so};for(const i of t){if("action.stop"===i.t)return!1;const t=s[i.t];if(t){if(!1===await t(e,i.p))return!1}}}function lo(t){const e=t.selection.getRange(),s=e.startContainer,i=e.endContainer,n=t.format.getBlock(s),o=t.format.getBlock(i),r=Re.check.isTableCell(n),l=Re.check.isTableCell(o);if((r&&!n.previousElementSibling&&!n.parentElement.previousElementSibling||l&&!o.nextElementSibling&&!o.parentElement.nextElementSibling)&&n!==o){const s=Re.query.getParentElement(e.commonAncestorContainer,Re.check.isFigure)?.parentElement||e.commonAncestorContainer;if(r){if(l)return Re.utils.removeItem(Re.query.getParentElement(n,(t=>s===t.parentNode))),t.focusManager.nativeFocus(),!0;Re.utils.removeItem(Re.query.getParentElement(n,(t=>s===t.parentNode)))}else Re.utils.removeItem(Re.query.getParentElement(o,(t=>s===t.parentNode)))}const a=1===s.nodeType?Re.query.getParentElement(s,".se-component"):null,h=1===i.nodeType?Re.query.getParentElement(i,".se-component"):null;return a&&Re.utils.removeItem(a),h&&Re.utils.removeItem(h),!1}function ao(t,e,s){const i=s?e.startContainer:e.endContainer,n=s?e.startOffset:e.endOffset,o=s?"previousSibling":"nextSibling";let r;return 1===i.nodeType?(r=ho(t,i.childNodes[n],o,i),Re.check.isComponentContainer(r)||Re.check.isNonEditable(r)?r:null):(r=ho(t,i,o,i),Re.check.isEdgePoint(i,n,s?"front":"end")&&(Re.check.isComponentContainer(r)||Re.check.isNonEditable(r))?r:null)}function ho(t,e,s,i){if(!e)return null;let n=e[s];if(!n){if(n=t.format.getLine(i),n=n?n[s]:null,!n||t.component.is(n))return null;n="previousSibling"===s?n.firstChild:n.lastChild}return n}function co(t,e,s,i){if(!t.collapsed||!e)return!1;const n=t.getBoundingClientRect();if(n.height<=0)return!1;const o=i.createRange();o.selectNodeContents(e);const r=o.getBoundingClientRect();return!(r.width<=2)&&("front"===s?n.left<=r.left+2:n.left>=r.right-2)}const uo=()=>({t:"event.prevent"}),po=()=>({t:"event.prevent.stop"}),go=()=>({t:"cache.styleNode"}),mo=t=>({t:"cache.formatAttrsTemp",p:{attrs:t}}),fo=()=>({t:"component.deselect"}),vo=()=>({t:"focusManager.nativeFocus"}),bo=t=>({t:"history.push",p:t}),yo=()=>({t:"documentType.refreshHeader"}),wo=(t,e,s,i,n)=>({t:"format.removeBlock",p:{rangeEl:t,selectedFormats:e,newBlockElement:s,shouldDelete:i,skipHistory:n}}),Co=t=>({t:"dom.utils.removeItem",p:{item:t}}),_o=t=>({t:"select.component.fallback",p:{cmponentInfo:t}}),ko=(t,e)=>({t:"del.format.removeAndMove",p:{container:t,formatEl:e}}),xo=t=>({t:"backspace.format.maintain",p:{formatEl:t}}),$o=t=>({t:"backspace.brline.strip",p:{formatEl:t}}),So=(t,e,s)=>({t:"backspace.component.select",p:{selectionNode:t,range:e,fileComponentInfo:s}}),Eo=(t,e,s,i)=>({t:"backspace.component.remove",p:{isList:t,sel:e,formatEl:s,fileComponentInfo:i}}),To=(t,e,s)=>({t:"backspace.list.mergePrev",p:{prev:t,formatEl:e,rangeEl:s}}),Mo=t=>({t:"backspace.list.removeNested",p:{range:t}}),No=(t,e)=>({t:"backspace.emptyLine.mergePrev",p:{formatEl:t,prev:e}}),Bo=(t,e)=>({t:"backspace.brline.rowMerge",p:{rowEndBr:t,rowStartBr:e}}),Io=t=>({t:"backspace.softBreak.merge",p:{zws:t}}),Lo=(t,e)=>({t:"delete.component.select",p:{formatEl:t,fileComponentInfo:e}}),Ao=(t,e)=>({t:"delete.component.selectNext",p:{formatEl:t,nextEl:e}}),Oo=(t,e,s)=>({t:"delete.list.removeNested",p:{range:t,formatEl:e,rangeEl:s}}),Ro=(t,e)=>({t:"delete.emptyLine.mergeNext",p:{formatEl:t,next:e}}),zo=t=>({t:"delete.brline.rowMerge",p:{rowEndBr:t}}),Po=t=>({t:"delete.softBreak.merge",p:{br:t}}),Do=(t,e)=>({t:"line.merge",p:{into:t,from:e}}),Fo=(t,e,s)=>({t:"tab.format.indent",p:{range:t,formatEl:e,shift:s}}),Ho=t=>({t:"caret.scrollTo",p:{range:t}}),qo=t=>({t:"enter.line.addDefault",p:{formatEl:t}}),Wo=(t,e)=>({t:"enter.list.addItem",p:{formatEl:t,selectionNode:e}}),Uo=(t,e)=>({t:"enter.format.exitEmpty",p:{formatEl:t,rangeEl:e}}),Vo=(t,e,s,i)=>({t:"enter.format.insertBrHtml",p:{brBlock:t,range:e,wSelection:s,offset:i}}),jo=t=>({t:"enter.format.insertBrNode",p:{wSelection:t}}),Go=t=>({t:"enter.brline.insert",p:{range:t}}),Ko=t=>({t:"enter.shift.br",p:{range:t}}),Yo=t=>({t:"enter.brline.exit",p:{brBlock:t}}),Xo=(t,e,s,i,n)=>({t:"enter.format.breakAtEdge",p:{formatEl:t,selectionNode:e,formatStartEdge:s,formatEndEdge:i,bidiSwapped:n}}),Zo=(t,e,s,i)=>({t:"enter.format.breakWithSelection",p:{formatEl:t,range:e,formatStartEdge:s,formatEndEdge:i}}),Jo=(t,e)=>({t:"enter.format.breakAtCursor",p:{formatEl:t,range:e}}),Qo=t=>({t:"enter.figcaption.exitInList",p:{formatEl:t}}),tr=()=>({t:"keydown.input.insertNbsp"}),er=()=>({t:"keydown.input.insertZWS"});function sr(t,e,s){const{format:i,component:n}=e,{fc:o,options:r,range:l,selectionNode:a}=s;let{formatEl:h}=s;const c=!l.collapsed||l.startContainer!==l.endContainer,d=r.get("_rtl")&&!c&&0===l.startOffset&&co(l,h,"front",o.get("_wd"));if(t.push(fo()),t.push(go()),c&&lo(e))return t.push(po()),t.push(Ho(l)),!0;if(!(i.isNormalLine(h)||i.isBrLine(h)||o.get("wysiwyg").firstElementChild||n.is(a)||null===function(t,e){return t.setDefaultLine(e)}(e,r.get("defaultLine"))))return t.push(po()),!1;if(i.isLine(h)&&c&&Re.check.isEdgePoint(l.startContainer,l.startOffset,"front")&&(!l.startContainer.previousSibling||Re.check.isZeroWidth(l.startContainer.previousSibling))&&i.getLine(l.startContainer)!==i.getLine(l.endContainer)&&(i.isLine(h.previousElementSibling)||Re.check.isListCell(h)))return t.push(po()),t.push(ko(l.startContainer,h)),t.push(bo(!0)),t.push(Ho(l)),!1;if(!c&&!d&&h&&i.isNormalLine(h)&&!Re.check.isListCell(h)&&i.isEdgeLine(l.startContainer,l.startOffset,"front")){const e=function(t,e){let s=e.previousElementSibling;if(s){if(!t.isBlock(s))return null}else{const i=e.parentElement;if(!t.isBlock(i)||t.isClosureBlock(i))return null;if(s=i.previousElementSibling,!s)return null}let i=s;for(;i&&t.isBlock(i)&&!t.isClosureBlock(i);)i=i.lastElementChild;if(!t.isNormalLine(i)||Re.check.isListCell(i)||t.isBrLine(i)||t.isClosureBrLine(i))return null;return i}(i,h);if(e)return t.push(po()),t.push(Do(e,h)),t.push(bo(!0)),!1}if(!c&&!d&&!h.previousElementSibling&&0===l.startOffset&&!a.previousSibling&&!Re.check.isListCell(h)&&i.isLine(h)&&(!i.isBrLine(h)||i.isClosureBrLine(h)||Re.check.isWysiwygFrame(h.parentNode)))return i.isClosureBlock(h.parentNode)?(t.push(po()),!1):i.isBrLine(h)&&Re.check.isWysiwygFrame(h.parentNode)?(t.push(po()),t.push($o(h)),t.push(bo(!0)),!1):(Re.check.isWysiwygFrame(h.parentNode)&&h.childNodes.length<=1&&(!h.firstChild||Re.check.isZeroWidth(h.textContent))&&(t.push(po()),t.push(xo(h))),t.push(vo()),t.push(Ho(l)),!1);const u=l.startContainer;if(h&&!d&&!h.previousElementSibling&&0===l.startOffset&&3===u.nodeType&&Re.check.isZeroWidth(u)&&!0===function(t,e,s){let i=e.parentNode.previousSibling;const n=e.parentNode.nextSibling;i||(n?i=n:(i=Re.utils.createElement("BR"),s.appendChild(i)));let o=e;for(;s.contains(o)&&!o.previousSibling;)o=o.parentNode;if(!s.contains(o))return e.textContent="",t.nodeTransform.removeAllParents(e,null,s),!0}(e,u,h))return!0;if(!c&&h&&(0===l.startOffset||a===h)){const s=a===h?ao(e,l,!0):Re.check.isElement(a.previousSibling)?a.previousSibling:Re.check.isEdgePoint(l.startContainer,l.startOffset)?Re.query.getPreviousDeepestNode(l.startContainer):null;if(n.is(s)){const e=n.get(s);if(e)return t.push(po()),t.push(So(a,l,e)),!0}}if(ao(e,l,!0))return t.push(po()),!0;c||d||!i.isEdgeLine(l.startContainer,l.startOffset,"front")||i.isLine(h.previousElementSibling)&&t.push(mo(h.previousElementSibling.attributes)),h=i.getLine(l.startContainer,null);const p=i.getBlock(h,null),g=l.commonAncestorContainer;if(p&&h&&!Re.check.isTableCell(p)&&!/^FIGCAPTION$/i.test(p.nodeName)){if(Re.check.isListCell(h)&&Re.check.isList(p)&&(Re.check.isListCell(p.parentElement)||h.previousElementSibling)&&(a===h||3===a.nodeType&&(!a.previousSibling||Re.check.isList(a.previousSibling)))&&(i.getLine(l.startContainer,null)!==i.getLine(l.endContainer,null)?p.contains(l.startContainer):0===l.startOffset&&l.collapsed&&!d)){if(l.startContainer!==l.endContainer)t.push(uo()),t.push(Mo(l)),t.push(bo(!0));else{let e=h.previousElementSibling||p.parentElement;if(Re.check.isListCell(e)){t.push(uo());let s=e;if(!e.contains(h)&&Re.check.isListCell(s)&&Re.check.isList(s.lastElementChild)){for(s=s.lastElementChild.lastElementChild;Re.check.isListCell(s)&&Re.check.isList(s.lastElementChild);)s=s.lastElementChild&&s.lastElementChild.lastElementChild;e=s}t.push(To(e,h,p)),t.push(bo(!0))}}return t.push(Ho(l)),!0}if(!c&&0===l.startOffset&&!d){let e=!0,s=g;for(;s&&s!==p&&!Re.check.isWysiwygFrame(s);){if(s.previousSibling&&(1===s.previousSibling.nodeType||!Re.check.isZeroWidth(s.previousSibling.textContent.trim()))){e=!1;break}s=s.parentNode}if(e&&p.parentNode)return t.push(uo()),t.push(wo(p,Re.check.isListCell(h)?[h]:null,null,!1,!1)),t.push(bo(!0)),t.push(Ho(l)),!0}}if(!c&&h&&Re.check.isEmptyLine(h)&&n.is(h.previousElementSibling)){const e=n.get(h.previousElementSibling);if(e)return t.push(po()),t.push(Eo(!1,h.firstChild,h,e)),t.push(Ho(l)),!0}if(!c&&h&&(0===l.startOffset||a===h&&h.childNodes[l.startOffset])){const e=Re.check.isListCell(h),s=a===h?h.childNodes[l.startOffset]:a,i=(e?s:h).previousSibling,o=e||(3===g.nodeType||Re.check.isBreak(g))&&!g.previousSibling&&0===l.startOffset;if(s&&(e||!s.previousSibling)&&(g&&n.is(g.previousSibling)||o&&n.is(i))){const o=n.get(i);return o?(t.push(po()),t.push(Eo(e,s,h,o))):n.is(i)&&(t.push(po()),t.push(Co(i))),t.push(Ho(l)),!0}if(s&&Re.check.isNonEditable(s.previousSibling))return t.push(po()),t.push(Co(s.previousSibling)),t.push(Ho(l)),!0}if(!c&&i.isBrLine(h)&&Re.check.isBreak(l.startContainer)&&0===l.startOffset){let e=l.startContainer.previousSibling;if(3===e?.nodeType&&Re.check.isZeroWidth(e)&&(e=e.previousSibling),Re.check.isBreak(e))return t.push(po()),t.push(Bo(l.startContainer,e)),t.push(bo(!0)),t.push(Ho(l)),!1}if(!c&&3===l.startContainer.nodeType&&Re.check.isZeroWidth(l.startContainer)&&l.startOffset<=1&&Re.check.isBreak(l.startContainer.previousSibling))return t.push(po()),t.push(Io(l.startContainer)),t.push(bo(!0)),t.push(Ho(l)),!1;const m=h?.previousElementSibling;return!c&&h&&i.isNormalLine(h)&&!Re.check.isListCell(h)&&Re.check.isEmptyLine(h)&&(i.isNormalLine(m)||i.isBrLine(m))?(t.push(po()),t.push(No(h,m)),t.push(bo(!0)),t.push(Ho(l)),!1):(t.push(Ho(l)),!0)}function ir(t,e,s){const{format:i,component:n}=e,{fc:o,range:r,selectionNode:l}=s;let{formatEl:a}=s;const h=!r.collapsed||r.startContainer!==r.endContainer,c=s.options.get("_rtl")&&!h&&r.endOffset>=(r.endContainer.textContent?.length||0)&&co(r,a,"end",o.get("_wd"));if(t.push(fo()),t.push(go()),h&&lo(e))return t.push(po()),!0;if(!h&&!c&&a&&i.isNormalLine(a)&&!Re.check.isListCell(a)&&i.isEdgeLine(r.endContainer,r.endOffset,"end")){const e=function(t,e){let s=e.nextElementSibling;if(s){if(!t.isBlock(s))return null}else{const i=e.parentElement;if(!t.isBlock(i)||t.isClosureBlock(i))return null;if(s=i.nextElementSibling,!s)return null}let i=s;for(;i&&t.isBlock(i)&&!t.isClosureBlock(i);)i=i.firstElementChild;if(!t.isNormalLine(i)||Re.check.isListCell(i)||t.isBrLine(i)||t.isClosureBrLine(i))return null;return i}(i,a);if(e)return t.push(po()),t.push(Do(a,e)),t.push(bo(!0)),!1}if(!h&&!c&&i.isEdgeLine(r.endContainer,r.endOffset,"end")&&!a.nextSibling)return t.push(po()),!1;if(i.isLine(a)&&h&&Re.check.isEdgePoint(r.endContainer,r.endOffset,"end")&&(!r.endContainer.nextSibling||Re.check.isZeroWidth(r.endContainer.nextSibling))&&i.getLine(r.startContainer)!==i.getLine(r.endContainer)&&(i.isLine(a.nextElementSibling)||Re.check.isListCell(a)))return t.push(po()),t.push(ko(r.endContainer,a)),t.push(bo(!0)),!1;if(!h&&a&&(r.endOffset===r.endContainer.textContent.length||l===a)){const s=l===a?ao(e,r,!1):Re.check.isElement(l.nextSibling)?l.nextSibling:Re.check.isEdgePoint(r.endContainer,r.endOffset)?Re.query.getNextDeepestNode(r.endContainer,null):null;if(n.is(s)){const e=n.get(s);if(e)return t.push(po()),t.push(Lo(a,e)),!0}}if(ao(e,r,!1))return t.push(po()),!0;if((i.isLine(l)||null===l.nextSibling||Re.check.isZeroWidth(l.nextSibling)&&null===l.nextSibling.nextSibling)&&r.startOffset===l.textContent.length){const e=a.nextElementSibling;if(!e)return!0;if(n.is(e))return t.push(uo()),t.push(Ao(a,e)),!0}if(!h&&(Re.check.isEdgePoint(r.endContainer,r.endOffset)||l===a&&a.childNodes[r.startOffset])){const e=l===a&&a.childNodes[r.startOffset]||l;if(e&&Re.check.isNonEditable(e.nextSibling))return t.push(po()),t.push(Co(e.nextSibling)),!0;if(n.is(e))return t.push(po()),t.push(Co(e)),!0}h||c||!i.isEdgeLine(r.endContainer,r.endOffset,"end")||i.isLine(a.nextElementSibling)&&t.push(mo(a.attributes)),a=i.getLine(r.startContainer,null);const d=i.getBlock(a,null);if(Re.check.isListCell(a)&&Re.check.isList(d)&&(l===a||3===l.nodeType&&(!l.nextSibling||Re.check.isList(l.nextSibling))&&(i.getLine(r.startContainer,null)!==i.getLine(r.endContainer,null)?d.contains(r.endContainer):r.endOffset===l.textContent.length&&r.collapsed&&!c)))return t.push(Oo(r,a,d)),!0;if(!h&&i.isBrLine(a)&&Re.check.isBreak(r.startContainer)&&0===r.startOffset){let e=r.startContainer.previousSibling;if(3===e?.nodeType&&Re.check.isZeroWidth(e)&&(e=e.previousSibling),Re.check.isBreak(e))return t.push(po()),t.push(zo(r.startContainer)),t.push(bo(!0)),!1}if(!h){const e=r.startContainer;let s=null;if(3===e.nodeType&&r.startOffset>=e.textContent.length&&Re.check.isBreak(e.nextSibling)){const t=e.nextSibling;3===t.nextSibling?.nodeType&&Re.check.isZeroWidth(t.nextSibling.textContent)&&(s=t)}else 3===e.nodeType&&Re.check.isZeroWidth(e)&&0===r.startOffset&&Re.check.isBreak(e.previousSibling)&&(s=e.previousSibling);if(s)return t.push(po()),t.push(Po(s)),t.push(bo(!0)),!1}const u=a?.nextElementSibling;return!(!h&&a&&i.isNormalLine(a)&&!Re.check.isListCell(a)&&Re.check.isEmptyLine(a)&&(i.isNormalLine(u)||i.isBrLine(u)))||(t.push(po()),t.push(Ro(a,u)),t.push(bo(!0)),!1)}function nr(t,e,s){const{format:i,char:n,selection:o}=e,{frameOptions:r,range:l,formatEl:a,selectionNode:h,shift:c,e:d}=s,u=!l.collapsed||l.startContainer!==l.endContainer;t.push(fo());const p=i.getBrLine(h,null),g=i.getBlock(a,null);if("byte-html"===r.get("charCounter_type")){let e="";if(e=!c&&p||c?"<br>":"<"+a.nodeName+"><br></"+a.nodeName+">",!n.check(e))return t.push(uo()),!1}if(c)return e.enterPrevent(d),t.push(Ko(l)),t.push(Ho(l)),!0;if(!c){let n=i.isEdgeLine(l.endContainer,l.endOffset,"end"),r=i.isEdgeLine(l.startContainer,l.startOffset,"front"),c=!1;if(s.options.get("_rtl")&&a&&l.collapsed&&r!==n){const t=s.fc.get("_wd");r&&co(l,a,"front",t)?(r=!1,n=!0,c=!0):n&&co(l,a,"end",t)&&(n=!1,r=!0,c=!0)}if(n&&(/^H[1-6]$/i.test(a.nodeName)||/^HR$/i.test(a.nodeName)))return e.enterPrevent(d),t.push(qo(a)),t.push(Ho(l)),!0;if(g&&a&&!Re.check.isTableCell(g)&&!/^FIGCAPTION$/i.test(g.nodeName)){const s=o.getRange();if(Re.check.isEdgePoint(s.endContainer,s.endOffset)&&Re.check.isList(h.nextSibling))return e.enterPrevent(d),t.push(Wo(a,h)),t.push(Ho(l)),!0;if((3!==s.commonAncestorContainer.nodeType||!s.commonAncestorContainer.nextElementSibling)&&Re.check.isZeroWidth(a.innerText.trim())&&!Re.check.isListCell(a.nextElementSibling))return e.enterPrevent(d),t.push(Uo(a,g)),!0}if(p||g===a&&i.isClosureBlock(g)&&i.isLine(a)){if(e.enterPrevent(d),p&&!i.isClosureBrLine(p))return!function(t,e){const s=Array.from(t.childNodes),i=[[]];for(const t of s)Re.check.isBreak(t)?i.push([]):i[i.length-1].push(t);s.length&&Re.check.isBreak(s[s.length-1])&&i.pop();const n=t=>!t||t.every((t=>Re.check.isZeroWidth(t.textContent))),o=e.anchorNode;let r=0;if(o===t)for(let t=0;t<e.anchorOffset&&t<s.length;t++)Re.check.isBreak(s[t])&&r++;else for(const t of s){if(t===o||1===t.nodeType&&t.contains(o))break;Re.check.isBreak(t)&&r++}const l=Math.max(i.length,1),a=Math.min(r,l-1);return{shouldExit:a===l-1&&n(i[a])&&a>=1&&n(i[a-1])}}(p,o.get()).shouldExit?t.push(Go(l)):t.push(Yo(p)),t.push(Ho(l)),!0;const s=o.get();return h===p?t.push(Vo(p,l,s,s.focusOffset)):t.push(jo(s)),t.push(Ho(l)),!0}if(l.collapsed&&(r||n))return e.enterPrevent(d),t.push(Xo(a,h,r,n,c)),t.push(Ho(l)),!0;if(a){if(t.push(uo()),u){if(s.options.get("_rtl")&&r&&!n){const t=s.fc.get("_wd"),e=t.createRange();e.setStart(l.startContainer,l.startOffset),e.collapse(!0),co(e,a,"front",t)&&(r=!1,n=!0,c=!0)}t.push(Zo(a,l,r,n))}else t.push(Jo(a,l));return t.push(Ho(l)),!0}}return u?(t.push(Ho(l)),!0):(g&&Re.query.getParentElement(g,"FIGCAPTION")&&Re.query.getParentElement(g,Re.check.isList)&&(e.enterPrevent(d),t.push(Qo(a)),t.push(Ho(l))),!0)}const{isOSX_IOS:or}=Le;function rr(t,e){return t.get("_canUseBeforeInput")&&!e?.repeat}async function lr(t,e){const s=[];switch(e.keyCode){case"Backspace":if(!1===sr(s,t,e))return s;break;case"Delete":if(!1===ir(s,t,e))return s;break;case"Tab":if(!1===function(t,e,s){const{options:i,selectionNode:n,range:o,formatEl:r,ctrl:l,alt:a,shift:h}=s;return!!i.get("tabDisable")||(t.push(uo()),l||a||Re.check.isWysiwygFrame(n)||(t.push(Fo(o,r,h)),t.push(bo(!1))),!0)}(s,0,e))return s;break;case"Enter":if(!rr(e.store,e.e)&&!1===nr(s,t,e))return s}const{fc:i,keyCode:n,shift:o,alt:r,ctrl:l,range:a}=e;if(o&&(or?r:l)&&Pe.isSpace(n))return s.push(po()),s.push(tr()),s;const h=!a.collapsed||a.startContainer!==a.endContainer;return l||r||h||Pe.isNonTextKey(n)||!Re.check.isBreak(a.commonAncestorContainer)?!i.has("documentType_use_header")||!h||l||r||o||Pe.isDirectionKey(n)?(function(t,e,s){const{component:i}=e,{formatEl:n,range:o,selectionNode:r,keyCode:l}=s,a=s.options.get("_rtl"),h="ArrowLeft"===l?a?"forward":"back":"ArrowRight"===l?a?"back":"forward":null;let c=null;switch(l){case"ArrowUp":i.is(n.previousElementSibling)&&(c=i.get(n.previousElementSibling));break;case"ArrowLeft":case"ArrowRight":if("forward"===h){if(Re.check.isEdgePoint(r,o.endOffset,"end")){const t=r.nextElementSibling||Re.query.getNextDeepestNode(r);t?i.is(t)&&(c=i.get(t)):i.is(n.nextElementSibling)&&(c=i.get(n.nextElementSibling))}}else if("back"===h&&Re.check.isEdgePoint(r,o.startOffset,"front")){const t=r.previousElementSibling||Re.query.getPreviousDeepestNode(r);t?i.is(t)&&(c=i.get(t)):i.is(n.previousElementSibling)&&(c=i.get(n.previousElementSibling))}break;case"ArrowDown":i.is(n.nextElementSibling)&&(c=i.get(n.nextElementSibling))}c&&!c.options?.isInputComponent&&(t.push(uo()),t.push(_o(c)))}(s,t,e),s):(s.push(yo()),s):(s.push(er()),s)}function ar(t,{_styleNodes:e}){const{frameContext:s,ui:i,focusManager:n,selection:o,format:r,listFormat:l,component:a,html:h,nodeTransform:c,history:d,char:u,menu:p,store:g}=t.$;return{focusManager:{nativeFocus:()=>n.nativeFocus(),blur:()=>n.blur()},selection:{getRange:()=>o.getRange(),getNode:()=>o.getNode(),setRange:(t,e,s,i)=>o.setRange(t,e,s,i),get:()=>o.get()},format:{isLine:t=>r.isLine(t),getLine:(t,e)=>r.getLine(t,e),getLines:t=>r.getLines(t),getBrLine:(t,e)=>r.getBrLine(t,e),getBlock:(t,e)=>r.getBlock(t,e),isNormalLine:t=>r.isNormalLine(t),isBrLine:t=>r.isBrLine(t),isClosureBrLine:t=>r.isClosureBrLine(t),isBlock:t=>r.isBlock(t),isClosureBlock:t=>r.isClosureBlock(t),isEdgeLine:(t,e,s)=>r.isEdgeLine(t,e,s),removeBlock:(t,e)=>r.removeBlock(t,e),addLine:(t,e)=>r.addLine(t,e),addLineAfter:t=>r.addLineAfter(t)},listFormat:{applyNested:(t,e)=>l.applyNested(t,e)},component:{deselect:()=>a.deselect(),is:t=>a.is(t),get:t=>a.get(t),select:(t,e)=>a.select(t,e)},html:{remove:()=>h.remove(),insert:(t,e)=>h.insert(t,e),insertNode:(t,e)=>h.insertNode(t,e)},history:{push:t=>d.push(!!t)},nodeTransform:{removeAllParents:(t,e,s)=>c.removeAllParents(t,e,s),split:(t,e,s)=>c.split(t,e,s)},char:{check:t=>u.check(t)},menu:{dropdownOff:()=>p.dropdownOff()},setDefaultLine:e=>t._setDefaultLine(e),hideToolbar:()=>t._hideToolbar(),hideToolbar_sub:()=>t._hideToolbar_sub(),styleNodeCache:()=>e.value=t.__cacheStyleNodes,formatAttrsTempCache:e=>t._formatAttrsTemp=e,setOnShortcutKey:e=>t._onShortcutKey=e,caretScrollTo(t){i._iframeAutoHeight(s),o.scrollTo(o.getRange()||t,{behavior:"auto",block:"nearest",inline:"nearest"})},enterPrevent(e){e.preventDefault(),b&&!rr(g)&&(t.__focusTemp.focus({preventScroll:!0}),s.get("wysiwyg").focus({preventScroll:!0}))}}}const hr={value:[]};async function cr(t,e){if(t.get("isReadOnly")||t.get("isDisabled"))return e.preventDefault(),e.stopPropagation(),!1;if(rr(this.$.store)&&("insertParagraph"===e.inputType||"insertLineBreak"===e.inputType))return void await dr.call(this,t,e);const s=(null===e.data?"":void 0===e.data?" ":e.data)||"";if(Pe.isComposing(e))this._handledInBefore=!1;else{if(!this.$.char.test(s,!1))return e.preventDefault(),e.stopPropagation(),!1;this._handledInBefore=!0}!1!==await this.$.eventManager.triggerEvent("onBeforeInput",{frameContext:t,event:e,data:s})&&await this._callPluginEventAsync("onBeforeInput",{frameContext:t,event:e,data:s})}async function dr(t,e){if(e.isComposing||this.isComposing)return;if(this.$.ui.selectMenuOn)return;let s=this.$.selection.getNode();if(Re.check.isInputElement(s))return;if(this.$.menu.currentDropdownName)return;Re.check.isWysiwygFrame(s)&&(this._setDefaultLine(this.$.options.get("defaultLine")),s=this.$.selection.getNode());const i=this._enterKeyShift||"insertLineBreak"===e.inputType;if(this._enterKeyShift=!1,!i){const t=this._normalizeEditRange();t&&(s=t)}const n=this.$.selection.getRange(),o=this.$.format.getLine(s,null)||s,r={e,fc:t,store:this.$.store,options:this.$.options,frameOptions:this.$.frameOptions,range:n,selectionNode:s,formatEl:o,keyCode:"Enter",ctrl:!1,alt:!1,shift:i},l=ar(this,{_styleNodes:hr}),a=[];nr(a,l,r),a.some((t=>"event.prevent"===t.t||"event.prevent.stop"===t.t))&&e.preventDefault(),await ro(a,{ports:l,ctx:r})}async function ur(t,e){if(t.get("isReadOnly")||t.get("isDisabled"))return e.preventDefault(),e.stopPropagation(),!1;const s=this.$.selection.getRange(),i=this.$.selection.getNode(),n=this.$.format.getLine(i,null);if(!this.$.format.isNormalLine(n)&&!this.$.format.isBrLine(n)&&s.collapsed&&!this.$.component.is(i)&&!Re.check.isList(i)){const t=this.$.format.getBlock(i,null);this._setDefaultLine(this.$.format.isBlock(t)?"DIV":this.$.options.get("defaultLine"))}this.$.selection.init();const o=(null===e.data?"":void 0===e.data?" ":e.data)||"";if(!this._handledInBefore&&!this.$.char.test(o,!0))return e.preventDefault(),e.stopPropagation(),!1;this._handledInBefore=!1,!1!==await this.$.eventManager.triggerEvent("onInput",{frameContext:t,event:e,data:o})&&(await this._callPluginEventAsync("onInput",{frameContext:t,event:e,data:o}),this.$.history.push(!0))}const{_w:pr}=Le,gr=new RegExp(Ae.zeroWidthSpace+"+",""),mr={ctrl:!1,alt:!1},fr=Object.preventExtensions({value:[]});async function vr(t,e){if(this.isComposing=Pe.isComposing(e))return!0;if(this.$.ui.selectMenuOn||!e.isTrusted)return;let s=this.$.selection.getNode();if(Re.check.isInputElement(s))return;if(this.$.menu.currentDropdownName)return;const i=e.code,n=Pe.isShift(e),o=mr.ctrl=Pe.isCtrl(e),r=mr.alt=Pe.isAlt(e);if(Pe.isEnter(i)&&(this._enterKeyShift=n),!o&&t.get("isReadOnly")&&!Pe.isDirectionKey(i))return e.preventDefault(),!1;this.$.menu.dropdownOff(),this.$.store.mode.isBalloon?this.$.store.mode.isBalloonAlways||this._hideToolbar():this.$.store.mode.isSubBalloon&&(this.$.store.mode.isSubBalloonAlways||this._hideToolbar_sub());if(Pe.isEnter(i)&&!rr(this.$.store,e)||Pe.isRemoveKey(i)){const t=this._normalizeEditRange();t&&(s=t)}const l=this.$.selection.getRange(),a=this.$.format.getLine(s,null)||s;if(o&&!Pe.isNonTextKey(i)&&this.$.shortcuts.command(e,o,n,i,"",!1,null,null))return this._onShortcutKey=!0,e.preventDefault(),e.stopPropagation(),!1;if(!o&&!Pe.isNonTextKey(i)&&this.$.format.isLine(a)&&l.collapsed&&Re.check.isEdgePoint(l.startContainer,0,"front")){const t=l.startContainer.substringData?.(0,l.startOffset);if(t&&this.$.shortcuts.command(e,!1,n,i,t,!0,a,l))return this._onShortcutKey=!0,e.preventDefault(),e.stopPropagation(),!1}else this._onShortcutKey&&(this._onShortcutKey=!1);const h={e,fc:t,store:this.$.store,options:this.$.options,frameOptions:this.$.frameOptions,range:l,selectionNode:s,formatEl:a,keyCode:i,ctrl:o,alt:r,shift:n},c=ar(this,{_styleNodes:fr}),d=await lr(c,h);!1!==await this.$.eventManager.triggerEvent("onKeyDown",{frameContext:t,event:e})&&!1!==await this._callPluginEventAsync("onKeyDown",{frameContext:t,event:e,range:l,line:a})&&await ro(d,{ports:c,ctx:h})}async function br(t,e){if(this._onShortcutKey||this.$.menu.currentDropdownName)return;const s=e.code,i=Pe.isCtrl(e),n=Pe.isAlt(e);if(i&&(mr.ctrl=!1),n&&(mr.alt=!1),t.get("isReadOnly"))return;const o=this.$.selection.getRange();let r=this.$.selection.getNode();if((this.$.store.mode.isBalloon||this.$.store.mode.isSubBalloon)&&((this.$.store.mode.isBalloonAlways||this.$.store.mode.isSubBalloonAlways)&&!Pe.isEsc(s)||!o.collapsed)){if(!this.$.store.mode.isBalloonAlways&&!this.$.store.mode.isSubBalloonAlways)return void(this.$.store.mode.isSubBalloon?this.$.subToolbar._showBalloon():this.$.toolbar._showBalloon());Pe.isEsc(s)||this._showToolbarBalloonDelay()}if(Pe.isBackspace(s)&&Re.check.isWysiwygFrame(r)&&""===r.textContent&&0===r.children.length){e.preventDefault(),e.stopPropagation(),r.innerHTML="";const i=this.$.store.get("currentNodes")[0],n=Re.utils.createElement(this.$.format.isLine(i)&&!Re.check.isListCell(i)?i:this.$.options.get("defaultLine"),null,"<br>");return r.appendChild(n),this.$.selection.setRange(n,0,n,0),this.applyTagEffect(),this.$.history.push(!1),void(t.has("documentType_use_header")&&Pe.isDocumentTypeObserverKey(s)&&t.get("documentType").reHeader())}const l=this.$.format.getLine(r,null),a=this.$.format.getBlock(r,null),h=this._formatAttrsTemp;if(l&&h){for(let t=0,e=h.length;t<e;t++)Pe.isEnter(s)&&/^id$/i.test(h[t].name)?l.removeAttribute("id"):l.setAttribute(h[t].name,h[t].value);this._formatAttrsTemp=null}this.$.format.isNormalLine(l)||this.$.format.isBrLine(l)||!o.collapsed||this.$.component.is(r)||Re.check.isList(r)||null===this._setDefaultLine(this.$.format.isBlock(a)?"DIV":this.$.options.get("defaultLine"))||(r=this.$.selection.getNode());if(!mr.ctrl&&!mr.alt&&!Pe.isNonTextKey(s)&&3===r.nodeType&&Ae.zeroWidthRegExp.test(r.textContent)&&!(void 0!==e.isComposing?e.isComposing:this.isComposing)){let t=o.startOffset,e=o.endOffset;const s=(r.textContent.substring(0,e).match(gr)||"").length;t=o.startOffset-s,e=o.endOffset-s,r.textContent=r.textContent.replace(Ae.zeroWidthRegExp,""),this.$.selection.setRange(r,t<0?0:t,r,e<0?0:e)}if(Pe.isRemoveKey(s)&&Re.check.isZeroWidth(l?.textContent)&&!l.previousElementSibling&&!Re.check.isListCell(l)){const t=this.$.options.get("retainStyleMode");"none"!==t&&fr.value?.length>0?"repeat"===t?this.__retainTimer?(this.__retainTimer=pr.clearTimeout(this.__retainTimer),this._clearRetainStyleNodes(l)):(this.__retainTimer=pr.setTimeout((()=>{this.__retainTimer=null}),0),this._retainStyleNodes(l,fr.value)):(this.__retainTimer=null,this._retainStyleNodes(l,fr.value)):this._clearRetainStyleNodes(l)}if(t.has("documentType_use_header"))if(Pe.isDocumentTypeObserverKey(s)){t.get("documentType").reHeader();const e=Re.query.getParentElement(this.$.selection.selectionNode,this.$.format.isLine.bind(this.$.format));t.get("documentType").on(e)}else{const e=Re.query.getParentElement(r,(t=>1===t.nodeType));t.get("documentType").onChangeText(e)}!1!==await this.$.eventManager.triggerEvent("onKeyUp",{frameContext:t,event:e})&&!1!==await this._callPluginEventAsync("onKeyUp",{frameContext:t,event:e,range:o,line:l})&&Pe.isHistoryRelevantKey(s)&&this.$.history.push(!0)}const{_w:yr}=Le;function wr(t,e){const s=e.clipboardData;return!s||this._dataTransferAction("paste",e,s,t)}async function Cr(t,e){const s=e.clipboardData;if(!1===await this.$.eventManager.triggerEvent("onCopy",{frameContext:t,event:e,clipboardData:s}))return e.preventDefault(),e.stopPropagation(),!1;const i=t.get("_ww").getSelection();this.__secopy=i.toString()}async function _r(t,e){const s=e.clipboardData;if(!1===await this.$.eventManager.triggerEvent("onCut",{frameContext:t,event:e,clipboardData:s}))return e.preventDefault(),e.stopPropagation(),!1;const i=t.get("_ww").getSelection();this.__secopy=i.toString(),yr.setTimeout((()=>{this.$.history.push(!1)}),0)}const{_w:kr}=Le;function xr(t,e,s,i,n){if(n.dataTransfer&&Array.from(n.dataTransfer.types||[]).includes("application/x-suneditor-block-drag"))return;const{sc:o,so:r,ec:l,eo:a}=this.$.selection.getDragEventLocationRange(n);if(!o)return;n.preventDefault();const h=t.get("_wd").createRange();h.setStart(o,r),h.setEnd(l,a);const c={y:0,x:0};if(s){const t=this.$.offset.getGlobal(s),e=i?this.$.context.get("toolbar_main").offsetHeight:0;c.y=t.top+e-kr.scrollY,c.x=t.left-kr.scrollX}const d=h.getBoundingClientRect();if(d.height>0){const s=t.get("wysiwygFrame");let i=0,n=0;/^iframe$/i.test(s.nodeName)&&(i=s.offsetLeft,n=s.offsetTop),e.style.left=`${d.right+kr.scrollX+c.x+i}px`,e.style.top=`${d.top+kr.scrollY+c.y-5+n}px`,e.style.height=`${d.height+10}px`,e.style.display="block";try{e.showPopover?.()}catch{}}else{try{e.hidePopover?.()}catch{}e.style.display="none"}}function $r(t){try{t.hidePopover?.()}catch{}t.style.display="none"}function Sr(t,e,s){try{if(t.get("isReadOnly"))return s.preventDefault(),s.stopPropagation(),!1;const e=s.dataTransfer;if(!e)return!0;if(Array.from(e.types||[]).includes("application/x-suneditor-block-drag"))return;const{sc:i,so:n,ec:o,eo:r}=this.$.selection.getDragEventLocationRange(s);if(!i)return;if(Re.query.getParentElement(i,".se-disable-pointer"))return void s.preventDefault();if(yi.get("__dragContainer")){if(s.preventDefault(),yi.get("__dragContainer").contains(s.target))return void this.$.component.deselect();const e=yi.get("__dragContainer");return this.$.component.deselect(),this.$.selection.setRange(i,n,o,r),this.$.html.insertNode(e,{afterNode:null,skipCharCount:!0}),void(t.has("documentType_use_page")&&(t.get("documentTypePageMirror").innerHTML=t.get("wysiwyg").innerHTML,t.get("documentType").rePage(!0)))}return this.$.html.remove(),this.$.selection.setRange(i,n,o,r),this._dataTransferAction("drop",s,e,t)}finally{try{e.hidePopover?.()}catch{}e.style.display="none"}}class Er{#J;constructor({$:t}){this.#J=t}execute(t){if(!this.#J.options.get("__lineFormatFilter"))return null;if(this.#J.pluginManager.fileInfo.pluginRegExp.test(this.#J.ui.currentControllerName))return;const e=this.#J.selection.getRange(),s=e.commonAncestorContainer,i=e.startContainer,n=e.endOffset,o=this.#J.format.getBlock(s,null);let r,l,a;if(o)return a=Re.utils.createElement(t||this.#J.options.get("defaultLine")),a.innerHTML=o.innerHTML,0===a.childNodes.length&&(a.innerHTML=Ae.zeroWidthSpace),o.innerHTML=a.outerHTML,a=o.firstChild,r=a.childNodes[n]||Re.query.getEdgeChildNodes(a,null).sc,r||(r=Re.utils.createTextNode(Ae.zeroWidthSpace),a.insertBefore(r,a.firstChild)),l=r.textContent.length,void this.#J.selection.setRange(r,l,r,l);if(3===s.nodeType&&this.#J.component.is(s.parentElement)){const t=this.#J.component.get(s.parentElement);if(!t)return;const e=t.container;if(s.parentElement===e){const t=s.nextElementSibling?e:e.nextElementSibling,i=Re.utils.createElement(this.#J.options.get("defaultLine"),null,s);return e.parentElement.insertBefore(i,t),void this.#J.focusManager.focusEdge(i)}return this.#J.component.select(t.target,t.pluginName),null}if(1===s.nodeType&&"true"===s.getAttribute("data-se-embed")){let t=s.nextElementSibling;return this.#J.format.isLine(t)||(t=this.#J.format.addLine(s,this.#J.options.get("defaultLine"))),void this.#J.selection.setRange(t.firstChild,0,t.firstChild,0)}if(!this.#J.format.isBlock(i)&&!Re.check.isWysiwygFrame(i)||!this.#J.component.is(i.children[e.startOffset])&&!this.#J.component.is(i.children[e.startOffset-1])){if(Re.query.getParentElement(s,Re.check.isExcludeFormat))return null;if(this.#J.format.isBlock(s)&&s.childNodes.length<=1){let t=null;return 1===s.childNodes.length&&Re.check.isBreak(s.firstChild)?t=s.firstChild:(t=Re.utils.createTextNode(Ae.zeroWidthSpace),s.appendChild(t)),void this.#J.selection.setRange(t,1,t,1)}try{if(3===s.nodeType&&(a=Re.utils.createElement(t||this.#J.options.get("defaultLine")),s.parentNode.insertBefore(a,s),a.appendChild(s)),Re.check.isBreak(a.nextSibling)&&Re.utils.removeItem(a.nextSibling),Re.check.isBreak(a.previousSibling)&&Re.utils.removeItem(a.previousSibling),Re.check.isBreak(r)){const t=Re.utils.createTextNode(Ae.zeroWidthSpace);r.parentNode.insertBefore(t,r),r=t}}catch{return this.#J.frameContext.get("_wd").execCommand("formatBlock",!1,`<${t||this.#J.options.get("defaultLine")}>`),this.#J.store.set("_lastSelectionNode",null),void this.#J.selection.init()}if(a&&(Re.check.isBreak(a.nextSibling)&&Re.utils.removeItem(a.nextSibling),Re.check.isBreak(a.previousSibling)&&Re.utils.removeItem(a.previousSibling),Re.check.isBreak(r))){const t=Re.utils.createTextNode(Ae.zeroWidthSpace);r.parentNode.insertBefore(t,r),r=t}this.#J.store.set("_lastSelectionNode",null),i?this.#J.selection.setRange(i,1,i,1):this.#J.focusManager.nativeFocus()}}}class Tr{#Hl;#J;#ql;constructor(t){this.#Hl=t,this.#J=t.$,this.#ql=new RegExp(`^(${Object.keys(this.#J.options.get("_defaultStyleTagMap")).join("|")})$`,"i")}update(t){if(t||=this.#J.selection.getNode(),t===this.#J.store.get("_lastSelectionNode"))return;this.#J.store.set("_lastSelectionNode",t);const e=this.#J.options.get("_rtl")?"marginRight":"marginLeft",s=this.#J.plugins,i=this.#J.commandDispatcher.targets,n=this.#ql,o=this.#J.options.get("_styleCommandMap"),r=[],l=[],a=this.#J.options.get("_textStyleTags"),h=[],c=[],d=this.#J.commandDispatcher.activeCommands,u=d.length;let p="";if(this.#J.component.is(t)&&!this.#J.component.__selectionSelected){const e=this.#J.component.get(t);if(!e)return;return this.#J.store.set("_lastSelectionNode",null),void this.#J.component.select(e.target,e.pluginName)}for(;t.firstChild;)t=t.firstChild;const g=this.#J.frameContext,m=!g.get("isReadOnly");for(let g=t;!Re.check.isWysiwygFrame(g)&&g;g=g.parentElement)if(1===g.nodeType&&!Re.check.isBreak(g)){if(this.#Wl(g))return void this.#J.focusManager.blur();if(p=g.nodeName.toLowerCase(),l.push(p),a.includes(p)&&!this.#J.format.isLine(p)&&h.push(g),m)for(let t,e=0;e<u;e++)t=d[e],!r.includes(t)&&!c.includes(t)&&i.get(t)&&i.get(t).filter((e=>{const i=s[t]?.active(g,e);return void 0===i&&c.push(t),i})).length>0&&r.push(t);if(this.#J.format.isLine(g)){if(!r.includes("outdent")&&i.has("outdent")&&(Re.check.isListCell(g)||g.style[e]&&ze.get(g.style[e],0)>0)&&i.get("outdent").filter((t=>!Re.check.isImportantDisabled(t)&&(t.disabled=!1,!0))).length>0&&r.push("outdent"),!r.includes("indent")&&i.has("indent")){const t=Re.check.isListCell(g)&&!g.previousElementSibling;i.get("indent").filter((e=>!Re.check.isImportantDisabled(e)&&(e.disabled=t,!0))).length>0&&r.push("indent")}}else n.test(p)&&(p=o[p]||p,r.push(p),Re.utils.addClass(i.get(p),"active"))}return this.#Ul(r),this.#Hl.__cacheStyleNodes=h.reverse(),this.#J.store.set("currentNodes",l.reverse()),this.#J.store.set("currentNodesMap",r),this.#J.frameOptions.get("statusbar_showPathLabel")&&g.get("navigation")&&(g.get("navigation").textContent=this.#J.options.get("_rtl")?this.#J.store.get("currentNodes").reverse().join(" < "):this.#J.store.get("currentNodes").join(" > ")),t}reset(){this.#Ul([])}#Ul(t){const e=this.#J.commandDispatcher.activeCommands,s=this.#J.commandDispatcher.targets,i=this.#J.plugins;for(let n,o,r,l=0,a=e.length;l<a;l++)if(n=e[l],!t.includes(n)&&(o=s.get(n))){r=i[n];for(let t,e=0,s=o.length;e<s;e++)t=o[e],t&&(r?r.active(null,t):/^outdent$/i.test(n)?Re.check.isImportantDisabled(t)||(t.disabled=!0):/^indent$/i.test(n)?Re.check.isImportantDisabled(t)||(t.disabled=!1):Re.utils.removeClass(t,"active"))}}#Wl(t){return Re.check.isElement(t)&&"true"===t.getAttribute("data-se-non-focus")}}const{_w:Mr,isMobile:Nr,isTouchDevice:Br}=Le;function Ir(t){if("Tab"!==t.key)return;t.preventDefault();const e=t.target,s=e.selectionStart,i=e.selectionEnd;e.value=e.value.substring(0,s)+"\t"+e.value.substring(i),e.selectionStart=e.selectionEnd=s+1}const Lr=class extends Hn{#t;#gi;#e;#ot;#mi;#o;#Vl;#jl;#Gl=null;#Kl=null;#Yl=null;#Xl=null;constructor(t){super(t),this.#t=this.$.store,this.#gi=this.$.contextProvider,this.#e=this.$.context,this.#ot=this.$.options,this.#mi=this.$.eventManager,this.#o=this.$.toolbar,this.#Vl=this.$.ui,this.#jl=this.$.menu,this.isComposing=!1,this._enterKeyShift=!1,this.scrollparents=[],this.defaultLineManager=new Er(this),this.selectionState=new Tr(this),this._onShortcutKey=!1,this._handledInBefore=!1,this._wwFrameObserver=null,this._toolbarObserver=null,this._lineBreakComp=null,this._formatAttrsTemp=null,this._resizeClientY=0,this.__cacheStyleNodes=[],this.__onDownEv=null,this._inputFocus=!1,this.__inputPlugin=null,this.__inputBlurEvent=null,this.__inputKeyEvent=null,this.__retainTimer=null,this.__eventDoc=null,this.__secopy=null,this.__focusTemp=this.#gi.carrierWrapper.querySelector(".__se__focus__temp__")}applyTagEffect(t){return this.selectionState.update(t)}_showToolbarBalloonDelay(){this.#Gl&&Mr.clearTimeout(this.#Gl),this.#Gl=Mr.setTimeout((()=>{Mr.clearTimeout(this.#Gl),this.#Gl=null,this.#t.mode.isSubBalloon?this.$.subToolbar._showBalloon():this.#o._showBalloon()}),250)}#Zl(){this.#Gl&&Mr.clearTimeout(this.#Gl),this.#Gl=Mr.setTimeout((()=>{Mr.clearTimeout(this.#Gl),this.#Gl=null,this._toggleToolbarBalloon()}),250)}_toggleToolbarBalloon(){this.$.selection.init();const t=this.$.selection.getRange(),e=this.#ot.has("_subMode");!(e?this.#t.mode.isSubBalloonAlways:this.#t.mode.isBalloonAlways)&&t.collapsed?e?this._hideToolbar_sub():this._hideToolbar():e?this.$.subToolbar._showBalloon(t):this.#o._showBalloon(t)}_hideToolbar(){this.#Vl.isPreventToolbarHide||this.$.frameContext.get("isFullScreen")||this.#o.hide()}_hideToolbar_sub(){this.$.subToolbar&&!this.#Vl.isPreventToolbarHide&&this.$.subToolbar.hide()}_setDefaultLine(t){return this.defaultLineManager.execute(t)}_normalizeEditRange(){if(!this.$.format.isLine(this.$.selection.getRange()?.startContainer))return null;this.$.selection.resetRangeToTextNode();const t=this.$.selection.getRange();if(t.startContainer===t.endContainer&&t.startOffset!==t.endOffset&&3===t.startContainer.nodeType&&Re.check.isZeroWidth(t.startContainer)){const e=t.startContainer.nextSibling;e&&Re.check.isBreak(e)?this.$.selection.setRange(e,0,e,0):this.$.selection.setRange(t.endContainer,t.endOffset,t.endContainer,t.endOffset)}return this.$.selection.getNode()}async _dataTransferAction(t,e,s,i){try{return this.#Vl.showLoading(),await this.#Jl(t,e,s,i),e.preventDefault(),e.stopPropagation(),!1}catch(t){console.warn("[SUNEDITOR.paste.error]",t)}finally{this.#Vl.hideLoading()}}async#Jl(t,e,s,i){e.preventDefault(),e.stopPropagation();let n=s.getData("text/plain"),o=s.getData("text/html");const r=!o,l=this.__secopy===n,a=/class=["']*Mso(Normal|List)/i.test(o)||/content=["']*Word.Document/i.test(o)||/content=["']*OneNote.File/i.test(o)||/content=["']*Excel.Sheet/i.test(o),h=l?"SE":a?"MS":"";if(r?o=Oe.htmlToEntity(n).replace(/\n/g,"<br>"):(o=o.replace(/^<html>\r?\n?<body>\r?\n?\x3C!--StartFragment-->|\x3C!--EndFragment-->\r?\n?<\/body>\r?\n?<\/html>$/g,""),a&&(o=o.replace(/\n/g," "),n=n.replace(/\n/g," "),o=He.cleanHTML(o))),!l){if(this.#ot.get("autoLinkify")){const t=(new DOMParser).parseFromString(o,"text/html");Re.query.getListChildNodes(t.body,Oe.textToAnchor,null),o=t.body.innerHTML}}r||(o=this.$.html.clean(o,{forceFormat:!1,whitelist:null,blacklist:null}));const c=this.$.char.test("byte-html"===this.$.frameOptions.get("charCounter_type")?o:n,!1);if("paste"===t){const t=await this.#mi.triggerEvent("onPaste",{frameContext:i,event:e,data:o,maxCharCount:c,from:h});if(!1===t)return!1;if("string"==typeof t){if(!t)return!1;o=t}}if("drop"===t){const t=await this.#mi.triggerEvent("onDrop",{frameContext:i,event:e,data:o,maxCharCount:c,from:h});if(!1===t)return!1;if("string"==typeof t){if(!t)return!1;o=t}}const d=s.files;if(d.length>0&&!a){for(let t=0,s=d.length;t<s;t++)await this._callPluginEventAsync("onFilePasteAndDrop",{frameContext:i,event:e,file:d[t]});return!1}if(!c)return!1;if(o){const t=(new DOMParser).parseFromString(o,"text/html");return!1!==await this._callPluginEventAsync("onPaste",{frameContext:i,event:e,data:o,doc:t})&&this.$.html.insert(o,{selectInserted:!1,skipCharCount:!0,skipCleaning:!0}),i.has("documentType_use_header")&&i.get("documentType").reHeader(),!1}}_addCommonEvents(){const t=Un.bind(this),e=jn.bind(this);this.#mi.addEvent(this.#e.get("menuTray"),"mousedown",t,!1),this.#mi.addEvent(this.#e.get("menuTray"),"click",Vn.bind(this),!0),this.#mi.addEvent(this.#e.get("toolbar_main"),"mousedown",t,!1),this.#mi.addEvent(this.#e.get("toolbar_main"),"click",e,!1),this.#ot.has("_subMode")&&(this.#mi.addEvent(this.#e.get("toolbar_sub_main"),"mousedown",t,!1),this.#mi.addEvent(this.#e.get("toolbar_sub_main"),"click",e,!1)),this.#o._setResponsive(),Le.isResizeObserverSupported&&(this._toolbarObserver=new ResizeObserver((()=>{Mr.setTimeout((()=>{this.#o.resetResponsiveToolbar()}),0)})),this._wwFrameObserver=new ResizeObserver((t=>{Mr.setTimeout((()=>{t.forEach((t=>{this.#Vl._emitResizeEvent(this.$.frameRoots.get(t.target.getAttribute("data-root-key")),-1,t)})),this.#t.mode.isInline&&this.#t.mode.isBottom&&this.#o._resetSticky()}),0)}))),this.#ot.get("closeModalOutsideClick")&&this.#mi.addEvent(this.#gi.carrierWrapper.querySelector(".se-modal .se-modal-inner"),"click",(t=>{t.target===this.#gi.carrierWrapper.querySelector(".se-modal .se-modal-inner")&&this.#Vl.offCurrentModal()}),!1),this.#mi.addEvent(Mr,"resize",this.#Ql.bind(this),!1),this.#mi.addEvent(Mr.visualViewport,"resize",this.#ta.bind(this),!1),this.#mi.addEvent(Mr,"scroll",this.#ea.bind(this),!1),Br&&this.#mi.addEvent(Mr.visualViewport,"scroll",this.#sa.bind(this),!1)}_addFrameEvents(t){const e=t.get("options").get("iframe"),s=e?t.get("_ww"):t.get("wysiwyg");t.set("eventWysiwyg",s);const i=t.get("code"),n=this.#gi.carrierWrapper.querySelector(".se-drag-cursor"),o=Qn.bind(this,t);this.#mi.addEvent(s,"mousemove",o,!1),this.#mi.addEvent(s,"mouseleave",to.bind(this,t),!1),this.#mi.addEvent(s,"mousedown",Yn.bind(this,t),!1),this.#mi.addEvent(s,"mouseup",Zn.bind(this,t),!1),this.#mi.addEvent(s,"click",Jn.bind(this,t),!1),this.#mi.addEvent(s,"beforeinput",cr.bind(this,t),!1),this.#mi.addEvent(s,"input",ur.bind(this,t),!1),this.#mi.addEvent(s,"keydown",vr.bind(this,t),!1),this.#mi.addEvent(s,"keyup",br.bind(this,t),!1),this.#mi.addEvent(s,"paste",wr.bind(this,t),!1),this.#mi.addEvent(s,"copy",Cr.bind(this,t),!1),this.#mi.addEvent(s,"cut",_r.bind(this,t),!1),this.#mi.addEvent(s,"dragover",xr.bind(this,t,n,e?this.$.frameContext.get("topArea"):null,!this.#ot.get("toolbar_container")&&!this.#t.mode.isBalloon&&!this.#t.mode.isInline),!1),this.#mi.addEvent(s,"dragend",$r.bind(this,n),!1),this.#mi.addEvent(s,"drop",Sr.bind(this,t,n),!1),this.#mi.addEvent(s,"scroll",this.#ia.bind(this,t,s),{passive:!0,capture:!1}),this.#mi.addEvent(s,"focus",this.#na.bind(this,t),!1),this.#mi.addEvent(s,"blur",this.#oa.bind(this,t),!1),this.#mi.addEvent(i,"mousedown",this.#ra.bind(this,t),!1);const r=t.get("wrapper").querySelector(".se-drag-handle");if(this.#mi.addEvent(r,"wheel",(t=>{t.preventDefault(),this.$.component.deselect()}),!1),this.#mi.addEvent(t.get("lineBreaker_t"),"pointerdown",this.#la.bind(this,"t"),!1),this.#mi.addEvent(t.get("lineBreaker_b"),"pointerdown",this.#la.bind(this,"b"),!1),Br&&this.#mi.addEvent(s,"touchstart",o,{passive:!0,capture:!1}),!this.#ot.get("hasCodeMirror")){const e=t.get("codeNumbers"),s=this.$.viewer._codeViewAutoHeight.bind(this.$.viewer,t.get("code"),e,"auto"===this.$.frameOptions.get("height"));this.#mi.addEvent(i,"keydown",s,!1),this.#mi.addEvent(i,"keyup",s,!1),this.#mi.addEvent(i,"paste",s,!1),this.#ot.get("tabDisable")||this.#mi.addEvent(i,"keydown",Ir,!1),e&&this.#mi.addEvent(i,"scroll",this.$.viewer._scrollLineNumbers.bind(i,e),!1)}const l=t.get("markdown");if(l){this.#mi.addEvent(l,"mousedown",this.#aa.bind(this,t),!1);const e=t.get("markdownNumbers"),s=this.$.viewer._markdownViewAutoHeight.bind(this.$.viewer,l,e,"auto"===this.$.frameOptions.get("height"));this.#mi.addEvent(l,"keydown",s,!1),this.#mi.addEvent(l,"keyup",s,!1),this.#mi.addEvent(l,"paste",s,!1),this.#ot.get("tabDisable")||this.#mi.addEvent(l,"keydown",Ir,!1),e&&this.#mi.addEvent(l,"scroll",this.$.viewer._scrollMarkdownLineNumbers.bind(l,e),!1)}t.has("statusbar")&&this.__addStatusbarEvent(t,t.get("options"));const a=this.#ha.bind(this),h=Re.query.getScrollParents(t.get("originElement"));for(const t of h)this.scrollparents.push(t),this.#mi.addEvent(t,"scroll",a,!1);this.#mi.addEvent(this.__focusTemp,"focus",(t=>t.preventDefault()),!1),this.__eventDoc!==t.get("_wd")&&(this.__eventDoc=t.get("_wd"),this.#mi.addEvent(this.__eventDoc,"selectionchange",this.#ca.bind(this,this.__eventDoc),!1))}__addStatusbarEvent(t,e){/\d+/.test(e.get("height"))&&e.get("statusbar_resizeEnable")?e.set("__statusbarEvent",this.#mi.addEvent(t.get("statusbar"),"mousedown",this.#da.bind(this),!1)):Re.utils.addClass(t.get("statusbar"),"se-resizing-none")}_removeAllEvents(){this.#mi._init(),this._wwFrameObserver&&(this._wwFrameObserver.disconnect(),this._wwFrameObserver=null),this._toolbarObserver&&(this._toolbarObserver.disconnect(),this._toolbarObserver=null),this.#Gl&&(Mr.clearTimeout(this.#Gl),this.#Gl=null),this.__retainTimer&&(Mr.clearTimeout(this.__retainTimer),this.__retainTimer=null),this.#Yl&&=this.#mi.removeGlobalEvent(this.#Yl),this.#Xl&&=this.#mi.removeGlobalEvent(this.#Xl),this.#Kl&&=this.#mi.removeGlobalEvent(this.#Kl),this._formatAttrsTemp=null,this.__cacheStyleNodes=null,this.__inputPlugin=null,this.__inputBlurEvent=null,this.__inputKeyEvent=null,this.__focusTemp=null,this.__eventDoc=null,this.__secopy=null,this._lineBreakComp=null,this.scrollparents=null}_setSelectionSync(){this.#mi.removeGlobalEvent(this.#Yl),this.#Yl=this.#mi.addGlobalEvent("mouseup",(()=>{this.$.selection.init(),this.#mi.removeGlobalEvent(this.#Yl)}))}_retainStyleNodes(t,e){let s=e[0].cloneNode(!1);for(let t,i=1,n=e.length;i<n;i++)t=e[i].cloneNode(!1),s.appendChild(t),s=t;const{parent:i,inner:n}=this.$.nodeTransform.createNestedNode(e,null),o=Re.utils.createTextNode(Ae.zeroWidthSpace);n.appendChild(o),t.innerHTML="",t.appendChild(i),this.$.selection.setRange(o,1,o,1)}_clearRetainStyleNodes(t){t.innerHTML="<br>",this.$.selection.setRange(t,0,t,0)}_callPluginEvent(t,e){return this.$.pluginManager.emitEvent(t,e)}async _callPluginEventAsync(t,e){return await this.$.pluginManager.emitEventAsync(t,e)}__removeInput(){this.#t.set("_preventBlur",!1),this._inputFocus=!1,this.__inputBlurEvent=this.#mi.removeEvent(this.__inputBlurEvent),this.__inputKeyEvent=this.#mi.removeEvent(this.__inputKeyEvent),this.__inputPlugin=null}__postFocusEvent(t,e){(this.#t.mode.isInline||this.#t.mode.isBalloonAlways)&&this.#o.show(),this.#t.mode.isSubBalloonAlways&&this.$.subToolbar.show(),this.#o._resetSticky(),this.#Vl._updatePlaceholder(t),this.#mi.triggerEvent("onFocus",{frameContext:t,event:e}),this._callPluginEvent("onFocus",{frameContext:t,event:e})}__postBlurEvent(t,e){this.#t.mode.isInline?Mr.setTimeout((()=>{this.#t.get("hasFocus")||this._hideToolbar()}),0):this.#t.mode.isBalloon&&this._hideToolbar(),this.#t.mode.isSubBalloon&&this._hideToolbar_sub(),this.#mi.triggerEvent("onBlur",{frameContext:t,event:e}),this._callPluginEvent("onBlur",{frameContext:t,event:e})}__setViewportSize(){this.#t.set("currentViewportHeight",ze.get(Mr.visualViewport.height,0))}#ua(){this.#jl.currentDropdownActiveButton&&this.#jl.currentDropdown&&this.#jl.__resetMenuPosition(this.#jl.currentDropdownActiveButton,this.#jl.currentDropdown),this.#Vl._repositionControllers()}#pa(){Le.isResizeObserverSupported||(this.#o.resetResponsiveToolbar(),this.#ot.get("_subMode")&&this.$.subToolbar.resetResponsiveToolbar());const t=this.#e.get("toolbar_main"),e="none"===t.style.display||this.#t.mode.isInline&&!this.#o.inlineToolbarAttr.isShow;if(0===t.offsetWidth&&!e)return;const s=this.#Vl.opendBrowser;if(s&&"block"===s.area.style.display&&(s.body.style.maxHeight=Re.utils.getClientSize().h-s.header.offsetHeight-50+"px"),this.#jl.currentDropdownActiveButton&&this.#jl.currentDropdown&&this.#jl.__resetMenuPosition(this.#jl.currentDropdownActiveButton,this.#jl.currentDropdown),this.$.viewer._resetFullScreenHeight())return;const i=this.$.frameContext;i.get("isCodeView")&&this.#t.mode.isInline?this.#o._showInline():(this.#Vl._iframeAutoHeight(i),this.#o.isSticky&&(this.#o.isCSSSticky||(this.#e.get("toolbar_main").style.width=i.get("topArea").offsetWidth-2+"px"),this.#o._resetSticky()))}#ia(t,e,s){this.#Vl._syncScrollPosition(e),this.#ua(),this._callPluginEvent("onScroll",{frameContext:t,event:s}),t.has("documentType_use_page")&&t.get("documentType").scrollPage(),this.#mi.triggerEvent("onScroll",{frameContext:t,event:s})}#na(t,e){if(this.$.selection.__iframeFocus||t.get("isReadOnly")||t.get("isDisabled"))return e.preventDefault(),!1;this.#t.set("hasFocus",!0),this.$.component.__prevent=!1,this.#mi.triggerEvent("onNativeFocus",{frameContext:t,event:e});const s=t.get("key");this._inputFocus?this.#t.mode.isInline&&Mr.setTimeout((()=>{this.#o._showInline()}),0):this.#t.get("rootKey")===s&&this.#t.get("_preventBlur")||this.#t.get("_preventFocus")||(this.#t.set("_preventFocus",!0),Re.utils.removeClass(this.$.commandDispatcher.targets.get("codeView"),"active"),this.#Vl._toggleCodeViewButtons(!1),this.$.facade.changeFrameContext(s),this.$.history.resetButtons(s,null),Mr.setTimeout((()=>{this.__postFocusEvent(t,e)}),0))}#oa(t,e){t.get("isCodeView")||t.get("isReadOnly")||t.get("isDisabled")||(this.#t.set("hasFocus",!1),this.#t.set("_lastSelectionNode",null),this.#mi.triggerEvent("onNativeBlur",{frameContext:t,event:e}),this.#Vl._updatePlaceholder(t),this._inputFocus||this.#t.get("_preventBlur")||(this.#t.set("_preventFocus",!1),this.selectionState.reset(),this.#t.set("currentNodes",[]),this.#t.set("currentNodesMap",[]),this.#Vl.offCurrentController(),this.#gi.applyToRoots((t=>{t.get("navigation")&&(t.get("navigation").textContent="")})),this.$.history.check(t.get("key"),this.#t.get("_range")),this.__postBlurEvent(t,e)))}#da(t){t.stopPropagation(),this._resizeClientY=t.clientY,this.#Vl.enableBackWrapper("ns-resize"),this.#Xl=this.#mi.addGlobalEvent("mousemove",this.#ga.bind(this)),this.#Kl=this.#mi.addGlobalEvent("mouseup",this.#ma.bind(this))}#ga(t){const e=this.$.frameContext,s=e.get("wrapper").offsetHeight+(t.clientY-this._resizeClientY),i=s<e.get("_minHeight")?e.get("_minHeight"):s;e.get("wysiwygFrame").style.height=e.get("code").style.height=i+"px",this._resizeClientY=t.clientY,Le.isResizeObserverSupported||this.#Vl._emitResizeEvent(e,i,null)}#ma(){this.#Vl.disableBackWrapper(),this.#Xl&&=this.#mi.removeGlobalEvent(this.#Xl),this.#Kl&&=this.#mi.removeGlobalEvent(this.#Kl)}#la(t,e){e.preventDefault();const s=this._lineBreakComp;if(!s)return;const i=Re.check.isListCell(s.parentElement),n=Re.utils.createElement(i?"BR":Re.check.isTableCell(s.parentElement)?"DIV":this.#ot.get("defaultLine"));if(i||(n.innerHTML="<br>"),"byte-html"!==this.$.frameOptions.get("charCounter_type")||this.$.char.check(n.outerHTML)){s.parentNode.insertBefore(n,"t"===t?s:s.nextSibling),this.$.component.deselect();try{const t=i?n:n.firstChild;this.$.selection.setRange(t,1,t,1),this.$.history.push(!1)}catch(t){console.warn("[SUNEDITOR.lineBreaker.error]",t)}}}#Ql(){this.#t.set("initViewportHeight",Mr.visualViewport.height),Nr||this.#Vl.offCurrentController(),this.#t.mode.isBalloon?this.#o.hide():this.#t.mode.isSubBalloon&&this.$.subToolbar.hide(),this.#pa()}#ta(){Nr&&this.#ot.get("_toolbar_sticky")>-1&&(this.#o._resetSticky(),this.#jl.__restoreMenuPosition()),this.#ua();const t=this.#t.get("currentViewportHeight");this.__setViewportSize(),Nr&&t>0&&t-Mr.visualViewport.height>100&&this.#t.get("hasFocus")&&this.$.selection.scrollTo(this.$.selection.getRange(),{behavior:"auto",block:"nearest",inline:"nearest"})}#ea(){this.#ot.get("_toolbar_sticky")>-1&&this.#o._resetSticky(),this.#t.mode.isBalloon&&"block"===this.#e.get("toolbar_main").style.display?this.#o._setBalloonOffset("top"===this.#o.balloonOffset.position):this.#t.mode.isSubBalloon&&"block"===this.#e.get("toolbar_sub_main").style.display&&this.$.subToolbar._setBalloonOffset("top"===this.$.subToolbar.balloonOffset.position),this.#ua(),this.$.frameContext.has("documentType_use_page")&&this.$.frameContext.get("documentType").scrollWindow()}#sa(){this.#ot.get("_toolbar_sticky")>-1&&(this.#o._resetSticky(),this.#jl.__restoreMenuPosition())}#ca(t){let e=t.getSelection().anchorNode;this.#gi.applyToRoots((t=>{if(e&&t.get("wysiwyg").contains(e)){if(t.get("isReadOnly")||t.get("isDisabled"))return;if(e=null,this.$.selection.init(),this.applyTagEffect(),this.#Vl._updatePlaceholder(t),Br&&(this.#t.mode.isBalloon||this.#t.mode.isSubBalloon)&&this.#Zl(),t.has("documentType_use_header")){const e=Re.query.getParentElement(this.$.selection.selectionNode,this.$.format.isLine.bind(this.$.format));t.get("documentType").on(e)}}}))}#ha(){this.#jl.dropdownOff(),this.#ua()}#ra(t){this.$.facade.changeFrameContext(t.get("key")),Re.utils.addClass(this.$.commandDispatcher.targets.get("codeView"),"active"),this.#Vl._toggleCodeViewButtons(!0)}#aa(t){this.$.facade.changeFrameContext(t.get("key")),Re.utils.addClass(this.$.commandDispatcher.targets.get("markdownView"),"active"),this.#Vl._toggleCodeViewButtons(!0)}};const Ar=class{#fa=new Map;#va=new Map;$=null;constructor(t,e){const{product:s,options:i}=e;this.store=new ys(s),this.$={facade:t,store:this.store},this.#ba(s,i),this.#ya(),this.#wa(s),this.#Ca(),this.#_a(),this._eventOrchestrator=new Lr(this),this.#fa.get("eventManager")._bindOrchestrator(this._eventOrchestrator)}#ba(t,e){const s=new _s(t),i=new ks(this,t,e);this.#fa.set("contextProvider",s),this.#fa.set("optionProvider",i),this.#fa.set("instanceCheck",new xs(s.frameContext)),this.#fa.set("eventManager",new Ts(s,i,this.$))}#ya(){const t=this.#fa.get("contextProvider"),e=this.#fa.get("optionProvider");Object.assign(this.$,{contextProvider:t,optionProvider:e,instanceCheck:this.#fa.get("instanceCheck"),eventManager:this.#fa.get("eventManager"),frameRoots:t.frameRoots,context:t.context,options:e.options,icons:t.icons,lang:t.lang,frameContext:t.frameContext,frameOptions:e.frameOptions})}#wa(t){this.#va.set("offset",new Ms(this)),this.#va.set("selection",new Bs(this)),this.#va.set("html",new pi(this)),this.#va.set("nodeTransform",new gi(this)),this.#va.set("format",new Ls(this)),this.#va.set("inline",new Os(this)),this.#va.set("listFormat",new zs(this)),this.#va.set("char",new fi(this)),this.#va.set("shortcuts",new vi(this)),this.#va.set("component",new Zi(this)),this.#va.set("pluginManager",new Ji(this,t)),this.#va.set("focusManager",new Qi(this)),this.#va.set("ui",new $n(this)),this.#va.set("commandDispatcher",new Cn(this)),this.#va.set("toolbar",new Tn(this,{keyName:"toolbar",balloon:this.store.mode.isBalloon,balloonAlways:this.store.mode.isBalloonAlways,inline:this.store.mode.isInline,res:t.responsiveButtons})),this.$.options.has("_subMode")&&this.#va.set("subToolbar",new Tn(this,{keyName:"toolbar_sub",balloon:this.store.mode.isSubBalloon,balloonAlways:this.store.mode.isSubBalloonAlways,inline:!1,res:t.responsiveButtons_sub})),this.#va.set("menu",new In(this)),this.#va.set("viewer",new Rn(this)),this.#va.set("finder",new Fn(this)),this.#va.set("history",Sn(this))}#_a(){for(const[,t]of this.#va)"function"==typeof t?._init&&t._init()}#Ca(){const t=this.#va.get("pluginManager");Object.assign(this.$,{offset:this.#va.get("offset"),selection:this.#va.get("selection"),format:this.#va.get("format"),inline:this.#va.get("inline"),listFormat:this.#va.get("listFormat"),html:this.#va.get("html"),nodeTransform:this.#va.get("nodeTransform"),char:this.#va.get("char"),component:this.#va.get("component"),focusManager:this.#va.get("focusManager"),pluginManager:t,plugins:t.plugins,ui:this.#va.get("ui"),commandDispatcher:this.#va.get("commandDispatcher"),history:this.#va.get("history"),shortcuts:this.#va.get("shortcuts"),toolbar:this.#va.get("toolbar"),subToolbar:this.#va.get("subToolbar"),menu:this.#va.get("menu"),viewer:this.#va.get("viewer"),finder:this.#va.get("finder")})}_destroy(){if(null===this.$)return;const t=[];for(const[e,s]of this.#va)try{s?._destroy?.()}catch(s){t.push(`[Logic:${e}] ${s.message}`)}this.#va.clear();try{this._eventOrchestrator?._removeAllEvents()}catch(e){t.push(`[EventOrchestrator] ${e.message}`)}this._eventOrchestrator=null;for(const[e,s]of this.#fa)try{s?._destroy?.()}catch(s){t.push(`[Config:${e}] ${s.message}`)}this.#fa.clear(),t.length>0&&console.warn("[CoreKernel._destroy] Cleanup completed with errors:",t),this.$=null,this.store._destroy(),this.store=null,this.facade=null}};const Or=class{#H;$;constructor(t,e){const s=ms(t,e),i=new Ar(this,{product:s,options:e});this.#H=i,this.$=i.$,this.#ka(e).catch((t=>{console.error("[SUNEDITOR:E_CREATE_FAIL] Failed to create editor instance.",t)}))}isEmpty(t){const e=(t||this.$.frameContext).get("wysiwyg");return Re.check.isZeroWidth(e.textContent)&&!e.querySelector(this.$.options.get("allowedEmptyTags"))&&(e.innerText.match(/\n/g)||"").length<=1}resetOptions(t){this.$.optionProvider.reset(t),this.$.store.set("_lastSelectionNode",null),this.#xa(this.$.frameRoots.get(this.$.store.get("rootKey")));for(const t of Object.values(this.$.plugins))t.init?.()}changeFrameContext(t){t!==this.$.store.get("rootKey")&&(this.$.store.set("rootKey",t),this.#xa(this.$.frameRoots.get(t)),this.$.toolbar._resetSticky())}destroy(){this.$.options.get("hasCodeMirror")&&this.$.contextProvider.applyToRoots((t=>{const e=t.get("options").get("codeMirrorEditor");e&&e.toTextArea()})),Re.utils.removeItem(this.$.context.get("toolbar_wrapper")),Re.utils.removeItem(this.$.context.get("toolbar_sub_wrapper")),Re.utils.removeItem(this.$.context.get("statusbar_wrapper"));for(const t in this.events)this.events[t]=null;return this.events=null,this.#H._destroy(),null}#xa(t){this.$.contextProvider.reset(t),this.$.optionProvider.resetFrame(t.get("options")),this.$.ui.reset(t)}#$a(t){this.$.store.set("initViewportHeight",Le._w.visualViewport.height),this.#H._eventOrchestrator.__setViewportSize(),this.$.store.set("_canUseBeforeInput",Le.canUseBeforeInput()),this.$.contextProvider.init(),this.#xa(this.$.frameRoots.get(this.$.store.get("rootKey"))),this.#xs(t),this.$.contextProvider.applyToRoots((t=>{this.#H._eventOrchestrator._addFrameEvents(t),this.#Sa(t,t.get("options").get("value")),t.get("options").get("iframe")&&"auto"===t.get("options").get("height")&&this.$.ui._emitResizeEvent(t,t.get("wysiwygFrame").offsetHeight,null)})),this.#H._eventOrchestrator.__eventDoc=null,this.$.store._editorInitFinished=!0,this.$.pluginManager.checkFileInfo(!0),this.$.history.reset(),Le._w.setTimeout((()=>{if(this.$.context?.size){this.$.context.get("toolbar_main").style.visibility="",this.$.contextProvider.applyToRoots((t=>{this.#H._eventOrchestrator._wwFrameObserver&&this.#H._eventOrchestrator._wwFrameObserver.observe(t.get("wysiwygFrame")),this.#H._eventOrchestrator._toolbarObserver&&this.#H._eventOrchestrator._toolbarObserver.observe(t.get("_toolbarShadow")),this.$.ui._syncFrameState(t)}));for(const t of Object.values(this.$.plugins))t.init?.();this.$.selection.__init(),this.$.eventManager.triggerEvent("onload",{})}else console.warn("[SUNEDITOR:E_INIT_FAIL] Editor instance was destroyed before initialization completed. Check if destroy() was called.")}),0)}#Sa(t,e){t.get("wysiwyg").innerHTML=this.$.html.clean("string"==typeof e?e:(/^TEXTAREA$/i.test(t.get("originElement").nodeName)?t.get("originElement").value:t.get("originElement").innerHTML)||"",{forceFormat:!0,whitelist:null,blacklist:null,_freeCodeViewMode:this.$.options.get("freeCodeViewMode")})||"<"+this.$.options.get("defaultLine")+"><br></"+this.$.options.get("defaultLine")+">",t.has("charCounter")&&(t.get("charCounter").textContent=String(this.$.char.getLength())),t.has("wordCounter")&&(t.get("wordCounter").textContent=String(this.$.char.getWordCount())),"document"===this.$.options.get("type")&&(t.set("documentType",new bs(this.#H,t)),t.get("documentType").useHeader&&t.set("documentType_use_header",!0),t.get("documentType").usePage&&(t.set("documentType_use_page",!0),t.get("documentTypePageMirror").innerHTML=t.get("wysiwyg").innerHTML))}#xs(t){this.$.pluginManager.init(t),this.$.shortcuts._registerShortcuts(),this.$.commandDispatcher._initCommandButtons(),this.$.ui.init()}#Ea(t,e,s){t.contentDocument.documentElement.className="sun-editor",t.contentDocument.head.innerHTML='<meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">'+Oe._setIframeStyleLinks(s.get("iframe_cssFileName"))+Oe._setAutoHeightStyle(s.get("height")),t.contentDocument.body.className=e.get("_editableClass"),t.contentDocument.body.setAttribute("contenteditable","true"),e.get("_rtl")&&(t.contentDocument.body.dir="rtl")}async#ka(t){this.#H._eventOrchestrator._addCommonEvents();const e=[];this.$.contextProvider.applyToRoots((t=>{const s=t.get("originElement"),i=t.get("topArea");if(s.style.display="none",i.style.display="block",s.parentNode.insertBefore(i,s.nextElementSibling),t.get("options").get("iframe")){const s=new Promise((e=>{const s=s=>{this.#Ea(s,this.$.optionProvider.options,t.get("options")),e()};if(Le.isGecko){let e=null;this.$.eventManager.addEvent(t.get("wysiwygFrame"),"load",(({target:t})=>{clearTimeout(e),e=setTimeout((()=>{this.$&&s(t)}),60)}))}else this.$.eventManager.addEvent(t.get("wysiwygFrame"),"load",(({target:t})=>{s(t)}))}));e.push(s)}})),this.$.contextProvider.applyToRoots((t=>{t.get("wrapper").appendChild(t.get("wysiwygFrame")),t.get("documentTypeInner")&&t.get("wrapper").insertBefore(t.get("documentTypeInner"),t.get("wysiwygFrame")),t.get("documentTypePage")&&(t.get("wrapper").appendChild(t.get("documentTypePage")),t.get("wrapper").appendChild(t.get("documentTypePageMirror"))),t.get("blockHandleArea")&&t.get("wrapper").insertBefore(t.get("blockHandleArea"),t.get("wysiwygFrame"))})),e.length>0&&await Promise.all(e),this.#$a(t)}};function Rr(t){let e;try{e=t.responseText}catch{return`status ${t.status}`}if(!e)return`status ${t.status}`;try{return JSON.parse(e)}catch{return e}}const zr=class{#J;#Ta;constructor(t,e,s){this.#J=e,this.kind=t.constructor.key||t.constructor.name,this.#Ta=Le.getXMLHttpRequest(),this.method=s?.method,this.url=s?.url,this.headers=s?.headers,this.data=s?.data,this.callBack=s?.callBack,this.errorCallBack=s?.errorCallBack,this.responseType=s?.responseType}call({method:t,url:e,headers:s,data:i,callBack:n,errorCallBack:o,responseType:r}){if(this.cancel(),t||=this.method,e=this.#Ma(e||this.url),s||=this.headers,i||=this.data,n||=this.callBack,o||=this.errorCallBack,r||=this.responseType,"function"!=typeof n)throw new Error(`[SUNEDITOR.ApiManager[${this.kind}].upload.callBack.fail] callBack is not a function`);const l=this.#Ta;if(r&&(l.responseType=r),l.onreadystatechange=this.#Na.bind(this,l,n,o),l.open(t,e,!0),null!==s&&"object"==typeof s&&Object.keys(s).length>0)for(const t in s)l.setRequestHeader(t,s[t]);l.send(i)}asyncCall({method:t,url:e,headers:s,data:i,responseType:n}){this.cancel(),t||=this.method,e=this.#Ma(e||this.url),s||=this.headers,i||=this.data,n||=this.responseType;const o=this.#Ta;return n&&(o.responseType=n),new Promise(((n,r)=>{if(o.open(t,e,!0),null!==s&&"object"==typeof s&&Object.keys(s).length>0)for(const t in s)o.setRequestHeader(t,s[t]);o.onload=()=>{if(200===o.status)try{n(o)}finally{this.#J.ui.hideLoading()}else{console.error(`[SUNEDITOR.ApiManager[${this.kind}].upload.serverException]`,o);try{r(Rr(o))}finally{this.#J.ui.hideLoading()}}},o.onerror=()=>{this.#J.ui.hideLoading(),r(new Error("Network error"))},o.send(i)}))}cancel(){this.#Ta&&(this.#Ta.onreadystatechange=null,this.#Ta.onload=null,this.#Ta.onerror=null,this.#Ta.abort())}#Ma(t){return t?t.replace(/([^:])\/+/g,"$1/").replace(/\/(\?|#|$)/,"$1"):""}async#Na(t,e,s){if(4===t.readyState)if(200===t.status)try{await e(t)}catch(t){throw Error(`[SUNEDITOR.ApiManager[${this.kind}].upload.callBack.fail] ${t.message}`)}finally{this.#J.ui.hideLoading()}else{console.error(`[SUNEDITOR.ApiManager[${this.kind}].upload.serverException]`,t);try{const e=Rr(t);let i="";"function"==typeof s&&(i=await s(e,t));const n=`[SUNEDITOR.ApiManager[${this.kind}].upload.serverException] status: ${t.status}, response: ${i||e.errorMessage||("string"==typeof e?e:JSON.stringify(e))}`;this.#J.ui.alertOpen(n,"error")}catch(t){throw Error(`[SUNEDITOR.ApiManager[${this.kind}].upload.errorCallBack.fail] ${t.message}`)}finally{this.#J.ui.hideLoading()}}}};function Pr(t){const e=t.src.split("/").pop(),s=t.thumbnail||"",i=s||t.src,n=this.props?.map((e=>`data-${e}="${t[e]}"`)).join(" ")||"",o=`data-type="${t.type}" data-command="${t.src}" data-name="${t.name||e}" data-thumbnail="${s}" data-extension="${t.src.split(".").pop()}" ${n}`,r=`class="${s||"se-browser-empty-image"}" src="${i}" alt="${t.alt||e}" ${o}`;return`\n\t\t<div class="se-file-item-img">\n\t\t\t${this.thumbnail&&!s&&"image"!==t.type?`<div class="se-browser-empty-thumbnail" ${r}>${this.thumbnail(t)}</div>`:`<img class="${s||"se-browser-empty-image"}" ${r}>`}\n\t\t\t<div class="se-file-name-image se-file-name-back"></div>\n\t\t\t<div class="se-file-name-image">${t.name||e}</div>\n\t\t</div>`}const Dr=class{#J;#Ba;#Go;#Ia=[];#La;#Aa;#po=!1;#vo=null;constructor(t,e,s){this.#J=e,this.useSearch=s.useSearch??!0;const i=Re.utils.createElement("DIV",{class:"se-browser sun-editor-common"+(s.className?` ${s.className}`:"")}),n=function(t,e){const s=t.lang,i=t.icons,n=`\n\t\t<div class="se-browser-content">\n\t\t\t<div class="se-browser-header">\n\t\t\t\t<button type="button" data-command="close" class="se-btn se-browser-close" class="close" title="${s.close}" aria-label="${s.close}">\n\t\t\t\t\t${i.cancel}\n\t\t\t\t</button>\n\t\t\t\t<span class="se-browser-title"></span>\n\t\t\t</div>\n\t\t\t<div class="se-browser-wrapper">\n\t\t\t\t<div class="se-browser-side"></div>\n\t\t\t\t<div class="se-browser-main"> \n\t\t\t\t\t<div class="se-browser-bar">\n\t\t\t\t\t\t<div class="se-browser-search">\n\t\t\t\t\t\t\t<button type="button" class="se-btn se-side-open-btn">${i.side_menu_hamburger}</button>\n\t\t\t\t\t\t\t${e?`\n\t\t\t\t\t\t\t\t\t\t<form class="se-browser-search-form">\n\t\t\t\t\t\t\t\t\t\t\t<div class="se-browser-search-input-wrap">\n\t\t\t\t\t\t\t\t\t\t\t\t<input type="text" class="se-input-form" placeholder="${s.search}" aria-label="${s.search}">\n\t\t\t\t\t\t\t\t\t\t\t\t<button type="button" class="se-btn se-btn-plain se-browser-search-clear" title="${s.cancel}" aria-label="${s.cancel}" style="display:none">${i.cancel}</button>\n\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t\t<button type="submit" class="se-btn" title="${s.search}" aria-label="${s.search}">${i.search}</button>\n\t\t\t\t\t\t\t\t\t\t</form>`:""}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class="se-browser-body">\n\t\t\t\t\t\t<div class="se-browser-tags"></div>\n\t\t\t\t\t\t<div class="se-loading-box sun-editor-common"><div class="se-loading-effect"></div></div>\n\t\t\t\t\t\t<div class="se-browser-menus"></div>\n\t\t\t\t\t\t<div class="se-browser-list"></div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>`,o=Re.utils.createElement("DIV",{class:"se-browser-inner"},n);return{html:o,header:o.querySelector(".se-browser-header"),titleArea:o.querySelector(".se-browser-title"),tagArea:o.querySelector(".se-browser-tags"),body:o.querySelector(".se-browser-body"),list:o.querySelector(".se-browser-list"),side:o.querySelector(".se-browser-side"),wrapper:o.querySelector(".se-browser-wrapper"),_loading:o.querySelector(".se-loading-box")}}(this.#J,this.useSearch),o=n.html;this.kind=t.constructor.key||t.constructor.name,this.host=t,this.area=i,this.header=n.header,this.titleArea=n.titleArea,this.tagArea=n.tagArea,this.body=n.body,this.list=n.list,this.side=n.side,this.wrapper=n.wrapper,this.#Ba=n._loading,this.title=s.title,this.listClass=s.listClass||"se-preview-list",this.directData=s.data,this.url=s.url,this.headers=s.headers,this.searchUrl=s.searchUrl,this.searchHeaders=s.searchHeaders,this.drawItemHandler=(s.drawItemHandler||Pr).bind({thumbnail:s.thumbnail,props:s.props||[]}),this.selectorHandler=s.selectorHandler,this.columnSize=s.columnSize||4,this.expand=s.expand??1,this.folderDefaultPath="",this.closeArrow=this.#J.icons.menu_arrow_right,this.openArrow=this.#J.icons.menu_arrow_down,this.icon_folder=this.#J.icons.side_menu_folder_item,this.icon_folder_item=this.#J.icons.side_menu_folder,this.icon_item=this.#J.icons.side_menu_item,this.items=[],this.folders={},this.tree={},this.data={},this.selectedTags=[],this.keyword="",this.sideInner=null,this.apiManager=new zr(this,e,{method:"GET"}),this.#Go=t=>{Pe.isEsc(t.code)&&this.close()},i.appendChild(Re.utils.createElement("DIV",{class:"se-browser-back"})),i.appendChild(o),i.setAttribute("popover","manual"),this.#J.contextProvider.carrierWrapper.appendChild(i),this.#J.eventManager.addEvent(this.tagArea,"click",this.#Oa.bind(this)),this.#J.eventManager.addEvent(this.list,"click",this.#Ra.bind(this)),this.#J.eventManager.addEvent(this.side,"click",this.#za.bind(this)),this.#J.eventManager.addEvent(o,"mousedown",this.#Pa.bind(this)),this.#J.eventManager.addEvent(o,"click",this.#Da.bind(this)),this.#J.eventManager.addEvent(this.sideOpenBtn=i.querySelector(".se-side-open-btn"),"click",this.#Fa.bind(this)),this.#J.eventManager.addEvent([this.header,i.querySelector(".se-browser-main")],"mousedown",this.#Ha.bind(this));const r=i.querySelector("form.se-browser-search-form");this.#La=r?.querySelector('input[type="text"]'),this.#Aa=i.querySelector(".se-browser-search-clear"),this.#J.eventManager.addEvent(r,"submit",this.#qa.bind(this)),this.#J.eventManager.addEvent(this.#Aa,"click",this.#Wa.bind(this))}open(t={}){this.#De();const e=t.listClass||this.listClass;Re.utils.hasClass(this.list,e)||(this.list.className="se-browser-list "+e),this.titleArea.textContent=t.title||this.title,this.area.style.display="block",this.area.showPopover?.(),this.#J.ui.opendBrowser=this,this.closeArrow=this.#J.options.get("_rtl")?this.#J.icons.menu_arrow_left:this.#J.icons.menu_arrow_right,this.directData?this.#Ua(this.directData):this.#Va(t.url||this.url,t.headers||this.headers,!1),this.body.style.maxHeight=Re.utils.getClientSize().h-(this.#J.offset.getGlobal(this.body).top-o.scrollY)-20+"px"}close(){this.#We(),this.apiManager.cancel(),this.area.hidePopover?.(),this.area.style.display="none",this.selectedTags=[],this.items=[],this.#Ia=[],this.folders={},this.tree={},this.data={},this.keyword="",this.list.innerHTML=this.tagArea.innerHTML=this.titleArea.textContent="",this.#La&&(this.#La.value=""),this.#Aa&&(this.#Aa.style.display="none"),this.#J.ui.opendBrowser=null,this.sideInner=null,this.host.browserInit?.()}search(t){if(this.searchUrl){this.keyword=t;const e=this.searchUrl.includes("?")?"&":"?";this.#Va(this.searchUrl+e+"keyword="+o.encodeURIComponent(t),this.searchHeaders,!1)}else this.keyword=t.toLowerCase(),this.#ja(this.#Ia.length>0?this.#Ia:this.items,!1)}#Ga(){const t=[];for(const e in this.data){const s=this.data[e];if(Array.isArray(s))for(let e=0;e<s.length;e++)t.push(s[e])}return t}tagfilter(t){const e=this.selectedTags;return 0===e.length?t:t.filter((t=>!Array.isArray(t.tag)||t.tag.some((t=>e.includes(t)))))}showBrowserLoading(){this.#Ba.style.display="block"}closeBrowserLoading(){this.#Ba.style.display="none"}#Va(t,e,s){this.apiManager.call({method:"GET",url:t,headers:e,callBack:this.#Ka.bind(this),errorCallBack:this.#Ya.bind(this)}),s||(this.sideOpenBtn.style.display="none",this.showBrowserLoading())}#ja(t,e){const s=this.keyword,i=[],n=(t=this.tagfilter(t).filter((t=>t.name.toLowerCase().indexOf(s)>-1))).length,o=this.columnSize,r=o<=1?1:Math.round(n/o)||1,l=this.drawItemHandler;let a="",h='<div class="se-file-item-column">',c=1;for(let s,d,u=0;u<n;u++)if(s=t[u],d=s.tag?"string"==typeof s.tag?s.tag.split(","):s.tag:[],d=s.tag=d.map((t=>t.trim())),h+=l(s),(u+1)%r==0&&c<o&&u+1<n&&(c++,h+='</div><div class="se-file-item-column">'),e&&d.length>0)for(let t,e=0,s=d.length;e<s;e++)t=d[e],t&&!i.includes(t)&&(i.push(t),a+=`<a title="${t}" aria-label="${t}">${t}</a>`);h+="</div>",this.list.innerHTML=h,s&&this.#Xa(s),e&&(this.items=t,this.tagArea.innerHTML=a)}#De(){this.#We(),this.#vo=this.#J.eventManager.addGlobalEvent("keydown",this.#Go,!0)}#We(){this.#vo&&=this.#J.eventManager.removeGlobalEvent(this.#vo)}#Ua(t){if(Array.isArray(t))return t.length>0&&this.#ja(t,!0),!0;if("object"==typeof t){this.sideOpenBtn.style.display="",this.#Za(t),this.#Ia=this.#Ga(),this.side.innerHTML="";const e=this.sideInner=Re.utils.createElement("div",null);if(this.#Ja(this.tree,e),this.side.appendChild(e),this.folderDefaultPath){const t=e.querySelector(`[data-command="${this.folderDefaultPath}"]`);t.click(),this.folderDefaultPath.includes("/")&&(Re.utils.removeClass(t.parentElement,"se-menu-hidden"),t.parentElement.previousElementSibling.querySelector("button").innerHTML=this.openArrow)}return!0}return!1}#Za(t,e){let s=this.tree;if(t._data){this.data[e]=t._data,this.folderDefaultPath&&!t.default||(this.folderDefaultPath=e);const i=e.split("/"),n=i.length-1;i.forEach(((t,i)=>{s[t]||={children:{}},i===n?(s[t].key=e,s[t].name=this.folders[e].name):s=s[t].children}))}else e&&(s[e]={name:this.folders[e].name,children:{}});Object.entries(t).forEach((([t,s])=>{if("_data"===t||!s||"object"!=typeof s)return;const i=s,n=e?`${e}/${t}`:t;this.folders[n]={name:i.name||t,meta:i.meta||{}},this.#Za(i,n)}))}#Ja(t,e,s=0){const i=s<this.expand;for(const n in t){const o=t[n];if(o)if(Object.keys(o.children).length>0){const t=Re.utils.createElement("div",o.key?{"data-command":o.key,"aria-label":o.name}:null,`<span class="se-menu-icon">${o.key?this.icon_folder:this.icon_folder_item}</span><span>${o.name}</span>`),n=Re.utils.createElement("div",{class:"se-menu-folder"},t);t.insertBefore(Re.utils.createElement("button",{type:"button"},i?this.openArrow:this.closeArrow),t.firstElementChild);const r=document.createElement("div");Re.utils.addClass(r,i?"se-menu-child":"se-menu-child|se-menu-hidden"),this.#Ja(o.children,r,s+1),n.appendChild(r),e.appendChild(n)}else{const t=Re.utils.createElement("div",{"data-command":o.key,"aria-label":o.name,class:"se-menu-folder-item"},`<span class="se-menu-icon">${this.icon_item}</span><span>${o.name}</span>`);if(e===this.sideInner){const s=Re.utils.createElement("div",{class:"se-menu-folder"},t);e.appendChild(s)}else e.appendChild(t)}}}#Ka(t){try{const e=JSON.parse(t.responseText),s=e.result;if(this.#Ua(s))return;e.nullMessage&&(this.list.innerHTML=e.nullMessage)}catch(t){throw Error(`[SUNEDITOR.browser.drawList.fail] cause: "${t.message}"`)}finally{this.closeBrowserLoading()}}#Ya(t,e){throw this.closeBrowserLoading(),Error(`[SUNEDITOR.browser.get.serverException] status: ${e.status}, response: ${t.errorMessage||e.responseText}`)}#Oa(t){const e=Re.query.getEventTarget(t);if(!Re.check.isAnchor(e))return;const s=e.textContent,i=this.tagArea.querySelector('a[title="'+s+'"]'),n=this.selectedTags.indexOf(s);n>-1?(this.selectedTags.splice(n,1),Re.utils.removeClass(i,"on")):(this.selectedTags.push(s),Re.utils.addClass(i,"on")),this.#ja(this.items,!1)}#Ra(t){const e=Re.query.getEventTarget(t);if(t.preventDefault(),t.stopPropagation(),e===this.list)return;const s=Re.query.getCommandTarget(e);s&&(this.close(),this.selectorHandler(s))}#za(t){const e=Re.query.getEventTarget(t);if(t.stopPropagation(),/^button$/i.test(e.nodeName)){const t=e.parentElement.parentElement.querySelector(".se-menu-child");return void(Re.utils.hasClass(t,"se-menu-hidden")?(Re.utils.removeClass(t,"se-menu-hidden"),e.innerHTML=this.openArrow):(Re.utils.addClass(t,"se-menu-hidden"),e.innerHTML=this.closeArrow))}const s=Re.query.getCommandTarget(e);if(!s||Re.utils.hasClass(s,"active"))return;const i=this.data[s.getAttribute("data-command")];Re.utils.removeClass(this.side.querySelectorAll(".active"),"active"),Re.utils.addClass([s,Re.query.getParentElement(s,".se-menu-folder")],"active"),this.tagArea.innerHTML="",this.selectedTags=[],"string"==typeof i?this.#Va(i,this.headers,!0):this.#ja(i,!0)}#Pa(t){const e=Re.query.getEventTarget(t);/se-browser-inner/.test(e.className)?this.#po=!0:this.#po=!1}#Da(t){const e=Re.query.getEventTarget(t);t.stopPropagation(),(/close/.test(e.getAttribute("data-command"))||this.#po)&&this.close()}#qa(t){t.preventDefault();const e=this.#La.value;this.search(e),this.#Aa&&(this.#Aa.style.display=e?"":"none")}#Wa(){this.#La&&(this.#La.value=""),this.#Aa&&(this.#Aa.style.display="none"),this.keyword="",this.#ja(this.items,!1)}#Xa(t){const e=this.list.querySelectorAll(".se-file-name-image:not(.se-file-name-back)");for(let s=0;s<e.length;s++){const i=e[s],n=i.textContent,o=n.toLowerCase().indexOf(t);o>-1&&(i.innerHTML=n.substring(0,o)+"<mark>"+n.substring(o,o+t.length)+"</mark>"+n.substring(o+t.length))}}#Fa(t){const e=Re.query.getEventTarget(t);Re.utils.hasClass(e,"active")?(Re.utils.removeClass(this.side,"se-side-show"),Re.utils.removeClass(e,"active")):(Re.utils.addClass(this.side,"se-side-show"),Re.utils.addClass(e,"active"))}#Ha({target:t}){t!==this.sideOpenBtn&&Re.utils.hasClass(this.sideOpenBtn,"active")&&(Re.utils.removeClass(this.side,"se-side-show"),Re.utils.removeClass(this.sideOpenBtn,"active"))}},{isTouchDevice:Fr}=Le,Hr=240,qr=120,Wr={hex:"#FFFFFF",r:255,g:255,b:255,h:0,s:1,l:1};let Ur,Vr=0,jr=!1,Gr=!1,Kr=120,Yr=120,Xr=Wr,Zr=!1;const{slider:Jr,offscreenCanvas:Qr,offscreenCtx:tl,wheel:el,wheelCtx:sl,wheelPointer:il,gradientBar:nl,gradientPointer:ol,fanalColorHex:rl,fanalColorBackground:ll}=function(){const t=document.createElement("canvas");t.width=Hr,t.height=Hr;const e=`\n\t<div class="se-hue-slider-container" style="width: 240px; height: 240px;">\n <canvas class="se-hue-wheel" width="240" height="240"></canvas>\n <div class="se-hue-wheel-pointer"></div>\n </div>\n <div class="se-hue-gradient-container">\n <canvas class="se-hue-gradient" width="240" height="28"></canvas>\n <div class="se-hue-gradient-pointer"></div>\n </div>\n <div class="se-hue-final-hex" style="width:240px; height: 28px;">\n\t\t<div style="flex: 3; line-height: 1.5;">${Wr.hex}</div>\n\t\t<div style="flex: 1; height: 100%; border: 1px solid #fff; outline: 1px solid #000;"></div>\n\t</div>\n\t`,s=Re.utils.createElement("DIV",{class:"se-hue-slider"},e),i=s.querySelector(".se-hue-wheel"),n=s.querySelector(".se-hue-gradient"),o=s.querySelector(".se-hue-final-hex").children;return{slider:s,offscreenCanvas:t,offscreenCtx:t.getContext("2d"),wheel:i,wheelCtx:i.getContext("2d"),wheelPointer:s.querySelector(".se-hue-wheel-pointer"),gradientBar:n,gradientPointer:s.querySelector(".se-hue-gradient-pointer"),fanalColorHex:o[0],fanalColorBackground:o[1]}}();function al(t){const{target:e,touches:s}=t,i=s[0].clientX,n=s[0].clientY;e===el?(t.preventDefault(),Gr=!1,jr=!0,ul(i,n)):e===nl&&(t.preventDefault(),Gr=!0,jr=!1,pl(i))}function hl(t){t.preventDefault();const{touches:e}=t,s=e[0].clientX,i=e[0].clientY;jr?ul(s,i):Gr&&pl(s)}function cl({target:t,clientX:e,clientY:s}){t===el?(Gr=!1,jr=!0,ul(e,s)):t===nl&&(Gr=!0,jr=!1,pl(e))}function dl({clientX:t,clientY:e}){jr?ul(t,e):Gr&&pl(t)}function ul(t,e){const s=el.getBoundingClientRect();t=t-s.left-qr,e=e-s.top-qr;const i=180*Math.atan2(e,t)/Math.PI,n=Math.min(Math.sqrt(t*t+e*e),qr),o=qr+n*Math.cos(i*Math.PI/180),r=qr+n*Math.sin(i*Math.PI/180);il.style.left=`${o}px`,il.style.top=`${r}px`,function(t,e){Kr=t,Yr=e,gl(ml())}(o,r),fl()}function pl(t){const e=nl.getBoundingClientRect();let s=t-e.left;s=Math.max(14,Math.min(s,e.width-14)),ol.style.left=`${s}px`,function(t){const e=nl.getBoundingClientRect();let s=t-e.left;s<0&&(s=0);s>e.width&&(s=e.width);const i=14;s>=nl.width-i?s=nl.width:s<=i&&(s=0);const n=1-s/e.width;Vr=n,yl()}(t),fl()}function gl(t){const e=nl.getContext("2d"),s=e.createLinearGradient(0,0,nl.width,0);s.addColorStop(0,"black"),s.addColorStop(1,t.hex),e.fillStyle=s,e.fillRect(0,0,nl.width,nl.height)}function ml(){return bl(tl)}function fl(){Ur.color=Xr=bl(sl),vl(Xr.hex)}function vl(t){ll.style.backgroundColor=rl.textContent=t}function bl(t){const e=t.getImageData(Kr,Yr,1,1).data;let[s,i,n]=function([t,e,s]){t/=255,e/=255,s/=255;const i=Math.max(t,e,s),n=Math.min(t,e,s);let o,r;const l=(i+n)/2;if(i===n)o=r=0;else{const a=i-n;switch(r=l>.5?a/(2-i-n):a/(i+n),i){case t:o=(e-s)/a+(e<s?6:0);break;case e:o=(s-t)/a+2;break;case s:o=(t-e)/a+4}o/=6}return[Cl(o),Cl(r),Cl(l)]}(e);const o=Kr-qr,r=Yr-qr;Math.sqrt(o*o+r*r)<3&&(n=1-Vr),n>1&&(n=1),n<0&&(n=0);const{r:l,g:a,b:h}=function([t,e,s]){let i,n,o;if(0===e)i=n=o=s;else{const r=function(t,e,s){return s<0&&(s+=1),s>1&&(s-=1),s<1/6?t+6*(e-t)*s:s<.5?e:s<2/3?t+(e-t)*(2/3-s)*6:t},l=s<.5?s*(1+e):s+e-s*e,a=2*s-l;i=r(a,l,t+1/3),n=r(a,l,t),o=r(a,l,t-1/3)}return{r:Math.round(255*i),g:Math.round(255*n),b:Math.round(255*o)}}([s,i,n]),c=`#${function({r:t,g:e,b:s}){let i=Math.floor(t).toString(16);t<16&&(i=`0${i}`);let n=Math.floor(e).toString(16);e<16&&(n=`0${n}`);let o=Math.floor(s).toString(16);s<16&&(o=`0${o}`);return`${i}${n}${o}`.toUpperCase()}({r:l,g:a,b:h})}`;return{hex:c,r:l,g:a,b:h,h:s,s:i,l:Cl(n)}}function yl(){sl.clearRect(0,0,Hr,Hr),sl.drawImage(Qr,0,0),sl.globalAlpha=Vr,sl.fillStyle="black",sl.beginPath(),sl.arc(qr,qr,qr,0,2*Math.PI),sl.fill(),sl.globalAlpha=1}function wl(t){return t*Math.PI/180}function Cl(t){const e=Math.pow(10,10);return Math.round(t*e)/e}function _l(){!function(t){if(!t)return void console.warn("[HueSlider.fail] Context not found.");for(let e=0;e<=360;e+=.5)for(let s=0;s<=qr;s+=1){t.beginPath();const i=50+(qr-s)/qr*50;t.fillStyle=`hsl(${e}, 100%, ${i}%)`;const n=qr+Math.cos(wl(e))*s,o=qr-Math.sin(wl(e))*s;t.arc(n,o,1.5,0,2*Math.PI),t.fill()}Zr=!0}(tl),Zr&&yl()}_l();const kl=class{#J;#Qa;#th;#eh;#sh;#ih;#nh;constructor(t,e,s={},i=""){if(this.#J=e,this.inst=t,this.ctx={wheelX:Kr,wheelY:Yr,lightness:Vr,wheelPointerX:"50%",wheelPointerY:"50%",gradientPointerX:"calc(100% - 14px)",color:Wr},this.isOpen=!1,this.controlle=null,this.#Qa=null,this.#th=null,this.#eh=null,this.#sh=null,this.#ih=null,this.#nh=null,!s.isNewForm){const n=function({lang:t,icons:e},s){const i=Re.utils.createElement("DIV",{class:`se-controller ${s}`},`\n\t\t<div class="se-hue"></div>\n\t\t<div class="se-form-group se-form-w0 se-form-flex-btn">\n\t\t\t<button type="button" class="se-btn se-btn-success" title="${t.submitButton}" aria-label="${t.submitButton}" data-command="submit">${e.checked}</button>\n\t\t\t<button type="button" class="se-btn se-btn-danger" title="${t.close}" aria-label="${t.close}" data-command="close">${e.cancel}</button>\n\t\t</div>\n\t`);return i}(e,i);this.circle=n.querySelector(".se-hue"),this.controller=new Mi(this,e,n,{position:"bottom",isWWTarget:!1,parents:[t.form],parentsHide:!0,...s.controllerOptions})}}controllerAction(t){const e=t.getAttribute("data-command");"submit"===e?(this.inst.hueSliderAction?.(this.get()),this.close()):"close"===e&&this.close()}controllerClose(){this.init(),this.inst.hueSliderCancelAction?.()}get(){return Xr}open(t){this.attach(),this.controller.open(t,null,{isWWTarget:!1,initMethod:null,addOffset:null})}close(){this.ctx={gradientPointerX:ol.style.left,wheelPointerX:il.style.left,wheelPointerY:il.style.top,wheelX:Kr,wheelY:Yr,lightness:Vr,color:Ur?.color||""},this.controller.close()}attach(t){Zr||_l(),this.init(),(t||this.circle).appendChild(Jr),Ur=this.ctx,Ur&&(Kr=Ur.wheelX,Yr=Ur.wheelY,Vr=Ur.lightness,il.style.left=Ur.wheelPointerX,il.style.top=Ur.wheelPointerY,ol.style.left=Ur.gradientPointerX,vl(Ur.color.hex),yl(),gl(ml())),Fr&&(this.#ih=this.#J.eventManager.addGlobalEvent("touchstart",al,{passive:!1,capture:!0}),this.#th=this.#J.eventManager.addGlobalEvent("touchmove",hl,!0),this.#nh=this.#J.eventManager.addGlobalEvent("touchend",(()=>{jr=!1,Gr=!1}),!0)),this.#Qa=this.#J.eventManager.addGlobalEvent("mousedown",cl,{passive:!1,capture:!0}),this.#sh=this.#J.eventManager.addGlobalEvent("mousemove",dl,!0),this.#eh=this.#J.eventManager.addGlobalEvent("mouseup",(()=>{jr=!1,Gr=!1}),!0),this.isOpen=!0}init(){this.isOpen=!1,jr=!1,Gr=!1,this.#Qa&&=this.#J.eventManager.removeGlobalEvent(this.#Qa),this.#sh&&=this.#J.eventManager.removeGlobalEvent(this.#sh),this.#eh&&=this.#J.eventManager.removeGlobalEvent(this.#eh),this.#ih&&=this.#J.eventManager.removeGlobalEvent(this.#ih),this.#th&&=this.#J.eventManager.removeGlobalEvent(this.#th),this.#nh&&=this.#J.eventManager.removeGlobalEvent(this.#nh)}},xl=["#ef4444","#f97316","#eab308","#22c55e","#06b6d4","#3b82f6","#8b5cf6","#ec4899","#000000","#fca5a5","#fdba74","#fcd34d","#6ee7b7","#5eead4","#7dd3fc","#c4b5fd","#f9a8d4","#e5e7eb","#fee2e2","#ffedd5","#fef9c3","#dcfce7","#cffafe","#dbeafe","#ede9fe","#fce7f3","#f3f4f6","#f87171","#fb923c","#facc15","#4ade80","#22d3ee","#60a5fa","#a78bfa","#f472b6","#9ca3af","#b91c1c","#c2410c","#a16207","#15803d","#0e7490","#1d4ed8","#6d28d9","#be185d","#4b5563","#7f1d1d","#7c2d12","#713f12","#14532d","#164e63","#1e3a8a","#4c1d95","#831843","#1f2937"];function $l(t,e){const s=`<ul class="se-color-pallet${e?" se-list-horizontal":""}">`;let i=s;for(let n,o,r,l=0,a=t.length;l<a;l++)n=t[l],"string"==typeof n?(o=n,r=n):"object"==typeof n&&(o=n.value,r=n.name||o),l>0&&l%e==0&&(i+=`</ul>${s}`),i+=`<li><button type="button" data-value="${o}" title="${r}" aria-label="${r}" style="background-color:${o};"></button></li>`;return i+="</ul>",i}const Sl=class{#J;constructor(t,e,s,i){this.#J=e,this.kind=t.constructor.key||t.constructor.name,this.host=t,this.form=i.form,this.target=function({lang:t,icons:e},{colorList:s,disableHEXInput:i,disableRemove:n,splitNum:o}){s||=xl,o=s===xl?9:o;let r="";for(let t,e=0,i=s.length,n=[];e<i;e++)t=s[e],t&&(("string"==typeof t||t.value)&&(n.push(t),e<i-1)||(n.length>0&&(r+=`<div class="se-selector-color">${$l(n,o)}</div>`,n=[]),"object"==typeof t&&(r+=`<div class="se-selector-color">${$l(t,o)}</div>`)));return r+=`\n\t\t<form class="se-form-group se-form-w0">\n\t\t\t${i?"":`<button type="button" class="se-btn __se_hue" title="${t.colorPicker}" aria-label="${t.colorPicker}">${e.color_palette}</button>`}\n\t\t\t<input type="text" class="se-color-input" ${i?"readonly":""} placeholder="${t.color}" />\n\t\t\t${i?"":`<button type="submit" class="se-btn se-btn-success" title="${t.submitButton}" aria-label="${t.submitButton}">${e.checked}</button>`}\n\t\t\t${n?"":`<button type="button" class="se-btn __se_remove" title="${t.remove}" aria-label="${t.remove}">${e.remove_color}</button>`}\n\t\t</form>`,Re.utils.createElement("DIV",{class:"se-list-inner"},r)}(this.#J,i),this.targetButton=null,this.inputElement=this.target.querySelector(".se-color-input"),this.styleProperties=s,this.splitNum=i.splitNum||0,this.defaultColor=i.defaultColor||"",this.hueSliderOptions=i.hueSliderOptions,this.currentColor="",this.colorList=this.target.querySelectorAll("li button")||[],this.hueSlider=null;const n=(new DOMParser).parseFromString(this.#J.icons.color_checked,"image/svg+xml");this.checkedIcon=n.documentElement,i.disableHEXInput||(this.hueSlider=new kl(this,e,i.hueSliderOptions,"se-dropdown"),this.#J.eventManager.addEvent(this.target.querySelector(".__se_hue"),"click",this.#oh.bind(this)),this.#J.eventManager.addEvent(this.inputElement,"input",this.#rh.bind(this)),this.#J.eventManager.addEvent(this.target.querySelector("form"),"submit",this.#lh.bind(this))),i.disableRemove||this.#J.eventManager.addEvent(this.target.querySelector(".__se_remove"),"click",this.#ah.bind(this)),this.#J.eventManager.addEvent(this.target,"click",this.#hh.bind(this)),this.form.appendChild(this.target)}init(t,e,s){this.targetButton=e,"function"!=typeof s&&(s=()=>!1);let i=("string"==typeof t?t:this.#ch(t,s))||this.defaultColor;i=Oe.isHexColor(i)?i:Oe.rgb2hex(i)||i||"";const n=this.colorList;for(let t,e=0,s=n.length;e<s;e++)t=n[e],i.toLowerCase()===t.getAttribute("data-value").toLowerCase()?(t.appendChild(this.checkedIcon),Re.utils.addClass(t,"active")):(Re.utils.removeClass(t,"active"),t.contains(this.checkedIcon)&&Re.utils.removeItem(this.checkedIcon));this.#dh(this.#uh(i))}setHexColor(t){this.currentColor=t,this.inputElement.style.borderColor=t}hueSliderClose(){this.hueSlider.close()}hueSliderAction(t){this.#dh(t.hex)}hueSliderCancelAction(){this.form.style.display="block",this.host.colorPickerHueSliderClose?.()}#dh(t){t=!t||/^#/.test(t)?t:"#"+t,this.inputElement.value=t,this.setHexColor.call(this,t)}#ch(t,e){let s="";const i=this.styleProperties;for(;t&&!e(t)&&!Re.check.isWysiwygFrame(t)&&0===s.length;)G(t)&&t.style[i]&&(s=t.style[i]),t=t.parentNode;return s}#uh(t){if(!t||/^#/.test(t))return t;const e=Re.utils.createElement("div",{style:"display: none; color: "+t}),s=Le._w.getComputedStyle(Le._d.body.appendChild(e)).color.match(/\d+/g).map((function(t){return parseInt(t,10)}));return Re.utils.removeItem(e),s.length>=3?"#"+((1<<24)+(s[0]<<16)+(s[1]<<8)+s[2]).toString(16).substring(1):""}#oh(){this.hueSlider.open(this.targetButton),this.host.colorPickerHueSliderOpen?.()}#lh(t){t.preventDefault(),this.host.colorPickerAction?.(this.currentColor)}#hh(t){const e=Re.query.getEventTarget(t).getAttribute("data-value");e&&this.host.colorPickerAction?.(e)}#ah(){this.host.colorPickerAction?.(null)}#rh(t){const e=Re.query.getEventTarget(t);this.setHexColor(e.value)}},{_w:El}=Le,Tl={w:"ns-resize",h:"ew-resize",c:"nwse-resize",wRTL:"ns-resize",hRTL:"ew-resize",cRTL:"nesw-resize"};const Ml=class{#J;#ph;#gh;#mh;#fh;#uo;#$e;#vo=null;#vh=!1;#bh=null;#yh=null;#wh="";#Ch=0;#_h=0;#kh=null;#xh=null;constructor(t,e,s){this.#J=e,this.inst=t,this.kind=t.constructor.key||t.constructor.name,this.form=s,this.isUpdate=!1,this.focusElement=s.querySelector("[data-focus]"),this.#gh=this.#J.contextProvider.carrierWrapper.querySelector(".se-modal"),this.#mh=this.#J.contextProvider.carrierWrapper.querySelector(".se-modal .se-modal-inner"),this.#uo=[this.#$h.bind(this),this.#Sh.bind(this)],this.#mh.appendChild(s),this.#J.eventManager.addEvent(s.querySelector("form"),"submit",this.#Re.bind(this)),this.#vh=!this.#J.eventManager.addEvent(s.querySelector('[data-command="close"]'),"click",this.close.bind(this)),(s.querySelector(".se-modal-resize-handle-w")||s.querySelector(".se-modal-resize-handle-h")||s.querySelector(".se-modal-resize-handle-c")||s.querySelector(".se-modal-resize-form"))&&!(this.#fh=s.querySelector(".se-modal-resize-form"))&&(this.#fh=s.querySelector(".se-modal-body"))&&(this.#J.eventManager.addEvent(s.querySelector(".se-modal-resize-handle-w"),"mousedown",this.#Eh.bind(this,"w")),this.#J.eventManager.addEvent(s.querySelector(".se-modal-resize-handle-h"),"mousedown",this.#Eh.bind(this,"h")),this.#J.eventManager.addEvent(s.querySelector(".se-modal-resize-handle-c"),"mousedown",this.#Eh.bind(this,"c")),this.#$e={mousemove:this.#Th.bind(this),mouseup:this.#Mh.bind(this)})}static CreateFileInput({icons:t,lang:e},{acceptedFormats:s,allowMultiple:i}){return`\n\t\t<div class="se-modal-form-files">\n\t\t\t<div class="se-flex-input-wrapper">\n\t\t\t\t<div class="se-input-form-abs">\n\t\t\t\t\t<div>\n\t\t\t\t\t\t<div class="se-input-file-w">\n\t\t\t\t\t\t\t<div class="se-input-file-icon-up">${t.upload_tray}</div>\n\t\t\t\t\t\t\t<div class="se-input-file-icon-files">${t.file_plus}</div>\n\t\t\t\t\t\t\t<span class="se-input-file-cnt"></span>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t\t<input class="se-input-form __se__file_input" data-focus type="file" accept="${s}"${i?' multiple="multiple"':""}/>\n\t\t\t</div>\n\t\t\t<button type="button" class="se-btn se-modal-files-edge-button se-file-remove se-tooltip" aria-label="${e.remove}">\n\t\t\t\t${t.selection_remove}\n\t\t\t\t${Re.utils.createTooltipInner(e.remove)}\n\t\t\t</button>\n\t\t</div>`}static OnChangeFile(t,e){if(!t||!e)return;const s=t.querySelector(".se-input-file-cnt"),i=t.querySelector(".se-input-file-icon-up"),n=t.querySelector(".se-input-file-icon-files");e.length>1?(i.style.display="none",n.style.display="inline-block",s.style.display="",s.textContent=` ..${e.length}`):e.length>0?(i.style.display="none",n.style.display="none",s.style.display="block",s.textContent=e[0].name):(i.style.display="inline-block",n.style.display="none",s.style.display="",s.textContent="")}open(){if(this.#J.ui.offCurrentModal(),this.#Nh(!0),this.#vh&&(this.#bh&&this.#J.eventManager.removeEvent(this.#bh),this.#bh=this.#J.eventManager.addEvent(this.#mh,"click",this.#uo[1])),this.#vo&&=this.#J.eventManager.removeGlobalEvent(this.#vo),this.#vo=this.#J.eventManager.addGlobalEvent("keydown",this.#uo[0]),this.isUpdate=this.kind===this.#J.ui.currentControllerName,this.#J.ui.opendModal=this,this.isUpdate||this.inst.modalInit?.(),this.inst.modalOn?.(this.isUpdate),Re.utils.addClass(this.#gh,"se-backdrop-show"),Re.utils.addClass(this.form,"se-modal-show"),this.#gh.showPopover?.(),this.#fh){const t=this.#Bh(),{maxWidth:e,maxHeight:s}=El.getComputedStyle(this.form),i=this.form.offsetWidth-t.width+"px",n=`${this.form.offsetTop+(this.form.offsetHeight-this.#fh.offsetHeight)}px`;e&&"string"==typeof this.#wh&&Re.utils.setStyle(this.#fh,"max-width",`calc(${e} - ${i})`),s&&Re.utils.setStyle(this.#fh,"max-height",`calc(${s} - ${n})`)}this.focusElement&&this.focusElement.focus(),this.#ph=this.#J.component.currentTarget}close(){this.#We(),this.#Nh(!1),El.setTimeout((()=>{this.#J.ui.opendModal=null}),0),this.#vh&&this.#bh&&(this.#J.eventManager.removeEvent(this.#bh),this.#bh=null),this.#vo&&=this.#J.eventManager.removeGlobalEvent(this.#vo),this.#gh.hidePopover?.(),Re.utils.removeClass(this.#gh,"se-backdrop-show"),Re.utils.removeClass(this.form,"se-modal-show"),this.inst.modalInit?.(),this.inst.modalOff?.(this.isUpdate),this.isUpdate?this.#ph&&this.inst.componentSelect?.(this.#ph):this.#J.focusManager.focus(),this.#ph=null}#Nh(t){const e=this.#J.ui.opendControllers;for(let s=0;s<e.length;s++)e[s].fixed=t,e[s].form.style.display=t?"none":"block"}#Bh(){const t=this.#J.offset.getGlobal(this.#fh);return this.#Ch=t.top,this.#_h=t.left,t}#De(t){this.#We(),this.#J.ui.enableBackWrapper(Tl[t]),this.#kh=this.#J.eventManager.addGlobalEvent("mousemove",this.#$e.mousemove,!0),this.#xh=this.#J.eventManager.addGlobalEvent("mouseup",this.#$e.mouseup,!0)}#We(){this.#J.ui.disableBackWrapper(),this.#kh&&=this.#J.eventManager.removeGlobalEvent(this.#kh),this.#xh&&=this.#J.eventManager.removeGlobalEvent(this.#xh)}async#Re(t){t.preventDefault(),t.stopPropagation(),this.#J.ui.showLoading();try{const t=await this.inst.modalAction();!1===t?this.#J.ui.hideLoading():void 0===t?this.close():(this.close(),this.#J.ui.hideLoading())}catch(t){throw this.close(),this.#J.ui.hideLoading(),Error(`[SUNEDITOR.Modal[${this.kind}].warn] ${t.message}`)}}#Sh(t){const e=Re.query.getEventTarget(t);(/close/.test(e.getAttribute("data-command"))||e===this.#mh)&&this.close()}#$h(t){Pe.isEsc(t.code)&&this.close()}#Eh(t,e){this.#yh=Re.query.getEventTarget(e),Re.utils.addClass(this.#yh,"active"),this.#De(this.#wh=t+(this.#J.options.get("_rtl")?"RTL":""))}#Th(t){switch(this.#wh){case"w":case"wRTL":{const e=t.clientY-this.#Ch-this.#fh.offsetHeight;this.#fh.style.height=this.#fh.offsetHeight+e+"px";break}case"h":{const e=t.clientX-this.#_h-this.#fh.offsetWidth;this.#fh.style.width=this.#fh.offsetWidth+e+"px";break}case"hRTL":{const e=this.#_h-t.clientX;this.#fh.style.width=this.#fh.offsetWidth+e+"px";break}case"c":{const e=t.clientX-this.#_h-this.#fh.offsetWidth,s=t.clientY-this.#Ch-this.#fh.offsetHeight;this.#fh.style.width=this.#fh.offsetWidth+e+"px",this.#fh.style.height=this.#fh.offsetHeight+s+"px";break}case"cRTL":{const e=this.#_h-t.clientX,s=t.clientY-this.#Ch-this.#fh.offsetHeight;this.#fh.style.width=this.#fh.offsetWidth+e+"px",this.#fh.style.height=this.#fh.offsetHeight+s+"px";break}}this.#Bh(),this.inst.modalResize?.()}#Mh(){Re.utils.removeClass(this.#yh,"active"),this.#yh=null,this.#We()}};function Nl(t,e){const s=t.getAttribute(`data-se-${e}`);if(s)return s;const i=t.getAttribute(`data-${e}`);return i?(t.removeAttribute(`data-${e}`),t.setAttribute(`data-se-${e}`,i),i):null}const Bl=class{#J;constructor(t,e,s){this.#J=e,t.__fileManagement=this,this.kind=t.constructor.key||t.constructor.name,this.inst=t,this.query=s.query,this.loadEventName=s.loadEventName,this.actionEventName=s.actionEventName,this.infoList=[],this.infoIndex=0,this.uploadFileLength=0,this.__updateTags=[],this.apiManager=new zr(this,e),this._resetInfo,this._checkInfo}upload(t,e,s,i,n){this.#J.ui.showLoading();let o=null;if("length"in s){o=new FormData;for(let t=0,e=s.length;t<e;t++)o.append("file-"+t,s[t]);this.uploadFileLength=s.length}else o=s.formData,this.uploadFileLength=s.size;this.apiManager.call({method:"POST",url:t,headers:e,data:o,callBack:i,errorCallBack:n})}async asyncUpload(t,e,s){this.#J.ui.showLoading();let i=null;if("length"in s){i=new FormData;for(let t=0,e=s.length;t<e;t++)i.append("file-"+t,s[t]);this.uploadFileLength=s.length}else i=s.formData,this.uploadFileLength=s.size;return await this.apiManager.asyncCall({method:"POST",url:t,headers:e,data:i})}setFileData(t,{name:e,size:s}){t&&(t.setAttribute("data-se-file-name",e),t.setAttribute("data-se-file-size",s+""))}getSize(){let t=0;for(let e=0,s=this.infoList.length;e<s;e++)t+=1*this.infoList[e].size;return t}_checkInfo(t){const e=[].slice.call(this.#J.frameContext.get("wysiwyg").querySelectorAll(this.query)),s=this.infoList;if(e.length===s.length){let t=!1;for(let i,n=0,o=s.length;n<o;n++)if(i=s[n],0===e.filter((function(t){return i.src===t.src&&i.index.toString()===Nl(t,"index")})).length){t=!0;break}if(!t)return}const i=[],n=[];for(let t=0,e=s.length;t<e;t++)n[t]=s[t].index;for(this.__updateTags=e;e.length>0;){const t=e.shift();Nl(t,"index")&&n.includes(Number(Nl(t,"index")))?i.push(Number(Nl(t,"index"))):(i.push(this.infoIndex),t.removeAttribute("data-se-index"),this.#Ih(t,null))}if(t&&this.loadEventName)this.#J.eventManager.triggerEvent(this.loadEventName,{infoList:s});else for(let t,e=0;e<s.length;e++){if(t=s[e].index,i.includes(t))continue;s.splice(e,1);const n={element:null,index:t,state:"delete",info:null,remainingFilesCount:0,pluginName:this.kind};this.actionEventName&&this.#J.eventManager.triggerEvent(this.actionEventName,n),this.#J.eventManager.triggerEvent("onFileManagerAction",{...n,pluginName:this.kind}),e--}}_resetInfo(){const t={element:null,state:"delete",info:null,remainingFilesCount:0,pluginName:this.kind};for(let e=0,s=this.infoList.length;e<s;e++)this.actionEventName&&this.#J.eventManager.triggerEvent(this.actionEventName,{...t,index:this.infoList[e].index,pluginName:this.kind}),this.#J.eventManager.triggerEvent("onFileManagerAction",{...t,index:this.infoList[e].index,pluginName:this.kind});this.infoList=[],this.infoIndex=0}#Lh(t){if(t>=0)for(let e=0,s=this.infoList.length;e<s;e++)if(t===this.infoList[e].index)return this.infoList.splice(e,1),void(this.actionEventName&&this.#J.eventManager.triggerEvent(this.actionEventName,{element:null,index:t,state:"delete",info:null,remainingFilesCount:0,pluginName:this.kind}))}#Ih(t,e){let s=Number(Nl(t,"index")),i=null,n="";if(e||={name:Nl(t,"file-name")||("string"==typeof t.src?t.src.split("/").pop():""),size:Number(Nl(t,"file-size"))||0},s&&this.#J.store._editorInitFinished){n="update",s*=1;for(let t=0,e=this.infoList.length;t<e;t++)if(s===this.infoList[t].index){i=this.infoList[t];break}i||(s=this.infoIndex++,i={index:s},this.infoList.push(i)),i.src=t.src,i.name=Nl(t,"file-name"),i.size=Number(Nl(t,"file-size"))}else n="create",s=this.infoIndex++,t.setAttribute("data-se-index",s+""),t.setAttribute("data-se-file-name",e.name),t.setAttribute("data-se-file-size",e.size+""),i={src:t.src,index:s,name:e.name,size:e.size},this.infoList.push(i);i.element=t,i.delete=function(t,e){this.inst.componentDestroy?.(e),t(Number(Nl(e,"index")))}.bind(this,this.#Lh.bind(this),t),i.select=function(t,e){e.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"});const s=t.get(e);s?t.select(s.target,s.pluginName):this.inst.componentSelect?.(e)}.bind(this,this.#J.component,t);const o={element:t,index:s,state:n,info:i,remainingFilesCount:--this.uploadFileLength<0?0:this.uploadFileLength,pluginName:this.kind};this.actionEventName&&this.#J.eventManager.triggerEvent(this.actionEventName,o),this.#J.eventManager.triggerEvent("onFileManagerAction",{...o,pluginName:this.kind})}},{_w:Il,NO_EVENT:Ll}=Le;const Al=class{#J;#Ah;#Oh;#Rh;#zh;constructor(t,e,s){this.#J=t,this.openNewWindow=!!s.openNewWindow,this.relList=Array.isArray(s.relList)?s.relList:[],this.defaultRel=s.defaultRel||{},this.noAutoPrefix=!!s.noAutoPrefix,s.enableFileUpload&&(this.uploadUrl="string"==typeof s.uploadUrl?s.uploadUrl:null,this.uploadHeaders=s.uploadHeaders||null,this.uploadSizeLimit=ze.get(s.uploadSizeLimit,0)||null,this.uploadSingleSizeLimit=ze.get(s.uploadSingleSizeLimit,0)||null,this.input=Re.utils.createElement("input",{type:"file",accept:s.acceptedFormats||"*"}),this.#J.eventManager.addEvent(this.input,"change",this.#Ph.bind(this)),this.fileManager=new Bl(this,t,{query:"a[download]:not([data-se-file-download])",loadEventName:"onFileLoad",actionEventName:"onFileAction"}));const i=function(t,e,s){const i=t.lang,n=t.icons,o=e.textToDisplay?"":'style="display: none;"',r=e.title?"":'style="display: none;"';let l=`\n\t\t<div class="se-modal-body">\n\t\t\t<div class="se-modal-form">\n\t\t\t\t<label>${i.link_modal_url}</label>\n\t\t\t\t<div class="se-modal-form-files">\n\t\t\t\t\t<input data-focus class="se-input-form se-input-url" type="text" placeholder="${t.options.get("defaultUrlProtocol")||""}" />\n\t\t\t\t\t${e.enableFileUpload?`<button type="button" class="se-btn se-tooltip se-modal-files-edge-button _se_upload_button" aria-label="${i.fileUpload}">\n\t\t\t\t\t\t\t\t\t${n.file_upload}\n\t\t\t\t\t\t\t\t\t${Re.utils.createTooltipInner(i.fileUpload)}\n\t\t\t\t\t\t\t\t</button>`:""}\n\t\t\t\t\t<button type="button" class="se-btn se-tooltip se-modal-files-edge-button _se_bookmark_button" aria-label="${i.link_modal_bookmark}">\n\t\t\t\t\t\t${n.bookmark}\n\t\t\t\t\t\t${Re.utils.createTooltipInner(i.link_modal_bookmark)}\n\t\t\t\t\t</button>\n\t\t\t\t</div>\n\t\t\t\t<div class="se-anchor-preview-form">\n\t\t\t\t\t<span class="se-svg se-anchor-preview-icon _se_anchor_bookmark_icon">${n.bookmark}</span>\n\t\t\t\t\t<span class="se-svg se-anchor-preview-icon _se_anchor_download_icon">${n.download}</span>\n\t\t\t\t\t<pre class="se-link-preview"></pre>\n\t\t\t\t</div>\n\t\t\t\t<label ${o}>${i.link_modal_text}</label>\n\t\t\t\t<input class="se-input-form _se_display_text" type="text" ${o} />\n\t\t\t\t<label ${r}>${i.title}</label>\n\t\t\t\t<input class="se-input-form _se_title" type="text" ${r} />\n\t\t\t</div>\n\t\t\t<div class="se-modal-form-footer">\n\t\t\t\t<label><input type="checkbox" class="se-modal-btn-check _se_anchor_check" /> ${i.link_modal_newWindowCheck}</label>\n\t\t\t\t<label><input type="checkbox" class="se-modal-btn-check _se_anchor_download" /> ${i.link_modal_downloadLinkCheck}</label>`;s.length>0&&(l+=`\n\t\t\t<div class="se-anchor-rel">\n\t\t\t\t<button type="button" class="se-btn se-tooltip se-anchor-rel-btn" title="${i.link_modal_relAttribute}" aria-label="${i.link_modal_relAttribute}">\n\t\t\t\t\t${n.link_rel}\n\t\t\t\t\t${Re.utils.createTooltipInner(i.link_modal_relAttribute)}\n\t\t\t\t</button>\n\t\t\t\t<div class="se-anchor-rel-wrapper"><pre class="se-link-preview se-anchor-rel-preview"></pre></div>\n\t\t\t</div>\n\t\t</div>`);return l+="</div></div>",Re.utils.createElement("DIV",null,l)}(t,s,this.relList);if(this.host=(Il.location.origin+Il.location.pathname).replace(/\/$/,""),this.urlInput=i.querySelector(".se-input-url"),this.displayInput=i.querySelector("._se_display_text"),this.titleInput=i.querySelector("._se_title"),this.newWindowCheck=i.querySelector("._se_anchor_check"),this.downloadCheck=i.querySelector("._se_anchor_download"),this.download=i.querySelector("._se_anchor_download_icon"),this.preview=i.querySelector(".se-link-preview"),this.bookmark=i.querySelector("._se_anchor_bookmark_icon"),this.bookmarkButton=i.querySelector("._se_bookmark_button"),this.currentRel=[],this.currentTarget=null,this.linkValue="",this.#Oh=this.relList.length>0,this.#Oh){this.relButton=i.querySelector(".se-anchor-rel-btn"),this.relPreview=i.querySelector(".se-anchor-rel-preview");const e=this.relList,s=(this.defaultRel.default||"").split(" "),n=[];for(let t,i=0,o=e.length;i<o;i++)t=e[i],n.push(Re.utils.createElement("BUTTON",{type:"button",class:"se-btn-list"+(s.includes(t)?" se-checked":""),"data-command":t,title:t,"aria-label":t},t+'<span class="se-svg">'+this.#J.icons.checked+"</span>"));this.#Rh=new Bi(t,{checkList:!0,position:"right-middle",dir:"ltr"}),this.#Rh.on(this.relButton,this.#Dh.bind(this)),this.#Rh.create(n),this.#J.eventManager.addEvent(this.relButton,"click",this.#Fh.bind(this))}this.#Ah=e,this.#Ah.querySelector(".se-anchor-editor").appendChild(i),this.#zh=new Bi(t,{checkList:!1,position:"bottom-left",dir:"ltr"}),this.#zh.on(this.urlInput,this.#Hh.bind(this)),this.#J.eventManager.addEvent(this.newWindowCheck,"change",this.#qh.bind(this)),this.#J.eventManager.addEvent(this.downloadCheck,"change",this.#Wh.bind(this)),this.#J.eventManager.addEvent(this.urlInput,"input",this.#Uh.bind(this)),this.#J.eventManager.addEvent(this.urlInput,"focus",this.#Vh.bind(this)),this.#J.eventManager.addEvent(this.bookmarkButton,"click",this.#jh.bind(this)),this.#J.eventManager.addEvent(i.querySelector("._se_upload_button"),"click",(()=>this.input.click()))}set(t){this.currentTarget=t}on(t){if(t){if(this.currentTarget){const t=this.currentTarget.href;this.linkValue=this.preview.textContent=this.urlInput.value=this.#Gh(t)?t.substring(t.lastIndexOf("#")):t,this.displayInput.value=this.currentTarget.textContent,this.titleInput.value=this.currentTarget.title,this.newWindowCheck.checked=!!/_blank/i.test(this.currentTarget.target),this.downloadCheck.checked=!!this.currentTarget.download}}else this.init(),this.displayInput.value=this.#J.selection.get().toString().trim(),this.newWindowCheck.checked=this.openNewWindow,this.titleInput.value="";this.#Kh(t&&this.currentTarget?this.currentTarget.rel:this.defaultRel.default||""),this.#Yh(this.linkValue)}create(t,e){const s=this.linkValue||e||"";if(0===s.length)return null;const i=0===this.displayInput.value.length?s:this.displayInput.value,n=this.currentTarget||Re.utils.createElement("A");return this.#Xh(n,s,i,this.titleInput.value,t),this.linkValue=this.preview.textContent=this.urlInput.value=this.displayInput.value="",n}init(){this.currentTarget=null,this.linkValue=this.preview.textContent=this.urlInput.value="",this.displayInput.value="",this.newWindowCheck.checked=!1,this.downloadCheck.checked=!1,this.#Kh(this.defaultRel.default||"")}#Xh(t,e,s,i,n){!this.#Gh(e)&&this.downloadCheck.checked?t.setAttribute("download",s||e):t.removeAttribute("download"),this.newWindowCheck.checked?t.target="_blank":t.removeAttribute("target");const o=this.currentRel.join(" ");o?t.rel=o:t.removeAttribute("rel"),t.href=e,i?t.title=i:t.removeAttribute("title"),n?0===t.children.length&&(t.textContent=""):t.textContent=s}#Gh(t){const e=Il.location.href.replace(/\/$/,"");return 0===t.indexOf("#")||0===t.indexOf(e)&&t.indexOf("#")===(e.includes("#")?e.substring(0,e.indexOf("#")).length:e.length)}#Kh(t){if(!this.#Oh)return;const e=this.currentRel=t?t.split(" "):[],s=this.#Rh.form.querySelectorAll("button");for(let t,i=0,n=s.length;i<n;i++)t=s[i].getAttribute("data-command"),e.includes(t)?Re.utils.addClass(s[i],"se-checked"):Re.utils.removeClass(s[i],"se-checked");this.relPreview.title=this.relPreview.textContent=e.join(" "),e.length>0?Re.utils.addClass(this.relButton,"on"):Re.utils.removeClass(this.relButton,"on")}#Zh(t){const e=Re.query.getListChildren(this.#J.frameContext.get("wysiwyg"),(t=>/h[1-6]/i.test(t.nodeName)||Re.check.isAnchor(t)&&!!t.id),null);if(0===e.length)return;const s=new RegExp(`^${t.replace(/^#/,"")}`,"i"),i=[],n=[];for(let t,o=0,r=e.length;o<r;o++)t=e[o],s.test(t.textContent)&&(i.push(t),n.push(Re.check.isAnchor(t)?`<div><span class="se-text-prefix-icon">${this.#J.icons.bookmark_anchor}</span>${t.id}</div>`:`<div style="${t.style.cssText}">${t.textContent}</div>`));0===i.length?this.#zh.close():(this.#zh.create(i,n),this.#zh.open(this.#J.options.get("_rtl")?"bottom-right":""))}#Yh(t){const e=this.preview,s=this.#J.options.get("defaultUrlProtocol"),i=this.noAutoPrefix,n=/^(mailto:|tel:|sms:|https*:\/\/|#)/.test(t)||0===t.indexOf(s),o=!!s&&RegExp("^"+Ae.escapeStringRegexp(t.substring(0,s.length))).test(s);t=this.linkValue=e.textContent=t?i?t:!s||n||o?n?t:/^www\./.test(t)?"http://"+t:this.host+(/^\//.test(t)?"":"/")+t:s+t:"",this.#Gh(t)?(this.bookmark.style.display="block",Re.utils.addClass(this.bookmarkButton,"active")):(this.bookmark.style.display="none",Re.utils.removeClass(this.bookmarkButton,"active")),!this.#Gh(t)&&this.downloadCheck.checked?this.download.style.display="block":this.download.style.display="none"}#Jh(t){const e=this.currentRel;if(!t)return e.join(" ");if(/^only:/.test(t))return t=t.replace(/^only:/,"").trim(),this.currentRel=t.split(" "),t;const s=t.split(" ");for(let t=0,i=s.length;t<i;t++)e.includes(s[t])||e.push(s[t]);return e.join(" ")}#Qh(t){if(!t)return this.currentRel.join(" ");/^only:/.test(t)&&(t=t.replace(/^only:/,"").trim());const e=this.currentRel.join(" ").replace(RegExp(t+"\\s*"),"");return this.currentRel=e.split(" "),e}#tc(t){const e=t.result[0];this.linkValue=this.preview.textContent=this.urlInput.value=e.url,this.displayInput.value=e.name,this.downloadCheck.checked=!0,this.download.style.display="block"}async#ec(t){const e=await this.#J.eventManager.triggerEvent("onFileUploadError",{error:t});if(!1===e)return;const s=e===Ll?t.errorMessage:e||t.errorMessage;this.#J.ui.alertOpen(s,"error"),console.error("[SUNEDITOR.plugin.fileUpload.error]",s)}#sc(t){const e=JSON.parse(t.responseText);e.errorMessage?this.#ec(e):this.#tc(e)}async#Ph(t){const e=Re.query.getEventTarget(t).files;if(!e[0])return;const s={url:this.uploadUrl,uploadHeaders:this.uploadHeaders,files:e},i=async function(t,e,s){e=s||e;t(await this.fileManager.asyncUpload(e.url,e.uploadHeaders,e.files))}.bind(this,this.#sc.bind(this),s),n=await this.#J.eventManager.triggerEvent("onFileUploadBefore",{info:s,handler:i});return void 0===n||!1!==n&&(null!==n&&"object"==typeof n&&i(n),void(!0!==n&&n!==Ll||i(null)))}#Fh(){this.#Rh.open(this.#J.options.get("_rtl")?"left-middle":"")}#Hh(t){const e=t.id||"h_"+Math.random().toString().replace(/.+\./,"");t.id=e,this.urlInput.value="#"+e,this.#Yh(this.urlInput.value),this.#zh.close(),this.urlInput.focus()}#Dh(t){const e=t.getAttribute("data-command");if(!e)return;const s=this.currentRel,i=s.indexOf(e);-1===i?s.push(e):s.splice(i,1),this.relPreview.title=this.relPreview.textContent=s.join(", ")}#Uh(t){const e=Re.query.getEventTarget(t).value.trim();this.#Yh(e),this.#Gh(e)?this.#Zh(e):this.#zh.close()}#Vh(){const t=this.urlInput.value;this.#Gh(t)&&this.#Zh(t)}#jh(){let t=this.urlInput.value;this.#Gh(t)?(t=t.substring(1),this.bookmark.style.display="none",Re.utils.removeClass(this.bookmarkButton,"active")):(t="#"+t,this.bookmark.style.display="block",Re.utils.addClass(this.bookmarkButton,"active"),this.downloadCheck.checked=!1,this.download.style.display="none",this.#Zh(t)),this.urlInput.value=t,this.#Yh(t),this.urlInput.focus()}#qh(t){if("string"!=typeof this.defaultRel.check_new_window)return;Re.query.getEventTarget(t).checked?this.#Kh(this.#Jh(this.defaultRel.check_new_window)):this.#Kh(this.#Qh(this.defaultRel.check_new_window))}#Wh(t){Re.query.getEventTarget(t).checked?(this.download.style.display="block",this.bookmark.style.display="none",Re.utils.removeClass(this.bookmarkButton,"active"),this.linkValue=this.preview.textContent=this.urlInput.value=this.urlInput.value.replace(/^#+/,""),"string"==typeof this.defaultRel.check_bookmark&&this.#Kh(this.#Jh(this.defaultRel.check_bookmark))):(this.download.style.display="none","string"==typeof this.defaultRel.check_bookmark&&this.#Kh(this.#Qh(this.defaultRel.check_bookmark)))}},Ol={init(t){return{create:(e,s)=>this.create(e,s,t)}},create(t,e,s){if("object"!=typeof e&&(e={}),s&&(e=[s,e].reduce(((t,e)=>(Object.entries(e).forEach((([e,s])=>{if("plugins"===e&&s&&t[e]){const i=Array.isArray(t[e])?t[e]:Object.values(t[e]),n=Array.isArray(s)?s:Object.values(s);t[e]=[...n.filter((t=>!i.includes(t))),...i]}else t[e]=s})),t)),{})),!t)throw Error('[SUNEDITOR.create.fail] The first parameter "target" is missing.');const i=[];if("string"==typeof t){const e=document.querySelector(t);if(!e)throw Error(`[SUNEDITOR.create.fail]-[document.querySelector(${t})] Cannot find target element. Make sure "${t}" is a valid selector and exists in the document.`);i.push({key:null,target:e})}else if(1===t.nodeType)i.push({key:null,target:t});else{let e;for(const s in t){if(e=t[s],!e.target||1!==e.target.nodeType)throw Error('[SUNEDITOR.create.fail] suneditor multi root requires textarea\'s element at the "target" property.');e.key=s,i.push(e)}}return new Or(i,e)}};class Rl extends Hn{static type="";static key="";static className="";static options={};constructor(t){super(t),this.title="",this.icon="",this.inner=null,this.beforeItem=null,this.afterItem=null,this.replaceButton=null}}class zl extends Rl{static type="browser";open(t){throw new Error(`[${this.constructor.name}] Abstract method 'open()' must be implemented`)}close(){throw new Error(`[${this.constructor.name}] Abstract method 'close()' must be implemented`)}}class Pl extends Rl{static type="command";action(t){throw new Error(`[${this.constructor.name}] Abstract method 'action()' must be implemented`)}}class Dl extends Rl{static type="dropdown";on(t){}action(t){throw new Error(`[${this.constructor.name}] Abstract method 'action()' must be implemented`)}}class Fl extends Rl{static type="dropdown-free";on(t){}off(){}}class Hl extends Rl{static type="field"}class ql extends Rl{static type="input";toolbarInputKeyDown(t){}toolbarInputChange(t){}}class Wl extends Rl{static type="modal";open(t){throw new Error(`[${this.constructor.name}] Abstract method 'open()' must be implemented`)}}class Ul extends Rl{static type="popup";show(){throw new Error(`[${this.constructor.name}] Abstract method 'show()' must be implemented`)}}const Vl=class extends Pl{static key="blockquote";static className="";constructor(t){super(t),this.title=this.$.lang.tag_blockquote,this.icon="blockquote",this.quoteTag=Re.utils.createElement("BLOCKQUOTE")}active(t,e){return/blockquote/i.test(t?.nodeName)?(Re.utils.addClass(e,"active"),!0):(Re.utils.removeClass(e,"active"),!1)}action(){const t=Re.query.getParentElement(this.$.selection.getNode(),"blockquote");t?this.$.format.removeBlock(t,{selectedFormats:null,newBlockElement:null,shouldDelete:!1,skipHistory:!1}):this.$.format.applyBlock(this.quoteTag.cloneNode(!1))}},jl=["javascript","typescript","html","css","json","python","java","c","cpp","csharp","go","rust","ruby","php","swift","kotlin","sql","bash","markdown","xml","yaml"];class Gl extends Pl{static key="codeBlock";static className="";#ic;#nc;#oc;#rc;#lc;#ac;#hc;#cc;#dc;constructor(t,e){if(super(t),this.title=this.$.lang.codeBlock||"Code Block",this.icon="code_block",this.#ic=Re.utils.createElement("PRE"),this.#oc=e?.langs??jl,!this.#oc.length)return;this.afterItem=Re.utils.createElement("button",{class:"se-btn se-tooltip se-sub-arrow-btn",type:"button","data-command":Gl.key,"data-type":"dropdown"},`${this.$.icons.arrow_down}<span class="se-tooltip-inner"><span class="se-tooltip-text">${this.$.lang.codeLanguage||"Language"}</span></span>`);const s=function(t,e){const s=t.lang.codeLanguage_none||"None";let i='<div class="se-list-inner"><ul class="se-list-basic">';i+=`<li><button type="button" class="se-btn se-btn-list" data-command="codeBlock" data-value="" title="${s}">${s}</button></li>`;for(const t of e)i+=`<li><button type="button" class="se-btn se-btn-list" data-command="codeBlock" data-value="${t}" title="${t}">${t}</button></li>`;return i+="</ul></div>",Re.utils.createElement("DIV",{class:"se-dropdown se-list-layer se-list-code-block"},i)}(this.$,this.#oc);this.#nc=s.querySelectorAll("li button"),this.$.menu.initDropdownTarget({key:Gl.key,type:"dropdown"},s);const i=Re.utils.createElement("DIV",{class:"se-controller se-code-lang"});this.#rc=Re.utils.createElement("DIV",{class:"se-code-lang-button"}),this.#uc(""),i.appendChild(this.#rc),this.#ac=new Mi(this,this.$,i,{position:"top",isWWTarget:!0}),this.#dc=Oe.debounce((t=>{this.#cc=this.$.eventManager.removeEvent(this.#cc),t&&i.contains(t.relatedTarget)?this.#pc():this.#gc()}),0),this.#lc=new Bi(this.$,{position:"bottom-right",dir:this.$.options.get("_rtl")?"rtl":"ltr",maxHeight:"214px",minWidth:"132px",closeMethod:this.#dc}),this.#lc.on(this.#rc,this.#mc.bind(this)),this.#fc(""),this.$.eventManager.addEvent(this.#rc,"click",(t=>{if(t.preventDefault(),t.stopPropagation(),this.#lc.isOpen)this.#lc.close();else{const t=this.#vc(this.#hc);this.#fc(t);const e=this.#lc.items,s=t?e.indexOf(t):0;this.#lc.open(null,s>=0?`[data-index="${s}"]`:null)}}))}onMouseMove({event:t}){if(!this.#ac)return;const e=Re.query.getEventTarget(t).closest("pre");e&&!this.#bc()&&0===this.$.ui.opendControllers.length&&this.#yc(e)}active(t,e){return/^PRE$/i.test(t?.nodeName)?(Re.utils.addClass(e,"active"),!0):(Re.utils.removeClass(e,"active"),!1)}action(t){const e=t?.getAttribute("data-value")||"",s=this.$.selection.getNode(),i=Re.query.getParentElement(s,(t=>/^PRE$/i.test(t.nodeName)));if(i&&!e)this.$.format.setLine(Re.utils.createElement(this.$.options.get("defaultLine")));else if(i||this.$.format.setBrLine(this.#ic.cloneNode(!1)),e){const t=Re.query.getParentElement(this.$.selection.getNode(),(t=>/^PRE$/i.test(t.nodeName)));t&&this.#wc(t,e)}this.$.menu.dropdownOff(),this.$.focusManager.focus(),this.$.history.push(!1)}on(){if(!this.#nc)return;const t=this.#vc(this.$.selection.getNode());for(let e=0,s=this.#nc.length;e<s;e++){const s=this.#nc[e];Re.utils.toggleClass(s,"active",s.getAttribute("data-value")===t)}}#yc(t){this.#hc===t&&this.#ac.isOpen||(this.#hc&&this.#hc!==t&&Re.utils.removeClass(this.#hc,"se-pre-code-focus"),this.#hc=t,Re.utils.addClass(t,"se-pre-code-focus"),this.#ac.open(t,null,{passive:!0,addOffset:{right:t.offsetWidth}}),this.#uc(this.#vc(t)),this.#Cc())}#gc(){this.#lc?.isOpen||this.#_c()}#_c(){this.#lc?.isOpen&&this.#lc.close(),Re.utils.removeClass(this.#hc,"se-pre-code-focus"),this.#ac.close(!0)}controllerClose(){this.#hc&&(Re.utils.removeClass(this.#hc,"se-pre-code-focus"),this.#hc=null)}#mc(t){this.#hc&&(this.#wc(this.#hc,t),this.#uc(t),this.#lc.close(),this.#gc(),this.$.focusManager.focus(),this.$.history.push(!1))}#Cc(){this.#cc??=this.$.eventManager.addEvent(this.#hc,"mouseleave",this.#dc)}#pc(){this.#cc??=this.$.eventManager.addEvent(this.#ac.form,"mouseleave",this.#dc)}#fc(t){const e=this.$.lang.codeLanguage_none||"None",s=t&&!this.#oc.includes(t),i=s?["",t,...this.#oc]:["",...this.#oc],n=s?[e,t,...this.#oc]:[e,...this.#oc];this.#lc.create(i,n)}#uc(t){this.#rc.innerHTML=`<span class="se-code-lang-icon"></></span><span class="se-code-lang-text">${t||this.$.lang.codeLanguage||"Language"}</span>`}#bc(){return this.#lc?.isOpen||this.#ac?.isOpen}#vc(t){const e="PRE"===t?.nodeName?t:Re.query.getParentElement(t,(t=>/^PRE$/i.test(t.nodeName)));return e&&e.className.match(/language-(\S+)/)?.[1]||""}#wc(t,e){t.className=t.className.replace(/\s*language-\S+/g,"").trim(),e?(Re.utils.addClass(t,"language-"+e),t.setAttribute("data-se-lang",e)):t.removeAttribute("data-se-lang")}destroy(){this.#hc&&Re.utils.removeClass(this.#hc,"se-pre-code-focus"),this.#ac?.form?.parentNode?.removeChild(this.#ac.form),this.#hc=null}}const Kl=Gl,{_w:Yl,_d:Xl}=Le;const Zl=class extends Pl{static key="exportPDF";static className="se-component-enabled";constructor(t,e){super(t),this.title=this.$.lang.exportPDF,this.icon="PDF",this.apiUrl=e.apiUrl,this.fileName=e.fileName||"suneditor-pdf",this.apiUrl?this.apiManager=new zr(this,this.$,{method:"POST",url:this.apiUrl,headers:{"Content-Type":"application/json"},responseType:"blob"}):console.warn('[SUNEDITOR.plugins.exportPDF.error] Requires exportPDF."apiUrl" options.')}async action(){if(!this.apiUrl)return void console.warn('[SUNEDITOR.plugins.exportPDF.error] Requires exportPDF."apiUrl" options.');this.$.ui.showLoading();let t=null;try{const e=this.$.frameContext.get("documentTypePageMirror")||this.$.frameContext.get("wysiwygFrame"),s=(this.$.options.get("_themeClass")||"").trim(),i=s?e.className.replace(s,"").trim():e.className,n=Re.utils.createElement("div",{class:i},e.innerHTML);t=Re.utils.createElement("div",{style:"position: absolute; top: -10000px; left: -10000px; width: 21cm; columns: 21cm; height: auto;"},n);const o=Yl.getComputedStyle(e).padding,r=Re.utils.applyInlineStylesAll(n,!0,this.$.options.get("allUsedStyles"));if(r.style.padding=r.style.paddingTop=r.style.paddingBottom=r.style.paddingLeft=r.style.paddingRight="0",t.innerHTML=`\n\t\t\t\t<style>\n\t\t\t\t\t@page {\n\t\t\t\t\t\tsize: A4;\n\t\t\t\t\t\tmargin: ${o};\n\t\t\t\t\t}\n\t\t\t\t</style>\n\t\t\t\t${r.outerHTML}`,Xl.body.appendChild(t),!1===await this.$.eventManager.triggerEvent("onExportPDFBefore",{target:t}))return;return void await this.#kc(t)}catch(t){console.error("[SUNEDITOR.plugins.exportPDF.error]",t.message)}finally{Re.utils.removeItem(t),this.$.ui.hideLoading()}}async#kc(t){const e={fileName:this.fileName,htmlContent:t.innerHTML},s=await this.apiManager.asyncCall({data:JSON.stringify(e)});if(200!==s.status){let t;try{t=JSON.parse(s.responseText).errorMessage}catch{}throw Error(`[SUNEDITOR.plugins.exportPDF.error] ${t||s.statusText}`)}const i=new Blob([s.response],{type:"application/pdf"}),n=s.getResponseHeader("Content-Disposition"),o=URL.createObjectURL(i),r=(n.match(/filename="([^"]+)/)||[])[1]||this.fileName+".pdf",l=Re.utils.createElement("A",{href:o,download:r,style:"display: none;"},null);try{Xl.body.appendChild(l),l.click()}finally{Yl.setTimeout((()=>{Re.utils.removeItem(l),URL.revokeObjectURL(o)}),100)}}},{NO_EVENT:Jl}=Le;class Ql extends Pl{static key="fileUpload";static className="";static options={eventIndex:1e4};static component(t){return Re.check.isAnchor(t)&&t.hasAttribute("data-se-file-download")?t:null}#xc;#$c=null;constructor(t,e){super(t),this.title=this.$.lang.fileUpload,this.icon="file_upload",e.uploadUrl||console.warn('[SUNEDITOR.fileUpload.warn] "fileUpload" plugin must be have "uploadUrl" option.'),this.uploadUrl=e.uploadUrl,this.uploadHeaders=e.uploadHeaders,this.uploadSizeLimit=ze.get(e.uploadSizeLimit,0),this.uploadSingleSizeLimit=ze.get(e.uploadSingleSizeLimit,0),this.allowMultiple=!!e.allowMultiple,this.acceptedFormats="string"!=typeof e.acceptedFormats?"*":e.acceptedFormats.trim()||"*",this.as=e.as||"box",this.insertBehavior=e.insertBehavior,this.input=Re.utils.createElement("input",{type:"file",accept:this.acceptedFormats}),this.allowMultiple&&this.input.setAttribute("multiple","multiple"),this.#xc=this.acceptedFormats.split(", ");const s={"custom-download":{command:"download",title:this.$.lang.download,icon:"download",action:t=>{const e=t.getAttribute("href");e&&Re.utils.createElement("A",{href:e},null).click()}},"custom-as":{command:"as",value:"link",title:this.$.lang.asLink,icon:"reduction",action:(t,e)=>{this.convertFormat(t,e)}}},i=(e.controls||[["custom-as","align","edit","custom-download","copy","remove"]]).map((t=>t.map((t=>t.startsWith("custom-")?s[t]:t))));if(this.figure=new Wi(this,this.$,i,{}),this.fileManager=new Bl(this,this.$,{query:"a[download][data-se-file-download]",loadEventName:"onFileLoad",actionEventName:"onFileAction"}),/\bedit\b/.test(JSON.stringify(i))){const t=function({lang:t,icons:e}){const s=`\n\t\t<div class="se-arrow se-arrow-up"></div>\n\t\t<form>\n\t\t\t<div class="se-btn-group se-form-group">\n\t\t\t\t<input type="text" />\n\t\t\t\t<button type="submit" data-command="edit" class="se-btn se-tooltip se-btn-success">\n\t\t\t\t\t${e.checked}\n\t\t\t\t\t<span class="se-tooltip-inner"><span class="se-tooltip-text">${t.save}</span></span>\n\t\t\t\t</button>\n\t\t\t\t<button type="button" data-command="cancel" class="se-btn se-tooltip se-btn-danger">\n\t\t\t\t\t${e.cancel}\n\t\t\t\t\t<span class="se-tooltip-inner"><span class="se-tooltip-text">${t.cancel}</span></span>\n\t\t\t\t</button>\n\t\t\t</div>\n\t\t</form>\n\t\t`;return Re.utils.createElement("DIV",{class:"se-controller se-controller-simple-input"},s)}(this.$);this.controller=new Mi(this,this.$,t,{position:"bottom",disabled:!0},Ql.key),this.editInput=t.querySelector("input")}this.$.eventManager.addEvent(this.input,"change",this.#Ph.bind(this))}action(){this.$.store.set("_preventBlur",!0),this.input.click()}onFilePasteAndDrop({file:t}){const e=t.type;this.#xc.some((t=>!!t.startsWith("*")||(!!t.startsWith(e)||void 0)))&&(this.submitFile([t]),this.$.focusManager.focus())}controllerAction(t){const e=t.getAttribute("data-command");if(e){if("edit"===e){if(0===this.editInput.value.trim().length)return;this.#$c.textContent=this.editInput.value}this.controller.close(),this.$.component.select(this.#$c,Ql.key)}}componentSelect(t){this.#$c=t;const e=this.figure.controller.form.querySelector('[data-command="__c__as"]');if(e)return Re.check.isFigure(t.parentElement)?(e.innerHTML=this.$.icons.reduction+Re.utils.createTooltipInner(this.$.lang.asLink),e.setAttribute("data-value","link"),void this.figure.open(t,{nonResizing:!0,nonSizeInfo:!0,nonBorder:!0,figureTarget:!0,infoOnly:!1})):(e.innerHTML=this.$.icons.expansion+Re.utils.createTooltipInner(this.$.lang.asBlock),e.setAttribute("data-value","box"),this.figure.controllerOpen(t,{isWWTarget:!0}),!0)}componentEdit(t){this.editInput.value=t.textContent,this.figure.controllerHide(),this.controller.open(t,null,{isWWTarget:!Re.check.isFigure(t.parentElement),initMethod:null,addOffset:null}),this.editInput.focus()}async componentDestroy(t){if(!t)return;const e=Wi.GetContainer(t),s=Re.query.getParentElement(t,".se-component")||t;if(!1===await this.$.eventManager.triggerEvent("onFileDeleteBefore",{element:e.target,container:e,url:e.target.getAttribute("href")}))return;const i=this.$.component.isInline(s)?s.previousSibling||s.nextSibling:s.previousElementSibling||s.nextElementSibling;Re.utils.removeItem(s),this.$.ui.offCurrentController(),this.$.focusManager.focusEdge(i),this.$.history.push(!1)}async submitFile(t){if(0===t.length)return;let e=0;const s=[],i=this.uploadSingleSizeLimit;for(let n,o,r=0,l=t.length;r<l;r++){if(n=t[r],o=n.size,i>0&&o>i){const t="[SUNEDITOR.fileUpload.fail] Size of uploadable single file: "+i/1e3+"KB",e=await this.$.eventManager.triggerEvent("onFileUploadError",{error:t,limitSize:i,uploadSize:o,file:n});return this.$.ui.alertOpen(e===Jl?t:e||t,"error"),!1}s.push(n),e+=o}const n=this.uploadSizeLimit,o=this.fileManager.getSize();if(n>0&&e+o>n){const t="[SUNEDITOR.fileUpload.fail] Size of uploadable total files: "+n/1e3+"KB",s=await this.$.eventManager.triggerEvent("onFileUploadError",{error:t,limitSize:n,currentSize:o,uploadSize:e});return this.$.ui.alertOpen(s===Jl?t:s||t,"error"),!1}const r={url:this.uploadUrl,uploadHeaders:this.uploadHeaders,files:s},l=async function(t,e,s){e=s||e;t(await this.fileManager.asyncUpload(e.url,e.uploadHeaders,e.files))}.bind(this,this.#sc.bind(this),r),a=await this.$.eventManager.triggerEvent("onFileUploadBefore",{info:r,handler:l});return void 0===a||!1!==a&&(null!==a&&"object"==typeof a&&l(a),void(!0!==a&&a!==Jl||l(null)))}convertFormat(t,e){if("link"===e){this.figure.close();const{container:e}=Wi.GetContainer(t),s=e.nextElementSibling,i=e.parentElement;t.removeAttribute("data-se-non-focus"),t.setAttribute("contenteditable","false"),Re.utils.addClass(t,"se-component|se-inline-component");const n=Re.utils.createElement(this.$.options.get("defaultLine"),null,t);i.insertBefore(n,s),Re.utils.removeItem(e)}else{this.$.selection.setRange(t,0,t,1);const e=this.$.html.remove(),s=this.$.nodeTransform.split(e.container,e.offset,0);s?.previousElementSibling&&Re.check.isZeroWidth(s.previousElementSibling)&&Re.utils.removeItem(s.previousElementSibling),t.setAttribute("data-se-non-focus","true"),t.removeAttribute("contenteditable"),Re.utils.removeClass(t,"se-component|se-component-selected|se-inline-component");const i=Wi.CreateContainer(t,"se-file-figure se-flex-component");(s||e.container).parentElement.insertBefore(i.container,s)}this.$.history.push(!1),this.$.component.select(t,Ql.key)}create(t,e,s){const i=e.name||t,n=Re.utils.createElement("A",{href:t,title:i,download:i,"data-se-file-download":"",contenteditable:"false","data-se-non-focus":"true","data-se-non-link":"true"},i);if(this.fileManager.setFileData(n,e),"link"===this.as)return n.className="se-component se-inline-component",void this.$.component.insert(n,{scrollTo:!!s,insertBehavior:s?this.insertBehavior:null});const o=Wi.CreateContainer(n);if(Re.utils.addClass(o.container,"se-file-figure|se-flex-component"),this.$.component.insert(o.container,{scrollTo:!!s,insertBehavior:s?this.insertBehavior:null})){if(s)if(this.$.options.get("componentInsertBehavior"))this.$.component.select(n,Ql.key);else{const t=this.$.format.addLine(o.container,null);t&&this.$.selection.setRange(t,0,t,0)}}else this.$.focusManager.focus()}#tc(t){t.result.forEach(((t,e,s)=>{this.create(t.url,{name:t.name,size:t.size},e===s.length-1)}))}async#ec(t){const e=await this.$.eventManager.triggerEvent("onFileUploadError",{error:t});if(!1===e)return;const s=e===Jl?t.errorMessage:e||t.errorMessage;this.$.ui.alertOpen(s,"error"),console.error("[SUNEDITOR.plugin.fileUpload.error]",s)}#sc(t){const e=JSON.parse(t.responseText);e.errorMessage?this.#ec(e):this.#tc(e)}async#Ph(t){const e=Re.query.getEventTarget(t);await this.submitFile(e.files)}}const ta=Ql;class ea extends Pl{static key="list_bulleted";static className="se-icon-flip-rtl";#Sc;constructor(t){super(t),this.title=this.$.lang.bulletedList,this.icon="list_bulleted",this.afterItem=Re.utils.createElement("button",{class:"se-btn se-tooltip se-sub-arrow-btn",type:"button","data-command":ea.key,"data-type":"dropdown"},`${this.$.icons.arrow_down}<span class="se-tooltip-inner"><span class="se-tooltip-text">${this.$.lang.bulletedList}</span></span>`);const e=function(){const t=`\n\t<div class="se-list-inner">\n\t\t<ul class="se-list-basic se-list-horizontal se-list-carrier">\n\t\t\t${e=["disc","circle","square"],e.map((t=>`\n\t\t\t<li>\n\t\t\t\t<button type="button" class="se-btn se-btn-list se-icon-flip-rtl" data-command="${t}" title="${t}" aria-label="${t}">\n\t\t\t\t\t<ul style="list-style-type: ${t};">\n\t\t\t\t\t\t<li></li><li></li><li></li>\n\t\t\t\t\t</ul>\n\t\t\t\t</button>\n\t\t\t</li>\n\t\t`)).join("")}\n\t\t</ul>\n\t</div>`;var e;return Re.utils.createElement("DIV",{class:"se-dropdown se-list-layer"},t)}();this.#Sc=e.querySelectorAll("li button ul"),this.$.menu.initDropdownTarget({key:ea.key,type:"dropdown"},e)}active(t,e){return Re.check.isListCell(t)&&/^UL$/i.test(t.parentElement.nodeName)?(Re.utils.addClass(e,"active"),!0):(Re.utils.removeClass(e,"active"),!1)}action(t){const e=this.$.format.getBlock(this.$.selection.getNode()),s=t?.querySelector("ul")?.style.listStyleType;Re.check.isList(e)&&s?e.style.listStyleType=s:this.submit(s),this.$.menu.dropdownOff()}on(){const t=this.#Sc,e=this.$.format.getBlock(this.$.selection.getNode()),s=e?.style?e.style.listStyleType||"disc":"";for(let e,i=0,n=t.length;i<n;i++)e=t[i],s===e.style.listStyleType?Re.utils.addClass(e.parentElement,"active"):Re.utils.removeClass(e.parentElement,"active")}shortcut({range:t,info:e}){const{startContainer:s}=t;if(Re.check.isText(s)){const t=s.substringData(e.key.length,s.textContent.length-1);s.textContent=t}this.submit()}submit(t){const e=this.$.listFormat.apply(`ul:${t||""}`,null,!1);e&&this.$.selection.setRange(e.sc,e.so,e.ec,e.eo),this.$.focusManager.focus(),this.$.history.push(!1)}}const sa=ea;class ia extends Pl{static key="list_numbered";static className="se-icon-flip-rtl";#Sc;constructor(t){super(t),this.title=this.$.lang.numberedList,this.icon="list_numbered",this.afterItem=Re.utils.createElement("button",{class:"se-btn se-tooltip se-sub-arrow-btn",type:"button","data-command":ia.key,"data-type":"dropdown"},`${this.$.icons.arrow_down}<span class="se-tooltip-inner"><span class="se-tooltip-text">${this.$.lang.numberedList}</span></span>`);const e=function(){const t=`\n\t<div class="se-list-inner">\n\t\t<ul class="se-list-basic se-list-horizontal se-list-carrier">\n\t\t\t${na(["decimal","upper-roman","lower-roman"])}\n\t\t</ul>\n\t\t<ul class="se-list-basic se-list-horizontal se-list-carrier">\n\t\t${na(["lower-latin","upper-latin","lower-greek"])}\n\t\t</ul>\n\t</div>`;return Re.utils.createElement("DIV",{class:"se-dropdown se-list-layer"},t)}();this.#Sc=e.querySelectorAll("li button ol"),this.$.menu.initDropdownTarget({key:ia.key,type:"dropdown"},e)}active(t,e){return Re.check.isListCell(t)&&/^OL$/i.test(t.parentElement.nodeName)?(Re.utils.addClass(e,"active"),!0):(Re.utils.removeClass(e,"active"),!1)}action(t){const e=this.$.format.getBlock(this.$.selection.getNode()),s=t?.querySelector("ol")?.style.listStyleType;Re.check.isList(e)&&s?e.style.listStyleType=s:this.submit(s),this.$.menu.dropdownOff()}on(){const t=this.#Sc,e=this.$.format.getBlock(this.$.selection.getNode()),s=e?.style?e.style.listStyleType||"decimal":"";for(let e,i=0,n=t.length;i<n;i++)e=t[i],s===e.style.listStyleType?Re.utils.addClass(e.parentElement,"active"):Re.utils.removeClass(e.parentElement,"active")}shortcut({range:t,info:e}){const{startContainer:s}=t;if(Re.check.isText(s)){const t=s.substringData(e.key.length,s.textContent.length-1);s.textContent=t}this.submit()}submit(t){const e=this.$.listFormat.apply(`ol:${t||""}`,null,!1);e&&this.$.selection.setRange(e.sc,e.so,e.ec,e.eo),this.$.focusManager.focus(),this.$.history.push(!1)}}function na(t){return t.map((t=>`\n\t\t\t<li>\n\t\t\t\t<button type="button" class="se-btn se-btn-list se-icon-flip-rtl" data-command="${t}" title="${t}" aria-label="${t}">\n\t\t\t\t\t<ol style="list-style-type: ${t};">\n\t\t\t\t\t\t<li></li><li></li><li></li>\n\t\t\t\t\t</ol>\n\t\t\t\t</button>\n\t\t\t</li>\n\t\t`)).join("")}const oa=ia,{debounce:ra}=Oe;function la(t){return`<div class="se-autocomplete-item"><span>${t.key}</span>${t.name?`<span>${t.name}</span>`:""}</div>`}function aa(t,e){return{tag:"span",attrs:{"data-se-autocomplete":e+t.key},text:e+t.key}}const ha=class extends Hl{static key="autocomplete";static className="";#Ec=0;#Tc=0;#Mc=null;#Nc=null;constructor(t,e){super(t);const s=e.limitSize||5,i=e.searchStartLength||0,n="number"==typeof e.delayTime?e.delayTime:120,o=e.useCachingData??!0,r=e.useCachingFieldData??!0;this.triggerContexts=new Map;const l=e.triggers||{};for(const[t,e]of Object.entries(l)){const n=e.limitSize??s;this.triggerContexts.set(t,{trigger:t,limitSize:n,searchStartLength:e.searchStartLength??i,directData:e.data||null,apiUrl:e.apiUrl?.replace(/\s/g,"").replace(/\{limitSize\}/i,String(n))||"",apiHeaders:e.apiHeaders||null,transformResponse:e.transformResponse||null,renderItem:e.renderItem||la,onSelect:e.onSelect||aa,apiManager:e.apiUrl?new zr(this,this.$,{headers:e.apiHeaders}):null,cachingData:e.useCachingData??o?new Map:null,cachingFieldData:e.useCachingFieldData??r?[]:null})}this.sortedTriggers=[...this.triggerContexts.keys()].sort(((t,e)=>e.length-t.length));const a=Re.utils.createElement("DIV",{class:"se-controller se-empty-controller"},"<div></div>");this.selectMenu=new Bi(this.$,{position:"right-bottom",dir:"ltr",closeMethod:()=>this.controller.close()}),this.controller=new Mi(this,this.$,a,{position:"bottom",initMethod:()=>{this.#Bc(),this.selectMenu.close()}},null),this.selectMenu.on(a.firstElementChild,this.#Ic.bind(this)),this.onInput=ra(this.onInput.bind(this),n)}#Bc(){this.#Nc?.apiManager&&this.#Nc.apiManager.cancel()}async onInput(){this.#Bc();const t=this.$.selection.get();if(!t.rangeCount)return void this.selectMenu.close();const e=t.anchorNode,s=t.anchorOffset,i=e.textContent.substring(0,s);for(const t of this.sortedTriggers){const n=i.lastIndexOf(t);if(-1===n)continue;const o=i.substring(n+t.length,s),r=i[n-1]?.trim();if(!/\s/.test(o)&&(!r||Re.check.isZeroWidth(r))){const i=this.triggerContexts.get(t);if(o.length<i.searchStartLength)return;const r=e.parentNode;if(Re.check.isAnchor(r)&&!r.getAttribute("data-se-autocomplete"))return;try{return this.#Nc=i,await this.#Lc(i,o,e),this.#Ec=n,this.#Mc=e,void(this.#Tc=s)}catch(t){console.warn("[SUNEDITOR.autocomplete.api] ",t)}}}this.selectMenu.close()}async#Lc(t,e,s){const i=t.limitSize,n=e.toLowerCase();let o=null;if(t.cachingData&&(o=t.cachingData.get(e)),!o)if(t.directData)o=t.directData.filter((t=>t.key.toLowerCase().startsWith(n))).slice(0,i);else{const s=await t.apiManager.asyncCall({method:"GET",url:this.#Ac(t,e)}),i=JSON.parse(s.responseText);o=t.transformResponse?t.transformResponse(i,s):i}if(t.cachingFieldData){const e=new Set;o=t.cachingFieldData.concat(o).filter((({key:t})=>!e.has(t)&&(e.add(t),t.toLowerCase().startsWith(n)))).slice(0,i)}if(!o?.length)return this.selectMenu.close(),!1;const r=[],l=[];for(let e,s=0,i=o.length;s<i;s++)e=o[s],r.push(e),l.push(t.renderItem(e,t.trigger));return this.controller.open(s,null,{isWWTarget:!0,initMethod:null,addOffset:null}),this.selectMenu.create(r,l),this.selectMenu.open(),this.selectMenu.setItem(0),t.cachingData&&t.cachingData.set(e,r),!0}#Ac(t,e){return t.apiUrl.replace(/\{key\}/i,e)}#Ic(t){if(!t)return!1;const e=this.#Nc;if(!e)return!1;const s=e.onSelect(t,e.trigger);let i=null;const n=this.#Mc.parentNode;if("string"==typeof s){if(this.$.selection.setRange(this.#Mc,this.#Ec,this.#Mc,this.#Tc),i=Re.utils.createTextNode(s),!this.$.html.insertNode(i,{afterNode:null,skipCharCount:!1}))return!1}else{let t;if(s?.nodeType)t=s;else{if(!s?.tag)return!1;t=Re.utils.createElement(s.tag.toUpperCase(),s.attrs||{},s.text||"")}if(n.getAttribute?.("data-se-autocomplete")){for(const t of[...n.attributes])n.removeAttribute(t.name);for(const e of[...t.attributes])n.setAttribute(e.name,e.value);n.textContent=t.textContent,i=n}else{if(this.$.selection.setRange(this.#Mc,this.#Ec,this.#Mc,this.#Tc),!this.$.html.insertNode(t,{afterNode:null,skipCharCount:!1}))return!1;i=t}}this.selectMenu.close();const o=Re.utils.createTextNode(" ");i.parentNode.insertBefore(o,i.nextSibling),this.$.selection.setRange(o,1,o,1),e.cachingFieldData&&!e.cachingFieldData.some((e=>e.key===t.key))&&e.cachingFieldData.push(t)}},{debounce:ca}=Oe;const da=class extends Hl{static key="slashCommand";static className="";#Oc;#Rc;#zc;#jl;#Ec=0;#Tc=0;#Mc=null;#Pc=!1;constructor(t,e){super(t),this.#Oc="string"==typeof e.triggerChar&&e.triggerChar.length>0?e.triggerChar:"/",this.#Rc="number"==typeof e.limitSize&&e.limitSize>0?e.limitSize:10,this.#zc="string"==typeof e.emptyMessage?e.emptyMessage:"";const s="number"==typeof e.delayTime?e.delayTime:120;this.#jl=new cn(this,this.$,{items:Array.isArray(e.items)?e.items:[],resolveButton:hs,renderCustomItem:"function"==typeof e.renderItem?e.renderItem:null,selectMenuParams:{position:"bottom-left",dir:"ltr",minWidth:"200px",maxHeight:"320px",closeMethod:()=>this.#Dc()}});const i=Re.utils.createElement("DIV",{class:"se-controller se-empty-controller"},"<div></div>");this.controller=new Mi(this,this.$,i,{position:"bottom",escGuard:()=>this.#jl.hasOpenSubPanel()},null),this.#jl.attach(i.firstElementChild,this.#Ic.bind(this),{class:"se-block-action-menu se-slash-command-menu"}),this.onInput=ca(this.onInput.bind(this),s)}onKeyDown({event:t}){Pe.isEsc(t.code)&&this.onInput.cancel?.()}onInput(){if(0===this.#jl.getItems().length)return;const t=this.$.selection.get();if(!t.rangeCount)return void this.#Fc();const e=t.anchorNode,s=t.anchorOffset;if(!e||"string"!=typeof e.textContent)return void this.#Fc();const i=e.textContent.substring(0,s),n=this.#Oc,o=i.lastIndexOf(n);if(-1===o)return void this.#Fc();const r=i.substring(o+n.length,s);if(/\s/.test(r))return void this.#Fc();const l=i[o-1];if(l&&""!==l.trim()&&!Re.check.isZeroWidth(l))return void this.#Fc();const a=this.#jl.filter(r,this.#Rc);0!==a.length?(this.controller.open(e,null,{isWWTarget:!0,initMethod:null,addOffset:null}),this.#jl.createRows(a),this.#jl.open(),this.#jl.setItem(0),this.#Hc(e,o,s)):this.#zc?(this.#qc(e),this.#Hc(e,o,s)):this.#Fc()}#Fc(){this.#Pc=!0,this.#jl.close(),this.#Pc=!1}#Dc(){this.#Pc||this.#Wc(),this.#Mc=null,this.controller.close()}#Wc(){const t=this.#Mc;if(!t||!t.parentNode)return;if(t.textContent?.[this.#Ec]!==this.#Oc)return;this.$.selection.setRange(t,this.#Ec,t,this.#Tc);const e=this.$.selection.getRange();e&&!e.collapsed&&this.$.html.remove()}#Hc(t,e,s){this.#Mc=t,this.#Ec=e,this.#Tc=s}#qc(t){this.controller.open(t,null,{isWWTarget:!0,initMethod:null,addOffset:null}),this.#jl.selectMenu.create([null],[`<span class="se-slash-empty">${this.#zc}</span>`]),this.#jl.open()}#Ic(t){if(!t)return!1;const e=this.#Mc;if(!e)return!1;const s=this.#Oc,i=e.textContent.substring(this.#Ec+s.length,this.#Tc);this.$.selection.setRange(e,this.#Ec,e,this.#Tc);const n=this.$.selection.getRange();n&&!n.collapsed&&this.$.html.remove(),this.#Fc(),this.#jl.dispatch(t,{triggerChar:s,query:i,item:t.raw})}};class ua extends Dl{static key="align";static className="";constructor(t,e){super(t),this.title=this.$.lang.align,this.icon=this.$.options.get("_rtl")?"align_right":"align_left",this.defaultDir="",this.alignIcons={justify:this.$.icons.align_justify,left:this.$.icons.align_left,right:this.$.icons.align_right,center:this.$.icons.align_center};const s=this.$.menu.initDropdownTarget(ua,function({lang:t,icons:e,options:s},i){return(Array.isArray(i)?i:s.get("_rtl")?["right","center","left","justify"]:["left","center","right","justify"]).map((s=>{const i=t["align"+s.charAt(0).toUpperCase()+s.slice(1)];return{command:s,title:i,innerHTML:`<span class="se-list-icon">${e["align_"+s]}</span>${i}`}}))}(this.$,e.items),{className:"se-list-align"});this._itemMenu=s.querySelector("ul"),this.alignList=s.querySelectorAll("li button")}active(t,e){const s=e.firstElementChild;if(t){if(this.$.format.isLine(t)){const i=t.style.textAlign;return i?(Re.utils.changeElement(s,this.alignIcons[i]||this.alignIcons[this.defaultDir]),e.setAttribute("data-focus",i),!0):void 0}}else Re.utils.changeElement(s,this.alignIcons[this.defaultDir]),e.removeAttribute("data-focus");return!1}on(t){const e=t.getAttribute("data-focus")||this.defaultDir;if(!e)return;const s=this.alignList;for(let t=0,i=s.length;t<i;t++)e===s[t].getAttribute("data-command")?Re.utils.addClass(s[t],"active"):Re.utils.removeClass(s[t],"active")}action(t){const e=t.getAttribute("data-command");if(!e)return;const s=this.defaultDir,i=this.$.format.getLines();for(let t=0,n=i.length;t<n;t++)Re.utils.setStyle(i[t],"textAlign",e===s?"":e);this.$.store.set("_lastSelectionNode",null),this.$.menu.dropdownOff(),this.$.focusManager.focus(),this.$.history.push(!1)}setDir(){const t=this.#Uc();if(this.defaultDir===t)return;this.defaultDir=t;const e=this._itemMenu.querySelector('[data-command="left"]'),s=this._itemMenu.querySelector('[data-command="right"]');if(e&&s){const t=e.parentElement,i=s.parentElement;t.appendChild(s),i.appendChild(e)}}init(){this.defaultDir=this.#Uc()}#Uc(){const t=this.$.frameContext.get("wwComputedStyle").getPropertyValue("text-align");return["left","center","right","justify"].includes(t)?t:this.$.options.get("_rtl")?"right":"left"}}const pa=ua;class ga extends Dl{static key="font";static className="se-btn-select se-btn-tool-font";#Vc;constructor(t,e){super(t),this.title=this.$.lang.font,this.inner='<span class="se-txt">'+this.$.lang.font+"</span>"+this.$.icons.arrow_down;const s=e.items||["Arial","Comic Sans MS","Courier New","Impact","Georgia","tahoma","Trebuchet MS","Verdana"],i=`<li><button type="button" class="se-btn se-btn-list default_value" data-command="" title="${this.$.lang.default}" aria-label="${this.$.lang.default}">${this.$.lang.default}</button></li><li class="se-btn-list se-sub-list"><span></span></li>`,n=this.$.menu.initDropdownTarget(ga,function(t){return t.map((t=>{const e=t.split(",")[0];return{command:t,title:e,innerHTML:e,attrs:{"data-txt":e,style:`font-family:${t};`}}}))}(s),{className:"se-list-font-family",prependHTML:i});this.currentFont="",this.fontList=n.querySelectorAll("ul li button"),this.fontArray=s,this.#Vc=n.querySelector(".se-sub-list span")}active(t,e){const s=e.querySelector(".se-txt"),i=e.parentNode.querySelector(".se-tooltip-text");let n="";if(t){if(this.$.format.isLine(t))return;if(n=Re.utils.getStyle(t,"fontFamily")){const t=n.replace(/["']/g,"");return Re.utils.changeTxt(s,t),Re.utils.changeTxt(i,this.$.lang.font+" ("+t+")"),!0}}else{const t=this.$.store.get("hasFocus")?this.$.frameContext.get("wwComputedStyle").fontFamily:this.$.lang.font;Re.utils.changeTxt(s,t),Re.utils.changeTxt(i,this.$.store.get("hasFocus")?this.$.lang.font+(t?" ("+t+")":""):t)}return!1}on(t){const e=this.fontList,s=t.querySelector(".se-txt").textContent;if(s!==this.currentFont){let t=!1;for(let i=0,n=e.length;i<n;i++)s===(e[i].getAttribute("data-command")||"").replace(/'|"/g,"")?(Re.utils.addClass(e[i],"active"),t=!0):Re.utils.removeClass(e[i],"active");this.currentFont=s,t?this.#Vc.style.display="none":(this.#Vc.textContent=s,this.#Vc.style.display="block")}}async action(t){let e=t.getAttribute("data-command");if(e){if(/[\s\d\W]/.test(e)&&!/^['"].*['"]$/.test(e)&&(e=`"${e}"`),!1===await this.$.eventManager.triggerEvent("onFontActionBefore",{value:e}))return;const t=Re.utils.createElement("SPAN",{style:"font-family: "+e+";"});this.$.inline.apply(t,{stylesToModify:["font-family"],nodesToRemove:null,strictRemove:null})}else this.$.inline.apply(null,{stylesToModify:["font-family"],nodesToRemove:["span"],strictRemove:!0});this.$.menu.dropdownOff()}}const ma=ga;class fa extends Fl{static key="fontColor";static className="";constructor(t,e){super(t),this.title=this.$.lang.fontColor,this.icon="font_color";const s=Re.utils.createElement("DIV",{class:"se-dropdown se-list-layer"},null);this.colorPicker=new Sl(this,this.$,"color",{form:s,colorList:e.items,splitNum:e.splitNum,disableHEXInput:e.disableHEXInput,hueSliderOptions:{controllerOptions:{isOutsideForm:!0}}}),this.$.menu.initDropdownTarget(fa,s)}active(t,e){const s=e.querySelector(".se-svg-color-helper");if(!s)return;let i="";if(t){if(this.$.format.isLine(t))return;if(i=Re.utils.getStyle(t,"color"))return s.style.color=i,!0}else s.style.color=i;return!1}on(t){this.colorPicker.init(this.$.selection.getNode(),t,(t=>this.$.format.isLine(t)))}off(){this.colorPicker.hueSliderClose()}colorPickerAction(t){if(t){const e=Re.utils.createElement("SPAN",{style:"color: "+t+";"});this.$.inline.apply(e,{stylesToModify:["color"],nodesToRemove:null,strictRemove:null})}else this.$.inline.apply(null,{stylesToModify:["color"],nodesToRemove:["span"],strictRemove:!0});this.$.menu.dropdownOff()}}const va=fa;class ba extends Fl{static key="backgroundColor";static className="";constructor(t,e){super(t),this.title=this.$.lang.backgroundColor,this.icon="background_color";const s=Re.utils.createElement("DIV",{class:"se-dropdown se-list-layer"},null);this.colorPicker=new Sl(this,this.$,"backgroundColor",{form:s,colorList:e.items,splitNum:e.splitNum,disableHEXInput:e.disableHEXInput,hueSliderOptions:{controllerOptions:{isOutsideForm:!0}}}),this.$.menu.initDropdownTarget(ba,s)}active(t,e){const s=e.querySelector("path.se-svg-color-helper");if(!s)return;let i="";if(t){if(this.$.format.isLine(t))return;if(i=Re.utils.getStyle(t,"backgroundColor"))return s.style.color=i,!0}else s.style.color=i;return!1}on(t){this.colorPicker.init(this.$.selection.getNode(),t,(t=>this.$.format.isLine(t)))}off(){this.colorPicker.hueSliderClose()}colorPickerAction(t){if(t){const e=Re.utils.createElement("SPAN",{style:"background-color: "+t+";"});this.$.inline.apply(e,{stylesToModify:["background-color"],nodesToRemove:null,strictRemove:null})}else this.$.inline.apply(null,{stylesToModify:["background-color"],nodesToRemove:["span"],strictRemove:!0});this.$.menu.dropdownOff()}}const ya=ba;class wa extends Dl{static key="hr";static className="";static component(t){return/^hr$/i.test(t?.nodeName)?t:null}constructor(t,e){super(t),this.title=this.$.lang.horizontalLine,this.icon="horizontal_line";const s=this.$.menu.initDropdownTarget(wa,function({lang:t},e){return(e||[{name:t.hr_solid,class:"__se__solid",style:null},{name:t.hr_dashed,class:"__se__dashed",style:null},{name:t.hr_dotted,class:"__se__dotted",style:null}]).map((t=>({command:"hr",title:t.name,innerHTML:`<hr${t.class?` class="${t.class}"`:""}${t.style?` style="${t.style}"`:""}/>`})))}(this.$,e.items),{className:"se-list-line"});this.list=s.querySelectorAll("button")}componentSelect(t){Re.utils.addClass(t,"on")}componentDeselect(t){Re.utils.removeClass(t,"on")}componentDestroy(t){if(!t)return;const e=t.previousElementSibling||t.nextElementSibling;Re.utils.removeItem(t),this.$.focusManager.focusEdge(e),this.$.history.push(!1)}shortcut({line:t,range:e}){const s=this.$.nodeTransform.split(e.endContainer,e.endOffset,0);this.submit("__se__solid"),Re.utils.removeItem(t),this.$.selection.setRange(s,0,s,0)}action(t){const e=this.submit(t.firstElementChild.className),s=this.$.format.addLine(e);this.$.selection.setRange(s,1,s,1),this.$.menu.dropdownOff()}submit(t){const e=Re.utils.createElement("hr",{class:t});return this.$.focusManager.focus(),this.$.component.insert(e,{insertBehavior:"line"}),e}}const Ca=wa;class _a extends Dl{static key="list";static className="se-icon-flip-rtl";#Sc;#jc;constructor(t){super(t),this.title=this.$.lang.list,this.icon="list_numbered",this.#jc={bulleted:this.$.icons.list_bulleted,numbered:this.$.icons.list_numbered};const e=this.$.menu.initDropdownTarget(_a,function({lang:t,icons:e}){return[{command:"ol",title:t.numberedList,innerHTML:e.list_numbered,className:"se-tooltip se-icon-flip-rtl"},{command:"ul",title:t.bulletedList,innerHTML:e.list_bulleted,className:"se-tooltip se-icon-flip-rtl"}]}(this.$));this.#Sc=e.querySelectorAll("li button")}active(t,e){const s=e.firstElementChild;if(Re.check.isList(t)){const i=t.nodeName.toLowerCase();return e.setAttribute("data-focus",i),Re.utils.addClass(e,"active"),/^ul$/.test(i)?Re.utils.changeElement(s,this.#jc.bulleted):Re.utils.changeElement(s,this.#jc.numbered),!0}return e.removeAttribute("data-focus"),Re.utils.changeElement(s,this.#jc.numbered),Re.utils.removeClass(e,"active"),!1}on(t){const e=t.getAttribute("data-focus")||"",s=this.#Sc;for(let t=0,i=s.length;t<i;t++)e===s[t].getAttribute("data-command")?Re.utils.addClass(s[t],"active"):Re.utils.removeClass(s[t],"active")}action(t){const e=t.getAttribute("data-command"),s=t.getAttribute("data-value")||"",i=this.$.listFormat.apply(`${e}:${s}`,null,!1);i&&this.$.selection.setRange(i.sc,i.so,i.ec,i.eo),this.$.menu.dropdownOff(),this.$.history.push(!1)}}const ka=_a,xa=".se-table-resize-line",$a=".se-table-resize-line-prev",Sa=".se-table-resize-row",Ea=".se-table-resize-row-prev",Ta=["none","solid","dotted","dashed","double","groove","ridge","inset","outset"],Ma={all:"border_all",inside:"border_inside",horizon:"border_horizontal",vertical:"border_vertical",outside:"border_outside",left:"border_left",top:"border_top",right:"border_right",bottom:"border_bottom",none:"border_none"},Na=["all","inside","horizon","vertical"],Ba="borderLeft",Ia="borderTop",La="borderRight",Aa="borderBottom",Oa=["#bbf7d0","#fde68a","#fecaca","#e9d5ff","#bfdbfe","#22c55e","#eab308","#ef4444","#a855f7","#3b82f6","#15803d","#ca8a04","#b91c1c","#7e22ce","#1d4ed8","#e5e7eb","#9ca3af","#6b7280","#374151","#000000"],Ra={physical_cellCnt:0,logical_cellCnt:0,cellCnt:0,rowCnt:0,rowIndex:0,physical_cellIndex:0,logical_cellIndex:0,current_colSpan:0,current_rowSpan:0,isShiftPressed:!1,ref:null,figureElement:null,selectedTable:null,trElement:null,trElements:null,tdElement:null,fixedCell:null,selectedCell:null,selectedCells:null},{_w:za}=Le,Pa=new WeakMap,Da=new WeakMap;function Fa(t){return/^(TD|TH|TR)$/i.test(t?.nodeName)}function Ha(t){return/^CAPTION$/i.test(t.nodeName)}function qa(t,e){const s=t.clientX,i=ze.get(za.getComputedStyle(e).width,0),n=e.getBoundingClientRect(),o=Math.round(s-n.left),r=o<=6;return{is:r||i-o<=6,isLeft:r,startX:s}}function Wa(t,e){const s=t.clientY,i=ze.get(za.getComputedStyle(e).height,0),n=e.getBoundingClientRect();return{is:Math.ceil(i+n.top-s)<=6,startY:s}}function Ua(t,e){return`<${t=t.toLowerCase()}><div><br></div></${t}>`.repeat(e)}function Va(t){return t=t.toLowerCase(),Re.utils.createElement(t,null,"<div><br></div>")}function ja(t,e,s){let i=Da.get(t);return i||(i=function(t){const e=[],s=t.rows,i=[];for(let t=0,n=s.length;t<n;t++){const n=s[t].cells;e[t]=[];let o=0;for(let s=0,r=n.length;s<r;s++){for(;i[t]?.[o];)o++;e[t][s]=o;const r=n[s],l=r.colSpan||1,a=r.rowSpan||1;if(a>1)for(let e=1;e<a;e++){i[t+e]||(i[t+e]=[]);for(let s=0;s<l;s++)i[t+e][o+s]=!0}o+=l}}return e}(t),Da.set(t,i)),i[e]?.[s]??0}function Ga(t,e){const s=Re.utils.clone(t,!0),i=Array.from(t.querySelectorAll("td, th")),n=Array.from(s.querySelectorAll("td, th"));return{clonedTable:s,clonedSelectedCells:e.map((t=>{const e=i.indexOf(t);return e>-1?n[e]:null})).filter((t=>null!==t))}}function Ka(t){t&&(Pa.delete(t),Da.delete(t))}function Ya(t,e,s){const i=[];let n="";for(const o in Ma){if(s.includes(o))continue;const r=Ma[o];i.push(o),n+=`\n\t\t\t<button type="button" class="se-btn se-tooltip">\n\t\t\t\t${e[r]}\n\t\t\t\t<span class="se-tooltip-inner">\n\t\t\t\t\t<span class="se-tooltip-text">${t[r]}</span>\n\t\t\t\t</span>\n\t\t\t</button>`}return{items:i,menus:Re.utils.createElement("DIV",null,n).querySelectorAll("button")}}const Xa=class{#Gc;#J;#I;constructor(t,{mergeButton:e,unmergeButton:s,splitButton:i,openCellMenuFunc:n,closeCellMenuFunc:o}){this.#Gc=t,this.#J=t.$,this.#I=t.state,this.mergeButton=e,this.unmergeButton=s,this.splitButton=i;const r=(l=this.#J.lang,{items:["vertical","horizontal"],menus:Re.utils.createElement("DIV",null,`\n\t\t<div title="${l.verticalSplit}" aria-label="${l.verticalSplit}">\n\t\t\t${l.verticalSplit}\n\t\t</div>\n\t\t<div title="${l.horizontalSplit}" aria-label="${l.horizontalSplit}">\n\t\t\t${l.horizontalSplit}\n\t\t</div>`).querySelectorAll("div")});var l;this.selectMenu_split=new Bi(this.#J,{checkList:!1,position:"bottom-center",openMethod:n,closeMethod:o}),this.selectMenu_split.on(this.splitButton,this._OnSplitCells.bind(this)),this.selectMenu_split.create(r.items,r.menus)}get#Kc(){return this.#Gc.selectionService}openSplitMenu(){this.selectMenu_split.open()}mergeCells(t,e=!1){const s=t[0].closest("table");Ka(s);const{clonedTable:i,clonedSelectedCells:n}=e?{clonedTable:s,clonedSelectedCells:t}:Ga(s,t);this.#Gc.setTableInfo(i),t=n,this.#Gc.setState("ref",null),this.#Kc.setMultiCells(t[0],Re.query.findVisualLastCell(t));const o=this.#I.ref,r=t[0];let l=null,a=null;const h=o.ce-o.cs+1;let c=o.re-o.rs+1,d="",u=null;for(let e,s,i=1,n=t.length;i<n;i++){e=t[i],u!==e.parentNode&&(u=e.parentNode),s=e.children;for(let t=0,e=s.length;t<e;t++)this.#J.format.isLine(s[t])&&Re.check.isZeroWidth(s[t].textContent)&&Re.utils.removeItem(s[t]);d+=e.innerHTML,Re.utils.removeItem(e),0===u.cells.length&&(l?a=u:l=u,c-=1)}if(l){const t=this.#I.trElements,e=Re.utils.getArrayIndex(t,l),s=Re.utils.getArrayIndex(t,a||l),i=[];for(let n,o=0;o<=s;o++)if(n=t[o].cells,0!==n.length)for(let t,i,r=0,l=n.length;r<l;r++)t=n[r],i=t.rowSpan-1,i>0&&o+i>=e&&(t.rowSpan-=ze.getOverlapRangeAtIndex(e,s,o,o+i));else i.push(t[o]);for(let t=0,e=i.length;t<e;t++)Re.utils.removeItem(i[t])}r.innerHTML+=d,r.colSpan=h,r.rowSpan=c,e||(s.replaceWith(i),this.#Gc._closeTableSelectInfo(),this.#Gc._setController(r),this.#Kc.focusCellEdge(r),this.#Kc.initCellSelection(r),this.#Gc.setState("ref",null),this.#Gc.setState("selectedCells",[r]),this.#Gc.setCellInfo(r,!0),this.setUnMergeButton(),this.setMergeSplitButton(),this.#Gc.historyPush())}unmergeCells(t,e=!1){if(!t?.length)return;const s=t[0].closest("table");Ka(s);const{clonedTable:i,clonedSelectedCells:n}=e?{clonedTable:s,clonedSelectedCells:t}:Ga(s,t);this.#Gc.setState("ref",null),this.#Gc.setTableInfo(i);let o=(t=n)[0],r=Re.query.findVisualLastCell(t),l=null;const a=o.closest("table"),h=a.rows;for(const e of t){const t=e.parentElement.rowIndex,s=e.cellIndex,i=e.rowSpan,n=e.colSpan;if(1===i&&1===n)continue;this.#Gc.setCellInfo(e,!0);const a=e.innerHTML;e.remove();for(let c=0;c<i;c++){const i=h[t+c];for(let t=0;t<n;t++){const n=Va("td");0===c&&0===t?(o===e&&(o=n),r===e&&(r=n),n.innerHTML=a,i.insertBefore(n,i.cells[s])):(i.insertBefore(n,i.cells[s+t]),l=n)}}}this.#Gc.setState("selectedCells",null),e||(s.replaceWith(i),this.#Gc._closeTableSelectInfo(),this.#Gc.setTableInfo(i),o!==r?(r=!l||r.closest("tr").rowIndex>l.closest("tr").rowIndex||r.cellIndex>l.cellIndex?r:l,this.#Kc.setMultiCells(o,r),this.#Gc.setState("selectedCells",Array.from(a.querySelectorAll(".se-selected-table-cell")))):this.#Gc.setCellInfo(r,!0),this.#Kc.initCellSelection(o),this.#Gc.setState("selectedCell",r),this.setUnMergeButton(),this.#Gc.controller_cell.resetPosition(r),this.#Gc.historyPush())}findMergedCells(t){const e=[];return t?.forEach((t=>{t&&(t.rowSpan>1||t.colSpan>1)&&e.push(t)})),e}setMergeSplitButton(){this.#I.ref?(this.splitButton.style.display="none",this.mergeButton.style.display="block"):(this.splitButton.style.display="block",this.mergeButton.style.display="none")}setUnMergeButton(){const t=this.findMergedCells(this.#I.selectedCells?.length?this.#I.selectedCells:[this.#I.fixedCell]).length>0;this.unmergeButton.style.display=t?"block":"none"}_OnSplitCells(t){Ka(this.#Gc._element);const e="vertical"===t,s=this.#I.tdElement,i=this.#I.trElements,n=this.#I.trElement,o=this.#I.logical_cellIndex,r=this.#I.rowIndex,l=Va(s.nodeName);if(e){const t=s.colSpan;if(l.rowSpan=s.rowSpan,t>1)l.colSpan=Math.floor(t/2),s.colSpan=t-l.colSpan,n.insertBefore(l,s.nextElementSibling);else{let e=[],r=[];for(let n,l,a=0,h=this.#I.rowCnt;a<h;a++){n=i[a].cells,l=0;for(let i,h,c,d,u=0,p=n.length;u<p;u++){if(i=n[u],h=i.colSpan-1,c=i.rowSpan-1,d=u+l,r.length>0)for(let t,e=0;e<r.length;e++)t=r[e],t.row>a||(d>=t.index?(l+=t.cs,d+=t.cs,t.rs-=1,t.row=a+1,t.rs<1&&(r.splice(e,1),e--)):u===p-1&&(t.rs-=1,t.row=a+1,t.rs<1&&(r.splice(e,1),e--)));if(d<=o&&c>0&&e.push({index:d,cs:h+1,rs:c,row:-1}),i!==s&&d<=o&&d+h>=o+t-1){i.colSpan+=1;break}if(d>o)break;l+=h}r=r.concat(e).sort((function(t,e){return t.index-e.index})),e=[]}n.insertBefore(l,s.nextElementSibling)}}else{const t=s.rowSpan;if(l.colSpan=s.colSpan,t>1){l.rowSpan=Math.floor(t/2);const e=t-l.rowSpan,r=[],a=Re.utils.getArrayIndex(i,n)+e;for(let t,e,s=0;s<a;s++){t=i[s].cells,e=0;for(let i,n,l,h=0,c=t.length;h<c&&(l=h+e,!(l>=o));h++)i=t[h],n=i.rowSpan-1,n>0&&n+s>=a&&l<o&&r.push({index:l,cs:i.colSpan}),e+=i.colSpan-1}const h=i[a],c=h.cells;let d=r.shift();for(let t,e,s,i,n=0,a=c.length,u=0;n<a;n++){if(s=n+u,t=c[n],e=t.colSpan-1,i=s+e+1,d&&i>=d.index&&(u+=d.cs,i+=d.cs,d=r.shift()),i>=o||n===a-1){h.insertBefore(l,t.nextElementSibling);break}u+=e}s.rowSpan=e}else{l.rowSpan=s.rowSpan;const t=Re.utils.createElement("TR");t.appendChild(l);for(let t,e=0;e<r;e++){if(t=i[e].cells,0===t.length)return;for(let s=0,i=t.length;s<i;s++)e+t[s].rowSpan-1>=r&&(t[s].rowSpan+=1)}const e=this.#I.physical_cellIndex,o=n.cells;for(let t=0,s=o.length;t<s;t++)t!==e&&(o[t].rowSpan+=1);n.parentNode.insertBefore(t,n.nextElementSibling)}}this.selectMenu_split.close(),this.#Kc.focusCellEdge(s),this.#Kc.deleteStyleSelectedCells(),this.#J.history.push(!1),this.#Gc._setController(s),this.#Gc.setState("selectedCell",s),this.#Gc.setState("fixedCell",s),this.#I.selectedCells?.length||this.#Gc.setState("selectedCells",[s])}};const Za=class{#Gc;#I;constructor(t){this.#Gc=t,this.#I=t.state}get#Kc(){return this.#Gc.selectionService}get#Yc(){return this.#Gc.gridService}get#Xc(){return this.#Gc.cellService}copySelectedTableCells(t,e,s){t.preventDefault(),t.stopPropagation();const i=s[0].closest("table"),n=i.cloneNode(!1),o=Re.utils.createElement("tbody");n.appendChild(o);const r=new Map;s.forEach((t=>{r.set(t,!0)}));const l=i.rows,a=l.length,h=Array.from(l[0].cells).reduce(((t,e)=>t+(e.colSpan||1)),0),c=Array.from({length:a},(()=>Array(h).fill(null)));for(let t=0;t<a;t++){const e=l[t].cells;for(let s=0,n=e.length;s<n;s++){const n=ja(i,t,s),o=e[s],r=o.rowSpan||1,l=o.colSpan||1;for(let e=0;e<r;e++)for(let s=0;s<l;s++)c[t+e][n+s]=o}}for(let t=0;t<a;t++){let e;for(let s=0;s<h;s++){const i=c[t][s];if(!i||!r.has(i))continue;if(e||(e=Re.utils.createElement("tr"),o.appendChild(e)),e.lastChild&&c[t][s-1]===i)continue;if(t>0&&c[t-1][s]===i)continue;const n=i.cloneNode(!0);let l=1,d=1;for(;t+l<a&&c[t+l][s]===i;)l++;for(;s+d<h&&c[t][s+d]===i;)d++;l>1&&(n.rowSpan=l),d>1&&(n.colSpan=d),e.appendChild(n)}}const d=Re.utils.createElement("figure");d.className=e.className,d.appendChild(n);const u=`<html><body>\x3c!--StartFragment--\x3e${d.outerHTML}\x3c!--EndFragment--\x3e</body></html>`;t.clipboardData.setData("text/html",u)}pasteTableCellMatrix(t,e){if(!t||!e)return;Ka(e.closest("table"));const s=t.rows;let i=0;const n=[];for(let t=0;t<s.length;t++){const e=s[t].cells;let o=0;for(let s=0;s<e.length;s++){const r=e[s];for(;n[t]?.[o];)o++;const l=r.rowSpan||1,a=r.colSpan||1;0===o&&(i+=l);for(let e=0;e<l;e++)for(let s=0;s<a;s++)n[t+e]||(n[t+e]=[]),n[t+e][o+s]=!0;o+=a}}let o=0;for(let t=0,e=s[0].cells,i=e.length;t<i;t++){o+=e[t].colSpan||1}const r={rowCnt:i,logicalCellCnt:o};this.#Kc.deleteStyleSelectedCells();const l=e.closest("table"),{clonedTable:a,clonedSelectedCells:h}=Ga(l,[e]),c=a;e=h[0];let d=c.rows;this.#Gc.setTableInfo(c),this.#Gc.setCellInfo(e,!0);const u={physicalCellCnt:this.#I.physical_cellCnt,logicalCellCnt:this.#I.logical_cellCnt,rowCnt:this.#I.rowCnt,rowIndex:this.#I.rowIndex,physicalCellIndex:this.#I.physical_cellIndex,logicalCellIndex:this.#I.logical_cellIndex,currentColSpan:this.#I.current_colSpan,currentRowSpan:this.#I.current_rowSpan},p=r.rowCnt-(u.rowCnt-(u.rowIndex+1))-1,g=r.logicalCellCnt-(u.logicalCellCnt-(u.logicalCellIndex+1))-1;if(u.rowCnt+=p,u.logicalCellCnt+=g,u.physicalCellCnt+=g,p>0||g>0){const t=d[d.length-1],e=t.cells[t.cells.length-1];for(let t=0;t<p;t++)this.#Yc.editRow("down",e);for(let t=0;t<g;t++)this.#Yc.editColumn("right",e);this.#Gc.setState("trElements",d=c.rows)}const m=u.rowIndex,f=u.logicalCellIndex,v=f+r.logicalCellCnt-1,b=[],y=[];for(let t=0,e=m+r.rowCnt;t<e;t++){const e=d[t]?.cells;if(!e)continue;let s=0,i=0;for(let n=0;n<e.length;n++){for(;y[t]?.[s];)s++;const n=e[i++];if(!n)break;const o=n.colSpan||1,r=n.rowSpan||1,l=s,a=s+o-1;if(r>1||o>1)for(let e=1;e<r;e++){const i=t+e;y[i]||=[];for(let t=0;t<o;t++)y[i][s+t]=!0}l<=v&&a>=f&&(o>1||r>1)&&b.push(n),s+=o}}b.length>0&&(this.#Xc.unmergeCells(b,!0),this.#Gc.setState("trElements",d=c.rows));const w=[],C=[],_=[];for(let t=0,e=r.rowCnt;t<e;t++){const e=s[t]?.cells;if(!e)break;let i=0;for(let s=0;s<e.length;s++){const n=e[s],o=n.colSpan||1,r=n.rowSpan||1;for(;C[t]?.[i];)i++;for(let e=1;e<r;e++){const s=t+e;C[s]||=[];for(let t=0;t<o;t++)C[s][i+t]=!0}if(o<=1&&r<=1){i+=o;continue}const l=i+u.logicalCellIndex,a=l+o-1,h=[];for(let e=u.rowIndex+t,s=e+r,i=0;e<s;e++,i++){const t=d[e].cells;let s=0,i=0;for(;i<t.length&&s<=a;){for(;_[e]?.[s];)s++;const n=t[i++],o=n.colSpan||1,r=n.rowSpan||1,c=s,d=s+o-1;if(r>1)for(let t=1;t<r;t++){const i=e+t;_[i]||=[];for(let t=0;t<o;t++)_[i][s+t]=!0}d>=l&&c<=a&&h.push(n),s+=o}}h.length>0&&w.push(h),i+=o}}if(w.length>0){for(const t of w)this.#Gc.setState("ref",null),this.#Gc.setState("trElements",c.rows),this.#Xc.mergeCells(t,!0);this.#Gc.setState("trElements",d=c.rows)}const k=[],x=[];for(let t=0;t<r.rowCnt;t++){const e=d[u.rowIndex+t],i=s[t];if(!e||!i)break;const n=e.cells,o=i.cells;let r=0,l=0,a=0;for(;l<n.length&&a<o.length&&r<=v;){for(;x[t]?.[r];)r++;const e=n[l++],s=o[a];if(!e||!s)break;const i=e.colSpan||1,h=e.rowSpan||1;if(h>1)for(let e=1;e<h;e++){const s=t+e;x[s]||=[];for(let t=0;t<i;t++)x[s][r+t]=!0}r>=f&&r+i-1<=v&&(e.innerHTML=s.innerHTML,k.push(e),a++),r+=i}}return l.replaceWith(c),this.#Gc._closeTableSelectInfo(),this.#Gc.setTableInfo(c),this.#Xc.setMergeSplitButton(),this.#Xc.setUnMergeButton(),this.#Kc.focusCellEdge(k[0]),this.#Gc.historyPush(),k}};const Ja=class{#Gc;#J;#I;constructor(t,{columnButton:e,rowButton:s,openCellMenuFunc:i,closeCellMenuFunc:n}){this.#Gc=t,this.#J=t.$,this.#I=t.state;const o=(r=this.#J.lang,l=this.#J.icons,{items:["insert-left","insert-right","delete"],menus:Re.utils.createElement("DIV",null,`\n\t\t<div title="${r.insertColumnBefore}" aria-label="${r.insertColumnBefore}">\n\t\t\t<span class="se-list-icon">${l.insert_column_left}</span><span class="se-txt">${r.insertColumnBefore}</span>\n\t\t</div>\n\t\t<div title="${r.insertColumnAfter}" aria-label="${r.insertColumnAfter}">\n\t\t\t<span class="se-list-icon">${l.insert_column_right}</span><span class="se-txt">${r.insertColumnAfter}</span>\n\t\t</div>\n\t\t<div title="${r.deleteColumn}" aria-label="${r.deleteColumn}">\n\t\t\t<span class="se-list-icon">${l.delete_column}</span><span class="se-txt">${r.deleteColumn}</span>\n\t\t</div>`).querySelectorAll("div")});var r,l;this.selectMenu_column=new Bi(this.#J,{checkList:!1,position:"bottom-center",openMethod:i,closeMethod:n}),this.selectMenu_column.on(e,this.#Zc.bind(this)),this.selectMenu_column.create(o.items,o.menus);const a=function(t,e){return{items:["insert-above","insert-below","delete"],menus:Re.utils.createElement("DIV",null,`\n\t\t<div title="${t.insertRowAbove}" aria-label="${t.insertRowAbove}">\n\t\t\t<span class="se-list-icon">${e.insert_row_above}</span><span class="se-txt">${t.insertRowAbove}</span>\n\t\t</div>\n\t\t<div title="${t.insertRowBelow}" aria-label="${t.insertRowBelow}">\n\t\t\t<span class="se-list-icon">${e.insert_row_below}</span><span class="se-txt">${t.insertRowBelow}</span>\n\t\t</div>\n\t\t<div title="${t.deleteRow}" aria-label="${t.deleteRow}">\n\t\t\t<span class="se-list-icon">${e.delete_row}</span><span class="se-txt">${t.deleteRow}</span>\n\t\t</div>`).querySelectorAll("div")}}(this.#J.lang,this.#J.icons);this.selectMenu_row=new Bi(this.#J,{checkList:!1,position:"bottom-center",openMethod:i,closeMethod:n}),this.selectMenu_row.on(s,this.#Jc.bind(this)),this.selectMenu_row.create(a.items,a.menus)}get#Kc(){return this.#Gc.selectionService}openColumnMenu(){this.selectMenu_column.open()}openRowMenu(){this.selectMenu_row.menus[0].style.display=this.selectMenu_row.menus[1].style.display=/^TH$/i.test(this.#I.tdElement?.nodeName)?"none":"",this.selectMenu_row.open()}editTable(t,e){const s=this.#Gc._element,i="row"===t;if(i){const t=this.#I.trElement.parentElement;if(/^THEAD$/i.test(t.nodeName)){if("up"===e)return;if(!t.nextElementSibling||!/^TBODY$/i.test(t.nextElementSibling.nodeName))return void(e?s.innerHTML+="<tbody><tr>"+Ua("td",this.#I.logical_cellCnt)+"</tr></tbody>":(Re.utils.removeItem(this.#I.figureElement),this.#Gc._closeTableSelectInfo()))}}if(this.#I.ref){const t=this.#I.tdElement,s=this.#I.selectedCells;if(i)if(e)this.#Gc.setCellInfo("up"===e?s[0]:s.at(-1),!0),this.editRow(e,null,t);else{let t=s[0].parentNode;const i=[s[0]];for(let e,n=1,o=s.length;n<o;n++)e=s[n],t!==e.parentNode&&(i.push(e),t=e.parentNode);for(let t=0,s=i.length;t<s;t++)this.#Gc.setCellInfo(i[t],!0),this.editRow(e)}else{const i=s[0].parentNode;if(e){let n=null;for(let t=0,e=s.length-1;t<e;t++)if(i!==s[t+1].parentNode){n=s[t];break}this.#Gc.setCellInfo("left"===e?s[0]:n||s[0],!0),this.editColumn(e,null,t)}else{const t=[s[0]];for(let e,n=1,o=s.length;n<o&&(e=s[n],i===e.parentNode);n++)t.push(e);for(let s=0,i=t.length;s<i;s++)this.#Gc.setCellInfo(t[s],!0),this.editColumn(e)}}e||this.#Gc.resetInfo()}else this[i?"editRow":"editColumn"](e);if(!e){const t=s.children;for(let e=0;e<t.length;e++)0===t[e].children.length&&(Re.utils.removeItem(t[e]),e--);0===s.children.length&&Re.utils.removeItem(s)}}editColumn(t,e,s){e&&this.#Gc.setCellInfo(e,!0);const i=!t,n="left"===t,o=this.#I.current_colSpan,r=this.#I.logical_cellIndex+(i||n?0:o+1),l=this.#I.trElements;let a,h=[],c=[],d=0;const u=[],p=[];for(let t,e,s,n,g,m=0,f=this.#I.rowCnt;m<f;m++){t=l[m],a=r,n=!1,e=t.cells,g=0;for(let t,s,l,f,v=0,b=e.length;v<b&&(t=e[v],t);v++)if(s=t.rowSpan-1,l=t.colSpan-1,i){if(f=v+g,c.length>0){const t=!e[v+1];for(let e,s=0;s<c.length;s++)e=c[s],e.row>m||(f>=e.index?(g+=e.cs,f=v+g,e.rs-=1,e.row=m+1,e.rs<1&&(c.splice(s,1),s--)):t&&(e.rs-=1,e.row=m+1,e.rs<1&&(c.splice(s,1),s--)))}s>0&&h.push({rs:s,cs:l+1,index:f,row:-1}),f>=a&&f+l<=a+o?u.push(t):f<=a+o&&f+l>=a?t.colSpan-=ze.getOverlapRangeAtIndex(r,r+o,f,f+l):s>0&&(f<a||f+l>a+o)&&p.push({cell:t,i:m,rs:m+s}),g+=l}else{if(v>=a)break;if(l>0){if(d<1&&l+v>=a){t.colSpan+=1,a=null,d=s+1;break}a-=l}if(!n){for(let t,e=0;e<c.length;e++)t=c[e],a-=t.cs,t.rs-=1,t.rs<1&&(c.splice(e,1),e--);n=!0}}if(c=c.concat(h).sort((function(t,e){return t.index-e.index})),h=[],!i){if(d>0){d-=1;continue}null!==a&&e.length>0&&(s=Va(e[0].nodeName),s=t.insertBefore(s,e[a]))}}const g=this.#Gc._element.querySelector("colgroup");if(g){const t=g.querySelectorAll("col");if(i)Re.utils.removeItem(t[a]);else{if(!(!Re.utils.hasClass(this.#Gc._element,"se-table-layout-fixed")&&"fixed"!==this.#Gc._element.style.tableLayout)&&Array.prototype.some.call(t,(t=>ze.get(t.style.width)>0))){let e=0;for(let s,i=0,n=t.length;i<n;i++)s=ze.get(t[i].style.width),s-=Math.round(s*n*.1/2),e+=s,t[i].style.width=`${s}%`;const s=Re.utils.createElement("col",{style:`width:${100-e}%`});g.insertBefore(s,t[a])}else g.insertBefore(Re.utils.createElement("col"),t[a]||null)}}if(i){let t,e;for(let s,i=0,n=u.length;i<n;i++)s=u[i].parentNode,Re.utils.removeItem(u[i]),0===s.cells.length&&(t||=Re.utils.getArrayIndex(l,s),e=Re.utils.getArrayIndex(l,s),Re.utils.removeItem(s));for(let s,i=0,n=p.length;i<n;i++)s=p[i],s.cell.rowSpan=ze.getOverlapRangeAtIndex(t,e,s.i,s.rs);this.#Gc._closeController()}else this.#Gc._setCellControllerPosition(s||this.#I.tdElement,!0);return s||this.#I.tdElement}editRow(t,e,s){this.#Kc.deleteStyleSelectedCells(),e&&this.#Gc.setCellInfo(e,!0);const i=!t,n="up"===t,o=this.#I.rowIndex,r=i||n?o:o+this.#I.current_rowSpan+1,l=i?-1:1,a=this.#I.trElements;let h=this.#I.logical_cellCnt;for(let t,e=0,s=o+(i?-1:0);e<=s;e++){if(t=a[e].cells,0===t.length)return;for(let s,i,n=0,o=t.length;n<o;n++)s=t[n].rowSpan,i=t[n].colSpan,s<2&&i<2||s+e>r&&r>e&&(t[n].rowSpan=s+l,h-=i)}if(i){const t=a[o+1];if(t){const e=[];let s=a[o].cells,i=0;for(let t,n,o=0,r=s.length;o<r;o++)t=s[o],n=o+i,i+=t.colSpan-1,t.rowSpan>1&&(t.rowSpan-=1,e.push({cell:t.cloneNode(!0),index:n}));if(e.length>0){let n=e.shift();s=t.cells,i=0;for(let o,r,l=0,a=s.length;l<a&&(o=s[l],r=l+i,i+=o.colSpan-1,!(r>=n.index)||(l--,i--,i+=n.cell.colSpan-1,t.insertBefore(n.cell,o),n=e.shift(),n));l++);if(n){t.appendChild(n.cell);for(let s=0,i=e.length;s<i;s++)t.appendChild(e[s].cell)}}}this.#Gc._element.deleteRow(r)}else this.insertBodyRow(this.#Gc._element,r,h);i?this.#Gc._closeController():this.#Gc._setCellControllerPosition(s||this.#I.tdElement,!0)}insertBodyRow(t,e,s){const i=t.insertRow(e);return i.innerHTML=Ua("td",s),i}#Zc(t){switch(Ka(this.#Gc._element),t){case"insert-left":this.editTable("cell","left");break;case"insert-right":this.editTable("cell","right");break;case"delete":this.editTable("cell",null)}this.#Gc.historyPush()}#Jc(t){switch(Ka(this.#Gc._element),t){case"insert-above":this.editTable("row","up");break;case"insert-below":this.editTable("row","down");break;case"delete":this.editTable("row",null)}this.#Gc.historyPush()}},{_w:Qa}=Le;const th=class{#Gc;#J;#I;#fi;#Qc=!1;#td=null;#ed=null;constructor(t){this.#Gc=t,this.#J=t.$,this.#I=t.state,this.#fi={resize:null,resizeStop:null,resizeKeyDown:null}}get#Kc(){return this.#Gc.selectionService}isResizing(){return this.#Qc}onResizeGuide(t,e){const s=qa(t,e);if(s.is)return this.#Gc._element&&(this.#Gc._element.style.cursor=""),this.#si(),"block"===this.#td?.style.display&&(this.#td.style.display="none"),this.#td=this.#J.frameContext.get("wrapper").querySelector(xa),this.#sd(Re.query.getParentElement(e,Re.check.isTable),e,this.#td,s.isLeft),this.#td.style.display="block",!1;return Wa(t,e).is?(this.#si(),this.#Gc._element=Re.query.getParentElement(e,Re.check.isTable),this.#Gc._element.style.cursor="ns-resize","block"===this.#td?.style.display&&(this.#td.style.display="none"),this.#td=this.#J.frameContext.get("wrapper").querySelector(Sa),this.#id(Re.query.getParentElement(e,Re.check.isTable),e,this.#td),this.#td.style.display="block",!1):void 0}offResizeGuide(){this.#nd()}readyResizeFromEdge(t,e){const s=qa(t,e);if(s.is){try{this.#Kc.deleteStyleSelectedCells(),this.#Gc.setCellInfo(e,!0);const t=this.#I.logical_cellIndex+this.#I.current_colSpan-(s.isLeft?1:0);if(this.#J.ui.enableBackWrapper("ew-resize"),this.#td||=this.#J.frameContext.get("wrapper").querySelector(xa),this.#ed=this.#J.frameContext.get("wrapper").querySelector($a),t<0||t===this.#I.logical_cellCnt-1)return this._startFigureResizing(s.startX,t<0),this.#Gc._editorEnable(!1),!1;const i=this.#Gc._element.querySelector("colgroup").querySelectorAll("col")[t<0?0:t];this._startCellResizing(i,s.startX,ze.get(Qa.getComputedStyle(i).width,0),s.isLeft),this.#Gc._editorEnable(!1)}catch(t){console.warn("[SUNEDITOR.plugins.table.error]",t),this.#Gc._editorEnable(!0),this.#si()}finally{this.#Gc.setState("fixedCell",null),this.#Gc.setState("selectedCell",null),this.#Gc.controller_table.hide(),this.#Gc.controller_cell.hide()}return!1}const i=Wa(t,e);if(i.is){try{let t=Re.query.getParentElement(e,Re.check.isTableRow),s=e.rowSpan;if(s>1)for(;Re.check.isTableRow(t)&&s>1;)t=t.nextElementSibling,--s;this.#Kc.deleteStyleSelectedCells(),this.#Gc.setRowInfo(t),this.#J.ui.enableBackWrapper("ns-resize"),this.#td||=this.#J.frameContext.get("wrapper").querySelector(Sa),this.#ed=this.#J.frameContext.get("wrapper").querySelector(Ea),this._startRowResizing(t,i.startY,ze.get(Qa.getComputedStyle(t).height,0)),this.#Gc._editorEnable(!1)}catch(t){console.warn("[SUNEDITOR.plugins.table.error]",t),this.#Gc._editorEnable(!0),this.#si()}finally{this.#Gc.setState("fixedCell",null),this.#Gc.setState("selectedCell",null),this.#Gc.controller_table.hide(),this.#Gc.controller_cell.hide()}return!1}}#od(t){const e=t.querySelector("colgroup").querySelectorAll("col"),s=t.offsetWidth;e.forEach((t=>{const e=t.style.width;if(!e.endsWith("%")){const i=(t.offsetWidth||ze.get(e,0))/s*100;t.style.width=i+"%"}}))}_startCellResizing(t,e,s,i){const n=this.#I.figureElement;Re.utils.removeClass(n,"se-component-selected"),this.#od(this.#Gc._element),this.#sd(n,this.#I.tdElement,this.#ed,i),this.#ed.style.display="block";const o=t.style.width,r=t.nextElementSibling,l=r.style.width,a=Re.utils.hasClass(this.#Gc._element,"se-table-layout-fixed")?l:Oe.getWidthInPercentage(r||t);yi.get("__dragHandler")&&(yi.get("__dragHandler").style.display="none"),this.#rd(this.#ld.bind(this,t,r,n,this.#I.tdElement,this.#td,i,e,s,ze.get(o,0),ze.get(a,0),this.#Gc._element.offsetWidth),(()=>{this.#si(),this.#od(this.#Gc._element),this.#J.history.push(!0),this.#J.component.hoverSelect(this.#Gc._element),this.#Gc._editorEnable(!0)}),(e=>{this._stopResize(t,o,"width",e),this._stopResize(r,l,"width",e)}))}#ld(t,e,s,i,n,o,r,l,a,h,c,d){const u=(l+(d.clientX-r))/c*100;if(u>0){t.style.width=`${u}%`;const r=a-u;e.style.width=`${h+r}%`,this.#sd(s,i,n,o)}}_startRowResizing(t,e,s){const i=this.#I.figureElement;Re.utils.removeClass(i,"se-component-selected"),this.#id(i,t,this.#ed),this.#ed.style.display="block";const n=t.style.height;yi.get("__dragHandler")&&(yi.get("__dragHandler").style.display="none"),this.#rd(this.#ad.bind(this,t,i,this.#td,e,s),(()=>{this.#si(),this.#J.history.push(!0),this.#J.component.hoverSelect(this.#Gc._element),this.#Gc._editorEnable(!0)}),this._stopResize.bind(this,t,n,"height"))}#ad(t,e,s,i,n,o){const r=n+(o.clientY-i);t.style.height=`${r}px`,this.#id(e,t,s)}_startFigureResizing(t,e){const s=this.#I.figureElement;Re.utils.removeClass(s,"se-component-selected"),this.#sd(s,s,this.#ed,e),this.#ed.style.display="block";const i=Oe.getWidthInPercentage(s);yi.get("__dragHandler")&&(yi.get("__dragHandler").style.display="none"),this.#rd(this.#hd.bind(this,s,this.#td,e,t,s.offsetWidth,ze.get(i,0)),(()=>{this.#si(),ze.get(s.style.width,0)>100&&(s.style.width="100%"),this.#J.history.push(!0),this.#J.component.hoverSelect(this.#Gc._element),this.#Gc._editorEnable(!0)}),this._stopResize.bind(this,s,s.style.width,"width"))}#hd(t,e,s,i,n,o,r){const l=(n+(s?i-r.clientX:r.clientX-i))/n*o;l>0&&(t.style.width=`${l}%`,this.#sd(t,t,e,s))}#sd(t,e,s,i){const n=this.#J.offset.getLocal(e),o=this.#J.offset.getLocal(t);s.style.left=`${n.left+(i?0:e.offsetWidth)}px`,s.style.top=`${o.top}px`,s.style.height=`${t.offsetHeight}px`}#id(t,e,s){const i=this.#J.offset.getLocal(e),n=this.#J.offset.getLocal(t);s.style.top=`${i.top+e.offsetHeight}px`,s.style.left=`${n.left}px`,s.style.width=`${t.offsetWidth}px`}_stopResize(t,e,s,i){Pe.isEsc(i.code)&&(this.#si(),this.#J.component.hoverSelect(this.#Gc._element),this.#Gc._editorEnable(!0),t.style[s]=e,"width"===s&&this.#J.component.select(this.#Gc._element,this.#Gc.constructor.key,{isInput:!0}))}#rd(t,e,s){this.#fi.resize=this.#J.eventManager.addGlobalEvent("mousemove",t,!1),this.#fi.resizeStop=this.#J.eventManager.addGlobalEvent("mouseup",e,!1),this.#fi.resizeKeyDown=this.#J.eventManager.addGlobalEvent("keydown",s,!1),this.#Qc=!0}#si(){this.#Qc=!1,this.#J.ui.disableBackWrapper(),this.#nd(),this.#ed&&(this.#ed.style.display="none",this.#ed=null);const t=this.#fi;for(const e in t)t[e]&&=this.#J.eventManager.removeGlobalEvent(t[e]);this.#Qc=!1,this.#td=null}#nd(){this.#td&&(this.#td.style.display="none",this.#td=null),this.#Gc._element&&(this.#Gc._element.style.cursor="")}init(){this.#si()}};const eh=class{#Gc;#J;#I;#cd;#dd;#ud;#pd;#fi;#gd=null;constructor(t){this.#Gc=t,this.#J=t.$,this.#I=t.state,this.#cd=this.#md.bind(this),this.#dd=this.#fd.bind(this),this.#ud=this.#vd.bind(this),this.#pd=this.#bd.bind(this),this.#fi={on:null,off:null,shiftOff:null,touchOff:null,resize:null,resizeStop:null,resizeKeyDown:null}}get#Xc(){return this.#Gc.cellService}selectCells(t){const e=t[0],s=Re.query.findVisualLastCell(t);return this.#gd=e.nodeName,this.setMultiCells(e,s),{fixedCell:e,selectedCell:s}}setMultiCells(t,e){const s=this.#I.selectedTable,i=s.rows;if(this.deleteStyleSelectedCells(),Re.utils.addClass(t,"se-selected-table-cell"),t===e&&!this.#I.isShiftPressed)return;const n=function(t,e){const s=t.parentNode,i=e.parentNode;return`${s.rowIndex},${t.cellIndex}-${i.rowIndex},${e.cellIndex}`}(t,e);let o=Pa.get(s);const r=o?.get(n);if(r)return this.#Gc.setState("ref",r),void this.#yd(i,r);const l=this.#wd(i,t,e);this.#Gc.setState("ref",l),o||(o=new Map,Pa.set(s,o)),o.set(n,l),this.#yd(i,l)}#wd(t,e,s){let i=!0,n=[],o=[];const r={_i:0,cs:null,ce:null,rs:null,re:null};for(let l,a,h=0,c=t.length;h<c;h++){l=t[h].cells,a=0;for(let t,c,d,u,p=0,g=l.length;p<g;p++){if(t=l[p],d=t.colSpan-1,u=t.rowSpan-1,c=p+a,n.length>0)for(let t,e=0;e<n.length;e++)t=n[e],t.row>h||(c>=t.index?(a+=t.cs,c+=t.cs,t.rs-=1,t.row=h+1,t.rs<1&&(n.splice(e,1),e--)):p===g-1&&(t.rs-=1,t.row=h+1,t.rs<1&&(n.splice(e,1),e--)));if(i){if(t!==e&&t!==s||(r.cs=null!==r.cs&&r.cs<c?r.cs:c,r.ce=null!==r.ce&&r.ce>c+d?r.ce:c+d,r.rs=null!==r.rs&&r.rs<h?r.rs:h,r.re=null!==r.re&&r.re>h+u?r.re:h+u,r._i+=1),2===r._i){i=!1,n=[],o=[],h=-1;break}}else{const t=r.cs<c?r.cs:c,e=r.ce>c+d?r.ce:c+d,s=r.rs<h?r.rs:h,i=r.re>h+u?r.re:h+u;if(ze.getOverlapRangeAtIndex(r.cs,r.ce,c,c+d)&&ze.getOverlapRangeAtIndex(r.rs,r.re,h,h+u)&&(r.cs!==t||r.ce!==e||r.rs!==s||r.re!==i)){r.cs=t,r.ce=e,r.rs=s,r.re=i,h=-1,n=[],o=[];break}}u>0&&o.push({index:c,cs:d+1,rs:u,row:-1}),a+=t.colSpan-1}n=n.concat(o).sort(((t,e)=>t.index-e.index)),o=[]}return r}#yd(t,e){let s=[],i=[];for(let n,o,r=0,l=t.length;r<l;r++){n=t[r].cells,o=0;for(let t,l,a,h,c=0,d=n.length;c<d;c++){if(t=n[c],a=t.colSpan-1,h=t.rowSpan-1,l=c+o,s.length>0)for(let t,e=0;e<s.length;e++)t=s[e],t.row>r||(l>=t.index?(o+=t.cs,l+=t.cs,t.rs-=1,t.row=r+1,t.rs<1&&(s.splice(e,1),e--)):c===d-1&&(t.rs-=1,t.row=r+1,t.rs<1&&(s.splice(e,1),e--)));ze.getOverlapRangeAtIndex(e.cs,e.ce,l,l+a)&&ze.getOverlapRangeAtIndex(e.rs,e.re,r,r+h)&&Re.utils.addClass(t,"se-selected-table-cell"),h>0&&i.push({index:l,cs:a+1,rs:h,row:-1}),o+=t.colSpan-1}s=s.concat(i).sort(((t,e)=>t.index-e.index)),i=[]}}initCellSelection(t){this.#Gc.setState("fixedCell",t),this.#I.selectedCells?.length||this.#Gc.setState("selectedCells",[t]),this.#gd=t.nodeName,this.#Gc.setState("selectedTable",Re.query.getParentElement(t,"TABLE")),this.deleteStyleSelectedCells(),Re.utils.addClass(t,"se-selected-cell-focus")}startCellSelection(t,e){this.#I.isShiftPressed||this.#I.ref||this.#si(),this.#Gc.setState("isShiftPressed",e),this.initCellSelection(t),e?(this.#fi.shiftOff=this.#J.eventManager.addGlobalEvent("keyup",this.#ud,!1),this.#fi.on=this.#J.eventManager.addGlobalEvent("mousedown",this.#cd,!1)):this.#fi.on=this.#J.eventManager.addGlobalEvent("mousemove",this.#cd,!1),this.#fi.off=this.#J.eventManager.addGlobalEvent("mouseup",this.#dd,!1),this.#fi.touchOff=this.#J.eventManager.addGlobalEvent("touchmove",this.#pd,!1)}deleteStyleSelectedCells(){Re.utils.removeClass([this.#I.fixedCell,this.#I.selectedCell],"se-selected-cell-focus");const t=this.#I.fixedCell?.closest("table");if(t){const e=t.querySelectorAll(".se-selected-table-cell");for(let t=0,s=e.length;t<s;t++)Re.utils.removeClass(e[t],"se-selected-table-cell")}}recallStyleSelectedCells(){if(this.#I.selectedCells){const t=this.#I.selectedCells;for(let e=0,s=t.length;e<s;e++)Re.utils.addClass(t[e],"se-selected-table-cell")}}focusCellEdge(t){Le.isMobile||this.#J.focusManager.focusEdge(t)}#md(t){this.#J.store.set("_preventBlur",!0);const e=Re.query.getParentElement(Re.query.getEventTarget(t),Re.check.isTableCell);if(this.#I.isShiftPressed){if(e===this.#I.fixedCell)return this.#Gc.setState("isShiftPressed",!1),this.deleteStyleSelectedCells(),this.#Gc._editorEnable(!0),void this.#si();this.#Gc._editorEnable(!1)}else if(!this.#I.ref){if(e===this.#I.fixedCell)return;this.#Gc._editorEnable(!1)}e&&e!==this.#I.selectedCell&&this.#gd===e.nodeName&&this.#I.selectedTable===Re.query.getParentElement(e,"TABLE")&&(this.#Gc.setState("selectedCell",e),this.setMultiCells(this.#I.fixedCell,this.#I.selectedCell))}#fd(t){t.stopPropagation(),this.#I.isShiftPressed?this.#fi.touchOff&&=this.#J.eventManager.removeGlobalEvent(this.#fi.touchOff):(this.#Gc._editorEnable(!0),this.#si());const e=this.#I.fixedCell;if(!e||!this.#I.selectedTable)return;if(this.#Xc.setMergeSplitButton(),this.#Gc.setState("selectedCells",Array.from(this.#I.selectedTable.querySelectorAll(".se-selected-table-cell"))),this.#I.isShiftPressed)return;e&&this.#I.selectedCell&&(this.focusCellEdge(e),e===this.#I.selectedCell&&Re.utils.removeClass(e,"se-selected-table-cell"));const s=this.#I.selectedCells?.length>0?this.#I.selectedCell:e;this.#Gc._setController(s)}#vd(){if(this.#I.ref){this.#si(),this.#Gc._editorEnable(!0),this.focusCellEdge(this.#I.fixedCell);const t=this.#I.selectedCells?.length>0?this.#I.selectedCell:this.#I.fixedCell;this.#Gc._setController(t)}else this.#Gc._closeController()}#bd(){this.#Gc.resetInfo()}#si(){this.#J.ui.disableBackWrapper();const t=this.#fi;for(const e in t)t[e]&&=this.#J.eventManager.removeGlobalEvent(t[e])}init(){this.#si()}},{_w:sh}=Le;const ih=class{#Gc;#I;#J;constructor(t,{pluginOptions:e,controller_table:s}){this.#Gc=t,this.#I=t.state,this.#J=t.$,this.sliderType="",this.resizeButton=s.querySelector("._se_table_resize"),this.resizeText=s.querySelector("._se_table_resize > span > span"),this.columnFixedButton=s.querySelector("._se_table_fixed_column"),this.headerButton=s.querySelector("._se_table_header"),this.captionButton=s.querySelector("._se_table_caption");const i=function({lang:t,icons:e,options:s}){const i=s.get("_rtl")?["right","center","left","justify"]:["left","center","right","justify"];let n="";for(let s,o,r=0;r<i.length;r++)s=i[r],o=t["align"+s.charAt(0).toUpperCase()+s.slice(1)],n+=`\n\t\t<button type="button" class="se-btn se-tooltip" data-command="props_align" data-value="${s}" title="${o}" aria-label="${o}">\n\t\t\t${e["align_"+s]}\n\t\t\t<span class="se-tooltip-inner">\n\t\t\t\t<span class="se-tooltip-text">${o}</span>\n\t\t\t</span>\n\t\t</button>`;const o=["top","middle","bottom"];let r="";for(let s,i,n=0;n<o.length;n++)s=o[n],i=t["align"+s.charAt(0).toUpperCase()+s.slice(1)],r+=`\n\t\t<button type="button" class="se-btn se-tooltip" data-command="props_align_vertical" data-value="${s}" title="${i}" aria-label="${i}">\n\t\t\t${e["align_"+s]}\n\t\t\t<span class="se-tooltip-inner">\n\t\t\t\t<span class="se-tooltip-text">${i}</span>\n\t\t\t</span>\n\t\t</button>`;const l=`\n\t\t<div class="se-controller-content">\n\t\t\t<div class="se-controller-header">\n\t\t\t\t<button type="button" data-command="close" class="se-btn se-close-btn close" title="${t.close}" aria-label="${t.close}">${e.cancel}</button>\n\t\t\t\t<span class="se-controller-title">${t.tableProperties}</span>\n\t\t\t</div>\n\t\t\t<div class="se-controller-body">\n\n\t\t\t\t<span>${t.border}</span>\n\t\t\t\t<div class="se-form-group se-form-w0">\n\t\t\t\t\t<button type="button" data-command="props_onborder_format" class="se-btn se-tooltip">\n\t\t\t\t\t\t${e[Ma.all]}\n\t\t\t\t\t\t<span class="se-tooltip-inner">\n\t\t\t\t\t\t\t<span class="se-tooltip-text">${t.border}</span>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</button>\n\t\t\t\t\t<button type="button" data-command="props_onborder_style" class="se-btn se-btn-select se-tooltip se-border-style">\n\t\t\t\t\t\t<span class="se-txt"></span>\n\t\t\t\t\t\t${e.arrow_down}\n\t\t\t\t\t\t<span class="se-tooltip-inner">\n\t\t\t\t\t\t\t<span class="se-tooltip-text">${t.border}</span>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</button>\n\t\t\t\t\t<input type="text" class="se-color-input __se_border_color" placeholder="${t.color}" />\n\t\t\t\t\t<button type="button" data-command="props_onpalette" data-value="border" class="se-btn se-tooltip">\n\t\t\t\t\t\t${e.color_palette}\n\t\t\t\t\t\t<span class="se-tooltip-inner">\n\t\t\t\t\t\t\t<span class="se-tooltip-text">${t.colorPicker}</span>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</button>\n\t\t\t\t\t<input type="text" class="se-input-control __se__border_size" placeholder="${t.width}" />\n\t\t\t\t</div>\n\n\t\t\t\t<span>${t.color}</span>\n\t\t\t\t<div class="se-form-group se-form-w0">\n\t\t\t\t\t<button type="button" data-command="props_onpalette" data-value="font" class="se-btn se-tooltip">\n\t\t\t\t\t\t${e.font_color}\n\t\t\t\t\t\t<span class="se-tooltip-inner">\n\t\t\t\t\t\t\t<span class="se-tooltip-text">${t.fontColor}</span>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</button>\n\t\t\t\t\t<input type="text" class="se-color-input __se_font_color" placeholder="${t.fontColor}" />\n\t\t\t\t\t<button type="button" data-command="props_onpalette" data-value="back" class="se-btn se-tooltip">\n\t\t\t\t\t\t${e.background_color}\n\t\t\t\t\t\t<span class="se-tooltip-inner">\n\t\t\t\t\t\t\t<span class="se-tooltip-text">${t.backgroundColor}</span>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</button>\n\t\t\t\t\t<input type="text" class="se-color-input __se_back_color" placeholder="${t.backgroundColor}" />\n\t\t\t\t</div>\n\n\t\t\t\t<span>${t.font}</span>\n\t\t\t\t<div class="se-form-group se-form-w0">\n\t\t\t\t\t<button type="button" data-command="props_font_style" data-value="bold" class="se-btn se-tooltip">\n\t\t\t\t\t\t${e.bold}\n\t\t\t\t\t\t<span class="se-tooltip-inner">\n\t\t\t\t\t\t\t<span class="se-tooltip-text">${t.bold}</span>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</button>\n\t\t\t\t\t<button type="button" data-command="props_font_style" data-value="underline" class="se-btn se-tooltip">\n\t\t\t\t\t\t${e.underline}\n\t\t\t\t\t\t<span class="se-tooltip-inner">\n\t\t\t\t\t\t\t<span class="se-tooltip-text">${t.underline}</span>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</button>\n\t\t\t\t\t<button type="button" data-command="props_font_style" data-value="italic" class="se-btn se-tooltip">\n\t\t\t\t\t\t${e.italic}\n\t\t\t\t\t\t<span class="se-tooltip-inner">\n\t\t\t\t\t\t\t<span class="se-tooltip-text">${t.italic}</span>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</button>\n\t\t\t\t\t<button type="button" data-command="props_font_style" data-value="strike" class="se-btn se-tooltip">\n\t\t\t\t\t\t${e.strike}\n\t\t\t\t\t\t<span class="se-tooltip-inner">\n\t\t\t\t\t\t\t<span class="se-tooltip-text">${t.strike}</span>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</button>\n\t\t\t\t</div>\n\n\t\t\t\t<div class="se-table-props-align">\n\t\t\t\t\t<span>${t.align} <span class="__se__a_table_t">( ${t.table} )</span></span>\n\t\t\t\t\t<div class="se-form-group se-form-w0 se-list-inner">\n\t\t\t\t\t\t<div class="__se__a_h">\n\t\t\t\t\t\t\t${n}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class="__se__a_v">\n\t\t\t\t\t\t\t${r}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t<div class="se-form-group se-form-w0 se-form-flex-btn">\n\t\t\t\t<button type="button" class="se-btn se-btn-success" data-command="props_submit" title="${t.submitButton}" aria-label="${t.submitButton}">${e.checked}</button>\n\t\t\t\t<button type="button" class="se-btn se-btn-danger" data-command="revert" title="${t.revert}" aria-label="${t.revert}">${e.revert}</button>\n\t\t\t</div>\n\t\t</div>`,a=Re.utils.createElement("DIV",{class:"se-controller se-table-props"},l);return{html:a,controller_props_title:a.querySelector(".se-controller-title"),borderButton:a.querySelector('[data-command="props_onborder_style"]'),borderFormatButton:a.querySelector('[data-command="props_onborder_format"]'),cell_alignment:a.querySelector(".se-table-props-align .__se__a_h"),cell_alignment_vertical:a.querySelector(".se-table-props-align .__se__a_v"),cell_alignment_table_text:a.querySelector(".se-table-props-align .__se__a_table_t"),border_style:a.querySelector('[data-command="props_onborder_style"] .se-txt'),border_color:a.querySelector(".__se_border_color"),border_width:a.querySelector(".__se__border_size"),back_color:a.querySelector(".__se_back_color"),font_color:a.querySelector(".__se_font_color"),palette_border_button:a.querySelector('[data-command="props_onpalette"][data-value="border"]'),font_bold:a.querySelector('[data-command="props_font_style"][data-value="bold"]'),font_underline:a.querySelector('[data-command="props_font_style"][data-value="underline"]'),font_italic:a.querySelector('[data-command="props_font_style"][data-value="italic"]'),font_strike:a.querySelector('[data-command="props_font_style"][data-value="strike"]')}}(this.#J),n=[this.#Gc.controller_table,this.#Gc.controller_cell];this.controller_props=new Mi(this,this.#J,i.html,{position:"bottom",parents:n,isInsideForm:!0}),this.controller_props_title=i.controller_props_title;const o=Re.utils.createElement("DIV",{class:"se-controller se-list-layer"},null);this.controller_colorPicker=new Mi(this,this.#J,o,{position:"bottom",parents:[this.controller_props].concat(n),isInsideForm:!0,isWWTarget:!1,initMethod:()=>{this.colorPicker.hueSlider.close(),Re.utils.removeClass(this.controller_colorPicker.currentTarget,"on")}}),this.colorPicker=new Sl(this,this.#J,"",{form:o,colorList:e.colorList||Oa,splitNum:5,disableRemove:!0,hueSliderOptions:{controllerOptions:{isOutsideForm:!0,parents:[this.controller_colorPicker],parentsHide:!0}}});const r=function(){let t="";for(let e,s=0,i=Ta.length;s<i;s++)e=Ta[s],t+=`\n\t\t<div title="${e}" aria-label="${e}" style="padding: 0 12px;">\n\t\t\t<span class="se-txt">${e}</span>\n\t\t</div>`;const e=Re.utils.createElement("DIV",null,t);return{items:Ta,menus:e.querySelectorAll("div")}}(),l=i.borderButton;this.selectMenu_props_border=new Bi(this.#J,{checkList:!1,position:"bottom-center"}),this.selectMenu_props_border.on(l,this.#Cd.bind(this)),this.selectMenu_props_border.create(r.items,r.menus);const a=Ya(this.#J.lang,this.#J.icons,[]),h=i.borderFormatButton;this.selectMenu_props_border_format=new Bi(this.#J,{checkList:!1,position:"bottom-left",dir:"ltr",splitNum:5}),this.selectMenu_props_border_format.on(h,this.#_d.bind(this,"all")),this.selectMenu_props_border_format.create(a.items,a.menus);const c=Ya(this.#J.lang,this.#J.icons,Na);this.selectMenu_props_border_format_oneCell=new Bi(this.#J,{checkList:!1,position:"bottom-left",dir:"ltr",splitNum:6}),this.selectMenu_props_border_format_oneCell.on(h,this.#_d.bind(this,"outside")),this.selectMenu_props_border_format_oneCell.create(c.items,c.menus),this.maxText=this.#J.lang.maxSize,this.minText=this.#J.lang.minSize,this.propTargets={cell_alignment:i.cell_alignment,cell_alignment_vertical:i.cell_alignment_vertical,cell_alignment_table_text:i.cell_alignment_table_text,border_format:h,border_style:i.border_style,border_color:i.border_color,border_width:i.border_width,back_color:i.back_color,font_color:i.font_color,palette_border_button:i.palette_border_button,font_bold:i.font_bold,font_underline:i.font_underline,font_italic:i.font_italic,font_strike:i.font_strike},this._propsCache=[],this._currentFontStyles=[],this._propsAlignCache="",this._propsVerticalAlignCache="",this._typeCache=""}get#Kc(){return this.#Gc.selectionService}colorPickerAction(t){this.applyColorPicker(t)}controllerAction(t){const e=t.getAttribute("data-command");if(!e)return;const s=t.getAttribute("data-value");switch(e){case"props_onborder_format":this.openBorderFormatMenu();break;case"props_onborder_style":this.openBorderStyleMenu();break;case"props_onpalette":this.openColorPalette(t,s);break;case"props_font_style":this.toggleFontStyle(s);break;case"props_submit":this.submitProps(t);break;case"props_align":this.setAlignProps(t.getAttribute("data-value"));break;case"props_align_vertical":this.setVerticalAlignProps(t.getAttribute("data-value"))}}openTableProps(t){this.controller_props.currentTarget===t&&"block"===this.controller_props.form?.style.display?this.controller_props.close():(this.controller_props_title.textContent=this.#J.lang.tableProperties,this.#kd("table"),this.controller_props.open(t,this.#Gc.controller_table.form,{isWWTarget:!1,initMethod:null,addOffset:null}))}openCellProps(t){this.controller_props.currentTarget===t&&"block"===this.controller_props.form?.style.display?this.controller_props.close():(this.controller_props_title.textContent=this.#J.lang.cellProperties,this.#kd("cell"),this.controller_props.open(t,this.#Gc.controller_cell.form,{isWWTarget:!1,initMethod:null,addOffset:null}))}openBorderFormatMenu(){1===this._propsCache.length?this.selectMenu_props_border_format_oneCell.open():this.selectMenu_props_border_format.open()}openBorderStyleMenu(){this.selectMenu_props_border.open()}openColorPalette(t,e){const{back_color:s,font_color:i,border_color:n}=this.propTargets,o="border"===e?n:"back"===e?s:i;this.controller_colorPicker.isOpen&&e===this.sliderType?this.controller_colorPicker.close():(this.sliderType=e,Re.utils.addClass(t,"on"),this.colorPicker.init(o?.value||"",t),this.controller_colorPicker.open(t,null,{isWWTarget:!1,initMethod:null,addOffset:null}))}toggleFontStyle(t){Re.utils.toggleClass(this.propTargets[`font_${t}`],"on")}toggleHeader(){const t=this.headerButton,e=Re.utils.hasClass(t,"active"),s=this.#Gc._element;if(Ka(s),e)Re.utils.removeItem(s.querySelector("thead"));else{const t=Re.utils.createElement("THEAD");t.innerHTML="<tr>"+Ua("th",this.#I.logical_cellCnt)+"</tr>",s.insertBefore(t,s.querySelector("tbody"))}Re.utils.toggleClass(t,"active"),/TH/i.test(this.#I.tdElement.nodeName)?this.#Gc._closeController():this.#Gc._setCellControllerPosition(this.#I.tdElement,!1)}toggleCaption(){const t=this.captionButton,e=Re.utils.hasClass(t,"active"),s=this.#Gc._element;if(e)Re.utils.removeItem(s.querySelector("caption"));else{const t=Re.utils.createElement("CAPTION",{class:`se-table-caption-${this.#Gc.captionPosition}`});t.innerHTML="<div><br></div>",s.insertBefore(t,s.firstElementChild)}Re.utils.toggleClass(t,"active"),this.#Gc._setCellControllerPosition(this.#I.tdElement,!1)}resetHeaderButton(t){t.querySelector("thead")?Re.utils.addClass(this.headerButton,"active"):Re.utils.removeClass(this.headerButton,"active")}resetCaptionButton(t){t.querySelector("caption")?Re.utils.addClass(this.captionButton,"active"):Re.utils.removeClass(this.captionButton,"active")}resetPropsAlign(){const{cell_alignment:t}=this.propTargets,e=t.querySelector('[data-value="left"]'),s=t.querySelector('[data-value="right"]'),i=e.parentElement,n=s.parentElement;i.appendChild(s),n.appendChild(e)}revertProps(){const t=this._propsCache;for(let e=0,s=t.length;e<s;e++)t[e][0].style.cssText=t[e][1];this.#xd(this.propTargets.cell_alignment,this._propsAlignCache,!0),this.#xd(this.propTargets.cell_alignment_vertical,this._propsVerticalAlignCache,!0),Re.check.isTable(t[0][0])&&this.#I.figureElement&&(this.#I.figureElement.style.float=this._propsAlignCache)}applyColorPicker(t){const e=this.propTargets[`${this.sliderType}_color`];e.style.borderColor=e.value=t,this.controller_colorPicker.close()}setAlignProps(t){this.#xd(this.propTargets.cell_alignment,t,!1)}setVerticalAlignProps(t){this.#xd(this.propTargets.cell_alignment_vertical,t,!1)}setTableLayout(t,e,s,i){if(t.includes("width")){const t=this.#I.figureElement;if(!t)return;let s,n;e?(s=this.#J.icons.reduction,n=this.minText,i||(t.style.width="100%")):(s=this.#J.icons.expansion,n=this.maxText,i||(t.style.width="max-content")),Re.utils.changeElement(this.resizeButton.firstElementChild,s),Re.utils.changeTxt(this.resizeText,n)}t.includes("column")&&(s?(Re.utils.removeClass(this.#Gc._element,"se-table-layout-auto"),Re.utils.addClass(this.#Gc._element,"se-table-layout-fixed"),Re.utils.addClass(this.columnFixedButton,"active")):(Re.utils.removeClass(this.#Gc._element,"se-table-layout-fixed"),Re.utils.addClass(this.#Gc._element,"se-table-layout-auto"),Re.utils.removeClass(this.columnFixedButton,"active")))}submitProps(t){try{t.disabled=!0;const e=this.#Gc.controller_table.form.contains(this.controller_props.currentTarget),s=e?[this.#Gc._element]:this.#I.selectedCells,i=s[0],n=sh.getComputedStyle(i),{border_format:o,border_color:r,border_style:l,border_width:a,back_color:h,font_color:c,cell_alignment:d,cell_alignment_vertical:u}=this.propTargets,p=o.getAttribute("se-border-format")||"",g="all"!==p,m=("none"===l.textContent?"":l.textContent)||"",f="none"===p||!m,v=d.getAttribute("se-cell-align")||"",b=u.getAttribute("se-cell-align")||"",y=f?"":r.value.trim()||n.borderColor;let w=f?"":a.value.trim()||n.borderWidth;w+=ze.is(w)?"px":"";const C=h.value.trim(),_=c.value.trim(),k=g&&!f&&w,x=`${w} ${m} ${y}`,$={left:[],top:[],right:[],bottom:[],middle:[],all:null};if(e){const t=i.style;this.#I.figureElement&&(this.#I.figureElement.style.float=v,this.#I.figureElement.style.verticalAlign=b),t.backgroundColor=C,t.color=_,this.#$d(t),k||(t.border=f?t.borderLeft=t.borderTop=t.borderRight=t.borderBottom="":x),$.left=$.top=$.right=$.bottom=s}else{const t=i.parentElement;let{rs:e,re:n,cs:o,ce:r}=this.#I.ref||{rs:t.rowIndex||0,re:t.rowIndex||0,cs:i.cellIndex||0,ce:i.cellIndex||0};const l=new Array(n-e+1).fill(0).map((()=>new Array(r-o+1).fill(0))),a=o;n-=e,e-=e,r-=o,o-=o;let h=t;for(let t,i,c,d,u,p=0,g=0,m=s.length,y=0;p<m;p++,g++){t=s[p],d=t.colSpan,u=t.rowSpan,c=t.cellIndex-a,h!==t.parentElement&&(y++,g=0,h=t.parentElement);let m=0;for(;m<=c;)c+=l[y][m]||0,m++;try{if(u>1){const t=u-1;for(let e=y;e<=y+t;e++)l[e][c]+=d-(y===e?1:0)}else d>1&&(l[y][c]+=d-1)}catch{}const w=y+u-1===n;y===e&&$.top.push(t),(y===n||w)&&$.bottom.push(t),c===o&&$.left.push(t),c!==r&&c+d-1!==r||$.right.push(t),w||y===e||y===n||c===o||c===r||$.middle.push(t),i=t.style,i.textAlign=v,i.verticalAlign=b,i.backgroundColor=C,i.color=_,this.#$d(i),k||(i.border=f?i.borderLeft=i.borderTop=i.borderRight=i.borderBottom="":x)}0===$.middle.length&&($.middle=s)}$.all=s,k&&this.#Sd($,p,x),this.#Gc.historyPush(),this.controller_props.close(),this.#I.tdElement&&(this.#Kc.recallStyleSelectedCells(),this.#Gc.setCellInfo(this.#I.tdElement,!0),Re.utils.addClass(this.#I.tdElement,"se-selected-cell-focus"))}catch(t){console.warn("[SUNEDITOR.plugins.table.setProps.error]",t)}finally{t.disabled=!1}}closeProps(){this.controller_props.close(),this.controller_colorPicker.close()}#kd(t){this._typeCache=t;const e="table"===t,s=e?[this.#Gc._element]:this.#I.selectedCells;if(!s?.[0])return;const{border_format:i,border_color:n,border_style:o,border_width:r,back_color:l,font_color:a,cell_alignment:h,cell_alignment_vertical:c,cell_alignment_table_text:d,font_bold:u,font_underline:p,font_italic:g,font_strike:m}=this.propTargets,{border:f,backgroundColor:v,color:b,textAlign:y,verticalAlign:w,fontWeight:C,textDecoration:_,fontStyle:k}=sh.getComputedStyle(s[0]),x=this.#Ed(f);h.querySelector('[data-value="justify"]').style.display=e?"none":"",d.style.display=e?"":"none",c.style.display=e?"none":"";let $=Oe.rgb2hex(x.c),S=x.s,E=x.w,T=Oe.rgb2hex(v),M=Oe.rgb2hex(b),N=/.+/.test(C),B=/underline/i.test(_),I=/line-through/i.test(_),L=/italic/i.test(k),A=e?this.#I.figureElement?.style.float:y,O=w;this._propsCache=[];for(let t,i,n=0;t=s[n];n++){const{cssText:s,border:n,backgroundColor:o,color:r,textAlign:l,verticalAlign:a,fontWeight:h,textDecoration:c,fontStyle:d}=t.style;if(this._propsCache.push([t,s]),i)continue;const{c:u,s:p,w:g}=this.#Ed(n);let m=o,f=r;if(m||f){const e=sh.getComputedStyle(t);m&&(m=e.backgroundColor),f&&(f=e.color)}$&&x.c!==u&&($=""),S&&x.s!==p&&(S=""),E&&x.w!==g&&(E=""),T!==Oe.rgb2hex(m)&&(T=""),M!==Oe.rgb2hex(f)&&(M=""),A!==(e?this.#I.figureElement?.style.float:l)&&(A=""),O&&O!==a&&(O=""),N&&N!==/.+/.test(h)&&(N=!1),B&&B!==/underline/i.test(c)&&(B=!1),I&&I!==/line-through/i.test(c)&&(I=!1),L&&L!==/italic/i.test(d)&&(L=!1),$&&S&&E&&T&&M||(i=!0)}i.firstElementChild.innerHTML=this.#J.icons[Ma[1===s.length?"outside":"all"]],i.setAttribute("se-border-format","all"),Re.utils.removeClass(i,"active"),S||=Ta[0],o.textContent=S,n.style.borderColor=n.value=$,r.value=E,this.#Td(S===Ta[0]),l.value=l.style.borderColor=T,a.value=a.style.borderColor=M,N&&Re.utils.addClass(u,"on"),B&&Re.utils.addClass(p,"on"),I&&Re.utils.addClass(m,"on"),L&&Re.utils.addClass(g,"on"),this.#xd(h,this._propsAlignCache=A,!0),this.#xd(c,this._propsVerticalAlignCache=O,!0)}#$d(t){const{font_bold:e,font_italic:s,font_strike:i,font_underline:n}=this.propTargets;t.fontWeight=Re.utils.hasClass(e,"on")?"bold":"",t.fontStyle=Re.utils.hasClass(s,"on")?"italic":"",t.textDecoration=((Re.utils.hasClass(i,"on")?"line-through ":"")+(Re.utils.hasClass(n,"on")?"underline":"")).trim()}#Ed(t){const e=t.split(/\s(?![^()]*\))/);let s="",i="",n="";return 3===e.length?(s=e[0],i=e[1],n=e[2]):2===e.length?/\d/.test(e[0])?(s=e[0],i=e[1]):(i=e[0],n=e[1]):1===e.length&&(/\d/.test(e[0])?s=e[0]:i=e[0]),{w:s,s:i,c:Oe.rgb2hex(n)}}#Sd(t,e,s){const{left:i,top:n,right:o,bottom:r,all:l}=t;switch(e){case"inside":if(1===l.length)return;Re.utils.setStyle(l.filter((t=>!r.includes(t))),Aa,s),Re.utils.setStyle(l.filter((t=>!o.includes(t))),La,s);break;case"horizon":if(1===l.length)return;Re.utils.setStyle(l.filter((t=>!r.includes(t))),Aa,s);break;case"vertical":if(1===l.length)return;Re.utils.setStyle(l.filter((t=>!o.includes(t))),La,s);break;case"outside":Re.utils.setStyle(i,Ba,s),Re.utils.setStyle(n,Ia,s),Re.utils.setStyle(o,La,s),Re.utils.setStyle(r,Aa,s);break;case"left":Re.utils.setStyle(i,Ba,s);break;case"top":Re.utils.setStyle(n,Ia,s);break;case"right":Re.utils.setStyle(o,La,s);break;case"bottom":Re.utils.setStyle(r,Aa,s)}}#Td(t){const{border_color:e,border_width:s,palette_border_button:i}=this.propTargets;t?(e.disabled=!0,s.disabled=!0,i.disabled=!0,s.disabled=!0):(e.disabled=!1,s.disabled=!1,i.disabled=!1,s.disabled=!1)}#xd(t,e,s){Re.utils.removeClass(t.querySelectorAll("button"),"on"),s||t.getAttribute("se-cell-align")!==e?(Re.utils.addClass(t.querySelector(`[data-value="${e}"]`),"on"),t.setAttribute("se-cell-align",e)):t.setAttribute("se-cell-align","")}#Cd(t){this.propTargets.border_style.textContent=t,this.#Td(t===Ta[0]),this.selectMenu_props_border.close()}#_d(t,e){const{border_format:s}=this.propTargets;s.setAttribute("se-border-format",e),s.firstElementChild.innerHTML=this.#J.icons[Ma[e]],e!==t?Re.utils.addClass(s,"active"):Re.utils.removeClass(s,"active"),this.selectMenu_props_border_format.close(),this.selectMenu_props_border_format_oneCell.close()}init(){const{border_format:t,border_color:e,border_style:s,border_width:i,back_color:n,font_color:o,cell_alignment:r,cell_alignment_vertical:l,font_bold:a,font_underline:h,font_italic:c,font_strike:d}=this.propTargets;Re.utils.removeClass([t,e,s,i,n,o,r,l,a,h,c,d],"on")}},{_w:nh,ON_OVER_COMPONENT:oh}=Le;class rh extends Fl{static key="table";static className="";static options={isInputComponent:!0};static component(t){return Re.check.isTable(t)?t:null}#Md;#Nd;#Bd;#Id;#Ld;#Ad=[];#Od=!0;#Rd=!1;#zd=!1;constructor(t,e){super(t),this.title=this.$.lang.table,this.icon="table",this.figureScrollList=["se-scroll-figure-xy","se-scroll-figure-x","se-scroll-figure-y"],this.figureScroll="string"==typeof e.scrollType?e.scrollType.toLowerCase():"x",this.captionPosition="bottom"!==e.captionPosition?"top":"bottom",this.cellControllerTop="table"==("cell"!==e.cellControllerPosition?"table":"cell");const s=Re.utils.createElement("DIV",{class:"se-dropdown se-selector-table"},'\n\t<div class="se-table-size">\n\t\t<div class="se-table-size-picker se-controller-table-picker"></div>\n\t\t<div class="se-table-size-highlighted"></div>\n\t\t<div class="se-table-size-unhighlighted"></div>\n\t</div>\n\t<div class="se-table-size-display">1 x 1</div>'),i=s.querySelector(".se-controller-table-picker"),n=function({lang:t,icons:e}){const s=`\n\t<div class="se-arrow se-arrow-down se-visible-hidden"></div>\n\t<div class="se-btn-group">\n\t\t<button type="button" data-command="openTableProperties" class="se-btn se-tooltip">\n\t\t\t${e.table_properties}\n\t\t\t<span class="se-tooltip-inner">\n\t\t\t\t<span class="se-tooltip-text">${t.tableProperties}</span>\n\t\t\t</span>\n\t\t</button>\n\t\t<button type="button" data-command="layout" class="se-btn se-tooltip _se_table_fixed_column">\n\t\t\t${e.fixed_column_width}\n\t\t\t<span class="se-tooltip-inner">\n\t\t\t\t<span class="se-tooltip-text">${t.fixedColumnWidth}</span>\n\t\t\t</span>\n\t\t</button>\n\t\t<button type="button" data-command="header" class="se-btn se-tooltip _se_table_header">\n\t\t\t${e.table_header}\n\t\t\t<span class="se-tooltip-inner">\n\t\t\t\t<span class="se-tooltip-text">${t.tableHeader}</span>\n\t\t\t</span>\n\t\t</button>\n\t\t<button type="button" data-command="caption" class="se-btn se-tooltip _se_table_caption">\n\t\t\t${e.caption}\n\t\t\t<span class="se-tooltip-inner">\n\t\t\t\t<span class="se-tooltip-text">${t.caption}</span>\n\t\t\t</span>\n\t\t</button>\n\t\t<button type="button" data-command="resize" class="se-btn se-tooltip _se_table_resize">\n\t\t\t${e.reduction}\n\t\t\t<span class="se-tooltip-inner">\n\t\t\t\t<span class="se-tooltip-text">${t.minSize}</span>\n\t\t\t</span>\n\t\t</button>\n\t\t<button type="button" data-command="copy" class="se-btn se-tooltip">\n\t\t\t${e.copy}\n\t\t\t<span class="se-tooltip-inner">\n\t\t\t\t<span class="se-tooltip-text">${t.copy}</span>\n\t\t\t</span>\n\t\t</button>\n\t\t<button type="button" data-command="remove" class="se-btn se-tooltip">\n\t\t\t${e.delete}\n\t\t\t<span class="se-tooltip-inner">\n\t\t\t\t<span class="se-tooltip-text">${t.remove}</span>\n\t\t\t</span>\n\t\t</button>\n\t</div>`;return Re.utils.createElement("DIV",{class:"se-controller se-controller-table"},s)}(this.$),o=function({lang:t,icons:e},s){const i=`\n\t<div class="se-arrow se-arrow-${s?"down se-visible-hidden":"up"}"></div>\n <div class="se-btn-group">\n\t\t<button type="button" data-command="openCellProperties" class="se-btn se-tooltip">\n\t\t\t${e.cell_properties}\n\t\t\t<span class="se-tooltip-inner">\n\t\t\t\t<span class="se-tooltip-text">${t.cellProperties}</span>\n\t\t\t</span>\n\t\t</button>\n <button type="button" data-command="oncolumn" class="se-btn se-tooltip">\n ${e.table_column}\n <span class="se-tooltip-inner">\n <span class="se-tooltip-text">${t.column}</span>\n </span>\n </button>\n <button type="button" data-command="onrow" class="se-btn se-tooltip">\n ${e.table_row}\n <span class="se-tooltip-inner">\n <span class="se-tooltip-text">${t.row}</span>\n </span>\n </button>\n <button type="button" data-command="merge" class="se-btn se-tooltip" style="display: none;">\n ${e.merge_cell}\n <span class="se-tooltip-inner">\n <span class="se-tooltip-text">${t.mergeCells}</span>\n </span>\n </button>\n <button type="button" data-command="onsplit" class="se-btn se-tooltip">\n ${e.split_cell}\n <span class="se-tooltip-inner">\n <span class="se-tooltip-text">${t.splitCells}</span>\n </span>\n </button>\n\t\t<button type="button" data-command="unmerge" class="se-btn se-tooltip">\n ${e.unmerge_cell}\n <span class="se-tooltip-inner">\n <span class="se-tooltip-text">${t.unmergeCells}</span>\n </span>\n </button>\n </div>`,n=Re.utils.createElement("DIV",{class:"se-controller se-controller-table-cell"},i);return{html:n,splitButton:n.querySelector('[data-command="onsplit"]'),columnButton:n.querySelector('[data-command="oncolumn"]'),rowButton:n.querySelector('[data-command="onrow"]'),mergeButton:n.querySelector('[data-command="merge"]'),unmergeButton:n.querySelector('[data-command="unmerge"]')}}(this.$,this.cellControllerTop);this.$.contextProvider.applyToRoots((t=>{t.get("wrapper").appendChild(Re.utils.createElement("DIV",{class:xa.replace(/^\./,"")})),t.get("wrapper").appendChild(Re.utils.createElement("DIV",{class:$a.replace(/^\./,"")})),t.get("wrapper").appendChild(Re.utils.createElement("DIV",{class:Sa.replace(/^\./,"")})),t.get("wrapper").appendChild(Re.utils.createElement("DIV",{class:Ea.replace(/^\./,"")}))})),this.cellControllerTop?(this.controller_cell=new Mi(this,this.$,o.html,{position:"top"}),this.controller_table=new Mi(this,this.$,n,{position:"top"}),this.controller_cell.sibling=this.controller_table.form,this.controller_table.sibling=this.controller_cell.form,this.controller_table.siblingMain=!0):(this.controller_table=new Mi(this,this.$,n,{position:"top"}),this.controller_cell=new Mi(this,this.$,o.html,{position:"bottom"})),this.figure=new Wi(this,this.$,null,{}),this._element=null,this.state=Ra,this.#Md=s,this.#Nd=s.querySelector(".se-table-size-highlighted"),this.#Bd=s.querySelector(".se-table-size-unhighlighted"),this.#Id=s.querySelector(".se-table-size-display");const r=lh.bind(this,!0),l=lh.bind(this,!1),a={...o,openCellMenuFunc:r,closeCellMenuFunc:l};this.cellService=new Xa(this,a),this.clipboardService=new Za(this),this.gridService=new Ja(this,a),this.resizeService=new th(this),this.selectionService=new eh(this),this.styleService=new ih(this,{pluginOptions:e,controller_table:n}),this.$.menu.initDropdownTarget(rh,s),this.$.eventManager.addEvent(i,"mousemove",this.#Pd.bind(this)),this.$.eventManager.addEvent(i,"click",this.#Dd.bind(this))}setState(t,e){this.state[t]=e}#Fd(){Object.assign(this.state,Ra)}off(){this.#Hd()}componentSelect(t){if(this.#qd(t),this.state.figureElement||this.setTableInfo(t),this.#Od="100%"===this.state.figureElement?.style.width,this.#Rd=Re.utils.hasClass(t,"se-table-layout-fixed")||"fixed"===t.style.tableLayout,this.styleService.setTableLayout(this.#Od?"width|column":"width",this.#Od,this.#Rd,!0),yi.get("__overInfo")===oh)return;if(!this.state.tdElement)return;this.setCellInfo(this.state.tdElement,!0);const e=this.state.selectedCells?.length>1,s=Re.query.getParentElement(t,Re.check.isFigure);this.controller_table.open(s,null,{isWWTarget:!1,initMethod:null,addOffset:null,disabled:e}),this.state.fixedCell&&(this.cellService.setUnMergeButton(),this.controller_cell.open(this.state.tdElement,this.cellControllerTop?s:null,{isWWTarget:!1,initMethod:null,addOffset:null,disabled:e}))}componentDeselect(){this.resetInfo()}componentDestroy(t){if(!t)return;const e=t.parentNode;Re.utils.removeItem(t),this._closeTableSelectInfo(),e!==this.$.frameContext.get("wysiwyg")&&this.$.nodeTransform.removeAllParents(e,(function(t){return 0===t.childNodes.length}),null),this.$.focusManager.focus(),this.$.history.push(!1)}componentCopy({event:t,cloneContainer:e}){const s=e.querySelectorAll(".se-selected-table-cell");Re.utils.removeClass(s,"se-selected-table-cell|se-selected-cell-focus"),s.length>0&&(this.clipboardService.copySelectedTableCells(t,e,s),this.$.ui.showToast(this.$.lang.message_copy_success,550))}onPaste({event:t,doc:e}){const s=Re.query.getParentElement(Re.query.getEventTarget(t),Re.check.isTableCell);if(!s)return;const i=e.body;if(1!==i.childElementCount)return;const n=this.$.component.get(i.firstElementChild);if(n?.pluginName!==rh.key)return;const o=n.target,r=this.clipboardService.pasteTableCellMatrix(o,s),{fixedCell:l,selectedCell:a}=this.selectionService.selectCells(r);return this.setState("selectedCells",r),this.setState("fixedCell",l),this.setState("selectedCell",a),this.setState("selectedTable",Re.query.getParentElement(l,"TABLE")),!1}retainFormat(){return{query:"table",method:t=>{const e=t.querySelector("colgroup");let s=Re.check.isFigure(t.parentNode)?t.parentNode:null;if(!e){const e=t.rows,s=function(t){const e=t.rows;let s=0;for(let t=0,i=e.length;t<i;t++){const i=e[t].cells;let n=0;for(let t=0,e=i.length;t<e;t++)n+=i[t].colSpan;s=Math.max(s,n)}return s}(t),i=new Array(s).fill(null);for(let t,n=0,o=e.length;n<o;n++){const o=e[n].cells;t=o.length;let r=0;const l=new Array(s).fill(!1);for(let e=0;e<t;e++){const t=o[e],n=t.style.width,a=t.colSpan||1;for(;r<s&&l[r];)r++;if(r>=s)break;n&&!i[r]&&(i[r]=n);for(let t=0;t<a;t++){if(r+t>=s||!n)continue;l[r+t]=!0;const e=ze.get(n,-1);for(let t=0;t<a;t++){const o=r+t;if(o>=s)continue;const l=i[o];if(null===l)i[o]=`width: ${n};`;else{const t=ze.get(l.replace("width: ","").replace(";",""),-1);1===a&&e!==t&&(i[o]=`width: ${n};`)}}}r+=a}if(t===s)break}const n=[];for(let t=0;t<s;t++){const e=i[t]?` style="${i[t]}"`:"";n.push(`<col${e}>`)}const o=Re.utils.createElement("colgroup",null,n.join(""));t.insertBefore(o,t.firstElementChild);for(let t=0;t<e.length;t++){const s=e[t].cells;for(let t=0;t<s.length;t++)Re.utils.setStyle(s[t],"width","")}}s?Re.utils.addClass(s,"se-flex-component|se-input-component"):(s=Re.utils.createElement("FIGURE",{class:"se-flex-component se-input-component"}),t.parentNode.insertBefore(s,t),s.appendChild(t));const i=t.style.width;if(i&&(s.style.width="auto"===i?"max-content":i,Re.utils.setStyle(t,"width","")),this.figureScroll){const t=`se-scroll-figure-${this.figureScroll}`;Re.utils.addClass(s,t),Re.utils.removeClass(s,this.figureScrollList.filter((e=>e!==t)).join("|"))}else Re.utils.removeClass(s,this.figureScrollList.join("|"))}}}setDir(){this.#Hd(),this.styleService.resetPropsAlign()}onMouseMove({event:t}){if(this.resizeService.isResizing())return;const e=Re.query.getEventTarget(t),s=Re.query.getParentElement(e,Fa);s&&1!==t.buttons?!1!==this.resizeService.onResizeGuide(t,s)&&(this._element&&(this._element.style.cursor=""),this.resizeService.offResizeGuide()):this.resizeService.offResizeGuide()}onMouseDown({event:t}){this.setState("ref",null),this.setState("selectedCell",null);const e=Re.query.getEventTarget(t);if(this._element&&Re.query.getParentElement(e,Ha))return void this._closeController();const s=Re.query.getParentElement(e,Fa);s&&(this.cellControllerTop||this.controller_cell.hide(),!1!==this.resizeService.readyResizeFromEdge(t,s)&&(this.state.isShiftPressed&&s!==this.state.fixedCell||(this.selectionService.deleteStyleSelectedCells(),/^TR$/i.test(s.nodeName)||(this.#zd=!1,this.selectionService.startCellSelection(s,!1)))))}onMouseUp(){this.setState("isShiftPressed",!1)}onMouseLeave(){this.resizeService.offResizeGuide()}onKeyDown({event:t,range:e,line:s}){this.setState("ref",null);const i=t.code,n=Pe.isTab(i);if(this.$.ui.selectMenuOn||this.resizeService.isResizing()||!n&&this.#zd||Pe.isCtrl(t))return;if(this.cellControllerTop||this.controller_cell.hide(),this.#zd=Pe.isShift(t),n){this.selectionService.deleteStyleSelectedCells();const i=Re.query.getParentElement(s,Re.check.isTableCell);if(i&&e.collapsed&&Re.check.isEdgePoint(e.startContainer,e.startOffset)){this._closeController();const e=this.#zd;this.setState("isShiftPressed",this.#zd=!1);const s=Re.query.getParentElement(i,"table"),n=Re.query.getListChildren(s,Re.check.isTableCell,null),o=e?Re.utils.prevIndex(n,i):Re.utils.nextIndex(n,i);if(o===n.length&&!e){if(!Re.query.getParentElement(i,"thead")){const t=s.rows,e=this.gridService.insertBodyRow(s,t.length,this.state.cellCnt).querySelector("td div");this.$.selection.setRange(e,0,e,0)}return t.preventDefault(),t.stopPropagation(),!1}if(-1===o&&e)return!1;const r=n[o];if(!r)return;const l=r.firstElementChild||r;return this.$.selection.setRange(l,0,l,0),t.preventDefault(),t.stopPropagation(),!1}}let o=null;if(!Pe.isShift(t)){if(o=Re.query.getParentElement(s,Re.check.isTableCell),!Re.utils.hasClass(o,"se-selected-cell-focus"))return;return this.selectionService.deleteStyleSelectedCells(),this._editorEnable(!0),this.#Wd(),void this._closeController()}return this.state.isShiftPressed||this.state.ref?void 0:(o||=Re.query.getParentElement(s,Re.check.isTableCell),o?(this.#zd=t.shiftKey,this.setState("fixedCell",o),this._closeController(),this.selectionService.startCellSelection(o,this.#zd),!1):void 0)}onKeyUp({line:t}){this.#zd=!1,this.state.isShiftPressed&&Re.query.getParentElement(t,Re.check.isTableCell)===this.state.fixedCell&&(this.selectionService.deleteStyleSelectedCells(),this._editorEnable(!0),this.#Wd()),this.setState("isShiftPressed",!1)}onScroll(){this.resizeService.offResizeGuide()}controllerAction(t){const e=t.getAttribute("data-command");if(e){switch(e){case"header":this.styleService.toggleHeader(),this.historyPush();break;case"caption":this.styleService.toggleCaption(),this.historyPush();break;case"onsplit":this.cellService.openSplitMenu();break;case"oncolumn":this.gridService.openColumnMenu();break;case"onrow":this.gridService.openRowMenu();break;case"openTableProperties":this.styleService.openTableProps(t);break;case"openCellProperties":this.styleService.openCellProps(t);break;case"revert":this.styleService.revertProps();break;case"merge":this.cellService.mergeCells(this.state.selectedCells);break;case"unmerge":this.cellService.unmergeCells(this.state.selectedCells);break;case"resize":this.#Od=!this.#Od,this.styleService.setTableLayout("width",this.#Od,this.#Rd,!1),this.historyPush(),nh.setTimeout((()=>{this.$.component.select(this._element,rh.key,{isInput:!0})}),0);break;case"layout":this.#Rd=!this.#Rd,this.styleService.setTableLayout("column",this.#Od,this.#Rd,!1),this.historyPush(),nh.setTimeout((()=>{this.$.component.select(this._element,rh.key,{isInput:!0})}),0);break;case"copy":this.$.component.copy(this.state.figureElement);break;case"remove":this.componentDestroy(this.state.figureElement)}/(^revert|Properties$)/.test(e)||this.styleService.closeProps(),/^(remove|on|open)/.test(e)||this._setCellControllerPosition(this.state.tdElement,this.state.isShiftPressed)}}setCellInfo(t,e){const s=this.setTableInfo(t);if(s&&(this.setState("fixedCell",t),this.setState("trElement",t.parentNode),this.styleService.resetHeaderButton(s),this.styleService.resetCaptionButton(s),e||0===this.state.physical_cellCnt)){this.state.tdElement!==t&&this.setState("tdElement",t),this.state.selectedCells?.length||this.setState("selectedCells",[t]);const e=s.rows;this.setState("trElements",e);const i=t.cellIndex;let n=0;for(let t=0,s=e[0].cells,i=e[0].cells.length;t<i;t++)n+=s[t].colSpan;const o=this.state.trElement.rowIndex;this.setState("rowIndex",o),this.setState("rowCnt",e.length),this.setState("physical_cellCnt",this.state.trElement.cells.length),this.setState("logical_cellCnt",n),this.setState("cellCnt",n),this.setState("physical_cellIndex",i),this.setState("current_colSpan",this.state.tdElement.colSpan-1),this.setState("current_rowSpan",this.state.trElement.cells[i].rowSpan-1);const r=ja(s,o,i);this.setState("logical_cellIndex",r)}}setRowInfo(t){const e=this.setTableInfo(t).rows;this.setState("trElements",e),this.setState("rowCnt",e.length),this.setState("rowIndex",t.rowIndex)}setTableInfo(t){const e=this._element=Re.query.getParentElement(t,"TABLE");return this.setState("selectedTable",e),this.setState("figureElement",Re.query.getParentElement(e,Re.check.isFigure)||e),e}resetInfo(){this.#Wd(),this.selectionService.deleteStyleSelectedCells(),this._editorEnable(!0),this._element=null,this.#Fd(),this.#Ad=[],this.#Od=!1,this.#Rd=!1}historyPush(){this.selectionService.deleteStyleSelectedCells(),this.$.history.push(!1),this.selectionService.recallStyleSelectedCells()}_setController(t){if(!this.$.selection.get().isCollapsed&&!this.state.selectedCell)return void this.selectionService.deleteStyleSelectedCells();this.cellService.setUnMergeButton(),this.setState("tdElement",t),this.state.fixedCell===t&&Re.utils.addClass(t,"se-selected-cell-focus"),this.state.selectedCells?.length||this.setState("selectedCells",[t]);const e=this.state.selectedTable||this._element||Re.query.getParentElement(t,"TABLE");this.$.component.select(e,rh.key,{isInput:!0})}_setCellControllerPosition(t,e){this.setCellInfo(t,e),this.cellControllerTop||this.controller_cell.resetPosition(t)}_editorEnable(t){const e=this.$.frameContext.get("wysiwyg");e.setAttribute("contenteditable",t.toString()),t?Re.utils.removeClass(e,"se-disabled"):Re.utils.addClass(e,"se-disabled")}_closeController(){this.controller_table.close(!0),this.controller_cell.close(!0)}_closeTableSelectInfo(){this.$.component.deselect(),this._closeController()}#qd(t){this.figure.open(t,{nonResizing:!0,nonSizeInfo:!0,nonBorder:!0,figureTarget:!0,infoOnly:!1})}#Hd(){if(!this.#Nd)return;const t=this.#Nd.style,e=this.#Bd.style;t.width="1em",t.height="1em",e.width="5em",e.height="5em",Re.utils.changeTxt(this.#Id,"1 x 1")}#Pd(t){t.stopPropagation();let e=Math.ceil(t.offsetX/18),s=Math.ceil(t.offsetY/18);e=e<1?1:e,s=s<1?1:s;const i=this.$.options.get("_rtl");i&&(e=11-e),this.#Nd.style.width=e+"em",this.#Nd.style.height=s+"em";const n=e<5?5:e>8?10:e+2,o=s<5?5:s>8?10:s+2;if(this.#Bd.style.width=n+"em",this.#Bd.style.height=o+"em",i){const t=n-(this.#Ld||5);if(0!==t){const e=ze.get(this.#Md.style.left);this.#Md.style.left=e-18*t+"px",this.#Ld=n}}Re.utils.changeTxt(this.#Id,e+" x "+s),this.#Ad=[e,s]}#Dd(){const t=Re.utils.createElement("TABLE"),e=this.#Ad[0],s=this.#Ad[1],i=`<tbody>${`<tr>${Ua("td",e)}</tr>`.repeat(s)}</tbody>`,n=`<colgroup>${`<col style="width: ${ze.get(100/e,0)}%;">`.repeat(e)}</colgroup>`;t.innerHTML=n+i;let o="";this.figureScroll&&(o=` se-scroll-figure-${this.figureScroll}`);const r=Re.utils.createElement("FIGURE",{class:"se-flex-component se-input-component"+o,style:"width: 100%;"});if(r.appendChild(t),this.#Od=!0,this.$.component.insert(r,{insertBehavior:"none"})){this.#Hd(),this.$.menu.dropdownOff();const e=t.querySelector("td div");this.$.selection.setRange(e,0,e,0)}}#Wd(){this.resizeService.init(),this.selectionService.init(),this.styleService.init()}}function lh(t){this.controller_cell.bringToTop(t)}const ah=rh;class hh extends Dl{static key="blockStyle";static className="se-btn-select se-btn-tool-format";constructor(t,e){super(t),this.title=this.$.lang.formats,this.inner='<span class="se-txt">'+this.$.lang.formats+"</span>"+this.$.icons.arrow_down;const s=this.$.menu.initDropdownTarget(hh,function({lang:t},e){const s=["p","blockquote","h1","h2","h3","h4","h5","h6"],i=e&&0!==e.length?e:s,n=[];for(let e,o,r,l,a,h,c,d=0,u=i.length;d<u;d++){if(e=i[d],"string"==typeof e){if(!s.includes(e))continue;o=e.toLowerCase(),r="blockquote"===o?"block":"pre"===o?"br-line":"line",a=/^h/.test(o)?o.match(/\d+/)[0]:"",l=t["tag_"+(a?"h":o)]+a,c="",h=""}else o=e.tag.toLowerCase(),r=e.command,l=e.name||o,c=e.class,h=c?' class="'+c+'"':"";n.push({command:r,value:o,title:l,innerHTML:`<${o}${h}>${l}</${o}>`,attrs:{"data-class":c||""}})}return n}(this.$,e.items),{className:"se-list-format"});this.formatList=s.querySelectorAll("li button"),this.currentFormat=""}active(t,e){let s=this.$.lang.formats;const i=e.querySelector(".se-txt");if(t){if(this.$.format.isLine(t)){const e=this.formatList,n=t.nodeName.toLowerCase(),o=(t.className.match(/(\s|^)__se__format__[^\s]+/)||[""])[0].trim();for(let t,i=0,r=e.length;i<r;i++)if(t=e[i],n===t.getAttribute("data-value")&&o===t.getAttribute("data-class")){s=t.title;break}return Re.utils.changeTxt(i,s),i.setAttribute("data-value",n),i.setAttribute("data-class",o),!0}}else Re.utils.changeTxt(i,s);return!1}on(t){const e=this.formatList,s=t.querySelector(".se-txt"),i=(s.getAttribute("data-value")||"")+(s.getAttribute("data-class")||"");if(i!==this.currentFormat){for(let t,s=0,n=e.length;s<n;s++)t=e[s],i===t.getAttribute("data-value")+t.getAttribute("data-class")?Re.utils.addClass(t,"active"):Re.utils.removeClass(t,"active");this.currentFormat=i}}action(t){const e=t.getAttribute("data-command"),s=t.firstElementChild;"block"===e?this.$.format.applyBlock(s):"br-line"===e?this.$.format.setBrLine(s):this.$.format.setLine(s),this.$.menu.dropdownOff()}applyHeaderByShortcut({keyCode:t}){const e=t.match(/\d+$/)?.[0],s=Re.utils.createElement(`H${e}`);this.$.format.setLine(s)}}const ch=hh;class dh extends Dl{static key="layout";static className="";constructor(t,e){super(t),this.title=this.$.lang.layout,this.icon="layout",this.selectedIndex=-1,this.items=e.items,this.$.menu.initDropdownTarget(dh,function(t){t&&0!==t.length||console.warn('[SUNEDITOR.plugins.layout.warn] To use the "layout" plugin, please define the "layouts" option.');return(t||[]).map(((t,e)=>({command:"layout",value:String(e),title:t.name,innerHTML:t.name})))}(this.items))}action(t){const e=Number(t.getAttribute("data-value")),s=this.items[this.selectedIndex=e];if(!s.html)throw this.$.menu.dropdownOff(),Error('[SUNEDITOR.layout.fail] cause : "layouts[i].html not found"');this.$.html.set(s.html),this.$.menu.dropdownOff()}}const uh=dh;class ph extends Dl{static key="lineHeight";static className="";#Vc;constructor(t,e){super(t),this.title=this.$.lang.lineHeight,this.icon="line_height";const s=`<li><button type="button" class="se-btn se-btn-list default_value" data-command="" title="${this.$.lang.default}" aria-label="${this.$.lang.default}">${this.$.lang.default}</button></li><li class="se-btn-list se-sub-list"><span></span></li>`,i=this.$.menu.initDropdownTarget(ph,(e.items||[{text:"1",value:"1em"},{text:"1.2",value:"1.2em"},{text:"1.7",value:"1.7em"},{text:"2",value:"2em"}]).map((t=>({command:t.value,title:t.text,innerHTML:t.text}))),{prependHTML:s});this.sizeList=i.querySelectorAll("li button"),this.currentSize=null,this.#Vc=i.querySelector(".se-sub-list span")}active(t,e){return this.$.format.isLine(t)&&t.style.lineHeight.length>0?(Re.utils.addClass(e,"active"),!0):(Re.utils.removeClass(e,"active"),!1)}on(){const t=this.$.format.getLine(this.$.selection.getNode()),e=t?t.style.lineHeight+"":"";if(e!==this.currentSize){let t=!1;const s=this.sizeList;for(let i=0,n=s.length;i<n;i++)e===s[i].getAttribute("data-command")?(Re.utils.addClass(s[i],"active"),t=!0):Re.utils.removeClass(s[i],"active");this.currentSize=e,t?this.#Vc.style.display="none":(this.#Vc.textContent=e,this.#Vc.style.display="block")}}action(t){const e=t.getAttribute("data-command")||"",s=this.$.format.getLines();for(let t=0,i=s.length;t<i;t++)s[t].style.lineHeight=e;this.$.menu.dropdownOff(),this.$.store.set("_lastSelectionNode",null),this.$.history.push(!1)}}const gh=ph;class mh extends Dl{static key="template";static className="";constructor(t,e){super(t),this.title=this.$.lang.template,this.icon="template",this.selectedIndex=-1,this.items=e.items,this.$.menu.initDropdownTarget(mh,function(t){t&&0!==t.length||console.warn('[SUNEDITOR.plugins.template.warn] To use the "template" plugin, please define the "templates" option.');return(t||[]).map(((t,e)=>({command:"template",value:String(e),title:t.name,innerHTML:t.name})))}(this.items))}action(t){const e=Number(t.getAttribute("data-value")),s=this.items[this.selectedIndex=e];if(!s.html)throw this.$.menu.dropdownOff(),Error('[SUNEDITOR.template.fail] cause : "templates[i].html not found"');this.$.html.insert(s.html,{selectInserted:!1,skipCharCount:!1,skipCleaning:!1}),this.$.menu.dropdownOff()}}const fh=mh;class vh extends Dl{static key="paragraphStyle";static className="";constructor(t,e){super(t),this.title=this.$.lang.paragraphStyle,this.icon="paragraph_style";const s=this.$.menu.initDropdownTarget(vh,function({lang:t},e){const s={spaced:{name:t.menu_spaced,class:"__se__p-spaced",_class:""},bordered:{name:t.menu_bordered,class:"__se__p-bordered",_class:""},neon:{name:t.menu_neon,class:"__se__p-neon",_class:""}},i=e&&0!==e.length?e:["spaced","bordered","neon"],n=[];for(let t,e,o,r=0,l=i.length;r<l;r++){if(t=i[r],"string"==typeof t){const e=s[t.toLowerCase()];if(!e)continue;t=e}e=t.name,o=t.class?` class="${t.class}"`:"",n.push({command:t.class,title:e,innerHTML:`<div${o}>${e}</div>`,className:t._class||void 0})}return n}(this.$,e.items),{className:"se-list-format"});this.classList=s.querySelectorAll("li button")}on(){const t=this.classList,e=this.$.format.getLine(this.$.selection.getNode());for(let s=0,i=t.length;s<i;s++)Re.utils.hasClass(e,t[s].getAttribute("data-command"))?Re.utils.addClass(t[s],"active"):Re.utils.removeClass(t[s],"active")}action(t){const e=t.getAttribute("data-command");let s=this.$.format.getLines();if(0!==s.length||(this.$.selection.getRangeAndAddLine(this.$.selection.getRange(),null),s=this.$.format.getLines(),0!==s.length)){for(let t=0,i=s.length;t<i;t++)Re.utils.toggleClass(s[t],e);this.$.menu.dropdownOff(),this.$.history.push(!1)}}}const bh=vh;class yh extends Dl{static key="textStyle";static className="";constructor(t,e){super(t),this.title=this.$.lang.textStyle,this.icon="text_style";const s=this.$.menu.initDropdownTarget(yh,function({lang:t},e){const s={code:{name:t.menu_code,class:"__se__t-code",tag:"code"},shadow:{name:t.menu_shadow,class:"__se__t-shadow",tag:"span"}},i=e||Object.keys(s),n=[];for(let t,e,o,r,l=0,a=i.length;l<a;l++){if(t=i[l],"string"==typeof t){const e=s[t.toLowerCase()];if(!e)continue;t=e}o=t.name,e=t.tag||"span",r=`.${t.class.trim().replace(/\s+/g,",.")}`.replace(/,$/,""),n.push({command:e,value:r,title:o,innerHTML:`<${e} class="${t.class}">${o}</${e}>`})}return n}(this.$,e.items),{className:"se-list-format"});this.styleList=s.querySelectorAll("li button")}on(){const t=this.styleList,e=this.$.selection.getNode();for(let s,i,n,o=0,r=t.length;o<r;o++){s=t[o],i=s.getAttribute("data-value").split(",");for(let t,o,r=0;r<i.length;r++){for(t=e,n=!1;t&&!this.$.format.isLine(t)&&!this.$.component.is(t);){if(t.nodeName.toLowerCase()===s.getAttribute("data-command").toLowerCase()&&(o=i[r],/^\./.test(o)?Re.utils.hasClass(t,o.replace(/^\./,"")):t.style[o])){n=!0;break}t=t.parentNode}if(!n)break}n?Re.utils.addClass(s,"active"):Re.utils.removeClass(s,"active")}}action(t){const e=t.firstElementChild,s=e.style.cssText.replace(/:.+(;|$)/g,",").split(",");s.pop();const i=e.classList;for(let t=0,e=i.length;t<e;t++)s.push("."+i[t]);const n=Re.utils.hasClass(t,"active")?null:e.cloneNode(!1),o=n?null:[e.nodeName];this.$.inline.apply(n,{stylesToModify:s,nodesToRemove:o,strictRemove:!0}),this.$.menu.dropdownOff()}}const wh=yh;const Ch=class extends Wl{static key="link";static className="se-icon-flip-rtl";#Ud;constructor(t,e){super(t),this.title=this.$.lang.link,this.icon="link",e.textToDisplay=!0,e.title=!0;const s=function({lang:t,icons:e}){const s=`\n\t<form>\n\t\t<div class="se-modal-header">\n\t\t\t<button type="button" data-command="close" class="se-btn se-close-btn" title="${t.close}" aria-label="${t.close}">\n\t\t\t\t${e.cancel}\n\t\t\t</button>\n\t\t\t<span class="se-modal-title">${t.link_modal_title}</span>\n\t\t</div>\n\t\t<div class="se-anchor-editor"></div>\n\t\t<div class="se-modal-footer">\n\t\t\t<button type="submit" class="se-btn-primary" title="${t.submitButton}" aria-label="${t.submitButton}">\n\t\t\t\t<span>${t.submitButton}</span>\n\t\t\t</button>\n\t\t</div>\n\t</form>`;return Re.utils.createElement("DIV",{class:"se-modal-content"},s)}(this.$),i=function({lang:t,icons:e}){const s=`\n\t<div class="se-arrow se-arrow-up"></div>\n\t<div class="link-content">\n\t\t<span><a target="_blank" href=""></a> </span>\n\t\t<div class="se-btn-group">\n\t\t\t<button type="button" data-command="update" tabindex="-1" class="se-btn se-tooltip">\n\t\t\t\t${e.edit}\n\t\t\t\t<span class="se-tooltip-inner">\n\t\t\t\t\t<span class="se-tooltip-text">${t.edit}</span>\n\t\t\t\t</span>\n\t\t\t</button>\n\t\t\t<button type="button" data-command="copy" tabindex="-1" class="se-btn se-tooltip">\n\t\t\t\t${e.copy}\n\t\t\t\t<span class="se-tooltip-inner">\n\t\t\t\t\t<span class="se-tooltip-text">${t.copy}</span>\n\t\t\t\t</span>\n\t\t\t</button>\n\t\t\t<button type="button" data-command="unlink" tabindex="-1" class="se-btn se-tooltip se-icon-flip-rtl">\n\t\t\t\t${e.unlink}\n\t\t\t\t<span class="se-tooltip-inner">\n\t\t\t\t\t<span class="se-tooltip-text">${t.unlink}</span>\n\t\t\t\t</span>\n\t\t\t</button>\n\t\t\t<button type="button" data-command="delete" tabindex="-1" class="se-btn se-tooltip">\n\t\t\t\t${e.delete}\n\t\t\t\t<span class="se-tooltip-inner">\n\t\t\t\t\t<span class="se-tooltip-text">${t.remove}</span>\n\t\t\t\t</span>\n\t\t\t</button>\n\t\t</div>\n\t</div>`;return Re.utils.createElement("DIV",{class:"se-controller se-controller-link"},s)}(this.$),n="string"==typeof e.uploadUrl?e.uploadUrl:null;this.target=null,this.isUpdateState=!1,this.pluginOptions={...e,uploadUrl:n,uploadHeaders:e.uploadHeaders||null,uploadSizeLimit:ze.get(e.uploadSizeLimit,0),uploadSingleSizeLimit:ze.get(e.uploadSingleSizeLimit,0),acceptedFormats:"string"==typeof e.acceptedFormats?e.acceptedFormats.trim():null,enableFileUpload:!!n},this.anchor=new Al(this.$,s,this.pluginOptions),this.modal=new Ml(this,this.$,s),this.controller=new Mi(this,this.$,i,{position:"bottom",disabled:!1}),this.#Ud=this.controller.form.querySelector("a")}active(t){if(Re.check.isAnchor(t)&&!t.hasAttribute("data-se-non-link")){const e=this.#Ud,s=t.getAttribute("href");return e.href=s,e.textContent=e.title=t.textContent,e.target=s?.startsWith("#")?t.target:"_blank",Re.utils.addClass(t,"on"),this.anchor.set(t),this.controller.open(t,null,{isWWTarget:!1,initMethod:null,addOffset:null}),this.target=t,!0}return this.controller.close(),!1}open(){this.modal.open()}modalOn(t){this.isUpdateState=t,this.anchor.on(t)}async modalAction(){const t=this.anchor.create(!1);if(null===t)return!1;if(this.isUpdateState){const t=this.controller.currentTarget.childNodes[0];this.$.selection.setRange(t,0,t,t.textContent.length)}else{const e=this.$.format.getLines();if(e.length>1){if(!this.$.html.insertNode(Re.utils.createElement(e[0].nodeName,null,t),{afterNode:null,skipCharCount:!1}))return!0}else if(!this.$.html.insertNode(t,{afterNode:null,skipCharCount:!1}))return!0;this.$.selection.setRange(t.childNodes[0],0,t.childNodes[0],t.textContent.length)}return this.$.history.push(!1),!0}modalInit(){this.controller.close(),this.anchor.init()}controllerAction(t){const e=t.getAttribute("data-command");if(/update/.test(e))this.modal.open();else if(/copy/.test(e))this.$.html.copy(this.target);else if(/unlink/.test(e)){const t=Re.query.getEdgeChild(this.controller.currentTarget,(function(t){return 0===t.childNodes.length||3===t.nodeType}),!1),e=Re.query.getEdgeChild(this.controller.currentTarget,(function(t){return 0===t.childNodes.length||3===t.nodeType}),!0);this.$.selection.setRange(t,0,e,e.textContent.length),this.$.inline.apply(null,{stylesToModify:null,nodesToRemove:["A"],strictRemove:!1})}else Re.utils.removeItem(this.controller.currentTarget),this.controller.currentTarget=null,this.$.focusManager.focus(),this.$.history.push(!1)}controllerClose(){Re.utils.removeClass(this.controller.currentTarget,"on")}},_h="%",kh="px",xh={BLOCK:"block",INLINE:"inline"},$h="image/*";const Sh=class{#Gc;#J;#I;#Vd;#Qc;#jd;#Gd;#Kd={w:0,h:0};#Yd=null;#Xd=null;#Zd=null;constructor(t,e){if(this.#Gc=t,this.#J=t.$,this.#I=t.state,this.#Vd=t.pluginOptions,this.#Qc=this.#Vd.canResize,this.#jd="auto"===this.#Vd.defaultWidth?"":this.#Vd.defaultWidth,this.#Gd="auto"===this.#Vd.defaultHeight?"":this.#Vd.defaultHeight,this.#Qc){this.#Yd=e.proportion,this.#Xd=e.inputX,this.#Zd=e.inputY,this.#Xd.value=this.#Vd.defaultWidth,this.#Zd.value=this.#Vd.defaultHeight;const t=this.#Jd.bind(this);this.#J.eventManager.addEvent(this.#Xd,"keyup",this.#Qd.bind(this,"x")),this.#J.eventManager.addEvent(this.#Zd,"keyup",this.#Qd.bind(this,"y")),this.#J.eventManager.addEvent(this.#Xd,"change",t),this.#J.eventManager.addEvent(this.#Zd,"change",t),this.#J.eventManager.addEvent(this.#Yd,"change",t),this.#J.eventManager.addEvent(e.revertBtn,"click",this.#tu.bind(this))}}setInputSize(t,e){this.#Xd.value="auto"===t?"":t,this.#I.onlyPercentage||(this.#Zd.value="auto"===e?"":e)}getInputSize(){return{w:this.#Xd?.value||"",h:this.#Zd?.value||""}}setOriginSize(t,e){this.#jd=t,this.#Gd=e}applySize(t,e){t||=this.#Xd?.value||this.#Vd.defaultWidth,e||=this.#Zd?.value||this.#Vd.defaultHeight,this.#I.onlyPercentage&&(t?/%$/.test(t)||(t+=_h):t="100%"),this.#Gc.figure.setSize(t,e)}on(){if(!this.#Qc)return;const t=this.#Vd.defaultWidth,e=this.#Vd.defaultHeight;this.setInputSize(t,e),this.setOriginSize(t,e)}ready(t,e,s){this.setInputSize(e,s);const i=this.#I.onlyPercentage&&this.#Gc.figure.isVertical;this.#Yd.checked=!0,this.#Xd.disabled=i,this.#Zd.disabled=i,this.#Yd.disabled=i,this.#Kd=this.#Yd.checked?t.ratio:{w:0,h:0}}init(){this.#Kd={w:0,h:0},this.#Qc&&(this.setInputSize(this.#Vd.defaultWidth,this.#Vd.defaultHeight),this.#Yd.checked=!0)}#Qd(t,e){if(Pe.isSpace(e.code))return void e.preventDefault();const s=e.target;if("x"===t&&this.#I.onlyPercentage&&Number(s.value)>100)s.value="100";else if(this.#Yd.checked){const e=Wi.CalcRatio(this.#Xd.value,this.#Zd.value,this.#I.sizeUnit,this.#Kd);"x"===t?this.#Zd.value=String(e.h):this.#Xd.value=String(e.w)}}#Jd(){this.#Kd=this.#Yd.checked?Wi.GetRatio(this.#Xd.value,this.#Zd.value,this.#I.sizeUnit):{w:0,h:0}}#tu(){this.#I.onlyPercentage?this.#Xd.value=Number(this.#jd)>100?"100":this.#jd:(this.#Xd.value=this.#jd,this.#Zd.value=this.#Gd)}},{NO_EVENT:Eh}=Le;const Th=class{#Gc;#J;#Vd;#Qc;constructor(t){this.#Gc=t,this.#J=t.$,this.#Vd=t.pluginOptions,this.#Qc=this.#Vd.canResize,this._base64RenderIndex=0}get#eu(){return this.#Gc.sizeService}serverUpload(t){if(!t.files)return;const e=this.#Vd.uploadUrl;"string"==typeof e&&e.length>0?this.#Gc.fileManager.upload(e,this.#Vd.uploadHeaders,t.files,this.#su.bind(this,t),this.#ec.bind(this)):this.#iu(t)}urlUpload(t){this.#Gc.setState("produceIndex",0);const e=t.url;this.#Gc.modal.isUpdate?this.#nu(e,t.element,t.files):this.#ou(e,t.anchor,t.inputWidth,t.inputHeight,t.align,t.files,t.alt,!0)}#ou(t,e,s,i,n,o,r,l){this.#Gc.as!==xh.INLINE?this.#Gc.create(t,e,s,i,n,o,r,l):this.#Gc.createInline(t,e,s,i,o,r,l)}#nu(t,e,s){e.src=t,this.#Gc.fileManager.setFileData(e,s),this.#J.component.select(e,this.#Gc.constructor.key)}#tc(t,e){this.#Gc.setState("produceIndex",0);const s=e.result;for(let e,i=0,n=s.length;i<n;i++){if(e={name:s[i].name,size:s[i].size},t.isUpdate){this.#nu(s[i].url,t.element,e);break}this.#ou(s[i].url,t.anchor,t.inputWidth,t.inputHeight,t.align,e,t.alt,i===n-1)}}#iu(t){try{const{files:e,element:s,anchor:i,inputWidth:n,inputHeight:o,align:r,alt:l,isUpdate:a}=t,h=this.#Gc.modal.isUpdate?1:e.length;if(0===h)return this.#J.ui.hideLoading(),void console.warn("[SUNEDITOR.image.base64.fail] cause : No applicable files");this._base64RenderIndex=h;const c=new Array(h);this.#Qc&&this.#eu.setInputSize(n,o);for(let t,d,u=0,p=this.#ru.bind(this);u<h;u++)t=new FileReader,d=e[u],t.onload=function(t,e,s,a,h,d){c[d]={result:e.result,file:h},0==--this._base64RenderIndex&&(t(s,c,a,i,n,o,r,l),this.#J.ui.hideLoading())}.bind(this,p,t,a,s,d,u),t.readAsDataURL(d)}catch(t){throw this.#J.ui.hideLoading(),Error(`[SUNEDITOR.plugins.image._setBase64.fail] ${t.message}`)}}#ru(t,e,s,i,n,o,r,l){this.#Gc.setState("produceIndex",0);for(let a=0,h=e.length;a<h;a++)t?this.#nu(e[a].result,s,e[a].file):this.#ou(e[a].result,i,n,o,r,e[a].file,l,a===h-1)}async#ec(t){const e=await this.#J.eventManager.triggerEvent("onImageUploadError",{error:t}),s=e===Eh?t.errorMessage:e||t.errorMessage;this.#J.ui.alertOpen(s,"error"),console.error("[SUNEDITOR.plugin.image.error]",s)}async#su(t,e){if(await this.#J.eventManager.triggerEvent("imageUploadHandler",{xmlHttp:e,info:t})===Eh){const s=JSON.parse(e.responseText);s.errorMessage?this.#ec(s):this.#tc(t,s)}}},{NO_EVENT:Mh}=Le;const Nh=class extends Wl{static key="image";static className="";static component(t){const e=Re.check.isFigure(t)||/^span$/i.test(t.nodeName)&&Re.check.isComponentContainer(t)?t.firstElementChild:t;return/^IMG$/i.test(e?.nodeName)?e:Re.check.isAnchor(e)&&/^IMG$/i.test(e?.firstElementChild?.nodeName)?e?.firstElementChild:null}#Qc;#lu;#au=null;#hu="";#cu="none";#du="30%";#$c=null;#uu=null;#pu=null;#gu=null;constructor(t,e){super(t),this.title=this.$.lang.image,this.icon="image",this.pluginOptions={canResize:void 0===e.canResize||e.canResize,showHeightInput:void 0===e.showHeightInput||!!e.showHeightInput,defaultWidth:e.defaultWidth?ze.is(e.defaultWidth)?e.defaultWidth+kh:e.defaultWidth:"auto",defaultHeight:e.defaultHeight?ze.is(e.defaultHeight)?e.defaultHeight+kh:e.defaultHeight:"auto",percentageOnlySize:!!e.percentageOnlySize,createFileInput:void 0===e.createFileInput||e.createFileInput,createUrlInput:void 0===e.createUrlInput||!e.createFileInput||e.createUrlInput,uploadUrl:"string"==typeof e.uploadUrl?e.uploadUrl:null,uploadHeaders:e.uploadHeaders||null,uploadSizeLimit:ze.get(e.uploadSizeLimit,0),uploadSingleSizeLimit:ze.get(e.uploadSingleSizeLimit,0),allowMultiple:!!e.allowMultiple,acceptedFormats:"string"!=typeof e.acceptedFormats||"*"===e.acceptedFormats.trim()?$h:e.acceptedFormats.trim()||$h,useFormatType:e.useFormatType??!0,defaultFormatType:[xh.BLOCK,xh.INLINE].includes(e.defaultFormatType)?e.defaultFormatType:xh.BLOCK,keepFormatType:e.keepFormatType??!1,insertBehavior:e.insertBehavior};const s=this.pluginOptions.percentageOnlySize?_h:kh,i=function({lang:t,icons:e,plugins:s},i){const n=i.createFileInput?`\n\t\t<div class="se-modal-form">\n\t\t\t<label>${t.image_modal_file}</label>\n\t\t\t${Ml.CreateFileInput({icons:e,lang:t},i)}\n\t\t</div>`:"",o=i.createUrlInput?`\n\t\t<div class="se-modal-form">\n\t\t\t<label>${t.image_modal_url}</label>\n\t\t\t<div class="se-modal-form-files">\n\t\t\t\t<input class="se-input-form se-input-url" data-focus type="text" />\n\t\t\t\t${s.imageGallery?`<button type="button" class="se-btn se-tooltip se-modal-files-edge-button __se__gallery" aria-label="${t.imageGallery}">\n\t\t\t\t\t\t\t${e.image_gallery}\n\t\t\t\t\t\t\t${Re.utils.createTooltipInner(t.imageGallery)}\n\t\t\t\t\t\t\t</button>`:""}\n\t\t\t</div>\n\t\t\t<pre class="se-link-preview"></pre>\n\t\t</div>`:"",r=i.canResize?`\n\t\t<div class="se-modal-form">\n\t\t\t<div class="se-modal-size-text">\n\t\t\t\t<label class="size-w">${t.width}</label>\n\t\t\t\t<label class="se-modal-size-x"> </label>\n\t\t\t\t<label class="size-h">${t.height}</label>\n\t\t\t</div>\n\t\t\t<input class="se-input-control _se_size_x" placeholder="auto" type="text" />\n\t\t\t<label class="se-modal-size-x">x</label>\n\t\t\t<input type="text" class="se-input-control _se_size_y" placeholder="auto" />\n\t\t\t<label><input type="checkbox" class="se-modal-btn-check _se_check_proportion" checked/> ${t.proportion}</label>\n\t\t\t<button type="button" aria-label="${t.revert}" class="se-btn se-tooltip se-modal-btn-revert">\n\t\t\t\t${e.revert}\n\t\t\t\t${Re.utils.createTooltipInner(t.revert)}\n\t\t\t</button>\n\t\t</div>`:"",l=i.useFormatType?`\n\t\t<div class="se-modal-form">\n\t\t\t<div class="se-modal-flex-form">\n\t\t\t\t<button type="button" data-command="asBlock" class="se-btn se-tooltip" aria-label="${t.inlineStyle}">\n\t\t\t\t\t${e.as_block}\n\t\t\t\t\t${Re.utils.createTooltipInner(t.blockStyle)}\n\t\t\t\t</button>\n\t\t\t\t<button type="button" data-command="asInline" class="se-btn se-tooltip" aria-label="${t.inlineStyle}">\n\t\t\t\t\t${e.as_inline}\n\t\t\t\t\t${Re.utils.createTooltipInner(t.inlineStyle)}\n\t\t\t\t</button>\n\t\t\t</div>\n\t\t</div>`:"",a=`\n\t\t<div class="se-modal-header">\n\t\t\t<button type="button" data-command="close" class="se-btn se-close-btn close" title="${t.close}" aria-label="${t.close}">${e.cancel}</button>\n\t\t\t<span class="se-modal-title">${t.image_modal_title}</span>\n\t\t</div>\n\t\t<div class="se-modal-tabs">\n\t\t\t<button type="button" class="_se_tab_link active" data-tab-link="image">${t.image}</button>\n\t\t\t<button type="button" class="_se_tab_link" data-tab-link="url">${t.link}</button>\n\t\t</div>\n\t\t<form method="post" enctype="multipart/form-data">\n\t\t\t<div class="_se_tab_content _se_tab_content_image">\n\t\t\t\t<div class="se-modal-body">\n\t\t\t\t\t${n}\n\t\t\t\t\t${o}\n\t\t\t\t\t<div class="se-modal-hr"></div>\n\t\t\t\t\t<div class="se-modal-form">\n\t\t\t\t\t\t<label>${t.image_modal_altText}</label><input class="se-input-form _se_image_alt" type="text" />\n\t\t\t\t\t</div>\n\t\t\t\t\t${r}\n\t\t\t\t\t${l}\n\t\t\t\t\t<div class="se-modal-form se-modal-form-footer">\n\t\t\t\t\t\t<label><input type="checkbox" class="se-modal-btn-check _se_image_check_caption" /> ${t.caption}</label>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t<div class="se-anchor-editor _se_tab_content _se_tab_content_url" style="display: none;">\n\t\t\t</div>\n\t\t\t<div class="se-modal-footer">\n\t\t\t\t<div class="se-figure-align">\n\t\t\t\t\t<label><input type="radio" name="suneditor_image_radio" class="se-modal-btn-radio" value="none" checked>${t.basic}</label>\n\t\t\t\t\t<label><input type="radio" name="suneditor_image_radio" class="se-modal-btn-radio" value="left">${t.left}</label>\n\t\t\t\t\t<label><input type="radio" name="suneditor_image_radio" class="se-modal-btn-radio" value="center">${t.center}</label>\n\t\t\t\t\t<label><input type="radio" name="suneditor_image_radio" class="se-modal-btn-radio" value="right">${t.right}</label>\n\t\t\t\t</div>\n\t\t\t\t<button type="submit" class="se-btn-primary" title="${t.submitButton}" aria-label="${t.submitButton}"><span>${t.submitButton}</span></button>\n\t\t\t</div>\n\t\t</form>`,h=Re.utils.createElement("DIV",{class:"se-modal-content"},a);return{html:h,alignForm:h.querySelector(".se-figure-align"),fileModalWrapper:h.querySelector(".se-flex-input-wrapper"),imgInputFile:h.querySelector(".__se__file_input"),imgUrlFile:h.querySelector(".se-input-url"),altText:h.querySelector("._se_image_alt"),captionCheckEl:h.querySelector("._se_image_check_caption"),previewSrc:h.querySelector("._se_tab_content_image .se-link-preview"),tabs:h.querySelector(".se-modal-tabs"),galleryButton:h.querySelector(".__se__gallery"),proportion:h.querySelector("._se_check_proportion"),inputX:h.querySelector("._se_size_x"),inputY:h.querySelector("._se_size_y"),revertBtn:h.querySelector(".se-modal-btn-revert"),asBlock:h.querySelector('[data-command="asBlock"]'),asInline:h.querySelector('[data-command="asInline"]'),fileRemoveBtn:h.querySelector(".se-file-remove")}}(this.$,this.pluginOptions),n=this.pluginOptions.useFormatType?"as":"",o=e.controls||(this.pluginOptions.canResize?[[n,"resize_auto,100,75,50","rotate_l","rotate_r","mirror_h","mirror_v"],["edit","align","caption","revert","copy","remove"]]:[[n,"mirror_h","mirror_v","align","caption","edit","revert","copy","remove"]]);this.alignForm=i.alignForm,o.some((t=>t.includes("align")))||(this.alignForm.style.display="none");const r=this.$.plugins.link?this.$.plugins.link.pluginOptions:{};this.anchor=new Al(this.$,i.html,{...r,textToDisplay:!1,title:!0}),this.modal=new Ml(this,this.$,i.html),this.figure=new Wi(this,this.$,o,{sizeUnit:s}),this.fileManager=new Bl(this,this.$,{query:"img",loadEventName:"onImageLoad",actionEventName:"onImageAction"}),this.state={sizeUnit:s,onlyPercentage:this.pluginOptions.percentageOnlySize,produceIndex:0},this.fileModalWrapper=i.fileModalWrapper,this.imgInputFile=i.imgInputFile,this.imgUrlFile=i.imgUrlFile,this.focusElement=this.imgInputFile||this.imgUrlFile,this.altText=i.altText,this.captionCheckEl=i.captionCheckEl,this.captionEl=this.captionCheckEl?.parentElement,this.previewSrc=i.previewSrc,this.as=xh.BLOCK,this.#Qc=this.pluginOptions.canResize,this.#lu=!this.#Qc||!this.pluginOptions.showHeightInput||this.pluginOptions.percentageOnlySize,this.sizeService=new Sh(this,i),this.uploadService=new Th(this),this.$.eventManager.addEvent(i.tabs,"click",this.#mu.bind(this)),this.imgInputFile&&this.$.eventManager.addEvent(i.fileRemoveBtn,"click",this.#fu.bind(this)),this.imgUrlFile&&this.$.eventManager.addEvent(this.imgUrlFile,"input",this.#vu.bind(this)),this.imgInputFile&&this.imgUrlFile&&this.$.eventManager.addEvent(this.imgInputFile,"change",this.#bu.bind(this));const l=i.galleryButton;l&&this.$.eventManager.addEvent(l,"click",this.#yu.bind(this)),this.pluginOptions.useFormatType&&(this.as=this.pluginOptions.defaultFormatType,this.asBlock=i.asBlock,this.asInline=i.asInline,this.$.eventManager.addEvent([this.asBlock,this.asInline],"click",this.#wu.bind(this)))}setState(t,e){this.state[t]=e}open(){this.state.produceIndex=0,this.modal.open()}retainFormat(){return{query:"img",method:t=>{const e=Wi.GetContainer(t);if(e&&e.container&&(e.cover||e.inlineCover))return;const{w:s,h:i}=this.#Cu(t,!0);this.#_u(s,i)}}}onFilePasteAndDrop({file:t}){/^image/.test(t.type)&&(this.submitFile([t]),this.$.focusManager.focus())}modalOn(t){t?this.imgInputFile&&this.pluginOptions.allowMultiple&&this.imgInputFile.removeAttribute("multiple"):(this.sizeService.on(),this.imgInputFile&&this.pluginOptions.allowMultiple&&this.imgInputFile.setAttribute("multiple","multiple")),this.anchor.on(t)}async modalAction(){return this.#cu=this.modal.form.querySelector('input[name="suneditor_image_radio"]:checked').value,this.modal.isUpdate&&(this.#ku(),this.$.history.push(!1)),this.imgInputFile&&this.imgInputFile.files.length>0?await this.submitFile(this.imgInputFile.files):!!(this.imgUrlFile&&this.#hu.length>0)&&await this.submitURL(this.#hu)}modalInit(){Ml.OnChangeFile(this.fileModalWrapper,[]),this.imgInputFile&&(this.imgInputFile.value=""),this.imgUrlFile&&(this.#hu=this.previewSrc.textContent=this.imgUrlFile.value=""),this.imgInputFile&&this.imgUrlFile&&(this.imgUrlFile.disabled=!1,this.previewSrc.style.textDecoration=""),this.altText.value="",this.modal.form.querySelector('input[name="suneditor_image_radio"][value="none"]').checked=!0,this.captionCheckEl.checked=!1,this.#$c=null,this.#mu("init"),this.sizeService.init(),this.pluginOptions.useFormatType&&this.#xu((this.pluginOptions.keepFormatType?this.as:this.pluginOptions.defaultFormatType)===xh.INLINE),this.anchor.init()}componentSelect(t){this.#Cu(t)}componentEdit(){this.modal.open()}async componentDestroy(t){const e=t||this.#$c,s=Re.query.getParentElement(e,Wi.is)||e,i=s.previousElementSibling||s.nextElementSibling,n=s.parentNode;!1!==await this.$.eventManager.triggerEvent("onImageDeleteBefore",{element:e,container:s,align:this.#cu,alt:this.altText.value,url:this.#hu})&&(Re.utils.removeItem(s),this.modalInit(),n!==this.$.frameContext.get("wysiwyg")&&this.$.nodeTransform.removeAllParents(n,(function(t){return 0===t.childNodes.length}),null),this.$.focusManager.focusEdge(i),this.$.history.push(!1))}async submitFile(t){if(0===t.length)return!1;let e=0;const s=[],i=this.pluginOptions.uploadSingleSizeLimit;for(let n,o,r=0,l=t.length;r<l;r++)if(n=t[r],/image/i.test(n.type)){if(o=n.size,i>0&&o>i){const t="[SUNEDITOR.imageUpload.fail] Size of uploadable single file: "+i/1e3+"KB",e=await this.$.eventManager.triggerEvent("onImageUploadError",{error:t,limitSize:i,uploadSize:o,file:n});return this.$.ui.alertOpen(e===Mh?t:e||t,"error"),!1}s.push(n),e+=o}const n=this.pluginOptions.uploadSizeLimit,o=this.fileManager.getSize();if(n>0&&e+o>n){const t="[SUNEDITOR.imageUpload.fail] Size of uploadable total images: "+n/1e3+"KB",s=await this.$.eventManager.triggerEvent("onImageUploadError",{error:t,limitSize:n,currentSize:o,uploadSize:e});return this.$.ui.alertOpen(s===Mh?t:s||t,"error"),!1}const r={files:s,...this.#$u()},l=function(t,e,s){t(e=s||e)}.bind(this,this.uploadService.serverUpload.bind(this.uploadService),r),a=await this.$.eventManager.triggerEvent("onImageUploadBefore",{info:r,handler:l});return void 0===a||!1!==a&&(null!==a&&"object"==typeof a&&l(a),void(!0!==a&&a!==Mh||l(null)))}async submitURL(t){if(!(t||=this.#hu))return!1;const e={name:t.split("/").pop(),size:0},s={url:t,files:e,...this.#$u()},i=function(t,e,s){t(e=s||e)}.bind(this,this.uploadService.urlUpload.bind(this.uploadService),s),n=await this.$.eventManager.triggerEvent("onImageUploadBefore",{info:s,handler:i});return void 0===n||!1!==n&&(null!==n&&"object"==typeof n&&i(n),!0!==n&&n!==Mh||i(null),!0)}create(t,e,s,i,n,o,r,l){const a=Re.utils.createElement("IMG");a.src=t,a.alt=r,e=this.#Su(a,e?e.cloneNode(!1):null);const h=Wi.CreateContainer(e,"se-image-container"),c=h.cover,d=h.container;this.captionCheckEl.checked&&(this.#gu=Wi.CreateCaption(c,this.$.lang.caption)),this.#$c=a,this.#uu=c,this.#pu=d,this.figure.open(a,{nonResizing:this.#lu,nonSizeInfo:!1,nonBorder:!1,figureTarget:!1,infoOnly:!0}),this.sizeService.applySize(s,i),this.figure.setAlign(a,n),this.fileManager.setFileData(a,o),this.setState("produceIndex",this.state.produceIndex+1),a.onload=this.#Eu.bind(this,a,this.#du,d),this.$.component.insert(d,{scrollTo:!!l,insertBehavior:l?null:"line"})}createInline(t,e,s,i,n,o,r){const l=Re.utils.createElement("IMG");l.src=t,l.alt=o,e=this.#Su(l,e?e.cloneNode(!1):null);const a=Wi.CreateInlineContainer(e,"se-image-container").container;this.#$c=l,this.#pu=a,this.figure.open(l,{nonResizing:this.#lu,nonSizeInfo:!1,nonBorder:!1,figureTarget:!1,infoOnly:!0}),this.sizeService.applySize(s,i),this.fileManager.setFileData(l,n),this.setState("produceIndex",this.state.produceIndex+1),l.onload=this.#Eu.bind(this,l,this.#du,a),this.$.component.insert(a,{scrollTo:!!r,insertBehavior:r?null:"line"})}#Cu(t,e=!1){if(!t)return;const s=this.figure.open(t,{nonResizing:this.#lu,nonSizeInfo:!1,nonBorder:!1,figureTarget:!1,infoOnly:e});this.anchor.set(Re.check.isAnchor(t.parentNode)?t.parentNode:null),this.#au=this.anchor.currentTarget,this.#$c=t,this.#uu=s.cover,this.#pu=s.container,this.#gu=s.caption,this.#cu=s.align,t.style.float="",this.sizeService.setOriginSize(String(s.originWidth||s.w||""),String(s.originHeight||s.h||"")),this.altText.value=this.#$c.alt,this.imgUrlFile&&(this.#hu=this.previewSrc.textContent=this.imgUrlFile.value=this.#$c.src);(this.modal.form.querySelector('input[name="suneditor_image_radio"][value="'+this.#cu+'"]')||this.modal.form.querySelector('input[name="suneditor_image_radio"][value="none"]')).checked=!0,this.captionCheckEl.checked=!!this.#gu;const{dw:i,dh:n}=this.figure.getSize(t);return this.#Qc?(this.sizeService.ready(s,i,n),this.pluginOptions.useFormatType&&this.#xu(this.$.component.isInline(s.container)),{w:i,h:n}):{w:i,h:n}}#$u(){const{w:t,h:e}=this.sizeService.getInputSize();return{element:this.#$c,anchor:this.anchor.create(!0),inputWidth:t,inputHeight:e,align:this.#cu,isUpdate:this.modal.isUpdate,alt:this.altText.value}}#xu(t){t?(Re.utils.addClass(this.asInline,"on"),Re.utils.removeClass(this.asBlock,"on"),this.as=xh.INLINE,this.alignForm&&(this.alignForm.style.display="none"),this.captionEl&&(this.captionEl.style.display="none")):(Re.utils.addClass(this.asBlock,"on"),Re.utils.removeClass(this.asInline,"on"),this.as=xh.BLOCK,this.alignForm&&(this.alignForm.style.display=""),this.captionEl&&(this.captionEl.style.display=""))}#ku(){const{w:t,h:e}=this.sizeService.getInputSize(),s=t||"auto",i=e||"auto";let n=this.#$c;(this.as===xh.BLOCK&&!this.#uu||this.as===xh.INLINE&&this.#uu)&&(n=this.figure.convertAsFormat(n,this.as));const o=this.#uu,r=this.#pu===this.#uu?null:this.#pu;let l;const a=ze.is(s)?s+this.state.sizeUnit:s,h=ze.is(i)?i+this.state.sizeUnit:i;l=/%$/.test(n.style.width)?a!==r.style.width||h!==r.style.height:a!==n.style.width||h!==n.style.height,n.alt=this.altText.value;let c=!1;this.captionCheckEl.checked?this.#gu||(this.#gu=Wi.CreateCaption(o,this.$.lang.caption),c=!0):this.#gu&&(Re.utils.removeItem(this.#gu),this.#gu=null,c=!0);let d=!1;const u=this.anchor.create(!0);if(u)this.#au===u&&r.contains(u)||(this.#au=u.cloneNode(!1),o.insertBefore(this.#Su(n,this.#au),this.#gu),d=!0);else if(null!==this.#au&&o.contains(this.#au)){const t=n.cloneNode(!0);o.removeChild(this.#au),o.insertBefore(t,this.#gu),n=t}d&&Re.utils.removeItem(u),this.#Qc&&l&&this.sizeService.applySize(s,i),(c||!this.state.onlyPercentage&&l)&&(/\d+/.test(n.style.height)||this.figure.isVertical&&this.captionCheckEl.checked)&&(/auto|%$/.test(s)||/auto|%$/.test(i)?this.figure.deleteTransform(n):this.#Qc&&l&&this.figure.isVertical||this.figure.setTransform(n,s,i,0)),this.figure.setAlign(n,this.#cu),n.onload=()=>{this.componentSelect(n)}}#_u(t,e){const{w:s,h:i}=this.sizeService.getInputSize();t||=s||"auto",e||=i||"auto";let n=this.#$c,o=this.#uu,r=null,l=this.#pu===this.#uu?null:this.#pu,a=!1;if(!o||!l){a=!0,n=this.#$c.cloneNode(!0);const e=this.pluginOptions.useFormatType&&"auto"!==t&&(/^span$/i.test(this.#$c.parentElement?.nodeName)||this.$.format.isLine(this.#$c.parentElement))?Wi.CreateInlineContainer(n,"se-image-container"):Wi.CreateContainer(n,"se-image-container");o=e.cover,l=e.container,r=e.inlineCover,this.figure.open(n,{nonResizing:!0,nonSizeInfo:!1,nonBorder:!1,figureTarget:!1,infoOnly:!0})}n.alt=this.altText.value;let h=!1;r||(this.captionCheckEl.checked?this.#gu&&!a||(this.#gu=Wi.CreateCaption(o,this.$.lang.caption),h=!0):this.#gu&&(Re.utils.removeItem(this.#gu),this.#gu=null,h=!0));let c=null;const d=this.anchor.create(!0,Re.check.isAnchor(this.#$c.parentElement)?this.#$c.parentElement.href:null);if(d)(this.#au!==d||a&&!l.contains(d))&&(this.#au=d.cloneNode(!1),o.insertBefore(this.#Su(n,this.#au),this.#gu),c=this.#$c);else if(null!==this.#au&&o.contains(this.#au)){const t=n.cloneNode(!0);o.removeChild(this.#au),o.insertBefore(t,this.#gu),n=t}a&&(n=this.#$c,this.figure.retainFigureFormat(l,this.#$c,c?d:null,this.fileManager),this.#$c=n=l.querySelector("img"),this.#uu=o,this.#pu=l),n.style.width="",n.style.height="",n.removeAttribute("width"),n.removeAttribute("height"),this.sizeService.applySize(t,e),c&&(a?(Re.utils.removeItem(c),0===Re.query.getListChildren(d,(t=>/IMG/i.test(t.tagName)),null).length&&Re.utils.removeItem(d)):Re.utils.removeItem(d)),!h&&this.state.onlyPercentage||(/\d+/.test(n.style.height)||this.figure.isVertical&&this.captionCheckEl.checked)&&(/auto|%$/.test(t)||/auto|%$/.test(e)?this.figure.deleteTransform(n):this.figure.setTransform(n,t,e,0)),this.figure.setAlign(n,this.#cu)}#Su(t,e){return e?(e.setAttribute("data-se-non-link","true"),e.appendChild(t),e):t}#mu(t){const e=this.modal.form,s="string"==typeof t?e.querySelector("._se_tab_link"):Re.query.getEventTarget(t);if(!/^BUTTON$/i.test(s.tagName))return!1;const i=s.getAttribute("data-tab-link");let n;const o=e.getElementsByClassName("_se_tab_content");for(n=0;n<o.length;n++)o[n].style.display="none";const r=e.getElementsByClassName("_se_tab_link");for(n=0;n<r.length;n++)Re.utils.removeClass(r[n],"active");return e.querySelector("._se_tab_content_"+i).style.display="block",Re.utils.addClass(s,"active"),"init"!==t&&("image"===i?this.focusElement.focus():"url"===i&&this.anchor.urlInput.focus()),!1}#fu(){this.imgInputFile.value="",this.imgUrlFile&&(this.imgUrlFile.disabled=!1,this.previewSrc.style.textDecoration=""),Ml.OnChangeFile(this.fileModalWrapper,[])}#wu({target:t}){this.#xu("asInline"===t.getAttribute("data-command"))}#vu(t){const e=t.target.value.trim();this.#hu=this.previewSrc.textContent=e?this.$.options.get("defaultUrlProtocol")&&!e.includes("://")&&0!==e.indexOf("#")?this.$.options.get("defaultUrlProtocol")+e:e.includes("://")?e:"/"+e:""}#bu({target:t}){this.imgInputFile.value?(this.imgUrlFile.disabled=!0,this.previewSrc.style.textDecoration="line-through"):(this.imgUrlFile.disabled=!1,this.previewSrc.style.textDecoration=""),Ml.OnChangeFile(this.fileModalWrapper,t.files)}#yu(){this.$.plugins.imageGallery.open(this.#Tu.bind(this))}#Tu(t){this.altText.value=t.getAttribute("data-value")||t.alt,this.#hu=this.previewSrc.textContent=this.imgUrlFile.value=t.getAttribute("data-command")||t.src,this.imgUrlFile.focus()}#Eu(t,e,s){this.setState("produceIndex",this.state.produceIndex-1),delete t.onload,0===t.offsetWidth&&this.sizeService.applySize(e,""),0===this.state.produceIndex&&(this.$.component.applyInsertBehavior(s,null,this.pluginOptions.insertBehavior||this.$.options.get("componentInsertBehavior")),this.$.ui._iframeAutoHeight(this.$.frameContext),this.$.history.push(!1))}};const Bh=class{#Gc;#J;#I;#Vd;#Qc;#Mu;#Nu;#Bu;#jd;#Gd;#Kd={w:0,h:0};#Yd=null;#Xd=null;#Zd=null;#Iu=null;constructor(t,e){if(this.#Gc=t,this.#J=t.$,this.#I=t.state,this.#Vd=t.pluginOptions,this.#Qc=this.#Vd.canResize,this.#Mu=this.#I.defaultRatio,this.#Nu="100%",this.#Bu=100*this.#Vd.defaultRatio+"%",this.#jd="100%"===this.#Vd.defaultWidth?"":this.#Vd.defaultWidth,this.#Gd=this.#Vd.defaultHeight===this.#I.defaultRatio?"":this.#Vd.defaultHeight,this.#Qc){this.#Yd=e.proportion,this.frameRatioOption=e.frameRatioOption,this.#Xd=e.inputX,this.#Zd=e.inputY,this.#Xd.value=this.#Vd.defaultWidth,this.#Zd.value=this.#Vd.defaultHeight;const t=this.#Jd.bind(this);this.#J.eventManager.addEvent(this.#Xd,"keyup",this.#Qd.bind(this,"x")),this.#J.eventManager.addEvent(this.#Zd,"keyup",this.#Qd.bind(this,"y")),this.#J.eventManager.addEvent(this.#Xd,"change",t),this.#J.eventManager.addEvent(this.#Zd,"change",t),this.#J.eventManager.addEvent(this.#Yd,"change",t),this.#J.eventManager.addEvent(this.frameRatioOption,"change",this.#Lu.bind(this)),this.#J.eventManager.addEvent(e.revertBtn,"click",this.#tu.bind(this))}}setInputSize(t,e){this.#Xd.value=t===this.#Nu?"":t,this.#I.onlyPercentage||(this.#Zd.value=e===this.#Bu?"":e)}getInputSize(){return{w:this.#Xd?.value||"",h:this.#Zd?.value||""}}setOriginSize(t,e){this.#jd=t,this.#Gd=e}applySize(t,e){t||=this.#Xd?.value||this.#Vd.defaultWidth,e||=this.#Zd?.value||this.#Vd.defaultHeight,this.#I.onlyPercentage&&(t?/%$/.test(t+"")||(t+="%"):t="100%"),this.#Gc.figure.setSize(t,e)}resolveSize(t,e,s,i){t||=this.#Nu,e||=this.#Mu;const n=this.#Gc.figure.getSize(s),o=n.w!==t||n.h!==e,r=!i||o;return r&&(this.#Iu!==this.frameRatioOption?.value&&this.#Gc.figure.deleteTransform(),this.applySize(t,e)),{width:t,height:e,isChanged:r}}on(t){if(this.#Qc){if(!t){const t=this.#Vd.defaultWidth,e=this.#Vd.defaultHeight;this.setInputSize(t,e),this.setOriginSize(t,e),this.#Yd.disabled=!0}this.#Au(this.#Gc.figure.isVertical?"":this.#Gd||this.#I.defaultRatio),this.#Iu=this.frameRatioOption?.value}}ready(t,e){const{dw:s,dh:i}=this.#Gc.figure.getSize(e);this.setInputSize(s,i);const n=t.height||t.h||this.#Gd||"";this.#Au(n)||(this.#Zd.value=String(this.#I.onlyPercentage?ze.get(n,2):n));const o=this.#I.onlyPercentage&&this.#Gc.figure.isVertical;this.#Xd.disabled=o,this.#Zd.disabled=o,this.#Yd.checked=!t.isVertical,this.#Yd.disabled=o,this.#Kd=this.#Yd.checked?t.ratio:{w:0,h:0}}init(){this.#Kd={w:0,h:0},this.#Qc&&(this.setInputSize(this.#Vd.defaultWidth,this.#Vd.defaultHeight),this.#Yd.checked=!1,this.#Yd.disabled=!0,this.#Au(this.#I.defaultRatio))}#tu(){this.#I.onlyPercentage?this.#Xd.value=Number(this.#jd)>100?"100":this.#jd:(this.#Xd.value=this.#jd,this.#Zd.value=this.#Gd)}#Au(t){if(!this.frameRatioOption)return;let e=!1;const s=this.frameRatioOption.options;/%$/.test(t+"")||this.#I.onlyPercentage?t=ze.get(t,2)/100+"":(!ze.is(t)||Number(t)>=1)&&(t=""),this.#Zd.placeholder="";for(let i=0,n=s.length;i<n;i++)s[i].value===t?(e=s[i].selected=!0,this.#Zd.placeholder=t?100*Number(t)+"%":""):s[i].selected=!1;return e}#Lu(t){const e=Re.query.getEventTarget(t),s=e.options[e.selectedIndex].value;this.#Bu=this.#Gc.figure.autoRatio.current=this.#Mu=s?100*Number(s)+"%":this.#Bu,this.#Zd.placeholder=s?100*Number(s)+"%":"",this.#Zd.value=""}#Jd(){this.#Kd=this.#Yd.checked?Wi.GetRatio(this.#Xd.value,this.#Zd.value,this.#I.sizeUnit):{w:0,h:0}}#Qd(t,e){if(Pe.isSpace(e.code))return void e.preventDefault();const s=Re.query.getEventTarget(e);if("x"===t&&this.#I.onlyPercentage&&Number(s.value)>100)s.value="100";else if(this.#Yd.checked&&!this.frameRatioOption?.value){const e=Wi.CalcRatio(this.#Xd.value,this.#Zd.value,this.#I.sizeUnit,this.#Kd);"x"===t?this.#Zd.value=String(e.h):this.#Xd.value=String(e.w)}"y"===t&&this.#Au(s.value||this.#I.defaultRatio)}},{NO_EVENT:Ih}=Le;const Lh=class{#Gc;#J;#Vd;constructor(t){this.#Gc=t,this.#J=t.$,this.#Vd=t.pluginOptions}serverUpload(t,e){if(!e)return;const s=this.#Vd.uploadUrl;"string"==typeof s&&s.length>0&&this.#Gc.fileManager.upload(s,this.#Vd.uploadHeaders,e,this.#su.bind(this,t),this.#ec.bind(this))}#tc(t,e){const s=e.result,i=this.#Gc.createVideoTag();for(let e=0,n=s.length;e<n;e++){const o=t.isUpdate?t.element:i.cloneNode(!1);this.#Gc.create(o,s[e].url,t.inputWidth,t.inputHeight,t.align,t.isUpdate,{name:s[e].name,size:s[e].size},e===n-1)}}async#ec(t){const e=await this.#J.eventManager.triggerEvent("onVideoUploadError",{error:t}),s=e===Ih?t.errorMessage:e||t.errorMessage;this.#J.ui.alertOpen(s,"error"),console.error("[SUNEDITOR.plugin.video.error]",e)}async#su(t,e){if(await this.#J.eventManager.triggerEvent("videoUploadHandler",{xmlHttp:e,info:t})===Ih){const s=JSON.parse(e.responseText);s.errorMessage?this.#ec(s):this.#tc(t,s)}}};const{_w:Ah,NO_EVENT:Oh}=Le;class Rh extends Wl{static key="video";static className="";static component(t){return/^(VIDEO)$/i.test(t?.nodeName)||/^(IFRAME)$/i.test(t?.nodeName)&&this.#Ou(t.src)?t:null}static#Ou(t){return t=t?.toLowerCase()||"",!(!this.#Ru.some((e=>t.endsWith(e)))&&!this.#zu.some((e=>e.test(t))))}static#Ru=[".mp4",".avi",".mov",".webm",".flv",".mkv",".m4v",".ogv"];static#zu=[/youtu\.?be/,/vimeo\.com\//,/dailymotion\.com\/video\//,/facebook\.com\/.+\/videos\//,/facebook\.com\/watch\/\?v=/,/twitter\.com\/.+\/status\//,/twitch\.tv\/videos\//,/twitch\.tv\/[^/]+$/,/tiktok\.com\/@[^/]+\/video\//,/instagram\.com\/p\//,/instagram\.com\/tv\//,/instagram\.com\/reel\//,/linkedin\.com\/posts\//,/\.(wistia\.com|wi\.st)\/(medias|embed)\//,/loom\.com\/share\//];#Qc;#lu;#hu="";#cu="none";#$c=null;#pu=null;constructor(t,e){super(t),this.title=this.$.lang.video,this.icon="video",this.pluginOptions={canResize:void 0===e.canResize||e.canResize,showHeightInput:void 0===e.showHeightInput||!!e.showHeightInput,defaultWidth:e.defaultWidth&&ze.get(e.defaultWidth,0)?ze.is(e.defaultWidth)?e.defaultWidth+"px":e.defaultWidth:"",defaultHeight:e.defaultHeight&&ze.get(e.defaultHeight,0)?ze.is(e.defaultHeight)?e.defaultHeight+"px":e.defaultHeight:"",percentageOnlySize:!!e.percentageOnlySize,createFileInput:!!e.createFileInput,createUrlInput:void 0===e.createUrlInput||!e.createFileInput||e.createUrlInput,uploadUrl:"string"==typeof e.uploadUrl?e.uploadUrl:null,uploadHeaders:e.uploadHeaders||null,uploadSizeLimit:ze.get(e.uploadSizeLimit,0),uploadSingleSizeLimit:ze.get(e.uploadSingleSizeLimit,0),allowMultiple:!!e.allowMultiple,acceptedFormats:"string"!=typeof e.acceptedFormats||"*"===e.acceptedFormats.trim()?"video/*":e.acceptedFormats.trim()||"video/*",defaultRatio:ze.get(e.defaultRatio,4)||.5625,showRatioOption:void 0===e.showRatioOption||!!e.showRatioOption,ratioOptions:e.ratioOptions?e.ratioOptions:null,videoTagAttributes:e.videoTagAttributes||null,iframeTagAttributes:e.iframeTagAttributes||null,query_youtube:e.query_youtube||"",query_vimeo:e.query_vimeo||"",insertBehavior:e.insertBehavior};const s=this.pluginOptions.percentageOnlySize?"%":"px",i=function({lang:t,icons:e,plugins:s},i){let n=`\n\t<form method="post" enctype="multipart/form-data">\n\t\t<div class="se-modal-header">\n\t\t\t<button type="button" data-command="close" class="se-btn se-close-btn" title="${t.close}" aria-label="${t.close}">\n\t\t\t${e.cancel}\n\t\t\t</button>\n\t\t\t<span class="se-modal-title">${t.video_modal_title}</span>\n\t\t</div>\n\t\t<div class="se-modal-body">`;if(i.createFileInput&&(n+=`\n\t\t\t<div class="se-modal-form">\n\t\t\t\t<label>${t.video_modal_file}</label>\n\t\t\t\t${Ml.CreateFileInput({lang:t,icons:e},i)}\n\t\t\t</div>`),i.createUrlInput&&(n+=`\n\t\t\t<div class="se-modal-form">\n\t\t\t\t<label>${t.video_modal_url}</label>\n\t\t\t\t<div class="se-modal-form-files">\n\t\t\t\t\t<input class="se-input-form se-input-url" type="text" data-focus />\n\t\t\t\t\t${s.videoGallery?`<button type="button" class="se-btn se-tooltip se-modal-files-edge-button __se__gallery" aria-label="${t.videoGallery}">\n\t\t\t\t\t\t\t\t${e.video_gallery}\n\t\t\t\t\t\t\t\t${Re.utils.createTooltipInner(t.videoGallery)}\n\t\t\t\t\t\t\t\t</button>`:""}\n\t\t\t\t</div>\n\t\t\t\t<pre class="se-link-preview"></pre>\n\t\t\t</div>`),i.canResize){const s=i.ratioOptions||[{name:"16:9",value:.5625},{name:"4:3",value:.75},{name:"21:9",value:.4285},{name:"9:16",value:1.78}],o=i.defaultRatio,r=i.percentageOnlySize,l=r?' style="display: none !important;"':"",a=i.showHeightInput?"":' style="display: none !important;"',h=i.showRatioOption?"":' style="display: none !important;"',c=r||i.showHeightInput||i.showRatioOption?"":' style="display: none !important;"';n+=`\n\t\t\t<div class="se-modal-form">\n\t\t\t\t<div class="se-modal-size-text">\n\t\t\t\t\t<label class="size-w">${t.width}</label>\n\t\t\t\t\t<label class="se-modal-size-x"> </label>\n\t\t\t\t\t<label class="size-h"${a}>${t.height}</label>\n\t\t\t\t\t<label class="size-h"${h}>(${t.ratio})</label>\n\t\t\t\t</div>\n\t\t\t\t<input class="se-input-control _se_size_x" placeholder="100%"${r?' type="number" min="1"':'type="text"'}${r?' max="100"':""}/>\n\t\t\t\t<label class="se-modal-size-x"${c}>${r?"%":"x"}</label>\n\t\t\t\t<input class="se-input-control _se_size_y" placeholder="${100*i.defaultRatio}%"\n\t\t\t\t${r?' type="number" min="1"':'type="text"'}${r?' max="100"':""}${a}/>\n\t\t\t\t<select class="se-input-select se-modal-ratio" title="${t.ratio}" aria-label="${t.ratio}"${h}>\n\t\t\t\t\t${a?"":'<option value=""> - </option>'} \n\t\t\t\t\t${s.map((t=>`<option value="${t.value}"${o.toString()===t.value.toString()?" selected":""}>${t.name}</option>`)).join("")}\n\t\t\t\t</select>\n\t\t\t\t<button type="button" title="${t.revert}" aria-label="${t.revert}" class="se-btn se-modal-btn-revert">${e.revert}</button>\n\t\t\t</div>\n\t\t\t<div class="se-modal-form se-modal-form-footer"${l}${c}>\n\t\t\t\t<label>\n\t\t\t\t\t<input type="checkbox" class="se-modal-btn-check _se_check_proportion" /> \n\t\t\t\t\t<span>${t.proportion}</span>\n\t\t\t\t</label>\n\t\t\t</div>`}n+=`\n\t\t</div>\n\t\t<div class="se-modal-footer">\n\t\t\t<div class="se-figure-align">\n\t\t\t\t<label><input type="radio" name="suneditor_video_radio" class="se-modal-btn-radio" value="none" checked>${t.basic}</label>\n\t\t\t\t<label><input type="radio" name="suneditor_video_radio" class="se-modal-btn-radio" value="left">${t.left}</label>\n\t\t\t\t<label><input type="radio" name="suneditor_video_radio" class="se-modal-btn-radio" value="center">${t.center}</label>\n\t\t\t\t<label><input type="radio" name="suneditor_video_radio" class="se-modal-btn-radio" value="right">${t.right}</label>\n\t\t\t</div>\n\t\t\t<button type="submit" class="se-btn-primary" title="${t.submitButton}" aria-label="${t.submitButton}"><span>${t.submitButton}</span></button>\n\t\t</div>\n\t</form>`;const o=Re.utils.createElement("DIV",{class:"se-modal-content"},n);return{html:o,alignForm:o.querySelector(".se-figure-align"),fileModalWrapper:o.querySelector(".se-flex-input-wrapper"),videoInputFile:o.querySelector(".__se__file_input"),videoUrlFile:o.querySelector(".se-input-url"),previewSrc:o.querySelector(".se-link-preview"),galleryButton:o.querySelector(".__se__gallery"),proportion:o.querySelector("._se_check_proportion"),frameRatioOption:o.querySelector(".se-modal-ratio"),inputX:o.querySelector("._se_size_x"),inputY:o.querySelector("._se_size_y"),revertBtn:o.querySelector(".se-modal-btn-revert"),fileRemoveBtn:o.querySelector(".se-file-remove")}}(this.$,this.pluginOptions),n=e.controls||(this.pluginOptions.canResize?[["resize_auto,75,50","align","edit","revert","copy","remove"]]:[["align","edit","copy","remove"]]);n.some((t=>t.includes("align")))||(i.alignForm.style.display="none");const o=100*this.pluginOptions.defaultRatio+"%";this.modal=new Ml(this,this.$,i.html),this.figure=new Wi(this,this.$,n,{sizeUnit:s,autoRatio:{current:o,default:o}}),this.fileManager=new Bl(this,this.$,{query:"iframe, video",loadEventName:"onVideoLoad",actionEventName:"onVideoAction"}),this.fileModalWrapper=i.fileModalWrapper,this.videoInputFile=i.videoInputFile,this.videoUrlFile=i.videoUrlFile,this.focusElement=this.videoUrlFile||this.videoInputFile,this.previewSrc=i.previewSrc,this.#Qc=this.pluginOptions.canResize,this.#lu=!this.#Qc||!this.pluginOptions.showHeightInput||this.pluginOptions.percentageOnlySize,this.query={youtube:{pattern:/youtu\.?be/i,action:t=>(t=this.convertUrlYoutube(t),Oe.addUrlQuery(t,this.pluginOptions.query_youtube)),tag:"iframe"},vimeo:{pattern:/vimeo\.com/i,action:t=>(t=this.convertUrlVimeo(t),Oe.addUrlQuery(t,this.pluginOptions.query_vimeo)),tag:"iframe"},...e.embedQuery};const r=[];for(const t in this.query)r.push(this.query[t].pattern);Rh.#Ru=Rh.#Ru.concat(this.pluginOptions.extensions||[]),Rh.#zu=Rh.#zu.concat(e.urlPatterns||[]),this.state={onlyPercentage:this.pluginOptions.percentageOnlySize,sizeUnit:s,defaultRatio:100*this.pluginOptions.defaultRatio+"%"},this.sizeService=new Bh(this,i),this.uploadService=new Lh(this);const l=i.galleryButton;l&&this.$.eventManager.addEvent(l,"click",this.#yu.bind(this)),this.videoInputFile&&this.$.eventManager.addEvent(i.fileRemoveBtn,"click",this.#fu.bind(this)),this.videoUrlFile&&this.$.eventManager.addEvent(this.videoUrlFile,"input",this.#vu.bind(this)),this.videoInputFile&&this.videoUrlFile&&this.$.eventManager.addEvent(this.videoInputFile,"change",this.#bu.bind(this))}setState(t,e){this.state[t]=e}open(){this.modal.open()}retainFormat(){return{query:"iframe, video",method:async t=>{if(/^(iframe)$/i.test(t?.nodeName)&&!Rh.#Ou(t.src))return;const e=Wi.GetContainer(t);if(e&&e.container&&e.cover)return;this.#Cu(t,!0);const s=this.$.format.getLine(t);s&&(this.#cu=s.style.textAlign||s.style.float),this.#ku(t)}}}onFilePasteAndDrop({file:t}){/^video/.test(t.type)&&(this.submitFile([t]),this.$.focusManager.focus())}modalOn(t){t?this.videoInputFile&&this.pluginOptions.allowMultiple&&this.videoInputFile.removeAttribute("multiple"):this.videoInputFile&&this.pluginOptions.allowMultiple&&this.videoInputFile.setAttribute("multiple","multiple"),this.sizeService.on(t)}async modalAction(){this.#cu=this.modal.form.querySelector('input[name="suneditor_video_radio"]:checked').value;let t=!1;return this.videoInputFile&&this.videoInputFile.files.length>0?t=await this.submitFile(this.videoInputFile.files):this.videoUrlFile&&this.#hu.length>0&&(t=await this.submitURL(this.#hu)),t&&Ah.setTimeout(this.$.component.select.bind(this.$.component,this.#$c,Rh.key),0),t}modalInit(){Ml.OnChangeFile(this.fileModalWrapper,[]),this.videoInputFile&&(this.videoInputFile.value=""),this.videoUrlFile&&(this.#hu=this.previewSrc.textContent=this.videoUrlFile.value=""),this.videoInputFile&&this.videoUrlFile&&(this.videoUrlFile.disabled=!1,this.previewSrc.style.textDecoration=""),this.modal.form.querySelector('input[name="suneditor_video_radio"][value="none"]').checked=!0,this.#lu=!1,this.sizeService.init()}componentSelect(t){this.#Cu(t)}componentEdit(){this.modal.open()}async componentDestroy(t){const e=t||this.#$c,s=Re.query.getParentElement(e,Wi.is)||e,i=s.previousElementSibling||s.nextElementSibling,n=s.parentNode;!1!==await this.$.eventManager.triggerEvent("onVideoDeleteBefore",{element:e,container:s,align:this.#cu,url:this.#hu})&&(Re.utils.removeItem(s),this.modalInit(),n!==this.$.frameContext.get("wysiwyg")&&this.$.nodeTransform.removeAllParents(n,(function(t){return 0===t.childNodes.length}),null),this.$.focusManager.focusEdge(i),this.$.history.push(!1))}findProcessUrl(t){const e=this.query;for(const s in e){const i=e[s];if(i.pattern.test(t))return{origin:t,url:i.action(t),tag:i.tag}}return null}convertUrlYoutube(t){return/^http/.test(t)||(t="https://"+t),t=t.replace("watch?v=",""),/^\/\/.+\/embed\//.test(t)||(t=t.replace(t.match(/\/\/.+\//)[0],"//www.youtube.com/embed/").replace("&","?&")),t}convertUrlVimeo(t){return t.endsWith("/")&&(t=t.slice(0,-1)),t="https://player.vimeo.com/video/"+t.slice(t.lastIndexOf("/")+1)}addQuery(t,e){if(e.length>0)if(/\?/.test(t)){const s=t.split("?");t=s[0]+"?"+e+"&"+s[1]}else t+="?"+e;return t}create(t,e,s,i,n,o,r,l){let a=null;if(o){if((t=this.#$c).src!==e){const s=this.findProcessUrl(e);if(/^iframe$/i.test(s?.tag)&&!/^iframe$/i.test(t.nodeName)){const s=this.createIframeTag();s.src=e,t.replaceWith(s),this.#$c=t=s}else if(/^video$/i.test(s?.tag)&&!/^video$/i.test(t.nodeName)){const s=this.createVideoTag();s.src=e,t.replaceWith(s),this.#$c=t=s}else t.src=e}a=this.#pu}else{t.src=e,this.#$c=t;a=Wi.CreateContainer(t,"se-video-container").container}this.#$c=t,this.#pu=a,this.figure.open(t,{nonResizing:this.#lu,nonSizeInfo:!1,nonBorder:!1,figureTarget:!1,infoOnly:!0});const h=this.sizeService.resolveSize(s,i,t,o);s=h.width,i=h.height,this.figure.setAlign(t,n),this.fileManager.setFileData(t,r),o?(this.#Qc&&h.isChanged&&this.figure.isVertical||this.figure.setTransform(t,s,i,0),this.$.history.push(!1)):this.$.component.insert(a,{scrollTo:!!l,insertBehavior:l?this.pluginOptions.insertBehavior:"line"})}createIframeTag(t){const e=Re.utils.createElement("IFRAME");if(t)for(const s in t)e[s]=t[s];return this.#Pu(e),e}createVideoTag(t){const e=Re.utils.createElement("VIDEO");if(t)for(const s in t)e[s]=t[s];return this.#Du(e),e}async submitFile(t){if(0===t.length)return;let e=0;const s=[],i=this.pluginOptions.uploadSingleSizeLimit;for(let n,o,r=0,l=t.length;r<l;r++)if(n=t[r],/video/i.test(n.type)){if(o=n.size,i>0&&o>i){const t="[SUNEDITOR.videoUpload.fail] Size of uploadable single file: "+i/1e3+"KB",e=await this.$.eventManager.triggerEvent("onVideoUploadError",{error:t,limitSize:i,uploadSize:o,file:n});return this.$.ui.alertOpen(e===Oh?t:e||t,"error"),!1}s.push(n),e+=o}const n=this.pluginOptions.uploadSizeLimit,o=this.fileManager.getSize();if(n>0&&e+o>n){const t="[SUNEDITOR.videoUpload.fail] Size of uploadable total videos: "+n/1e3+"KB",s=await this.$.eventManager.triggerEvent("onVideoUploadError",{error:t,limitSize:n,currentSize:o,uploadSize:e});return this.$.ui.alertOpen(s===Oh?t:s||t,"error"),!1}const r={url:null,files:s,...this.#$u()},l=function(t,e,s){t(e=s||e,e.files)}.bind(this,this.uploadService.serverUpload.bind(this.uploadService),r),a=await this.$.eventManager.triggerEvent("onVideoUploadBefore",{info:r,handler:l});return void 0===a||!1!==a&&(null!==a&&"object"==typeof a&&l(a),void(!0!==a&&a!==Oh||l(null)))}async submitURL(t){if(!(t=this.#hu))return!1;if(/^<iframe.*\/iframe>$/.test(t)){if(0===(t=(new DOMParser).parseFromString(t,"text/html").querySelector("iframe").src).length)return!1}const e=this.findProcessUrl(t);e&&(t=e.url);const s={name:t.split("/").pop(),size:0},i={url:t,files:s,...this.#$u(),process:e},n=function(t,e){t=e||t,this.create(this[/^iframe$/i.test(t.process?.tag)?"createIframeTag":"createVideoTag"](),t.url,t.inputWidth,t.inputHeight,t.align,t.isUpdate,t.files,!0)}.bind(this,i),o=await this.$.eventManager.triggerEvent("onVideoUploadBefore",{info:i,handler:n});return void 0===o||!1!==o&&(null!==o&&"object"==typeof o&&n(o),!0!==o&&o!==Oh||n(null),!0)}#Cu(t,e=!1){if(!t)return;const s=this.figure.open(t,{nonResizing:this.#lu,nonSizeInfo:!1,nonBorder:!1,figureTarget:!1,infoOnly:e});this.#$c=t,this.#pu=s.container,this.#cu=s.align,t.style.float="";const i=String(s.width||s.originWidth||s.w||""),n=String(s.height||s.originHeight||s.h||"");this.sizeService.setOriginSize(i,n),this.videoUrlFile&&(this.#hu=this.previewSrc.textContent=this.videoUrlFile.value=this.#$c.src||this.#$c.querySelector("source")?.src||"");(this.modal.form.querySelector('input[name="suneditor_video_radio"][value="'+this.#cu+'"]')||this.modal.form.querySelector('input[name="suneditor_video_radio"][value="none"]')).checked=!0,this.#Qc&&this.sizeService.ready(s,t)}#$u(){const{w:t,h:e}=this.sizeService.getInputSize();return{inputWidth:t,inputHeight:e,align:this.#cu,isUpdate:this.modal.isUpdate,element:this.#$c}}#ku(t){if(!t)return;/^video$/i.test(t.nodeName)?this.#Du(t):/^iframe$/i.test(t.nodeName)&&this.#Pu(t);const e=t,s=t.cloneNode(!0),i=Wi.CreateContainer(s,"se-video-container"),n=i.container,o=Wi.GetContainer(e)?.container?.querySelector("figcaption");let r=null;o&&(r=Re.utils.createElement("figcaption"),r.innerHTML=o.innerHTML,Re.utils.removeItem(o),i.cover.appendChild(r)),this.figure.open(s,{nonResizing:this.#lu,nonSizeInfo:!1,nonBorder:!1,figureTarget:!1,infoOnly:!0});const l=(s.getAttribute("data-se-size")||",").split(","),a=l[0]||e.width||"",h=l[1]||e.height||this.state.defaultRatio||"";this.sizeService.applySize(a,h);const c=this.$.format.getLine(e);return c&&(this.#cu=c.style.textAlign||c.style.float),this.figure.setAlign(s,this.#cu),this.figure.retainFigureFormat(n,this.#$c,null,this.fileManager),s}#Du(t){t.setAttribute("controls","true");const e=this.pluginOptions.videoTagAttributes;if(e)for(const s in e)t.setAttribute(s,e[s])}#Pu(t){t.frameBorder="0",t.allowFullscreen=!0;const e=this.pluginOptions.iframeTagAttributes;if(e)for(const s in e)t.setAttribute(s,e[s])}#fu(){this.videoInputFile.value="",this.videoUrlFile&&(this.videoUrlFile.disabled=!1,this.previewSrc.style.textDecoration=""),Ml.OnChangeFile(this.fileModalWrapper,[])}#vu(t){const e=Re.query.getEventTarget(t).value.trim();/^<iframe.*\/iframe>$/.test(e)?(this.#hu=e,this.previewSrc.textContent='<IFrame :src=".."></IFrame>'):this.#hu=this.previewSrc.textContent=e?this.$.options.get("defaultUrlProtocol")&&!e.includes("://")&&0!==e.indexOf("#")?this.$.options.get("defaultUrlProtocol")+e:e.includes("://")?e:"/"+e:""}#yu(){this.$.plugins.videoGallery.open(this.#Tu.bind(this))}#Tu(t){this.#hu=this.previewSrc.textContent=this.videoUrlFile.value=t.getAttribute("data-command")||t.src,this.videoUrlFile.focus()}#bu(t){this.videoInputFile.value?(this.videoUrlFile.disabled=!0,this.previewSrc.style.textDecoration="line-through"):(this.videoUrlFile.disabled=!1,this.previewSrc.style.textDecoration="");const e=Re.query.getEventTarget(t);Ml.OnChangeFile(this.fileModalWrapper,e.files)}}const zh=Rh,{NO_EVENT:Ph,ON_OVER_COMPONENT:Dh}=Le;class Fh extends Wl{static key="audio";static className="";static component(t){return/^AUDIO$/i.test(t?.nodeName)?t:null}#Fu;#Hu;#qu="";#$c=null;constructor(t,e){super(t),this.title=this.$.lang.audio,this.icon="audio",this.pluginOptions={defaultWidth:e.defaultWidth?ze.is(e.defaultWidth)?e.defaultWidth+"px":e.defaultWidth:"",defaultHeight:e.defaultHeight?ze.is(e.defaultHeight)?e.defaultHeight+"px":e.defaultHeight:"",createFileInput:!!e.createFileInput,createUrlInput:void 0===e.createUrlInput||!e.createFileInput||e.createUrlInput,uploadUrl:"string"==typeof e.uploadUrl?e.uploadUrl:null,uploadHeaders:e.uploadHeaders||null,uploadSizeLimit:ze.get(e.uploadSizeLimit,0),uploadSingleSizeLimit:ze.get(e.uploadSingleSizeLimit,0),allowMultiple:!!e.allowMultiple,acceptedFormats:"string"!=typeof e.acceptedFormats||"*"===e.acceptedFormats.trim()?"audio/*":e.acceptedFormats.trim()||"audio/*",audioTagAttributes:e.audioTagAttributes||null,insertBehavior:e.insertBehavior};const s=function({lang:t,icons:e,plugins:s},i){let n=`\n <form method="post" enctype="multipart/form-data">\n <div class="se-modal-header">\n <button type="button" data-command="close" class="se-btn se-close-btn" title="${t.close}" aria-label="${t.close}">\n ${e.cancel}\n </button>\n <span class="se-modal-title">${t.audio_modal_title}</span>\n </div>\n <div class="se-modal-body">`;i.createFileInput&&(n+=`\n <div class="se-modal-form">\n <label>${t.audio_modal_file}</label>\n ${Ml.CreateFileInput({lang:t,icons:e},i)}\n </div>`);i.createUrlInput&&(n+=`\n <div class="se-modal-form">\n <label>${t.audio_modal_url}</label>\n\t\t\t<div class="se-modal-form-files">\n\t\t\t\t<input class="se-input-form se-input-url" data-focus type="text" />\n\t\t\t\t${s.audioGallery?`<button type="button" class="se-btn se-tooltip se-modal-files-edge-button __se__gallery" aria-label="${t.audioGallery}">\n\t\t\t\t\t\t\t${e.audio_gallery}\n\t\t\t\t\t\t\t${Re.utils.createTooltipInner(t.audioGallery)}\n\t\t\t\t\t\t\t</button>`:""}\n\t\t\t</div>\n <pre class="se-link-preview"></pre>\n </div>`);return n+=`\n </div>\n <div class="se-modal-footer">\n <button type="submit" class="se-btn-primary" title="${t.submitButton}" aria-label="${t.submitButton}">\n <span>${t.submitButton}</span>\n </button>\n </div>\n </form>`,Re.utils.createElement("DIV",{class:"se-modal-content"},n)}(this.$,this.pluginOptions),i=function({lang:t,icons:e}){const s=`\n <div class="se-arrow se-arrow-up"></div>\n <div class="link-content">\n <div class="se-btn-group">\n <button type="button" data-command="update" tabindex="-1" class="se-btn se-tooltip">\n ${e.edit}\n <span class="se-tooltip-inner">\n <span class="se-tooltip-text">${t.edit}</span>\n </span>\n </button>\n <button type="button" data-command="copy" tabindex="-1" class="se-btn se-tooltip">\n ${e.copy}\n <span class="se-tooltip-inner">\n <span class="se-tooltip-text">${t.copy}</span>\n </span>\n </button>\n <button type="button" data-command="delete" tabindex="-1" class="se-btn se-tooltip">\n ${e.delete}\n <span class="se-tooltip-inner">\n <span class="se-tooltip-text">${t.remove}</span>\n </span>\n </button>\n </div>\n </div>`;return Re.utils.createElement("DIV",{class:"se-controller"},s)}(this.$);this.modal=new Ml(this,this.$,s),this.controller=new Mi(this,this.$,i,{position:"bottom",disabled:!0}),this.fileManager=new Bl(this,this.$,{query:"audio",loadEventName:"onAudioLoad",actionEventName:"onAudioAction"}),this.figure=new Wi(this,this.$,null,{}),this.fileModalWrapper=s.querySelector(".se-flex-input-wrapper"),this.audioInputFile=s.querySelector(".__se__file_input"),this.audioUrlFile=s.querySelector(".se-input-url"),this.preview=s.querySelector(".se-link-preview"),this.#Fu=this.pluginOptions.defaultWidth,this.#Hu=this.pluginOptions.defaultHeight;const n=s.querySelector(".__se__gallery");n&&this.$.eventManager.addEvent(n,"click",this.#yu.bind(this)),this.audioInputFile&&(this.$.eventManager.addEvent(s.querySelector(".se-modal-files-edge-button"),"click",this.#fu.bind(this,this.audioUrlFile,this.preview)),this.audioUrlFile&&this.$.eventManager.addEvent(this.audioInputFile,"change",this.#Wu.bind(this))),this.audioUrlFile&&this.$.eventManager.addEvent(this.audioUrlFile,"input",this.#vu.bind(this))}open(){this.modal.open()}retainFormat(){return{query:"audio",method:t=>{const e=Wi.GetContainer(t);if(e&&e.container&&e.cover)return;this.#Du(t);const s=Wi.CreateContainer(t.cloneNode(!0),"se-flex-component");this.figure.retainFigureFormat(s.container,t,null,this.fileManager)}}}onFilePasteAndDrop({file:t}){/^audio/.test(t.type)&&(this.submitFile([t]),this.$.focusManager.focus())}modalOn(t){t?this.#$c?(this.#qu=this.preview.textContent=this.audioUrlFile.value=this.#$c.src,this.audioInputFile&&this.pluginOptions.allowMultiple&&this.audioInputFile.removeAttribute("multiple")):this.audioInputFile&&this.pluginOptions.allowMultiple&&this.audioInputFile.removeAttribute("multiple"):this.audioInputFile&&this.pluginOptions.allowMultiple&&this.audioInputFile.setAttribute("multiple","multiple")}async modalAction(){return this.audioInputFile&&this.audioInputFile?.files.length>0?await this.submitFile(this.audioInputFile.files):!!(this.audioUrlFile&&this.#qu.length>0)&&await this.submitURL(this.#qu)}modalInit(){Ml.OnChangeFile(this.fileModalWrapper,[]),this.audioInputFile&&(this.audioInputFile.value=""),this.audioUrlFile&&(this.#qu=this.preview.textContent=this.audioUrlFile.value=""),this.audioInputFile&&this.audioUrlFile&&(this.audioUrlFile.disabled=!1,this.preview.style.textDecoration="")}controllerAction(t){switch(t.getAttribute("data-command")){case"update":this.audioUrlFile&&(this.#qu=this.preview.textContent=this.audioUrlFile.value=this.#$c.src),this.open();break;case"copy":{const t=Wi.GetContainer(this.#$c);this.$.component.copy(t.container);break}case"delete":this.componentDestroy(null)}}componentSelect(t){this.figure.open(t,{nonResizing:!0,nonSizeInfo:!0,nonBorder:!0,figureTarget:!0,infoOnly:!1}),this.#Cu(t)}async componentDestroy(t){const e=t||this.#$c,s=Wi.GetContainer(e),i=s.container||e,n=i.previousElementSibling||i.nextElementSibling;if(!1===await this.$.eventManager.triggerEvent("onAudioDeleteBefore",{element:e,container:s,url:e.getAttribute("src")}))return;const o=i.parentNode;Re.utils.removeItem(i),this.modalInit(),this.controller.close(),o!==this.$.frameContext.get("wysiwyg")&&this.$.nodeTransform.removeAllParents(o,(function(t){return 0===t.childNodes.length}),null),this.$.focusManager.focusEdge(n),this.$.history.push(!1)}async submitFile(t){if(0===t.length)return!1;let e=0;const s=[],i=this.pluginOptions.uploadSingleSizeLimit;for(let n,o,r=0,l=t.length;r<l;r++)if(n=t[r],/audio/i.test(n.type)){if(o=n.size,i>0&&o>i){const t="[SUNEDITOR.audioUpload.fail] Size of uploadable single file: "+i/1e3+"KB",e=await this.$.eventManager.triggerEvent("onAudioUploadError",{error:t,limitSize:i,uploadSize:o,file:n});return this.$.ui.alertOpen(e===Ph?t:e||t,"error"),!1}s.push(n),e+=o}const n=this.pluginOptions.uploadSizeLimit;if(n>0&&e+this.fileManager.getSize()>n){const t="[SUNEDITOR.audioUpload.fail] Size of uploadable total audios: "+n/1e3+"KB",s=await this.$.eventManager.triggerEvent("onAudioUploadError",{error:t,limitSize:n,currentSize:this.fileManager.getSize(),uploadSize:e});return this.$.ui.alertOpen(s===Ph?t:s||t,"error"),!1}const o={files:s,isUpdate:this.modal.isUpdate,element:this.#$c},r=function(t,e,s){t(s=e||s,s.files)}.bind(this,this.#Uu.bind(this),o),l=await this.$.eventManager.triggerEvent("onAudioUploadBefore",{info:o,handler:r});return void 0===l||!!l&&(null!==l&&"object"==typeof l&&r(l),!0!==l&&l!==Ph||r(null),!0)}async submitURL(t){if(0===t.length)return!1;const e={name:t.split("/").pop(),size:0},s={url:t,files:e,isUpdate:this.modal.isUpdate,element:this.#Vu()},i=function(t,e,s){t((s=e||s).element,s.url,s.files,s.isUpdate,!0)}.bind(this,this.create.bind(this),s),n=await this.$.eventManager.triggerEvent("onAudioUploadBefore",{info:s,handler:i});return void 0===n||!!n&&(null!==n&&"object"==typeof n&&i(n),!0!==n&&n!==Ph||i(null),!0)}create(t,e,s,i,n){if(i){if(this.#$c&&(t=this.#$c),this.fileManager.setFileData(t,s),!t||t.src===e)return void this.$.component.select(t,Fh.key);t.src=e,this.$.component.select(t,Fh.key)}else{this.fileManager.setFileData(t,s),t.src=e;const i=Wi.CreateContainer(t,"se-flex-component");if(!this.$.component.insert(i.container,{scrollTo:!!n,insertBehavior:n?this.pluginOptions.insertBehavior:"line"}))return void(n&&this.$.focusManager.focus());if(!this.$.options.get("componentInsertBehavior")){const t=this.$.format.addLine(i.container,null);t&&this.$.selection.setRange(t,0,t,0)}}i&&this.$.history.push(!1)}#Cu(t){yi.get("__overInfo")!==Dh&&(this.#$c=t,this.controller.open(t,null,{isWWTarget:!1,addOffset:null}))}#tc(t,e){const s=e.result;for(let e,i,n=0,o=s.length;n<o;n++)i=t.isUpdate?t.element:this.#Vu(),e={name:s[n].name,size:s[n].size},this.create(i,s[n].url,e,t.isUpdate,n===o-1)}#Vu(){const t=this.#Fu,e=this.#Hu,s=Re.utils.createElement("AUDIO",{style:(t?"width:"+t+"; ":"")+(e?"height:"+e+";":"")});return this.#Du(s),s}#Du(t){t.setAttribute("controls","true");const e=this.pluginOptions.audioTagAttributes;if(e)for(const s in e)t.setAttribute(s,e[s])}#Uu(t,e){if(!e)return;const s=this.modal.isUpdate?[e[0]]:e;this.fileManager.upload(this.pluginOptions.uploadUrl,this.pluginOptions.uploadHeaders,s,this.#su.bind(this,t),this.#ec.bind(this))}async#ec(t){const e=await this.$.eventManager.triggerEvent("onAudioUploadError",{error:t}),s=e===Ph?t.errorMessage:e||t.errorMessage;this.$.ui.alertOpen(s,"error"),console.error("[SUNEDITOR.plugin.audio.error]",s)}async#su(t,e){if(await this.$.eventManager.triggerEvent("audioUploadHandler",{xmlHttp:e,info:t})===Ph){const s=JSON.parse(e.responseText);s.errorMessage?this.#ec(s):this.#tc(t,s)}}#vu(t){const e=Re.query.getEventTarget(t).value.trim();this.#qu=this.preview.textContent=e?this.$.options.get("defaultUrlProtocol")&&!e.includes("://")&&0!==e.indexOf("#")?this.$.options.get("defaultUrlProtocol")+e:e.includes("://")?e:"/"+e:""}#yu(){this.$.plugins.audioGallery.open(this.#Tu.bind(this))}#Tu(t){this.#qu=this.preview.textContent=this.audioUrlFile.value=t.getAttribute("data-command")||t.src,this.audioUrlFile.focus()}#fu(t,e){this.audioInputFile.value="",t&&(t.disabled=!1,e.style.textDecoration=""),Ml.OnChangeFile(this.fileModalWrapper,[])}#Wu(t){const e=Re.query.getEventTarget(t);this.audioInputFile.value?(this.audioUrlFile.disabled=!0,this.preview.style.textDecoration="line-through"):(this.audioUrlFile.disabled=!1,this.preview.style.textDecoration=""),Ml.OnChangeFile(this.fileModalWrapper,e.files)}}const Hh=Fh,{_w:qh,NO_EVENT:Wh}=Le;class Uh extends Wl{static key="embed";static className="";static component(t){const e=t.children;let s="",i=null;if(Re.check.isIFrame(t)&&(i=t,s=t.src),!s&&/^DIV$/i.test(t?.nodeName)&&Re.check.isIFrame(e[0])&&(i=e[0],s=i.src),!s&&Re.utils.hasClass(t,"se-embed-container")){i=Re.query.getChildNode(t,(t=>t.src||t.href)),s=i?.src||i?.href}if(/^BLOCKQUOTE$/i.test(t?.nodeName)){const e=t.querySelector("a");if(e&&e.href)return i=t,s=e.href,this.#Ou(s)?i:null}return s?this.#Ou(s)?i:null:i}static#Ou(t){return t=t?.toLowerCase()||"",!!this.#zu.some((e=>e.test(t)))}static#ju(t,e){return!!t&&e.some((e=>e instanceof RegExp?e.test(t):t.startsWith(e)))}static#zu=null;#Nu;#Bu;#jd;#Gd;#Qc;#Gu;#lu;#hu="";#cu="none";#$c=null;#uu=null;#pu=null;#Kd={w:0,h:0};constructor(t,e){super(t),this.title=this.$.lang.embed,this.icon="embed",this.pluginOptions={canResize:void 0===e.canResize||e.canResize,showHeightInput:void 0===e.showHeightInput||!!e.showHeightInput,defaultWidth:e.defaultWidth&&ze.get(e.defaultWidth,0)?ze.is(e.defaultWidth)?e.defaultWidth+"px":e.defaultWidth:"",defaultHeight:e.defaultHeight&&ze.get(e.defaultHeight,0)?ze.is(e.defaultHeight)?e.defaultHeight+"px":e.defaultHeight:"",percentageOnlySize:!!e.percentageOnlySize,uploadUrl:"string"==typeof e.uploadUrl?e.uploadUrl:null,uploadHeaders:e.uploadHeaders||null,uploadSizeLimit:ze.get(e.uploadSizeLimit,0),uploadSingleSizeLimit:ze.get(e.uploadSingleSizeLimit,0),iframeTagAttributes:e.iframeTagAttributes||null,query_youtube:e.query_youtube||"",query_vimeo:e.query_vimeo||"",scriptSrcWhitelist:Array.isArray(e.scriptSrcWhitelist)?e.scriptSrcWhitelist:[],insertBehavior:e.insertBehavior};const s=this.pluginOptions.percentageOnlySize?"%":"px",i=function({lang:t,icons:e},s){let i=`\n\t<form method="post" enctype="multipart/form-data">\n\t\t<div class="se-modal-header">\n\t\t\t<button type="button" data-command="close" class="se-btn se-close-btn" title="${t.close}" aria-label="${t.close}">\n\t\t\t${e.cancel}\n\t\t\t</button>\n\t\t\t<span class="se-modal-title">${t.embed_modal_title}</span>\n\t\t</div>\n\t\t<div class="se-modal-body">\n\t\t\t<div class='se-modal-form'>\n\t\t\t\t<label>${t.embed_modal_source}</label>\n\t\t\t\t<input class='se-input-form se-input-url' type='text' data-focus />\n\t\t\t\t<pre class='se-link-preview'></pre>\n\t\t\t</div>`;if(s.canResize){const n=s.percentageOnlySize,o=n?' style="display: none !important;"':"",r=s.showHeightInput?"":' style="display: none !important;"',l=s.showRatioOption?"":' style="display: none !important;"',a=n||s.showHeightInput||s.showRatioOption?"":' style="display: none !important;"';i+=`\n\t\t\t<div class="se-modal-form">\n\t\t\t\t<div class="se-modal-size-text">\n\t\t\t\t\t<label class="size-w">${t.width}</label>\n\t\t\t\t\t<label class="se-modal-size-x"> </label>\n\t\t\t\t\t<label class="size-h"${r}>${t.height}</label>\n\t\t\t\t\t<label class="size-h"${l}>(${t.ratio})</label>\n\t\t\t\t</div>\n\t\t\t\t<input class="se-input-control _se_size_x" placeholder="auto"${n?' type="number" min="1"':'type="text"'}${n?' max="100"':""}/>\n\t\t\t\t<label class="se-modal-size-x"${a}>${n?"%":"x"}</label>\n\t\t\t\t<input class="se-input-control _se_size_y" placeholder="auto"\n\t\t\t\t${n?' type="number" min="1"':'type="text"'}${n?' max="100"':""}${r}/>\n\t\t\t\t<button type="button" title="${t.revert}" aria-label="${t.revert}" class="se-btn se-modal-btn-revert">${e.revert}</button>\n\t\t\t</div>\n\t\t\t<div class="se-modal-form se-modal-form-footer"${o}${a}>\n\t\t\t\t<label>\n\t\t\t\t\t<input type="checkbox" class="se-modal-btn-check _se_check_proportion" /> \n\t\t\t\t\t<span>${t.proportion}</span>\n\t\t\t\t</label>\n\t\t\t</div>`}i+=`\n\t\t</div>\n\t\t<div class="se-modal-footer">\n\t\t\t<div class="se-figure-align">\n\t\t\t\t<label><input type="radio" name="suneditor_embed_radio" class="se-modal-btn-radio" value="none" checked>${t.basic}</label>\n\t\t\t\t<label><input type="radio" name="suneditor_embed_radio" class="se-modal-btn-radio" value="left">${t.left}</label>\n\t\t\t\t<label><input type="radio" name="suneditor_embed_radio" class="se-modal-btn-radio" value="center">${t.center}</label>\n\t\t\t\t<label><input type="radio" name="suneditor_embed_radio" class="se-modal-btn-radio" value="right">${t.right}</label>\n\t\t\t</div>\n\t\t\t<button type="submit" class="se-btn-primary" title="${t.submitButton}" aria-label="${t.submitButton}"><span>${t.submitButton}</span></button>\n\t\t</div>\n\t</form>`;const n=Re.utils.createElement("DIV",{class:"se-modal-content"},i);return{html:n,figureAlignBtn:n.querySelector(".se-figure-align"),fileModalWrapper:n.querySelector(".se-flex-input-wrapper"),embedInput:n.querySelector(".se-input-url"),previewSrc:n.querySelector(".se-link-preview"),proportion:n.querySelector("._se_check_proportion"),inputX:n.querySelector("._se_size_x"),inputY:n.querySelector("._se_size_y"),revertBtn:n.querySelector(".se-modal-btn-revert")}}(this.$,this.pluginOptions),n=e.controls||(this.pluginOptions.canResize?[["resize_auto,75,50","align","edit","revert","copy","remove"]]:[["align","edit","copy","remove"]]);n.some((t=>t.includes("align")))||(i.figureAlignBtn.style.display="none"),this.modal=new Ml(this,this.$,i.html),this.figure=new Wi(this,this.$,n,{sizeUnit:s}),this.fileModalWrapper=i.fileModalWrapper,this.embedInput=i.embedInput,this.focusElement=this.embedInput,this.previewSrc=i.previewSrc,this.sizeUnit=s,this.proportion=null,this.inputX=null,this.inputY=null,this.#Nu=this.pluginOptions.defaultWidth,this.#Bu=this.pluginOptions.defaultHeight,this.#jd="auto"===this.pluginOptions.defaultWidth?"":this.pluginOptions.defaultWidth,this.#Gd="auto"===this.pluginOptions.defaultHeight?"":this.pluginOptions.defaultHeight,this.#Qc=this.pluginOptions.canResize,this.#Gu=this.pluginOptions.percentageOnlySize,this.#lu=!this.#Qc||!this.pluginOptions.showHeightInput||this.#Gu,this.query={facebook:{pattern:/(?:https?:\/\/)?(?:www\.)?(?:facebook\.com)\/(.+)/i,action:t=>`https://www.facebook.com/plugins/post.php?href=${encodeURIComponent(t)}&show_text=true&width=500`,tag:"iframe"},twitter:{pattern:/^(?:https?:\/\/)?(?:(?:www\.)?(?:twitter\.com|x\.com)\/(?:[^/?#]+\/)?status\/\d+(?:[/?#]|$)|platform\.twitter\.com\/embed\/Tweet\.html(?:[?#].*)?$)/i,action:t=>`https://platform.twitter.com/embed/Tweet.html?url=${encodeURIComponent(t)}`,tag:"iframe"},instagram:{pattern:/(?:https?:\/\/)?(?:www\.)?(?:instagram\.com)\/p\/(.+)/i,action:t=>`https://www.instagram.com/p/${t.match(this.query.instagram.pattern)[1]}/embed`,tag:"iframe"},linkedin:{pattern:/(?:https?:\/\/)?(?:www\.)?(?:linkedin\.com)\/(.+)\/(.+)/i,action:t=>`https://www.linkedin.com/embed/feed/update/${encodeURIComponent(t.split("/").pop())}`,tag:"iframe"},pinterest:{pattern:/(?:https?:\/\/)?(?:www\.)?(?:pinterest\.com)\/pin\/(.+)/i,action:t=>`https://assets.pinterest.com/ext/embed.html?id=${t.match(this.query.pinterest.pattern)[1]}`,tag:"iframe"},spotify:{pattern:/(?:https?:\/\/)?(?:open\.)?(?:spotify\.com)\/(track|album|playlist|show|episode)\/(.+)/i,action:t=>{const e=t.match(this.query.spotify.pattern);return`https://open.spotify.com/embed/${e[1]}/${e[2]}`},tag:"iframe"},codepen:{pattern:/(?:https?:\/\/)?(?:www\.)?(?:codepen\.io)\/(.+)\/pen\/(.+)/i,action:t=>{const[,e,s]=t.match(this.query.codepen.pattern);return`https://codepen.io/${e}/embed/${s}`},tag:"iframe"},...e.embedQuery};const o=[];for(const t in this.query)o.push(this.query[t].pattern);Uh.#zu=o.concat(e.urlPatterns||[]),this.$.eventManager.addEvent(this.embedInput,"input",this.#vu.bind(this)),this.#Qc&&(this.proportion=i.proportion,this.inputX=i.inputX,this.inputY=i.inputY,this.inputX.value=this.pluginOptions.defaultWidth,this.inputY.value=this.pluginOptions.defaultHeight,this.$.eventManager.addEvent(this.inputX,"keyup",this.#Qd.bind(this,"x")),this.$.eventManager.addEvent(this.inputY,"keyup",this.#Qd.bind(this,"y")),this.$.eventManager.addEvent(i.revertBtn,"click",this.#tu.bind(this)))}open(){this.modal.open()}retainFormat(){return{query:"iframe",method:async t=>{if(!Uh.#Ou(t.src))return;const e=Wi.GetContainer(t);if(e&&e.container&&e.cover)return;this.#Cu(t,!0);const s=this.$.format.getLine(t);s&&(this.#cu=s.style.textAlign||s.style.float),this.#ku(t)}}}modalOn(t){!t&&this.#Qc?(this.inputX.value=this.#jd="auto"===this.pluginOptions.defaultWidth?"":this.pluginOptions.defaultWidth,this.inputY.value=this.#Gd="auto"===this.pluginOptions.defaultHeight?"":this.pluginOptions.defaultHeight,this.proportion.disabled=!0):t&&(this.#hu=this.previewSrc.textContent=this.embedInput.value=this.#uu.getAttribute("data-se-origin")||"")}async modalAction(){this.#cu=this.modal.form.querySelector('input[name="suneditor_embed_radio"]:checked').value;let t=!1;return this.#hu.length>0&&(t=await this.submitSRC(this.#hu)),t&&qh.setTimeout(this.$.component.select.bind(this.$.component,this.#$c,Uh.key),0),t}modalInit(){Ml.OnChangeFile(this.fileModalWrapper,[]),this.#hu=this.previewSrc.textContent=this.embedInput.value="",this.modal.form.querySelector('input[name="suneditor_embed_radio"][value="none"]').checked=!0,this.#Kd={w:0,h:0},this.#lu=!1,this.#Qc&&(this.inputX.value=this.pluginOptions.defaultWidth===this.#Nu?"":this.pluginOptions.defaultWidth,this.inputY.value=this.pluginOptions.defaultHeight===this.#Bu?"":this.pluginOptions.defaultHeight,this.proportion.checked=!1,this.proportion.disabled=!0)}componentSelect(t){this.#Cu(t)}componentEdit(){this.modal.open()}async componentDestroy(t){const e=t||this.#$c,s=Re.query.getParentElement(e,Wi.is)||e,i=s.previousElementSibling||s.nextElementSibling,n=s.parentNode;!1!==await this.$.eventManager.triggerEvent("onEmbedDeleteBefore",{element:e,container:s,align:this.#cu,url:this.#hu})&&(Re.utils.removeItem(s),this.modalInit(),n!==this.$.frameContext.get("wysiwyg")&&this.$.nodeTransform.removeAllParents(n,(function(t){return 0===t.childNodes.length}),null),this.$.focusManager.focusEdge(i),this.$.history.push(!1))}findProcessUrl(t){const e=this.query;for(const s in e){const i=e[s];if(i.pattern.test(t))return{origin:t,url:i.action(t),tag:i.tag}}return null}async submitSRC(t){if(!(t||=this.#hu))return!1;let e=null;if(/^<iframe\s|^<blockquote\s/i.test(t)){const s=(new DOMParser).parseFromString(t,"text/html").body.children;if(0===s.length)return!1;for(let t=0;t<s.length;t++){const e=s[t];if(/^iframe$/i.test(e.nodeName)&&!Uh.#Ou(e.getAttribute("src")||""))return!1;const i=e.querySelectorAll?.("iframe");if(i)for(let t=0;t<i.length;t++)if(!Uh.#Ou(i[t].getAttribute("src")||""))return!1}e={children:s,...this.#$u(),process:null}}else{const s=this.findProcessUrl(t);if(!s)return!1;t=s.url,e={...this.#$u(),url:t,process:s}}const s=function(e,s,i){e(t,(s=i||s).process,s.url,s.children,s.inputWidth,s.inputHeight,s.align,s.isUpdate)}.bind(this,this.#Ku.bind(this),e),i=await this.$.eventManager.triggerEvent("onEmbedInputBefore",{...e,handler:s});return void 0===i||!1!==i&&(null!==i&&"object"==typeof i&&s(i),!0!==i&&i!==Wh||s(null),!0)}#Cu(t,e=!1){if(!t)return;const s=this.figure.open(t,{nonResizing:this.#lu,nonSizeInfo:!1,nonBorder:!1,figureTarget:!1,infoOnly:e});if(this.#$c=t,this.#uu=s.cover,this.#pu=s.container,this._caption=s.caption,this.#cu=s.align,!this.#uu?.getAttribute?.("data-se-origin")){const e=t?.getAttribute?.("src")||t?.querySelector?.("a")?.href;e&&Uh.#Ou(e)&&this.#uu.setAttribute("data-se-origin",e)}t.style.float="",this.#jd=String(s.originWidth||s.w||""),this.#Gd=String(s.originHeight||s.h||"");if((this.modal.form.querySelector('input[name="suneditor_embed_radio"][value="'+this.#cu+'"]')||this.modal.form.querySelector('input[name="suneditor_embed_radio"][value="none"]')).checked=!0,!this.#Qc)return;const i=this.#Gu&&this.figure.isVertical,{dw:n,dh:o}=this.figure.getSize(t);this.inputX.value="auto"===n?"":n,this.inputY.value="auto"===o?"":o,this.proportion.checked=!0,this.inputX.disabled=!!i,this.inputY.disabled=!!i,this.proportion.disabled=!!i,this.#Kd=this.proportion.checked?s.ratio:{w:0,h:0}}#Yu(){const t=Re.utils.createElement("IFRAME");return this.#Pu(t),t}#Xu(){return Re.utils.createElement("BLOCKQUOTE")}#Ku(t,e,s,i,n,o,r,l){let a=null,h=null,c=null,d=null;if(l){if(a=this.#$c,a.src!==s){const t=this.findProcessUrl(s);if(/^iframe$/i.test(t?.tag)&&!/^iframe$/i.test(a.nodeName)){const t=this.#Yu();t.src=s,a.replaceWith(t),a=t}else if(/^blockquote$/i.test(t?.tag)&&!/^blockquote$/i.test(a.nodeName)){const t=this.#Xu();t.setAttribute("src",s),a.replaceWith(t),a=t}else a.src=s}c=this.#pu,h=Re.query.getParentElement(a,"FIGURE")}else if(e){a=this.#Yu(),a.src=s;const t=Wi.CreateContainer(a,"se-embed-container");h=t.cover,c=t.container}else{a=i[0];const t=Wi.CreateContainer(a,"se-embed-container");h=t.cover,c=t.container;const e=Array.from(i),s=this.pluginOptions.scriptSrcWhitelist;for(const t of e)if(/^script$/i.test(t.nodeName)){const e=t.getAttribute("src")||"";if(!Uh.#ju(e,s))continue;d=Re.utils.createElement("script",{src:e,async:"true"},null)}else h.appendChild(t)}this.#$c=a,this.#uu=h,this.#pu=c,this.figure.open(a,{nonResizing:this.#lu,nonSizeInfo:!1,nonBorder:!1,figureTarget:!1,infoOnly:!0}),n||=this.#Nu,o||=this.#Bu;const u=this.figure.getSize(a),p=u.w!==n||u.h!==o,g=!l||p;if(g&&this.#Zu(n,o),this.figure.setAlign(a,r),h.setAttribute("data-se-origin",t),l)this.#Qc&&g&&this.figure.isVertical||this.figure.setTransform(a,n,o,0),d||this.$.history.push(!1);else{if(this.$.component.insert(c,{skipHistory:!0,scrollTo:!1,insertBehavior:this.pluginOptions.insertBehavior}),d)try{this.$.history.pause(),d.onload=()=>{Re.utils.removeItem(d),d=null},h.appendChild(d);const t=new MutationObserver((e=>{for(const s of e)if("childList"===s.type&&!a.parentElement){this.$.history.resume(),this.$.history.push(!1),t.disconnect();break}}));t.observe(this.$.frameContext.get("wysiwyg"),{subtree:!0,childList:!0})}catch(t){this.$.history.resume(),console.warn("[SUNEDITOR] Embed tag script load error.",t)}if(!this.$.options.get("componentInsertBehavior")){const t=this.$.format.addLine(c,null);t&&this.$.selection.setRange(t,0,t,0)}}}#ku(t){if(!t)return;this.#Pu(t);const e=t;t=t.cloneNode(!0);const s=Wi.CreateContainer(t,"se-embed-container").container;this.figure.open(t,{nonResizing:this.#lu,nonSizeInfo:!1,nonBorder:!1,figureTarget:!1,infoOnly:!0});const i=(t.getAttribute("data-se-size")||",").split(","),n=i[0]||e.width||"",o=i[1]||e.height||"";this.#Zu(n,o);const r=this.$.format.getLine(e);return r&&(this.#cu=r.style.textAlign||r.style.float),this.figure.setAlign(t,this.#cu),this.figure.retainFigureFormat(s,this.#$c,null,null),t}#Zu(t,e){t||=this.inputX?.value||this.pluginOptions.defaultWidth,e||=this.inputY?.value||this.pluginOptions.defaultHeight,this.#Gu&&(t?/%$/.test(t+"")||(t+="%"):t="100%"),this.figure.setSize(t,e)}#$u(){return{inputWidth:this.inputX?.value||"",inputHeight:this.inputY?.value||"",align:this.#cu,isUpdate:this.modal.isUpdate,element:this.#$c}}#Pu(t){t.frameBorder="0",t.allowFullscreen=!0;const e=this.pluginOptions.iframeTagAttributes;if(e)for(const s in e)t.setAttribute(s,e[s])}#vu(t){const e=Re.query.getEventTarget(t).value.trim();/^<iframe.*\/iframe>$/.test(e)?(this.#hu=e,this.previewSrc.textContent='<IFrame :src=".."></IFrame>'):this.#hu=this.previewSrc.textContent=e?this.$.options.get("defaultUrlProtocol")&&!e.includes("://")&&0!==e.indexOf("#")?this.$.options.get("defaultUrlProtocol")+e:e.includes("://")?e:"/"+e:""}#tu(){this.#Gu?this.inputX.value=Number(this.#jd)>100?"100":this.#jd:(this.inputX.value=this.#jd,this.inputY.value=this.#Gd)}#Qd(t,e){if(Pe.isSpace(e.code))return void e.preventDefault();const s=Re.query.getEventTarget(e);if("x"===t&&this.#Gu&&Number(s.value)>100)s.value="100";else if(this.proportion.checked){const e=Wi.CalcRatio(this.inputX.value,this.inputY.value,this.sizeUnit,this.#Kd);"x"===t?this.inputY.value=String(e.h):this.inputX.value=String(e.w)}}}const Vh=Uh,{_w:jh,_d:Gh}=Le;class Kh extends Wl{static key="math";static className="";static component(t){return Re.utils.hasClass(t,"se-math|katex")&&Re.check.isComponentContainer(t)?t:null}#$c=null;constructor(t,e){super(t),this.title=this.$.lang.math,this.icon="math",this.katex=null,this.mathjax=null,(this.katex=this.#Ju())||(this.mathjax=this.#Qu())||console.warn('[SUNEDITOR.plugins.math.warn] The math plugin must need either "KaTeX" or "MathJax" library. Please add the katex or mathjax option. See: https://github.com/ARA-developer/suneditor/blob/develop/guide/external-libraries.md'),this.pluginOptions={formSize:{width:"460px",height:"14em",maxWidth:"",maxHeight:"",minWidth:"400px",minHeight:"40px",...e.formSize},canResize:e.canResize??!0,autoHeight:!!e.autoHeight,fontSizeList:e.fontSizeList||[{text:"1",value:"1em"},{text:"1.5",value:"1.5em"},{text:"2",value:"2em"},{text:"2.5",value:"2.5em"}],onPaste:"function"==typeof e.onPaste?e.onPaste:null},this.pluginOptions.autoHeight&&(this.pluginOptions.formSize.height=this.pluginOptions.formSize.minHeight),this.defaultFontSize=null;const s=function(t){const{$:e,pluginOptions:s,katex:i}=t,{lang:n,icons:o}=e,{formSize:r,fontSizeList:l,canResize:a,autoHeight:h}=s,{width:c,height:d,maxWidth:u,maxHeight:p,minWidth:g,minHeight:m}=r,f=a?h?"horizontal":"auto":"none";let v=l[0].value,b=`\n <form>\n <div class="se-modal-header">\n <button type="button" data-command="close" class="se-btn se-close-btn" title="${n.close}" aria-label="${n.close}">\n ${o.cancel}\n </button>\n <span class="se-modal-title">${n.math_modal_title}</span>\n </div>\n <div class="se-modal-body">\n <div class="se-modal-form">\n <label>${n.math_modal_inputLabel} ${i?`(<a href="${Le.KATEX_WEBSITE}" target="_blank">KaTeX</a>)`:`(<a href="${Le.MATHJAX_WEBSITE}" target="_blank">MathJax</a>)`}</label>\n <textarea class="se-input-form se-math-exp se-modal-resize-form" type="text" data-focus style="width: ${c}; height: ${d}; min-width: ${g}; min-height: ${m}; resize: ${f};"></textarea>\n </div>\n <div class="se-modal-form">\n <label>${n.math_modal_fontSizeLabel}</label>\n <select class="se-input-select se-math-size">`;for(let t,e=0,s=l.length;e<s;e++)t=l[e],t.default&&(v=t.value),b+=`<option value="${t.value}"${t.default?" selected":""}>${t.text}</option>`;return b+=`</select>\n </div>\n <div class="se-modal-form">\n <label>${n.math_modal_previewLabel}</label>\n <p class="se-math-preview"></p>\n </div>\n </div>\n <div class="se-modal-footer">\n <button type="submit" class="se-btn-primary" title="${n.submitButton}" aria-label="${n.submitButton}">\n <span>${n.submitButton}</span>\n </button>\n </div>\n </form>`,t.defaultFontSize=v,Re.utils.createElement("DIV",{class:"se-modal-content se-modal-responsive",style:`max-width: ${u}; max-height: ${p};`},b)}(this),i=function({lang:t,icons:e}){const s=`\n <div class="se-arrow se-arrow-up"></div>\n <div class="link-content">\n <div class="se-btn-group">\n <button type="button" data-command="update" tabindex="-1" class="se-btn se-tooltip">\n ${e.edit}\n <span class="se-tooltip-inner">\n <span class="se-tooltip-text">${t.edit}</span>\n </span>\n </button>\n <button type="button" data-command="copy" tabindex="-1" class="se-btn se-tooltip">\n ${e.copy}\n <span class="se-tooltip-inner">\n <span class="se-tooltip-text">${t.copy}</span>\n </span>\n </button>\n <button type="button" data-command="delete" tabindex="-1" class="se-btn se-tooltip">\n ${e.delete}\n <span class="se-tooltip-inner">\n <span class="se-tooltip-text">${t.remove}</span>\n </span>\n </button>\n </div>\n </div>`;return Re.utils.createElement("DIV",{class:"se-controller se-controller-link"},s)}(this.$);this.modal=new Ml(this,this.$,s),this.controller=new Mi(this,this.$,i,{position:"bottom",disabled:!0}),this.textArea=s.querySelector(".se-math-exp"),this.previewElement=s.querySelector(".se-math-preview"),this.fontSizeElement=s.querySelector(".se-math-size"),this.isUpdateState=!1,this.previewElement.style.fontSize=this.defaultFontSize,this.$.eventManager.addEvent(this.textArea,"input",this.#tp.bind(this)),this.$.eventManager.addEvent(this.fontSizeElement,"change",function(t){this.fontSize=t.target.value}.bind(this.previewElement.style)),this.pluginOptions.onPaste&&this.$.eventManager.addEvent(this.textArea,"paste",this.pluginOptions.onPaste.bind(this))}open(){this.modal.open()}retainFormat(){return{query:".se-math, .katex, .MathJax",method:t=>{if(!this.katex&&!this.mathjax)return;const e=Yh(t);if(!e)return;const s=Gh.createRange().createContextualFragment(this.#ep(Oe.entityToHTML(this.#sp(e,!0))));t.innerHTML=s.querySelector(".se-math, .katex").innerHTML,t.setAttribute("contenteditable","false"),Re.utils.addClass(t,"se-component|se-inline-component|se-disable-pointer|se-math"),this.katex?Re.utils.addClass(t,"katex"):Re.utils.removeClass(t,"katex"),this.mathjax&&this.#ip(this.mathjax)}}}modalOn(t){if(this.isUpdateState=t,t){if(this.controller.currentTarget){const t=this.controller.currentTarget,e=Oe.entityToHTML(this.#sp(Yh(t),!0)),s=function(t){const e=t.getAttribute("data-se-type");if(e)return e;const s=t.getAttribute("data-font-size");return s?(t.removeAttribute("data-font-size"),t.setAttribute("data-se-type",s),s):null}(t)||"1em";this.textArea.value=e,this.fontSizeElement.value=s,this.previewElement.innerHTML=this.#ep(e),this.previewElement.style.fontSize=s}}else this.modalInit()}async modalAction(){if(0===this.textArea.value.trim().length||Re.utils.hasClass(this.textArea,"se-error"))return this.textArea.focus(),!1;const t=this.textArea.value,e=this.previewElement.querySelector(".se-math, .katex");if(!e)return!1;if(Re.utils.addClass(e,"se-component|se-inline-component|se-disable-pointer|se-math"),e.setAttribute("contenteditable","false"),e.setAttribute("data-se-value",Oe.htmlToEntity(this.#sp(t,!1))),e.setAttribute("data-se-type",this.fontSizeElement.value),e.style.fontSize=this.fontSizeElement.value,this.katex?(Re.utils.addClass(e,"katex"),Re.utils.removeClass(e,"MathJax")):Re.utils.removeClass(e,"katex"),this.isUpdateState){Re.query.getParentElement(this.controller.currentTarget,".se-component").replaceWith(e);const t=this.$.component.get(e);return this.$.component.select(t.target,t.pluginName),!0}{const t=this.$.format.getLines();if(t.length>1){const s=Re.utils.createElement(t[0].nodeName,null,e);this.$.component.insert(s,{insertBehavior:"none",scrollTo:!1})}else this.$.component.insert(e,{insertBehavior:"none",scrollTo:!1})}this.mathjax&&this.#ip(this.mathjax);const s=this.$.selection.getNearRange(e);return s?this.$.selection.setRange(s.container,s.offset,s.container,s.offset):this.$.component.select(e,Kh.key),!0}modalInit(){this.textArea.value="",this.previewElement.innerHTML="",Re.utils.removeClass(this.textArea,"se-error")}controllerAction(t){switch(t.getAttribute("data-command")){case"update":this.modal.open();break;case"copy":this.#np(this.#$c);break;case"delete":this.componentDestroy(this.controller.currentTarget)}}controllerClose(){this.#$c=null}componentSelect(t){if(Re.utils.hasClass(t,"se-math|katex")&&Yh(t))return this.#$c=t,void this.controller.open(t,null,{isWWTarget:!1,initMethod:null,addOffset:null})}async componentDestroy(t){Re.utils.removeItem(t),this.controller.close(),this.$.focusManager.focus(),this.$.history.push(!1)}#ep(t){let e="";try{if(Re.utils.removeClass(this.textArea,"se-error"),this.katex)e=this.katex.src.renderToString(t,{throwOnError:!0,displayMode:!0});else{if(!this.mathjax){const t=new Error('404 Not found. "KaTeX" or "MathJax" library');throw t.code="MATH_LIB_NOT_FOUND",t}e=this.mathjax.convert(t).outerHTML,/<mjx-merror/.test(e)?(Re.utils.addClass(this.textArea,"se-error"),e=`<span class="se-math-error">${e}</span>`):e=`<span class="se-math">${e}</span>`}}catch(t){Re.utils.addClass(this.textArea,"se-error"),e="MATH_LIB_NOT_FOUND"===t.code?`<span class="se-math-error">${t.message}</span>`:`<span class="se-math-error">Math syntax error. (Refer ${this.katex?`<a href="${Le.KATEX_WEBSITE}" target="_blank">KaTeX</a>`:`<a href="${Le.MATHJAX_WEBSITE}" target="_blank">MathJax</a>`})</span>`,console.warn("[SUNEDITOR.math.error] ",t.message)}return e}#sp(t,e){return t.replace(/\\{2}/g,e?"\\":"\\\\")}async#np(t){if(navigator.clipboard&&t)try{const e=Yh(t);await this.$.html.copy(e),Re.utils.addClass(t,"se-copy"),jh.setTimeout((()=>{Re.utils.removeClass(t,"se-copy")}),120)}catch(t){console.error("[SUNEDITOR.math.copy.fail]",t)}}#tp(t){const e=Re.query.getEventTarget(t);this.pluginOptions.autoHeight&&(e.style.height="5px",e.style.height=e.scrollHeight+5+"px"),this.previewElement.innerHTML=this.#ep(e.value),this.mathjax&&this.#ip(this.mathjax)}#ip(t){t.clear(),t.updateDocument()}#Ju(){const t=this.$.options.get("externalLibs").katex;if(!t)return null;if(!t.src)return console.warn("[SUNEDITOR.math.katex.fail] The katex option is set incorrectly."),null;const e=[{throwOnError:!1},t.options||{}].reduce(((t,e)=>{for(const s in e)t[s]=e[s];return t}),{});return t.options=e,t}#Qu(){const t=this.$.options.get("externalLibs").mathjax;if(!t)return null;this.$.frameOptions.get("iframe")&&console.warn("[SUNEDITOR.math.mathjax.fail] The MathJax option is not supported in the iframe.");try{const e=t.browserAdaptor();t.RegisterHTMLHandler(e);const s=new t.TeX,i=new t.CHTML;return t.src.document(document,{InputJax:s,OutputJax:i})}catch(t){return console.warn("[SUNEDITOR.math.mathjax.fail] The MathJax option is set incorrectly.",t),null}}}function Yh(t){const e=t.getAttribute("data-se-value");if(e)return e;const s=t.getAttribute("data-exp");return s?(t.removeAttribute("data-exp"),t.setAttribute("data-se-value",s),s):null}const Xh=Kh,{_w:Zh}=Le;const Jh=class extends Wl{static key="drawing";static className="";#st;#op;constructor(t,e){super(t),this.title=this.$.lang.drawing,this.icon="drawing",this.pluginOptions={outputFormat:e.outputFormat||"dataurl",useFormatType:e.useFormatType??!1,defaultFormatType:["block","inline"].includes(e.defaultFormatType)?e.defaultFormatType:"block",keepFormatType:e.keepFormatType??!1,lineWidth:e.lineWidth||5,lineReconnect:!!e.lineReconnect,lineCap:["butt","round","square"].includes(e.lineCap)?e.lineCap:"round",lineColor:e.lineColor||"",formSize:{width:"750px",height:"50vh",maxWidth:"",maxHeight:"",minWidth:"150px",minHeight:"100px",...e.formSize},canResize:e.canResize??!0,maintainRatio:e.maintainRatio??!0},this.$.plugins.image?"svg"!==this.pluginOptions.outputFormat||this.$.plugins.image.pluginOptions.uploadUrl||console.warn('[SUNEDITOR.plugins.drawing.warn] The drawing plugin must need the "image" plugin with the "uploadUrl" option. Please add the "image" plugin with the "uploadUrl" option.'):console.warn('[SUNEDITOR.plugins.drawing.warn] The drawing plugin must need either "image" plugin. Please add the "image" plugin.');const s=function({lang:t,icons:e},s){const{width:i,height:n,maxWidth:o,maxHeight:r,minWidth:l,minHeight:a}=s.formSize,h=`\n <form>\n <div class="se-modal-header">\n <button type="button" data-command="close" class="se-btn se-close-btn" title="${t.close}" aria-label="${t.close}">\n ${e.cancel}\n </button>\n <span class="se-modal-title">${t.drawing_modal_title}</span>\n </div>\n <div class="se-modal-body" style="width: ${i}; height: ${n}; min-width: ${l}; min-height: ${a};">\n <canvas class="se-drawing-canvas" style="width: 100%; height: 100%;"></canvas>\n\t\t\t${s.canResize?'<div class="se-modal-resize-handle-w"></div><div class="se-modal-resize-handle-h"></div><div class="se-modal-resize-handle-c"></div>':""}\n\t\t</div>\n\t\t<div class="se-modal-body-bottom">\n\t\t\t<div class="se-modal-form">\n\t\t\t\t<div class="se-modal-flex-form">\n\t\t\t\t\t${s.useFormatType?`\n\t\t\t\t\t\t\t<div class="se-modal-flex-group">\n\t\t\t\t\t\t\t\t<button type="button" class="se-btn se-tooltip" data-command="asBlock" aria-label="${t.blockStyle}">\n\t\t\t\t\t\t\t\t\t${e.as_block}\n\t\t\t\t\t\t\t\t\t${Re.utils.createTooltipInner(t.blockStyle)}\n\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t<button type="button" class="se-btn se-tooltip" data-command="asInline" aria-label="${t.inlineStyle}">\n\t\t\t\t\t\t\t\t\t${e.as_inline}\n\t\t\t\t\t\t\t\t\t${Re.utils.createTooltipInner(t.inlineStyle)}\n\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t</div>`:""}\n\t\t\t\t\t<div class="se-modal-flex-group">\n\t\t\t\t\t\t<button type="button" class="se-btn se-tooltip" data-command="remove" aria-label="${t.remove}">\n\t\t\t\t\t\t\t${e.eraser}\n\t\t\t\t\t\t\t${Re.utils.createTooltipInner(t.remove)}\n\t\t\t\t\t\t</button>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n <div class="se-modal-footer">\n\t\t\t<button type="submit" class="se-btn-primary" title="${t.submitButton}" aria-label="${t.submitButton}">\n\t\t\t\t<span>${t.submitButton}</span>\n\t\t\t</button>\n </div>\n </form>`;return Re.utils.createElement("DIV",{class:"se-modal-content se-modal-responsive",style:`max-width: ${o}; max-height: ${r};`},h)}(this.$,this.pluginOptions);this.modal=new Ml(this,this.$,s),this.as=this.pluginOptions.defaultFormatType,this.pluginOptions.useFormatType&&(this.asBlock=s.querySelector('[data-command="asBlock"]'),this.asInline=s.querySelector('[data-command="asInline"]'),this.$.eventManager.addEvent([this.asBlock,this.asInline],"click",this.#wu.bind(this))),this.canvas=null,this.ctx=null,this.isDrawing=!1,this.points=[],this.paths=[],this.resizeObserver=null,this.#st={touchstart:this.#rp.bind(this),touchmove:this.#lp.bind(this),mousedown:this.#ap.bind(this),mousemove:this.#hp.bind(this),mouseup:this.#cp.bind(this),mouseleave:this.#dp.bind(this),mouseenter:this.#up.bind(this)},this.#op={touchstart:null,touchmove:null,mousedown:null,mousemove:null,mouseup:null,mouseleave:null,mouseenter:null},this.$.eventManager.addEvent(s.querySelector('[data-command="remove"]'),"click",this.#pp.bind(this))}open(){this.pluginOptions.useFormatType&&this.#xu("inline"===(this.pluginOptions.keepFormatType?this.as:this.pluginOptions.defaultFormatType)),this.modal.open(),this.#gp()}modalOff(){this.#mp()}async modalAction(){if("svg"===this.pluginOptions.outputFormat){const t=this.#fp();this.$.plugins.image.modalInit(),this.$.plugins.image.submitFile(t)}else{const t=this.canvas.toDataURL(),e={name:"drawing",size:0};this.$.plugins.image.modalInit(),"inline"!==this.as?this.$.plugins.image.create(t,null,"auto","","none",e,""):this.$.plugins.image.createInline(t,null,"auto","","none",e,"")}return!0}#gp(){const t=this.canvas=this.modal.form.querySelector(".se-drawing-canvas");this.ctx=t.getContext("2d"),t.width=t.offsetWidth,t.height=t.offsetHeight,this.points=[],this.paths=[],this.#vp(),this.#op.touchstart=this.$.eventManager.addEvent(t,"touchstart",this.#st.touchstart,{passive:!1,capture:!0}),this.#op.touchmove=this.$.eventManager.addEvent(t,"touchmove",this.#st.touchmove,!0),this.#op.mousedown=this.$.eventManager.addEvent(t,"mousedown",this.#st.mousedown,{passive:!1,capture:!0}),this.#op.mousemove=this.$.eventManager.addEvent(t,"mousemove",this.#st.mousemove,!0),this.#op.mouseup=this.$.eventManager.addEvent(t,"mouseup",this.#st.mouseup,!0),this.#op.mouseleave=this.$.eventManager.addEvent(t,"mouseleave",this.#st.mouseleave),this.#op.mouseenter=this.$.eventManager.addEvent(t,"mouseenter",this.#st.mouseenter),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),Le.isResizeObserverSupported&&(this.resizeObserver=new ResizeObserver((()=>{const e=t.width,s=t.height,i=t.offsetWidth,n=t.offsetHeight;t.width=i,t.height=n,e===t.width&&s===t.height||(this.pluginOptions.maintainRatio&&this.#bp(e,s,i,n),this.#yp())})),this.resizeObserver.observe(t))}#mp(){this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.canvas&&(this.$.eventManager.removeEvent(this.#op.mousedown),this.$.eventManager.removeEvent(this.#op.mousemove),this.$.eventManager.removeEvent(this.#op.mouseup),this.$.eventManager.removeEvent(this.#op.mouseleave),this.$.eventManager.removeEvent(this.#op.mouseenter)),this.canvas=null,this.ctx=null,this.points=[],this.paths=[],this.isDrawing=!1}#vp(){this.ctx.lineWidth=this.pluginOptions.lineWidth,this.ctx.lineCap=this.pluginOptions.lineCap,this.ctx.strokeStyle=this.pluginOptions.lineColor||Zh.getComputedStyle(this.$.contextProvider.carrierWrapper).color}#wp(){this.#vp(),this.ctx.beginPath(),this.points.forEach((([t,e],s)=>{0===s?this.ctx.moveTo(t,e):this.ctx.lineTo(t,e)})),this.ctx.stroke()}#yp(){this.#vp(),this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.paths.forEach((t=>{this.points=t,this.#wp()})),this.points=[]}#bp(t,e,s,i){const n=s/t,o=i/e;this.paths=this.paths.map((t=>t.map((([t,e])=>[t*n,e*o]))))}#Cp(){this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.points=[],this.paths=[]}#_p(){const t="http://www.w3.org/2000/svg",e=document.createElementNS(t,"svg");return e.setAttribute("width",this.canvas.width+""),e.setAttribute("height",this.canvas.height+""),e.setAttribute("viewBox",`0 0 ${this.canvas.width} ${this.canvas.height}`),e.setAttribute("xmlns",t),this.paths.forEach((s=>{const i=s.reduce(((t,[e,s],i)=>t+(0===i?`M ${e} ${s}`:` L ${e} ${s}`)),""),n=document.createElementNS(t,"path");n.setAttribute("d",i),n.setAttribute("fill","none"),n.setAttribute("stroke",String(this.ctx.strokeStyle)),n.setAttribute("stroke-width",this.ctx.lineWidth+""),e.appendChild(n)})),e}#fp(){const t=this.#_p(),e=(new XMLSerializer).serializeToString(t),s=new Blob([e],{type:"image/svg+xml"}),i=new File([s],"drawing.svg",{type:"image/svg+xml"}),n=new DataTransfer;return n.items.add(i),n.files}#kp(t){const{touches:e}=t,s=this.canvas.getBoundingClientRect();return{x:e[0].clientX-s.left,y:e[0].clientY-s.top}}#xu(t){t?(Re.utils.addClass(this.asInline,"on"),Re.utils.removeClass(this.asBlock,"on"),this.as="inline"):(Re.utils.addClass(this.asBlock,"on"),Re.utils.removeClass(this.asInline,"on"),this.as="block")}#ap(t){t.preventDefault(),this.isDrawing=!0,this.points.push([t.offsetX,t.offsetY]),this.#wp()}#hp(t){t.preventDefault(),this.isDrawing&&(this.points.push([t.offsetX,t.offsetY]),this.#wp())}#rp(t){t.preventDefault();const{x:e,y:s}=this.#kp(t);this.isDrawing=!0,this.points.push([e,s]),this.#wp()}#lp(t){t.preventDefault();const{x:e,y:s}=this.#kp(t);this.isDrawing&&(this.points.push([e,s]),this.#wp())}#cp(){this.isDrawing=!1,this.points.length>0&&(this.paths.push([...this.points]),this.points=[])}#dp(){this.isDrawing&&(this.paths.push([...this.points]),this.pluginOptions.lineReconnect||(this.points=[],this.isDrawing=!1))}#up(t){if(1===t.buttons){if(this.isDrawing=!0,this.pluginOptions.lineReconnect){const e=this.paths.at(-1).at(-1);this.points.push([e[0],e[1]]),this.points.push([t.offsetX,t.offsetY])}else this.points.push([t.offsetX,t.offsetY]);this.#wp()}}#pp(){this.#Cp()}#wu(t){this.#xu("asInline"===Re.query.getEventTarget(t).getAttribute("data-command"))}};const Qh=class extends zl{static key="imageGallery";static className="";constructor(t,e){super(t),this.title=this.$.lang.imageGallery,this.icon="image_gallery",this.onSelectfunction=null,this.browser=new Dr(this,this.$,{title:this.$.lang.imageGallery,data:e.data,url:e.url,headers:e.headers,searchUrl:e.searchUrl,searchHeaders:e.searchHeaders,selectorHandler:this.#xp.bind(this),columnSize:4,className:"se-image-gallery"}),this.width="auto"===this.$.plugins.image.pluginOptions.defaultWidth?"":this.$.plugins.image.pluginOptions.defaultWidth,this.height="auto"===this.$.plugins.image.pluginOptions.defaultHeight?"":this.$.plugins.image.pluginOptions.defaultHeight}open(t){this.onSelectfunction=t,this.browser.open()}close(){this.onSelectfunction=null,this.browser.close()}#xp(t){if(this.onSelectfunction)this.onSelectfunction(t);else{const e={name:t.getAttribute("data-name"),size:0};this.$.plugins.image.modalInit(),this.$.plugins.image.create(t.getAttribute("data-command"),null,this.width,this.height,"none",e,t.alt,!0)}}};const tc=class extends zl{static key="videoGallery";static className="";constructor(t,e){super(t),this.title=this.$.lang.videoGallery,this.icon="video_gallery",this.onSelectfunction=null;const s="string"==typeof e.thumbnail?e.thumbnail:this.$.icons.video_thumbnail;this.browser=new Dr(this,this.$,{title:this.$.lang.videoGallery,data:e.data,url:e.url,headers:e.headers,searchUrl:e.searchUrl,searchHeaders:e.searchHeaders,selectorHandler:this.#xp.bind(this),columnSize:4,className:"se-video-gallery",thumbnail:"function"==typeof e.thumbnail?e.thumbnail:()=>s,props:["frame"]}),this.width="auto"===this.$.plugins.video.pluginOptions.defaultWidth?"":this.$.plugins.video.pluginOptions.defaultWidth,this.height="auto"===this.$.plugins.video.pluginOptions.defaultHeight?"":this.$.plugins.video.pluginOptions.defaultHeight}open(t){this.onSelectfunction=t,this.browser.open()}close(){this.onSelectfunction=null,this.browser.close()}#xp(t){if(this.onSelectfunction)this.onSelectfunction(t);else{let e=t.getAttribute("data-command");const s=this.$.plugins.video.findProcessUrl(e);s&&(e=s.url);const i={name:t.getAttribute("data-name"),size:0};this.$.plugins.video.modalInit(),this.$.plugins.video.create(this.$.plugins.video["iframe"===t.getAttribute("data-frame")?"createIframeTag":"createVideoTag"]({poster:t.getAttribute("data-thumbnail")}),e,null,this.width,this.height,!1,i,!0)}}};const ec=class extends zl{static key="audioGallery";static className="";constructor(t,e){super(t),this.title=this.$.lang.audioGallery,this.icon="audio_gallery",this.onSelectfunction=null;const s="string"==typeof e.thumbnail?e.thumbnail:this.$.icons.audio_thumbnail;this.browser=new Dr(this,this.$,{title:this.$.lang.audioGallery,data:e.data,url:e.url,headers:e.headers,searchUrl:e.searchUrl,searchHeaders:e.searchHeaders,selectorHandler:this.#xp.bind(this),columnSize:4,className:"se-audio-gallery",thumbnail:"function"==typeof e.thumbnail?e.thumbnail:()=>s})}open(t){this.onSelectfunction=t,this.browser.open()}close(){this.onSelectfunction=null,this.browser.close()}#xp(t){this.onSelectfunction?this.onSelectfunction(t):(this.$.plugins.audio.modalInit(),this.$.plugins.audio.submitURL(t.getAttribute("data-command")))}};const sc=class extends zl{static key="fileGallery";static className="";constructor(t,e){super(t),this.title=this.$.lang.fileGallery,this.icon="file_gallery",this.onSelectfunction=null;const s="string"==typeof e.thumbnail?e.thumbnail:this.$.icons.file_thumbnail;this.browser=new Dr(this,this.$,{title:this.$.lang.fileGallery,data:e.data,url:e.url,headers:e.headers,searchUrl:e.searchUrl,searchHeaders:e.searchHeaders,selectorHandler:this.#xp.bind(this),columnSize:4,className:"se-file-gallery",thumbnail:"function"==typeof e.thumbnail?e.thumbnail:()=>s})}open(t){this.onSelectfunction=t,this.browser.open()}close(){this.onSelectfunction=null,this.browser.close()}#xp(t){if(this.onSelectfunction)this.onSelectfunction(t);else{const e={name:t.getAttribute("data-name"),size:0};this.$.plugins.fileUpload.create(t.getAttribute("data-command"),e,!0)}}};const ic=class extends zl{static key="fileBrowser";static className="";constructor(t,e){super(t),this.title=this.$.lang.fileBrowser,this.icon="file_browser",this.onSelectfunction=null;const s={video:this.$.icons.video_thumbnail,audio:this.$.icons.audio_thumbnail,file:this.$.icons.file_thumbnail},i=this.$.icons.file_thumbnail;this.browser=new Dr(this,this.$,{title:this.$.lang.fileBrowser,data:e.data,url:e.url,headers:e.headers,searchUrl:e.searchUrl,searchHeaders:e.searchHeaders,selectorHandler:this.#xp.bind(this),columnSize:4,className:"se-file-browser",thumbnail:"function"==typeof e.thumbnail?e.thumbnail:t=>s[t.type]||i,props:[...new Set((e.props??[]).concat(["frame"]))],expand:e.expand})}open(t){this.onSelectfunction=t,this.browser.open()}close(){this.onSelectfunction=null,this.browser.close()}#xp(t){if(this.onSelectfunction)this.onSelectfunction(t);else{switch(t.getAttribute("data-type")){case"image":this.$.plugins.imageGallery.browser.selectorHandler(t);break;case"video":this.$.plugins.videoGallery.browser.selectorHandler(t);break;case"audio":this.$.plugins.audioGallery.browser.selectorHandler(t);break;case"file":this.$.plugins.fileGallery.browser.selectorHandler(t)}}}},nc={text:{default:"16px",list:[{title:"XX-Small",size:"8px"},{title:"X-Small",size:"10px"},{title:"Small",size:"13px"},{title:"Medium",size:"16px"},{title:"Large",size:"18px"},{title:"X-Large",size:"24px"},{title:"XX-Large",size:"32px"}]},px:{default:13,inc:1,min:8,max:72,list:[8,10,13,15,18,20,22,26,28,36,48,72]},pt:{default:10,inc:1,min:6,max:72,list:[6,8,10,12,14,18,22,26,32]},em:{default:1,inc:.1,min:.5,max:5,list:[.5,.75,1,1.25,1.5,1.75,2,2.5,3]},rem:{default:1,inc:.1,min:.5,max:5,list:[.5,.75,1,1.25,1.5,1.75,2,2.5,3]},vw:{inc:.1,min:.5,max:10,list:[2,3.5,4,4.5,6,8]},vh:{default:1.5,inc:.1,min:.5,max:10,list:[1,1.5,2,2.5,3,3.5,4]},"%":{default:100,inc:1,min:50,max:200,list:[50,70,90,100,120,140,160,180,200]}};class oc extends ql{static key="fontSize";static className="se-btn-select se-btn-input se-btn-tool-font-size";#$p;constructor(t,e){super(t),this.unitMap={...nc,...e.unitMap||{}},this.sizeUnit=/text/.test(e.sizeUnit)?"":e.sizeUnit||this.$.options.get("fontSizeUnits")[0];const s=this.unitMap[this.sizeUnit||"text"],i=function({lang:t},e,s,i){const n=e.list,o=e.default,r=i?t.default:"";let l='\n\t<div class="se-list-inner">\n\t\t<ul class="se-list-basic">';for(let t,e,i,a,h,c=0,d=n.length;c<d;c++)t=n[c],"object"==typeof t?(e=t.title,i=t.size):e=i=t+s,a=o===i?" default_value":"",h=a&&r||e,l+=`\n\t\t\t<li>\n\t\t\t\t<button type="button" class="se-btn se-btn-list${a}" data-command="${i}" data-value="${e}" title="${h}" aria-label="${h}" style="font-size:${i};">${h}</button>\n\t\t\t</li>`;return l+="\n\t\t</ul>\n\t</div>",Re.utils.createElement("DIV",{class:"se-dropdown se-list-layer se-list-font-size"},l)}(this.$,s,this.sizeUnit,e.showDefaultSizeLabel),n=!!this.sizeUnit&&(e.showIncDecControls??!1),o=!this.sizeUnit||(e.disableInput??!1);this.title=this.$.lang.fontSize,this.inner=!(o&&!n)&&(o?`<span class="se-txt se-not-arrow-text __se__font_size">${this.$.lang.fontSize}</span>`:`<input type="text" class="__se__font_size se-not-arrow-text" placeholder="${this.$.lang.fontSize}" />`),n?(this.beforeItem=Re.utils.createElement("button",{class:"se-btn se-tooltip se-sub-btn",type:"button","data-command":oc.key,"data-type":"command","data-value":"dec"},`${this.$.icons.minus}<span class="se-tooltip-inner"><span class="se-tooltip-text">${this.$.lang.decrease}</span></span>`),this.afterItem=Re.utils.createElement("button",{class:"se-btn se-tooltip se-sub-btn",type:"button","data-command":oc.key,"data-type":"command","data-value":"inc"},`${this.$.icons.plus}<span class="se-tooltip-inner"><span class="se-tooltip-text">${this.$.lang.increase}</span></span>`)):o?o&&!n&&(this.replaceButton=Re.utils.createElement("button",{class:"se-btn se-tooltip se-btn-select se-btn-tool-font-size",type:"button","data-command":oc.key,"data-type":"dropdown"},`<span class="se-txt __se__font_size">${this.$.lang.fontSize}</span>${this.$.icons.arrow_down}<span class="se-tooltip-inner"><span class="se-tooltip-text">${this.$.lang.fontSize}</span></span>`),this.$.menu.initDropdownTarget({key:oc.key,type:"dropdown"},i)):(this.afterItem=Re.utils.createElement("button",{class:"se-btn se-tooltip se-sub-arrow-btn",type:"button","data-command":oc.key,"data-type":"dropdown"},`${this.$.icons.arrow_down}<span class="se-tooltip-inner"><span class="se-tooltip-text">${this.$.lang.fontSize}</span></span>`),this.$.menu.initDropdownTarget({key:oc.key,type:"dropdown"},i)),this.currentSize="",this.sizeList=i.querySelectorAll("li button"),this.hasInputFocus=!1,this.isInputActive=!1,this.#$p=o,this.$.menu.initDropdownTarget(oc,i)}active(t,e){if(!Re.utils.hasClass(e,"__se__font_size"))return!1;let s="";if(t){if(this.$.format.isLine(t))return;if(s=Re.utils.getStyle(t,"fontSize"))return this.#Sp(e,s),!0}else this.#Sp(e,this.#Ep());return!1}toolbarInputKeyDown({target:t,event:e}){const s=e.code;if(this.#$p||Pe.isSpace(s))return void e.preventDefault();if(!/^(ArrowUp|ArrowDown|Enter)$/.test(s))return;const{value:i,unit:n}=this.#Tp(t);if(!i)return;const o=ze.get(i),r=this.unitMap[n];let l=o;switch(s){case"ArrowUp":l+=r.inc,l>r.max&&(l=o);break;case"ArrowDown":l-=r.inc,l<r.min&&(l=o)}e.preventDefault();try{this.isInputActive=!0;const e=this.#Sp(t,l+n);if(this.#$p)return;const i=Re.utils.createElement("SPAN",{style:"font-size: "+e+";"});this.$.inline.apply(i,{stylesToModify:["font-size"],nodesToRemove:null,strictRemove:null}),Pe.isEnter(s)||t.focus()}finally{this.isInputActive=!1}}toolbarInputChange({target:t,value:e,event:s}){if(!this.#$p)try{this.isInputActive=!0;let{value:s,unit:i}=this.#Tp(e);const{max:n,min:o}=this.unitMap[i];s=s>n?n:s<o?o:s;const r=Re.utils.createElement("SPAN",{style:"font-size: "+this.#Sp(t,s+i)+";"});this.$.inline.apply(r,{stylesToModify:["font-size"],nodesToRemove:null,strictRemove:null})}finally{this.isInputActive=!1,s.preventDefault(),this.$.focusManager.focus()}}on(t){const{value:e,unit:s}=this.#Tp(t),i=e+s;if(i===this.currentSize)return;const n=this.sizeList;for(let t=0,e=n.length;t<e;t++)i===n[t].getAttribute("data-value")?Re.utils.addClass(n[t],"active"):Re.utils.removeClass(n[t],"active");this.currentSize=i}action(t){const e=t.getAttribute("data-command");if(e===oc.key){const{value:e,unit:s}=this.#Tp(t);let i=ze.get(e)+("inc"===t.getAttribute("data-value")?1:-1);const{min:n,max:o}=this.unitMap[s];i=i<n?n:i>o?o:i;const r=Re.utils.createElement("SPAN",{style:"font-size: "+i+s+";"});this.$.inline.apply(r,{stylesToModify:["font-size"],nodesToRemove:null,strictRemove:null})}else if(e){const t=Re.utils.createElement("SPAN",{style:"font-size: "+e+";"});this.$.inline.apply(t,{stylesToModify:["font-size"],nodesToRemove:null,strictRemove:null})}else this.$.inline.apply(null,{stylesToModify:["font-size"],nodesToRemove:["span"],strictRemove:!0});this.$.menu.dropdownOff()}#Ep(){return this.$.frameContext.get("wwComputedStyle").fontSize}#Tp(t){if(!(t="string"==typeof t?t:t.parentElement.querySelector(".__se__font_size")))return{unit:this.sizeUnit,value:this.sizeUnit?0:""};const e="string"==typeof t?t:Re.check.isInputElement(t)?t.value:t.textContent,s=this.sizeUnit?e.split(/(\d+)/):[e,""];let i=(s.pop()||"").trim().toLowerCase();i=this.$.options.get("fontSizeUnits").includes(i)?i:this.sizeUnit;const n=s.pop();return{unit:i,value:i?Number(n):n}}#Sp(t,e){return(t=t.parentElement.querySelector(".__se__font_size"))?Re.check.isInputElement(t)?t.value=String(e):t.textContent=String(this.sizeUnit?e:this.unitMap.text.list.find((t=>t.size===e))?.title||e):0}}const rc=oc;const lc=class extends ql{static key="pageNavigator";static className="se-btn-input se-btn-tool-pageNavigator";constructor(t){super(t),this.title=this.$.lang.pageNumber,this.inner=Re.utils.createElement("input",{type:"number",class:"se-not-arrow-text",placeholder:"1",value:"1",min:"1"},null),this.afterItem=Re.utils.createElement("span",{class:"se-btn se-sub-btn"},""),this.pageNum=1,this.totalPages=1,this.$.eventManager.addEvent(this.inner,"change",this.#Mp.bind(this))}display(t,e){this.pageNum=t,this.totalPages=e,this.inner.value=String(t),this.afterItem.textContent=this.inner.max=String(e)}#Mp(t){if(!this.$.frameContext.has("documentType_use_page"))return;const e=Re.query.getEventTarget(t),s=Number(e.value)||1;this.$.frameContext.get("documentType").pageGo(s)}},{_w:ac}=Le;class hc extends Ul{static key="anchor";static className="";static component(t){return Re.check.isAnchor(t)&&t.hasAttribute("id")&&t.hasAttribute("data-se-anchor")?t:null}#$c=null;#Np=null;constructor(t){super(t),this.title=this.$.lang.anchor,this.icon="bookmark_anchor";const e=(new DOMParser).parseFromString(this.$.icons.bookmark_anchor,"image/svg+xml");this.bookmarkIcon=e.documentElement;const s=function({lang:t,icons:e}){const s=`\n\t<div class="se-arrow se-arrow-up"></div>\n\t<div class="link-content">\n\t\t<div class="se-controller-display"></div>\n\t\t<div class="se-btn-group">\n\t\t\t<button type="button" data-command="edit" tabindex="-1" class="se-btn se-tooltip">\n\t\t\t\t${e.edit}\n\t\t\t\t<span class="se-tooltip-inner">\n\t\t\t\t\t<span class="se-tooltip-text">${t.edit}</span>\n\t\t\t\t</span>\n\t\t\t</button>\n\t\t\t<button type="button" data-command="delete" tabindex="-1" class="se-btn se-tooltip">\n\t\t\t\t${e.delete}\n\t\t\t\t<span class="se-tooltip-inner">\n\t\t\t\t\t<span class="se-tooltip-text">${t.remove}</span>\n\t\t\t\t</span>\n\t\t\t</button>\n\t\t</div>\n\t</div>`;return Re.utils.createElement("DIV",{class:"se-controller se-controller-link"},s)}(this.$);this.displayId=s.querySelector(".se-controller-display"),this.controllerSelect=new Mi(this,this.$,s,{position:"bottom",disabled:!0},hc.key);const i=function({lang:t,icons:e}){const s=`\n\t\t<div class="se-arrow se-arrow-up"></div>\n\t\t<form>\n\t\t\t<div class="se-controller-display">${t.id}</div>\n\t\t\t<div class="se-btn-group se-form-group">\n\t\t\t\t<input type="text" required />\n\t\t\t\t<button type="submit" data-command="submit" class="se-btn se-tooltip se-btn-success">\n\t\t\t\t\t${e.checked}\n\t\t\t\t\t<span class="se-tooltip-inner"><span class="se-tooltip-text">${t.save}</span></span>\n\t\t\t\t</button>\n\t\t\t\t<button type="button" data-command="cancel" class="se-btn se-tooltip se-btn-danger">\n\t\t\t\t\t${e.cancel}\n\t\t\t\t\t<span class="se-tooltip-inner"><span class="se-tooltip-text">${t.cancel}</span></span>\n\t\t\t\t</button>\n\t\t\t</div>\n\t\t</form>\n\t\t`;return Re.utils.createElement("DIV",{class:"se-controller se-controller-simple-input"},s)}(this.$);this.inputEl=i.querySelector("input"),this.controller=new Mi(this,this.$,i,{position:"bottom",disabled:!0,parents:[this.controllerSelect.form],parentsHide:!0},hc.key)}show(){this.controller.open(this.#Np=this.$.selection.getRange()),ac.setTimeout((()=>{this.inputEl.focus()}),0)}componentSelect(t){this.#$c=t,this.displayId.textContent=t.getAttribute("id"),this.controllerSelect.open(t)}componentDeselect(){this.#xs()}controllerAction(t){const e=t.getAttribute("data-command");if(!e)return;const s=this.#$c;switch(e){case"submit":if(this.controller.close(),s)s.id=this.inputEl.value,this.$.component.select(s,hc.key);else{const t=this.inputEl.value.trim();if(!t)return void this.inputEl.focus();const e=Re.utils.createElement("A",{id:t,"data-se-anchor":this.inputEl.value,"data-se-non-link":"true",contenteditable:"false",class:"se-component se-inline-component"});this.$.component.insert(e,{insertBehavior:"none",scrollTo:!1});const s=this.$.selection.getNearRange(e);s?this.$.selection.setRange(s.container,s.offset,s.container,s.offset):this.$.component.select(e,hc.key),this.#xs()}break;case"cancel":this.controller.close(!s),this.#Np&&this.$.selection.setRange(this.#Np),this.#xs(),s&&this.componentSelect(s);break;case"edit":this.inputEl.value=this.displayId.textContent,this.controllerSelect.hide(),this.controller.open(s),this.inputEl.focus();break;case"delete":{const t=this.$.selection.getNearRange(s);Re.utils.removeItem(s),this.controllerSelect.close(!0),t&&this.$.selection.setRange(t.container,t.offset,t.container,t.offset),this.#xs();break}}}#xs(){this.#$c=null,this.#Np=null,this.inputEl.value="",this.displayId.textContent=""}}const cc={blockquote:Vl,codeBlock:Kl,exportPDF:Zl,fileUpload:ta,list_bulleted:sa,list_numbered:oa,autocomplete:ha,slashCommand:da,align:pa,font:ma,fontColor:va,backgroundColor:ya,list:ka,table:ah,blockStyle:ch,hr:Ca,layout:uh,lineHeight:gh,template:fh,paragraphStyle:bh,textStyle:wh,link:Ch,image:Nh,video:zh,audio:Hh,embed:Vh,math:Xh,drawing:Jh,imageGallery:Qh,videoGallery:tc,audioGallery:ec,fileGallery:sc,fileBrowser:ic,fontSize:rc,pageNavigator:lc,anchor:hc};class dc{async modalAction(){return!0}modalOn(t){}modalInit(){}modalOff(t){}modalResize(){}}class uc{controllerAction(t){}controllerOn(t,e){}controllerClose(){}}class pc{browserInit(){}}class gc{colorPickerAction(t){}colorPickerHueSliderOpen(){}colorPickerHueSliderClose(){}}class mc{hueSliderAction(){}hueSliderCancelAction(){}}class fc{componentSelect(t){}componentDeselect(t){}componentEdit(t){}async componentDestroy(t){}componentCopy(t){}}const vc={contract:t,manager:e,ui:i};Object.defineProperty(window,"SUNEDITOR",{enumerable:!0,writable:!1,configurable:!1,value:{...Ol,plugins:cc,modules:vc,helper:qe,interfaces:n}})})()})();
|
|
1
|
+
(()=>{var t={cfbI(t){var e,s;e="undefined"!=typeof window?window:this,s=function(t,e){const s={code:"en",align:"Align",alignBottom:"Align bottom",alignCenter:"Align center",alignJustify:"Align justify",alignLeft:"Align left",alignMiddle:"Align middle",alignRight:"Align right",alignTop:"Align top",anchor:"Anchor",asBlock:"As a block",asInline:"As a inline",asLink:"As a link",audio:"Audio",audioGallery:"Audio gallery",audio_modal_file:"Select from files",audio_modal_title:"Insert Audio",audio_modal_url:"Audio URL",autoSize:"Auto size",backgroundColor:"Background color",basic:"Basic",blockStyle:"Block style",bold:"Bold",border:"Border",border_all:"Border all",border_inside:"Border inside",border_horizontal:"Border horizontal",border_vertical:"Border vertical",border_outside:"Border outside",border_left:"Border left",border_top:"Border top",border_right:"Border right",border_bottom:"Border bottom",border_none:"Border none",bulletedList:"Bulleted list",cancel:"Cancel",caption:"Insert description",cellProperties:"Cell properties",center:"Center",close:"Close",codeView:"Code view",color:"Color",colorPicker:"Color picker",column:"Column",comment:"Comments",commentAdd:"Add comment",commentShow:"Show comments",copy:"Copy",copyFormat:"Paint Formatting",cut:"Cut",default:"Default",deleteColumn:"Delete column",deleteRow:"Delete row",dir_ltr:"Left to right",dir_rtl:"Right to left",download:"Download",drag:"Drag",drawing:"Drawing",drawing_modal_title:"Drawing",edit:"Edit",embed:"Embed",embed_modal_title:"Embed",embed_modal_source:"Embed Source / URL",exportPDF:"Export to PDF",exportWord:"Export to Word",find:"Find",decrease:"Decrease",increase:"Increase",fileBrowser:"File browser",fileGallery:"File gallery",fileUpload:"File upload",fixedColumnWidth:"Fixed column width",font:"Font",fontColor:"Font color",fontSize:"Size",formats:"Formats",fullScreen:"Full screen",height:"Height",horizontalLine:"Horizontal line",horizontalSplit:"Horizontal split",hr_dashed:"Dashed",hr_dotted:"Dotted",hr_solid:"Solid",id:"ID",image:"Image",imageGallery:"Image gallery",image_modal_altText:"Alternative text",image_modal_file:"Select from files",image_modal_title:"Insert image",image_modal_url:"Image URL",importWord:"Import from Word",indent:"Indent",inlineStyle:"Inline style",insertColumnAfter:"Insert column after",insertColumnBefore:"Insert column before",insertRowAbove:"Insert row above",insertRowBelow:"Insert row below",insertLine:"Insert line",italic:"Italic",layout:"Layout",left:"Left",lineHeight:"Line height",link:"Link",link_modal_bookmark:"Bookmark",link_modal_downloadLinkCheck:"Download link",link_modal_newWindowCheck:"Open in new window",link_modal_text:"Text to display",link_modal_title:"Insert Link",link_modal_url:"URL to link",link_modal_relAttribute:"Rel attribute",list:"List",markdownView:"Markdown view",math:"Math",math_modal_fontSizeLabel:"Font Size",math_modal_inputLabel:"Mathematical Notation",math_modal_previewLabel:"Preview",math_modal_title:"Math",maxSize:"Max size",mediaGallery:"Media gallery",menu_bordered:"Bordered",menu_code:"Code",menu_neon:"Neon",menu_shadow:"Shadow",menu_spaced:"Spaced",menu_translucent:"Translucent",mergeCells:"Merge cells",minSize:"Min size",mirrorHorizontal:"Mirror, Horizontal",mirrorVertical:"Mirror, Vertical",newDocument:"New document",numberedList:"Numbered list",outdent:"Outdent",pageBreak:"Page break",pageDown:"Page down",pageNumber:"Page number",pageUp:"Page up",paragraphStyle:"Paragraph style",preview:"Preview",print:"print",proportion:"Constrain proportions",ratio:"Ratio",redo:"Redo",remove:"Remove",removeFormat:"Remove Format",replace:"Replace",replaceAll:"Replace all",resize100:"Zoom 100%",resize25:"Zoom 25%",resize50:"Zoom 50%",resize75:"Zoom 75%",resize:"Resize",revert:"Revert",revisionHistory:"Revision History",right:"Right",rotateLeft:"Rotate left",rotateRight:"Rotate right",row:"Row",save:"Save",search:"Search",selectAll:"Select All",showBlocks:"Show blocks",size:"Size",splitCells:"Split cells",strike:"Strike",submitButton:"Submit",subscript:"Subscript",superscript:"Superscript",table:"Table",tableHeader:"Table header",tableProperties:"Table properties",tags:"Tags",tag_blockquote:"Quote",codeBlock:"Code Block",tag_div:"Normal (DIV)",tag_h:"Header",tag_p:"Paragraph",tag_pre:"Code",template:"Template",textStyle:"Text style",title:"Title",underline:"Underline",undo:"Undo",unmergeCells:"Unmerge cells",unlink:"Unlink",verticalSplit:"Vertical split",video:"Video",videoGallery:"Video gallery",video_modal_file:"Select from files",video_modal_title:"Insert Video",video_modal_url:"Media embed URL, YouTube/Vimeo",width:"Width",codeLanguage:"Language",codeLanguage_none:"None",finder_matchCase:"Match Case",finder_wholeWord:"Whole Word",finder_regex:"Regular Expression",finder_prev:"Previous Match",finder_next:"Next Match",message_copy_success:"Copied to clipboard",message_copy_fail:"Copy failed. Please copy manually."};return void 0===e&&(t.SUNEDITOR_LANG||Object.defineProperty(t,"SUNEDITOR_LANG",{enumerable:!0,writable:!1,configurable:!1,value:{}}),Object.defineProperty(t.SUNEDITOR_LANG,"en",{enumerable:!0,writable:!0,configurable:!0,value:s})),s},"object"==typeof t.exports?t.exports=e.document?s(e,!0):function(t){if(!t.document)throw new Error("SUNEDITOR_LANG a window with a document");return s(t)}:s(e)}},e={};function s(i){var n=e[i];if(void 0!==n)return n.exports;var o=e[i]={exports:{}};return t[i].call(o.exports,o,o.exports,s),o.exports}s.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return s.d(e,{a:e}),e},s.d=(t,e)=>{for(var i in e)s.o(e,i)&&!s.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},s.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),s.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},(()=>{"use strict";var t={};s.r(t),s.d(t,{Browser:()=>jr,ColorPicker:()=>Ll,Controller:()=>Ii,Figure:()=>ji,HueSlider:()=>Nl,Modal:()=>Rl});var e={};s.r(e),s.d(e,{ApiManager:()=>Ur,FileManager:()=>Pl});var i={};s.r(i),s.d(i,{CommandMenu:()=>gn,ModalAnchorEditor:()=>Hl,SelectMenu:()=>Ai,_DragHandle:()=>_i});var n={};s.r(n),s.d(n,{EditorComponent:()=>xc,ModuleBrowser:()=>Cc,ModuleColorPicker:()=>_c,ModuleController:()=>wc,ModuleHueSlider:()=>kc,ModuleModal:()=>yc,PluginBrowser:()=>Ul,PluginCommand:()=>Vl,PluginDropdown:()=>jl,PluginDropdownFree:()=>Gl,PluginField:()=>Kl,PluginInput:()=>Yl,PluginModal:()=>Xl,PluginPopup:()=>Zl});const o=window,r=document,l=Symbol("noEventHandler"),a=Symbol("onOverComponent"),h=navigator.userAgent.toLowerCase();const c="function"==typeof ResizeObserver,d="function"==typeof navigator.clipboard?.write,u=/Edg/.test(navigator.userAgent),p=/(Mac|iPhone|iPod|iPad)/.test(navigator.userAgent),g=h.includes("chrome/")&&!h.includes("edge/"),m=!!h.match(/gecko\/\d+/),f=!!o.chrome,v=h.includes("applewebkit/")&&!h.includes("chrome"),b=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(h),y=navigator.maxTouchPoints>0&&"ontouchstart"in o,w=h.includes("android"),C=p?"⌘":"CTRL",_=p?"⇧":"+SHIFT",k=o.devicePixelRatio;let x=null;const $={_w:o,_d:r,NO_EVENT:l,ON_OVER_COMPONENT:a,getXMLHttpRequest:function(){return new XMLHttpRequest},getPageStyle:function(t){let e="";const s=(t||r).styleSheets;for(let t,i=0,n=s.length;i<n;i++){try{t=s[i].cssRules}catch{continue}if(t)for(let s=0,i=t.length;s<i;s++)e+=t[s].cssText}return e},getIncludePath:function(t,e){let s="";const i=[],n="js"===e?"script":"link",o="js"===e?"src":"href";let l="(?:";for(let e=0,s=t.length;e<s;e++)l+=t[e]+(e<s-1?"|":")");const a=new RegExp(`(^|.*[\\/])${l}(\\.[^\\/]+)?.${e}(?:\\?.*|;.*)?$`,"i"),h=new RegExp(`.+\\.${e}(?:\\?.*|;.*)?$`,"i");for(let t=r.getElementsByTagName(n),e=0;e<t.length;e++)h.test(t[e][o])&&i.push(t[e]);for(let t=0;t<i.length;t++){const e=i[t][o].match(a);if(e){s=e[0];break}}if(!s)throw new Error("[SUNEDITOR.helper.env.getIncludePath.fail] The SUNEDITOR installation path could not be automatically detected. (path: +"+s+", extension: "+e+")");return""===s&&(s=i.length>0?i[0][o]:""),s.includes(":/")||"//"===s.slice(0,2)||(s=!1===s.includes("/")?location.href.match(/^.*?:\/\/[^/]*/)[0]+s:location.href.match(/^[^?]*\/(?:)/)[0]+s),s},isResizeObserverSupported:c,isClipboardSupported:d,isEdge:u,isBlink:g,isGecko:m,isChromium:f,isSafari:v,isOSX_IOS:p,isAndroid:w,isMobile:b,isTouchDevice:y,canUseBeforeInput:function(){if(null!==x)return x;if(!r.body||"function"!=typeof r.execCommand)return!0;let t=!1;try{const e=r.createElement("div");e.setAttribute("contenteditable","true"),e.setAttribute("aria-hidden","true"),e.style.cssText="position: fixed; top: 0; left: -9999px; width: 1px; height: 1px; opacity: 0; pointer-events: none;";const s=r.activeElement;r.body.appendChild(e);const i=()=>{t=!0};e.addEventListener("beforeinput",i,!0),e.addEventListener("input",i,!0),e.focus({preventScroll:!0}),r.execCommand("insertText",!1,""),e.removeEventListener("beforeinput",i,!0),e.removeEventListener("input",i,!0),e.remove(),s&&s!==r.body&&"function"==typeof s.focus&&s.focus({preventScroll:!0})}catch{t=!0}return x=t},cmdIcon:C,shiftIcon:_,DPI:k,KATEX_WEBSITE:"https://katex.org/docs/supported.html",MATHJAX_WEBSITE:"https://www.mathjax.org/"},S=8203,E=String.fromCharCode(S),T=new RegExp(String.fromCharCode(S),"g"),M=new RegExp("^"+String.fromCharCode(S)+"+$");const N={zeroWidthSpace:E,zeroWidthRegExp:T,onlyZeroWidthRegExp:M,escapeStringRegexp:function(t){if("string"!=typeof t)throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}};function B(t,e=0){if(!t)return 0;const s=(t+"").match(/-?\d+(\.\d+)?/);if(!s||!s[0])return 0;const i=Number(s[0]);return e<0?i:0===e?Math.round(i):Number(i.toFixed(e))}const I={is:function(t){return/^-?\d+(\.\d+)?$/.test(t+"")},get:B,getOverlapRangeAtIndex:function(t,e,s,i){if(t<=i?e<s:e>s)return 0;const n=(t>s?t:s)-(e<i?e:i);return(n<0?-1*n:n)+1},isEven:function(t){return!(1&t)},isOdd:function(t){return!(1&~t)}},L=/&|\u00A0|'|"|<|>/g,A=/&| |'|"|<|>/g,O={"&":"&"," ":" ","'":"'",'"':""","<":"<",">":">"},R={"&":"&"," ":" ","'":"'",""":'"',"<":"<",">":">"},z=/[A-Z]/g,P=/-[a-zA-Z]/g,D={"xx-small":.5625,"x-small":.625,small:.8333,medium:1,large:1.125,"x-large":1.5,"xx-large":2,"xxx-large":2.5};function F(t){if(3===t.nodeType){const e=t.nodeValue.trim();return e?{type:"text",content:e}:null}if(1===t.nodeType){const e={type:"element",tag:t.tagName.toLowerCase(),attributes:{},children:[]};for(const s of t.attributes)e.attributes[s.name]=s.value;for(const s of t.childNodes){const t=F(s);t&&e.children.push(t)}return e}return null}function H(t){return t.replace(L,(t=>O[t]||t))}function q(t){return/^#[0-9a-f]{3}(?:[0-9a-f]{3})?$/i.test(t)}const W={htmlToJson:function(t){return F((new DOMParser).parseFromString(t,"text/html").body)},jsonToHtml:function t(e){if(!e)return"";if("text"===e.type)return H(e.content||"");if("element"===e.type){const{tag:s,attributes:i={},children:n=[]}=e,o=Object.entries(i).map((([t,e])=>`${t}="${H(e)}"`)).join(" "),r=`</${s}>`;return`${o?`<${s} ${o}>`:`<${s}>`}${n.map(t).join("")}${r}`}return""},htmlToEntity:H,entityToHTML:function(t){return t.replace(A,(t=>R[t]||t))},debounce:function(t,e){let s;function i(...i){o.clearTimeout(s),s=o.setTimeout((()=>{s=null,t(...i)}),e)}return i.cancel=()=>{o.clearTimeout(s),s=null},i},syncMaps:function(t,e){e.forEach(((e,s)=>{t.set(s,e)})),t.forEach(((s,i)=>{e.has(i)||t.delete(i)}))},mergeMaps:function(...t){const e=t.filter((t=>t instanceof Map)).flatMap((t=>[...t]));return new Map(e)},getValues:function(t){return t?Object.keys(t).map((function(e){return t[e]})):[]},camelToKebabCase:function t(e){return"string"==typeof e?e.replace(z,(t=>"-"+t.toLowerCase())):e.map((function(e){return t(e)}))},kebabToCamelCase:function t(e){return"string"==typeof e?e.replace(P,(t=>t.replace("-","").toUpperCase())):e.map((function(e){return t(e)}))},toFontUnit:function(t,e){const s=e.match(/(\d+(?:\.\d+)?)(.+)/),i=s?Number(s[1]):D[e],n=s?s[2]:"rem";let o=i;switch(/em/.test(n)?o=Math.round(i/.0625):"pt"===n?o=Math.round(1.333*i):"%"===n&&(o=i/100),t){case"em":case"rem":return(.0625*o).toFixed(2)+t;case"%":return 100*Number((.0625*o).toFixed(2))+t;case"pt":return Math.round(o/1.333)+t;default:return o+t}},nodeListToArray:function(t){return t?Array.prototype.slice.call(t):[]},swapKeyValue:function(t){const e={},s=Object.prototype.hasOwnProperty;for(const i in t)s.call(t,i)&&(e[t[i]]=i);return e},createElementWhitelist:function(t){return new RegExp(`<\\/?\\b(?!\\b${(t||"").replace(/\|/g,"\\b|\\b")}\\b)[^>]*>`,"gi")},createElementBlacklist:function(t){return new RegExp(`<\\/?\\b(?:\\b${(t||"^").replace(/\|/g,"\\b|\\b")}\\b)[^>]*>`,"gi")},isHexColor:q,rgb2hex:function(t){if(q(t)||!t)return t;const e=t.match(/^rgba?[\s+]?\(([\d]+)[\s+]?,[\s+]?([\d]+)[\s+]?,[\s+]?([\d]+)[\s+]?/i);if(e&&e.length>=4){const s=("0"+parseInt(e[1],10).toString(16)).slice(-2),i=("0"+parseInt(e[2],10).toString(16)).slice(-2),n=("0"+parseInt(e[3],10).toString(16)).slice(-2);let o="";if(t.includes("rgba")){const e=t.match(/,\s*([\d]+\.?[\d]*)\s*\)/);e&&(o=("0"+Math.round(255*parseFloat(e[1])).toString(16)).slice(-2))}return`#${s}${i}${n}${o}`}return t},getWidthInPercentage:function(t,e){const s=e||t.parentElement,i=o.getComputedStyle(s),n=B(i.paddingLeft,-1),r=B(i.paddingRight,-1),l=s.offsetWidth-s.clientWidth,a=s.offsetWidth-n-r-l;return t.offsetWidth/a*100},textToAnchor:function(t){const e=/https?:\/\/[^\s]+/g;if(3===t.nodeType&&e.test(t.textContent)&&!/^A$/i.test(t.parentNode?.nodeName)){const s=t.textContent,i=r.createDocumentFragment();let n=0;return s.replace(e,((t,e)=>{e>n&&i.appendChild(r.createTextNode(s.slice(n,e)));const o=r.createElement("a");return o.href=t,o.target="_blank",o.textContent=t,i.appendChild(o),n=e+t.length,t})),n<s.length&&i.appendChild(r.createTextNode(s.slice(n))),t.parentNode.replaceChild(i,t),!0}return!1},spanToStyleNode:function(t,e){if(1===e.nodeType&&/^SPAN$/i.test(e.nodeName)&&e.hasAttribute("style")){const s=e.getAttribute("style"),i=[];if(Object.keys(t).forEach((e=>{if(t[e].regex.test(s)){const s=r.createElement(t[e].tag);i.push(s)}})),i.length>0){const t=r.createElement("span");let s=e.firstChild;i.forEach(((e,s)=>{0===s?t.appendChild(e):i[s-1].appendChild(e)}));const n=i[i.length-1];for(;s;){const t=s.nextSibling;n.appendChild(s),s=t}e.appendChild(t)}}},addUrlQuery:function(t,e){if(e.length>0)if(/\?/.test(t)){const s=t.split("?");t=s[0]+"?"+e+"&"+s[1]}else t+="?"+e;return t},_setDefaultOptionStyle:function(t,e){let s="";t.get("height")&&(s+="height:"+t.get("height")+";"),t.get("minHeight")&&(s+="min-height:"+t.get("minHeight")+";"),t.get("maxHeight")&&(s+="max-height:"+t.get("maxHeight")+";"),t.get("width")&&(s+="width:"+t.get("width")+";"),t.get("minWidth")&&(s+="min-width:"+t.get("minWidth")+";"),t.get("maxWidth")&&(s+="max-width:"+t.get("maxWidth")+";");let i="",n="",o="";const r=(e=s+e).split(";");for(let e,s=0,l=r.length;s<l;s++)e=r[s].trim(),e&&(/^(min-|max-)?width\s*:/.test(e)||/^(z-index|position|display)\s*:/.test(e)?i+=e+";":/^(min-|max-)?height\s*:/.test(e)?(/^height/.test(e)&&"auto"===e.split(":")[1].trim()&&t.set("height","auto"),n+=e+";"):o+=e+";");return{top:i,frame:n,editor:o}},_setIframeStyleLinks:function(t){let e="";if(t){const s=r.getElementsByTagName("link");for(let i,n=0,o=t.length;n<o;n++){i=[];const o=t[n];if("*"===o)for(let t=0,e=s.length;t<e;t++)"stylesheet"===s[t].rel&&s[t].href&&i.push(s[t].href);else if(/(^https?:\/\/)|(^data:text\/css,)/.test(o))i.push(o);else{const t=new RegExp(`(^|.*[\\/])${o}(\\..+)?.css((\\??.+?)|\\b)$`,"i");for(let e,n=0,o=s.length;n<o;n++)e=s[n].href.match(t),e&&i.push(e[0])}if(!i||0===i.length)throw new Error('[SUNEDITOR.constructor.iframe.fail] The suneditor CSS files installation path could not be automatically detected. Please set the option property "iframe_cssFileName" before creating editor instances.');for(let t=0,s=i.length;t<s;t++)e+='<link href="'+i[t]+'" rel="stylesheet">'}}return e},_setAutoHeightStyle:function(t){return"auto"===t?"<style>\n/** Iframe height auto */\nbody{height: min-content; overflow: hidden;}\n</style>":""}},U=W,V=/(\s|^)(katex|MathJax|se-exclude-format)(\s|$)/;function j(t){if(null==t)return!1;if("string"!=typeof t){if(G(t)){const e=t.children;for(let t=0,s=e.length;t<s;t++){if(!J(e[t]))return!1}}t=t.textContent}return""===t||M.test(t)}function G(t){return 1===t?.nodeType}function K(t){return/^(OL|UL)$/i.test("string"==typeof t?t:t?.nodeName)}function Y(t){return/^TABLE$/i.test("string"==typeof t?t:t?.nodeName)}function X(t){return/^(TD|TH)$/i.test("string"==typeof t?t:t?.nodeName)}function Z(t){return/^BR$/i.test("string"==typeof t?t:t?.nodeName)}function J(t){return/^(BR|COLGROUP|COL|THEAD|TBODY|TFOOT|TR|AREA|BASE|EMBED|HR|IMG|INPUT|KEYGEN|LINK|META|PARAM|SOURCE|TRACK|WBR)$/i.test("string"==typeof t?t:t?.nodeName)}function Q(t){if(1!==t?.nodeType)return!1;const e=t.classList;return!!e&&(e.contains("se-component")||e.contains("se-flex-component"))}function tt(t){if(1!==t?.nodeType)return!1;const e=t.classList;return!!e&&("BODY"===t.nodeName.toUpperCase()||e.contains("se-wrapper-wysiwyg")||e.contains("sun-editor-carrier-wrapper")||e.contains("se-wrapper"))}function et(t){return t?.hasAttribute("data-important-disabled")}const st={isZeroWidth:j,isEdgePoint:function(t,e,s){return"end"!==s&&0===e||(!s||"front"!==s)&&!t.nodeValue&&e<=1||(!s||"end"===s)&&t.nodeValue&&e>=t.nodeValue.length},isText:function(t){return 3===t?.nodeType},isElement:G,isInputElement:function(t){return G(t)&&/^(INPUT|TEXTAREA|SELECT|OPTION)$/i.test(t.nodeName)},isButtonElement:function(t){return G(t)&&/^(BUTTON)$/i.test(t.nodeName)},isList:K,isListCell:function(t){return/^LI$/i.test("string"==typeof t?t:t?.nodeName)},isTable:Y,isTableElements:function(t){return/^(TABLE|THEAD|TBODY|TR|TH|TD|COL)$/i.test("string"==typeof t?t:t?.nodeName)},isTableCell:X,isTableRow:function(t){return/^TR$/i.test("string"==typeof t?t:t?.nodeName)},isBreak:Z,isAnchor:function(t){return/^A$/i.test("string"==typeof t?t:t?.nodeName)},isMedia:function(t){return/^(IMG|IFRAME|AUDIO|VIDEO|CANVAS)$/i.test("string"==typeof t?t:t?.nodeName)},isIFrame:function(t){return/^IFRAME$/i.test("string"==typeof t?t:t?.nodeName)},isFigure:function(t){return/^FIGURE$/i.test("string"==typeof t?t:t?.nodeName)},isContentLess:J,isEmptyLine:function(t){if(!t?.parentNode)return!0;const e=t;return!e.querySelector("IMG, IFRAME, AUDIO, VIDEO, CANVAS, TABLE")&&(e.children.length<=1||Z(e.firstElementChild))&&j(e.textContent)},isComponentContainer:Q,isWysiwygFrame:tt,isNonEditable:function(t){return 1===t?.nodeType&&"false"===t.getAttribute("contenteditable")},isSpanWithoutAttr:function(t){if(1!==t?.nodeType)return!1;const e=t;return/^SPAN$/i.test(e.nodeName)&&!e.className&&0===e.style.length},isSameAttributes:function(t,e){if(3===t.nodeType&&3===e.nodeType)return!0;if(3===t.nodeType||3===e.nodeType)return!1;const s=t,i=e,n=s.style,o=i.style;let r=0;for(let t=0,e=n.length;t<e;t++)n[n[t]]===o[n[t]]&&r++;const l=s.classList,a=i.classList;let h=0;for(let t=0,e=l.length;t<e;t++)a.contains(l[t])&&h++;return r===o.length&&r===n.length&&h===a.length&&h===l.length},isExcludeFormat:function(t){return V.test(t?.className)},isUneditable:function(t){return t?.classList.contains("__se__uneditable")},isImportantDisabled:et},it=st;function nt(t){const e=Object.prototype.toString.call(t);return"[object HTMLCollection]"===e||"[object NodeList]"===e||"[object Array]"===e}function ot(t,e,s){const i=r.createElement(t);if(e)for(const t in e)void 0!==e[t]&&null!==e[t]&&i.setAttribute(t,e[t]);return s&&("string"==typeof s?i.innerHTML=s:"object"==typeof s&&i.appendChild(s)),i}function rt(t){return r.createTextNode(t||"")}function lt(t,e){let s=-1;for(let i=0,n=t.length;i<n;i++)if(t[i]===e){s=i;break}return s}const at=/(\s|^)(se-block-hover|se-block-dragging)(?=\s|$)/g;function ht(t,e,s){const i=t,n=e;if(n.style.length>0){const t=n.style;for(let e=0,s=t.length;e<s;e++)i.style[t[e]]=t[t[e]]}const o=n.attributes;for(let t,e=0,n=o.length;e<n;e++)if(t=o[e].name.toLowerCase(),s?.includes(t)||!o[e].value)i.removeAttribute(t);else if("style"!==t)if("class"===t){const t=o[e].value.replace(at," ").replace(/\s+/g," ").trim();t?i.setAttribute("class",t):i.removeAttribute("class")}else i.setAttribute(o[e].name,o[e].value)}function ct(t,e){if(t&&1===t.nodeType)return e.split("|").some((e=>t.classList.contains(e)))}function dt(t,e){if(!t)return;const s=nt(t)?t:[t],i=e.split("|");for(let t=0,e=s.length;t<e;t++){const e=s[t];if(e&&1===e.nodeType)for(const t of i)t&&e.classList.add(t)}}function ut(t,e){if(!t)return;const s=nt(t)?t:[t],i=e.split("|");for(let t=0,e=s.length;t<e;t++){const e=s[t];if(e&&1===e.nodeType)for(const t of i)t&&e.classList.remove(t)}}function pt(t=r){return{w:t.documentElement.clientWidth,h:t.documentElement.clientHeight}}const gt={clone:function(t,e=!1){return t.cloneNode(e)},createElement:ot,createTextNode:rt,getAttributesToString:function(t,e){const s=t.attributes;if(!s)return"";let i="";for(let t=0,n=s.length;t<n;t++)e?.includes(s[t].name)||(i+=s[t].name+'="'+H(s[t].value)+'" ');return i},arrayFilter:function(t,e){if(!t||0===t.length)return null;e||=()=>!0;const s=[];for(let i,n=0,o=t.length;n<o;n++)i=t[n],e(i)&&s.push(i);return s},arrayFind:function(t,e){if(!t||0===t.length)return null;e||=()=>!0;for(let s,i=0,n=t.length;i<n;i++)if(s=t[i],e(s))return s;return null},arrayIncludes:function(t,e){for(let s=0;s<t.length;s++)if(t[s]===e)return!0;return!1},getArrayIndex:lt,nextIndex:function(t,e){const s=lt(t,e);return-1===s?-1:s+1},prevIndex:function(t,e){const s=lt(t,e);return-1===s?-1:s-1},copyTagAttributes:ht,copyFormatAttributes:function(t,e){const s=e.cloneNode(!1);s.className=s.className.replace(/(\s|^)__se__format__[^\s]+/g,""),ht(t,s)},removeItem:function(t){t&&("remove"in t&&"function"==typeof t.remove?t.remove():t.parentNode&&t.parentNode.removeChild(t))},changeElement:function(t,e){if(t)if("string"==typeof e)if("outerHTML"in t)t.outerHTML=e;else{const s=ot("DIV");s.innerHTML=e,t.parentNode.replaceChild(s.firstChild,t)}else 1===e?.nodeType&&t.parentNode.replaceChild(e,t)},changeTxt:function(t,e){t&&e&&(t.textContent=e)},setStyle:function(t,e,s){for(let i,n=0,o=(t=Array.isArray(t)?t:[t]).length;n<o;n++)i=t[n],i.style[e]=s,0===i.style.length&&i.removeAttribute("style")},getStyle:function(t,e){if(1===t?.nodeType)return t.style[e]},setDisabled:function(t,e,s){for(let i=0,n=t.length;i<n;i++){const n=t[i];!s&&et(n)||(n.disabled=e),s&&(e?n.setAttribute("data-important-disabled",""):n.removeAttribute("data-important-disabled"))}},hasClass:ct,addClass:dt,removeClass:ut,toggleClass:function(t,e,s){if(!t||1!==t.nodeType)return;const i=t;i.classList.toggle(e,s),i.className.trim()||i.removeAttribute("class")},flashClass:function(t,e,s=120){dt(t,e),o.setTimeout((()=>{ut(t,e)}),s)},getClientSize:pt,getViewportSize:function(){return"visualViewport"in o?{top:o.visualViewport.pageTop,left:o.visualViewport.pageLeft,scale:o.visualViewport.scale}:{top:0,left:0,scale:1}},applyInlineStylesAll:function(t,e,s){if(!t)return console.warn('"parentTarget" is not exist'),null;let i=t;const n=r.createElement("DIV");if(n.style.display="none",/body/i.test(i.nodeName)){const t=r.createElement("DIV"),e=i.attributes;for(let s=0,i=e.length;s<i;s++)t.setAttribute(e[s].name,e[s].value);t.innerHTML=i.innerHTML,i=t}else i=i.cloneNode(!0);n.appendChild(i),r.body.appendChild(n);const l=Array.from(i.querySelectorAll("*")),a=e?[i].concat(l):l;for(let t,e=0;t=a[e];e++){if(1!==t.nodeType)continue;const e=o.getComputedStyle(t),i=t.style;for(const t of s)i.setProperty(t,e.getPropertyValue(t)||"")}return r.body.removeChild(n),i},waitForMediaLoad:function(t,e=5e3){const s=t||r;return new Promise((t=>{const i=["img","video","audio","iframe"].flatMap((t=>Array.from(s.querySelectorAll(t))));if(0===i.length)return void t();const n=i.map((t=>{if(function(t){return"[object HTMLImageElement]"===Object.prototype.toString.call(t)}(t)){if(t.complete)return Promise.resolve()}else if(function(t){const e=Object.prototype.toString.call(t);return"[object HTMLVideoElement]"===e||"[object HTMLAudioElement]"===e}(t)){if(t.readyState>=2)return Promise.resolve()}else if(function(t){return"[object HTMLIFrameElement]"===Object.prototype.toString.call(t)}(t))try{if("complete"===t.contentDocument?.readyState)return Promise.resolve()}catch(t){console.warn(["[SUNEDITOR] Iframe load error",t])}return new Promise((e=>{t.addEventListener("load",e,{once:!0}),t.addEventListener("error",e,{once:!0})}))}));Promise.race([Promise.all(n),new Promise((t=>o.setTimeout(t,e)))]).then((()=>{t()}))}))},getRootCssVar:function(t){return r.documentElement.style.getPropertyValue(t)},setRootCssVar:function(t,e){r.documentElement.style.setProperty(t,e)},createTooltipInner:function(t){return`<span class="se-tooltip-inner"><span class="se-tooltip-text">${t}</span></span>`}};function mt(t){let e=0;for(;t=t.previousSibling;)e+=1;return e}function ft(t,e,s){const i=[];let n=!0;return wt(t,(t=>{if(t===e&&(n=!1),n&&!it.isWysiwygFrame(t)){if(s&&3===t.nodeType){let e=null,i=null;s.s=s.e=0;let n=t.previousSibling;for(;3===n?.nodeType;)i=n.textContent.replace(T,""),s.s+=i.length,t.textContent=i+t.textContent,e=n,n=n.previousSibling,gt.removeItem(e);let o=t.nextSibling;for(;3===o?.nodeType;)i=o.textContent.replace(T,""),s.e+=i.length,t.textContent+=i,e=o,o=o.nextSibling,gt.removeItem(e)}i.push(t)}return!1})),i.map(mt).reverse()}function vt(t,e){let s,i=e;for(let e=0,n=t.length;e<n&&(s=i.childNodes,0!==s.length);e++)i=s.length<=t[e]?s[s.length-1]:s[t[e]];return i}function bt(t,e,s){const i=[];return s??=1/0,!t||s<=0||0===t.childNodes.length||(e||=()=>!0,function t(n,o){if(o>s)return;if(o>0&&e(n)&&i.push(n),o===s)return;const r=n.childNodes;for(let e=0,s=r.length;e<s;e++)t(r[e],o+1)}(t,0)),i}function yt(t){if(!t||it.isWysiwygFrame(t))return-1;let e=0;for(t=t.parentNode;t&&!it.isWysiwygFrame(t);)e+=1,t=t.parentNode;return e}function wt(t,e,s){let i;if("function"==typeof e)i=e;else if("object"==typeof e)i=t=>t===e;else{let t;/^\./.test(e)?(t="className",e="(\\s|^)"+e.split(".")[1]+"(\\s|$)"):/^#/.test(e)?(t="id",e="^"+e.split("#")[1]+"$"):/^:/.test(e)?(t="name",e="^"+e.split(":")[1]+"$"):(t="nodeName",e="^"+e+"$");const s=new RegExp(e,"i");i=e=>s.test(e[t])}s||=1/0;let n=0;for(;t&&!i(t);){if(n>=s||it.isWysiwygFrame(t))return null;t=t.parentElement,n++}return t}const Ct={getPositionIndex:mt,getNodePath:ft,getNodeFromPath:vt,getChildNode:function(t,e){let s=null;if(!t)return s;const i=t;return i.children&&0!==i.children.length?(e||=()=>!0,function t(n){if(i!==n&&e(n))return s=n,!0;if(n.children)for(let e=0,s=n.children.length;e<s;e++)t(n.children[e])}(i),s):s},getListChildren:function(t,e,s){const i=[];if(s??=1/0,!t||s<=0)return i;const n=t;return n.children&&0!==n.children.length?(e||=()=>!0,function t(o,r){if(!(r>s)&&(r>0&&n!==o&&e(o)&&i.push(o),r!==s&&o.children))for(let e=0,s=o.children.length;e<s;e++)t(o.children[e],r+1)}(n,0),i):i},getListChildNodes:bt,getNodeDepth:yt,sortNodeByDepth:function(t,e){const s=e?1:-1,i=-1*s;t.sort((function(t,e){if(!it.isListCell(t)||!it.isListCell(e))return 0;const n=yt(t),o=yt(e);return n>o?s:n<o?i:0}))},compareElements:function(t,e){let s=t,i=e;const n=yt(t),o=yt(e);if(n>o){let t=n-o;for(;t>0&&s;)s=s.parentElement,t--}else if(o>n){let t=o-n;for(;t>0&&i;)i=i.parentElement,t--}for(;s&&i&&s.parentElement!==i.parentElement;)s=s.parentElement,i=i.parentElement;if(!s?.parentNode||!i?.parentNode)return{ancestor:null,a:t,b:e,result:0};const r=s.parentNode.childNodes,l=gt.getArrayIndex(r,s),a=gt.getArrayIndex(r,i);return{ancestor:s.parentElement,a:s,b:i,result:l>a?1:l<a?-1:0}},getParentElement:wt,getParentElements:function(t,e,s){let i;if("function"==typeof e)i=e;else if("object"==typeof e)i=t=>t===e;else{let t;/^\./.test(e)?(t="className",e="(\\s|^)"+e.split(".")[1]+"(\\s|$)"):/^#/.test(e)?(t="id",e="^"+e.split("#")[1]+"$"):/^:/.test(e)?(t="name",e="^"+e.split(":")[1]+"$"):(t="nodeName",e="^"+e+"$");const s=new RegExp(e,"i");i=e=>s.test(e[t])}const n=[];s||=1/0;let o=0;for(;o<=s&&t&&!it.isWysiwygFrame(t);)i(t)&&n.push(t),t=t.parentElement,o++;return n},getCommandTarget:function(t){let e=t;for(;e&&!/^(UL)$/i.test(e.nodeName)&&!gt.hasClass(e,"sun-editor");){if(e.hasAttribute("data-command"))return e;e=e.parentElement}return null},getEventTarget:function(t){return t.target},getEdgeChild:function(t,e,s){let i;if("function"==typeof e)i=e;else if("object"==typeof e)i=function(t){return t===e};else{let t;/^\./.test(e)?(t="className",e="(\\s|^)"+e.split(".")[1]+"(\\s|$)"):/^#/.test(e)?(t="id",e="^"+e.split("#")[1]+"$"):/^:/.test(e)?(t="name",e="^"+e.split(":")[1]+"$"):(t="nodeName",e="^"+("text"===e?"#"+e:e)+"$");const s=new RegExp(e,"i");i=function(e){return s.test(e[t])}}const n=bt(t,(t=>i(t)),null);return n[s?n.length-1:0]},getEdgeChildNodes:function(t,e){if(t){for(e||=t;t&&1===t.nodeType&&t.childNodes.length>0&&!it.isBreak(t);)t=t.firstChild;for(;e&&1===e.nodeType&&e.childNodes.length>0&&!it.isBreak(e);)e=e.lastChild;return{sc:t,ec:e||t}}},getPreviousDeepestNode:function(t,e){let s=t.previousSibling;if(!s){for(let i=t.parentNode;i;i=i.parentNode){if(i===e)return null;if(i.previousSibling){s=i.previousSibling;break}}if(!s)return null}if(it.isNonEditable(s))return s;for(;!it.isComponentContainer(s)&&s.lastChild;)s=s.lastChild;return s},getNextDeepestNode:function(t,e){let s=t.nextSibling;if(!s){for(let i=t.parentNode;i;i=i.parentNode){if(i===e)return null;if(i.nextSibling){s=i.nextSibling;break}}if(!s)return null}if(it.isNonEditable(s))return s;for(;!it.isComponentContainer(s)&&s.firstChild;)s=s.firstChild;return s},findTextIndexOnLine:function(t,e,s,i){if(!t)return 0;i||=()=>!0;let n=0,o=!1;return function t(r){if(!o&&8!==r.nodeType&&!i(r))if(3===r.nodeType){if(r===e)return n+=s,void(o=!0);n+=r.textContent.length}else if(1===r.nodeType){const e=r.childNodes;for(let s=0,i=e.length;s<i;s++)if(t(e[s]),o)return}}(t),n},findTabEndIndex:function(t,e,s){if(!t)return 0;const i=t.textContent,n=new RegExp(`((\\u00A0|\\s){${s},})`,"g");let o;for(n.lastIndex=e;null!==(o=n.exec(i));)if(o.index>=e){const t=o.index+o[0].length-1;return t+(i.slice(0,t+1).match(/[^\u00A0\s]/g)||[]).length+s}return 0},findVisualLastCell:function(t){if(!t||0===t.length)return null;const e={};let s=null,i=-1,n=-1;for(const o of t){const t=o.parentElement.rowIndex,r=o.rowSpan||1,l=o.colSpan||1;e[t]||=[];let a=0;const h=e[t];for(;h[a];)a++;for(let t=0;t<l;t++)h[a+t]=!0;for(let s=1;s<r;s++){const i=t+s;e[i]||=[];for(let t=0;t<l;t++)e[i][a+t]=!0}const c=t+r-1,d=a+l-1;(c>i||c===i&&d>n)&&(i=c,n=d,s=o)}return s},getScrollParents:function(t){const e=[];let s=t?.parentElement;for(;s&&!/^(body|html)$/i.test(s.nodeName);){const t=o.getComputedStyle(s),{overflow:i,overflowX:n,overflowY:r}=t;[i,n,r].some((t=>["auto","scroll","overlay"].includes(t)))&&e.push(s),s=s.parentElement}return e},getIframeDocument:function(t){return t.contentWindow?.document||t.contentDocument}};const _t={query:Ct,check:it,utils:gt},kt="ArrowLeft|ArrowUp|ArrowRight|ArrowDown",xt="F1|F2|F3|F4|F5|F6|F7|F8|F9|F10|F11|F12",$t=kt.split("|"),St="Backspace|Delete".split("|"),Et=`Backspace|Tab|Enter|ShiftLeft|ShiftRight|ControlLeft|ControlRight|AltLeft|AltRight|Pause|CapsLock|Escape|PageUp|PageDown|End|Home|${kt}|Insert|Delete|${xt}|NumLock|ScrollLock`.split("|"),Tt="Backspace|Enter|Delete".split("|"),Mt="Backspace|Enter|Delete".split("|"),Nt=`ControlLeft|ControlRight|AltLeft|AltRight|Pause|CapsLock|Escape|Insert|${xt}|NumLock|ScrollLock`.split("|");const Bt={write:async function(t){if(!d)return console.error("Clipboard is not supported in this browser."),!1;let e="",s="";"string"==typeof t?(e=t,s=t):G(t)?(t.querySelectorAll("iframe").forEach((t=>{const e=document.createElement("div"),s={};for(const e of Array.from(t.attributes))s[e.name]=e.value;e.setAttribute("data-se-iframe-holder","1"),e.setAttribute("data-se-iframe-holder-attrs",JSON.stringify(s)),e.innerText=`[iframe: ${t.src}]`,t.replaceWith(e)})),e=t.outerHTML,s=t.textContent):(e=t.textContent,s=t.textContent);try{await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([e],{type:"text/html"}),"text/plain":new Blob([s],{type:"text/plain"})})])}catch{console.warn("[SUNEDITOR.copy.warn] This browser is not supported Clipboard API");try{await navigator.clipboard.writeText(s||function(t){const e=document.createElement("div");return e.innerHTML=t,e.textContent||e.innerText||""}(e))}catch(t){console.error("[SUNEDITOR.copy.fail] "+t)}}}},It=/^(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/i,Lt=/^[\u200B\uFEFF]+$/;function At(t){const e=t.trim();return""===e||Lt.test(e)}const Ot={strong:"**",b:"**",em:"*",i:"*",del:"~~",s:"~~",mark:"=="};function Rt(t){if(!t||0===t.length)return"";const e=[];for(let s=0;s<t.length;s++){const i=qt(t[s],"",!1);if(i){if(e.length>0){const t=e[e.length-1];!t||t.endsWith(" ")||t.endsWith("\n")||i.startsWith(" ")||i.startsWith("\n")||e.push(" ")}e.push(i)}}return e.join("")}function zt(t){return t?"text"===t.type?t.content||"":t.children?t.children.map(zt).join(""):"":""}function Pt(t){if(!t)return"";if("text"===t.type)return t.content||"";const{tag:e,attributes:s={},children:i=[]}=t,n=Object.entries(s).map((([t,e])=>`${t}="${e}"`)).join(" "),o=n?`<${e} ${n}>`:`<${e}>`;if(It.test(e))return o;return`${o}${i.map(Pt).join("")}</${e}>`}function Dt(t,e){return t?t.split("\n").map((t=>t?e+t:"")).join("\n")+"\n":""}function Ft(t,e,s){const i=t.children||[];let n="",o=1;for(const t of i){if("element"!==t.type||"li"!==t.tag)continue;const i=s?`${o}. `:"- ",r=t.children||[];let l="",a="";const h=e+" ".repeat(i.length);let c="";const d=r[0];d&&"element"===d.type&&"input"===d.tag&&"checkbox"===d.attributes?.type&&(c=void 0!==d.attributes.checked?"[x] ":"[ ] ");for(let t=0;t<r.length;t++){const e=r[t];if(0===t&&c)continue;if("element"!==e.type){l+=qt(e,"",!1);continue}const s=e.tag;if("ul"===s||"ol"===s)a+=Ft(e,h,"ol"===s);else if("table"===s)a+=Dt(Ht(e),h);else if("figure"===s){const t=(e.children||[]).find((t=>"element"===t.type&&"table"===t.tag));a+=Dt(t?Ht(t):qt(e,"",!0),h)}else"blockquote"===s||"pre"===s?a+=Dt(qt(e,"",!0),h):l+=qt(e,"",!1)}n+=`${e}${i}${c}${l.trim()}\n`,a&&(n+=a),o++}return n}function Ht(t){const e=[];let s=!1;if(function t(i,n){for(const o of i.children||[])if("thead"===o.tag)t(o,!0);else if("tbody"===o.tag||"tfoot"===o.tag)t(o,!1);else if("tr"===o.tag){const t=[];for(const e of o.children||[])if("td"===e.tag||"th"===e.tag){const s=Rt(e.children).trim(),i=parseInt(e.attributes?.colspan,10)||1,n=parseInt(e.attributes?.rowspan,10)||1;t.push({content:s,colspan:i,rowspan:n})}const i=n||!s&&o.children?.some((t=>"th"===t.tag));i&&(s=!0),e.push({cells:t,isHeader:i})}}(t,!1),0===e.length)return"";const i=e.filter((t=>t.isHeader)),n=e.filter((t=>!t.isHeader)),o=[...i,...n];let r=0;for(const t of o){let e=0;for(const s of t.cells)e+=s.colspan;e>r&&(r=e)}const l=Array.from({length:o.length},(()=>new Array(r).fill(null)));for(let t=0;t<o.length;t++){let e=0;for(const s of o[t].cells){for(;e<r&&null!==l[t][e];)e++;if(e>=r)break;for(let i=0;i<s.rowspan&&t+i<o.length;i++)for(let n=0;n<s.colspan&&e+n<r;n++)l[t+i][e+n]=0===i&&0===n?s.content:"";e+=s.colspan}for(let e=0;e<r;e++)null===l[t][e]&&(l[t][e]="")}let a="";if(i.length>0){a+="| "+l[0].join(" | ")+" |\n",a+="| "+l[0].map((()=>"---")).join(" | ")+" |\n";for(let t=1;t<l.length;t++)a+="| "+l[t].join(" | ")+" |\n"}else{a+="| "+new Array(r).fill(" ").join(" | ")+" |\n",a+="| "+new Array(r).fill("---").join(" | ")+" |\n";for(let t=0;t<l.length;t++)a+="| "+l[t].join(" | ")+" |\n"}return a}function qt(t,e,s){if(!t)return"";if("text"===t.type)return(t.content||"").replace(/[\u200B\uFEFF]/g,"");if("element"!==t.type)return"";const{tag:i,attributes:n={},children:o=[]}=t;if("body"===i)return o.map((t=>qt(t,"",!0))).join("");const r=/^h([1-6])$/.exec(i);if(r){const t=Rt(o).trim();if(!t)return"\n";const e=parseInt(r[1],10);return`${"#".repeat(e)} ${t}\n\n`}if("p"===i){const t=Rt(o);return t.trim()?`${t.trim()}\n\n`:"\n"}if("br"===i)return"\n";if("hr"===i)return"---\n\n";const l=Ot[i];if(l){return`${l}${Rt(o)}${l}`}if("code"===i){const t=zt({children:o});return t.includes("`")?"`` "+t+" ``":"`"+t+"`"}if("kbd"===i){return`<kbd>${zt({children:o})}</kbd>`}if("sub"===i){return`<sub>${Rt(o)}</sub>`}if("sup"===i){return`<sup>${Rt(o)}</sup>`}if("a"===i){const t=n.href||"",e=Rt(o),s=n.title;return s?`[${e}](${t} "${s}")`:`[${e}](${t})`}if("img"===i){const t=n.src||"";return``}if("blockquote"===i){return o.map((t=>qt(t,"",!0))).join("").replace(/\n$/,"").split("\n").map((t=>`> ${t}`)).join("\n")+"\n\n"}if("pre"===i){let e="",s="";const i=o.find((t=>"element"===t.type&&"code"===t.tag));return i?(e=(i.attributes?.class||"").replace(/^language-/,""),s=zt(i)):(e=(t.attributes?.class||"").match(/language-(\S+)/)?.[1]||"",s=zt({children:o})),"```"+e+"\n"+s+"\n```\n\n"}if("details"===i)return Pt(t)+"\n\n";if("summary"===i)return Pt(t);if("ul"===i)return Ft(t,e,!1)+"\n";if("ol"===i)return Ft(t,e,!0)+"\n";if("table"===i)return Ht(t)+"\n";if("dl"===i){let t="";for(const e of o)"element"===e.type&&("dt"===e.tag?t+=Rt(e.children).trim()+"\n":"dd"===e.tag&&(t+=": "+Rt(e.children).trim()+"\n"));return t+"\n"}if("dt"===i||"dd"===i)return Rt(o).trim();if("div"===i){if(n.class&&/se-component/.test(n.class))return o.map((t=>qt(t,e,!0))).join("");const t=Rt(o);return s?t+"\n\n":t}if("span"===i)return n.style||n.class?Pt(t):Rt(o);if("figure"===i){const t=o.map((t=>qt(t,e,!0))).join("");return/\n$/.test(t)?t:t+"\n\n"}if("figcaption"===i){const t=Rt(o).trim();return t?t+"\n\n":""}return"video"===i||"audio"===i||"iframe"===i?Pt(t)+"\n\n":Pt(t)}function Wt(t){if(!t)return"";const e=[];function s(t){return e.push(t),""+(e.length-1)+""}return t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=t.replace(/\\([\\*_~`[\]()#!|{}<>+-])/g,((t,e)=>s(e)))).replace(/``\s(.+?)\s``/g,((t,e)=>s("<code>"+e+"</code>")))).replace(/`([^`]+)`/g,((t,e)=>s("<code>"+e+"</code>")))).replace(/!\[([^\]]*)\]\(([^)\s]+)(?:\s+"([^"]*)")?\)/g,((t,e,i,n)=>s(n?`<img src="${i}" alt="${e}" title="${n}">`:`<img src="${i}" alt="${e}">`)))).replace(/\[([^\]]+)\]\(([^)\s]+)(?:\s+"([^"]*)")?\)/g,((t,e,i,n)=>s(n?`<a href="${i}" title="${n}">${e}</a>`:`<a href="${i}">${e}</a>`)))).replace(/<(https?:\/\/[^>]+)>/g,((t,e)=>s(`<a href="${e}">${e}</a>`)))).replace(/<([a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,})>/g,((t,e)=>s(`<a href="mailto:${e}">${e}</a>`)))).replace(/(?<![="'\w/])(https?:\/\/[^\s<>\])"]+)/g,((t,e)=>s(`<a href="${e}">${e}</a>`)))).replace(/~~(.+?)~~/g,"<del>$1</del>")).replace(/\*{3}(.+?)\*{3}/g,"<strong><em>$1</em></strong>")).replace(/_{3}(.+?)_{3}/g,"<strong><em>$1</em></strong>")).replace(/\*{2}(.+?)\*{2}/g,"<strong>$1</strong>")).replace(/_{2}(.+?)_{2}/g,"<strong>$1</strong>")).replace(/\*(.+?)\*/g,"<em>$1</em>")).replace(/(?<![a-zA-Z0-9])_(.+?)_(?![a-zA-Z0-9])/g,"<em>$1</em>")).replace(/==(.+?)==/g,"<mark>$1</mark>")).replace(/\^([^\s^]+)\^/g,"<sup>$1</sup>")).replace(/(?<!~)~([^\s~]+)~(?!~)/g,"<sub>$1</sub>")).replace(/\uFFFC(\d+)\uFFFC/g,((t,s)=>e[parseInt(s,10)]))}function Ut(t){if(t.length<2)return"";const e=t=>t.replace(/^\|/,"").replace(/\|$/,"").split("|").map((t=>t.trim())),s=e(t[0]),i=e(t[1]).map((t=>{const e=t.trim();return/^:-+:$/.test(e)?"center":/^-+:$/.test(e)?"right":/^:-+$/.test(e)?"left":""})),n=t.slice(2).map(e),o=s.length,r=s.every((t=>""===t));let l="<table>";const a=t=>{const e=i[t];return e?` style="text-align: ${e};"`:""};if(!r){l+="<thead><tr>";for(let t=0;t<o;t++)l+=`<th${a(t)}>${Wt(s[t])}</th>`;l+="</tr></thead>"}if(n.length>0||r){l+="<tbody>";for(const t of n){l+="<tr>";for(let e=0;e<o;e++)l+=`<td${a(e)}>${Wt(t[e]||"")}</td>`;l+="</tr>"}l+="</tbody>"}return l+="</table>",l}function Vt(t,e,s){const i=s?"ol":"ul",n=s?/^(\s*)\d+\.\s+(.*)/:/^(\s*)([-*+])\s+(.*)/;let o=`<${i}>`,r=e;const l=(t[r].match(/^(\s*)/)[1]||"").length;for(;r<t.length;){const e=t[r];if(At(e)){r++;continue}const i=(e.match(/^(\s*)/)[1]||"").length;if(i<l)break;if(i!==l)break;{if(!n.exec(e))break;const i=s?e.replace(/^\s*\d+\.\s+/,""):e.replace(/^\s*[-*+]\s+/,"");r++;let a=!1,h=!1,c=i;const d=/^\[([ xX])\]\s*(.*)/.exec(i);d&&(a=!0,h=" "!==d[1],c=d[2]);let u="";for(;r<t.length;){const e=t[r];if(At(e)){r++;continue}if((e.match(/^(\s*)/)[1]||"").length<=l)break;if(/^\s*[-*+]\s+/.test(e)||/^\s*\d+\.\s+/.test(e)){const s=Vt(t,r,/^\s*\d+\.\s+/.test(e));u+=s.html,r=s.index;continue}const s=e.trimStart();if(!(/^\|.*\|/.test(s)&&r+1<t.length&&/^\s*\|[\s:]*-{3,}/.test(t[r+1])))break;{const e=[];for(;r<t.length;){const s=t[r];if(At(s)||(s.match(/^(\s*)/)[1]||"").length<=l)break;if(!/^\s*\|/.test(s))break;e.push(s.trimStart()),r++}u+=Ut(e)}}if(a){o+=`<li class="task-list-item">${h?'<input type="checkbox" checked disabled> ':'<input type="checkbox" disabled> '}${Wt(c)}${u}</li>`}else o+=`<li>${Wt(i)}${u}</li>`}}return o+=`</${i}>`,{html:o,index:r}}const jt={jsonToMarkdown:function(t){return t?qt(t,"",!0).replace(/\n{3,}/g,"\n\n").trim()+"\n":""},markdownToHtml:function t(e,s){if(!e)return"";s||(s="p");const i=e.split("\n"),n=[];let o=0;for(;o<i.length;){const e=i[o];if(At(e)){o++;continue}const l=/^(`{3,}|~{3,})(\w*)/.exec(e);if(l){const t=l[1].charAt(0),e=l[1].length,s=l[2],a=[];o++;const h=new RegExp("^"+("`"===t?"`":"~")+"{"+e+",}\\s*$");for(;o<i.length&&!h.test(i[o]);)a.push(i[o]),o++;o++;const c=s?` class="language-${s}"`:"";n.push(`<pre><code${c}>${r=a.join("\n"),r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}</code></pre>`);continue}const a=/^(#{1,6})\s+(.+)/.exec(e);if(a){const t=a[1].length;n.push(`<h${t}>${Wt(a[2].trim())}</h${t}>`),o++;continue}if(/^(\*{3,}|-{3,}|_{3,})\s*$/.test(e)){n.push("<hr>"),o++;continue}if(/^>\s?/.test(e)){const e=[];for(;o<i.length&&/^>\s?/.test(i[o]);)e.push(i[o].replace(/^>\s?/,"")),o++;const r=t(e.join("\n"),s);n.push(`<blockquote>${r}</blockquote>`);continue}if(/^\|.*\|/.test(e)&&o+1<i.length&&/^\|[\s:]*-{3,}[\s:]*/.test(i[o+1])){const t=[];for(;o<i.length&&/^\|.*\|/.test(i[o]);)t.push(i[o]),o++;n.push(Ut(t));continue}if(/^(\s*)([-*+])\s+/.test(e)){const t=Vt(i,o,!1);n.push(t.html),o=t.index;continue}if(/^(\s*)\d+\.\s+/.test(e)){const t=Vt(i,o,!0);n.push(t.html),o=t.index;continue}if(/^\s*<[a-zA-Z]/.test(e)){let t=e;if(o++,It.test(e.match(/<(\w+)/)?.[1]||"")){n.push(t);continue}for(;o<i.length&&!At(i[o]);)t+="\n"+i[o],o++;n.push(t);continue}const h=[];for(;o<i.length&&!At(i[o])&&!/^(#{1,6}\s|`{3,}|~{3,}|>|\||(\s*)([-*+]|\d+\.)\s|(\*{3,}|-{3,}|_{3,})\s*$)/.test(i[o]);)h.push(i[o]),o++;if(h.length>0){const t=Wt(h.join("\n"));n.push(`<${s}>${t}</${s}>`)}else n.push(`<${s}>${Wt(i[o])}</${s}>`),o++}var r;return n.join("")}},Gt=/<!--\[if[^>]*>[\s\S]*?<!\[endif\]-->/gi,Kt=/<\/?(?:\w+:)\w+[^>]*>/gi,Yt=/<xml>[\s\S]*?<\/xml>/gi,Xt=/<style[^>]*>[\s\S]*?<\/style>/gi,Zt=/\s*mso-[^:]+:[^;"]+;?/gi,Jt=/l(\d+)\s+level(\d+)\s+lfo(\d+)/i,Qt=/mso-list:\s*Ignore/i,te=/\bMso\w+/g,ee=/\bxl\d+/g,se=/\s*tab-stops:[^;"]+;?/gi,ie=/^[\s\u00a0]*[\u2022\u00b7\u00a7\u25cf\u25cb\u25aa\u25a0·o§]\s*/,ne=[/^\s*[0-9]+[.)]\s/,/^\s*[a-z][.)]\s/i,/^\s*[ivxlmcd]+[.)]\s/i],oe=/<span\s+style\s*=\s*["']?\s*mso-spacerun:\s*yes\s*;?\s*["']?\s*>([\s\u00a0]*)<\/span>/gi,re=/<span\s+style\s*=\s*["'][^"']*mso-tab-count:\s*\d+[^"']*["']\s*>[^<]*<\/span>/gi,le=/mso-outline-level:\s*(\d+)/i,ae=/mso-highlight:\s*([^;"]+)/i,he=/mso-level-number-format:\s*([^;\s]+)/i,ce=/mso-level-start-at:\s*(\d+)/i,de=/mso-level-text:\s*([^;\s]+)/i,ue={decimal:"decimal","alpha-upper":"upper-alpha","alpha-lower":"lower-alpha","roman-upper":"upper-roman","roman-lower":"lower-roman","arabic-leading-zero":"decimal-leading-zero"},pe=/\s*margin:\s*0[a-z]*\s+0[a-z]*\s+0[a-z]*\s*;?/gi,ge=/\s*text-indent:\s*-?[\d.]+[a-z]*\s*;?/gi,me=/\s*line-height:\s*normal\s*;?/gi,fe=/MsoHeading(\d)/i,ve=/^file:\/\/\//i,be=/^_(Toc|Ref|Hlt|Hlk)\d+$/i,ye=/^#_(Toc|Ref|Hlt|Hlk)\d+$/i,we=/page-break-before\s*:\s*always/i,Ce=/mso-break-type\s*:\s*section-break/i,_e=/mso-column-break-before\s*:\s*always/i,ke=/^(?:Word)?Section\d+$/i;function xe(t){const e=t.replace(/[\s\u00a0]+/g," ").trim();if(ie.test(e))return"ul";for(const t of ne)if(t.test(e))return"ol";return"ul"}function $e(t){const e=document.createTreeWalker(t,NodeFilter.SHOW_COMMENT,null),s=[];for(;e.nextNode();)s.push(e.currentNode);for(const t of s)t?.remove();const i=t.querySelectorAll("span");for(const t of i){const e=t.getAttribute("style")||"";Qt.test(e)&&t.remove()}t.firstChild&&3===t.firstChild.nodeType&&(t.firstChild.nodeValue=t.firstChild.nodeValue.replace(/^[\s\u00a0]+/,""))}function Se(t){const e=t.getAttribute("style");if(!e)return;let s=e;const i=ae.exec(s);!i||/background-color/i.test(s)||/background\s*:/i.test(s)||(s+=";background-color:"+i[1].trim()),s=s.replace(Zt,"").replace(se,"").replace(pe,"").replace(ge,"").replace(me,"").trim(),s=s.replace(/^;+|;+$/g,"").replace(/;{2,}/g,";").trim(),s?t.setAttribute("style",s):t.removeAttribute("style")}function Ee(t){const e=t.getAttribute("class");if(!e)return;const s=e.replace(te,"").replace(ee,"").trim();s?t.setAttribute("class",s):t.removeAttribute("class")}function Te(t){let e=t.previousSibling;for(;e;){if(1===e.nodeType)return e;if(3===e.nodeType&&e.nodeValue.trim())return null;e=e.previousSibling}return null}function Me(t,e){for(const s of t){const t=`l${s.listId}:level${s.level}`,i=e.get(t);if(i)s.type=i.type,s.listStyleType=i.listStyleType,s.startAt=i.startAt;else{const t=Be(s.el);s.type=xe(t),s.listStyleType="",s.startAt=1}}const s=t[0].el.parentNode,i=t[t.length-1].el.nextSibling,n=[];let o=null;for(const e of t){const{el:t,level:s,type:i,listStyleType:r,startAt:l}=e;$e(t),Se(t),Ee(t);const a=t.ownerDocument.createElement("li");for(;t.firstChild;)a.appendChild(t.firstChild);if(t.getAttribute("style")&&a.setAttribute("style",t.getAttribute("style")),0===n.length)o=Ne(t.ownerDocument,i,r,l),o.appendChild(a),n.push({listEl:o,level:s});else{const e=n[n.length-1].level;if(s>e){const e=n[n.length-1].listEl.lastElementChild,o=Ne(t.ownerDocument,i,r,l);o.appendChild(a),e?e.appendChild(o):n[n.length-1].listEl.appendChild(o),n.push({listEl:o,level:s})}else if(s<e){for(;n.length>1&&n[n.length-1].level>s;)n.pop();n[n.length-1].listEl.appendChild(a)}else n[n.length-1].listEl.appendChild(a)}t.remove()}o&&s.insertBefore(o,i)}function Ne(t,e,s,i){const n=t.createElement(e);return s&&(n.style.listStyleType=s),"ol"===e&&i>1&&n.setAttribute("start",String(i)),n}function Be(t){const e=t.querySelectorAll("span");for(const t of e){const e=t.getAttribute("style")||"";if(Qt.test(e))return t.textContent||""}return t.textContent?.substring(0,10)||""}const Ie={cleanHTML:function(t){if(!t)return"";const e=function(t){const e=new Map,s=t.match(/<style[^>]*>([\s\S]*?)<\/style>/i);if(!s)return e;const i=s[1],n=/@list\s+l(\d+):level(\d+)\s*\{([^}]*)\}/gi;let o;for(;null!==(o=n.exec(i));){const t=o[1],s=o[2],i=o[3],n=`l${t}:level${s}`,r=he.exec(i),l=ce.exec(i),a=de.exec(i);let h="ol",c="";if(r){const t=r[1].toLowerCase();if("bullet"===t||"image"===t){if(h="ul",a){const t=a[1].replace(/["%\\]/g,"");"·"===t||"·"===t?c="disc":"o"===t?c="circle":"§"!==t&&"§"!==t||(c="square")}}else c=ue[t]||""}e.set(n,{type:h,listStyleType:c,startAt:l?parseInt(l[1],10):1})}return e}(t);let s=t;s=s.replace(Xt,""),s=s.replace(Yt,""),s=s.replace(Gt,""),s=s.replace(Kt,""),s=s.replace(/<!--(?:Start|End)Fragment-->/gi,""),s=s.replace(/<(?:meta|link)[^>]*>/gi,""),s=s.replace(oe," "),s=s.replace(re," "),s=s.replace(/( ){2,}/g," "),s=s.replace(/\u00AD/g,"");const i=(new DOMParser).parseFromString(s,"text/html");!function(t){const e=t.body.querySelectorAll("del, .msoDel");for(const t of e)t.remove();const s=t.body.querySelectorAll("ins, .msoIns");for(let t=s.length-1;t>=0;t--){const e=s[t],i=e.parentNode;if(i){for(;e.firstChild;)i.insertBefore(e.firstChild,e);e.remove()}}const i=t.body.querySelectorAll('.MsoCommentReference, [style*="mso-comment-reference"]');for(const t of i)t.remove();const n=t.body.querySelectorAll(".MsoCommentText");for(const t of n)t.remove();const o=t.body.querySelectorAll('div[style*="mso-element:comment"]');for(const t of o)t.remove();const r=t.body.querySelectorAll('a[name^="_msocom"], a[name^="_msoanchor"]');for(const t of r)t.remove()}(i),function(t,e){const s=[],i=t.body.querySelectorAll("p, h1, h2, h3, h4, h5, h6");for(const t of i){const e=t.getAttribute("style")||"",i=t.getAttribute("class")||"",n=Jt.exec(e);(n||/MsoListParagraph/i.test(i))&&s.push({el:t,listId:n?n[1]:"0",level:n?parseInt(n[2],10):1,lfo:n?n[3]:"1"})}if(0===s.length)return;const n=[];let o=null;for(const t of s){const e=Te(t.el);o&&o.length>0&&e===o[o.length-1].el?o.push(t):(o=[t],n.push(o))}for(const t of n)Me(t,e)}(i,e),function(t){const e=t.body.querySelectorAll("p");for(const s of e){const e=s.getAttribute("style")||"",i=s.getAttribute("class")||"";let n=0;const o=le.exec(e);if(o&&(n=parseInt(o[1],10)),!n){const t=fe.exec(i);t&&(n=parseInt(t[1],10))}if(n>=1&&n<=6){const i=t.createElement("h"+n);for(;s.firstChild;)i.appendChild(s.firstChild);e&&i.setAttribute("style",e),s.replaceWith(i)}}}(i),function(t){const e=t.body.querySelectorAll("table");for(const t of e){Ee(t),t.removeAttribute("cellspacing"),t.removeAttribute("cellpadding");const e=t.querySelectorAll("col");for(const t of e)t.remove();const s=t.querySelectorAll("colgroup");for(const t of s)t.children.length||t.remove()}const s=t.body.querySelectorAll("tr");for(const t of s)t.removeAttribute("height");const i=t.body.querySelectorAll("td, th");for(const t of i){const e=t.getAttribute("valign");if(e){t.removeAttribute("valign");const s=t.getAttribute("style")||"";/vertical-align/i.test(s)||t.setAttribute("style",(s?s+";":"")+"vertical-align:"+e)}const s=t.children;if(1===s.length&&"P"===s[0].tagName){const e=s[0],i=e.getAttribute("class")||"";if(/MsoNormal/i.test(i)||!i){for(;e.firstChild;)t.insertBefore(e.firstChild,e);e.remove()}}}}(i),function(t){const e=t.body.querySelectorAll("a");for(let t=e.length-1;t>=0;t--){const s=e[t],i=s.getAttribute("href")||"",n=s.getAttribute("name")||"";if(ve.test(i)){const t=s.parentNode;if(t){for(;s.firstChild;)t.insertBefore(s.firstChild,s);s.remove()}}else if(be.test(n)){const t=s.parentNode;if(t){if(s.childNodes.length)for(;s.firstChild;)t.insertBefore(s.firstChild,s);s.remove()}}else if(ye.test(i)){const t=s.parentNode;if(t){for(;s.firstChild;)t.insertBefore(s.firstChild,s);s.remove()}}else s.removeAttribute("v:shapes")}}(i),function(t){const e=t.body.querySelectorAll("img");for(let t=e.length-1;t>=0;t--){const s=e[t],i=s.getAttribute("src")||"";ve.test(i)?s.remove():s.removeAttribute("v:shapes")}}(i),function(t){const e=t.body.querySelectorAll("br");for(let t=e.length-1;t>=0;t--){const s=e[t],i=s.getAttribute("style")||"";we.test(i)||Ce.test(i)||_e.test(i)?s.remove():(s.removeAttribute("style"),s.removeAttribute("clear"))}const s=t.body.querySelectorAll('div[class*="Section"]');for(let t=s.length-1;t>=0;t--){const e=s[t],i=e.getAttribute("class")||"";if(ke.test(i.trim())){const t=e.parentNode;if(t){for(;e.firstChild;)t.insertBefore(e.firstChild,e);e.remove()}}}}(i);const n=i.body.querySelectorAll("*");for(const t of n){Se(t),Ee(t),t.getAttribute("lang")&&t.removeAttribute("lang"),t.removeAttribute("v:shapes");const e=t.tagName.toLowerCase();"img"!==e&&"video"!==e&&"iframe"!==e&&"table"!==e&&"td"!==e&&"th"!==e&&(t.removeAttribute("width"),t.removeAttribute("height"))}!function(t){const e=t.querySelectorAll("span");for(let t=e.length-1;t>=0;t--){const s=e[t];if(!s.attributes.length||!s.getAttribute("style")&&!s.getAttribute("class")){const t=s.parentNode;if(t){for(;s.firstChild;)t.insertBefore(s.firstChild,s);t.removeChild(s)}}}}(i.body);const o=i.body.querySelectorAll("p");for(const t of o)t.textContent.trim()||t.querySelector("img, video, iframe, br, table")||t.remove();return i.body.innerHTML}},Le=/id=["']?docs-internal-guid-/i;const Ae={isGoogleDocs:function(t){return Le.test(t)},cleanHTML:function(t){const e=(new DOMParser).parseFromString(t,"text/html"),s=e.body.querySelectorAll('b[id^="docs-internal-guid-"], span[id^="docs-internal-guid-"]');if(0===s.length)return t;for(let t,e=0,i=s.length;e<i;e++){for(t=s[e];t.firstChild;)t.parentNode.insertBefore(t.firstChild,t);t.parentNode.removeChild(t)}return e.body.innerHTML}},Oe=$,Re=N,ze=U,Pe=_t,De=I,Fe={isShift:function(t){return t.shiftKey||16===t.keyCode},isCtrl:function(t){const e=t.code;return t.ctrlKey||t.metaKey||"MetaLeft"===e||"MetaRight"===e},isAlt:function(t){return t.altKey},isComposing:function(t){return t.isComposing||"Process"===t.key||229===t.keyCode},isBackspace:function(t){return"Backspace"===t},isTab:function(t){return"Tab"===t},isEnter:function(t){return"Enter"===t},isEsc:function(t){return"Escape"===t},isSpace:function(t){return"Space"===t},isDirectionKey:function(t){return $t.includes(t)},isRemoveKey:function(t){return St.includes(t)},isNonTextKey:function(t){return Et.includes(t)},isHistoryRelevantKey:function(t){return Tt.includes(t)},isDocumentTypeObserverKey:function(t){return Mt.includes(t)},isNonResponseKey:function(t){return Nt.includes(t)}},He=Bt,qe=jt,We=Ie,Ue=Ae,Ve={env:Oe,unicode:Re,converter:ze,dom:Pe,numbers:De,keyCodeMap:Fe,clipboard:He,markdown:qe,msOffice:We,googleDocs:Ue},je={redo:'<svg class="se-io" 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="m15 14 5-5-5-5" /><path d="M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13" /></svg>',undo:'<svg class="se-io" 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="M9 14 4 9l5-5" /><path d="M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11" /></svg>',bold:'<svg class="se-io" 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="M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8" /></svg>',underline:'<svg class="se-io" 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="M6 4v6a6 6 0 0 0 12 0V4" /><line x1="4" x2="20" y1="20" y2="20" /></svg>',italic:'<svg class="se-io" 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" ><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" /></svg>',strike:'<svg class="se-io" 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="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" /></svg>',subscript:'<svg class="se-io" 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="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" /></svg>',superscript:'<svg class="se-io" 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="m4 19 8-8" /><path d="m12 19-8-8" /><path d="M20 12h-4c0-1.5.442-2 1.5-2.5S20 8.334 20 7.002c0-.472-.17-.93-.484-1.29a2.105 2.105 0 0 0-2.617-.436c-.42.239-.738.614-.899 1.06" /></svg>',remove_color:'<svg class="se-io" 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="M10 2v2" /><path d="M14 2v4" /><path d="M17 2a1 1 0 0 1 1 1v9H6V3a1 1 0 0 1 1-1z" /><path d="M6 12a1 1 0 0 0-1 1v1a2 2 0 0 0 2 2h2a1 1 0 0 1 1 1v2.9a2 2 0 1 0 4 0V17a1 1 0 0 1 1-1h2a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1" /></svg>',remove_format:'<svg class="se-io" 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="M4 7V4h16v3" /><path d="M5 20h6" /><path d="M13 4 8 20" /><path d="m15 15 5 5" /><path d="m20 15-5 5" /></svg>',indent:'<svg class="se-io" 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 5H11" /><path d="M21 12H11" /><path d="M21 19H11" /><path d="m3 8 4 4-4 4" /></svg>',outdent:'<svg class="se-io" 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 5H11" /><path d="M21 12H11" /><path d="M21 19H11" /><path d="m7 8-4 4 4 4" /></svg>',expansion:'<svg class="se-io" 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="M8 3H5a2 2 0 0 0-2 2v3" /><path d="M21 8V5a2 2 0 0 0-2-2h-3" /><path d="M3 16v3a2 2 0 0 0 2 2h3" /><path d="M16 21h3a2 2 0 0 0 2-2v-3" /></svg>',reduction:'<svg class="se-io" 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="M8 3v3a2 2 0 0 1-2 2H3" /><path d="M21 8h-3a2 2 0 0 1-2-2V3" /><path d="M3 16h3a2 2 0 0 1 2 2v3" /><path d="M16 21v-3a2 2 0 0 1 2-2h3" /></svg>',code_block:'<svg class="se-io" 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="m10 9-3 3 3 3" /><path d="m14 15 3-3-3-3" /><rect x="3" y="3" width="18" height="18" rx="2" /></svg>',code_view:'<svg class="se-io" 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="m9 7-5 5 5 5" /><path d="m15 7 5 5-5 5" /></svg>',markdown_view:'<svg class="se-io" 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="M4 17V7l4 5 4-5v10" /><path d="M17 7v7" /><path d="M14 14l3 3l3-3" /></svg>',preview:'<svg class="se-io" 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="M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0" /><circle cx="12" cy="12" r="3" /></svg>',print:'<svg class="se-io" 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="M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2" /><path d="M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6" /><rect x="6" y="14" width="12" height="8" rx="1" /></svg>',template:'<svg class="se-io" 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="M8 2v4" /><path d="M12 2v4" /><path d="M16 2v4" /><rect width="16" height="18" x="4" y="4" rx="2" /><path d="M8 10h6" /><path d="M8 14h8" /><path d="M8 18h5" /></svg>',layout:'<svg class="se-io" 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" ><rect width="18" height="18" x="3" y="3" rx="2" /><path d="M3 9h18" /><path d="M9 21V9" /></svg>',ai:'<svg class="se-io" 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="M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z" /><path d="M20 2v4" /><path d="M22 4h-4" /><circle cx="4" cy="20" r="2" /></svg>',new_document:'<svg class="se-io" 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="M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z" /><path d="M14 2v5a1 1 0 0 0 1 1h5" /></svg>',select_all:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M8 9a1 1 0 0 1 1 -1h6a1 1 0 0 1 1 1v6a1 1 0 0 1 -1 1h-6a1 1 0 0 1 -1 -1l0 -6" /><path d="M12 20v.01" /><path d="M16 20v.01" /><path d="M8 20v.01" /><path d="M4 20v.01" /><path d="M4 16v.01" /><path d="M4 12v.01" /><path d="M4 8v.01" /><path d="M4 4v.01" /><path d="M8 4v.01" /><path d="M12 4v.01" /><path d="M16 4v.01" /><path d="M20 4v.01" /><path d="M20 8v.01" /><path d="M20 12v.01" /><path d="M20 16v.01" /><path d="M20 20v.01" /></svg>',line_height:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M3 8l3 -3l3 3" /><path d="M3 16l3 3l3 -3" /><path d="M6 5l0 14" /><path d="M13 6l7 0" /><path d="M13 12l7 0" /><path d="M13 18l7 0" /></svg>',paragraph_style:'<svg class="se-io" 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="M13 4v16" /><path d="M17 4v16" /><path d="M19 4H9.5a4.5 4.5 0 0 0 0 9H13" /></svg>',text_style:'<svg class="se-io" 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="M14 16.5a.5.5 0 0 0 .5.5h.5a2 2 0 0 1 0 4H9a2 2 0 0 1 0-4h.5a.5.5 0 0 0 .5-.5v-9a.5.5 0 0 0-.5-.5h-3a.5.5 0 0 0-.5.5V8a2 2 0 0 1-4 0V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v3a2 2 0 0 1-4 0v-.5a.5.5 0 0 0-.5-.5h-3a.5.5 0 0 0-.5.5Z" /></svg>',save:'<svg class="se-io" 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="M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z" /><path d="M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7" /><path d="M7 3v4a1 1 0 0 0 1 1h7" /></svg>',blockquote:'<svg class="se-io" 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="M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z" /><path d="M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z" /></svg>',arrow_down:'<svg class="se-io" 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="m6 9 6 6 6-6" /></svg>',align_justify:'<svg class="se-io" 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="M3 5h18" /><path d="M3 12h18" /><path d="M3 19h18" /></svg>',align_left:'<svg class="se-io" 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 5H3" /><path d="M15 12H3" /><path d="M17 19H3" /></svg>',align_right:'<svg class="se-io" 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 5H3" /><path d="M21 12H9" /><path d="M21 19H7" /></svg>',align_center:'<svg class="se-io" 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 5H3" /><path d="M17 12H7" /><path d="M19 19H5" /></svg>',align_top:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M4 4l16 0" /><path d="M9 10a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-2a2 2 0 0 1 -2 -2l0 -8" /></svg>',align_middle:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M4 12l5 0" /><path d="M15 12l5 0" /><path d="M9 8a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-2a2 2 0 0 1 -2 -2l0 -8" /></svg>',align_bottom:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M4 20l16 0" /><path d="M9 6a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-2a2 2 0 0 1 -2 -2l0 -8" /></svg>',format_float_none:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M4 6a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1l0 -4" /><path d="M4 15l16 0" /><path d="M4 19l16 0" /></svg>',format_float_left:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M4 6a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1l0 -4" /><path d="M14 7l6 0" /><path d="M14 11l6 0" /><path d="M4 15l16 0" /><path d="M4 19l16 0" /></svg>',format_float_right:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M14 6a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1l0 -4" /><path d="M4 7l6 0" /><path d="M4 11l6 0" /><path d="M4 15l16 0" /><path d="M4 19l16 0" /></svg>',format_float_center:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M9 6a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1l0 -4" /><path d="M4 7l1 0" /><path d="M4 11l1 0" /><path d="M19 7l1 0" /><path d="M19 11l1 0" /><path d="M4 15l16 0" /><path d="M4 19l16 0" /></svg>',font_color:'<svg class="se-io" 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="m6 16 6-12 6 12" /><path d="M8 12h8" /><path class="se-svg-color-helper" stroke-width="2.5" d="M4 20h16" /></svg>',background_color:'<svg class="se-io" 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" ><g transform="translate(1 -2) scale(0.9)" stroke-width="2.22"><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" /></g><path class="se-svg-color-helper" stroke-width="2.5" d="M4 20h16" /></svg>',list_bulleted:'<svg class="se-io" 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="M3 5h.01" /><path d="M3 12h.01" /><path d="M3 19h.01" /><path d="M8 5h13" /><path d="M8 12h13" /><path d="M8 19h13" /></svg>',list_numbered:'<svg class="se-io" 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="M11 5h10" /><path d="M11 12h10" /><path d="M11 19h10" /><path d="M4 4h1v5" /><path d="M4 9h2" /><path d="M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02" /></svg>',list_checked:'<svg class="se-io" 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="M13 5h8" /><path d="M13 12h8" /><path d="M13 19h8" /><path d="m3 17 2 2 4-4" /><rect x="3" y="4" width="6" height="6" rx="1" /></svg>',table:'<svg class="se-io" 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="M12 3v18" /><rect width="18" height="18" x="3" y="3" rx="2" /><path d="M3 9h18" /><path d="M3 15h18" /></svg>',table_header:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M3 5a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-14" /><path d="M9 3l-6 6" /><path d="M14 3l-7 7" /><path d="M19 3l-7 7" /><path d="M21 6l-4 4" /><path d="M3 10h18" /><path d="M10 10v11" /></svg>',table_properties:'<svg class="se-io" 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="M11.035 7.69a1 1 0 0 1 1.909.024l.737 1.452a1 1 0 0 0 .737.535l1.634.256a1 1 0 0 1 .588 1.806l-1.172 1.168a1 1 0 0 0-.282.866l.259 1.613a1 1 0 0 1-1.541 1.134l-1.465-.75a1 1 0 0 0-.912 0l-1.465.75a1 1 0 0 1-1.539-1.133l.258-1.613a1 1 0 0 0-.282-.866l-1.156-1.153a1 1 0 0 1 .572-1.822l1.633-.256a1 1 0 0 0 .737-.535z" /><rect x="3" y="3" width="18" height="18" rx="2" /></svg>',cell_properties:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M12 21h-7a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v7" /><path d="M3 10h18" /><path d="M10 3v18" /><path d="M17.001 19a2 2 0 1 0 4 0a2 2 0 1 0 -4 0" /><path d="M19.001 15.5v1.5" /><path d="M19.001 21v1.5" /><path d="M22.032 17.25l-1.299 .75" /><path d="M17.27 20l-1.3 .75" /><path d="M15.97 17.25l1.3 .75" /><path d="M20.733 20l1.3 .75" /></svg>',table_column:'<svg class="se-io" 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" ><rect width="18" height="18" x="3" y="3" rx="2" /><path d="M9 3v18" /><path d="M15 3v18" /></svg>',table_row:'<svg class="se-io" 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" ><rect width="18" height="18" x="3" y="3" rx="2" /><path d="M21 9H3" /><path d="M21 15H3" /></svg>',color_checked:'<svg class="se-io" 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="M20 6 9 17l-5-5" /></svg>',color_palette:'<svg class="se-io" 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="M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z" /><circle cx="13.5" cy="6.5" r=".5" fill="currentColor" /><circle cx="17.5" cy="10.5" r=".5" fill="currentColor" /><circle cx="6.5" cy="12.5" r=".5" fill="currentColor" /><circle cx="8.5" cy="7.5" r=".5" fill="currentColor" /></svg>',border_all:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M4 6a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2l0 -12" /><path d="M4 12l16 0" /><path d="M12 4l0 16" /></svg>',border_inside:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M4 12l16 0" /><path d="M12 4l0 16" /><path d="M4 4l0 .01" /><path d="M8 4l0 .01" /><path d="M16 4l0 .01" /><path d="M20 4l0 .01" /><path d="M4 8l0 .01" /><path d="M20 8l0 .01" /><path d="M4 16l0 .01" /><path d="M20 16l0 .01" /><path d="M4 20l0 .01" /><path d="M8 20l0 .01" /><path d="M16 20l0 .01" /><path d="M20 20l0 .01" /></svg>',border_horizontal:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M4 12l16 0" /><path d="M4 4l0 .01" /><path d="M8 4l0 .01" /><path d="M12 4l0 .01" /><path d="M16 4l0 .01" /><path d="M20 4l0 .01" /><path d="M4 8l0 .01" /><path d="M12 8l0 .01" /><path d="M20 8l0 .01" /><path d="M4 16l0 .01" /><path d="M12 16l0 .01" /><path d="M20 16l0 .01" /><path d="M4 20l0 .01" /><path d="M8 20l0 .01" /><path d="M12 20l0 .01" /><path d="M16 20l0 .01" /><path d="M20 20l0 .01" /></svg>',border_vertical:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M12 4l0 16" /><path d="M4 4l0 .01" /><path d="M8 4l0 .01" /><path d="M16 4l0 .01" /><path d="M20 4l0 .01" /><path d="M4 8l0 .01" /><path d="M20 8l0 .01" /><path d="M4 12l0 .01" /><path d="M8 12l0 .01" /><path d="M16 12l0 .01" /><path d="M20 12l0 .01" /><path d="M4 16l0 .01" /><path d="M20 16l0 .01" /><path d="M4 20l0 .01" /><path d="M8 20l0 .01" /><path d="M16 20l0 .01" /><path d="M20 20l0 .01" /></svg>',border_outside:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M4 6a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2l0 -12" /><path d="M12 8l0 .01" /><path d="M8 12l0 .01" /><path d="M12 12l0 .01" /><path d="M16 12l0 .01" /><path d="M12 16l0 .01" /></svg>',border_left:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M4 20l0 -16" /><path d="M8 4l0 .01" /><path d="M12 4l0 .01" /><path d="M16 4l0 .01" /><path d="M20 4l0 .01" /><path d="M12 8l0 .01" /><path d="M20 8l0 .01" /><path d="M8 12l0 .01" /><path d="M12 12l0 .01" /><path d="M16 12l0 .01" /><path d="M20 12l0 .01" /><path d="M12 16l0 .01" /><path d="M20 16l0 .01" /><path d="M8 20l0 .01" /><path d="M12 20l0 .01" /><path d="M16 20l0 .01" /><path d="M20 20l0 .01" /></svg>',border_top:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M4 4l16 0" /><path d="M4 8l0 .01" /><path d="M12 8l0 .01" /><path d="M20 8l0 .01" /><path d="M4 12l0 .01" /><path d="M8 12l0 .01" /><path d="M12 12l0 .01" /><path d="M16 12l0 .01" /><path d="M20 12l0 .01" /><path d="M4 16l0 .01" /><path d="M12 16l0 .01" /><path d="M20 16l0 .01" /><path d="M4 20l0 .01" /><path d="M8 20l0 .01" /><path d="M12 20l0 .01" /><path d="M16 20l0 .01" /><path d="M20 20l0 .01" /></svg>',border_right:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M20 4l0 16" /><path d="M4 4l0 .01" /><path d="M8 4l0 .01" /><path d="M12 4l0 .01" /><path d="M16 4l0 .01" /><path d="M4 8l0 .01" /><path d="M12 8l0 .01" /><path d="M4 12l0 .01" /><path d="M8 12l0 .01" /><path d="M12 12l0 .01" /><path d="M16 12l0 .01" /><path d="M4 16l0 .01" /><path d="M12 16l0 .01" /><path d="M4 20l0 .01" /><path d="M8 20l0 .01" /><path d="M12 20l0 .01" /><path d="M16 20l0 .01" /></svg>',border_bottom:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M20 20l-16 0" /><path d="M4 4l0 .01" /><path d="M8 4l0 .01" /><path d="M12 4l0 .01" /><path d="M16 4l0 .01" /><path d="M20 4l0 .01" /><path d="M4 8l0 .01" /><path d="M12 8l0 .01" /><path d="M20 8l0 .01" /><path d="M4 12l0 .01" /><path d="M8 12l0 .01" /><path d="M12 12l0 .01" /><path d="M16 12l0 .01" /><path d="M20 12l0 .01" /><path d="M4 16l0 .01" /><path d="M12 16l0 .01" /><path d="M20 16l0 .01" /></svg>',border_none:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M4 4l0 .01" /><path d="M8 4l0 .01" /><path d="M12 4l0 .01" /><path d="M16 4l0 .01" /><path d="M20 4l0 .01" /><path d="M4 8l0 .01" /><path d="M12 8l0 .01" /><path d="M20 8l0 .01" /><path d="M4 12l0 .01" /><path d="M8 12l0 .01" /><path d="M12 12l0 .01" /><path d="M16 12l0 .01" /><path d="M20 12l0 .01" /><path d="M4 16l0 .01" /><path d="M12 16l0 .01" /><path d="M20 16l0 .01" /><path d="M4 20l0 .01" /><path d="M8 20l0 .01" /><path d="M12 20l0 .01" /><path d="M16 20l0 .01" /><path d="M20 20l0 .01" /></svg>',horizontal_line:'<svg class="se-io" 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="M5 12h14" /></svg>',show_blocks:'<svg class="se-io" 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="M5 3a2 2 0 0 0-2 2" /><path d="M19 3a2 2 0 0 1 2 2" /><path d="M21 19a2 2 0 0 1-2 2" /><path d="M5 21a2 2 0 0 1-2-2" /><path d="M9 3h1" /><path d="M9 21h1" /><path d="M14 3h1" /><path d="M14 21h1" /><path d="M3 9v1" /><path d="M21 9v1" /><path d="M3 14v1" /><path d="M21 14v1" /></svg>',cancel:'<svg class="se-io" 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="M18 6 6 18" /><path d="m6 6 12 12" /></svg>',selection_remove:'<svg class="se-io" 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" ><rect width="18" height="18" x="3" y="3" rx="2" ry="2" /><path d="m15 9-6 6" /><path d="m9 9 6 6" /></svg>',image:'<svg class="se-io" 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" ><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.086-3.086a2 2 0 0 0-2.828 0L6 21" /></svg>',image_thumbnail:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M15 8h.01" /><path d="M3 6a3 3 0 0 1 3 -3h12a3 3 0 0 1 3 3v12a3 3 0 0 1 -3 3h-12a3 3 0 0 1 -3 -3v-12" /><path d="M3 16l5 -5c.928 -.893 2.072 -.893 3 0l5 5" /><path d="M14 14l1 -1c.928 -.893 2.072 -.893 3 0l3 3" /></svg>',video:'<svg class="se-io" 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="m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5" /><rect x="2" y="6" width="14" height="12" rx="2" /></svg>',video_thumbnail:'<svg class="se-io" 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" ><rect width="18" height="18" x="3" y="3" rx="2" /><path d="M7 3v18" /><path d="M3 7.5h4" /><path d="M3 12h18" /><path d="M3 16.5h4" /><path d="M17 3v18" /><path d="M17 7.5h4" /><path d="M17 16.5h4" /></svg>',link:'<svg class="se-io" 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="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" /></svg>',link_rel:'<svg class="se-io" 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="M9 17H7A5 5 0 0 1 7 7h2" /><path d="M15 7h2a5 5 0 1 1 0 10h-2" /><line x1="8" x2="16" y1="12" y2="12" /></svg>',math:'<svg class="se-io" 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="M18 7V5a1 1 0 0 0-1-1H6.5a.5.5 0 0 0-.4.8l4.5 6a2 2 0 0 1 0 2.4l-4.5 6a.5.5 0 0 0 .4.8H17a1 1 0 0 0 1-1v-2" /></svg>',unlink:'<svg class="se-io" 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="m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71" /><path d="m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71" /><line x1="8" x2="8" y1="2" y2="5" /><line x1="2" x2="5" y1="8" y2="8" /><line x1="16" x2="16" y1="19" y2="22" /><line x1="19" x2="22" y1="16" y2="16" /></svg>',merge_cell:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M3 7h1.948c1.913 0 3.705 .933 4.802 2.5a5.861 5.861 0 0 0 4.802 2.5h6.448" /><path d="M3 17h1.95a5.854 5.854 0 0 0 4.798 -2.5a5.854 5.854 0 0 1 4.798 -2.5h5.454" /><path d="M18 15l3 -3l-3 -3" /></svg>',split_cell:'<svg class="se-io se-io-sharp" 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="M8 19H5c-1 0-2-1-2-2V7c0-1 1-2 2-2h3"/><path d="M16 5h3c1 0 2 1 2 2v10c0 1-1 2-2 2h-3"/><line x1="12" x2="12" y1="4" y2="20"/></svg>',unmerge_cell:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M21 17h-5.397a5 5 0 0 1 -4.096 -2.133l-.514 -.734a5 5 0 0 0 -4.096 -2.133h-3.897" /><path d="M21 7h-5.395a5 5 0 0 0 -4.098 2.135l-.51 .73a5 5 0 0 1 -4.097 2.135h-3.9" /><path d="M18 10l3 -3l-3 -3" /><path d="M18 20l3 -3l-3 -3" /></svg>',caption:'<svg class="se-io" 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" ><rect width="18" height="14" x="3" y="5" rx="2" ry="2" /><path d="M7 15h4M15 15h2M7 11h2M13 11h4" /></svg>',edit:'<svg class="se-io" 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.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z" /><path d="m15 5 4 4" /></svg>',delete:'<svg class="se-io se-io-sharp" 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="M10 11v6"/><path d="M14 11v6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"/><path d="M3 6h18"/><path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></svg>',revert:'<svg class="se-io" 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="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" /><path d="M3 3v5h5" /><path d="M12 7v5l4 2" /></svg>',auto_size:'<svg class="se-io" 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="M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7" /><path d="M14 15H9v-5" /><path d="M16 3h5v5" /><path d="M21 3 9 15" /></svg>',resize:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M4 11v8a1 1 0 0 0 1 1h8m-9 -14v-1a1 1 0 0 1 1 -1h1m5 0h2m5 0h1a1 1 0 0 1 1 1v1m0 5v2m0 5v1a1 1 0 0 1 -1 1h-1" /><path d="M4 12h7a1 1 0 0 1 1 1v7" /></svg>',insert_row_below:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M20 6v4a1 1 0 0 1 -1 1h-14a1 1 0 0 1 -1 -1v-4a1 1 0 0 1 1 -1h14a1 1 0 0 1 1 1" /><path d="M12 15l0 4" /><path d="M14 17l-4 0" /></svg>',insert_row_above:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M4 18v-4a1 1 0 0 1 1 -1h14a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-14a1 1 0 0 1 -1 -1" /><path d="M12 9v-4" /><path d="M10 7l4 0" /></svg>',insert_column_left:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M14 4h4a1 1 0 0 1 1 1v14a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1v-14a1 1 0 0 1 1 -1" /><path d="M5 12l4 0" /><path d="M7 10l0 4" /></svg>',insert_column_right:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M6 4h4a1 1 0 0 1 1 1v14a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1v-14a1 1 0 0 1 1 -1" /><path d="M15 12l4 0" /><path d="M17 10l0 4" /></svg>',delete_row:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M20 6v4a1 1 0 0 1 -1 1h-14a1 1 0 0 1 -1 -1v-4a1 1 0 0 1 1 -1h14a1 1 0 0 1 1 1" /><path d="M10 16l4 4" /><path d="M10 20l4 -4" /></svg>',delete_column:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M6 4h4a1 1 0 0 1 1 1v14a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1v-14a1 1 0 0 1 1 -1" /><path d="M16 10l4 4" /><path d="M16 14l4 -4" /></svg>',fixed_column_width:'<svg class="se-io" 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="M4 12v-6a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v6" /><path d="M10 18h-7" /><path d="M21 18h-7" /><path d="M6 15l-3 3l3 3" /><path d="M18 15l3 3l-3 3" /></svg>',rotate_left:'<svg class="se-io" 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="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" /><path d="M3 3v5h5" /></svg>',rotate_right:'<svg class="se-io" 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 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8" /><path d="M21 3v5h-5" /></svg>',mirror_horizontal:'<svg class="se-io" 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="m3 7 5 5-5 5V7" /><path d="m21 7-5 5 5 5V7" /><path d="M12 20v2" /><path d="M12 14v2" /><path d="M12 8v2" /><path d="M12 2v2" /></svg>',mirror_vertical:'<svg class="se-io" 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="m17 3-5 5-5-5h10" /><path d="m17 21-5-5-5 5h10" /><path d="M4 12H2" /><path d="M10 12H8" /><path d="M16 12h-2" /><path d="M22 12h-2" /></svg>',checked:'<svg class="se-io" 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="M20 6 9 17l-5-5" /></svg>',line_break:'<svg class="se-io" 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="M20 4v7a4 4 0 0 1-4 4H4" /><path d="m9 10-5 5 5 5" /></svg>',audio:'<svg class="se-io" 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="M9 18V5l12-2v13" /><circle cx="6" cy="18" r="3" /><circle cx="18" cy="16" r="3" /></svg>',audio_thumbnail:'<svg class="se-io" 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="M4 6.835V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-.343" /><path d="M14 2v5a1 1 0 0 0 1 1h5" /><path d="M2 19a2 2 0 0 1 4 0v1a2 2 0 0 1-4 0v-4a6 6 0 0 1 12 0v4a2 2 0 0 1-4 0v-1a2 2 0 0 1 4 0" /></svg>',image_gallery:'<svg class="se-io" 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="m22 11-1.296-1.296a2.4 2.4 0 0 0-3.408 0L11 16" /><path d="M4 8a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2" /><circle cx="13" cy="7" r="1" fill="currentColor" /><rect x="8" y="2" width="14" height="14" rx="2" /></svg>',audio_gallery:'<svg class="se-io" 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="M16 5H3" /><path d="M11 12H3" /><path d="M11 19H3" /><path d="M21 16V5" /><circle cx="18" cy="16" r="3" /></svg>',video_gallery:'<svg class="se-io" 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="m12.296 3.464 3.02 3.956" /><path d="M20.2 6 3 11l-.9-2.4c-.3-1.1.3-2.2 1.3-2.5l13.5-4c1.1-.3 2.2.3 2.5 1.3z" /><path d="M3 11h18v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z" /><path d="m6.18 5.276 3.1 3.899" /></svg>',file_gallery:'<svg class="se-io" 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="M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8" /><path d="M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z" /><path d="M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1" /></svg>',file_browser:'<svg class="se-io" 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="m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2" /></svg>',bookmark:'<svg class="se-io" 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="M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z" /></svg>',bookmark_anchor:'<svg class="se-io" 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="M12 6v16" /><path d="m19 13 2-1a9 9 0 0 1-18 0l2 1" /><path d="M9 11h6" /><circle cx="12" cy="4" r="2" /></svg>',download:'<svg class="se-io" 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="M12 15V3" /><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" /><path d="m7 10 5 5 5-5" /></svg>',dir_ltr:'<svg class="se-io" 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="M10 3v11" /><path d="M10 9H7a1 1 0 0 1 0-6h8" /><path d="M14 3v11" /><path d="m18 14 4 4H2" /><path d="m22 18-4 4" /></svg>',dir_rtl:'<svg class="se-io" 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="M14 3v11" /><path d="M14 9h-3a3 3 0 0 1 0-6h9" /><path d="M18 3v11" /><path d="M22 18H2l4-4" /><path d="m6 22-4-4" /></svg>',dragHandle:'<svg class="se-io" 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" ><circle cx="9" cy="12" r="1" /><circle cx="9" cy="5" r="1" /><circle cx="9" cy="19" r="1" /><circle cx="15" cy="12" r="1" /><circle cx="15" cy="5" r="1" /><circle cx="15" cy="19" r="1" /></svg>',file_upload:'<svg class="se-io" 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="M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z" /><path d="M14 2v5a1 1 0 0 0 1 1h5" /><path d="M12 12v6" /><path d="m15 15-3-3-3 3" /></svg>',file_thumbnail:'<svg class="se-io" 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="M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z" /><path d="M14 2v5a1 1 0 0 0 1 1h5" /></svg>',file_plus:'<svg class="se-io" 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="M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z" /><path d="M14 2v5a1 1 0 0 0 1 1h5" /><path d="M9 15h6" /><path d="M12 18v-6" /></svg>',upload_tray:'<svg class="se-io" 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="M12 3v12" /><path d="m17 8-5-5-5 5" /><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" /></svg>',folder:'<svg class="se-io" 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="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z" /></svg>',plus:'<svg class="se-io" 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="M5 12h14" /><path d="M12 5v14" /></svg>',minus:'<svg class="se-io" 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="M5 12h14" /></svg>',selection:'<svg class="se-io" 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="M5 3a2 2 0 0 0-2 2" /><path d="M19 3a2 2 0 0 1 2 2" /><path d="M21 19a2 2 0 0 1-2 2" /><path d="M5 21a2 2 0 0 1-2-2" /><path d="M9 3h1" /><path d="M9 21h1" /><path d="M14 3h1" /><path d="M14 21h1" /><path d="M3 9v1" /><path d="M21 9v1" /><path d="M3 14v1" /><path d="M21 14v1" /></svg>',copy:'<svg class="se-io se-io-sharp" 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" ><rect width="14" height="14" x="8" y="8" rx="2" ry="2" /><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" /></svg>',cut:'<svg class="se-io" 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" ><circle cx="6" cy="6" r="3" /><path d="M8.12 8.12 12 12" /><path d="M20 4 8.12 15.88" /><circle cx="6" cy="18" r="3" /><path d="M14.8 14.8 20 20" /></svg>',PDF:'<svg class="se-io" 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 stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M14 3v4a1 1 0 0 0 1 1h4" /><path d="M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4" /><path d="M5 18h1.5a1.5 1.5 0 0 0 0 -3h-1.5v6" /><path d="M17 18h2" /><path d="M20 15h-3v6" /><path d="M11 15v6h1a2 2 0 0 0 2 -2v-2a2 2 0 0 0 -2 -2h-1" /></svg>',format_paint:'<svg class="se-io" 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="m14.622 17.897-10.68-2.913" /><path d="M18.376 2.622a1 1 0 1 1 3.002 3.002L17.36 9.643a.5.5 0 0 0 0 .707l.944.944a2.41 2.41 0 0 1 0 3.408l-.944.944a.5.5 0 0 1-.707 0L8.354 7.348a.5.5 0 0 1 0-.707l.944-.944a2.41 2.41 0 0 1 3.408 0l.944.944a.5.5 0 0 0 .707 0z" /><path d="M9 8c-1.804 2.71-3.97 3.46-6.583 3.948a.507.507 0 0 0-.302.819l7.32 8.883a1 1 0 0 0 1.185.204C12.735 20.405 16 16.792 16 15" /></svg>',drawing:'<svg class="se-io" 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="m11 10 3 3" /><path d="M6.5 21A3.5 3.5 0 1 0 3 17.5a2.62 2.62 0 0 1-.708 1.792A1 1 0 0 0 3 21z" /><path d="M9.969 17.031 21.378 5.624a1 1 0 0 0-3.002-3.002L6.967 14.031" /></svg>',eraser:'<svg class="se-io" 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 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21" /><path d="m5.082 11.09 8.828 8.828" /></svg>',search:'<svg class="se-io" 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 21-4.34-4.34" /><circle cx="11" cy="11" r="8" /></svg>',selection_search:'<svg class="se-io" 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="M3 7V5a2 2 0 0 1 2-2h2" /><path d="M17 3h2a2 2 0 0 1 2 2v2" /><path d="M21 17v2a2 2 0 0 1-2 2h-2" /><path d="M7 21H5a2 2 0 0 1-2-2v-2" /><circle cx="12" cy="12" r="3" /><path d="m16 16-1.9-1.9" /></svg>',embed:'<svg class="se-io" 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="M12 12h.01" /><path d="M16 12h.01" /><path d="m17 7 5 5-5 5" /><path d="m7 7-5 5 5 5" /><path d="M8 12h.01" /></svg>',finder:'<svg class="se-io" 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 5H3" /><path d="M10 12H3" /><path d="M10 19H3" /><circle cx="17" cy="15" r="3" /><path d="m21 19-1.9-1.9" /></svg>',regex:'<svg class="se-ci" xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M197-199q-56-57-86.5-130T80-482q0-80 30-153t87-130l57 57q-46 45-70 103.5T160-482q0 64 24.5 122.5T254-256l-57 57Zm140.5-58.5Q320-275 320-300t17.5-42.5Q355-360 380-360t42.5 17.5Q440-325 440-300t-17.5 42.5Q405-240 380-240t-42.5-17.5ZM519-440v-71l-61 36-40-70 61-35-61-35 40-70 61 36v-71h80v71l61-36 40 70-61 35 61 35-40 70-61-36v71h-80Zm244 241-57-57q46-45 70-103.5T800-482q0-64-24.5-122.5T706-708l57-57q56 57 86.5 130T880-482q0 80-30 153t-87 130Z"/></svg>',match_case:'<svg class="se-ci" xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="m131-252 165-440h79l165 440h-76l-39-112H247l-40 112h-76Zm139-176h131l-64-182h-4l-63 182Zm395 186q-51 0-81-27.5T554-342q0-44 34.5-72.5T677-443q23 0 45 4t38 11v-12q0-29-20.5-47T685-505q-23 0-42 9.5T610-468l-47-35q24-29 54.5-43t68.5-14q69 0 103 32.5t34 97.5v178h-63v-37h-4q-14 23-38 35t-53 12Zm12-54q35 0 59.5-24t24.5-56q-14-8-33.5-12.5T689-393q-32 0-50 14t-18 37q0 20 16 33t40 13Z"/></svg>',whole_word:'<svg class="se-ci" xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M40-199v-200h80v120h720v-120h80v200H40Zm342-161v-34h-3q-13 20-35 31.5T294-351q-49 0-77-25.5T189-446q0-42 32.5-68.5T305-541q23 0 42.5 3.5T381-526v-14q0-27-18.5-43T312-599q-21 0-39.5 9T241-564l-43-32q19-27 48-41t67-14q62 0 95 29.5t33 85.5v176h-59Zm-66-134q-32 0-49 12.5T250-446q0 20 15 32.5t39 12.5q32 0 54.5-22.5T381-478q-14-8-32-12t-33-4Zm185 134v-401h62v113l-3 40h3q3-5 24-25.5t66-20.5q64 0 101 46t37 106q0 60-36.5 105.5T653-351q-41 0-62.5-18T563-397h-3v37h-59Zm143-238q-40 0-62 29.5T560-503q0 37 22 66t62 29q40 0 62.5-29t22.5-66q0-37-22.5-66T644-598Z"/></svg>',swap_vert:'<svg class="se-io" 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 16-4 4-4-4" /><path d="M17 20V4" /><path d="m3 8 4-4 4 4" /><path d="M7 4v16" /></svg>',arrow_down_small:'<svg class="se-io" 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="m6 9 6 6 6-6" /></svg>',arrow_up_small:'<svg class="se-io" 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="m18 15-6-6-6 6" /></svg>',replaceText:'<svg class="se-ci" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" ><g stroke-width="0"></g><g stroke-linecap="round" stroke-linejoin="round"></g><g><path fill-rule="evenodd" clip-rule="evenodd" d="M3.221 3.739l2.261 2.269L7.7 3.784l-.7-.7-1.012 1.007-.008-1.6a.523.523 0 0 1 .5-.526H8V1H6.48A1.482 1.482 0 0 0 5 2.489V4.1L3.927 3.033l-.706.706zm6.67 1.794h.01c.183.311.451.467.806.467.393 0 .706-.168.94-.503.236-.335.353-.78.353-1.333 0-.511-.1-.913-.301-1.207-.201-.295-.488-.442-.86-.442-.405 0-.718.194-.938.581h-.01V1H9v4.919h.89v-.386zm-.015-1.061v-.34c0-.248.058-.448.175-.601a.54.54 0 0 1 .445-.23.49.49 0 0 1 .436.233c.104.154.155.368.155.643 0 .33-.056.587-.169.768a.524.524 0 0 1-.47.27.495.495 0 0 1-.411-.211.853.853 0 0 1-.16-.532zM9 12.769c-.256.154-.625.231-1.108.231-.563 0-1.02-.178-1.369-.533-.349-.355-.523-.813-.523-1.374 0-.648.186-1.158.56-1.53.374-.376.875-.563 1.5-.563.433 0 .746.06.94.179v.998a1.26 1.26 0 0 0-.792-.276c-.325 0-.583.1-.774.298-.19.196-.283.468-.283.816 0 .338.09.603.272.797.182.191.431.287.749.287.282 0 .558-.092.828-.276v.946zM4 7L3 8v6l1 1h7l1-1V8l-1-1H4zm0 1h7v6H4V8z"></path></g></svg>',relaceTextAll:'<svg class="se-ci" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><g stroke-width="0"></g><g stroke-linecap="round" stroke-linejoin="round"></g><g><path fill-rule="evenodd" clip-rule="evenodd" d="M11.6 2.677c.147-.31.356-.465.626-.465.248 0 .44.118.573.353.134.236.201.557.201.966 0 .443-.078.798-.235 1.067-.156.268-.365.402-.627.402-.237 0-.416-.125-.537-.374h-.008v.31H11V1h.593v1.677h.008zm-.016 1.1a.78.78 0 0 0 .107.426c.071.113.163.169.274.169.136 0 .24-.072.314-.216.075-.145.113-.35.113-.615 0-.22-.035-.39-.104-.514-.067-.124-.164-.187-.29-.187-.12 0-.219.062-.297.185a.886.886 0 0 0-.117.48v.272zM4.12 7.695L2 5.568l.662-.662 1.006 1v-1.51A1.39 1.39 0 0 1 5.055 3H7.4v.905H5.055a.49.49 0 0 0-.468.493l.007 1.5.949-.944.656.656-2.08 2.085zM9.356 4.93H10V3.22C10 2.408 9.685 2 9.056 2c-.135 0-.285.024-.45.073a1.444 1.444 0 0 0-.388.167v.665c.237-.203.487-.304.75-.304.261 0 .392.156.392.469l-.6.103c-.506.086-.76.406-.76.961 0 .263.061.473.183.631A.61.61 0 0 0 8.69 5c.29 0 .509-.16.657-.48h.009v.41zm.004-1.355v.193a.75.75 0 0 1-.12.436.368.368 0 0 1-.313.17.276.276 0 0 1-.22-.095.38.38 0 0 1-.08-.248c0-.222.11-.351.332-.389l.4-.067zM7 12.93h-.644v-.41h-.009c-.148.32-.367.48-.657.48a.61.61 0 0 1-.507-.235c-.122-.158-.183-.368-.183-.63 0-.556.254-.876.76-.962l.6-.103c0-.313-.13-.47-.392-.47-.263 0-.513.102-.75.305v-.665c.095-.063.224-.119.388-.167.165-.049.315-.073.45-.073.63 0 .944.407.944 1.22v1.71zm-.64-1.162v-.193l-.4.068c-.222.037-.333.166-.333.388 0 .1.027.183.08.248a.276.276 0 0 0 .22.095.368.368 0 0 0 .312-.17c.08-.116.12-.26.12-.436zM9.262 13c.321 0 .568-.058.738-.173v-.71a.9.9 0 0 1-.552.207.619.619 0 0 1-.5-.215c-.12-.145-.181-.345-.181-.598 0-.26.063-.464.189-.612a.644.644 0 0 1 .516-.223c.194 0 .37.069.528.207v-.749c-.129-.09-.338-.134-.626-.134-.417 0-.751.14-1.001.422-.249.28-.373.662-.373 1.148 0 .42.116.764.349 1.03.232.267.537.4.913.4zM2 9l1-1h9l1 1v5l-1 1H3l-1-1V9zm1 0v5h9V9H3zm3-2l1-1h7l1 1v5l-1 1V7H6z"></path></g></svg>',menu_arrow_down:'<svg class="se-io" 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="m6 9 6 6 6-6" /></svg>',menu_arrow_up:'<svg class="se-io" 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="m18 15-6-6-6 6" /></svg>',menu_arrow_right:'<svg class="se-io" 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="m9 18 6-6-6-6" /></svg>',menu_arrow_left:'<svg class="se-io" 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="m15 18-6-6 6-6" /></svg>',side_menu_hamburger:'<svg class="se-io" 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="M4 5h16" /><path d="M4 12h16" /><path d="M4 19h16" /></svg>',side_menu_folder:'<svg class="se-io" 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="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z" /></svg>',side_menu_folder_item:'<svg class="se-io" 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="m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2" /></svg>',side_menu_item:'<svg class="se-io" 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="M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z" /><path d="M14 2v5a1 1 0 0 0 1 1h5" /></svg>',side_menu_folder_plus:'<svg class="se-io" 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="M12 10v6" /><path d="M9 13h6" /><path d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z" /></svg>',alert_outline:'<svg class="se-io" 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" ><circle cx="12" cy="12" r="10" /><line x1="12" x2="12" y1="8" y2="12" /><line x1="12" x2="12.01" y1="16" y2="16" /></svg>',more_media:'<svg class="se-io" 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" ><rect width="18" height="18" x="3" y="3" rx="2" /><path d="M7 3v18" /><path d="M3 7.5h4" /><path d="M3 12h18" /><path d="M3 16.5h4" /><path d="M17 3v18" /><path d="M17 7.5h4" /><path d="M17 16.5h4" /></svg>',more_gallery:'<svg class="se-io" 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" ><rect width="7" height="7" x="3" y="3" rx="1" /><rect width="7" height="7" x="14" y="3" rx="1" /><rect width="7" height="7" x="14" y="14" rx="1" /><rect width="7" height="7" x="3" y="14" rx="1" /></svg>',more_folder:'<svg class="se-io" 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="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z" /></svg>',more_list:'<svg class="se-io" 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="M3 5h.01" /><path d="M3 12h.01" /><path d="M3 19h.01" /><path d="M8 5h13" /><path d="M8 12h13" /><path d="M8 19h13" /></svg>',more_file:'<svg class="se-io" 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="M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z" /><path d="M14 2v5a1 1 0 0 0 1 1h5" /></svg>',more_view:'<svg class="se-io" 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="M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0" /><circle cx="12" cy="12" r="3" /></svg>',more_page:'<svg class="se-io" 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="M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z" /><path d="M14 2v5a1 1 0 0 0 1 1h5" /><path d="M10 9H8" /><path d="M16 13H8" /><path d="M16 17H8" /></svg>',more_text:'<svg class="se-io" 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="M12 4v16" /><path d="M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2" /><path d="M9 20h6" /></svg>',more_paragraph:'<svg class="se-io" 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="M13 4v16" /><path d="M17 4v16" /><path d="M19 4H9.5a4.5 4.5 0 0 0 0 9H13" /></svg>',more_plus:'<svg class="se-io" 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="M5 12h14" /><path d="M12 5v14" /></svg>',more_horizontal:'<svg class="se-io" 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" ><circle cx="12" cy="12" r="1" /><circle cx="19" cy="12" r="1" /><circle cx="5" cy="12" r="1" /></svg>',more_vertical:'<svg class="se-io" 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" ><circle cx="12" cy="12" r="1" /><circle cx="12" cy="5" r="1" /><circle cx="12" cy="19" r="1" /></svg>',more_flag:'<svg class="se-io" 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="M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528" /></svg>',as_inline:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M8,7L13,17H3L8,7M3,3H21V5H3V3M21,15V17H14V15H21M3,19H21V21H3V19Z" /></svg>',as_block:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12,7L17,17H7L12,7M3,3H21V5H3V3M3,19H21V21H3V19Z" /></svg>',page_break:'<svg class="se-io" 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="m16 16-4 4-4-4" /><path d="M3 12h18" /><path d="m8 8 4-4 4 4" /></svg>',page_down:'<svg class="se-io" 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="M12 17V3" /><path d="m6 11 6 6 6-6" /><path d="M19 21H5" /></svg>',page_up:'<svg class="se-io" 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="M5 3h14" /><path d="m18 13-6-6-6 6" /><path d="M12 7v14" /></svg>',collapse_left:'<svg class="se-io" 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" ><rect width="18" height="18" x="3" y="3" rx="2" /><path d="M9 3v18" /><path d="m16 15-3-3 3-3" /></svg>',collapse_right:'<svg class="se-io" 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" ><rect width="18" height="18" x="3" y="3" rx="2" /><path d="M15 3v18" /><path d="m8 9 3 3-3 3" /></svg>',map:'<svg class="se-io" 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="M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z" /><path d="M15 5.764v15" /><path d="M9 3.236v15" /></svg>',magic_stick:'<svg class="se-io" 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.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72" /><path d="m14 7 3 3" /><path d="M5 6v4" /><path d="M19 14v4" /><path d="M10 2v2" /><path d="M7 8H3" /><path d="M21 16h-4" /><path d="M11 3H9" /></svg>',open_in_new:'<svg class="se-io" 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="M15 3h6v6" /><path d="M10 14 21 3" /><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6" /></svg>'};var Ge=s("cfbI"),Ke=s.n(Ge);function Ye(t,e,s,i,n){const o=new Map([["menuTray",s],["toolbar_main",t],["toolbar_buttonTray",t.querySelector(".se-btn-tray")],["toolbar_arrow",t.querySelector(".se-arrow")]]);return i&&(o.set("toolbar_sub_main",i),o.set("toolbar_sub_buttonTray",i.querySelector(".se-btn-tray")),o.set("toolbar_sub_arrow",i.querySelector(".se-arrow")),o.set("toolbar_sub_wrapper",i.parentElement.parentElement)),e&&(o.set("toolbar_wrapper",e.querySelector(".sun-editor")),o.set("_stickyDummy",e.querySelector(".se-toolbar-sticky-dummy"))),n&&o.set("statusbar_wrapper",n.querySelector(".sun-editor")),o}function Xe(t,e,s,i,n,o,r,l,a,h,c){const d=new Map([["key",c],["options",t.options],["originElement",t.target],["topArea",e],["container",e.querySelector(".se-container")],["wrapper",e.querySelector(".se-wrapper")],["wysiwygFrame",s],["wysiwyg",s],["codeWrapper",i],["code",n],["codeNumbers",i?.querySelector(".se-code-view-line")],["markdownWrapper",o],["markdown",r],["markdownNumbers",o?.querySelector(".se-markdown-view-line")],["lineBreaker_t",e.querySelector(".se-line-breaker-component-t")],["lineBreaker_b",e.querySelector(".se-line-breaker-component-b")],["blockHandleArea",h],["blockHandle",h?.querySelector(".se-block-handle")||null],["blockHandlePlus",h?.querySelector(".se-block-handle-plus")||null],["blockHandleDrag",h?.querySelector(".se-block-handle-drag")||null],["_stickyDummy",e.querySelector(".se-toolbar-sticky-dummy")],["_toolbarShadow",e.querySelector(".se-toolbar-shadow")],["_minHeight",B(s.style.minHeight||"65",0)],["isCodeView",!1],["isMarkdownView",!1],["isFullScreen",!1],["isReadOnly",!1],["isDisabled",!1],["isChanged",!1],["historyIndex",-1],["savedIndex",-1],["documentTypeInner",a.inner],["documentTypePage",a.page],["documentTypePageMirror",a.pageMirror]]);l&&Ze(l,d);const u=e.querySelector(".se-placeholder");u&&d.set("placeholder",u);const p=t.options.get("placeholder_line");return p&&d.set("placeholder_line",p),d}function Ze(t,e){t?e.set("statusbar",t):e.delete("statusbar");const s=t?t.querySelector(".se-navigation"):null,i=t?t.querySelector(".se-char-counter-wrapper"):null,n=t?t.querySelector(".se-char-counter-wrapper .se-char-counter"):null;s?e.set("navigation",s):e.delete("navigation"),i?e.set("charWrapper",i):e.delete("charWrapper"),n?e.set("charCounter",n):e.delete("charCounter");const o=t?t.querySelector(".se-word-counter-wrapper"):null,r=t?t.querySelector(".se-word-counter-wrapper .se-word-counter"):null;o?e.set("wordWrapper",o):e.delete("wordWrapper"),r?e.set("wordCounter",r):e.delete("wordCounter")}const Je={BUTTON_LIST:[["undo","redo"],"|",["bold","underline","italic","strike","|","subscript","superscript"],"|",["removeFormat"],"|",["outdent","indent"],"|",["fullScreen","showBlocks","codeView"],"|",["preview","print"]],REQUIRED_FORMAT_LINE:"div",REQUIRED_ELEMENT_WHITELIST:"br|div",ELEMENT_WHITELIST:"p|pre|blockquote|h1|h2|h3|h4|h5|h6|ol|ul|li|hr|figure|figcaption|img|iframe|audio|video|source|table|colgroup|col|thead|tbody|tr|th|td|caption|a|b|strong|var|i|em|u|ins|s|span|strike|del|sub|sup|code|svg|path|details|summary",TEXT_STYLE_TAGS:"strong|span|font|b|var|i|em|u|ins|s|strike|del|sub|sup|mark|a|label|code|summary",SCOPE_SELECTION_TAGS:["td","table","li","ol","ul","pre","figcaption","blockquote","dl","dt","dd"],ATTRIBUTE_WHITELIST:"contenteditable|target|href|title|download|rel|src|alt|class|type|colspan|rowspan|width|height|controls|autoplay|loop|muted|poster|preload|playsinline|volume|crossorigin|disableRemotePlayback|controlsList|allowfullscreen|sandbox|loading|allow|referrerpolicy|frameborder|scrolling",FORMAT_LINE:"P|H[1-6]|LI|TH|TD|DETAILS",FORMAT_BR_LINE:"PRE",FORMAT_CLOSURE_BR_LINE:"",FORMAT_BLOCK:"BLOCKQUOTE|OL|UL|FIGCAPTION|TABLE|THEAD|TBODY|TR|CAPTION|DETAILS",FORMAT_CLOSURE_BLOCK:"TH|TD",ALLOWED_EMPTY_NODE_LIST:".se-component, pre, blockquote, hr, li, table, img, iframe, video, audio, canvas, details",SIZE_UNITS:["px","pt","em","rem"],CLASS_NAME:"^__se__|^se-|^katex|^MathJax|^language-",CLASS_MJX:"mjx-container|mjx-math|mjx-mrow|mjx-mi|mjx-mo|mjx-mn|mjx-msup|mjx-mfrac|mjx-munderover",EXTRA_TAG_MAP:{script:!1,style:!1,meta:!1,link:!1,"[a-z]+:[a-z]+":!1},CONTENT_STYLES:"background|background-clip|background-color|border|border-bottom|border-collapse|border-color|border-image|border-left-width|border-radius|border-right-width|border-spacing|border-style|border-top|border-width|box-shadow|box-sizing|caption-side|color|content|direction|display|position|float|font|font-family|font-size|font-style|font-weight|height|min-height|max-height|width|min-width|max-width|left|letter-spacing|line-height|list-style-position|list-style-type|margin|margin-block-end|margin-block-start|margin-bottom|margin-inline-end|margin-inline-start|margin-left|margin-right|margin-top|padding|padding-bottom|padding-inline-start|padding-left|padding-right|padding-top|outline|overflow|page-break-before|page-break-after|page-break-inside|rotate|rotateX|rotateY|table-layout|text-align|text-decoration|text-shadow|text-transform|top|text-indent|text-rendering|vertical-align|visibility|white-space|word-break|word-wrap",TAG_STYLES:{"@text":"font-family|font-size|color|background-color|width|height","@line":"text-align|margin|margin-left|margin-right|line-height","@component":"width|height|min-width",li:"font-family|font-size|color|background-color|font-weight|font-style","table|th|td":"border|border-[a-z]+|color|background-color|text-align|float|font-weight|text-decoration|font-style|vertical-align","table|td":"width",tr:"height",col:"width",caption:"text-align|caption-side","ol|ul":"list-style-type",figure:"display|width|height|padding|padding-bottom",figcaption:"margin|margin-top|margin-bottom|text-align","img|video|iframe":"transform|transform-origin|width|min-width|max-width|height|min-height|max-height|float|margin|margin-top",hr:""},RETAIN_STYLE_MODE:["repeat","always","none"]},Qe={value:"fixed",placeholder:!0,placeholder_line:!0,editableFrameAttributes:!0,width:!0,minWidth:!0,maxWidth:!0,innerWidth:"fixed",height:!0,minHeight:!0,maxHeight:!0,editorStyle:!0,iframe:"fixed",iframe_fullPage:"fixed",iframe_attributes:!0,iframe_cssFileName:!0,statusbar:!0,statusbar_showPathLabel:!0,statusbar_resizeEnable:"fixed",charCounter:!0,charCounter_max:!0,charCounter_label:!0,charCounter_type:!0,wordCounter:!0,wordCounter_label:!0},ts={plugins:"fixed",excludedPlugins:"fixed",buttonList:"fixed",v2Migration:"fixed",strictMode:"fixed",mode:"fixed",blockHandle:"fixed",type:"fixed",theme:!0,lang:"fixed",fontSizeUnits:"fixed",allowedClassName:"fixed",closeModalOutsideClick:"fixed",copyFormatKeepOn:!0,syncTabIndent:!0,tabDisable:!0,autoLinkify:!0,autoStyleify:!0,retainStyleMode:!0,allowedExtraTags:"fixed",events:!0,__textStyleTags:"fixed",textStyleTags:"fixed",convertTextTags:"fixed",__tagStyles:"fixed",tagStyles:"fixed",textDirection:!0,reverseButtons:"fixed",historyStackDelayTime:!0,historyStackSize:"fixed",lineAttrReset:!0,printClass:!0,defaultLine:"fixed",defaultLineBreakFormat:!0,lineBreakClearStyle:!0,scopeSelectionTags:!0,__defaultElementWhitelist:"fixed",elementWhitelist:"fixed",elementBlacklist:"fixed",__defaultAttributeWhitelist:"fixed",attributeWhitelist:"fixed",attributeBlacklist:"fixed",__defaultFormatLine:"fixed",formatLine:"fixed",__defaultFormatBrLine:"fixed",formatBrLine:"fixed",__defaultFormatClosureBrLine:"fixed",formatClosureBrLine:"fixed",__defaultFormatBlock:"fixed",formatBlock:"fixed",__defaultFormatClosureBlock:"fixed",formatClosureBlock:"fixed",allowedEmptyTags:!0,toolbar_width:!0,toolbar_innerWidth:"fixed",toolbar_container:"fixed",toolbar_sticky:!0,toolbar_hide:!0,subToolbar:"fixed",statusbar_container:"fixed",shortcutsHint:!0,shortcutsDisable:"fixed",shortcuts:"fixed",fullScreenOffset:!0,previewTemplate:!0,printTemplate:!0,componentInsertBehavior:!0,defaultUrlProtocol:!0,allUsedStyles:"fixed",toastMessageTime:!0,icons:"fixed",freeCodeViewMode:!0,finder_panel:"fixed",finder_liveSearch:!0,__lineFormatFilter:!0,__pluginRetainFilter:!0,__listCommonStyle:"fixed",externalLibs:"fixed"},es=Oe._d;let ss=0;function is(t,e,s,i,n,o){if(!s||s.length<2)return;const r=e?.querySelector(".se-tooltip-text");for(let l,a,h,c,d,u,p,g,m,f,v,b,y,w,C=0;C<s.length;C+=2+w){if(w=0,l=s[C].split("+"),m=null,f=l.at(-1).trim?.(),f.startsWith("~"))m=t,f=l.pop().trim().substring(1);else if(f.startsWith("$~")){const t=l.pop().trim().substring(2).split(".");m=t[0],f=t[1]}else f.startsWith("$")?(w=1,f=s[C+2]):f="";h=c=d=u=p=g=a=null;for(const t of l)switch(t.trim()){case"c":h=!0;break;case"!":d=!0;break;case"s":c=!0;break;case"_":u=!0;break;case"=":g=!0;break;case"/":p=!0;break;default:a=t}a=a.split("|");for(let s=0,r=a.length;s<r;s++)b=h?a[s]+(c?"1000":""):a[s],i.has(b)||(y=n.indexOf(t),y=-1===y?"":De.isOdd(y)?n[y+1]:n[y-1],y&&o.add(b),i.set(b,{c:h,s:c,edge:d,space:u,enter:p,textTrigger:g,plugin:m,command:t,method:f,r:y,type:e?.getAttribute("data-type"),button:e,key:b}));(v=s[C+1])&&(r&&ns(r,c,v))}}function ns(t,e,s){const i=Pe.utils.createElement("SPAN",{class:"se-shortcut"},Oe.cmdIcon+(e?Oe.shiftIcon:"")+'+<span class="se-shortcut-key">'+s+"</span>"),n=t.querySelector(".se-shortcut");n?t.replaceChild(i,n):t.appendChild(i)}function os(t,e){return[t,e].reduce(((t,e)=>{for(const s in e)t[s]=(e[s]||"").toLowerCase();return t}),{})}function rs(t,e,s){const i=t.buttonList||Je.BUTTON_LIST,n=new Map;if(e.length>1&&!t.toolbar_container&&!/inline|balloon/i.test(t.mode))throw Error('[SUNEDITOR.create.fail] In multi root, The "mode" option cannot be "classic" without using the "toolbar_container" option.');n.set("v2Migration",!!t.v2Migration),n.set("buttons",new Set(i.toString().split(","))),n.set("strictMode",{tagFilter:!0,formatFilter:!0,classFilter:!0,textStyleTagFilter:!0,attrFilter:!0,styleFilter:!0,..."boolean"==typeof t.strictMode?{}:t.strictMode}),n.set("freeCodeViewMode",!!t.freeCodeViewMode),n.set("finder_panel",!1!==t.finder_panel),n.set("finder_liveSearch",!1!==t.finder_liveSearch),n.set("__lineFormatFilter",t.__lineFormatFilter??!0),n.set("__pluginRetainFilter",t.__pluginRetainFilter??!0);const[o,r]=(t.mode||"classic").split(":");n.set("mode",o),n.set("_toolbar_bottom","bottom"===r&&/^(classic|inline)$/i.test(o)),n.set("blockHandle",t.blockHandle?"object"==typeof t.blockHandle?t.blockHandle:{}:null),n.set("type",t.type?.split(":")[0]||""),n.set("theme",t.theme||""),n.set("_themeClass",t.theme?` se-theme-${t.theme}`:""),n.set("_type_options",t.type?.split(":")[1]||""),n.set("externalLibs",t.externalLibs||{}),n.set("fontSizeUnits",Array.isArray(t.fontSizeUnits)&&t.fontSizeUnits.length>0?t.fontSizeUnits.map((t=>t.toLowerCase())):Je.SIZE_UNITS),n.set("allowedClassName",new RegExp(`${t.allowedClassName&&"string"==typeof t.allowedClassName?t.allowedClassName+"|":""}${Je.CLASS_NAME}`)),n.set("closeModalOutsideClick",!!t.closeModalOutsideClick),n.set("copyFormatKeepOn",!!t.copyFormatKeepOn),n.set("syncTabIndent",t.syncTabIndent??!0),n.set("autoLinkify",t.autoLinkify??!!s.link),n.set("autoStyleify",Array.isArray(t.autoStyleify)?t.autoStyleify:["bold","underline","italic","strike"]);let l=t.retainStyleMode||"repeat";"string"!=typeof l||Je.RETAIN_STYLE_MODE.includes(l)||(console.error(`Invalid retainStyleMode: ${l}. Valid options are ${Je.RETAIN_STYLE_MODE.join(", ")}. Using default 'repeat'.`),l="repeat"),n.set("retainStyleMode",l);const a={...Je.EXTRA_TAG_MAP,...t.allowedExtraTags,"-":!0},h=Object.keys(a),c=h.filter((t=>a[t])).join("|"),d=h.filter((t=>!a[t])).join("|");n.set("_allowedExtraTag",c),n.set("_disallowedExtraTag",d),n.set("events",t.events||{}),n.set("textStyleTags",("string"==typeof t.__textStyleTags?t.__textStyleTags:Je.TEXT_STYLE_TAGS)+(t.textStyleTags?"|"+t.textStyleTags:""));const u=os({bold:"strong",underline:"u",italic:"em",strike:"del",subscript:"sub",superscript:"sup"},t.convertTextTags||{});n.set("convertTextTags",u),n.set("_textStyleTags",Object.values(u).concat(["span","li"])),n.set("tagStyles",[{...Je.TAG_STYLES,...t.__tagStyles||{}},t.tagStyles||{}].reduce(((t,e)=>{for(const s in e)t[s]=e[s];return t}),{})),n.set("_defaultStyleTagMap",{strong:u.bold,b:u.bold,u:u.underline,ins:u.underline,em:u.italic,i:u.italic,del:u.strike,strike:u.strike,s:u.strike,sub:u.subscript,sup:u.superscript}),n.set("_styleCommandMap",os(ze.swapKeyValue(u),{strong:"bold",b:"bold",u:"underline",ins:"underline",em:"italic",i:"italic",del:"strike",strike:"strike",s:"strike",sub:"subscript",sup:"superscript"})),n.set("_defaultTagCommand",{bold:u.bold,underline:u.underline,italic:u.italic,strike:u.strike,subscript:u.sub,superscript:u.sup}),n.set("textDirection",t.textDirection??"ltr"),n.set("_rtl","rtl"===n.get("textDirection")),n.set("reverseCommands",["indent-outdent"].concat(t.reverseButtons||[])),n.set("_reverseCommandArray",("-"+n.get("reverseCommands").join("-")).split("-")),De.isEven(n.get("_reverseCommandArray").length)&&console.warn('[SUNEDITOR.create.warning] The "reverseCommands" option is invalid, Shortcuts key may not work properly.'),n.set("historyStackDelayTime","number"==typeof t.historyStackDelayTime?t.historyStackDelayTime:400),n.set("historyStackSize","number"==typeof t.historyStackSize&&t.historyStackSize>0?t.historyStackSize:100),n.set("_editableClass","sun-editor-editable"+n.get("_themeClass")+(n.get("_rtl")?" se-rtl":"")+("document"===n.get("type")?" se-type-document-editable-a4":"")),n.set("lineAttrReset",["id"].concat(t.lineAttrReset&&"string"==typeof t.lineAttrReset?t.lineAttrReset.toLowerCase().split("|"):[])),n.set("printClass","string"==typeof t.printClass?t.printClass+" "+n.get("_editableClass"):null),n.set("defaultLine","string"==typeof t.defaultLine&&t.defaultLine.length>0?t.defaultLine:"p"),n.set("defaultLineBreakFormat",t.defaultLineBreakFormat||"line"),n.set("lineBreakClearStyle",!!t.lineBreakClearStyle),n.set("scopeSelectionTags",t.scopeSelectionTags||Je.SCOPE_SELECTION_TAGS);const p=("string"==typeof t.elementWhitelist?t.elementWhitelist:"").toLowerCase(),g=n.get("externalLibs").mathjax?Je.CLASS_MJX+"|":"";n.set("elementWhitelist",p+(p?"|":"")+g+n.get("_allowedExtraTag"));const m=(f=("string"==typeof t.elementBlacklist?t.elementBlacklist:"").toLowerCase(),v=(v=n.get("defaultLine")).toLowerCase(),f.split("|").filter((function(t){return t!==v||(console.warn(`[SUNEDITOR.constructor.createBlacklist.warn] defaultLine("<${v}>") cannot be included in the blacklist and will be removed.`),!1)})).join("|"));var f,v;if(n.set("elementBlacklist",m+(m?"|":"")+n.get("_disallowedExtraTag")),n.set("attributeWhitelist",t.attributeWhitelist&&"object"==typeof t.attributeWhitelist?t.attributeWhitelist:null),n.set("attributeBlacklist",t.attributeBlacklist&&"object"==typeof t.attributeBlacklist?t.attributeBlacklist:null),n.set("formatClosureBrLine",ds(t.formatClosureBrLine,(t.__defaultFormatClosureBrLine="string"==typeof t.__defaultFormatClosureBrLine?t.__defaultFormatClosureBrLine:Je.FORMAT_CLOSURE_BR_LINE).toLowerCase(),n.get("elementBlacklist"))),n.set("formatBrLine",ds((t.formatBrLine||"")+"|"+n.get("formatClosureBrLine").str,(t.__defaultFormatBrLine="string"==typeof t.__defaultFormatBrLine?t.__defaultFormatBrLine:Je.FORMAT_BR_LINE).toLowerCase(),n.get("elementBlacklist"))),n.set("formatLine",ds(Je.REQUIRED_FORMAT_LINE+"|"+(t.formatLine||"")+"|"+n.get("formatBrLine").str,(t.__defaultFormatLine="string"==typeof t.__defaultFormatLine?t.__defaultFormatLine:Je.FORMAT_LINE).toLowerCase(),n.get("elementBlacklist"))),!n.get("formatLine").reg.test(n.get("defaultLine")))throw Error(`[SUNEDITOR.create.fail] The "defaultLine(${n.get("defaultLine")})" option must be included in the "formatLine(${n.get("formatLine").str})" option.`);n.set("formatClosureBlock",ds(t.formatClosureBlock,(t.__defaultFormatClosureBlock="string"==typeof t.__defaultFormatClosureBlock?t.__defaultFormatClosureBlock:Je.FORMAT_CLOSURE_BLOCK).toLowerCase(),n.get("elementBlacklist"))),n.set("formatBlock",ds((t.formatBlock||"")+"|"+n.get("formatClosureBlock").str,(t.__defaultFormatBlock="string"==typeof t.__defaultFormatBlock?t.__defaultFormatBlock:Je.FORMAT_BLOCK).toLowerCase(),n.get("elementBlacklist"))),n.set("allowedEmptyTags",Je.ALLOWED_EMPTY_NODE_LIST+(t.allowedEmptyTags?", "+t.allowedEmptyTags:"")),n.set("__defaultElementWhitelist",Je.REQUIRED_ELEMENT_WHITELIST+"|"+("string"==typeof t.__defaultElementWhitelist?t.__defaultElementWhitelist:Je.ELEMENT_WHITELIST).toLowerCase()),n.set("__defaultAttributeWhitelist",("string"==typeof t.__defaultAttributeWhitelist?t.__defaultAttributeWhitelist:Je.ATTRIBUTE_WHITELIST).toLowerCase()),n.set("_editorElementWhitelist","*"===n.get("elementWhitelist")?"*":function(t){const e=t.get("elementBlacklist").split("|"),s=(t.get("__defaultElementWhitelist")+"|"+t.get("elementWhitelist")+"|"+t.get("formatLine").str+"|"+t.get("formatBrLine").str+"|"+t.get("formatClosureBlock").str+"|"+t.get("formatClosureBrLine").str).replace(/(^\||\|$)/g,"").split("|").filter(((t,s,i)=>t&&i.indexOf(t)===s&&!e.includes(t)));return s.join("|")}(n)),n.set("toolbar_width",t.toolbar_width?De.is(t.toolbar_width)?t.toolbar_width+"px":t.toolbar_width:"auto"),n.set("toolbar_innerWidth",t.toolbar_innerWidth?De.is(t.toolbar_innerWidth)?t.toolbar_innerWidth+"px":t.toolbar_innerWidth:""),n.set("toolbar_container",t.toolbar_container&&!/inline/i.test(n.get("mode"))?"string"==typeof t.toolbar_container?es.querySelector(t.toolbar_container):t.toolbar_container:null);const b=t.toolbar_sticky;/balloon/i.test(n.get("mode"))?(n.set("_toolbar_sticky",-1),n.set("_toolbar_sticky_offset",0),n.set("_toolbar_sticky_fixed",!1)):null!==b&&"object"==typeof b?(n.set("_toolbar_sticky",De.get(b.top,0)),n.set("_toolbar_sticky_offset",De.get(b.offset,0)),n.set("_toolbar_sticky_fixed","fixed"===b.position)):(n.set("_toolbar_sticky",void 0===b?0:De.is(b)?b:-1),n.set("_toolbar_sticky_offset",0),n.set("_toolbar_sticky_fixed",!1)),n.set("toolbar_hide",!!t.toolbar_hide);let y=null;const w=t.subToolbar;w?.buttonList?.length>0&&(/balloon/.test(n.get("mode"))?console.warn('[SUNEDITOR.create.subToolbar.fail] When the "mode" option is "balloon-*", the "subToolbar" option is omitted.'):(n.set("_subMode",w.mode||"balloon"),n.set("toolbar_sub_width",w.width?De.is(w.width)?w.width+"px":w.width:"auto"),y=w.buttonList,n.set("buttons_sub",new Set(y.toString().split(",")))));const C=new Map;for(let s=0,i=e.length;s<i;s++)C.set(e[s].key,as(e[s].options||{},t));n.set("tabDisable",!!t.tabDisable),n.set("shortcutsHint",void 0===t.shortcutsHint||!!t.shortcutsHint);const _=void 0!==t.shortcutsDisable&&t.shortcutsDisable?{}:[{selectAll:["c+KeyA","A"],bold:["c+KeyB","B"],strike:["c+s+KeyS","S"],underline:["c+KeyU","U"],italic:["c+KeyI","I"],redo:["c+KeyY","Y","c+s+KeyZ","Z"],undo:["c+KeyZ","Z"],indent:["c+BracketRight","]"],outdent:["c+BracketLeft","["],save:["c+KeyS","S"],...n.get("finder_panel")?{finder:["c+KeyF","F"]}:{},link:["c+KeyK","K"],hr:["!+---+=+~shortcut",""],list_numbered:["!+1.+_+~shortcut",""],list_bulleted:["!+*.+_+~shortcut",""],_h1:["c+s+Digit1|Numpad1+$~blockStyle.applyHeaderByShortcut",""],_h2:["c+s+Digit2|Numpad2+$~blockStyle.applyHeaderByShortcut",""],_h3:["c+s+Digit3|Numpad3+$~blockStyle.applyHeaderByShortcut",""]},t.shortcuts||{}].reduce(((t,e)=>{for(const s in e)t[s]=e[s];return t}),{});n.set("shortcuts",_),n.set("fullScreenOffset",void 0===t.fullScreenOffset?0:De.is(t.fullScreenOffset)?De.get(t.fullScreenOffset,0):0),n.set("previewTemplate","string"==typeof t.previewTemplate?t.previewTemplate:null),n.set("printTemplate","string"==typeof t.printTemplate?t.printTemplate:null),n.set("componentInsertBehavior",["auto","select","line","none"].includes(t.componentInsertBehavior)?t.componentInsertBehavior:"auto"),n.set("defaultUrlProtocol","string"==typeof t.defaultUrlProtocol?t.defaultUrlProtocol:null);const k=n.get("externalLibs").codeMirror;k&&(n.set("codeMirror",k),k.src?n.set("codeMirrorEditor",!0):(console.warn("[SUNEDITOR.options.externalLibs.codeMirror.fail] The codeMirror option is set incorrectly. See: https://github.com/ARA-developer/suneditor/blob/develop/guide/external-libraries.md"),n.set("codeMirror",null))),n.set("__listCommonStyle",t.__listCommonStyle||["fontSize","color","fontFamily","fontWeight","fontStyle"]);const x=t.icons&&"object"==typeof t.icons?[je,t.icons].reduce(((t,e)=>{for(const s in e)t[s]=e[s];return t}),{}):je;n.set("icons",x);const $=new Set(Je.CONTENT_STYLES.split("|")),S=n.get("__listCommonStyle");for(const t of Object.values(n.get("tagStyles"))){const e=t.split("|");for(let t=0,s=e.length;t<s;t++)$.add(e[t])}for(let t=0,e=S.length;t<e;t++)$.add(S[t]);const E=("string"==typeof t.allUsedStyles?t.allUsedStyles.split("|"):t.allUsedStyles)||[];for(let t=0,e=E.length;t<e;t++)$.add(E[t]);return n.set("allUsedStyles",$),n.set("toastMessageTime",{copy:1500,...t.toastMessageTime}),{o:n,i:x,l:t.lang||Ke(),v:t.value="string"==typeof t.value?t.value:null,buttons:i,subButtons:y,statusbarContainer:"string"==typeof t.statusbar_container?es.querySelector(t.statusbar_container):t.statusbar_container,frameMap:C}}function ls(t,e){let s=null,i=null,n=null,o=null,r=null;if(t.get("statusbar")){if(e||=Pe.utils.createElement("DIV",{class:"se-status-bar sun-editor-common"}),s=e.querySelector(".se-navigation")||Pe.utils.createElement("DIV",{class:"se-navigation sun-editor-common"}),e.appendChild(s),t.get("wordCounter")){if(o=e.querySelector(".se-word-counter-wrapper")||Pe.utils.createElement("DIV",{class:"se-word-counter-wrapper"}),t.get("wordCounter_label")){const e=o.querySelector(".se-word-label")||Pe.utils.createElement("SPAN",{class:"se-word-label"});e.textContent=t.get("wordCounter_label"),o.appendChild(e)}r=o.querySelector(".se-word-counter")||Pe.utils.createElement("SPAN",{class:"se-word-counter"}),r.textContent="0",o.appendChild(r),e.appendChild(o)}if(t.get("charCounter")){if(i=e.querySelector(".se-char-counter-wrapper")||Pe.utils.createElement("DIV",{class:"se-char-counter-wrapper"}),t.get("wordCounter")&&-1===i.className.indexOf("se-with-word-counter")&&(i.className+=" se-with-word-counter"),t.get("charCounter_label")){const e=i.querySelector(".se-char-label")||Pe.utils.createElement("SPAN",{class:"se-char-label"});e.textContent=t.get("charCounter_label"),i.appendChild(e)}if(n=i.querySelector(".se-char-counter")||Pe.utils.createElement("SPAN",{class:"se-char-counter"}),n.textContent="0",i.appendChild(n),t.get("charCounter_max")>0){const e=i.querySelector(".se-char-max")||Pe.utils.createElement("SPAN",{class:"se-char-max"});e.textContent=" / "+t.get("charCounter_max"),i.appendChild(e)}e.appendChild(i)}}return{statusbar:e,navigation:s,charWrapper:i,charCounter:n,wordWrapper:o,wordCounter:r}}function as(t,e){const s=new Map;s.set("_origin",t);const i=e.statusbar_container,n=void 0===t.value?e.value:t.value,o=void 0===t.placeholder?e.placeholder:t.placeholder,r=void 0===t.placeholder_line?e.placeholder_line:t.placeholder_line,l=void 0===t.editableFrameAttributes?e.editableFrameAttributes:t.editableFrameAttributes,a=void 0===t.width?e.width:t.width,h=void 0===t.minWidth?e.minWidth:t.minWidth,c=void 0===t.maxWidth?e.maxWidth:t.maxWidth,d=void 0===t.innerWidth?e.innerWidth:t.innerWidth,u=void 0===t.height?e.height:t.height,p=void 0===t.minHeight?e.minHeight:t.minHeight,g=void 0===t.maxHeight?e.maxHeight:t.maxHeight,m=void 0===t.editorStyle?e.editorStyle:t.editorStyle,f=void 0===t.iframe?e.iframe:t.iframe,v=void 0===t.iframe_fullPage?e.iframe_fullPage:t.iframe_fullPage,b=void 0===t.iframe_attributes?e.iframe_attributes:t.iframe_attributes,y=void 0===t.iframe_cssFileName?e.iframe_cssFileName:t.iframe_cssFileName,w=i||void 0===t.statusbar?e.statusbar:t.statusbar,C=i||void 0===t.statusbar_showPathLabel?e.statusbar_showPathLabel:t.statusbar_showPathLabel,_=!i&&(void 0===t.statusbar_resizeEnable?e.statusbar_resizeEnable:t.statusbar_resizeEnable),k=i||void 0===t.charCounter?e.charCounter:t.charCounter,x=i||void 0===t.charCounter_max?e.charCounter_max:t.charCounter_max,$=i||void 0===t.charCounter_label?e.charCounter_label:t.charCounter_label,S=i||void 0===t.charCounter_type?e.charCounter_type:t.charCounter_type,E=i||void 0===t.wordCounter?e.wordCounter:t.wordCounter,T=i||void 0===t.wordCounter_label?e.wordCounter_label:t.wordCounter_label;s.set("value",n),s.set("placeholder",o),s.set("placeholder_line",r),s.set("editableFrameAttributes",{spellcheck:"false",...l}),s.set("width",a?String(De.is(a)?a+"px":a):"100%"),s.set("minWidth",h?String(De.is(h)?h+"px":h):""),s.set("maxWidth",c?String(De.is(c)?c+"px":c):""),s.set("innerWidth",d?String(De.is(d)?d+"px":d):""),s.set("height",u?String(De.is(u)?u+"px":u):"auto"),s.set("minHeight",p?String(De.is(p)?p+"px":p):""),s.set("maxHeight",g?String(De.is(g)?g+"px":g):""),s.set("editorStyle",m),s.set("_defaultStyles",ze._setDefaultOptionStyle(s,"string"==typeof m?m:"")),s.set("iframe",!(!v&&!f)),s.set("iframe_fullPage",!!v),s.set("iframe_attributes",b||{}),s.set("iframe_cssFileName",f?("string"==typeof y?[y]:y)||["suneditor"]:null);const M=void 0===w||!!w;return s.set("statusbar",M),s.set("statusbar_showPathLabel",!!M&&("boolean"!=typeof C||C)),s.set("statusbar_resizeEnable",!!M&&(void 0===_||!!_)),s.set("charCounter",x>0||"boolean"==typeof k&&k),s.set("charCounter_max",De.is(x)&&x>-1?1*x:null),s.set("charCounter_label","string"==typeof $?$.trim():null),s.set("charCounter_type","string"==typeof S?S:"char"),s.set("wordCounter","boolean"==typeof E&&E),s.set("wordCounter_label","string"==typeof T?T.trim():null),s}function hs(t,e,s,i,n){const o=i.get("_defaultStyles");s.style.cssText=o.top;const r=Pe.utils.createElement(i.get("iframe")?"IFRAME":"DIV",{class:"se-wrapper-inner se-wrapper-wysiwyg"+("document"===e.get("type")?" se-type-document-iframe-a4":""),"data-root-key":t});if(i.get("iframe")){const t=r,e=i.get("iframe_attributes");let s=e.sandbox;if(s){const t=["allow-same-origin","allow-scripts"],e=s.split(/\s+/),i=t.filter((t=>!e.includes(t)));i.length>0&&(s=e.concat(i).join(" "))}else s="allow-same-origin allow-scripts";t.setAttribute("sandbox",s),t.setAttribute("frameBorder","0");for(const s in e)"sandbox"!==s&&t.setAttribute(s,e[s]);t.allowFullscreen=!0,t.setAttribute("scrolling","auto"===i.get("height")?"no":"auto"),t.style.cssText=o.frame}else r.setAttribute("contenteditable","true"),e.get("_rtl")&&(r.dir="rtl"),r.className+=" "+e.get("_editableClass"),r.style.cssText=o.frame+o.editor;const l=Pe.utils.createElement("TEXTAREA",{id:n+"-code-viewer-"+(t||"default"),class:"se-wrapper-inner se-code-viewer",style:o.frame,autocomplete:"off"}),a=Pe.utils.createElement("TEXTAREA",{id:n+"-markdown-viewer-"+(t||"default"),class:"se-wrapper-inner se-markdown-viewer",style:o.frame,autocomplete:"off"}),h=Pe.utils.createElement("SPAN",{class:"se-placeholder"});return i.get("placeholder")&&(h.textContent=i.get("placeholder")),{bottomBar:ls(i,null),wysiwygFrame:r,codeView:l,markdownView:a,placeholder:h}}function cs(t,e,s){let i=null,n=!1;if(t.get("codeMirrorEditor")){const o=t.get("codeMirror"),r=[{mode:"htmlmixed",htmlMode:!0,lineNumbers:!0,lineWrapping:!1},o.options||{}].reduce(((t,e)=>{for(const s in e)t[s]=e[s];return t}),{});"auto"===e.get("height")&&(r.viewportMargin=1/0,r.height="auto");const l=s.style.cssText,a=o.src.fromTextArea(s,r);e.set("codeMirrorEditor",a),i=a.display.wrapper,i.style.cssText=l,n=!0}return t.set("hasCodeMirror",n),i?(Pe.utils.removeItem(s),i.className+=" se-code-viewer-mirror",i):s}function ds(t,e,s){const i=s.split("|"),n=(e+"|"+("string"==typeof t?t.toLowerCase():"")).replace(/^\||\|$/g,"").split("|").filter((t=>t&&!i.includes(t))).join("|");return{reg:new RegExp(`^(${n})$`,"i"),str:n}}function us(t,e,s,i,n){const o=e?.[t];if(o){const e="function"==typeof o?o:o.constructor;return{className:o.className||e.className||"",title:n[o.title]||o.title||n[e.title]||e.title||t,command:t,type:o.type||e.type||"",icon:i[o.icon]||o.icon||i[e.icon]||e.icon||""}}const r=ps(s.get("_rtl"),i,n)[t];return r?{className:r[0],title:r[1],command:r[2],type:r[3],icon:r[4]}:null}function ps(t,e,s){return{bold:["",s.bold,"bold","",e.bold],underline:["",s.underline,"underline","",e.underline],italic:["",s.italic,"italic","",e.italic],strike:["",s.strike,"strike","",e.strike],subscript:["",s.subscript,"subscript","",e.subscript],superscript:["",s.superscript,"superscript","",e.superscript],removeFormat:["",s.removeFormat,"removeFormat","",e.remove_format],copyFormat:["",s.copyFormat,"copyFormat","",e.format_paint],indent:["se-icon-flip-rtl",s.indent,"indent","",t?e.outdent:e.indent],outdent:["se-icon-flip-rtl",s.outdent,"outdent","",t?e.indent:e.outdent],fullScreen:["se-code-view-enabled se-component-enabled",s.fullScreen,"fullScreen","",e.expansion],showBlocks:["",s.showBlocks,"showBlocks","",e.show_blocks],codeView:["se-code-view-enabled se-component-enabled",s.codeView,"codeView","",e.code_view],markdownView:["se-code-view-enabled se-component-enabled",s.markdownView,"markdownView","",e.markdown_view],undo:["se-component-enabled",s.undo,"undo","",e.undo],redo:["se-component-enabled",s.redo,"redo","",e.redo],preview:["se-component-enabled",s.preview,"preview","",e.preview],print:["se-component-enabled",s.print,"print","",e.print],copy:["",s.copy,"copy","",e.copy],dir:["",s[t?"dir_ltr":"dir_rtl"],"dir","",e[t?"dir_ltr":"dir_rtl"]],dir_ltr:["",s.dir_ltr,"dir_ltr","",e.dir_ltr],dir_rtl:["",s.dir_rtl,"dir_rtl","",e.dir_rtl],finder:["se-component-enabled",s.find,"finder","",e.finder],save:["se-component-enabled",s.save,"save","",e.save],newDocument:["se-component-enabled",s.newDocument,"newDocument","",e.new_document],selectAll:["se-component-enabled",s.selectAll,"selectAll_full","",e.select_all],pageBreak:["se-component-enabled",s.pageBreak,"pageBreak","",e.page_break],pageUp:["se-component-enabled",s.pageUp,"pageUp","",e.page_up],pageDown:["se-component-enabled",s.pageDown,"pageDown","",e.page_down],pageNavigator:["se-component-enabled","","pageNavigator","input",""]}}function gs(){const t=Pe.utils.createElement("UL",{class:"se-menu-list"});return{div:Pe.utils.createElement("DIV",{class:"se-btn-module se-btn-module-border"},t),ul:t}}function ms(t,e,s,i,n,o,r){n||="";const l=Pe.utils.createElement("LI"),a=e||"",h=/^INPUT|FIELD$/i.test(i),c="se-toolbar-separator-vertical"===t?Pe.utils.createElement("DIV",{class:t,tabindex:"-1"},null):Pe.utils.createElement(h?"DIV":"BUTTON",{class:"se-toolbar-btn se-btn se-tooltip"+(t?" "+t:""),"data-command":s,"data-type":i,"aria-label":a.replace(/<span .+<\/span>/,""),tabindex:"-1"});return h||c.setAttribute("type","button"),/^default\./i.test(n)&&(n=r[n.replace(/^default\./i,"")]),/^text\./i.test(n)&&(n=n.replace(/^text\./i,""),c.className+=" se-btn-more-text"),o&&(c.disabled=!0),/^FIELD$/i.test(i)&&Pe.utils.addClass(l,"se-toolbar-hidden-btn"),a&&(n+=Pe.utils.createTooltipInner(a)),n&&(c.innerHTML=n),l.appendChild(c),{li:l,button:c}}function fs(t,e,s,i){if(!t)return;const n=!1===e.inner;if(1===e.inner?.nodeType?t.appendChild(e.inner):t.innerHTML=n?"":(e.inner||s[e.icon]||e.icon||'<span class="se-icon-text">!</span>')+'<span class="se-tooltip-inner"><span class="se-tooltip-text">'+(i[e.title]||e.title)+"</span></span>",t.setAttribute("aria-label",e.title),e.type&&t.setAttribute("data-type",e.type),e.className&&(t.className+=" "+e.className),e.afterItem&&(Pe.utils.addClass(e.afterItem,"se-toolbar-btn"),t.parentElement.appendChild(e.afterItem),Pe.utils.addClass(t,"se-side-btn-a"),Pe.utils.addClass(e.afterItem,"se-side-btn-after")),e.beforeItem&&(Pe.utils.addClass(e.beforeItem,"se-toolbar-btn"),t.parentElement.insertBefore(e.beforeItem,t),e.afterItem?(Pe.utils.addClass(t,"se-side-btn"),Pe.utils.removeClass(t,"se-side-btn-a")):Pe.utils.addClass(t,"se-side-btn-b"),Pe.utils.addClass(e.beforeItem,"se-side-btn-before")),e.replaceButton&&(t.parentElement.appendChild(e.replaceButton),t.style.display="none"),!e.replaceButton&&/^INPUT$/i.test(t.getAttribute("data-type"))){const e=t.querySelector("input");e&&(Pe.utils.addClass(e,"se-toolbar-btn"),e.setAttribute("data-command",t.getAttribute("data-command")),e.setAttribute("data-type",t.getAttribute("data-type")),t.hasAttribute("disabled")&&(e.disabled=!0))}}function vs(t,e,s,i,n,o){t=JSON.parse(JSON.stringify(t));const r=ps(s.get("_rtl"),i,n),l={},a=[],h=[];let c=null,d=null,u=null,p=null,g=null;const m=Pe.utils.createElement("DIV",{class:"se-toolbar-more-layer"}),f=Pe.utils.createElement("DIV",{class:"se-btn-tray"}),v=Pe.utils.createElement("DIV",{class:"se-toolbar-separator-vertical"});t:for(let s,b,y,w,C,_=0;_<t.length;_++)if(s=!1,C="",w=t[_],p=gs(),"object"==typeof w){for(let f,v=0;v<w.length;v++){if(d=w[v],f=!1,u=e[d],/^%\d+/.test(d)&&0===v){w[0]=d.replace(/[^\d]/g,""),a.push(w),t.splice(_--,1);continue t}if("function"==typeof u)c=[u.className,u.title,d,u.type,u.innerHTML,u._disabled];else if("object"==typeof u){const t=u.constructor;c=[u.className||t.className,u.title||t.title,d,u.type||t.type,u.innerHTML||t.innerHTML,u._disabled||t._disabled]}else{if(/^-/.test(d)){C=d.substring(1),p.div.className+=" module-float-"+C;continue}if(/^#/.test(d)){"fix"===d.substring(1)&&(p.ul.className+=" se-menu-dir-fix");continue}if(/^:/.test(d)){f=!0;const t=d.match(/^:([^-]+)-([^-]+)/);y="__se__more_"+_;const e=t[1].trim(),s=t[2].trim();c=["se-btn-more",/^lang\./i.test(e)?n[e.replace(/^lang\./i,"")]:e,y,"MORE",s]}else"|"===d?c=["se-toolbar-separator-vertical","","","separator",""]:("copy"!==d||Oe.isClipboardSupported||console.warn("[SUNEDITOR.constructor.warn] Clipboard is not supported in this browser. : [copy] button is not rendered."),c=r[d]);if(!c){if(!u)throw Error(`[SUNEDITOR.create.toolbar.fail] The button name of a plugin that does not exist. [${d}]`);u="object"==typeof u?u.constructor:u,c=[u.className,u.title,u.key,u.type,u.innerHTML,u._disabled]}}g=ms(c[0],c[1],c[2],c[3],c[4],c[5],i),(s?b:p.ul).appendChild(g.li),u&&(l[d]?l[d].push(g.button):l[d]=[g.button],o&&h.push({button:g.button,plugin:u,key:d})),f&&(s=!0,b=Pe.utils.createElement("DIV"),b.className="se-more-layer "+y,b.setAttribute("data-ref",y),b.innerHTML='<div class="se-more-form"><ul class="se-menu-list"'+(C?' style="float: '+C+';"':"")+"></ul></div>",m.appendChild(b),b=b.firstElementChild.firstElementChild)}f.appendChild(p.div)}else{if("|"===w){const t=v.cloneNode(!1);f.appendChild(t);continue}if(/^\/$/.test(w)){const t=Pe.utils.createElement("DIV",{class:"se-btn-module-enter"});f.appendChild(t)}}switch(f.children.length){case 0:f.style.display="none";break;case 1:Pe.utils.removeClass(f.firstElementChild,"se-btn-module-border")}var b,y;m.children.length>0&&f.appendChild(m),a.length>0&&a.unshift(t),b=f,y=s.get("toolbar_innerWidth"),b&&y&&("auto"!==y&&(b.style.maxWidth=y),b.style.width="max-content",b.style.marginLeft="auto",b.style.marginRight="auto");const w=Pe.utils.createElement("DIV",{class:"se-toolbar sun-editor-common"+(s.get("shortcutsHint")?"":" se-shortcut-hide")},f);return s.get("toolbar_hide")&&(w.style.display="none"),{element:w,pluginCallButtons:l,responsiveButtons:a,buttonTray:f,updateButtons:h}}const bs=function(t,e){"object"!=typeof e&&(e={});const s={};if(e.plugins){const t=e.excludedPlugins||[],i=e.plugins,n=Array.isArray(i)?i.map((t=>[null,t])):Object.keys(i).map((t=>[t,i[t]]));for(let e,i,o=0,r=n.length;o<r;o++)e=n[o][0],i=n[o][1],i=i?.default||i,i?.key&&(t.includes(i.key)||null!==e&&t.includes(e)||(s[i.key]=i))}const i=rs(e,t,s),n=i.o,o=i.i,r=i.l,l=Pe.utils.createElement("DIV",{class:"se-loading-box sun-editor-common"},'<div class="se-loading-effect"></div>'),a="suneditor-"+ ++ss,h=Pe.utils.createElement("DIV",{class:"sun-editor sun-editor-carrier-wrapper sun-editor-common"+n.get("_themeClass")+(n.get("_rtl")?" se-rtl":"")}),c=Pe.utils.createElement("DIV",{class:"se-menu-tray",popover:"manual"});h.appendChild(c);const d=Pe.utils.createElement("INPUT",{type:"text",id:a+"-focus-temp",class:"__se__focus__temp__",autocomplete:"off","aria-hidden":"true",style:"position: fixed !important; top: -10000px !important; left: -10000px !important; display: block !important; width: 0 !important; height: 0 !important; margin: 0 !important; padding: 0 !important;"});d.tabIndex=-1,h.appendChild(d);const u=Pe.utils.createElement("DIV",{class:"se-modal se-modal-area sun-editor-common",popover:"manual"}),p=Pe.utils.createElement("DIV",{class:"se-modal-back"}),g=Pe.utils.createElement("DIV",{class:"se-modal-inner"});u.appendChild(p),u.appendChild(g),h.appendChild(u);const m=Pe.utils.createElement("DIV",{class:"se-alert se-modal-area sun-editor-common",style:"display: none;",popover:"manual"}),f=Pe.utils.createElement("DIV",{class:"se-modal-back"}),v=Pe.utils.createElement("DIV",{class:"se-modal-inner"});m.appendChild(f),m.appendChild(v),h.appendChild(m),h.appendChild(Pe.utils.createElement("DIV",{class:"se-back-wrapper",popover:"manual"}));const b=l.cloneNode(!0);b.setAttribute("popover","manual"),h.appendChild(b);const y=Pe.utils.createElement("DIV",{class:"se-drag-cursor",popover:"manual"});h.appendChild(y),es.body.appendChild(h);let w=null,C=null;const _=vs(i.buttons,s,n,o,r,!1),k=_.element;k.style.visibility="hidden",/inline/i.test(n.get("mode"))?(k.className+=" se-toolbar-inline",k.style.width=n.get("toolbar_width")):/balloon/i.test(n.get("mode"))&&(k.className+=" se-toolbar-balloon",k.style.width=n.get("toolbar_width"),k.appendChild(Pe.utils.createElement("DIV",{class:"se-arrow"}))),n.get("_toolbar_bottom")&&(k.className+=" se-toolbar-bottom"),i.subButtons&&(C=vs(i.subButtons,s,n,o,r,!1),w=C.element,w.style.visibility="hidden",w.className+=" se-toolbar-balloon se-toolbar-sub",w.style.width=n.get("toolbar_sub_width"),w.appendChild(Pe.utils.createElement("DIV",{class:"se-arrow"})));const x=t[0].key||null,$=[],S=new Map,E=i.statusbarContainer;let T=null;for(let e=0,s=t.length;e<s;e++){const s=t[e],h=i.frameMap.get(s.key),c=Pe.utils.createElement("DIV",{class:"sun-editor"+n.get("_themeClass")+(n.get("_rtl")?" se-rtl":"")}),d=Pe.utils.createElement("DIV",{class:"se-container"}),u=!!n.get("blockHandle"),p=Pe.utils.createElement("DIV",{class:"se-wrapper"+(u?" se-mode-block":"")+("document"===n.get("type")?" se-type-document":"")+(n.get("_type_options").includes("header")?" se-type-document-header":"")}),g=h.get("innerWidth");g&&"auto"!==g&&p.style.setProperty("--se-editor-inner-width",g),d.appendChild(Pe.utils.createElement("DIV",{class:"se-toolbar-shadow"}));const m=hs(s.key,n,c,h,a),f=m.bottomBar.statusbar,v=m.wysiwygFrame,b=m.placeholder;let y=m.codeView;const w=Pe.utils.createElement("DIV",{class:"se-line-breaker-component se-line-breaker-component-t",title:r.insertLine},o.line_break),C=Pe.utils.createElement("DIV",{class:"se-line-breaker-component se-line-breaker-component-b",title:r.insertLine},o.line_break);p.appendChild(w),p.appendChild(C),b&&p.appendChild(b),d.appendChild(Pe.utils.createElement("DIV",{class:"se-toolbar-sticky-dummy"})),d.appendChild(p),f&&(E?T||(E.appendChild(Pe.utils.createElement("DIV",{class:"sun-editor"+n.get("_themeClass")},f)),T=f):d.appendChild(f)),d.appendChild(l.cloneNode(!0));const _=s.key||null;let k=null;if(n.get("buttons").has("codeView")){k=Pe.utils.createElement("DIV",{class:"se-code-wrapper"},y),k.style.setProperty("display","none","important"),p.appendChild(k);const t=cs(n,h,y);if(y===t){const t=Pe.utils.createElement("TEXTAREA",{id:a+"-code-view-line-"+(_||"default"),class:"se-code-view-line",readonly:"true",autocomplete:"off","aria-hidden":"true",tabindex:"-1"},null);k.insertBefore(t,y)}else y=t}let x=null,M=null;if(n.get("buttons").has("markdownView")){M=m.markdownView;const t=Pe.utils.createElement("TEXTAREA",{id:a+"-markdown-view-line-"+(_||"default"),class:"se-markdown-view-line",readonly:"true",autocomplete:"off","aria-hidden":"true",tabindex:"-1"},null);x=Pe.utils.createElement("DIV",{class:"se-markdown-wrapper"}),x.appendChild(t),x.appendChild(M),x.style.setProperty("display","none","important"),p.appendChild(x)}const N={inner:null,page:null,pageMirror:null};n.get("_type_options").includes("header")&&(N.inner=Pe.utils.createElement("DIV",{class:"se-document-lines",style:`height: ${h.get("height")};`},'<div class="se-document-lines-inner"></div>')),n.get("_type_options").includes("page")&&(N.page=Pe.utils.createElement("DIV",{class:"se-document-page"},null),N.pageMirror=Pe.utils.createElement("DIV",{class:"sun-editor-editable se-document-page-mirror-a4",style:"position: absolute; width: 21cm; columns: 21cm; border: 0; overflow: hidden; height: auto; top: -10000px; left: -10000px;"},null));let B=null;if(u){B=Pe.utils.createElement("DIV",{class:"se-block-handle-area"});const t=Pe.utils.createElement("DIV",{class:"se-block-handle",popover:"manual"}),e=Pe.utils.createElement("DIV",{class:"se-block-handle-btn se-block-handle-plus"},o.plus),s=Pe.utils.createElement("DIV",{class:"se-block-handle-btn se-block-handle-drag"},o.dragHandle);t.appendChild(e),t.appendChild(s),B.appendChild(t)}c.appendChild(d),$.push(_),S.set(_,Xe({target:s.target,key:s.key,options:h},c,v,k,y,x,M,T||f,N,B,_))}const M=n.get("toolbar_container");if(M){const t=Pe.utils.createElement("DIV",{class:"sun-editor"+n.get("_themeClass")+(n.get("_rtl")?" se-rtl":"")}),e=Pe.utils.createElement("DIV",{class:"se-container"});e.appendChild(k),w&&e.appendChild(w),t.appendChild(e),M.appendChild(t),M.appendChild(Pe.utils.createElement("DIV",{class:"se-toolbar-sticky-dummy"}))}else{const t=S.get(x).get("container");if(n.get("_toolbar_bottom")){const e=t.querySelector(".se-statusbar");t.insertBefore(k,e),w&&t.insertBefore(w,k)}else t.insertBefore(k,t.firstElementChild),w&&t.insertBefore(w,t.firstElementChild)}return{context:Ye(k,M,c,w,E),carrierWrapper:h,options:n,plugins:s,icons:o,lang:r,value:i.v,rootId:x,rootKeys:$,frameRoots:S,pluginCallButtons:_.pluginCallButtons,responsiveButtons:_.responsiveButtons,pluginCallButtons_sub:C?C.pluginCallButtons:[],responsiveButtons_sub:C?C.responsiveButtons:[]}},{_w:ys}=Oe,ws=Math.floor(96/72*841.89105);const Cs=class{#t;#e;#s;#i;#n;#o;#r;#l;#a;#h;#c;#d;#u;#p;#g;#m;#f=-1;#v=-1;#b=null;#y=null;#w=0;#C=0;#_=-1;#k=0;#x=[];#$=null;#S=0;#E=0;#T=new Map;#M=null;constructor(t,e){const s=t.$;if(this.#t=s.store,this.#e=s.context,this.#s=this.#t.get("isScrollable"),this.#i=s.offset,this.#n=s.selection,this.#o=s.toolbar,this.useHeader=s.options.get("_type_options").includes("header"),this.usePage=s.options.get("_type_options").includes("page"),this.#r=e,this.#l=e.get("wysiwyg"),this.#a=e.get("wysiwygFrame"),this.#h=e.get("documentTypeInner"),this.#p=e.get("documentTypePageMirror"),this.#p){const t=ys.getComputedStyle(this.#p);this.#g=De.get(t.paddingTop),this.#m=De.get(t.paddingBottom)}if(this.useHeader){const t=this._getHeaders(),e=this.#c=this.#h.querySelector(".se-document-lines-inner");let i="";for(let e,s=0,n=t.length;s<n;s++)e=t[s],i+=`<div class="se-doc-item se-doc-h${De.get(e.nodeName)}" title="${e.textContent}">${e.textContent}</div>`;e.innerHTML=i,this.#b=e.querySelectorAll("div"),s.eventManager.addEvent(e,"click",this.#N.bind(this,this.#l))}this.usePage&&(this.#d=e.get("documentTypePage"),this.#u=s.plugins.pageNavigator)}reHeader(){if(!this.useHeader)return;const t=this._getHeaders(),e=this.#c,s=this.#b;for(let i,n,o,r=0,l=t.length;r<l;r++)if(i=t[r],n=`se-doc-h${De.get(i.nodeName)}`,o=s[r],r<s.length)o.classList.contains(n)&&o.textContent===i.textContent||(o.textContent=o.title=i.textContent,o.className=`se-doc-item ${n}`);else{const t=document.createElement("div");t.className=`se-doc-item ${n}`,t.textContent=t.title=i.textContent,e.appendChild(t)}if(s.length>t.length)for(let i=t.length;i<s.length;i++)e.removeChild(s[i]);this.#b=e.querySelectorAll("div")}async rePage(t){this.#d&&(this.#M&&ys.clearTimeout(this.#M),this.#M=ys.setTimeout((async()=>{await Pe.utils.waitForMediaLoad(this.#p,1500);const e=this.#l.scrollHeight>this.#p.scrollHeight?this.#l.scrollHeight-this.#p.scrollHeight:0,s=this.#p.scrollHeight+e,i=this.#l.querySelectorAll(".se-page-break");if(!t&&this.#_===s&&this.#k===i.length)return;this.#_=s,this.#k=i.length;let n=0;const o=[];if(i.length>0){n=i[0].offsetHeight;for(let t=0;t<i.length;t++)o.push({top:i[t].offsetTop,end:i[t].offsetTop+n/2})}const r=this.#s(this.#r)?this._getWWScrollTop():0,l=[{number:0,top:0}];for(let t=0;t<o.length;t++)l.push({number:0,top:o[t].top+n/2,isBreak:!0});this.#E=0;const a=this.#l.children,h=this.#p.children;this._initializeCache(h);const c=[0,...o.map((t=>t.end))],d=[...o.map((t=>t.top)),s];for(let t=0;t<c.length;t++){const e=d[t];let s=c[t],i=0===t;for(;s+=ws+(i?this.#g+this.#m:this.#g),i=!1,!(s>=e);)if(!l.some((t=>Math.abs(t.top-s)<3))){const t=this._calcPageBreakTop(s,a,h,l);if(null===t)break;l.push({number:0,top:t})}}if(0===l.length)return this.#$=null,this.#w=1,void this._displayCurrentPage();l.sort(((t,e)=>t.top-e.top)),this.#d.innerHTML="",this.#x=[];const u=this.#a.offsetWidth+1;for(let t,e=0;e<l.length&&(t=l[e].top,!(s<t));e++){const s=Pe.utils.createElement("DIV",{style:`top:${t-r}px`,innerHTML:String(e+1)},`<div class="se-document-page-line" style="width: ${u}px;"></div>${e+1}`);this.#d.appendChild(s),this.#x.push(s)}this.#$=this.#d.querySelectorAll(".se-document-page-line"),this.#w=this.#x.length,this.#B(),this._displayCurrentPage()}),400))}_getDisplayPage(){return this.#s(this.#r)?this.#r.get("wysiwyg"):ys}_calcPageBreakTop(t,e,s,i){const{ci:n}=this._getElementAtPosition(t,s,i),o=s[n],r=e[n];if(!o||!r)return null;const l=t+(r.offsetTop-o.offsetTop)+(r.offsetHeight-o.offsetHeight)/2;return Math.round(l)}_initializeCache(t){this.#T.clear();for(let e=0,s=t.length;e<s;e++){const s=t[e],i=s.offsetTop,n=s.offsetHeight,o=i+n;this.#T.set(e,{top:i,height:n,bottom:o})}}_getElementAtPosition(t,e,s){let i=this.#E,n=e.length-1;if(i>0){const e=this.#T.get(i);e&&t<e.top&&(i=0)}for(;i<=n;){const o=Math.floor((i+n)/2),{top:r,height:l,bottom:a}=this.#T.get(o);if(t>=r&&t<=a){let i=o;if(s&&Pe.utils.hasClass(e[i],"se-page-break")){i=i+1<e.length?i+1:Math.max(0,i-1);const s=this.#T.get(i);return this.#E=i,{ci:i,cm:t-s.bottom,ch:s.height}}return this.#E=i,{ci:i,cm:t-a,ch:l}}t<r?n=o-1:i=o+1}let o=e[i]?i:n;s&&Pe.utils.hasClass(e[o],"se-page-break")&&(o=o+1<e.length?o+1:Math.max(0,o-1)),this.#E=o;const r=this.#T.get(o);return{ci:o,cm:t-r.bottom,ch:r.height}}resizePage(){const t=this.#a.offsetWidth+1,e=this.#a.offsetHeight+1;let s=!1;if(t===this.#f&&(s=e===this.#v))return;t>800?Pe.utils.removeClass(this.#h,"se-document-responsible"):Pe.utils.addClass(this.#h,"se-document-responsible"),this.#f=t,this.#v=e;const i=this.#$;for(let e=0,s=i?.length;e<s;e++)i[e].style.width=`${t}px`;s||this.rePage(!0),this._displayCurrentPage()}scrollPage(){const t=this.#S,e=this._getWWScrollTop();if(t===e)return;const s=this.#x,i=e-t;for(let t=0,e=s.length;t<e;t++)s[t].style.top=De.get(s[t].style.top)-i+"px";this.#B(),this.#S=e,this._displayCurrentPage()}#B(){const t=this.#x;if(!t?.length)return;const e=this.#a.offsetHeight;for(let s=0,i=t.length;s<i;s++){const i=De.get(t[s].style.top);t[s].style.display=i<0||i>e?"none":""}}scrollWindow(){this.#s(this.#r)||this._displayCurrentPage()}getCurrentPageNumber(){if(this.#w<=1)return 1;let t=0;if(this.#s(this.#r))t=this.#v/2;else{const e=this._getGlobalTop();if(t=ys.scrollY-e+ws/2,t<=0)return 1}const e=this.#x;for(let s=0,i=e.length;s<i;s++)if(e[s].offsetTop>=t)return this.#C=s;return this.#C=this.#w}pageUp(){const t=this.#C-1<=1?1:this.#C-1;this._movePage(t,!1)}pageDown(){const t=this.#C+1>this.#x.length?this.#x.length:this.#C+1;this._movePage(t,!1)}pageGo(t){t<1?t=1:t>this.#x.length&&(t=this.#x.length),this._movePage(t,!0)}on(t){if(!this.useHeader)return;if(this._is(t)||(t=this._findLinesHeader(t)),!t)return;const e=this._findItem(t);e&&(Pe.utils.removeClass(this.#b,"active"),Pe.utils.addClass(e,"active"))}onChangeText(t){if(!this.useHeader)return;if(!this._is(t))return;const e=this._findItem(t);e&&(e.textContent=t.textContent)}_displayCurrentPage(){const t=this.getCurrentPageNumber();this.#u?.display(t,this.#w)}_getWWScrollTop(){const t=this._getDisplayPage();return t.scrollTop||t.scrollY||0}_movePage(t,e){const s=this._getGlobalTop(),i=this.#s(this.#r),n=ze.nodeListToArray(this.#l.children),o=this.#d.offsetTop+De.get(this.#x[t-1].style.top)+(i?this._getWWScrollTop():0);for(let r,l=0,a=n.length;l<a;l++)if(r=n[l],r.offsetTop>=o){e||this.#n.setRange(r,0,r,0);const n=0===l&&i?0:r.offsetTop-this.#d.offsetTop-r.offsetHeight+s;this._applyPageScroll(n,(()=>{this.#o.isSticky&&!this.#t.mode.isBottom&&this._getDisplayPage().scrollTo({top:n-this.#e.get("toolbar_main").offsetHeight,behavior:"smooth"})})),this.#C=t;break}}_applyPageScroll(t,e){const s=this._getDisplayPage();s.scrollTo({top:t,behavior:"smooth"});const i=()=>{Math.abs((s.scrollY??s.scrollTop)-t)<1?e():ys.requestAnimationFrame(i)};ys.requestAnimationFrame(i)}_getGlobalTop(){return this.#s(this.#r)?0:this.#i.getGlobal(this.#a).top}_findItem(t){const e=this.#y,s=Array.prototype.indexOf.call(e,t);return-1!==s&&this.#b[s]?this.#b[s]:null}_findLinesHeader(t){for(;t&&t!==this.#l;){if(this._is(t))return t;t=t.previousElementSibling||t.parentElement}return null}_is(t){return/^h[1-6]$/i.test(t?.nodeName)}_getHeaders(){return this.#y=this.#l.querySelectorAll("h1, h2, h3, h4, h5, h6")}#N(t,e){e.preventDefault();try{this.#t.set("_preventBlur",!0);const t=Pe.query.getEventTarget(e);if(Pe.utils.hasClass(t,"se-doc-item")){const e=Array.prototype.indexOf.call(this.#b,t);if(-1===e)return;const s=this.#y[e];s&&this.#n.scrollTo(s)}}finally{this.#t.set("_preventBlur",!1)}}_destroy(){this.#M&&(ys.clearTimeout(this.#M),this.#M=null),this.#T&&(this.#T.clear(),this.#T=null),this.#r=null,this.#l=null,this.#a=null,this.#h=null,this.#c=null,this.#d=null,this.#x=null,this.#$=null,this.#b=null,this.#y=null,this.#u=null,this.#p=null}};const _s=class{#I;#L=new Map;constructor(t){const e=t.options,s=e.get("mode"),i=e.get("_subMode");this._editorInitFinished=!1,this.mode={isClassic:/classic/i.test(s),isInline:/inline/i.test(s),isBalloon:/balloon/i.test(s),isBalloonAlways:/balloon-always/i.test(s),isSubBalloon:/balloon/i.test(i),isSubBalloonAlways:/balloon-always/i.test(i),isBottom:!!e.get("_toolbar_bottom")},this.#I={rootKey:t.rootId,hasFocus:!1,tabSize:4,indentSize:25,codeIndentSize:2,currentNodes:[],currentNodesMap:[],initViewportHeight:0,currentViewportHeight:0,controlActive:!1,_lastSelectionNode:null,isScrollable:t=>{const e=t.get("options"),s=e.get("height"),i=e.get("maxHeight");return"auto"!==s||!!i&&t.get("wysiwyg").offsetHeight>=De.get(i)},_range:null,_mousedown:!1,_preventBlur:!1,_preventFocus:!1,_canUseBeforeInput:!0}}get(t){return this.#I[t]}set(t,e){const s=this.#I[t];this.#I[t]=e,this.#A(t,e,s)}subscribe(t,e){return this.#L.has(t)||this.#L.set(t,new Set),this.#L.get(t).add(e),()=>this.#L.get(t).delete(e)}#A(t,e,s){const i=this.#L.get(t);if(i)for(const n of i)try{n(e,s)}catch(e){console.error(`[Store] Subscriber error for "${t}":`,e)}}_reset(){}_destroy(){this.#L.clear(),this.#I=null}},{_w:ks,_d:xs}=Oe;class $s{#O;#R;#z;constructor(t){this.#O=t.frameRoots,this.#R=this.#P(t.context),this.#z=this.#D({value:new Map}),this.rootKeys=t.rootKeys,this.carrierWrapper=t.carrierWrapper,this.icons=t.icons,this.lang=t.lang,this.shadowRoot=null}get frameRoots(){return this.#O}get context(){return this.#R}get frameContext(){return this.#z}init(){this.applyToRoots((t=>{this.#F(t)}))}reset(t){this.#z.reset(t)}applyToRoots(t){this.#O.forEach(t)}#F(t){const e=t.get("options");if(t.set("wwComputedStyle",ks.getComputedStyle(t.get("wysiwyg"))),!e.get("iframe")&&"function"==typeof ShadowRoot){let e=t.get("wysiwygFrame");for(;e;){if(e.shadowRoot){this.shadowRoot=e.shadowRoot;break}if(e instanceof ShadowRoot){this.shadowRoot=e;break}e=e.parentNode}}e.get("iframe")?(t.set("_ww",t.get("wysiwygFrame").contentWindow),t.set("_wd",t.get("wysiwygFrame").contentDocument),t.set("wysiwyg",t.get("_wd").body),e.get("_defaultStyles").editor&&(t.get("wysiwyg").style.cssText=e.get("_defaultStyles").editor),"auto"===e.get("height")&&t.set("_iframeAuto",t.get("_wd").body)):(t.set("_ww",ks),t.set("_wd",xs));const s=e.get("editableFrameAttributes");for(const e in s)t.get("wysiwyg").setAttribute(e,s[e])}#P(t){const e=t;return{get:t=>e.get(t),set:(t,s)=>e.set(t,s),has:t=>e.has(t),delete:t=>e.delete(t),getAll:()=>Object.fromEntries(e.entries()),get size(){return e.size},clear(){e.clear()}}}#D(t){let e=t.value;return{get:t=>e.get(t),set:(t,s)=>e.set(t,s),has:t=>e.has(t),delete:t=>e.delete(t),getAll:()=>Object.fromEntries(e.entries()),reset(s){e=t.value=s},get size(){return e.size},clear(){e.clear()}}}_destroy(){this.applyToRoots((t=>{const e=t.get("documentType");e&&e._destroy(),Pe.utils.removeItem(t.get("topArea")),t.get("options").clear(),t.clear()})),this.#R.clear(),this.#z.clear(),this.#O.clear(),Pe.utils.removeItem(this.carrierWrapper),this.rootKeys=null,this.carrierWrapper=null,this.icons=null,this.lang=null,this.shadowRoot=null}}class Ss{#H;#q;#W;#U;constructor(t,e,s){this.#H=t,this.#q=s,this.#W=this.#V({value:e.options}),this.#U=this.#j({value:new Map})}get options(){return this.#W}get frameOptions(){return this.#U}reset(t){const{$:e}=this.#H,s=e.frameRoots,i=e.context,n=e.eventManager,o=e.format,r=e.html,l=e.char,a=e.viewer,h=e.plugins,c=e.history,d=e.ui,u=this.#H._eventOrchestrator;a.codeView(!1),a.showBlocks(!1);const p=new Map,g=[],m=new Map,f={};for(const e in t)void 0!==Qe[e]&&(f[e]=t[e],delete t[e]);for(const e of s.keys())t[e||""]={...f,...t[e||""]};const v=Object.keys(t);if(this.#G(v,h,""),0===v.length)return;1===s.size&&v.unshift(null);const b=[this.#q,t].reduce(((t,e)=>{for(const i in e)s.has(i||null)?this.#K(i,e,s,p,m,g):t[i]=e[i];return t}),{}),y=this.#W,w=rs(b,g,h),C=w.o,_=w.frameMap;for(let t,e=0,i=v.length;e<i;e++)if(t=v[e]||null,m.has(t)){const e=p.get(t),i=s.get(t),o=i.get("options"),r=_.get(t);for(const[t,e]of r.entries())o.set(t,e);if(e.has("statusbar-changed")){if(Pe.utils.removeItem(i.get("statusbar")),r.get("statusbar")){const t=ls(r,null).statusbar;i.get("container").appendChild(t),Ze(t,i),u.__addStatusbarEvent(i,r)}else n.removeEvent(o.get("__statusbarEvent")),r.set("__statusbarEvent",null),Ze(null,i);i.get("statusbar")&&l.display(i)}if(e.has("iframe_attributes")){const t=i.get("wysiwygFrame"),e=o.get("iframe_attributes"),s=r.get("iframe_attributes");for(const s in e)t.removeAttribute(s);for(const e in s)t.setAttribute(e,s[e])}if(e.has("iframe_cssFileName")){const t=i.get("_wd").head,e=t.getElementsByTagName("link");for(;e[0];)t.removeChild(e[0]);const s=(new DOMParser).parseFromString(ze._setIframeStyleLinks(r.get("iframe_cssFileName")),"text/html").head.children,n=t.querySelector("style");for(;s[0];)t.insertBefore(s[0],n)}if(e.has("placeholder")&&(i.get("placeholder").textContent=r.get("placeholder")),e.has("placeholder_line")){const t=r.get("placeholder_line");i.set("placeholder_line",t);const e=i.get("wysiwyg").querySelector(".se-placeholder-line");if(e){const s=d.resolveLinePlaceholder(e,t);s?e.setAttribute("data-se-placeholder-line",s):(e.classList.remove("se-placeholder-line"),e.removeAttribute("data-se-placeholder-line"),e.getAttribute("class")||e.removeAttribute("class"))}}d.setEditorStyle(r.get("editorStyle"),i);const a=i.get("wysiwyg"),h=o.get("editableFrameAttributes"),c=r.get("editableFrameAttributes");for(const t in h)a.removeAttribute(t);for(const t in c)a.setAttribute(t,c[t])}else switch(t){case"theme":d.setTheme(C.get("theme"));break;case"events":{const t=C.get("events");for(const e in t)n.events[e]=t[e];break}case"autoStyleify":r.__resetAutoStyleify(C.get("autoStyleify"));break;case"textDirection":d.setDir("rtl"===C.get("textDirection")?"rtl":"ltr");break;case"historyStackDelayTime":c.resetDelayTime(C.get("historyStackDelayTime"));break;case"defaultLineBreakFormat":o.__resetBrLineBreak(C.get("defaultLineBreakFormat"))}y.setMany(C),this.#q=b;const k=i.get("toolbar_main");/inline|balloon/i.test(y.get("mode"))&&v.includes("toolbar_width")&&(k.style.width=y.get("toolbar_width")),y.get("toolbar_hide")?k.style.display="none":k.style.display="",y.get("shortcutsHint")?Pe.utils.removeClass(k,"se-shortcut-hide"):Pe.utils.addClass(k,"se-shortcut-hide")}resetFrame(t){this.#U.reset(t)}#K(t,e,s,i,n,o){const r=e[t],l=Object.keys(r);if(this.#G(l,null,t+"."),0===l.length)return!1;const a=t||null;i.set(a,new Map);const h=s.get(a).get("options").get("_origin"),c={},d=Object.prototype.hasOwnProperty;for(const t in r){if(!d.call(Qe,t))continue;const e=r[t];l.includes(t)&&h[t]!==e&&(i.get(a).set(this.#Y(t),!0),c[t]=e)}const u={...h,...c};n.set(a,new Map(Object.entries(u))),o.push({key:a,options:u})}#Y(t){return/^statusbar|^charCounter|^wordCounter/.test(t)?"statusbar-changed":t}#G(t,e,s){for(let i,n=0,o=t.length;n<o;n++)i=t[n],("fixed"===ts[i]||"fixed"===Qe[i]||e&&e[i])&&(console.warn(`[SUNEDITOR.warn.resetOptions] The "[${s+i}]" option cannot be changed after the editor is created.`),t.splice(n--,1),o--)}#V(t){let e=t.value;return{get:t=>e.get(t),set:(t,s)=>e.set(t,s),has:t=>e.has(t),getAll:()=>Object.fromEntries(e.entries()),setMany(t){t.forEach(((t,s)=>e.set(s,t)))},reset(s){e=t.value=s},size:()=>e.size,clear(){e.clear()},entries:()=>e.entries(),keys:()=>e.keys(),values:()=>e.values(),forEach(t){e.forEach(t)}}}#j(t){let e=t.value;return{get:t=>e.get(t),set:(t,s)=>e.set(t,s),has:t=>e.has(t),getAll:()=>Object.fromEntries(e.entries()),setMany(t){t.forEach(((t,s)=>e.set(s,t)))},reset(s){e=t.value=s},size:()=>e.size,clear(){e.clear()},entries:()=>e.entries(),keys:()=>e.keys(),values:()=>e.values(),forEach(t){e.forEach(t)}}}_destroy(){this.#q=null,this.#W.clear(),this.#U.clear()}}const Es=class{#X;constructor(t){this.#X=t}isNode(t){return t&&"number"==typeof t.nodeType||t instanceof this.#Z().Node}isElement(t){return t&&1===t.nodeType||t instanceof this.#Z().Element}isRange(t){return t&&"Range"===t.constructor?.name||t instanceof this.#Z().Range}isSelection(t){return t&&"Selection"===t.constructor?.name||t instanceof this.#Z().Selection}#Z(){return this.#X.get("_ww")}},{_w:Ts,_d:Ms,NO_EVENT:Ns}=Oe;const Bs=class{#J;#X;#Q;#tt=null;#et=null;#st=[];#it=[];constructor(t,e,s){this.#J=s,this.#X=t.frameContext,this.#Q=e.frameOptions,this.events=e.options.get("events")||{},this.triggerEvent=async(t,e)=>{if(Pe.check.isNonEditable(e?.frameContext?.get("wysiwyg")))return!1;const s=this.events[t];if("function"==typeof s)try{return await s({$:this.#J,...e})}catch(e){return console.error(`[SUNEDITOR.triggerEvent.${t}]`,e),!1}return Ns}}_bindOrchestrator(t){this.#tt=t}applyTagEffect(t){return this.#tt?.applyTagEffect(t)}addEvent(t,e,s,i){if(!t)return null;if((t===Ts||t===Ms||"number"!=typeof t.length||t.nodeType||!Array.isArray(t)&&t.length<1)&&(t=[t]),0===t.length)return null;const n=t.length;for(let o=0;o<n;o++)t[o].addEventListener(e,s,i),this.#st.push({target:t[o],type:e,listener:s,useCapture:i});return{target:t,type:e,listener:s,useCapture:i}}removeEvent(t){if(!t)return;let e=t.target;const s=t.type,i=t.listener,n=t.useCapture;if(e&&((e===Ts||e===Ms||"number"!=typeof e.length||e.nodeType||!Array.isArray(e)&&e.length<1)&&(e=[e]),0!==e.length)){for(let t=0,o=e.length;t<o;t++)e[t].removeEventListener(s,i,n);return null}}addGlobalEvent(t,e,s){this.#Q.get("iframe")&&this.#X.get("_ww").addEventListener(t,e,s),Ts.addEventListener(t,e,s);const i={type:t,listener:e,useCapture:s};return this.#it?.push(i),i}removeGlobalEvent(t,e,s){if(!t)return;"object"==typeof t&&(e=t.listener,s=t.useCapture,t=t.type),this.#Q.get("iframe")&&this.#X.get("_ww").removeEventListener(t,e,s),Ts.removeEventListener(t,e,s);const i=this.#it?.findIndex((i=>i.type===t&&i.listener===e&&i.useCapture===s))??-1;return i>-1&&this.#it.splice(i,1),null}_injectActiveEvent(t){Pe.utils.addClass(t,"__se__active"),this.#et=this.addGlobalEvent("mouseup",(()=>{Pe.utils.removeClass(t,"__se__active"),this.#et=this.removeGlobalEvent(this.#et)}))}_init(){for(let t,e=0,s=this.#st.length;e<s;e++)t=this.#st[e],t.target.removeEventListener(t.type,t.listener,t.useCapture);this.#st=null,this.#et&&=this.removeGlobalEvent(this.#et);const t=this.#Q.get("iframe")?this.#X.get("_ww"):null;for(let e,s=0,i=this.#it.length;s<i;s++)e=this.#it[s],t?.removeEventListener(e.type,e.listener,e.useCapture),Ts.removeEventListener(e.type,e.listener,e.useCapture);this.#it=null}};const Is=class{#J;#t;#nt;#ot;#e;#X;#rt;#Q;constructor(t){this.#J=t.$,this.#t=t.store,this.#nt=this.#J.contextProvider.shadowRoot,this.#ot=this.#J.contextProvider.carrierWrapper,this.#e=this.#J.context,this.#X=this.#J.frameContext,this.#rt=this.#J.options,this.#Q=this.#J.frameOptions}get(t){const e=this.#X.get("wysiwygFrame"),s=/iframe/i.test(e?.nodeName),i=this.getLocal(t);return{left:i.left+(s?e.parentElement.offsetLeft:0),top:i.top+(s?e.parentElement.offsetTop:0)}}getLocal(t){const e=t;let s=0,i=0,n=0,o=0,r=0,l=3===e.nodeType?e.parentElement:e;const a=e.offsetWidth,h=wt(e,tt.bind(this)),c=l;for(;l&&!ct(l,"se-wrapper")&&l!==h;)s+=l.offsetLeft-(c!==l?l.scrollLeft:0),i+=l.offsetTop+(c!==l?l.scrollTop:0),l=l.offsetParent;const d=this.#X.get("wysiwygFrame");this.#X.get("wysiwyg").contains(e)&&(n=d.offsetLeft,o=d.offsetTop,r=d.parentElement.offsetWidth-(d.offsetLeft+d.offsetWidth));const u=this.#X.get("eventWysiwyg");return s+=n-(h?h.scrollLeft:0),i+=o-(h?h.scrollTop:0),{left:s,top:i,right:l?.offsetWidth?l.offsetWidth-(s-n+a)+r:0,scrollX:u.scrollLeft||u.scrollX||0,scrollY:u.scrollTop||u.scrollY||0,scrollH:this.#X.get("wysiwyg").scrollHeight||0}}getGlobal(t){const e=this.#X.get("topArea"),s=this.#X.get("wysiwygFrame");if(t||=e,!G(t))return{top:0,left:0,fixedTop:0,fixedLeft:0,width:0,height:0};const i=t,n=i.getBoundingClientRect();let r=n.top,l=n.left;if(/^iframe$/i.test(s.nodeName)&&s.contentDocument.contains(i)){const t=s.getBoundingClientRect();r+=t.top,l+=t.left}return{top:r+o.scrollY,left:l+o.scrollX,fixedTop:r,fixedLeft:l,width:i.offsetWidth,height:i.offsetHeight}}getGlobalScroll(t){const e=this.#X.get("topArea");let s=!1,i=!1;t||=e,t===e&&(s=!0),!s&&G(t)&&(i="absolute"===o.getComputedStyle(t).position);let n=0,r=0,l=0,a=0,h=0,c=0,d=0,u=0,p=null,g=null,m=null,f=null,v=t;for(;v;)n+=v.scrollTop,r+=v.scrollLeft,l+=v.scrollHeight,a+=v.scrollWidth,v.scrollTop>0&&(c+=v.offsetTop),v.scrollHeight>=v.clientHeight&&(d=/^html$/i.test(v.nodeName)?d||v.clientHeight:v.clientHeight+(m?-m.clientTop:0),p=m||p||v,m=v),v.scrollLeft>0&&(h+=v.offsetLeft),v.scrollWidth>=v.clientWidth&&(u=/^html$/i.test(v.nodeName)?u||v.clientWidth:v.clientWidth+(f?-f.clientLeft:0),g=f||g||v,f=v),v=v.parentElement;if(!i&&!s&&/^iframe$/i.test(this.#X.get("wysiwygFrame").nodeName))for(v=this.#X.get("wrapper"),p=g=e;v;)n+=v.scrollTop,r+=v.scrollLeft,l+=v.scrollHeight,a+=v.scrollWidth,v.scrollTop>0&&(c+=v.offsetTop),v.scrollHeight>=v.clientHeight&&(d=/^html$/i.test(v.nodeName)?d||v.clientHeight:v.clientHeight+(m?-m.clientTop:0),m=v),v.scrollLeft>0&&(h+=v.offsetLeft),v.scrollWidth>=v.clientWidth&&(u=/^html$/i.test(v.nodeName)?u||v.clientWidth:v.clientWidth+(f?-f.clientLeft:0),f=v),v=v.parentElement;for(v=this.#nt?.host,v&&(p=g=e);v;)n+=v.scrollTop,r+=v.scrollLeft,l+=v.scrollHeight,a+=v.scrollWidth,v.scrollTop>0&&(c+=v.offsetTop),v.scrollHeight>=v.clientHeight&&(d=/^html$/i.test(v.nodeName)?d||v.clientHeight:v.clientHeight+(m?-m.clientTop:0),m=v),v.scrollLeft>0&&(h+=v.offsetLeft),v.scrollWidth>=v.clientWidth&&(u=/^html$/i.test(v.nodeName)?u||v.clientWidth:v.clientWidth+(f?-f.clientLeft:0),f=v),v=v.parentElement;const b=e.contains(p),y=e.contains(g);p=b?e:p,g=y?e:g;const w=p?p.getBoundingClientRect().top+(!p.parentElement||/^html$/i.test(p.parentElement.nodeName)?o.scrollY:0):0,C=g?g.getBoundingClientRect().left+(!g.parentElement||/^html$/i.test(g.parentElement.nodeName)?o.scrollX:0):0;d=b?e.clientHeight:d,u=y?e.clientWidth:u;const _=pt(this.#X.get("_wd"));return{top:n,left:r,ts:w,ls:C,width:a,height:l,x:h,y:c,ohOffsetEl:i?window:p,owOffsetEl:i?window:g,oh:i?_.h:d,ow:i?_.w:u,heightEditorRefer:b,widthEditorRefer:y}}getWWScroll(){const t=this.#X.get("eventWysiwyg"),e=t.scrollTop||t.scrollY||0,s=t.scrollHeight||t.document?.documentElement.scrollHeight||0;return{top:e,left:t.scrollLeft||t.scrollX||0,width:t.scrollWidth||t.document?.documentElement.scrollWidth||0,height:s,bottom:e+s}}setRelPosition(t,e,s,i,{preferUp:n}={}){const l=/^fixed$/i.test(o.getComputedStyle(i).position),a=this.getGlobal(s);if(l)t.style.position="fixed",t.style.top=n?a.fixedTop-t.offsetHeight+"px":`${a.fixedTop+a.height}px`;else{t.style.position="";const l=i.contains(t)?this.getGlobal(e).top:0,h=t.offsetHeight,c=o.scrollY,d=a.top;if(n){const e=l-c+d;if(e<h){const i=pt(r).h-(l-c+d+s.offsetHeight);i>=h?t.style.top=`${d+s.offsetHeight}px`:i>e?(t.style.height=`${i}px`,t.style.top=`${d+s.offsetHeight}px`):(t.style.height=`${e}px`,t.style.top=-1*(e-d+3)+"px")}else t.style.top=d-h+"px"}else{const e=pt(r).h-(l-c+d+s.offsetHeight);if(e<h){let i=-1*(h-d+3);const n=l-c+i,o=h+(n<0?n:0);o>e?(t.style.height=`${o}px`,i=-1*(o-d+3)):(t.style.height=`${e}px`,i=d+s.offsetHeight),t.style.top=`${i}px`}else t.style.top=`${d+s.offsetHeight}px`}}const h=t.offsetWidth,c=a.left,d=this.getGlobal(i).left;if(this.#rt.get("_rtl")){const e=s.getBoundingClientRect(),n=o.innerWidth;let r=n-e.right;if(h>0){const t=i.getBoundingClientRect();n-r-h<t.left&&(r=n-t.left-h)}t.style.left="auto",t.style.right=`${Math.max(0,r)}px`}else{const e=i.offsetWidth+d,s=e<=h?0:e-(c+h);t.style.right="",t.style.left=s<0?`${c+s}px`:`${c}px`}}setAbsPosition(t,e,s){const i={left:0,right:0,top:0,...s.addOffset},n=s.position||"bottom",l=s.inst,a=!this.#rt.get("_rtl");a||(i.left*=-1);const h=this.#Q.get("iframe"),c=this.#X.get("wrapper").contains(e)||s.isWWTarget||!!h&&this.#X.get("wysiwyg").contains(e),d=Boolean(wt(e,".se-toolbar")),u=1===e.nodeType,p=c&&!u,g=u&&/inline/.test(o.getComputedStyle(e).display),m=pt(r),f=p?this.getWWScroll():this.#lt(),v=!c||!h&&u?e.getBoundingClientRect():this.#J.selection.getRects(e,"start").rects,b=this.getGlobal(e),y=ct(t.firstElementChild,"se-arrow")?t.firstElementChild:null,w=s.sibling?.offsetHeight||0,C=y?y.offsetHeight:0,_=t.offsetHeight,k=e.offsetHeight,x=v.top,$=m.h-v.bottom,S=this.getGlobal(this.#X.get("topArea")).top,E=o.scrollY,T=this.#e.get("toolbar_main").offsetHeight,M=this.#rt.get("toolbar_container"),N=this.#t.mode.isBalloon||this.#t.mode.isInline||M,B=M&&S-E-T>0||!this.#J.toolbar.isSticky&&N?0:T+(this.#J.toolbar.isSticky?this.#rt.get("_toolbar_sticky"):0),I=this.#X.get("statusbar")?.offsetHeight||0,{rmt:L,rmb:A,bMargin:O,rt:R}=this.#at(x,$,B,m,v,p,d);if(c&&(A-I+k<=0||L+R+k-(this.#J.toolbar.isSticky&&g?B:0)<=0)||L+k<0)return;const z=this.#X.get("topArea").getBoundingClientRect(),P=this.#t.mode.isBottom?z.bottom>=o.innerHeight-T:z.top<=T,D=this.#J.toolbar.isSticky&&"none"!==this.#e.get("toolbar_main").style.display&&(!N||P);let F=i.top,H=0,q="";"bottom"===n?(q="up",F+=v.bottom+C+E,H=A-(_+C),H-w<0&&(q="down",F-=k+_+2*C,H=L-(_+C),H-w<0&&(q="",F-=H-w-Math.max(1,H+_+C)))):(q="down",F+=v.top-_-C+E,H=(D&&!this.#t.mode.isBottom?v.top-B:L)-_-C,H-w<0&&(q="up",F+=k+_+2*C,H=(A>0?O:A)-(_+C)-I,H-w<0&&(q="",F+=H-2))),this.#ht(y,q),t.style.top=`${F}px`;const W=(1===t.nodeType?De.get(o.getComputedStyle(t).borderRadius):0)||0,U=b.width,V=t.offsetWidth,j=y?y.offsetWidth:0,G=v.left,K=m.w-v.right;if(c&&(G+U<=0||K+U<=0))return;y&&(y.style.left="",y.style.right="");let Y=i.left||(i.right?a?i.right-t.offsetWidth:t.offsetWidth-i.right:0),X=0,Z=0,J=0;return a?(Y+=v.left+o.scrollX-(G<0?G:0),X=U+G,X<j&&(J=j/2-1+(W<=2?0:W-2),Z=J),X=U+K-V,X<0&&(Y+=X,J=V-1-(j/2+(W<=2?0:W-2)),Z=-(X-j/2),Z=Z>J?J:Z),y&&Z>0&&(y.style.left=Z+"px")):(Y+=v.right-V+o.scrollX+(K<0?K:0),X=U+K,X<j&&(J=j/2-1+(W<=2?0:W-2),Z=J),X=U+G-V,X<0&&(Y-=X,J=j/2-1+(W<=2?0:W-2),Z=-(X-j/2),Z=Z<J?J:Z>V-J?V-J:Z),y&&Z>0&&(y.style.right=Z+"px")),t.style.left=`${Y}px`,l.__offset={left:t.offsetLeft+f.left,top:t.offsetTop+f.top,addOffset:i},{position:"up"===q?"bottom":"top"}}setRangePosition(t,e,{position:s,addTop:i}={}){t.style.top="-10000px",t.style.visibility="hidden",t.style.display="block";let n="top"===s;e||=this.#J.selection.getRange();const l=this.#J.selection.getRects(e,n?"start":"end");if(n="start"===l.position,l.rects.noText){let t=e.startContainer;1===t.nodeType&&(t=t.childNodes[e.startOffset]||t);const s=t.parentNode;if(s){const e=rt(E);s.insertBefore(e,t);const i=r.createRange();i.setStart(e,1),i.setEnd(e,1);const n=i.getClientRects()[0];n&&(l.rects=n,l.scrollLeft=o.scrollX,l.scrollTop=o.scrollY),s.removeChild(e)}}const a=this.#X.get("isFullScreen"),h=this.#X.get("topArea"),c=this.#ot.contains(t),d=l.rects,u=a?0:l.scrollLeft,p=a?0:l.scrollTop,g=c?pt(r).w:h.offsetWidth,m=this.getGlobal(h),f=c?0:m.left,v=t.offsetWidth,b=t.offsetHeight;this.#ct(n,d,t,f,g,u,p,i),this.getGlobal(t).top-m.top<0&&(n=!n,this.#ct(n,d,t,f,g,u,p,i)),v===t.offsetWidth&&b===t.offsetHeight||this.#ct(n,d,t,f,g,u,p,i);const y=!this.#ot.contains(t),w=pt(r),C=d.height,_=d.top,k=w.h-d.bottom,x=this.#J.toolbar.isSticky||!this.#t.mode.isBalloon&&!this.#t.mode.isInline?this.#e.get("toolbar_main").offsetHeight:0,{rmt:$,rmb:S,rt:T}=this.#at(_,k,x,w,d,y,!1);if(!(S+C<=0||$+T+C<=0))return t.style.visibility="",!0}#ct(t,e,s,i,n,o,l,a=0){const h=s.querySelector(".se-arrow "),c=Math.round(h.offsetWidth/2),d=s.offsetWidth,u=e.noText&&!t?0:s.offsetHeight,p=(t?e.left:e.right)-i-d/2+o,g=p+d-n;let m=(t?e.top-u-c:e.bottom+c)-(e.noText?0:a)+l;const f=p<0?1:g<0?p:p-g-1-1;let v=!1;const b=m+(t?this.getGlobal(this.#X.get("topArea")).top:s.offsetHeight-this.#X.get("wysiwyg").offsetHeight);!t&&b>0&&this.#dt()<b?(t=!0,v=!0):t&&r.documentElement.offsetTop>b&&(t=!1,v=!0),v&&(m=(t?e.top-u-c:e.bottom+c)-(e.noText?0:a)+l),s.style.left=Math.floor(f)+"px",s.style.top=Math.floor(m)+"px",t?(ut(h,"se-arrow-up"),dt(h,"se-arrow-down")):(ut(h,"se-arrow-down"),dt(h,"se-arrow-up"));const y=Math.floor(d/2+(p-f));h.style.left=(y+c>s.offsetWidth?s.offsetWidth-c:y<c?c:y)+"px"}#dt(){const t=this.#X.get("topArea");return r.documentElement.scrollHeight-(this.getGlobal(t).top+t.offsetHeight)}#at(t,e,s,i,n,r,l){const a=this.#J.selection.getRects(this.#X.get("wysiwyg"),"start").rects;let h=0,c=0,d=0,u=0,p=0;const g=this.#Q.get("iframe");u=n.top,p=i.h-n.bottom;const m=this.getGlobal(),f=this.#t.mode.isBottom;if(r){d=l||this.#J.toolbar.isSticky||this.#rt.get("toolbar_container")?0:s;const t=g?0:m.top-o.scrollY+d,e=g?0:this.#t.get("currentViewportHeight")-(m.top+m.height-o.scrollY);let i=t,r=e;f?(s>e?r=this.#J.toolbar.isSticky?s:e+s:this.#rt.get("toolbar_container")&&!this.#J.toolbar.isSticky?s=0:r=e+s,h=n.top-(a.top-t),c=a.bottom-(n.bottom-r)+s,c=c>0?c:c-s):(s>t?i=this.#J.toolbar.isSticky?s:t+s:this.#rt.get("toolbar_container")&&!this.#J.toolbar.isSticky?s=0:i=t+s,h=n.top-(a.top-i)+s,c=a.bottom-(n.bottom-e),h=h>0?h:h-s)}else{const t=m.fixedTop>0?m.fixedTop:0,e=o.innerHeight-(m.fixedTop+m.height);d=l||!this.#J.toolbar.isSticky&&this.#J.toolbar.isBalloonMode?0:s,f?(h=u-(l?0:t),c=p-(e>0?e:0)-d):(h=u-(l?0:t)-d,c=p-(e>0?e:0))}return{rmt:h,rmb:c,rt:d,tMargin:u,bMargin:p}}#ht(t,e){"up"===e?(t&&(t.style.visibility=""),dt(t,"se-arrow-up"),ut(t,"se-arrow-down")):"down"===e?(t&&(t.style.visibility=""),dt(t,"se-arrow-down"),ut(t,"se-arrow-up")):t&&(t.style.visibility="hidden")}#lt(){const t=pt(r);return{top:o.scrollY,left:o.scrollX,width:t.w,height:t.h,bottom:o.scrollY+t.h,rects:{left:0,top:0,right:o.innerWidth,bottom:this.#t.get("currentViewportHeight")||o.innerHeight,noText:!0}}}},{_w:Ls}=Oe;const As=class{#H;#J;#t;#nt;#ut;#e;#X;#rt;#Q;#pt=0;#gt=!1;constructor(t){this.#H=t,this.#J=t.$,this.#t=t.store,this.#nt=this.#J.contextProvider.shadowRoot,this.#ut=this.#J.instanceCheck,this.#e=this.#J.context,this.#X=this.#J.frameContext,this.#rt=this.#J.options,this.#Q=this.#J.frameOptions,this.range=null,this.selectionNode=null,this.__iframeFocus=!1}get(){let t=null;return t="function"==typeof this.#nt?.getSelection?this.#nt.getSelection():this.#X.get("_ww").getSelection(),t?(this.#t.get("_range")||this.#X.get("wysiwyg").contains(t.focusNode)||(t.removeAllRanges(),t.addRange(this.#mt())),t):null}isRange(t){return this.#ut.isRange(t)}getRange(){const t=this.#t.get("_range")||this.#mt(),e=this.get();if(t.collapsed===e.isCollapsed||!this.#X.get("wysiwyg").contains(e.focusNode)){if(this.#J.component.is(t.startContainer)){const e=this.#J.component.get(t.startContainer),s=e?.container;return s?this.setRange(s,0,s,1):t}return t}if(e.rangeCount>0){const t=e.getRangeAt(0);return this.#t.set("_range",t),t}{const t=e.anchorNode,s=e.focusNode,i=e.anchorOffset,n=e.focusOffset,o=Pe.query.compareElements(t,s),r=o.ancestor&&(0===o.result?i<=n:o.result>1);return this.setRange(r?t:s,r?i:n,r?s:t,r?n:i)}}setRange(t,e,s,i){let n,o,r,l;if(this.isRange(t)){const e=t;n=e.startContainer,o=e.startOffset,r=e.endContainer,l=e.endOffset}else n=t,o=e,r=s,l=i;if(!n||!r)return;(Pe.check.isBreak(n)||3===n.nodeType)&&o>n.textContent.length&&(o=n.textContent.length),(Pe.check.isBreak(r)||3===r.nodeType)&&l>r.textContent.length&&(l=r.textContent.length),this.#J.format.isLine(n)&&(n=n.childNodes[o>0?n.childNodes.length-1:0]||n,o=o>0?1!==n.nodeType||Pe.check.isBreak(n)?n.textContent?n.textContent.length:0:1:0),this.#J.format.isLine(r)&&(r=r.childNodes[l>0?r.childNodes.length-1:0]||r,l=l>0?1!==r.nodeType||Pe.check.isBreak(r)?r.textContent?r.textContent.length:0:1:0);const a=this.#X.get("_wd").createRange();try{o=Math.min(o,n.textContent?.length||0),l=l>0&&0===(r.textContent?.length||0)&&1===r.nodeType?1:Math.min(Math.max(l,0),r.textContent?.length||0),a.setStart(n,o),a.setEnd(r,l),this.#t.set("hasFocus",!0)}catch(t){return console.warn("[SUNEDITOR.selection.focus.warn]",t.message),void this.#J.focusManager.nativeFocus()}const h=this.get();return h.removeAllRanges&&h.removeAllRanges(),h.addRange(a),this.#t.set("_range",a),this.#ft(a,this.get()),this.#Q.get("iframe")&&this.__focus(),a}removeRange(){this.#t.set("_range",null),this.#t.set("_lastSelectionNode",null),this.selectionNode=null,this.#t.get("hasFocus")&&this.get().removeAllRanges(),this.#H._eventOrchestrator.selectionState.reset()}getNearRange(t){const e=t.nextSibling,s=t.previousSibling;return e?{container:e,offset:0}:s?{container:s,offset:1}:null}getRangeAndAddLine(t,e){if(this.#vt(t)){const s=e?.parentElement||this.#X.get("wysiwyg"),i=Pe.utils.createElement(this.#rt.get("defaultLine"),null,"<br>");s.insertBefore(i,e&&e!==s?e.previousElementSibling?e.nextElementSibling:e:s.firstElementChild),this.setRange(i.firstElementChild,0,i.firstElementChild,1),t=this.#t.get("_range")}return t}getNode(){if(this.#X.get("wysiwyg").contains(this.selectionNode)||this.init(),!this.selectionNode){const t=Pe.query.getEdgeChild(this.#X.get("wysiwyg").firstChild,(t=>0===t.childNodes.length||3===t.nodeType),!1);if(t)return this.selectionNode=t,t;this.init()}return this.selectionNode}getRects(t,e){const s=!!Pe.check.isElement(t)&&"absolute"===Ls.getComputedStyle(t).position;t=!t||Pe.check.isText(t)?this.getRange():t;let i="start"===e,n=Ls.scrollX,o=Ls.scrollY,r=t.getClientRects();if(r=r[i?0:r.length-1],!r){const t=this.getNode();if(this.#J.format.isLine(t)){const t=Pe.utils.createTextNode(Re.zeroWidthSpace);this.#J.html.insertNode(t,{afterNode:null,skipCharCount:!0}),this.setRange(t,1,t,1),this.init(),r=this.getRange().getClientRects(),r=r[i?0:r.length-1]}if(!r){const e=this.#J.offset.get(t);r={left:e.left,top:e.top,right:e.left+t.offsetWidth,bottom:e.top+t.offsetHeight,noText:!0},n=0,o=0}i=!0}const l=/^iframe$/i.test(this.#X.get("wysiwygFrame").nodeName)?this.#X.get("wysiwygFrame").getClientRects()[0]:null;return!s&&l&&(r={left:r.left+l.left,top:r.top+l.top,right:r.right+l.right-l.width,bottom:r.bottom+l.bottom-l.height}),{rects:r,position:i?"start":"end",scrollLeft:n,scrollTop:o}}getDragEventLocationRange(t){const e=this.#X.get("_wd");let s,i,n,o,r;return e.caretPositionFromPoint?(s=e.caretPositionFromPoint(t.clientX,t.clientY),i=s.offsetNode,n=s.offset,o=s.offsetNode,r=s.offset):e.caretRangeFromPoint&&(s=e.caretRangeFromPoint(t.clientX,t.clientY),i=s.startContainer,n=s.startOffset,o=s.endContainer,r=s.endOffset),{sc:i,so:n,ec:o,eo:r}}scrollTo(t,e){const s=e?.noFocus;if(this.#ut.isSelection(t))t=t.getRangeAt(0);else if(this.#ut.isNode(t))if(s){const e=this.#X.get("_wd").createRange();e.selectNodeContents(t),t=e}else t=this.setRange(t,1,t,1);else void 0===t?.startContainer&&console.warn('[SUNEDITOR.html.scrollTo.warn] "selectionRange" must be Selection or Range or Node object.',t);const i=Pe.query.getParentElement(t?.startContainer,(t=>1===t.nodeType));if(!i)return;delete(e={behavior:"smooth",block:"nearest",inline:"nearest",...e}).noFocus;const n=this.#X.get("_ww"),o=this.#X.get("wysiwygFrame"),r=this.#Q.get("iframe"),l=!this.#t.get("isScrollable")(this.#X),a=this.#t.get("currentViewportHeight"),h=l?Ls.scrollY:r?n.scrollY:o.scrollTop,c=this.#t.mode.isBottom,d=this.#e.get("toolbar_main").offsetHeight,u=this.#J.toolbar.isSticky?d:0,p=this.#J.toolbar.isSticky?u+this.#rt.get("_toolbar_sticky"):u,g=this.#X.get("statusbar")?.offsetHeight||0;if(this.#gt){const s=this.#J.format.isBrLine(i)?t?.getBoundingClientRect?.():null;if(s?.height>0?this.#bt(s,e.behavior):i?.scrollIntoView(e),"auto"===e?.behavior)if(p&&!c){const e=t?.getBoundingClientRect?.();e?.height>0&&e.top>=0&&e.top<p&&Ls.scrollBy(0,-(p-e.top))}else h!==Ls.scrollY&&(p?h<Ls.scrollY&&Ls.scrollBy(0,p):l&&Ls.scrollBy(0,g));return}const m=this.#pt,f=l?a-(c?p:0):o.offsetHeight,v=t?.getBoundingClientRect?.(),b=(v?.height>0?v.height:i.offsetHeight)||0,y=e?.behavior,w=c?0:p;if(l)if(r){const e=this.getRects(t,"end").rects,s=e.top+b-w,i=f-m-(e.top+b);if(s>=0&&i>=0)return;const n=h-(s<0?-(s-m):i),o=w>0&&s<0;Ls.scrollTo({top:o?n-w:n,behavior:y})}else{const t=v?.height>0?v.top+h:this.#J.offset.getGlobal(i).top,e=f+h-t-b,s=w>0?t-h>=w:f>e+m;if(e-m>0&&s)return;const n=e<=m?h-e+m+g:h-e+(f-b-m),o=w>0&&!s;Ls.scrollTo({top:o?n-w:n,behavior:y})}else{const t=v?.height>0?v.top:i.getBoundingClientRect().top,e=r?t:t-o.getBoundingClientRect().top,s=e>=(c?0:u)&&e+m<=f;let l=h+(c?e-m>0?e+m-f+u:e-b:e-m>0?e+m-f:e-(u+b));const p=Ls.scrollY,w=this.#J.offset.getGlobal(),C=c?0:d,_=c?d:0,k=p-w.top+C,x=w.top+w.height-(p+a)+_;if(k>0){const t=(s?e:e+h-l)-b-m-k;t<0&&(l+=C,Ls.scrollTo({top:p+t,behavior:"smooth"}))}if(x>0){const t=(s?e:e+h-l)+b+m-(w.height-x);t>0&&(l+=c?_:g,Ls.scrollTo({top:p+t,behavior:"smooth"}))}s||(r?n:o).scrollTo({top:l,behavior:y})}}#bt(t,e){let{top:s,bottom:i}=t;const n=[...this.#H._eventOrchestrator.scrollparents||[],Ls];for(const t of n){const n=t===Ls,o=n?0:t.getBoundingClientRect().top,r=n?this.#t.get("currentViewportHeight"):t.getBoundingClientRect().bottom;let l=0;s<o?l=s-o:i>r&&(l=i-r),0!==l&&(t.scrollBy({top:l,behavior:e}),s-=l,i-=l)}}resetRangeToTextNode(){let t=this.getRange();if(this.#vt(t)){if(!Pe.check.isWysiwygFrame(t.startContainer)||!Pe.check.isWysiwygFrame(t.endContainer))return!1;const e=t.commonAncestorContainer,s=e.children[t.startOffset],i=e.children[t.endOffset];if(!(t=this.setRange(s,0,i,s===i?0:1)))return!1}const e=t,s=e.collapsed;let i,n,o,r=e.startContainer,l=e.startOffset,a=e.endContainer,h=e.endOffset;if(this.#J.format.isLine(r))for(r.childNodes[l]?(r=r.childNodes[l]||r,l=0):(r=r.lastChild||r,l=r.textContent.length);1===r?.nodeType&&r.firstChild;)r=r.firstChild||r,l=0;if(this.#J.format.isLine(a)){for(a=a.childNodes[h]||a.lastChild||a;1===a?.nodeType&&a.lastChild;)a=a.lastChild;s?h=0:h>0&&(h=a.textContent.length)}if(i=Pe.check.isWysiwygFrame(r)?this.#X.get("wysiwyg").firstChild:r,n=l,Pe.check.isBreak(i)||1===i.nodeType&&i.childNodes.length>0){const t=Pe.check.isBreak(i);if(!t){const t=i;for(;i&&!Pe.check.isBreak(i)&&1===i.nodeType&&(o=i.childNodes,0!==o.length);)i=o[n>0?n-1:n]||!/FIGURE/i.test(o[0].nodeName)?o[0]:i.previousElementSibling||i.previousSibling||r,n=n>0?i.textContent.length:n;let e=this.#J.format.getLine(i,null);e===this.#J.format.getBlock(e,null)&&(i||=t,e=Pe.utils.createElement(Pe.query.getParentElement(i,Pe.check.isTableCell)?"DIV":this.#rt.get("defaultLine")),i.parentNode.insertBefore(e,i),i!==t&&e.appendChild(i))}if(Pe.check.isBreak(i)||this.#J.component.is(i)){const e=Pe.utils.createTextNode(Re.zeroWidthSpace);i.parentNode.insertBefore(e,i),i=e,t&&r===a&&(a=i,h=1)}}if(r=i,l=n,i=Pe.check.isWysiwygFrame(a)?this.#X.get("wysiwyg").lastChild:a,n=h,Pe.check.isBreak(i)||1===i.nodeType&&i.childNodes.length>0){const t=Pe.check.isBreak(i);if(!t){for(;i&&!Pe.check.isBreak(i)&&1===i.nodeType&&(o=i.childNodes,0!==o.length);)i=o[n>0?n-1:n]||!/FIGURE/i.test(o[0].nodeName)?o[0]:i.previousElementSibling||i.previousSibling||r,n=n>0?i.textContent.length:n;let t=this.#J.format.getLine(i,null);t===this.#J.format.getBlock(t,null)&&(t=Pe.utils.createElement(Pe.check.isTableCell(t)?"DIV":this.#rt.get("defaultLine")),i.parentNode.insertBefore(t,i),t.appendChild(i))}if(Pe.check.isBreak(i)){const e=Pe.utils.createTextNode(Re.zeroWidthSpace);i.parentNode.insertBefore(e,i),i=e,n=1,t&&!i.previousSibling&&Pe.utils.removeItem(a)}}return a=i,h=n,this.setRange(r,l,a,h),!0}init(){const t=this.#X.get("_wd").activeElement;if(Pe.check.isInputElement(t))return this.selectionNode=t,t;const e=this.get();if(!e)return null;let s=null;s=e.rangeCount>0?e.getRangeAt(0):this.#mt(),this.#ft(s,e)}#ft(t,e){let s=null;this.#t.set("_range",t),s=t.collapsed?Pe.check.isWysiwygFrame(t.commonAncestorContainer)&&t.commonAncestorContainer.children[t.startOffset]||t.commonAncestorContainer:e.anchorNode,this.selectionNode=s}#vt(t){const e=t.commonAncestorContainer;return Pe.check.isWysiwygFrame(t.startContainer)&&Pe.check.isWysiwygFrame(t.endContainer)||/FIGURE/i.test(e.nodeName)||this.#J.pluginManager.fileInfo.regExp.test(e.nodeName)&&(!this.#J.pluginManager.fileInfo.tagAttrs[e.nodeName]||this.#J.pluginManager.fileInfo.tagAttrs[e.nodeName]?.every((t=>e.hasAttribute(t))))||this.#J.component.is(e)}#mt(){const t=this.#X.get("wysiwyg"),e=this.#X.get("_wd").createRange();let s=t.firstElementChild,i=null;return s?(i=s.firstChild,i||(i=Pe.utils.createElement("BR"),s.appendChild(i))):(i=Pe.utils.createElement("BR"),s=Pe.utils.createElement(this.#rt.get("defaultLine"),null,i),t.appendChild(s)),e.setStart(i,0),e.setEnd(i,0),e}__focus(){try{this.__iframeFocus=!0;const t=Pe.query.getParentElement(this.getNode(),"figcaption");t?t.focus():this.#X.get("wysiwyg").focus()}finally{Ls.setTimeout((()=>this.__iframeFocus=!1),0)}}__init(){this.#gt=this.#H._eventOrchestrator.scrollparents?.length>0,this.#pt=this.#X?.get("wysiwyg")?(De.get(Ls.getComputedStyle(this.#X.get("wysiwyg")).scrollMargin,0)||40)+De.get(Ls.getComputedStyle(this.#X.get("wrapper")).paddingBottom,0):40}};function Os(t,e,s){const i=[];for(let n,o,r=0,l=t.length;r<l;r++)n=t[r],Pe.check.isListCell(n)?(e<0||n.previousElementSibling)&&i.push(n):(o=/\d+/.test(n.style[s])?De.get(n.style[s],0):0,o+=e,Pe.utils.setStyle(n,s,o<=0?"":o+"px"));return i}const Rs=class{#J;#t;#rt;#X;#yt;#wt;#Ct;#_t;#kt;#xt;#$t=null;constructor(t){this.#J=t.$,this.#t=t.store,this.#rt=this.#J.options,this.#X=this.#J.frameContext,this.#yt=this.#rt.get("formatLine").reg,this.#wt=this.#rt.get("formatBrLine").reg,this.#Ct=this.#rt.get("formatBlock").reg,this.#_t=this.#rt.get("formatClosureBlock").reg,this.#kt=this.#rt.get("formatClosureBrLine").reg,this.#xt=new RegExp("^("+this.#rt.get("textStyleTags")+")$","i"),this.__resetBrLineBreak(this.#rt.get("defaultLineBreakFormat"))}setLine(t){if(!this.isLine(t))throw new Error('[SUNEDITOR.format.setLine.fail] The "element" must satisfy "format.isLine()".');const e=this.#St(),s=e.lines,i=t.className,n=t.nodeName;let o=e.firstNode,r=e.lastNode;for(let e,l,a=0,h=s.length;a<h;a++){if(e=s[a],(e.nodeName!==n||(e.className.match(/(\s|^)__se__format__[^\s]+/)||[""])[0].trim()!==i)&&!this.#J.component.is(e)){for(l=t.cloneNode(!1),Pe.utils.copyFormatAttributes(l,e);e.firstChild;)l.appendChild(e.firstChild);e.parentNode.replaceChild(l,e)}0===a&&(o=l||e),a===h-1&&(r=l||e),l=null}this.#J.selection.setRange(Pe.query.getNodeFromPath(e.firstPath,o),e.startOffset,Pe.query.getNodeFromPath(e.lastPath,r),e.endOffset),this.#J.history.push(!1),this.#X.has("documentType_use_header")&&this.#X.get("documentType").reHeader()}getLine(t,e){if(!t)return null;for(e||=()=>!0;t;){if(Pe.check.isWysiwygFrame(t))return null;if(this.isBlock(t)){if(this.isLine(t.firstElementChild))return t.firstElementChild;if(this.isLine(t))return t}if(this.isLine(t)&&e(t))return t;t=t.parentNode}return null}setBrLine(t){if(!this.isBrLine(t))throw new Error('[SUNEDITOR.format.setBrLine.fail] The "element" must satisfy "format.isBrLine()".');const e=this.#St().lines,s=e.length-1;let i=e[s].parentNode,n=t.cloneNode(!1);const o=n;for(let o,r,l,a,h,c,d=s,u=!0;d>=0;d--)if(o=e[d],o!==(e[d+1]?e[d+1].parentNode:null)){if(c=this.#J.component.is(o),r=c?"":o.innerHTML.replace(/(?!>)\s+(?=<)|\n/g," "),l=Pe.query.getParentElement(o,(t=>t.parentNode===i)),(i!==o.parentNode||c)&&(this.isLine(i)?(i.parentNode.insertBefore(n,i.nextSibling),i=i.parentNode):(i.insertBefore(n,l?l.nextSibling:null),i=o.parentNode),a=n.nextSibling,a&&n.nodeName===a.nodeName&&Pe.check.isSameAttributes(n,a)&&(n.innerHTML+="<BR>"+a.innerHTML,Pe.utils.removeItem(a)),n=t.cloneNode(!1),u=!0),h=n.innerHTML,n.innerHTML=(u||!r||!h||/<br>$/i.test(r)?r:r+"<BR>")+h,0===d){i.insertBefore(n,o),a=o.nextSibling,a&&n.nodeName===a.nodeName&&Pe.check.isSameAttributes(n,a)&&(n.innerHTML+="<BR>"+a.innerHTML,Pe.utils.removeItem(a));const t=n.previousSibling;t&&n.nodeName===t.nodeName&&Pe.check.isSameAttributes(n,t)&&(t.innerHTML+="<BR>"+n.innerHTML,Pe.utils.removeItem(n))}c||Pe.utils.removeItem(o),r&&(u=!1)}this.#J.selection.setRange(o,0,o,0),this.#J.history.push(!1)}getBrLine(t,e){if(!t)return null;for(e||=()=>!0;t;){if(Pe.check.isWysiwygFrame(t))return null;if(this.isBrLine(t)&&e(t))return t;t=t.parentNode}return null}addLine(t,e){if(!t||!t.parentNode)return null;const s=this.getLine(this.#J.selection.getNode(),null);let i=null;if(this.isBrLine(t)||!this.isBrLine(s||t.parentNode)||this.#J.component.is(t)){const t=e?"string"==typeof e?e:e.nodeName:this.isNormalLine(s)?s.nodeName:this.#rt.get("defaultLine");i=Pe.utils.createElement(t,null,"<br>"),(e&&"string"!=typeof e||!e&&this.isLine(s))&&Pe.utils.copyTagAttributes(i,e||s,["id"])}else i=Pe.utils.createElement("BR");return Pe.check.isTableCell(t)?t.insertBefore(i,t.nextElementSibling):t.parentNode.insertBefore(i,t.nextElementSibling),i}addLineAfter(t){if(!t||!t.parentNode)return null;const e=t.nodeName,s=this.#rt.get("lineAttrReset");let i;return/^H[1-6]$/i.test(e)||this.#J.component.is(t)||this.isBrLine(t)?i=Pe.utils.createElement(this.#rt.get("defaultLine"),null,"<br>"):(i=Pe.utils.createElement(e,null,"<br>"),Pe.utils.copyTagAttributes(i,t,s)),Pe.check.isTableCell(t)?t.insertBefore(i,t.nextElementSibling):t.parentNode.insertBefore(i,t.nextElementSibling),i}getBlock(t,e){if(!t)return null;for(e||=()=>!0;t;){if(Pe.check.isWysiwygFrame(t))return null;if(this.isBlock(t)&&!/^(THEAD|TBODY|TR)$/i.test(t.nodeName)&&e(t))return t;t=t.parentNode}return null}applyBlock(t){this.#J.selection.getRangeAndAddLine(this.#J.selection.getRange(),null);const e=this.getLinesAndComponents(!1);if(!e||0===e.length)return;t:for(let t,s,i,n,o,r,l=0,a=e.length;l<a;l++)if(t=e[l],Pe.check.isListCell(t))if(s=t.lastElementChild,s&&Pe.check.isListCell(t.nextElementSibling)&&e.includes(t.nextElementSibling)&&(n=s.lastElementChild,e.includes(n))){let t=null;for(;t=n.lastElementChild;)if(Pe.check.isList(t)){if(!e.includes(t.lastElementChild))continue t;n=t.lastElementChild}i=s.firstElementChild,o=e.indexOf(i),r=e.indexOf(n),e.splice(o,r-o+1),a=e.length}else;const s=e.at(-1);let i,n,o;i=this.isBlock(s)||this.isLine(s)?s:this.getBlock(s,null)||this.getLine(s,null),Pe.check.isTableCell(i)?(n=null,o=i):(n=i.nextSibling,o=i.parentNode);const r=t.cloneNode(!1);let l=Pe.query.getNodeDepth(i),a=null;const h=[],c=(t,e,s)=>{let i=null;if(t!==e&&!Pe.check.isTableElements(e)){if(e&&Pe.query.getNodeDepth(t)===Pe.query.getNodeDepth(e))return s;i=this.#J.nodeTransform.removeAllParents(e,null,t)}return i?i.ec:s};for(let t,s,i,d,u,p,g,m=0,f=e.length;m<f;m++)if(t=e[m],s=t.parentNode,s&&!r.contains(s))if(i=Pe.query.getNodeDepth(t),Pe.check.isList(s)){if(null===a&&(p?(a=p,g=!0,p=null):a=s.cloneNode(!1)),h.push(t),u=e[m+1],m===f-1||u?.parentNode!==s){t.contains(u?.parentNode)&&(p=u.parentNode.cloneNode(!1));let e,m=s.parentNode;for(;Pe.check.isList(m);)e=Pe.utils.createElement(m.nodeName),e.appendChild(a),a=e,m=m.parentNode;const f=this.removeBlock(s,{selectedFormats:h,newBlockElement:null,shouldDelete:!0,skipHistory:!0});l>=i?(l=i,o=f.cc,n=c(o,s,f.ec),n&&(o=n.parentNode)):o===f.cc&&(n=f.ec),o!==f.cc&&(d=c(o,f.cc,d),n=void 0!==d?d:f.cc);for(let t=0,e=f.removeArray.length;t<e;t++)a.appendChild(f.removeArray[t]);g||r.appendChild(a),p&&f.removeArray.at(-1).appendChild(p),a=null,g=!1}}else l>=i&&(l=i,o=s,n=t.nextSibling),r.appendChild(t),o!==s&&(d=c(o,s),void 0!==d&&(n=d));if(this.#t.set("_lastSelectionNode",null),this.#J.nodeTransform.mergeSameTags(r,null,!1),this.#J.nodeTransform.mergeNestedTags(r,(t=>Pe.check.isList(t))),n&&Pe.query.getNodeDepth(n)>0&&(Pe.check.isList(n.parentNode)||Pe.check.isList(n.parentNode.parentNode))){const t=Pe.query.getParentElement(n,(t=>this.isBlock(t)&&!Pe.check.isList(t))),e=this.#J.nodeTransform.split(n,null,t?Pe.query.getNodeDepth(t)+1:0);e.parentNode.insertBefore(r,e)}else o.insertBefore(r,n),c(r,n);const d=Pe.query.getEdgeChildNodes(r.firstElementChild,r.lastElementChild);e.length>1?this.#J.selection.setRange(d.sc,0,d.ec,d.ec.textContent.length):this.#J.selection.setRange(d.ec,d.ec.textContent.length,d.ec,d.ec.textContent.length),this.#J.history.push(!1)}removeBlock(t,{selectedFormats:e,newBlockElement:s,shouldDelete:i,skipHistory:n}={}){const o=this.#J.selection.getRange();let r=o.startOffset,l=o.endOffset,a=Pe.query.getListChildNodes(t,null,1),h=t.parentNode,c=null,d=null,u=t.cloneNode(!1);const p=[],g=Pe.check.isList(s);let m=!1,f=!1,v=!1;const b=(e,s,i,n)=>{if(1===s.childNodes.length&&Pe.check.isZeroWidth(s)&&(s.innerHTML=Re.zeroWidthSpace,r=l=1),3===s.nodeType)return e.insertBefore(s,i),s;const o=(v?s:n).childNodes;let a=s.cloneNode(!1),h=null,c=null;for(;o[0];)c=o[0],!this._isNotTextNode(c)||Pe.check.isBreak(c)||Pe.check.isListCell(a)?a.appendChild(c):(a.childNodes.length>0&&(h||=a,e.insertBefore(a,i),a=s.cloneNode(!1)),e.insertBefore(c,i),h||=c);if(a.childNodes.length>0){if(Pe.check.isListCell(e)&&Pe.check.isListCell(a)&&Pe.check.isList(i))if(g){for(h=i;i;)a.appendChild(i),i=i.nextSibling;e.parentNode.insertBefore(a,e.nextElementSibling)}else{const e=n.nextElementSibling,s=this.#J.listFormat.removeNested(n,!1);if(t!==s||e!==n.nextElementSibling){const e=a.childNodes;for(;e[0];)n.appendChild(e[0]);t=s,f=!0}}else e.insertBefore(a,i);h||=a}return h};for(let n,o,r,l=0,y=a.length;l<y;l++)if(n=a[l],3!==n.nodeType||!Pe.check.isList(u))if(v=!1,i&&0===l&&(c=e&&e.length!==y&&e[0]!==n?u:t.previousSibling),e&&(o=e.indexOf(n)),e&&-1===o)u||=t.cloneNode(!1),u.appendChild(n);else{if(e&&(r=e[o+1]),u&&u.children.length>0&&(h.insertBefore(u,t),u=null),!g&&Pe.check.isListCell(n))if(r&&Pe.query.getNodeDepth(n)!==Pe.query.getNodeDepth(r)&&(Pe.check.isListCell(h)||Pe.utils.arrayFind(n.children,Pe.check.isList))){const e=n.nextElementSibling,s=this.#J.listFormat.removeNested(n,!1);t===s&&e===n.nextElementSibling||(t=s,f=!0)}else{const e=n;n=Pe.utils.createElement(i?e.nodeName:Pe.check.isList(t.parentNode)||Pe.check.isListCell(t.parentNode)?"LI":Pe.check.isTableCell(t.parentNode)?"DIV":this.#rt.get("defaultLine"));const s=Pe.check.isListCell(n),o=e.childNodes;for(;o[0]&&(!Pe.check.isList(o[0])||s);)n.appendChild(o[0]);Pe.utils.copyFormatAttributes(n,e),v=!0}else n=n.cloneNode(!1);if(!f&&(i?(p.push(n),Pe.utils.removeItem(a[l])):(s?(m||(h.insertBefore(s,t),m=!0),n=b(s,n,null,a[l])):n=b(h,n,t,a[l]),f||(e?(d=n,c||=n):c||(c=d=n))),f)){f=v=!1,a=Pe.query.getListChildNodes(t,null,1),u=t.cloneNode(!1),h=t.parentNode,l=-1,y=a.length;continue}}const y=t.parentNode;let w=t.nextSibling;u?.children.length>0&&y.insertBefore(u,w),s?c=s.previousSibling:c||=t.previousSibling,w=t.nextSibling!==u?t.nextSibling:u?u.nextSibling:null,0===t.children.length||0===t.textContent.length?Pe.utils.removeItem(t):this.#J.nodeTransform.removeEmptyNode(t,null,!1);let C=null;if(this.#t.set("_lastSelectionNode",null),i)C={cc:y,sc:c,so:r,ec:w,eo:l,removeArray:p};else{c||=d,d||=c;const t=Pe.query.getEdgeChildNodes(c,d?.parentNode?c:d);t?C={cc:(t.sc||t.ec).parentNode,sc:t.sc,so:r,ec:t.ec,eo:l,removeArray:null}:this.#J.focusManager.focus()}if(n)return C;!i&&C&&(e?this.#J.selection.setRange(C.sc,r,C.ec,l):this.#J.selection.setRange(C.sc,0,C.sc,0)),this.#J.history.push(!1)}indent(){const t=this.#J.selection.getRange(),e=t.startContainer,s=t.endContainer,i=t.startOffset,n=t.endOffset,o=Os(this.getLines(null),this.#t.get("indentSize"),this.#rt.get("_rtl")?"marginRight":"marginLeft");o.length>0&&this.#J.listFormat.applyNested(o,!1),this.#t.set("_lastSelectionNode",null),this.#J.selection.setRange(e,i,s,n),this.#J.history.push(!1)}outdent(){const t=this.#J.selection.getRange(),e=t.startContainer,s=t.endContainer,i=t.startOffset,n=t.endOffset,o=Os(this.getLines(null),-1*this.#t.get("indentSize"),this.#rt.get("_rtl")?"marginRight":"marginLeft");o.length>0&&this.#J.listFormat.applyNested(o,!0),this.#t.set("_lastSelectionNode",null),this.#J.selection.setRange(e,i,s,n),this.#J.history.push(!1)}isEdgeLine(t,e,s){if("front"===s){if(e>0)return!1}else if(t?.textContent?.length>e)return!1;let i=!1;const n="front"===s?"previousSibling":"nextSibling";for(;t&&!this.isLine(t)&&!Pe.check.isWysiwygFrame(t);){if(t[n]&&(!Pe.check.isBreak(t[n])||t[n][n]))return!1;i=!0,t=t.parentNode}return i}isTextStyleNode(t){return"string"==typeof t?this.#xt.test(t):1===t?.nodeType&&this.#xt.test(t.nodeName)}isLine(t){return"string"==typeof t?this.#yt.test(t):1===t?.nodeType&&(this.#yt.test(t.nodeName)||Pe.utils.hasClass(t,"__se__format__line_.+|__se__format__br_line_.+"))&&!this.#Et(t)}isNormalLine(t){return this.isLine(t)&&(this.#$t||!this.isBrLine(t))&&!this.isBlock(t)}isBrLine(t){return this.#$t&&this.isLine(t)||("string"==typeof t?this.#wt.test(t):1===t?.nodeType&&(this.#wt.test(t.nodeName)||Pe.utils.hasClass(t,"__se__format__br_line_.+"))&&!this.#Et(t))}isBlock(t){return"string"==typeof t?this.#Ct.test(t):1===t?.nodeType&&(this.#Ct.test(t.nodeName)||Pe.utils.hasClass(t,"__se__format__block_.+"))&&!this.#Et(t)}isClosureBlock(t){return"string"==typeof t?this.#_t.test(t):1===t?.nodeType&&(this.#_t.test(t.nodeName)||Pe.utils.hasClass(t,"__se__format__block_closure_.+"))&&!this.#Et(t)}isClosureBrLine(t){return"string"==typeof t?this.#kt.test(t):1===t?.nodeType&&(this.#kt.test(t.nodeName)||Pe.utils.hasClass(t,"__se__format__br_line__closure_.+"))&&!this.#Et(t)}getLines(t){if(!this.#J.selection.resetRangeToTextNode())return[];let e=this.#J.selection.getRange();if(Pe.check.isWysiwygFrame(e.startContainer)){const t=this.#X.get("wysiwyg").children,s=t.length;if(0===s)return[];this.#J.selection.setRange(t[0],0,t[s-1],t[s-1].textContent.trim().length),e=this.#J.selection.getRange()}const s=e.startContainer,i=e.endContainer,n=e.commonAncestorContainer;t||=this.isLine.bind(this);const o=Pe.query.getListChildren(n,(e=>t(e)),null);if(3!==n.nodeType&&(Pe.check.isWysiwygFrame(n)||this.isBlock(n))||o.unshift(this.getLine(n,null)),s===i||1===o.length)return o;const r=this.getLine(s,null),l=this.getLine(i,null);let a=null,h=null;const c=function(t){return!Pe.check.isTableElements(t)||/^TABLE$/i.test(t.nodeName)};let d=this.getBlock(r,c),u=this.getBlock(l,c);Pe.check.isTableElements(d)&&Pe.check.isListCell(d.parentNode)&&(d=d.parentNode),Pe.check.isTableElements(u)&&Pe.check.isListCell(u.parentNode)&&(u=u.parentNode);const p=d===u;for(let t,e=0,s=o.length;e<s;e++)if(t=o[e],r===t||!p&&t===d)a=e;else if(l===t||!p&&t===u){h=e;break}return null===a&&(a=0),null===h&&(h=o.length-1),o.slice(a,h+1)}getLinesAndComponents(t){const e=this.#J.selection.getRange().commonAncestorContainer,s=Pe.query.getParentElement(e,this.#J.component.is.bind(this.#J.component)),i=Pe.check.isTableElements(e)?this.getLines(null):this.getLines((t=>{const e=Pe.query.getParentElement(t,this.#J.component.is.bind(this.#J.component));return this.isLine(t)&&(!e||e===s)||Pe.check.isComponentContainer(t)&&!this.getLine(t)}));if(t)for(let t=0,e=i.length;t<e;t++)for(let s=t-1;s>=0;s--)if(i[s].contains(i[t])){i.splice(t,1),t--,e--;break}return i}_isNotTextNode(t){if(!t)return!1;const e=/^(br|input|select|canvas|img|iframe|audio|video)$/i;return"string"==typeof t?e.test(t):1===t.nodeType&&(this.#J.component.is(t)||e.test(t.nodeName))}_isExcludeSelectionElement(t){return!/FIGCAPTION/i.test(t.nodeName)&&(this.#J.component.is(t)||/FIGURE/i.test(t.nodeName))}#Et(t){return Pe.check.isExcludeFormat(t)||this.#J.component.is(t)||Pe.check.isWysiwygFrame(t)}#St(){let t=this.#J.selection.getRange(),e=this.getLinesAndComponents(!1);if(0===e.length&&(t=this.#J.selection.getRangeAndAddLine(t,null),e=this.getLinesAndComponents(!1),0===e.length))return;const s=t.startOffset,i=t.endOffset;let n=e[0],o=e.at(-1);const r=Pe.query.getNodePath(t.startContainer,n,null),l=Pe.query.getNodePath(t.endContainer,o,null),a=this.#J.listFormat.remove(e,!1);return a.sc&&(n=a.sc),a.ec&&(o=a.ec),this.#J.selection.setRange(Pe.query.getNodeFromPath(r,n),s,Pe.query.getNodeFromPath(l,o),i),{lines:this.getLinesAndComponents(!1),firstNode:n,lastNode:o,firstPath:r,lastPath:l,startOffset:s,endOffset:i}}__resetBrLineBreak(t){return this.#$t="br"===t}};function zs(t){const e=t.parentNode;if(!t||3===t.nodeType||!e)return;const s=t.childNodes;for(;s[0];)e.insertBefore(s[0],t);e.removeChild(t)}const Ps=class{#J;#rt;#Tt;#Mt;constructor(t){this.#J=t.$,this.#rt=this.#J.options,this.#Tt=this.#rt.get("__listCommonStyle"),this.#Mt=ze.camelToKebabCase(this.#rt.get("__listCommonStyle"))}apply(t,{stylesToModify:e,nodesToRemove:s,strictRemove:i}={}){if(Pe.query.getParentElement(this.#J.selection.getNode(),Pe.check.isNonEditable))return;this.#J.selection.resetRangeToTextNode();let n=this.#J.selection.getRangeAndAddLine(this.#J.selection.getRange(),null);e=e?.length>0?e:null,s=s?.length>0?s:null;const o=!t,r=o&&!s&&!e;let l=n.startContainer,a=n.startOffset,h=n.endContainer,c=n.endOffset;if(r&&n.collapsed&&this.#J.format.isLine(l.parentNode)&&this.#J.format.isLine(h.parentNode)||l===h&&1===l.nodeType&&Pe.check.isNonEditable(l)){const t=l.parentNode;if(!Pe.check.isListCell(t)||!ze.getValues(t.style).some((t=>this.#Mt.includes(t))))return}if(n.collapsed&&!r&&1===l.nodeType&&!Pe.check.isBreak(l)&&!this.#J.component.is(l)){let t=null;const e=l.childNodes[a];e&&(t=e.nextSibling?Pe.check.isBreak(e)?e:e.nextSibling:null);const s=Pe.utils.createTextNode(Re.zeroWidthSpace);l.insertBefore(s,t),this.#J.selection.setRange(s,1,s,1),n=this.#J.selection.getRange(),l=n.startContainer,a=n.startOffset,h=n.endContainer,c=n.endOffset}this.#J.format.isLine(l)&&(l=l.childNodes[a]||l.firstChild,a=0),this.#J.format.isLine(h)&&(h=h.childNodes[c]||h.lastChild,c=h.textContent.length),o&&(t=Pe.utils.createElement("DIV"));const d=RegExp,u=t.nodeName;if(!r&&l===h&&!s&&t){let e=l,s=0;const i=[],n=t.style;for(let t=0,e=n.length;t<e;t++)i.push(n[t]);const r=t.className,a=t.classList;for(let t=0,e=a.length;t<e;t++)i.push("."+a[t]);if(i.length>0){for(;!this.#J.format.isLine(e)&&!Pe.check.isWysiwygFrame(e);){for(let t=0;t<i.length;t++)if(1===e.nodeType){const l=i[t],a=!!/^\./.test(l)&&new d("\\s*"+l.replace(/^\./,"")+"(\\s+|$)","ig"),h=e.style,c=e.className,u=o?!!h[l]:!!h[l]&&!!n[l]&&h[l]===n[l],p=!1!==a&&(o?!!c.match(a):!!c.match(a)&&!!r.match(a));(u||p)&&s++}e=e.parentNode}if(s>=i.length)return}}let p,g,m={},f={},v="",b="";if(e){for(let t,s=0,i=e.length;s<i;s++)t=e[s],/^\./.test(t)?b+=(b?"|":"\\s*(?:")+t.replace(/^\./,""):v+=(v?"|":"(?:;|^|\\s)(?:")+t;v&&(v+=")\\s*:[^;]*\\s*(?:;|$)",v=new d(v,"ig")),b&&(b+=")(?=\\s+|$)",b=new d(b,"ig"))}if(s){g="^(?:"+s[0];for(let t=1;t<s.length;t++)g+="|"+s[t];g+=")$",g=new d(g,"i")}const y={v:!1},w=function(t){const e=t.cloneNode(!1);if(3===e.nodeType||Pe.check.isBreak(e))return e;if(r)return null;const s=!g&&o||g?.test(e.nodeName);if(s&&!i)return y.v=!0,null;const n=e.style.cssText;let l="";v&&n.length>0&&(l=n.replace(v,"").trim(),l!==n&&(y.v=!0));const a=e.className;let h="";return b&&a.length>0&&(h=a.replace(b,"").trim(),h!==a&&(y.v=!0)),(!o||!b&&a||!v&&n||l||h||!s)&&(l||h||e.nodeName!==u||Boolean(v)!==Boolean(n)||Boolean(b)!==Boolean(a))?(v&&n.length>0&&(e.style.cssText=l),e.style.cssText||e.removeAttribute("style"),b&&a.length>0&&(e.className=h.trim()),e.className.trim()||e.removeAttribute("class"),e.style.cssText||e.className||e.nodeName!==u&&!s?e:(y.v=!0,null)):(y.v=!0,null)},C=this.#J.format.getLines(null);if(0===C.length)return void console.warn("[SUNEDITOR.inline.apply.warn] There is no line to apply.");n=this.#J.selection.getRange(),l=n.startContainer,a=n.startOffset,h=n.endContainer,c=n.endOffset,this.#J.format.getLine(l,null)||(l=Pe.query.getEdgeChild(C[0],(function(t){return 3===t.nodeType}),!1),a=0),this.#J.format.getLine(h,null)||(h=Pe.query.getEdgeChild(C.at(-1),(function(t){return 3===t.nodeType}),!1),c=h.textContent.length);const _=this.#J.format.getLine(l,null)===this.#J.format.getLine(h,null),k=C.length-(_?0:1);p=t.cloneNode(!1);const x=r||o&&(t=>{for(let e=0,s=t?.length;e<s;e++)if(this._isNonSplitNode(t[e]))return!0;return!1})(s),$=o||this.#Nt(p),S=this.#Bt.bind(this,x,$),E=this.#It.bind(this,x,$);if(_){this.#Lt(C[0],e)&&(n=this.#J.selection.setRange(l,a,h,c));const t=this.#At(C[0],p,w,l,a,h,c,r,o,n.collapsed,y,S,E);m.container=t.startContainer,m.offset=t.startOffset,f.container=t.endContainer,f.offset=t.endOffset,m.container===f.container&&Pe.check.isZeroWidth(m.container)&&(m.offset=f.offset=1),this.#Ot(t.ancestor,null)}else{let s=!1;k>0&&this.#Lt(C[k],e)&&(s=!0),this.#Lt(C[0],e)&&(s=!0),s&&this.#J.selection.setRange(l,a,h,c),k>0&&(p=t.cloneNode(!1),f=this.#Rt(C[k],p,w,h,c,r,o,y,S,E));for(let s,i=k-1;i>0;i--)this.#Lt(C[i],e),p=t.cloneNode(!1),s=this.#zt(C[i],p,w,r,o,y,f.container),s.endContainer&&s.ancestor.contains(s.endContainer)&&(f.ancestor=null,f.container=s.endContainer),this.#Ot(s.ancestor,null);p=t.cloneNode(!1),m=this.#Pt(C[0],p,w,l,a,r,o,y,S,E,f.container),m.endContainer&&(f.ancestor=null,f.container=m.endContainer),k<=0?f=m:f.container||(f.ancestor=null,f.container=m.container,f.offset=m.container.textContent.length),this.#Ot(m.ancestor,null),this.#Ot(f.ancestor||this.#J.format.getLine(f.container),null)}return this.#J.ui.offCurrentController(),this.#J.selection.setRange(m.container,m.offset,f.container,f.offset),this.#J.history.push(!1),p}remove(){this.apply(null,{stylesToModify:null,nodesToRemove:null,strictRemove:null})}_isNonSplitNode(t){if(!t)return!1;const e=/^(a|label|code|summary)$/i;return"string"==typeof t?e.test(t):1===t.nodeType&&e.test(t.nodeName)}_isIgnoreNodeChange(t){return t&&1===t.nodeType&&(Pe.check.isNonEditable(t)||!this.#J.format.isTextStyleNode(t)||this.#J.component.is(t))}#At(t,e,s,i,n,o,r,l,a,h,c,d,u){let p=i.parentNode;for(;!(p.nextSibling||p.previousSibling||this.#J.format.isLine(p.parentNode)||Pe.check.isWysiwygFrame(p.parentNode))&&p.nodeName!==e.nodeName;)p=p.parentNode;if(!a&&!l&&p===o.parentNode&&p.nodeName===e.nodeName&&Pe.check.isZeroWidth(i.textContent.slice(0,n))&&Pe.check.isZeroWidth(o.textContent.slice(r))){const s=p.childNodes;let l=!0;for(let t,e,n,r,a=0,h=s.length;a<h;a++)if(t=s[a],r=!Pe.check.isZeroWidth(t),t!==i&&t!==o){if(!e&&r||e&&n&&r){l=!1;break}}else t===i&&(e=!0),t===o&&(n=!0);if(l)return Pe.utils.copyTagAttributes(p,e),{ancestor:t,startContainer:i,startOffset:n,endContainer:o,endOffset:r}}c.v=!1;const g=this,m=t,f=[e],v=t.cloneNode(!1),b=i===o;let y,w,C,_,k,x=i,$=n,S=o,E=r,T=!1,M=!1;const N=RegExp;function B(t){const e=new N("(?:;|^|\\s)(?:"+_+"null)\\s*:[^;]*\\s*(?:;|$)","ig");let s=!1;return e&&t.style.cssText.length>0&&(s=e.test(t.style.cssText)),!s}if(function t(i,n){const o=i.childNodes;for(let i,r=0,a=o.length;r<a;r++){const a=o[r];if(!a)continue;let c,p=n;if(!T&&a===x){let t=v;k=d(a);let o="",r="";if(3===x.nodeType){const t=x;o=t.substringData(0,$),r=t.substringData($,b&&E>=$?E-$:t.data.length-$)}const l=Pe.utils.createTextNode(o),h=Pe.utils.createTextNode(r);if(k){const e=d(n);if(e.parentNode!==t){let s=e,i=null;for(;s.parentNode!==t;){for(n=i=s.parentNode.cloneNode(!1);s.childNodes[0];)i.appendChild(s.childNodes[0]);s.appendChild(i),s=s.parentNode}s.parentNode.appendChild(e)}k=k.cloneNode(!1)}Pe.check.isZeroWidth(l)||n.appendChild(l);const c=d(n);for(c&&(k=c),k&&(t=k),w=a,y=[],_="";w!==t&&w!==m&&null!==w;)i=u(w)?null:s(w),i&&1===w.nodeType&&B(w)&&(y.push(i),_+=w.style.cssText.substring(0,w.style.cssText.indexOf(":"))+"|"),w=w.parentElement;const p=y.pop()||h;for(C=w=p;y.length>0;)w=y.pop(),C.appendChild(w),C=w;if(e.appendChild(p),t.appendChild(e),k&&!d(S)&&(e=e.cloneNode(!1),v.appendChild(e),f.push(e)),x=h,$=0,T=!0,w!==h&&w.appendChild(x),!b)continue}if(M||a!==S){if(T){if(1===a.nodeType&&!Pe.check.isBreak(a)){g._isIgnoreNodeChange(a)?(v.appendChild(a.cloneNode(!0)),h||(e=e.cloneNode(!1),v.appendChild(e),f.push(e))):t(a,a);continue}w=a,y=[],_="";const o=[];for(;null!==w.parentNode&&w!==m&&w!==e;)i=M?w.cloneNode(!1):s(w),1===w.nodeType&&!Pe.check.isBreak(a)&&i&&B(w)&&(u(w)?k||o.push(i):y.push(i),_+=w.style.cssText.substring(0,w.style.cssText.indexOf(":"))+"|"),w=w.parentElement;y=y.concat(o);const r=y.pop()||a;for(C=w=r;y.length>0;)w=y.pop(),C.appendChild(w),C=w;if(!u(e.parentNode)||u(r)||Pe.check.isZeroWidth(e)||(e=e.cloneNode(!1),v.appendChild(e),f.push(e)),M||k||!u(r))r===a?n=M?v:e:M?(v.appendChild(r),n=w):(e.appendChild(r),n=w);else{e=e.cloneNode(!1);const t=r.childNodes;for(let s=0,i=t.length;s<i;s++)e.appendChild(t[s]);r.appendChild(e),v.appendChild(r),f.push(e),n=e.children.length>0?w:e}if(k&&3===a.nodeType)if(d(a)){const t=Pe.query.getParentElement(n,(t=>g._isNonSplitNode(t.parentNode)||t.parentNode===v));k.appendChild(t),e=t.cloneNode(!1),f.push(e),v.appendChild(e)}else k=null}c=a.cloneNode(!1),n.appendChild(c),1!==a.nodeType||Pe.check.isBreak(a)||(p=c),t(a,p)}else{k=d(a);let t="",n="";if(3===S.nodeType){const e=S;t=e.substringData(E,e.length-E),n=b?"":e.substringData(0,E)}const o=Pe.utils.createTextNode(t),r=Pe.utils.createTextNode(n);if(k?k=k.cloneNode(!1):u(e.parentNode)&&!k&&(e=e.cloneNode(!1),v.appendChild(e),f.push(e)),!Pe.check.isZeroWidth(o)){w=a,_="",y=[];const t=[];for(;w!==v&&w!==m&&null!==w;)1===w.nodeType&&B(w)&&(u(w)?t.push(w.cloneNode(!1)):y.push(w.cloneNode(!1)),_+=w.style.cssText.substring(0,w.style.cssText.indexOf(":"))+"|"),w=w.parentElement;for(y=y.concat(t),c=C=w=y.pop()||o;y.length>0;)w=y.pop(),C.appendChild(w),C=w;v.appendChild(c),w.textContent=o.data}if(k&&c){const t=d(c);t&&(k=t)}for(w=a,y=[],_="";w!==v&&w!==m&&null!==w;)i=u(w)?null:s(w),i&&1===w.nodeType&&B(w)&&(y.push(i),_+=w.style.cssText.substring(0,w.style.cssText.indexOf(":"))+"|"),w=w.parentElement;const p=y.pop()||r;for(C=w=p;y.length>0;)w=y.pop(),C.appendChild(w),C=w;k?((e=e.cloneNode(!1)).appendChild(p),k.insertBefore(e,k.firstChild),v.appendChild(k),f.push(e),k=null):e.appendChild(p),S=r,E=r.data.length,M=!0,!l&&h&&(e=r,r.textContent=Re.zeroWidthSpace),w!==r&&w.appendChild(S)}}}(t,v),a&&!l&&!c.v)return{ancestor:t,startContainer:i,startOffset:n,endContainer:o,endOffset:r};if(l&&=a,l)for(let t=0;t<f.length;t++){const e=f[t];let s,i,n;if(h)s=Pe.utils.createTextNode(Re.zeroWidthSpace),v.replaceChild(s,e);else{const t=e.childNodes;for(i=t[0];t[0];)n=t[0],v.insertBefore(n,e);Pe.utils.removeItem(e)}0===t&&(h?x=S=s:(x=i,S=n))}else{if(a)for(let t=0;t<f.length;t++)zs(f[t]);h&&(x=S=e)}this.#J.nodeTransform.removeEmptyNode(v,e,!1),h&&($=x.textContent.length,E=S.textContent.length);const I=l||0===S.textContent.length;Pe.check.isBreak(S)||0!==S.textContent.length||(Pe.utils.removeItem(S),S=x),E=I?S.textContent.length:E;const L={s:0,e:0},A=Pe.query.getNodePath(x,v,L),O=!S.parentNode;O&&(S=x);const R={s:0,e:0},z=Pe.query.getNodePath(S,v,O||I?null:R);$+=L.s,E=h?$:O?x.textContent.length:I?E+L.s:E+R.s;const P=this.#J.nodeTransform.mergeSameTags(v,[A,z],!0);return t.parentNode.replaceChild(v,t),x=Pe.query.getNodeFromPath(A,v),S=Pe.query.getNodeFromPath(z,v),{ancestor:v,startContainer:x,startOffset:$+P[0],endContainer:S,endOffset:E+P[1]}}#Pt(t,e,s,i,n,o,r,l,a,h,c){let d=i.parentNode;for(;!(d.nextSibling||d.previousSibling||this.#J.format.isLine(d.parentNode)||Pe.check.isWysiwygFrame(d.parentNode))&&d.nodeName!==e.nodeName;)d=d.parentNode;if(!r&&!o&&d.nodeName===e.nodeName&&!this.#J.format.isLine(d)&&!d.nextSibling&&Pe.check.isZeroWidth(i.textContent.slice(0,n))){let s=!0,o=i.previousSibling;for(;o;){if(!Pe.check.isZeroWidth(o)){s=!1;break}o=o.previousSibling}if(s)return Pe.utils.copyTagAttributes(d,e),{ancestor:t,container:i,offset:n}}l.v=!1;const u=this,p=t,g=[e],m=t.cloneNode(!1);let f,v,b,y,w=i,C=n,_=!1;if(function t(i,n){const o=i.childNodes;for(let i,r,l=0,d=o.length;l<d;l++){const d=o[l];if(!d)continue;let k=n;if(_&&!Pe.check.isBreak(d)){if(1===d.nodeType){if(u._isIgnoreNodeChange(d)){if(e=e.cloneNode(!1),r=d.cloneNode(!0),m.appendChild(r),m.appendChild(e),g.push(e),c&&d.contains(c)){const t=Pe.query.getNodePath(c,d);c=Pe.query.getNodeFromPath(t,r)}}else t(d,d);continue}v=d,f=[];const o=[];for(;null!==v.parentNode&&v!==p&&v!==e;)i=s(v),1===v.nodeType&&i&&(h(v)?y||o.push(i):f.push(i)),v=v.parentNode;f=f.concat(o);const l=f.length>0,w=f.pop()||d;for(b=v=w;f.length>0;)v=f.pop(),b.appendChild(v),b=v;if(h(e.parentNode)&&!h(w)&&(e=e.cloneNode(!1),m.appendChild(e),g.push(e)),!y&&h(w)){e=e.cloneNode(!1);const t=w.childNodes;for(let s=0,i=t.length;s<i;s++)e.appendChild(t[s]);w.appendChild(e),m.appendChild(w),n=h(v)?e:v,g.push(e)}else l?(e.appendChild(w),n=v):n=e;if(y&&3===d.nodeType)if(a(d)){const t=Pe.query.getParentElement(n,(t=>u._isNonSplitNode(t.parentNode)||t.parentNode===m));y.appendChild(t),e=t.cloneNode(!1),g.push(e),m.appendChild(e)}else y=null}if(_||d!==w)i=_?s(d):d.cloneNode(!1),i&&(n.appendChild(i),1!==d.nodeType||Pe.check.isBreak(d)||(k=i)),t(d,k);else{let t=m;y=a(d);let o="",r="";if(3===w.nodeType){const t=w;o=t.substringData(0,C),r=t.substringData(C,t.length-C)}const l=Pe.utils.createTextNode(o),h=Pe.utils.createTextNode(r);if(y){const e=a(n);if(e&&e.parentNode!==t){let s=e,i=null;for(;s.parentNode!==t;){for(n=i=s.parentNode.cloneNode(!1);s.childNodes[0];)i.appendChild(s.childNodes[0]);s.appendChild(i),s=s.parentNode}s.parentNode.appendChild(e)}y=y.cloneNode(!1)}Pe.check.isZeroWidth(l)||n.appendChild(l);const c=a(n);for(c&&(y=c),y&&(t=y),v=n,f=[];v!==t&&null!==v;)i=s(v),1===v.nodeType&&i&&f.push(i),v=v.parentNode;const u=f.pop()||n;for(b=v=u;f.length>0;)v=f.pop(),b.appendChild(v),b=v;u!==n?(e.appendChild(u),n=v):n=e,Pe.check.isBreak(d)&&e.appendChild(d.cloneNode(!1)),t.appendChild(e),w=h,C=0,_=!0,n.appendChild(w)}}}(t,m),r&&!o&&!l.v)return{ancestor:t,container:i,offset:n,endContainer:c};if(o&&=r,o)for(let t=0;t<g.length;t++){const e=g[t],s=e.childNodes,i=s[0];for(;s[0];)m.insertBefore(s[0],e);Pe.utils.removeItem(e),0===t&&(w=i)}else if(r){e=e.firstChild;for(let t=0;t<g.length;t++)zs(g[t])}if(o||0!==m.childNodes.length){this.#J.nodeTransform.removeEmptyNode(m,e,!1),Pe.check.isZeroWidth(m.textContent)&&(w=m.firstChild,C=0);const s={s:0,e:0},i=Pe.query.getNodePath(w,m,s);C+=s.s;const n=this.#J.nodeTransform.mergeSameTags(m,[i],!0);t.parentNode.replaceChild(m,t),w=Pe.query.getNodeFromPath(i,m),C+=n[0]}else t.childNodes?w=t.childNodes[0]:(w=Pe.utils.createTextNode(Re.zeroWidthSpace),t.appendChild(w));return{ancestor:m,container:w,offset:C,endContainer:c}}#zt(t,e,s,i,n,o,r){if(!n){let s=null;r&&t.contains(r)&&(s=Pe.query.getNodePath(r,t));const i=t.cloneNode(!0),n=e.nodeName,o=e.style.cssText,l=e.className;let a=i.childNodes,h=0,c=a.length;for(let t;h<c&&(t=a[h],3!==t.nodeType);h++){if(t.nodeName!==n){if(!Pe.check.isBreak(t)&&this._isIgnoreNodeChange(t))continue;if(1===c){a=t.childNodes,c=a.length,h=-1;continue}break}t.style.cssText+=o,Pe.utils.addClass(t,l)}if(c>0&&h===c)return t.innerHTML=i.innerHTML,{ancestor:t,endContainer:s?Pe.query.getNodeFromPath(s,t):null}}o.v=!1;const l=this,a=t.cloneNode(!1),h=[e];let c=!0;if(function t(i,n){const o=i.childNodes;for(let i,d,u=0,p=o.length;u<p;u++){const p=o[u];if(!p)continue;let g=n;if(Pe.check.isBreak(p)||!l._isIgnoreNodeChange(p))i=s(p),i&&(c=!1,n.appendChild(i),1===p.nodeType&&(g=i)),Pe.check.isBreak(p)||t(p,g);else if(e.childNodes.length>0&&(a.appendChild(e),e=e.cloneNode(!1)),d=p.cloneNode(!0),a.appendChild(d),a.appendChild(e),h.push(e),n=e,r&&p.contains(r)){const t=Pe.query.getNodePath(r,p);r=Pe.query.getNodeFromPath(t,d)}}}(t,e),c||n&&!i&&!o.v)return{ancestor:t,endContainer:r};if(a.appendChild(e),i&&n)for(let t=0;t<h.length;t++){const e=h[t],s=e.childNodes;for(;s[0];)a.insertBefore(s[0],e);Pe.utils.removeItem(e)}else if(n){e=e.firstChild;for(let t=0;t<h.length;t++)zs(h[t])}return this.#J.nodeTransform.removeEmptyNode(a,e,!1),this.#J.nodeTransform.mergeSameTags(a,null,!0),t.parentNode.replaceChild(a,t),{ancestor:a,endContainer:r}}#Rt(t,e,s,i,n,o,r,l,a,h){let c=i.parentNode;for(;!(c.nextSibling||c.previousSibling||this.#J.format.isLine(c.parentNode)||Pe.check.isWysiwygFrame(c.parentNode))&&c.nodeName!==e.nodeName;)c=c.parentNode;if(!r&&!o&&c.nodeName===e.nodeName&&!this.#J.format.isLine(c)&&!c.previousSibling&&Pe.check.isZeroWidth(i.textContent.slice(n))){let s=!0,o=i.nextSibling;for(;o;){if(!Pe.check.isZeroWidth(o)){s=!1;break}o=o.nextSibling}if(s)return Pe.utils.copyTagAttributes(c,e),{ancestor:t,container:i,offset:n}}l.v=!1;const d=this,u=t,p=[e],g=t.cloneNode(!1);let m,f,v,b,y=i,w=n,C=!1;if(function t(i,n){const o=i.childNodes;for(let i,r=o.length-1;0<=r;r--){const l=o[r];if(!l)continue;let c=n;if(C&&!Pe.check.isBreak(l)){if(1===l.nodeType){if(d._isIgnoreNodeChange(l)){e=e.cloneNode(!1);const t=l.cloneNode(!0);g.insertBefore(t,n),g.insertBefore(e,t),p.push(e)}else t(l,l);continue}f=l,m=[];const o=[];for(;null!==f.parentNode&&f!==u&&f!==e;)i=s(f),i&&1===f.nodeType&&(h(f)?b||o.push(i):m.push(i)),f=f.parentNode;m=m.concat(o);const r=m.length>0,c=m.pop()||l;for(v=f=c;m.length>0;)f=m.pop(),v.appendChild(f),v=f;if(h(e.parentNode)&&!h(c)&&(e=e.cloneNode(!1),g.insertBefore(e,g.firstChild),p.push(e)),!b&&h(c)){e=e.cloneNode(!1);const t=c.childNodes;for(let s=0,i=t.length;s<i;s++)e.appendChild(t[s]);c.appendChild(e),g.insertBefore(c,g.firstChild),p.push(e),n=e.children.length>0?f:e}else r?(e.insertBefore(c,e.firstChild),n=f):n=e;if(b&&3===l.nodeType)if(a(l)){const t=Pe.query.getParentElement(n,(t=>d._isNonSplitNode(t.parentNode)||t.parentNode===g));b.appendChild(t),e=t.cloneNode(!1),p.push(e),g.insertBefore(e,g.firstChild)}else b=null}if(C||l!==y)i=C?s(l):l.cloneNode(!1),i&&(n.insertBefore(i,n.firstChild),1!==l.nodeType||Pe.check.isBreak(l)||(c=i)),t(l,c);else{b=a(l);let t="",o="";if(3===y.nodeType){const e=y;t=e.substringData(w,e.length-w),o=e.substringData(0,w)}const r=Pe.utils.createTextNode(t),c=Pe.utils.createTextNode(o);if(b){b=b.cloneNode(!1);const t=a(n);if(t.parentNode!==g){let e=t,s=null;for(;e.parentNode!==g;){for(n=s=e.parentNode.cloneNode(!1);e.childNodes[0];)s.appendChild(e.childNodes[0]);e.appendChild(s),e=e.parentNode}e.parentNode.insertBefore(t,e.parentNode.firstChild)}b=b.cloneNode(!1)}else h(e.parentNode)&&!b&&(e=e.cloneNode(!1),g.appendChild(e),p.push(e));for(Pe.check.isZeroWidth(r)||n.insertBefore(r,n.firstChild),f=n,m=[];f!==g&&null!==f;)i=h(f)?null:s(f),i&&1===f.nodeType&&m.push(i),f=f.parentNode;const d=m.pop()||n;for(v=f=d;m.length>0;)f=m.pop(),v.appendChild(f),v=f;d!==n?(e.insertBefore(d,e.firstChild),n=f):n=e,Pe.check.isBreak(l)&&e.appendChild(l.cloneNode(!1)),b?(b.insertBefore(e,b.firstChild),g.insertBefore(b,g.firstChild),b=null):g.insertBefore(e,g.firstChild),y=c,w=c.data.length,C=!0,n.insertBefore(y,n.firstChild)}}}(t,g),r&&!o&&!l.v)return{ancestor:t,container:i,offset:n};if(o&&=r,o)for(let t=0;t<p.length;t++){const e=p[t],s=e.childNodes;let i=null;for(;s[0];)i=s[0],g.insertBefore(i,e);Pe.utils.removeItem(e),t===p.length-1&&(y=i,w=i.textContent.length)}else if(r){e=e.firstChild;for(let t=0;t<p.length;t++)zs(p[t])}if(o||0!==g.childNodes.length){if(!r&&0===e.textContent.length)return this.#J.nodeTransform.removeEmptyNode(g,null,!1),{ancestor:null,container:null,offset:0};this.#J.nodeTransform.removeEmptyNode(g,e,!1),Pe.check.isZeroWidth(g.textContent)?(y=g.firstChild,w=y.textContent.length):Pe.check.isZeroWidth(y)&&(y=e,w=1);const s={s:0,e:0},i=Pe.query.getNodePath(y,g,s);w+=s.s;const n=this.#J.nodeTransform.mergeSameTags(g,[i],!0);t.parentNode.replaceChild(g,t),y=Pe.query.getNodeFromPath(i,g),w+=n[0]}else t.childNodes?y=t.childNodes[0]:(y=Pe.utils.createTextNode(Re.zeroWidthSpace),t.appendChild(y));return{ancestor:g,container:y,offset:1===y.nodeType&&1===w?y.childNodes.length:w}}#Nt(t){return t&&"string"!=typeof t&&3!==t.nodeType&&this.#J.format.isTextStyleNode(t)&&!!t.style.fontSize}#Bt(t,e,s){return!s||t?null:Pe.query.getParentElement(s,this._isNonSplitNode.bind(this))||(e?null:Pe.query.getParentElement(s,this.#Nt.bind(this)))}#It(t,e,s){if(!s||t||1!==s.nodeType)return!1;const i=this._isNonSplitNode(s);return Pe.query.getParentElement(s,this._isNonSplitNode.bind(this))?i:i||!e&&this.#Nt(s)}#Ot(t,e){if(!Pe.check.isListCell(t))return;const s=Pe.utils.arrayFilter((e||t).childNodes,(t=>!Pe.check.isBreak(t)));if(e=s[0],!Pe.check.isElement(e)||s.length>1)return;const i=e.style,n=t.style,o=e.nodeName.toLowerCase();let r=!1;this.#rt.get("_defaultStyleTagMap")[o]===this.#rt.get("_defaultTagCommand").bold.toLowerCase()&&(n.fontWeight="bold"),this.#rt.get("_defaultStyleTagMap")[o]===this.#rt.get("_defaultTagCommand").italic.toLowerCase()&&(n.fontStyle="italic");const l=ze.getValues(i);if(l.length>0)for(let t=0,e=this.#Tt.length;t<e;t++)l.includes(this.#Mt[t])&&(n[this.#Tt[t]]=i[this.#Tt[t]],i.removeProperty(this.#Mt[t]),r=!0);if(this.#Ot(t,e),r&&0===i.length){const t=e.childNodes,s=e.parentNode,i=e.nextSibling;for(;t.length>0;)s.insertBefore(t[0],i);Pe.utils.removeItem(e)}}#Lt(t,e){if(!Pe.check.isListCell(t))return;e||=this.#Mt;const s=Pe.utils.arrayFilter(t.childNodes,(t=>!Pe.check.isBreak(t))),i=t.style,n=[],o=[],r=ze.getValues(i);for(let t=0,s=this.#Mt.length;t<s;t++)r.includes(this.#Mt[t])&&e.includes(this.#Mt[t])&&(n.push(this.#Tt[t]),o.push(this.#Mt[t]));if(0===n.length)return;const l=Pe.utils.createElement("SPAN");for(let t=0,e=n.length;t<e;t++)l.style[n[t]]=i[o[t]],i.removeProperty(o[t]);let a=l.cloneNode(!1),h=null,c=!1;for(let e,i,o=0,r=s.length;o<r;o++)e=s[o],this.#rt.get("_defaultStyleTagMap")[e.nodeName.toLowerCase()]||(i=ze.getValues(e.style),0===i.length||n.some((function(t){return!i.includes(t)}))&&i.some((function(t){return n.includes(t)}))?(h=e.nextSibling,a.appendChild(e)):a.childNodes.length>0&&(t.insertBefore(a,h),a=l.cloneNode(!1),h=null,c=!0));return a.childNodes.length>0&&(t.insertBefore(a,h),c=!0),0===i.length&&t.removeAttribute("style"),c}};function Ds(t){const e=t.parentNode;let s,i,n,o,r,l=e.parentNode,a=e;for(;Pe.check.isListCell(l);){for(o=Pe.query.getPositionIndex(t),s=l.nextElementSibling,i=l.parentNode,n=a;n;){if(a=a.nextSibling,Pe.check.isList(n)){for(r=n.childNodes;r[o];)i.insertBefore(r[o],s);0===r.length&&Pe.utils.removeItem(n)}else i.appendChild(n);n=a}l=i.parentNode}return 0===e.children.length&&Pe.utils.removeItem(e),i}const Fs=class{#J;#t;constructor(t){this.#J=t.$,this.#t=t.store}apply(t,e,s){const i=(t.split(":")[0]||"ol").toUpperCase(),n=t.split(":")[1]||"";let o=this.#J.selection.getRange(),r=e||this.#J.format.getLinesAndComponents(!1);if(0===r.length){if(e)return;if(o=this.#J.selection.getRangeAndAddLine(o,null),r=this.#J.format.getLinesAndComponents(!1),0===r.length)return}Pe.query.sortNodeByDepth(r,!0);const l=r[0],a=r.at(-1);let h=!Pe.check.isListCell(l)&&!this.#J.component.is(l)||l.previousElementSibling?l.previousElementSibling:l.parentElement.previousElementSibling,c=!Pe.check.isListCell(a)&&!this.#J.component.is(a)||a.nextElementSibling?a.nextElementSibling:a.parentElement.nextElementSibling;const d=o.collapsed,u={sc:o.startContainer,so:o.startContainer===o.endContainer&&Pe.check.isZeroWidth(o.startContainer)&&0===o.startOffset&&1===o.endOffset?o.endOffset:o.startOffset,ec:o.endContainer,eo:o.endOffset};let p=null,g=!0;for(let t=0,e=r.length;t<e;t++)if(!Pe.check.isList(this.#J.format.getBlock(r[t],(e=>this.#J.format.getBlock(e)&&e!==r[t])))){g=!1;break}if(!g||h&&l.tagName===h.tagName&&i===h.tagName.toUpperCase()||c&&a.tagName===c.tagName&&i===c.tagName.toUpperCase()){const t=h?h.parentNode:h,e=c?c.parentNode:c;h=t&&!Pe.check.isWysiwygFrame(t)&&t.nodeName===i?t:h,c=e&&!Pe.check.isWysiwygFrame(e)&&e.nodeName===i?e:c;const s=h?.tagName===i,o=c?.tagName===i;let l=s?h:Pe.utils.createElement(i,{style:"list-style-type: "+n}),a=null,d=null;const u=t=>!Pe.check.isComponentContainer(t)&&!Pe.check.isList(t);for(let t,e,o,h,c,p,g,m,f,v=0,b=r.length;v<b;v++)if(e=r[v],0!==e.childNodes.length||this.#J.inline._isIgnoreNodeChange(e)){if(h=r[v+1],c=e.parentNode,p=h?h.parentNode:null,o=Pe.check.isListCell(e),f=this.#J.format.isBlock(c)?c:null,g=o&&!Pe.check.isWysiwygFrame(c)?c.parentNode:c,m=o&&!Pe.check.isWysiwygFrame(c)?!h||Pe.check.isListCell(g)?c:c.nextSibling:e.nextSibling,t=Pe.utils.createElement("LI"),this.#J.component.is(e)){const s=/^HR$/i.test(e.nodeName);s||(t.innerHTML="<br>"),t.innerHTML+=e.outerHTML,s&&(t.innerHTML+="<br>")}else{Pe.utils.copyFormatAttributes(t,e);const s=e.childNodes;for(;s[0];)t.appendChild(s[0])}l.appendChild(t),h&&g===p&&!this.#J.format.isBlock(m)||(a||=l,s&&h&&g===p||h&&Pe.check.isList(p)&&p===c||l.parentNode!==g&&g.insertBefore(l,m)),Pe.utils.removeItem(e),s&&null===d&&(d=l.children.length-1),h&&(this.#J.format.getBlock(p,u)!==this.#J.format.getBlock(c,u)||Pe.check.isList(p)&&Pe.check.isList(c)&&Pe.query.getNodeDepth(p)!==Pe.query.getNodeDepth(c))&&(l=Pe.utils.createElement(i,{style:"list-style-type: "+n})),0===f?.children.length&&Pe.utils.removeItem(f)}else Pe.utils.removeItem(e);d&&(a=a.children[d]),o&&(l.innerHTML+=c.innerHTML,Pe.utils.removeItem(c))}else{if(s)for(let t=0,e=r.length;t<e;t++)for(let s=t-1;s>=0;s--)if(r[s].contains(r[t])){r.splice(t,1),t--,e--;break}const t=this.#J.format.getBlock(l),e=t?.tagName===i;let o,a;const h=t=>!Pe.check.isComponentContainer(t);e||(a=Pe.utils.createElement(i,{style:"list-style-type: "+n}));for(let t,l,c=0,d=r.length;c<d;c++)l=this.#J.format.getBlock(r[c],h),l&&Pe.check.isList(l)&&(t?t!==l?(s&&Pe.check.isListCell(l.parentNode)?this.#Dt(o.f):p=this.#J.format.removeBlock(o.f[0].parentElement,{selectedFormats:o.f,newBlockElement:a,shouldDelete:!1,skipHistory:!0}),l=r[c].parentNode,e||(a=Pe.utils.createElement(i,{style:"list-style-type: "+n})),t=l,o={r:t,f:[Pe.query.getParentElement(r[c],"LI")]}):o.f.push(Pe.query.getParentElement(r[c],"LI")):(t=l,o={r:t,f:[Pe.query.getParentElement(r[c],"LI")]}),c===d-1&&(s&&Pe.check.isListCell(l.parentNode)?this.#Dt(o.f):p=this.#J.format.removeBlock(o.f[0].parentElement,{selectedFormats:o.f,newBlockElement:a,shouldDelete:!1,skipHistory:!0})))}return this.#t.set("_lastSelectionNode",null),g&&d&&p||u}remove(t,e){let s={},i=!1,n=!1,o=null,r=null;const l=t=>!Pe.check.isComponentContainer(t);for(let a,h,c,d,u=0,p=t.length;u<p;u++){if(c=u===p-1,h=this.#J.format.getBlock(t[u],l),d=Pe.check.isList(h),!a&&d)a=h,s={r:a,f:[Pe.query.getParentElement(t[u],"LI")]},0===u&&(i=!0);else if(a&&d)if(a!==h){const l=this.#J.format.removeBlock(s.f[0].parentNode,{selectedFormats:s.f,newBlockElement:null,shouldDelete:e,skipHistory:!0});h=t[u].parentNode,i&&(o=l.sc,i=!1),c&&(r=l.ec),d?(a=h,s={r:a,f:[Pe.query.getParentElement(t[u],"LI")]},c&&(n=!0)):a=null}else s.f.push(Pe.query.getParentElement(t[u],"LI")),c&&(n=!0);if(c&&Pe.check.isList(a)){const t=this.#J.format.removeBlock(s.f[0].parentNode,{selectedFormats:s.f,newBlockElement:null,shouldDelete:e,skipHistory:!0});(n||1===p)&&(r=t.ec),i&&(o=t.sc||r)}}return{sc:o,ec:r}}applyNested(t,e){const s=(t=t||this.#J.format.getLines().filter((function(t){return Pe.check.isListCell(t)}))).length;if(0===s||!e&&!Pe.check.isListCell(t[0].previousElementSibling)&&!Pe.check.isListCell(t.at(-1).nextElementSibling))return{sc:t[0],so:0,ec:t.at(-1),eo:1};let i=t[0].parentElement,n=t.at(-1),o=null;if(e){if(i!==n.parentElement&&Pe.check.isList(n.parentElement?.parentElement)&&n.nextElementSibling)for(n=n.nextElementSibling;n;)t.push(n),n=n.nextElementSibling;o=this.apply(i.nodeName+":"+i.style.listStyleType,t,!0)}else{let e=Pe.utils.createElement(i.nodeName),r=t[0].previousElementSibling,l=n.nextElementSibling;const a={s:null,e:null,sl:i,el:i},{startContainer:h,startOffset:c,endContainer:d,endOffset:u}=this.#J.selection.getRange();for(let n,o=0,h=s;o<h;o++)n=t[o],n.parentElement!==i&&(this.#Ft(i,e,r,l,a),i=n.parentElement,e=Pe.utils.createElement(i.nodeName)),r=n.previousElementSibling,l=n.nextElementSibling,e.appendChild(n);if(this.#Ft(i,e,r,l,a),s>1){const t=Pe.query.getNodeFromPath(a.s,a.sl),e=Pe.query.getNodeFromPath(a.e,a.el);o={sc:t,so:0,ec:e,eo:e.textContent.length}}else o={sc:h,so:c,ec:d,eo:u}}return o}removeNested(t,e){const s=Ds(t);let i,n,o;if(s){i=s.cloneNode(!1),n=s.childNodes;const e=Pe.query.getPositionIndex(t);for(;n[e];)i.appendChild(n[e])}else i=t;if(e)o=Pe.query.getListChildren(i,(t=>Pe.check.isListCell(t)&&!t.previousElementSibling),null);else{const e=Pe.query.getNodeDepth(t)+2;o=Pe.query.getListChildren(t,(t=>Pe.check.isListCell(t)&&!t.previousElementSibling&&Pe.query.getNodeDepth(t)===e),null)}for(let t=0,e=o.length;t<e;t++)Ds(o[t]);return s&&(s.parentNode.insertBefore(i,s.nextSibling),0===n?.length&&Pe.utils.removeItem(s)),i===t?i.parentNode:i}#Ft(t,e,s,i,n){let o=!1;if(e.tagName===s?.tagName){const t=e.children;for(;t[0];)s.appendChild(t[0]);e=s,o=!0}if(e.tagName===i?.tagName){const t=i.children;for(;t[0];)e.appendChild(t[0]);const s=i.nextElementSibling;i.parentNode.removeChild(i),i=s}if(!o){Pe.check.isListCell(s)&&(t=s,i=null),t.insertBefore(e,i),n.s||(n.s=Pe.query.getNodePath(e.firstElementChild.firstChild,t,null),n.sl=t);const o=t.contains(n.sl)?Pe.query.getNodePath(n.sl,t):null;n.e=Pe.query.getNodePath(e.lastElementChild.firstChild,t,null),n.el=t,this.#J.nodeTransform.mergeSameTags(t,[n.s,n.e,o],!1),this.#J.nodeTransform.mergeNestedTags(t),o&&(n.sl=Pe.query.getNodeFromPath(o,t))}return e}#Dt(t){const e=t[0],s=t.at(-1),i=s.nextElementSibling,n=e.parentElement,o=n.parentElement.nextElementSibling,r=n.parentElement.parentElement;for(let e=0,s=t.length;e<s;e++)r.insertBefore(t[e],o);if(i&&n.children.length>0){const t=n.cloneNode(!1),e=n.childNodes,o=Pe.query.getPositionIndex(i);for(;e[o];)t.appendChild(e[o]);s.appendChild(t)}0===n.children.length&&Pe.utils.removeItem(n),this.#J.nodeTransform.mergeSameTags(r);const l=Pe.query.getEdgeChildNodes(e,s);return{cc:e.parentNode,sc:l.sc,ec:l.ec}}},{_d:Hs}=Oe,qs=new RegExp(Re.zeroWidthSpace+"+","g");const Ws=/^<[a-z0-9]+:[a-z0-9]+/i,Us=/(?!<)[a-zA-Z0-9-]+/,Vs=/\s(?:on[a-z]+)\s*=\s*(?:(["'])[^"']*\1|\S+)/gi,js=/style=/i,Gs=/style\s*=\s*(?:"|')[^"']*(?:"|')/,Ks=/class\s*=\s*("|')(?:[^"']*\s)?se-component(?=[\s"'])/i,Ys=/^\s/,Xs=/<[^\s]+\s(.+)/,Zs=/^[ \t\n\r\f\v]+$/,Js=/\ssize="([^"]+)"/i,Qs=/\sface="([^"]+)"/i,ti=/\scolor="([^"]+)"/i,ei=/"/g,si=/([a-zA-Z0-9-]+)(:)([^"']+)/,ii=/inherit|initial|revert|unset/i,ni=/"/g,oi=/:\s*([^;]+)/,ri=/rgba\(([0-9]+\s*,\s*){3}0\)|windowtext/i,li=/[^;]+;/g,ai=/^span$/i,hi=/^(?:https?|ftps?|mailto|tel|blob|sms|geo|webcal|callto):|^[#/]|^data:image\//i,ci=/^(?:href|src)\s*=/i,di=/=\s*(?:"([^"]*)"|'([^']*)'|(\S+))/,ui=/:/i;function pi(t){const e=function(t){let e,s=5;do{e=t,t=t.replace(/&(#x([0-9a-f]+)|#([0-9]+)|([a-z]+));/gi,((t,e,s,i)=>s?String.fromCharCode(parseInt(s,16)):i?String.fromCharCode(parseInt(i,10)):""))}while(t!==e&&--s);try{t=decodeURIComponent(t)}catch{}return t.replace(/[\u0000-\u0020]+/g,"")}(t);return hi.test(e)||!ui.test(e)}function gi(t){if(!ci.test(t))return!0;const e=t.match(di);if(!e)return!0;return pi(e[1]??e[2]??e[3]??"")}function mi(t,e){return t?"*"===t?"[a-z-]+":e?t+"|"+e:t:"^"}const fi=class{#J;#t;#X;#Q;#rt;#ut;#Ht;#qt;#Wt;#Ut;#Vt;#jt;#Gt;#Kt;#Yt;#Xt;#Zt;#Jt;#Qt;#te;#ee;#se;#ie;#ne;#oe;#re;constructor(t){this.#J=t.$,this.#t=t.store;const e=this.#rt=this.#J.options;this.#Q=this.#J.frameOptions,this.#X=this.#J.frameContext,this.#ut=this.#J.instanceCheck,this.#qt=function(t){return this.test(t)?t:""}.bind(e.get("allowedClassName")),this.#Qt=e.get("_textStyleTags");const s=e.get("tagStyles"),i={};for(const t in s){const e=t.split("|");for(let n,o=0,r=e.length;o<r;o++)n=e[o],i[n]?i[n]+="|":i[n]="",i[n]+=s[t]}const n=e.get("formatLine").reg;for(const t in i){if(t.startsWith("@"))continue;const e=n.test(t)?"@line":this.#Qt.includes(t)?"@text":"";e&&s[e]&&(i[t]+=(i[t]?"|":"")+s[e])}for(const t in i)i[t]=new RegExp(`\\s*[^-a-zA-Z](${i[t]})\\s*:[^;]+(?!;)*`,"gi");const o=new Map;for(const t in i)o.set(new RegExp(`^(${t})$`),i[t]);this.#Zt=new RegExp(`^(${Object.keys(i).join("|")})$`,"i"),this.#Jt=o,this.#Ht=new RegExp("\\d+("+e.get("fontSizeUnits").join("|")+")$","i");const r=e.get("_allowedExtraTag"),l=e.get("_disallowedExtraTag");this.#te=new RegExp(`<(${l})[^>]*>([\\s\\S]*?)<\\/\\1>|<(${l})[^>]*\\/?>`,"gi"),this.#ee=new RegExp(`^(${l})$`,"i"),this.#se=new RegExp(`^(${r})$`,"i"),this.#ie=new RegExp(`<${e.get("defaultLine")}(?:\\s[^>]*)?></${e.get("defaultLine")}>`,"i");const a=Object.keys(e.get("_defaultStyleTagMap")),h=e.get("elementWhitelist")?e.get("elementWhitelist").split("|").filter((t=>/b|i|ins|s|strike/i.test(t))):[];for(let t=0;t<h.length;t++)a.splice(a.indexOf(h[t].toLowerCase()),1);this.#Ut=0===a.length?null:new RegExp("(<\\/?)("+a.join("|")+")\\b\\s*([^>^<]+)?\\s*(?=>)","gi");const c=e.get("__defaultAttributeWhitelist");this.#Wt=e.get("_editorElementWhitelist").includes("//")||"*"===e.get("_editorElementWhitelist"),this.#Vt=new RegExp("^("+mi(e.get("_editorElementWhitelist").replace("|//",""),"")+")$","i"),this.#jt=new RegExp("^("+(e.get("elementBlacklist")||"^")+")$","i"),this.#Gt=ze.createElementWhitelist(mi(e.get("_editorElementWhitelist").replace("|//","|\x3c!--|--\x3e"),"")),this.#Kt=ze.createElementBlacklist(e.get("elementBlacklist").replace("|//","|\x3c!--|--\x3e"));const d='\\s*=\\s*(")[^"]*\\1',u=e.get("attributeWhitelist");let p={},g="";if(u)for(const t in u)/^on[a-z]+$/i.test(u[t])||("*"===t?g=mi(u[t],c):p[t]=new RegExp("\\s(?:"+mi(u[t],c)+")"+d,"ig"));this.#Yt=new RegExp("\\s(?:"+(g||c)+"|data-se-[^\\s]+"+(e.get("v2Migration")?"|data-index|data-file-size|data-file-name|data-exp|data-font-size":"")+")"+d,"ig"),this.#ne=p;const m=e.get("attributeBlacklist");if(p={},g="",m)for(const t in m)"*"===t?g=mi(m[t],""):p[t]=new RegExp("\\s(?:"+mi(m[t],"")+")"+d,"ig");this.#Xt=new RegExp("\\s(?:"+(g||"^")+")"+d,"ig"),this.#oe=p,this.__resetAutoStyleify(e.get("autoStyleify"))}filter(t,{tagWhitelist:e,tagBlacklist:s,validate:i,validateAll:n}){if(e&&(t=t.replace(ze.createElementWhitelist(e),"")),s&&(t=t.replace(ze.createElementBlacklist(s),"")),i){const e=(new DOMParser).parseFromString(t,"text/html");e.body.querySelectorAll("*").forEach((t=>{if(n||!t.closest(".se-component")&&!t.closest(".se-flex-component")){const e=i(t);null===e?t.remove():this.#ut.isNode(e)?t.replaceWith(e):"string"==typeof e&&(t.outerHTML=e)}})),t=e.body.innerHTML}return t}clean(t,{forceFormat:e,whitelist:s,blacklist:i,_freeCodeViewMode:n}={}){const{tagFilter:o,formatFilter:r,classFilter:l,textStyleTagFilter:a,attrFilter:h,styleFilter:c}=this.#rt.get("strictMode");let d="";if(t=this.compress(t),o&&(t=t.replace(this.#te,""),t=this.#le(t,this.#Gt,this.#Kt).replace(/<br\/?>$/i,"")),this.#re){const e=(new DOMParser).parseFromString(t,"text/html");Pe.query.getListChildNodes(e.body,ze.spanToStyleNode.bind(null,this.#re),null),t=e.body.innerHTML}(h||c)&&(t=t.replace(/(<[a-zA-Z0-9-]+)[^>]*(?=>)/g,this.#ae.bind(this,h,c)));const u=Hs.createRange().createContextualFragment(t);if(o)try{this.#he(u,this.#Vt,this.#jt,o,r,l,n)}catch(t){console.warn("[SUNEDITOR.html.clean.fail]",t.message)}const p=u.querySelectorAll("[data-se-iframe-holder]");for(let t=0,e=p.length;t<e;t++){const e=Pe.utils.createElement("iframe"),s=JSON.parse(p[t].getAttribute("data-se-iframe-holder-attrs"));for(const[t,i]of Object.entries(s))/^on/i.test(t)||("src"!==t||pi(String(i)))&&e.setAttribute(t,i);p[t].replaceWith(e)}if(this.#J.pluginManager.applyRetainFormat(u),r){let t=u.childNodes;e||=this.#ce(t),e&&(t=this.#de(u).childNodes);for(let s,i=0,n=t.length;i<n;i++)s=t[i],this.#se.test(s.nodeName)?d+=s.outerHTML:d+=this.#ue(s,e)}return d||=t,o&&(s&&(d=d.replace("string"==typeof s?ze.createElementWhitelist(s):s,"")),i&&(d=d.replace("string"==typeof i?ze.createElementBlacklist(i):i,""))),a&&(d=this.#pe(d)),!n&&d.includes(Re.zeroWidthSpace)&&(d=d.replace(qs,((t,e,s)=>{const i=0===e||">"===s[e-1],n=e+t.length===s.length||"<"===s[e+t.length];return i&&n?t:""}))),r&&!n&&(d=this.#ge(d)),d}insert(t,{selectInserted:e,skipCharCount:s,skipCleaning:i}={}){this.#X.get("wysiwyg").contains(this.#J.selection.get().focusNode)||this.#J.focusManager.focus(),this.remove(),this.#J.focusManager.focus();let n=null;if("string"==typeof t){i||(t=this.clean(t,{forceFormat:!1,whitelist:null,blacklist:null}));try{if(Pe.check.isListCell(this.#J.format.getLine(this.#J.selection.getNode(),null))){const e=Hs.createRange().createContextualFragment(t).childNodes;this.#ce(e)&&(t=this.#me(e))}const i=Hs.createRange().createContextualFragment(t).childNodes;if(!s){const t="byte-html"===this.#Q.get("charCounter_type")?"outerHTML":"textContent";let e="";for(let s=0,n=i.length;s<n;s++)e+=i[s][t];if(!this.#J.char.check(e))return}let o,r,l,a,h;for(;o=i[0];)3===a?.nodeType&&1===r?.nodeType&&Pe.check.isBreak(o)?(a=o,Pe.utils.removeItem(o)):(l=this.insertNode(o,{afterNode:r,skipCharCount:!0}),r=l.container||l,h||=l,a=o);3===a?.nodeType&&1===r?.nodeType&&(r=a);const c=3===r.nodeType?l.endOffset||r.textContent.length:r.childNodes.length;n=r,e?this.#J.selection.setRange(h.container||h,h.startOffset||0,r,c):this.#J.component.is(r)||this.#J.selection.setRange(r,c,r,c)}catch(t){if(this.#X.get("isReadOnly")||this.#X.get("isDisabled"))return;throw Error(`[SUNEDITOR.html.insert.error] ${t.message}`)}}else if(this.#J.component.is(t))this.#J.component.insert(t,{skipCharCount:s,insertBehavior:"none"});else{let e=null;(this.#J.format.isLine(t)||Pe.check.isMedia(t))&&(e=this.#J.format.getLine(this.#J.selection.getNode(),null)),this.insertNode(t,{afterNode:e,skipCharCount:s})}if(this.#t.set("_lastSelectionNode",null),n){const t=Pe.query.getListChildNodes(n,null,null);if(t.length>0){n=t.at(-1);const e=3===n?.nodeType?n.textContent.length:1;this.#J.selection.setRange(n,e,n,e)}else this.#J.focusManager.focus()}else this.#J.focusManager.focus();this.#J.history.push(!1)}insertNode(t,{afterNode:e,skipCharCount:s}={}){let i=null;if(this.#X.get("isReadOnly")||!s&&!this.#J.char.check(t))return i;let n=null,o=null;if(e){const t=this.#J.format.isLine(e)||this.#J.format.isBlock(e)||this.#J.component.is(e)?this.#J.format.addLine(e,null):e;o=this.#J.selection.setRange(t,1,t,1)}else o=this.#J.selection.getRange();let r,l,a,h=Pe.check.isListCell(o.commonAncestorContainer)?o.commonAncestorContainer:this.#J.format.getLine(this.#J.selection.getNode(),null),c=Pe.check.isListCell(h)&&(Pe.check.isListCell(t)||Pe.check.isList(t)),d=null;const u=this.#J.format.isBrLine(h),p=this.#J.format.isLine(t)||this.#J.format.isBlock(t)||this.#J.component.isBasic(t);if(c&&(a=e||Pe.check.isList(t)?h.lastChild:h.nextElementSibling,d=Pe.check.isList(t)?h:(a||h).parentNode),!e&&(p||this.#J.component.isBasic(t)||Pe.check.isMedia(t))){const t=Pe.check.isEdgePoint(o.endContainer,o.endOffset,"end"),s=this.remove(),i=s.container,n=i===s.prevContainer&&o.collapsed?null:s.prevContainer;if(c&&n)if(d=3===n.nodeType?n.parentNode:n,d.contains(i)){let t=!0;for(a=i;a.parentNode&&a.parentNode!==d;)a=a.parentNode,t=!1;t&&i===n&&(a=a.nextSibling)}else a=null;else if(c&&Pe.check.isListCell(i)&&!h.parentElement)h=Pe.utils.createElement("LI"),d.appendChild(h),i.appendChild(d),a=null;else if(3===i.nodeType||Pe.check.isBreak(i)||c){const n=Pe.query.getParentElement(i,(t=>this.#J.format.isBlock(t)||Pe.check.isListCell(t)));if(e=this.#J.nodeTransform.split(i,s.offset,n?Pe.query.getNodeDepth(n)+1:0))if(c){if(h.contains(i)){const s=Pe.check.isList(h.lastElementChild);let i=null;t||(i=h.cloneNode(!1),i.appendChild(e.textContent.trim()?e:Pe.utils.createTextNode(Re.zeroWidthSpace))),s&&(i||(i=h.cloneNode(!1),i.appendChild(Pe.utils.createTextNode(Re.zeroWidthSpace))),i.appendChild(h.lastElementChild)),i&&(h.parentNode.insertBefore(i,h.nextElementSibling),a=e=i)}}else e=e.previousSibling;else Pe.check.isListCell(h)||(a=e=h)}}o=e||p?this.#J.selection.getRange():this.#J.selection.getRangeAndAddLine(this.#J.selection.getRange(),null);const g=o.commonAncestorContainer,m=o.startOffset,f=o.endOffset,v=o.startContainer===g&&this.#J.format.isLine(g),b=v&&(g.childNodes[m]||g.childNodes[0])||o.startContainer,y=v&&(g.childNodes[f]||g.childNodes[g.childNodes.length-1])||o.endContainer;if(!c)if(e)r=e.parentNode,e=e.nextSibling,l=!0;else if(r=b,3===b.nodeType&&(r=b.parentNode),o.collapsed)if(3===g.nodeType)e=g.textContent.length>f?g.splitText(f):g.nextSibling;else if(Pe.check.isBreak(r))e=r,r=r.parentNode;else{const s=r.childNodes[m],i=3===s?.nodeType&&Pe.check.isZeroWidth(s)&&Pe.check.isBreak(s.nextSibling)?s.nextSibling:s;i?!i.nextSibling&&Pe.check.isBreak(i)?(r.removeChild(i),e=null):e=Pe.check.isBreak(i)&&!Pe.check.isBreak(t)?i:i.nextSibling:e=null}else{if(b===y){e=Pe.check.isEdgePoint(y,f)?y.nextSibling:y.splitText(f);let t=b;Pe.check.isEdgePoint(b,m)||(t=b.splitText(m)),r.removeChild(t),0===r.childNodes.length&&p&&(r.innerHTML="<br>")}else{const s=this.remove(),i=s.container,n=s.prevContainer;if(0===i?.childNodes.length&&p&&(this.#J.format.isLine(i)?i.innerHTML="<br>":this.#J.format.isBlock(i)&&(i.innerHTML="<"+this.#rt.get("defaultLine")+"><br></"+this.#rt.get("defaultLine")+">")),Pe.check.isListCell(i)&&3===t.nodeType)r=i,e=null;else if(!p&&n)if(r=3===n.nodeType?n.parentNode:n,r.contains(i)){let t=!0;for(e=i;e.parentNode&&e.parentNode!==r;)e=e.parentNode,t=!1;t&&i===n&&(e=e.nextSibling)}else e=null;else Pe.check.isWysiwygFrame(i)&&!this.#J.format.isLine(t)?(r=i.appendChild(Pe.utils.createElement(this.#rt.get("defaultLine"))),e=null):r=(e=p?y:i===n?i.nextSibling:i)&&e.parentNode?e.parentNode:g;for(;e&&!this.#J.format.isLine(e)&&e.parentNode!==g;)e=e.parentNode}}try{const s=this.#X.get("wysiwyg");if(!c){if((Pe.check.isWysiwygFrame(e)||r===s.parentNode)&&(r=s,e=null),this.#J.format.isLine(t)||this.#J.format.isBlock(t)||!Pe.check.isListCell(r)&&this.#J.component.isBasic(t)){const t=r;if(Pe.check.isListCell(e))r=e.previousElementSibling||e;else if(!l&&!e){const t=this.remove(),s=3===t.container.nodeType?Pe.check.isListCell(this.#J.format.getLine(t.container,null))?t.container:this.#J.format.getLine(t.container,null)||t.container.parentNode:t.container,i=Pe.check.isWysiwygFrame(s)||this.#J.format.isBlock(s);r=i?s:s.parentNode,e=i?null:s.nextSibling}0===t.childNodes.length&&r!==t&&Pe.utils.removeItem(t)}if(!p||u||this.#J.format.isBlock(r)||Pe.check.isListCell(r)||Pe.check.isWysiwygFrame(r)||(e=r.nextElementSibling,r=r.parentNode),Pe.check.isWysiwygFrame(r)&&(3===t.nodeType||Pe.check.isBreak(t))){const e=Pe.utils.createElement(this.#rt.get("defaultLine"),null,t);n=t,t=e}}if(c?d.parentNode?(r=d,e=a):(r=s,e=null):e=r===e?r.lastChild:e,Pe.check.isListCell(t)&&!Pe.check.isList(r)){if(Pe.check.isListCell(r))e=r.nextElementSibling,r=r.parentNode;else{const t=Pe.utils.createElement("ol");r.insertBefore(t,e),r=t,e=null}c=!0}if(this.#fe(t,r),r.insertBefore(t,e),c)if(Pe.check.isZeroWidth(h.textContent.trim()))Pe.utils.removeItem(h),t=t.lastChild;else{const e=Pe.utils.arrayFind(h.children,Pe.check.isList);e&&(t!==e?(t.appendChild(e),t=e.previousSibling):(r.appendChild(t),t=r),Pe.check.isZeroWidth(h.textContent.trim())&&Pe.utils.removeItem(h))}}catch(e){r.appendChild(t),console.warn("[SUNEDITOR.html.insertNode.warn]",e)}finally{n&&(t=n);const e=r.querySelectorAll("[data-duple]");if(e.length>0)for(let s,i,n,o,r=0,l=e.length;r<l;r++){for(s=e[r],n=s.childNodes,o=s.parentNode;n[0];)i=n[0],o.insertBefore(i,s);s===t&&(t=i),Pe.utils.removeItem(s)}if((this.#J.format.isLine(t)||this.#J.component.isBasic(t))&&b===y){const t=this.#J.format.getLine(g,null);1===t?.nodeType&&Pe.check.isEmptyLine(t)&&Pe.utils.removeItem(t)}if(u&&!Pe.check.isList(t)&&(this.#J.format.isLine(t)||this.#J.format.isBlock(t))&&(t=this.#ve(t)),!this.#J.component.isBasic(t)){let e=1;if(3===t.nodeType)e=t.textContent.length,this.#J.selection.setRange(t,e,t,e);else if(!Pe.check.isBreak(t)&&!Pe.check.isListCell(t)&&this.#J.format.isLine(r)){let s=null;t.previousSibling&&!Pe.check.isBreak(t.previousSibling)||(s=Pe.utils.createTextNode(Re.zeroWidthSpace),t.parentNode.insertBefore(s,t)),t.nextSibling&&!Pe.check.isBreak(t.nextSibling)||(s=Pe.utils.createTextNode(Re.zeroWidthSpace),t.parentNode.insertBefore(s,t.nextSibling)),this.#J.inline._isIgnoreNodeChange(t)&&(t=t.nextSibling,e=0),this.#J.selection.setRange(t,e,t,e)}}i=t}return i}remove(){this.#J.selection.resetRangeToTextNode();const t=this.#J.selection.getRange(),e=0===t.startOffset,s=Pe.check.isEdgePoint(t.endContainer,t.endOffset,"end");let i=null,n=null,o=null;e&&(n=this.#J.format.getLine(t.startContainer),i=n?n.previousElementSibling:null,n=n?i:n),s&&(o=this.#J.format.getLine(t.endContainer),o=o?o.nextElementSibling:o);let r,l=0,a=t.startContainer,h=t.endContainer,c=t.startOffset,d=t.endOffset;const u=3===t.commonAncestorContainer.nodeType&&t.commonAncestorContainer.parentNode===a.parentNode?a.parentNode:t.commonAncestorContainer;if(Pe.check.isWysiwygFrame(a)&&Pe.check.isWysiwygFrame(h)){this.set("");return{container:this.#J.selection.getNode(),offset:0,commonCon:u}}if(u===a&&u===h){if(this.#J.component.isBasic(u)){const t=this.#J.component.get(u).container,e=t.parentElement,s=t.nextSibling||t.previousSibling,i=s===t.previousSibling?s?.textContent?.length||1:0,n=e.nextElementSibling||e.previousElementSibling,o=n===e.previousElementSibling?n?.textContent?.length||1:0;return Pe.utils.removeItem(t),this.#J.format.isLine(e)?0===e.childNodes.length?(Pe.utils.removeItem(e),{container:n,offset:o,commonCon:u}):{container:s,offset:i,commonCon:u}:{container:n,offset:o,commonCon:u}}if(1===u.nodeType&&0===c&&1===d||3===u.nodeType&&0===c&&d===u.textContent.length){const t=Pe.query.getNextDeepestNode(u,this.#X.get("wysiwyg")),e=Pe.query.getPreviousDeepestNode(u,this.#X.get("wysiwyg")),s=this.#J.format.getLine(u);Pe.utils.removeItem(u);let i=t||e,n=t?0:3===i?.nodeType?i.textContent.length:1;const o=this.#J.format.getLine(i)||this.#J.component.get(i);return s!==o&&(i=o,n=0===n?0:1),Pe.check.isZeroWidth(s)&&!s.contains(i)&&Pe.utils.removeItem(s),{container:i,offset:n,commonCon:u}}a=u.children[c],h=u.children[d],c=d=0}if(!a||!h)return{container:u,offset:0,commonCon:u};if(a===h&&t.collapsed&&Pe.check.isZeroWidth(a.textContent?.substring(c)))return{container:a,offset:c,prevContainer:a&&a.parentNode?a:null,commonCon:u};let p=null,g=null;const m=Pe.query.getListChildNodes(u,null,null);let f=Pe.utils.getArrayIndex(m,a),v=Pe.utils.getArrayIndex(m,h);if(m.length>0&&f>-1&&v>-1){for(let t=f+1,e=a;t>=0;t--)m[t]===e.parentNode&&m[t].firstChild===e&&0===c&&(f=t,e=e.parentNode);for(let t=v-1,e=h;t>f;t--)m[t]===e.parentNode&&1===m[t].nodeType&&(m.splice(t,1),e=e.parentNode,--v)}else{if(0===m.length){if(this.#J.format.isLine(u)||this.#J.format.isBlock(u)||Pe.check.isWysiwygFrame(u)||Pe.check.isBreak(u)||Pe.check.isMedia(u))return{container:u,offset:0,commonCon:u};if(Pe.check.isText(u))return{container:u,offset:d,commonCon:u};m.push(u),a=h=u}else if(a=h=m[0],Pe.check.isBreak(a)||Pe.check.isZeroWidth(a))return{container:Pe.check.isMedia(u)?u:a,offset:0,commonCon:u};f=v=0}const b=Pe.check.isText,y=Pe.check.isElement,w=f===v;let C=null;for(let t=f;t<=v;t++){const e=m[t];if(!b(e)||void 0!==e.data&&0!==e.length)if(e!==a)if(e!==h)C=this.#be(e,w);else{if(b(h))g=Pe.utils.createTextNode(h.substringData(d,h.length-d));else{if(this.#J.component.is(h))continue;g=Pe.utils.createTextNode(h.textContent)}g.length>0?h.data=g.data:C=this.#be(h,w)}else{if(y(a)){if(this.#J.component.is(a))continue;p=Pe.utils.createTextNode(a.textContent)}else{const t=a,s=h;e===h?(p=Pe.utils.createTextNode(t.substringData(0,c)+s.substringData(d,s.length-d)),l=c):p=Pe.utils.createTextNode(t.substringData(0,c))}if(p.length>0?a.data=p.data:C=this.#be(a,w),e===h)break}else C=this.#be(e,w)}const _=Pe.query.getParentElement(h,"ul"),k=Pe.query.getParentElement(a,"li");if(_&&k&&k.contains(_)?(r=_.previousSibling,l=r.textContent.length):(r=h&&h.parentNode?h:a&&a.parentNode?a:t.endContainer||t.startContainer,(e||s)&&(s?1===r.nodeType&&0===r.childNodes.length?(r.appendChild(Pe.utils.createElement("BR")),l=1):l=r.textContent.length:l=0)),this.#J.format.getLine(r)||a&&a.parentNode||(o?(r=o,l=0):n&&(r=n,l=1)),!Pe.check.isWysiwygFrame(r)&&0===r.childNodes.length){const t=this.#J.nodeTransform.removeAllParents(r,null,null);t&&(r=t.sc||t.ec||this.#X.get("wysiwyg"))}return r&&(1!==r.nodeType||this.#J.format.isLine(r)||Pe.check.isBreak(r))||(r=C?.sc||C?.ec,l=3===r?.nodeType?r.textContent.length:1),this.#J.selection.setRange(r,l,r,l),{container:r,offset:l,prevContainer:i,commonCon:u?.parentElement?u:null}}get({withFrame:t,includeFullPage:e,rootKey:s}={}){s?Array.isArray(s)||(s=[s]):s=[this.#t.get("rootKey")];const i=this.#t.get("rootKey"),n={};for(let i,o=0,r=s.length;o<r;o++){this.#J.facade.changeFrameContext(s[o]);const r=Pe.utils.createElement("DIV",null,this._convertToCode(this.#X.get("wysiwyg"),!0)),l=r.querySelectorAll(".se-placeholder-line");for(let t=0,e=l.length;t<e;t++)l[t].classList.remove("se-placeholder-line"),l[t].removeAttribute("data-se-placeholder-line"),l[t].getAttribute("class")||l[t].removeAttribute("class");const a=Pe.check.isTableCell,h=Pe.check.isEmptyLine,c=[],d=[];Pe.query.getListChildren(r,(t=>{t.hasAttribute("contenteditable")&&c.push(t);const e=t.parentElement;return a(e)&&e.children.length<=1&&h(t)&&d.push(e),!1}),null);for(let t=0,e=c.length;t<e;t++)c[t].removeAttribute("contenteditable");for(let t=0,e=d.length;t<e;t++)d[t].innerHTML="<br>";this.#ye(r);const u=r.innerHTML;if(this.#Q.get("iframe_fullPage"))if(e){const t=Pe.utils.getAttributesToString(this.#X.get("_wd").body,["contenteditable"]);i=`<!DOCTYPE html><html>${this.#X.get("_wd").head.outerHTML}<body ${t}>${u}</body></html>`}else i=u;else i=t?`<div class="${this.#rt.get("_editableClass")+""+(this.#rt.get("_rtl")?" se-rtl":"")}">${u}</div>`:r.innerHTML;n[s[o]]=i}return this.#J.facade.changeFrameContext(i),s.length>1?n:n[s[0]]}set(t,{rootKey:e}={}){this.#J.ui.offCurrentController(),this.#J.selection.removeRange();const s=null==t?"":this.clean(t,{forceFormat:!0,whitelist:null,blacklist:null});e?Array.isArray(e)||(e=[e]):e=[this.#t.get("rootKey")];for(let t=0;t<e.length;t++)if(this.#J.facade.changeFrameContext(e[t]),this.#X.get("isMarkdownView")){const t=ze.htmlToJson(s);this.#X.get("markdown").value=qe.jsonToMarkdown(t)}else if(this.#X.get("isCodeView")){const t=this._convertToCode(s,!1);this.#J.viewer._setCodeView(t)}else this.#X.get("wysiwyg").innerHTML=s,this.#J.pluginManager.resetFileInfo(),this.#J.history.push(!1,e[t])}add(t,{rootKey:e}={}){this.#J.ui.offCurrentController(),e?Array.isArray(e)||(e=[e]):e=[this.#t.get("rootKey")];for(let s=0;s<e.length;s++){this.#J.facade.changeFrameContext(e[s]);const i=this.clean(t,{forceFormat:!0,whitelist:null,blacklist:null});if(this.#X.get("isMarkdownView")){const t=ze.htmlToJson(i);this.#X.get("markdown").value+="\n"+qe.jsonToMarkdown(t)}else if(this.#X.get("isCodeView"))this.#J.viewer._setCodeView(this.#J.viewer._getCodeView()+"\n"+this._convertToCode(i,!1));else{const t=Pe.utils.createElement("DIV",null,i),n=Array.from(t.children);for(let t=0,e=n.length;t<e;t++)this.#X.get("wysiwyg").appendChild(n[t]);this.#J.history.push(!1,e[s]),this.#J.selection.scrollTo(n.at(-1))}}}getJson({withFrame:t,rootKey:e}={}){return ze.htmlToJson(this.get({withFrame:t,rootKey:e}))}setJson(t,{rootKey:e}={}){this.set(ze.jsonToHtml(t),{rootKey:e})}async copy(t){try{return!("string"!=typeof t&&!Pe.check.isElement(t)&&!Pe.check.isText(t))&&(!1===await He.write(t)?(this.#J.ui.showToast(this.#J.lang.message_copy_fail,this.#rt.get("toastMessageTime").copy,"error"),!1):(this.#J.ui.showToast(this.#J.lang.message_copy_success,this.#rt.get("toastMessageTime").copy),!0))}catch(t){return console.error("[SUNEDITOR.html.copy.fail] :",t),this.#J.ui.showToast(this.#J.lang.message_copy_fail,this.#rt.get("toastMessageTime").copy,"error"),!1}}setFullPage(t,{rootKey:e}={}){if(!this.#Q.get("iframe"))return!1;e?Array.isArray(e)||(e=[e]):e=[this.#t.get("rootKey")];for(let s=0;s<e.length;s++)this.#J.facade.changeFrameContext(e[s]),t.head&&(this.#X.get("_wd").head.innerHTML=t.head.replace(this.#te,"")),t.body&&(this.#X.get("_wd").body.innerHTML=this.clean(t.body,{forceFormat:!0,whitelist:null,blacklist:null})),this.#J.pluginManager.resetFileInfo()}compress(t){return t.replace(/>\s+</g,"> <").replace(/\n/g,"").trim()}_convertToCode(t,e){let s="";const i=RegExp,n=new i("^(BLOCKQUOTE|PRE|TABLE|THEAD|TBODY|TR|TH|TD|OL|UL|IMG|IFRAME|VIDEO|AUDIO|FIGURE|FIGCAPTION|HR|BR|CANVAS|SELECT)$","i"),o="string"==typeof t?Hs.createRange().createContextualFragment(t):t,r=t=>this.#J.format.isLine(t)||this.#J.component.is(t),l=e?"":"\n",a=e?0:1*this.#t.get("codeIndentSize"),h=a>0?new Array(a+1).join(" "):"";return function t(e,o){const a=e?.childNodes;if(!a)return;const c=n.test(e.nodeName),d=c?o:"";for(let u,p,g,m,f,v,b=0,y=a.length;b<y;b++)u=a[b],m=n.test(u.nodeName),p=m?l:"",g=!r(u)||c||/^(TH|TD)$/i.test(e.nodeName)?"":l,8!==u.nodeType?3!==u.nodeType?0!==u.childNodes.length?u.outerHTML?(f=u.nodeName.toLowerCase(),v=d||m?o:"",s+=(g||(c?"":p))+v+u.outerHTML.match(i("<"+f+"[^>]*>","i"))[0]+p,t(u,o+h+""),s+=(/\n$/.test(s)?v:"")+"</"+f+">"+(g||p||c||/^(TH|TD)$/i.test(u.nodeName)?l:"")):s+=(new XMLSerializer).serializeToString(u):s+=(/^HR$/i.test(u.nodeName)?l:"")+(/^PRE$/i.test(u.parentElement.nodeName)&&/^BR$/i.test(u.nodeName)?"":d)+u.outerHTML+p:Pe.check.isList(u.parentElement)||(s+=ze.htmlToEntity(/^\n+$/.test(u.data)?"":u.data)):s+="\n\x3c!-- "+u.textContent.trim()+" --\x3e"+p}(o,""),s.trim()+l}#be(t,e){const s=this.#J.format.getLine(t,null);if(Pe.utils.removeItem(t),!Pe.check.isListCell(s)||e)return;const i=this.#J.nodeTransform.removeAllParents(s,null,null);return Pe.check.isList(s?.firstChild)&&s.insertBefore(Pe.utils.createTextNode(Re.zeroWidthSpace),s.firstChild),i?{sc:i.sc,ec:i.ec}:null}#ve(t){const e=t.parentNode;let s,i;for(;this.#J.format.isLine(t)||this.#J.format.isBlock(t);){for(s=t.childNodes,i=null;s[0];)if(i=s[0],this.#J.format.isLine(i)||this.#J.format.isBlock(i)){if(this.#ve(i),!t.parentNode)break;s=t.childNodes}else e.insertBefore(i,t);0===t.childNodes.length&&Pe.utils.removeItem(t),t=Pe.utils.createElement("BR"),e.insertBefore(t,i.nextSibling)}return t}#ue(t,e){const s=this.#rt.get("defaultLine");if(1===t.nodeType){if(this.#ee.test(t.nodeName))return"";if(Pe.check.isExcludeFormat(t))return t.outerHTML;const i=Pe.query.getListChildNodes(t,(t=>Pe.check.isSpanWithoutAttr(t)&&!Pe.query.getParentElement(t,Pe.check.isExcludeFormat)),null)||[];for(let t,e=i.length-1;e>=0;e--)t=i[e],t.replaceWith(...t.childNodes);if(!e||this.#J.format.isLine(t)||this.#J.format.isBlock(t)||this.#J.component.is(t)||Pe.check.isMedia(t)||Pe.check.isFigure(t)||Pe.check.isAnchor(t)&&Pe.check.isMedia(t.firstElementChild)){const e=t;return Pe.check.isSpanWithoutAttr(t)?e.innerHTML:e.outerHTML}{const e=t;return"<"+s+">"+(Pe.check.isSpanWithoutAttr(t)?e.innerHTML:e.outerHTML)+"</"+s+">"}}if(3===t.nodeType){if(!e)return ze.htmlToEntity(t.textContent);const i=t.textContent.split(/\n/g);let n="";for(let t,e=0,o=i.length;e<o;e++)t=i[e].trim(),t.length>0&&(n+="<"+s+">"+ze.htmlToEntity(t)+"</"+s+">");return n}return 8===t.nodeType&&this.#Wt?"\x3c!--"+t.textContent.trim()+"--\x3e":""}#ge(t){if(!this.#ie.test(t))return t;const e=Pe.utils.createElement("DIV",null,t),s=e.querySelectorAll(this.#rt.get("defaultLine"));let i=!1;for(let t=s.length-1;t>=0;t--)s[t].firstChild||(Pe.utils.removeItem(s[t]),i=!0);return i?e.innerHTML:t}#we(t){return!t||11===t.nodeType||Pe.check.isWysiwygFrame(t)||Pe.check.isList(t)||Pe.check.isTableElements(t)||this.#J.format.isBlock(t)}#he(t,e,s,i,n,o,r){const l=[],a=[],h=[],c=[],d=Pe.query.getListChildNodes(t,(d=>{if(1!==d.nodeType)return n&&Pe.check.isList(d.parentElement)&&l.push(d),3===d.nodeType&&(!d.textContent||Zs.test(d.textContent)&&(this.#we(d.parentNode)||!d.previousSibling!=!d.nextSibling))&&l.push(d),!1;if(i&&(s.test(d.nodeName)||!e.test(d.nodeName)&&0===d.childNodes.length&&Pe.check.isExcludeFormat(d)))return l.push(d),!1;"PRE"===d.nodeName&&this.#Ce(d);const u=!Pe.query.getParentElement(d,Pe.check.isExcludeFormat);if(n){if(!Pe.check.isTableElements(d)&&!Pe.check.isListCell(d)&&!Pe.check.isAnchor(d)&&(this.#J.format.isLine(d)||this.#J.format.isBlock(d)||this.#J.format.isTextStyleNode(d))&&0===d.childNodes.length&&u)return a.push(d),!1;if(Pe.check.isList(d.parentNode)&&!Pe.check.isList(d)&&!Pe.check.isListCell(d))return h.push(d),!1;if(Pe.check.isTableCell(d)){const t=d.firstElementChild;if(!this.#J.format.isLine(t)&&!this.#J.format.isBlock(t)&&!this.#J.component.is(t))return c.push(d),!1}}if(o&&u&&d.className){const t=Array.from(d.classList).map(this.#qt).join(" ").trim();t?d.className=t:d.removeAttribute("class")}if(!n)return!1;return!r&&d.parentNode!==t&&u&&(Pe.check.isListCell(d)&&!Pe.check.isList(d.parentNode)||(this.#J.format.isLine(d)||this.#J.component.is(d))&&!this.#J.format.isBlock(d.parentNode)&&!Pe.query.getParentElement(d,this.#J.component.is.bind(this.#J.component)))}),null);for(let t=0,e=l.length;t<e;t++)Pe.utils.removeItem(l[t]);const u=[];for(let t,e,s=0,i=d.length;s<i;s++)if(t=d[s],e=t.parentNode,e&&e.parentNode)if(Pe.query.getParentElement(t,Pe.check.isListCell)){const s=t.childNodes;for(let i=s.length-1;i>=0;i--)e.insertBefore(s[i],t);u.push(t)}else{const s=e.nextSibling;let i=null;if(t.nextSibling)for(i=e.cloneNode(!1);t.nextSibling;)i.appendChild(t.nextSibling);e.parentNode.insertBefore(t,s),i&&(e.parentNode.insertBefore(i,s),u.push(i)),u.push(e)}for(let t,e=0,s=u.length;e<s;e++)t=u[e],Pe.check.isZeroWidth(t.textContent.trim())&&Pe.utils.removeItem(t);for(let t=0,e=a.length;t<e;t++)Pe.utils.removeItem(a[t]);for(let t,e,s,i,n=0,o=h.length;n<o;n++)if(t=h[n],i=t.parentNode,i)if(e=Pe.utils.createElement("LI"),this.#J.format.isLine(t)){for(s=t.childNodes;s[0];)e.appendChild(s[0]);i.insertBefore(e,t),Pe.utils.removeItem(t)}else t=t.nextSibling,e.appendChild(h[n]),i.insertBefore(e,t);if(n){const e=Pe.query.getListChildNodes(t,(t=>Pe.check.isListCell(t)&&!Pe.check.isList(t.parentNode)),null);for(let t,s,i,n,o=0,r=e.length;o<r;o++)if(t=e[o],!Pe.check.isList(t.parentNode))for(s=Pe.utils.createElement("UL"),t.parentNode.insertBefore(s,t),i=t;i&&(Pe.check.isListCell(i)||3===i.nodeType&&!i.textContent.trim());)n=i.nextSibling,s.appendChild(i),i=n}for(let t,e,s=0,i=c.length;s<i;s++){for(t=c[s],e=Pe.utils.createElement("DIV");t.firstChild;)e.appendChild(t.firstChild);if(0===e.textContent.trim().length&&this.#_e(e)){let t=e;for(;t.firstElementChild;)t=t.firstElementChild;t.innerHTML="<br>"}t.appendChild(e)}}#_e(t){const e=t.querySelectorAll("*"),s=this.#J.format;for(let t=0;t<e.length;t++)if(!s.isTextStyleNode(e[t]))return!1;return!0}#pe(t){if(!this.#Ut)return t;const e=this.#rt.get("_defaultStyleTagMap");return t.replace(this.#Ut,((t,s,i,n)=>s+("string"==typeof e[i]?e[i]:i)+(n?" "+n:"")))}#de(t){let e,s="";const i=t.childNodes;for(let t,n=0,o=i.length;n<o;n++)t=i[n],this.#se.test(t.nodeName)?s+=t.outerHTML:8===t.nodeType?s+="\x3c!-- "+t.textContent+" --\x3e":/meta/i.test(t.nodeName)||this.#J.format.isLine(t)||this.#J.format.isBlock(t)||this.#J.component.is(t)||Pe.check.isExcludeFormat(t)?(e&&(s+=e.outerHTML,e=null),s+=t.outerHTML):(e||=Pe.utils.createElement(this.#rt.get("defaultLine")),this.#J.format.isTextStyleNode(t)&&t.removeAttribute("style"),e.appendChild(t),n--,o--);return e&&(s+=e.outerHTML),Hs.createRange().createContextualFragment(s)}#me(t){let e="";for(let s,i=0,n=t.length;i<n;i++)s=t[i],1===s.nodeType?Pe.check.isList(s)?e+=s.innerHTML:Pe.check.isListCell(s)?e+=s.outerHTML:this.#J.format.isLine(s)?e+="<li>"+(s.innerHTML.trim()||"<br>")+"</li>":this.#J.format.isBlock(s)&&!Pe.check.isTableElements(s)?e+=this.#me(s.children):e+="<li>"+s.outerHTML+"</li>":e+="<li>"+(s.textContent||"<br>")+"</li>";return e}#ce(t){let e=!1;for(let s,i=0,n=t.length;i<n;i++)if(s=t[i],1===s.nodeType&&!this.#J.format.isTextStyleNode(s)&&!Pe.check.isBreak(s)&&!this.#ee.test(s.nodeName)){e=!0;break}return e}#ke(t,e,s){let i=(t.match(Gs)||[])[0];if(this.#Qt.includes(s)&&!i&&(t.match(Xs)||[])[1]){const e=(t.match(Js)||[])[1],s=(t.match(Qs)||[])[1],n=(t.match(ti)||[])[1];(e||s||n)&&(i='style="'+(e?"font-size:"+De.get(Number(e)/3.333,1)+"rem;":"")+(s?"font-family:"+s+";":"")+(n?"color:"+n+";":"")+'"')}if(i){let t;e||=[];for(const[e,i]of this.#Jt)if(e.test(s)){t=i;break}if(!t)return e;const n=i.replace(ei,"").match(t);if(!n)return e;const o=[];for(let t,e=0,s=n.length;e<s;e++)if(t=n[e].match(si),t&&!ii.test(t[3])){const e=ze.kebabToCamelCase(t[1].trim()),s=this.#X.get("wwComputedStyle")[e]?.replace(ni,""),i=t[3].trim();switch(e){case"fontFamily":if(!this.#J.plugins.font||!this.#J.plugins.font.fontArray.includes(i))continue;break;case"fontSize":if(!this.#J.plugins.fontSize)continue;this.#Ht.test(t[0])||(t[0]=t[0].replace((t[0].match(oi)||[])[1],ze.toFontUnit.bind(null,this.#rt.get("fontSizeUnits")[0])));break;case"color":if(!this.#J.plugins.fontColor||ri.test(i))continue;break;case"backgroundColor":if(!this.#J.plugins.backgroundColor||ri.test(i))continue}s!==i&&o.push(t[0])}o.length>0&&e.push('style="'+o.join(";")+'"')}return e}#le(t,e,s){return e.test("<font>")&&(t=t.replace(/(<\/?)font(\s?)/gi,"$1span$2")),t.replace(e,"").replace(s,"")}#fe(t,e){const s=t=>{this.#xe(t,e);const i=t.childNodes;for(let t=0,e=i.length;t<e;t++)s(i[t])};s(t)}#xe(t,e){if(!this.#J.format.isTextStyleNode(t))return;const s=(t.style.cssText.match(li)||[]).map((function(t){return t.trim()})),i=t.nodeName;if(ai.test(i)&&0===s.length)return t;const n=this.#J.format;let o=!1;return function e(r){if(!Pe.check.isWysiwygFrame(r)&&n.isTextStyleNode(r)){if(r.nodeName===i){o=!0;const e=r.style.cssText.match(li)||[];for(let t,i=0,n=e.length;i<n;i++)(t=s.indexOf(e[i].trim()))>-1&&s.splice(t,1);for(let e=0,s=r.classList.length;e<s;e++)t.classList.remove(r.classList[e])}e(r.parentElement)}}(e),o&&((t.style.cssText=s.join(" "))||(t.setAttribute("style",""),t.removeAttribute("style")),0===t.attributes.length&&t.setAttribute("data-duple","true")),t}#ae(t,e,s,i){if(Ws.test(s))return s;let n=null;const o=i.match(Us)[0].toLowerCase();if(t){const t=this.#oe[o];s=s.replace(Vs,""),s=t?s.replace(t,""):s.replace(this.#Xt,"");const e=this.#ne[o];n=e?s.match(e):s.match(this.#Yt)}if(!e)return s;if("a"===o){const t=s.match(/(?:(?:id|name)\s*=\s*(?:"|')[^"']*(?:"|'))/g);t&&(n||=[],n.push(t[0]))}else n&&js.test(n.toString())||(Ks.test(s)?n=this.#ke(s,n,"@component"):this.#Zt.test(o)?n=this.#ke(s,n,o):this.#J.format.isLine(o)?n=this.#ke(s,n,"@line"):this.#Qt.includes(o)&&(n=this.#ke(s,n,"@text")));if(Pe.check.isMedia(o)||Pe.check.isFigure(o)){const t=s.match(Gs);n||=[],t&&n.push(t[0])}if(n)for(let t,e=0,s=n.length;e<s;e++)t=gi(n[e].trim())?n[e]:"",i+=(Ys.test(t)?"":" ")+t;return i}__resetAutoStyleify(t){if(t.length>0){const e=this.#rt.get("convertTextTags"),s={};t.forEach((t=>{switch(t){case"bold":s.bold={regex:/font-weight\s*:\s*bold/i,tag:e.bold};break;case"italic":s.italic={regex:/font-style\s*:\s*italic/i,tag:e.italic};break;case"underline":s.underline={regex:/text-decoration\s*:\s*underline/i,tag:e.underline};break;case"strike":s.strike={regex:/text-decoration\s*:\s*line-through/i,tag:e.strike}}})),this.#re=s}else this.#re=null}_destroy(){this.#Jt&&this.#Jt.clear()}#Ce(t){if(1!==t.children.length||"CODE"!==t.firstElementChild?.nodeName)return;const e=t.firstElementChild,s=(e.className||"").match(/language-(\S+)/);for(s&&(Pe.utils.addClass(t,"language-"+s[1]),t.setAttribute("data-se-lang",s[1]));e.firstChild;)t.insertBefore(e.firstChild,e);t.removeChild(e)}#ye(t){const e=t.querySelectorAll('pre[class*="language-"]');for(let t,s,i,n=0,o=e.length;n<o;n++)if(t=e[n],s=(t.className.match(/language-(\S+)/)||[])[1],s){for(i=Pe.utils.createElement("CODE",{class:"language-"+s});t.firstChild;)i.appendChild(t.firstChild);t.appendChild(i),t.className=t.className.replace(/\s*language-\S+/g,"").trim(),t.removeAttribute("data-se-lang")}}};const vi=class{#J;#rt;constructor(t){this.#J=t.$,this.#rt=this.#J.options}split(t,e,s){if(Pe.check.isWysiwygFrame(t)||this.#J.component.is(t)||!t)return t;if(e&&!De.is(e)){const s=t.childNodes;let i=Pe.query.getPositionIndex(e);const n=t.cloneNode(!1),o=t.cloneNode(!1);for(let t=0,e=s.length;t<e;t++){if(t<i)n.appendChild(s[t]);else{if(!(t>i))continue;o.appendChild(s[t])}t--,e--,i--}return n.childNodes.length>0&&t.parentNode.insertBefore(n,t),o.childNodes.length>0&&t.parentNode.insertBefore(o,t.nextElementSibling),t}const i=t.parentNode;let n,o,r,l=0,a=1,h=!0;if((!s||s<0)&&(s=0),Pe.check.isText(t)){if(l=Pe.query.getPositionIndex(t),(e=Number(e))>=0&&t.length!==e){t.splitText(e);const s=Pe.query.getNodeFromPath([l+1],i);Pe.check.isZeroWidth(s)&&(s.data=Re.zeroWidthSpace)}}else if(1===t.nodeType){if(0===e){for(;t.firstChild;)t=t.firstChild;if(3===t.nodeType){const e=Pe.utils.createTextNode(Re.zeroWidthSpace);t.parentNode.insertBefore(e,t),t=e}}t.previousSibling?t=t.previousSibling:Pe.query.getNodeDepth(t)===s&&(h=!1)}1===t.nodeType&&(a=0);let c=t;for(;Pe.query.getNodeDepth(c)>s;){if(l=Pe.query.getPositionIndex(c)+a,c=c.parentNode,r=n,n=c.cloneNode(!1),o=c.childNodes,r)if(Pe.check.isListCell(n)&&Pe.check.isList(r)&&r.firstElementChild){const t=r.firstElementChild;for(;t.firstChild;)n.appendChild(t.firstChild);Pe.utils.removeItem(t),r.children.length>0&&n.appendChild(r)}else n.appendChild(r);for(;o[l];)n.appendChild(o[l])}1===c.nodeType&&c.childNodes.length<=1&&!c.firstChild?.textContent?.length&&(c.innerHTML="<br>");const d=c.parentNode;return h&&(c=c.nextSibling),n?(this.mergeSameTags(n,null,!1),this.mergeNestedTags(n,Pe.check.isList),n.childNodes.length>0?d.insertBefore(n,c):n=c,Pe.check.isListCell(n)&&n.children&&Pe.check.isList(n.children[0])&&n.insertBefore(Pe.utils.createElement("BR"),n.children[0]),0===i.childNodes.length&&Pe.utils.removeItem(i),n):c}mergeSameTags(t,e,s){const i=e?e.length:0;let n=null;i&&(n=Array.apply(null,new Array(i)).map(Number.prototype.valueOf,0));const o=(t,r,l)=>{const a=t.childNodes;for(let h,c,d=0,u=a.length;d<u&&(h=a[d],c=a[d+1],h);d++)if(!(Pe.check.isBreak(h)||Pe.check.isMedia(h)||Pe.check.isInputElement(h)))if(s&&this.#J.inline._isIgnoreNodeChange(h)||!s&&(Pe.check.isTableElements(h)||Pe.check.isListCell(h)||this.#J.format.isLine(h)&&!this.#J.format.isBrLine(h)))(Pe.check.isTableElements(h)||Pe.check.isListCell(h))&&o(h,r+1,d);else{if(1===u&&t.nodeName===h.nodeName&&t.parentNode){if(i){let s,n,o,l,a;for(let c=0;c<i;c++)if(s=e[c],s&&s[r]===d){for(n=h,o=t,l=r,a=!0;l>=0;){if(Pe.utils.getArrayIndex(o.childNodes,n)!==s[l]){a=!1;break}n=h.parentNode,o=n.parentNode,l--}a&&(s.splice(r,1),s[r]=d)}}Pe.utils.copyTagAttributes(h,t),t.parentNode.insertBefore(h,t),Pe.utils.removeItem(t)}if(!c){1===h.nodeType&&o(h,r+1,d);break}if(h.nodeName===c.nodeName&&Pe.check.isSameAttributes(h,c)&&h.getAttribute?.("href")===c.getAttribute?.("href")){const t=h.childNodes;let s=0;for(let e=0,i=t.length;e<i;e++)t[e].textContent.length>0&&s++;const o=h.lastChild,a=c.firstChild;let u=0;if(o&&a){const t=3===o.nodeType&&3===a.nodeType;u=o.textContent.length;let h=o.previousSibling;for(;h&&3===h.nodeType;)u+=h.textContent.length,h=h.previousSibling;if(s>0&&3===o.nodeType&&3===a.nodeType&&(o.textContent.length>0||a.textContent.length>0)&&s--,i){let h=null;for(let c=0;c<i;c++)if(h=e[c],h&&h[r]>d){if(r>0&&h[r-1]!==l)continue;h[r]-=1,h[r+1]>=0&&h[r]===d&&(h[r+1]+=s,t&&o&&3===o.nodeType&&a&&3===a.nodeType&&(n[c]+=u))}}}if(3===h.nodeType){if(u=h.textContent.length,h.textContent+=c.textContent,i){let t=null;for(let o=0;o<i;o++)if(t=e[o],t&&t[r]>d){if(r>0&&t[r-1]!==l)continue;t[r]-=1,t[r+1]>=0&&t[r]===d&&(t[r+1]+=s,n[o]+=u)}}}else{for(;c.firstChild;)h.appendChild(c.firstChild);h.normalize()}Pe.utils.removeItem(c),d--}else 1===h.nodeType&&o(h,r+1,d)}};return o(t,0,0),n}mergeNestedTags(t,e){if("string"==typeof e){const t=new RegExp(`^(${e||".+"})$`,"i");e=e=>t.test(e.nodeName)}else"function"!=typeof e&&(e=()=>!0);!function t(s){let i=s.children;if(1===i.length&&i[0].nodeName===s.nodeName&&e(s)){const t=i[0];for(i=t.children;i[0];)s.appendChild(i[0]);s.removeChild(t)}for(let e=0,i=s.children.length;e<i;e++)t(s.children[e])}(t)}removeAllParents(t,e,s){if(!t)return null;let i=null;return e||=t=>{if(t===s||this.#J.component.is(t))return!1;const e=t.textContent.trim();return 0===e.length||/^(\n|\u200B)+$/.test(e)},function t(s){if(!Pe.check.isWysiwygFrame(s)){const n=s.parentNode;n&&e(s)&&(i={sc:s.previousElementSibling,ec:s.nextElementSibling},Pe.utils.removeItem(s),t(n))}}(t),i}removeEmptyNode(t,e,s){const i=this.#rt.get("allowedEmptyTags");e&&=Pe.query.getParentElement(e,(e=>t===e.parentElement));const n=s=>{if(this.#J.format._isNotTextNode(s)||s===e||Pe.check.isNonEditable(s))return 0;if(s===t||!Pe.check.isZeroWidth(s.textContent)||s.firstChild&&Pe.check.isBreak(s.firstChild)||s.querySelector(i)){const t=s.children;for(let e=0,s=t.length,i=0;e<s;e++)t[e+i]&&!this.#J.component.is(t[e+i])&&(i+=n(t[e+i]))}else if(s.parentNode)return s.parentNode.removeChild(s),-1;return 0};n(t),0===t.childNodes.length&&(s?Pe.utils.removeItem(t):t.innerHTML="<br>")}createNestedNode(t,e){"function"!=typeof e&&(e=()=>!0);const s=t[0].cloneNode(!1);let i=s;for(let s,n=1,o=t.length;n<o;n++)e(t[n])&&(s=t[n].cloneNode(!1),i.appendChild(s),i=s);return i.innerHTML="",{parent:s,inner:i}}};function bi(t){t&&!ct(t,"se-blink")&&(dt(t,"se-blink"),o.setTimeout((()=>{ut(t,"se-blink")}),600))}const yi=class{#J;#X;#Q;constructor(t){this.#J=t.$,this.#X=this.#J.frameContext,this.#Q=this.#J.frameOptions}check(t){const e=this.#Q.get("charCounter_max");if(e){const s=this.getLength("string"==typeof t?t:"byte-html"===this.#Q.get("charCounter_type")&&1===t.nodeType?t.outerHTML:t.textContent);if(s>0&&s+this.getLength()>e)return bi(this.#X.get("charWrapper")),!1}return!0}getLength(t){return"string"!=typeof t&&(t="byte-html"===this.#Q.get("charCounter_type")?this.#X.get("wysiwyg").innerHTML:this.#X.get("wysiwyg").textContent),/byte/.test(this.#Q.get("charCounter_type"))?this.getByteLength(t):t.length}getByteLength(t){if(!t||!t.toString)return 0;let e,s;return t=t.toString(),u?(s=decodeURIComponent(encodeURIComponent(t)).length,e=0,null!==encodeURIComponent(t).match(/(%0A|%0D)/gi)&&(e=encodeURIComponent(t).match(/(%0A|%0D)/gi).length),s+e):(s=(new TextEncoder).encode(t).length,e=0,null!==encodeURIComponent(t).match(/(%0A|%0D)/gi)&&(e=encodeURIComponent(t).match(/(%0A|%0D)/gi).length),s+e)}getWordCount(t){"string"!=typeof t&&(t=this.#X.get("wysiwyg").innerText);const e=t.trim();return e?e.split(/\s+/).length:0}display(t){const e=t||this.#X,s=e.get("charCounter"),i=e.get("wordCounter");(s||i)&&o.setTimeout((()=>{s&&(s.textContent=String(this.getLength())),i&&(i.textContent=String(this.getWordCount()))}),0)}test(t,e){let s=0;t&&(s=this.getLength(t)),this.display();const i=this.#Q.get("charCounter_max");if(i>0){let t=!1;const n=this.getLength();if(n>i){if(t=!0,s>0&&e){this.#J.selection.init();const t=this.#J.selection.getRange(),e=t.endOffset-1,s=this.#J.selection.getNode().textContent,i=t.endOffset-1;this.#J.selection.getNode().textContent=s.slice(0,i<0?0:i)+s.slice(t.endOffset,s.length),this.#J.selection.setRange(t.endContainer,e,t.endContainer,e)}}else n+s>i&&(t=!0);if(t&&(bi(this.#X.get("charWrapper")),s>0))return!1}return!0}};const wi=class{#J;#rt;#$e=!1;constructor(t){this.#J=t.$,this.#rt=this.#J.options,this.keyMap=new Map,this.reverseKeys=new Set}command(t,e,s,i,n,o,r,l){if(this.#$e)return!1;let a=null;return a=e?this.keyMap.get(i+(s?"1000":"")):this.keyMap.get(n)||this.keyMap.get(n+t.key),!(!a||!s&&a.s||a.space&&!Fe.isSpace(i)||a.enter&&!Fe.isEnter(i)||a.textTrigger&&!t.key.trim()||a.edge&&!o)&&(a.plugin&&"string"==typeof a.method?this.#J.plugins[a.plugin][a.method]?.({range:l,line:r,info:a,event:t,keyCode:i}):"function"==typeof a.method?a.method({range:l,line:r,info:a,event:t,keyCode:i}):this.#J.commandDispatcher.run(a.command,a.type,a.button),!0)}disable(){this.#$e=!0}enable(){this.#$e=!1}_registerShortcuts(){const t=this.#rt.get("shortcuts"),e=this.#rt.get("_reverseCommandArray"),s=this.keyMap=new Map,i=this.reverseKeys;for(const n of Object.keys(t)){if(this.#J.plugins[n])continue;is(n.startsWith("_")?"":n,null,t[n],s,e,i)}}_destroy(){this.keyMap.clear(),this.reverseKeys.clear()}},Ci=new Map([["__figureInst",null],["__dragInst",null],["__dragHandler",null],["__dragContainer",null],["__dragCover",null],["__dragMove",null],["__overInfo",null]]),_i=Ci,{_w:ki,isMobile:xi,ON_OVER_COMPONENT:$i}=Oe,Si="2147483646",Ei="2147483645",Ti="2147483642",Mi="2147483641",Ni={left:0,right:0,top:0};let Bi=null;const Ii=class{#J;#Se;#Ee;#Te;#Me=Ni;#Ne=!1;#Be=!1;#Ie=null;#Le=null;#Ae=null;#Oe=[];#Re=new Map;constructor(t,e,s,i,n){this.#J=e,this.kind=n||t.constructor.key||t.constructor.name,this.host=t,this.form=s,this.isOpen=!1,this.currentTarget=null,this.currentPositionTarget=null,this.isWWTarget=i.isWWTarget??!0,this.position=i.position||"bottom",this.disabled=!!i.disabled,this.parents=i.parents||[],this.parentsForm=[],this.parentsHide=!!i.parentsHide,this.sibling=i.sibling||null,this.siblingMain=!!i.siblingMain,this.isInsideForm=!!i.isInsideForm,this.isOutsideForm=!!i.isOutsideForm,this.toTop=!1,this.__offset={},this.#Se="function"==typeof i.initMethod?i.initMethod:null,this.#Ee="function"==typeof i.escGuard?i.escGuard:null,this.#Te={keydown:this.#ze.bind(this),mousedown:this.#Pe.bind(this)};for(const t of this.parents)Pe.check.isElement(t)?this.parentsForm.push(t):(t.#Oe.push(this),this.parentsForm.push(t.form));this.form.setAttribute("popover","manual"),this.#J.contextProvider.carrierWrapper.appendChild(s),this.#J.eventManager.addEvent(s,"click",this.#De.bind(this)),this.#J.eventManager.addEvent(s,"mouseenter",this.#Fe.bind(this)),this.#J.eventManager.addEvent(s,"mouseleave",this.#He.bind(this))}open(t,e,{isWWTarget:s,passive:i,initMethod:n,disabled:o,addOffset:r}={}){if(Ci.get("__overInfo")===$i&&(i=!0),!t)return void console.warn("[SUNEDITOR.Controller.open.fail] The target element is required.");if(this.form.removeAttribute("data-se-hidden-by-parent"),this.form.removeAttribute("data-se-hidden-by-children"),this.#Re.clear(),i||(this.#J.store.mode.isBalloon?this.#J.toolbar.hide():this.#J.store.mode.isSubBalloon&&this.#J.subToolbar.hide(),this.#J.store.get("hasFocus")||(o??this.disabled?this.#J.ui.setControllerOnDisabledButtons(!0):this.#J.ui.setControllerOnDisabledButtons(!1))),this.currentPositionTarget=e||t,this.isWWTarget=s??this.isWWTarget,"function"==typeof n&&(this.#Se=n),i||(this.#J.ui.currentControllerName=this.kind),this.#Me={left:0,right:0,top:0,...r},!i){const t=this.isOutsideForm?this.parentsForm:[];this.#J.ui.opendControllers?.forEach((e=>{t.includes(e.form)||(e.form.style.zIndex=Mi)})),this.parentsHide&&this.parentsForm.forEach((t=>{t.style.display="none",t.setAttribute("data-se-hidden-by-children","1")}))}this.#qe(),this.#We(this.form,this.currentPositionTarget,!1);const l=this.#J.instanceCheck.isRange(t);this.currentTarget=l?null:t,this.#Ue(this.form,t,l,i),ki.setTimeout((()=>Ci.set("__overInfo",!1)),0)}close(t){(t||this.isOpen&&!this.#Be)&&(this.form.removeAttribute("data-se-hidden-by-parent"),this.form.removeAttribute("data-se-hidden-by-children"),this.#Re.clear(),this.#Ve("close"),this.toTop=!1,this.isOpen=!1,this.#Be=!1,this.__offset={},this.#Me=Ni,this.#je(),this.#Se?.(),this.#Ge(),this.parentsHide&&!t&&this.parentsForm.forEach((t=>{t.style.display="block",t.removeAttribute("data-se-hidden-by-children")})),this.host.controllerClose?.(),this.parentsForm.length>0||this.#J.component.deselect())}hide(){this.#Ve("hide"),this.form.style.display="none"}show(){this.#We(this.form,this.currentPositionTarget,!1)}bringToTop(t){this.toTop=t,this.form.style.zIndex=t?Si:Ei}resetPosition(t){this.#We(this.form,t||this.currentPositionTarget,!0)}_scrollReposition(){this.form.hasAttribute("data-se-hidden-by-parent")||this.form.hasAttribute("data-se-hidden-by-children")||this.#We(this.form,this.currentPositionTarget,!1)&&ki.setTimeout((()=>{this.#Ve("show")}),0)}#Ve(t){for(const e of this.#Oe)if("hide"===t&&"none"!==e.form.style.display){const t=this.#Ke(e);e.#Re.set(this,!0);const s=this.#Ke(e);!t&&s&&(e.form.setAttribute("data-se-hidden-by-parent","1"),e.hide())}else if("show"===t){if(e.form.hasAttribute("data-se-hidden-by-children")){e.#Ve("show");continue}const t=this.#Ke(e);e.#Re.set(this,!1);const s=this.#Ke(e);t&&!s&&(e.form.removeAttribute("data-se-hidden-by-parent"),e.show())}else e[t]?.(!0)}#Ke(t){for(const e of t.#Re.values())if(!0===e)return!0;return!1}async#Ue(t,e,s,i){const n={position:this.position,inst:this,form:t,target:e,isRangeTarget:s,notInCarrier:!this.#J.contextProvider.carrierWrapper.contains(t)};!1!==await this.#J.eventManager.triggerEvent("onBeforeShowController",{caller:this.kind,frameContext:this.#J.frameContext,info:n})&&(t.style.display="block",this.#J.contextProvider.shadowRoot&&(this.#Ie=this.#J.eventManager.addEvent(t,"mousedown",(t=>t.stopPropagation()))),i||(this.#J.ui.onControllerContext(),this.#J.store.set("controlActive",!0),this.#J.store.set("_preventBlur",!0)),this.isOpen||this.#J.ui.opendControllers.push(n),this.isOpen=!0,this.host.controllerOn?.(t,e),this.#J.eventManager.triggerEvent("onShowController",{caller:this.kind,frameContext:this.#J.frameContext,info:n}))}#Ge(){Bi===this&&(Bi=null),this.form.hidePopover?.(),this.form.style.display="none",this.#J.ui.opendControllers=this.#J.ui.opendControllers.filter((t=>t.form!==this.form)),this.#J.ui.currentControllerName!==this.kind&&this.#J.ui.opendControllers.length>0||(this.#J.ui.setControllerOnDisabledButtons(!1),this.#J.ui.offControllerContext(),this.#J.frameContext.get("lineBreaker_t").style.display=this.#J.frameContext.get("lineBreaker_b").style.display="none",this.#J.store.set("_lastSelectionNode",null),this.#J.ui.currentControllerName="",this.#J.store.set("_preventBlur",!1),ki.setTimeout((()=>{this.#J.store.set("controlActive",!1)}),0),this.#Ie&&=this.#J.eventManager.removeEvent(this.#Ie))}#We(t,e,s){if(!e)return!1;if(t.style.visibility="hidden",t.style.display="block",this.sibling&&"block"!==this.sibling.style.display&&(this.sibling.style.visibility="hidden",this.sibling.style.display="block"),this.#J.selection.isRange(e)){if(!this.#J.offset.setRangePosition(this.form,e,{position:"bottom"}))return this.hide(),!1}else{const i=this.#J.offset.setAbsPosition(t,e,{addOffset:this.#Me,position:this.position,isWWTarget:this.isWWTarget,inst:this,sibling:this.sibling});if(!i)return this.hide(),!1;if(s||!this.sibling||this.siblingMain)this.#Ne=!1;else{const e=t.offsetTop-this.#Me.top;"bottom"===i.position?(this.#Ne=!0,t.style.top=e+this.sibling.offsetHeight-1+"px"):(this.#Ne=!1,t.style.top=e-this.sibling.offsetHeight+2+"px")}}return t.style.zIndex=this.toTop?Ei:this.#Ne?Ti:Mi,t.style.visibility="",t.showPopover?.(),!0}#qe(){this.#je(),this.#Le=this.#J.eventManager.addGlobalEvent("keydown",this.#Te.keydown,!0),this.#Ae=this.#J.eventManager.addGlobalEvent(xi?"click":"mousedown",this.#Te.mousedown,!0)}#je(){this.#J.component.__removeGlobalEvent(),this.#Le&&=this.#J.eventManager.removeGlobalEvent(this.#Le),this.#Ae&&=this.#J.eventManager.removeGlobalEvent(this.#Ae)}#Ye(){if(this.#J.ui.selectMenuOn)return!0;const t=this.#J.ui.opendControllers;for(let e=0;e<t.length;e++)if(t[e].inst===this&&t[e].fixed)return!0;return!1}#Xe(t){if(Pe.check.isWysiwygFrame(t)||t.contains(this.form))return!1;if(Pe.utils.hasClass(t,"se-drag-handle"))return!0;let e=!1;this.isInsideForm&&this.parentsForm?.length>0&&this.parentsForm.some((s=>{if(s.contains(t))return e=!0,!0}));const s=this.host._element;return!e&&(!!Pe.query.getParentElement(t,".se-controller")||(this.#J.component.isInline(s)?t===s:t?.contains(s)))}#De(t){const e=Pe.query.getEventTarget(t),s=Pe.query.getCommandTarget(e);s&&(t.stopPropagation(),t.preventDefault(),"close"!==s.getAttribute("data-command")?this.host.controllerAction(s):this.close())}#Fe(t){if(this.#J.ui.currentControllerName=this.kind,this.parentsForm.length>0&&this.isInsideForm)return;Pe.query.getEventTarget(t).style.zIndex=this.toTop?Si:Ei,this.sibling&&Bi!==this&&this.form.matches?.(":popover-open")&&(Bi=this,this.form.hidePopover(),this.form.showPopover())}#He(t){if(this.parentsForm.length>0&&this.isInsideForm)return;Pe.query.getEventTarget(t).style.zIndex=this.toTop?Ei:this.#Ne?Ti:Mi}#ze(t){if(this.#Ye())return;const e=t.code;if(Fe.isCtrl(t)||!Fe.isNonResponseKey(e))return;const s=Pe.query.getEventTarget(t);if(Fe.isEsc(e)){if(this.#Oe.some((({isOpen:t})=>t)))return;if(this.#Ee?.())return}else{if(this.form.contains(s)||this.#Xe(s))return;if(this.#J.pluginManager.fileInfo.pluginRegExp.test(this.kind))return}this.#Ze(s),this.close()}#Pe(t){const e=Pe.query.getEventTarget(t);this.host?._element?.contains(e)?this.#Be=!0:(this.#Be=!1,e===this.host._element||e===this.currentTarget||this.#Ye()||this.form.contains(e)||this.#Xe(e)||Pe.query.getParentElement(e,".se-line-breaker-component")||(this.#Ze(e),this.close(!0)))}#Ze(t){this.#J.frameContext.get("wysiwyg").contains(t)||(this.#J.component.__prevent=!1)}},{_w:Li}=Oe;const Ai=class{#J;#Je;#Qe;#ts;#es;#Te;#ss=null;#is=null;#ns=null;#os=null;#rs=null;#Le=null;#ls=null;#as=null;#hs=null;#st=null;#cs=null;#ds=null;#us=new Map;#ps=-1;#gs=-1;#ms=!1;#fs=null;constructor(t,e){this.#J=t;const s=e.position.split("-");this.form=null,this.items=[],this.menus=null,this.menuLen=0,this.index=-1,this.item=null,this.isOpen=!1,this.checkList=!!e.checkList,this.position=s[0],this.subPosition=s[1],this.splitNum=e.splitNum||0,this.horizontal=!!this.splitNum,this.openMethod=e.openMethod,this.closeMethod=e.closeMethod,this.subEscMethod=e.subEscMethod||null,this.subCheckMethod=e.subCheckMethod||null,this.maxHeight=e.maxHeight||"",this.minWidth=e.minWidth||"",this.#os=e.keydownTarget||null,this.#Je=/^(left|right)$/.test(this.position)?"left"===this.position?"right":"left":this.position,this.#Qe=/^(left|right)$/.test(this.subPosition)?"left"===this.subPosition?"right":"left":this.subPosition,this.#ts="ltr"!==e.dir&&("rtl"===e.dir||null),this.#es={mousedown:this.#vs.bind(this),mousemove:this.#bs.bind(this),click:this.#ys.bind(this),keydown:this.#ws.bind(this)},this.#Te={keydown:this.#Cs.bind(this),mousedown:this.#Pe.bind(this),click:this.#_s.bind(this),submenuReposition:this.#ks.bind(this)}}create(t,e){this.#ss.innerHTML="";for(const[,t]of this.#us)t.element?.remove();this.#us.clear(),e||=t;let s="";for(let i=0,n=e.length;i<n;i++){i>0&&i%this.splitNum==0&&(this.#xs(s),s="");const n=t[i],o="string"==typeof e[i]?e[i]:e[i].outerHTML,r=n&&"object"==typeof n?n:{};if(r.children?.length>0){let t="";const e=r.childMenus||r.children;for(let s=0;s<e.length;s++)t+=`<li class="se-select-item" data-parent-index="${i}" data-child-index="${s}">${"string"==typeof e[s]?e[s]:e[s].outerHTML}</li>`;s+=`<li class="se-select-item se-has-submenu" data-index="${i}">${o}<span class="se-submenu-arrow">${this.#J.icons.menu_arrow_right}</span></li>`;const n=Pe.utils.createElement("DIV",{class:"se-select-submenu",popover:"manual","data-parent-index":String(i)},`<ul class="se-list-basic se-list-checked">${t}</ul>`);this.#us.set(i,{items:r.children,menus:e,element:n})}else s+=`<li class="se-select-item" data-index="${i}">${o}</li>`}this.#xs(s);for(const[,t]of this.#us)this.form.appendChild(t.element);this.items=t,this.menus=Array.from(this.form.querySelectorAll("li[data-index]")),this.menuLen=this.menus.length}on(t,e,s={}){this.#is=t,this.#ns=this.#os||(Pe.check.isInputElement(t)?t:this.#J.frameContext.get("_ww")),this.#rs=e;let i="";this.maxHeight&&(i+="max-height:"+this.maxHeight+";overflow-y:auto;"),this.minWidth&&(i+="min-width:"+this.minWidth+";"),this.form=Pe.utils.createElement("DIV",{class:"se-select-menu"+(!0===this.#ts?" se-rtl":"")+(s.class?" "+s.class:""),style:s.style||""},'<div class="se-list-inner"'+(i?' style="'+i+'"':"")+"></div>"),this.#ss=this.form.firstElementChild,t.parentNode.insertBefore(this.form,t)}open(t,e){this.#J.ui.setSelectMenuOpen(this,!0),this.openMethod?.(),this.#$s(),this.#qe();const s=t?t.split("-"):[],i=s[0]||(null!==this.#ts&&this.#ts!==this.#J.options.get("_rtl")?this.#Je:this.position),n=s[1]||(null!==this.#ts&&this.#ts!==this.#J.options.get("_rtl")?this.#Qe:this.subPosition);this.#cs=i,this.#ds=n,this.#Ss(i,n,e),this.isOpen=!0}reposition(){this.isOpen&&this.#cs&&this.#Ss(this.#cs,this.#ds)}setHidden(t){this.isOpen&&(t?(this.#Es(),this.form.style.display="none"):this.reposition())}close(){this.#J.ui.setSelectMenuOpen(this,!1),Pe.utils.removeClass(this.#is,"on"),this.#Ts(),this.form?.removeAttribute("style"),this.#ss&&this.#Ms(),this.isOpen=!1,this.closeMethod?.()}getItem(t){return this.items[t]}setItem(t){this.#Ns(t)}hasOpenSubmenu(){return this.#ps>-1}#Bs(t){if(this.#ps===t)return;this.#Es();const e=this.menus[t];if(!e||!Pe.utils.hasClass(e,"se-has-submenu"))return;Pe.utils.addClass(e,"se-submenu-open"),this.#ps=t,this.#gs=-1,this.#ms=!1;const s=this.#us.get(t),i=s?.element;if(i){const t="function"==typeof i.showPopover;i.style.visibility="hidden",t?i.matches(":popover-open")||i.showPopover():i.style.display="block",this.#Is(e,i,t),i.style.visibility="",this.#hs=this.#J.eventManager.addGlobalEvent("scroll",this.#Te.submenuReposition,!0)}}#Is(t,e,s){const i=s?{top:0,left:0}:this.form.getBoundingClientRect(),n=t.getBoundingClientRect(),o=e.offsetWidth,r=e.offsetHeight,l=Li.innerWidth,a=Li.innerHeight,h=n.right,c=n.left-o,d=Math.max(0,h+o-l),u=Math.max(0,-c);let p;p=!0===this.#ts?0===u?c:0===d?h:u<=d?c+u:h-d:0===d?h:0===u?c:d<=u?h-d:c+u,e.style.left=p-i.left+"px",e.style.right="";const g=n.top,m=n.bottom-r,f=Math.max(0,g+r-a),v=Math.max(0,-m);let b;b=0===f?g:0===v?m:f<=v?g-f:m+v,e.style.top=b-i.top+"px"}#ks(){if(this.#ps<0)return;const t=this.#us.get(this.#ps),e=t?.element,s=this.menus[this.#ps];e&&s&&this.#Is(s,e,"function"==typeof e.showPopover)}#Es(){if(this.#fs&&(Li.clearTimeout(this.#fs),this.#fs=null),this.#hs&&=this.#J.eventManager.removeGlobalEvent(this.#hs),this.#ps>-1){const t=this.menus[this.#ps];t&&Pe.utils.removeClass(t,"se-submenu-open");const e=this.#us.get(this.#ps);e?.element&&("function"==typeof e.element.hidePopover?e.element.matches(":popover-open")&&e.element.hidePopover():e.element.style.display="",Pe.utils.removeClass(e.element.querySelectorAll(".se-select-item"),"se-select-cursor"))}this.#ps=-1,this.#gs=-1,this.#ms=!1}#Ls(t,e){const s=this.#us.get(t);if(s){if(this.checkList){const t=s.element?.querySelectorAll(".se-select-item")[e];t&&Pe.utils.toggleClass(t,"se-checked")}this.#rs(s.items[e])}}#As(t){const e=this.#us.get(this.#ps);if(!e?.element)return;const s=e.element.querySelectorAll(".se-select-item"),i=s.length;if(!i)return;t=this.#gs+t;const n=this.#gs=t>=i?0:t<0?i-1:t;Pe.utils.removeClass(this.form,"se-select-menu-mouse-move");for(let t=0;t<i;t++)t===n?Pe.utils.addClass(s[t],"se-select-cursor"):Pe.utils.removeClass(s[t],"se-select-cursor")}#xs(t){this.#ss.innerHTML+=`<ul class="se-list-basic se-list-checked${this.horizontal?" se-list-horizontal":""}">${t}</ul>`}#Ts(){this.#Os(),this.#je(),this.#Es(),this.index=-1,this.item=null,this._onItem&&(Pe.utils.removeClass(this._onItem,"se-select-on"),this._onItem=null)}#Rs(t){t=this.index+t;const e=this.menuLen,s=this.index=t>=e?0:t<0?e-1:t;this.#Ns(s)}#Ms(){this.form.style.height="",this.#ss.style.maxHeight=this.maxHeight,this.#ss.style.overflowY=this.maxHeight?"auto":""}#zs(t){const e=this.form.offsetHeight-this.#ss.offsetHeight;this.form.style.height=t+"px",this.#ss.style.maxHeight=(t-e>0?t-e:0)+"px",this.#ss.style.overflowY="auto"}#Ps(t){if(!t)return;const e=this.#ss;if(!e.style.maxHeight)return;const s=e.getBoundingClientRect().top+e.clientTop,i=s+e.clientHeight,{top:n,bottom:o}=t.getBoundingClientRect();n<s?e.scrollTop-=s-n:o>i&&(e.scrollTop+=o-i)}#Ns(t){Pe.utils.removeClass(this.form,"se-select-menu-mouse-move");const e=this.menuLen;for(let s=0;s<e;s++)s===t?Pe.utils.addClass(this.menus[s],"se-select-cursor"):Pe.utils.removeClass(this.menus[s],"se-select-cursor");this.index=t,this.item=this.items[t],this.#Ps(this.menus[t])}#Ss(t,e,s,i){const n=t,o=this.form,r=this.#is;o.style.visibility="hidden",o.style.display="block",this.#Ms(),Pe.utils.addClass(r,"on");const l=o.offsetWidth,a=r.offsetWidth,h=r.offsetLeft;let c=!1,d=0,u=0;"left"===t?(d=h-l-1,t=e,c=!0):"right"===t&&(d=h+a+1,t=e,c=!0);const p=this.#J.offset.get(r),g=r.offsetTop,m=p.top,f=r.offsetHeight,v=Pe.utils.getClientSize().h-(m-Li.scrollY+f),b=c?f:0;let y=1e4;switch(t){case"middle":{let t=o.offsetHeight;const e=f/2;u=g-t/2+e,m<t/2&&(u+=t/2-m-e+4,o.style.top=u+"px");let s=this.#J.offset.getGlobal(o).top;const i=t-(m-s)-v-f;i>0&&(u-=i+4,o.style.top=u+"px"),s=this.#J.offset.getGlobal(o).top,s<0&&(t+=s-4,u-=s-4),this.#zs(t);break}case"top":if(m<o.offsetHeight-b){if(!i){y=0;break}y=m-4+b,y>=38&&this.#zs(y)}u=g-o.offsetHeight+b;break;case"bottom":if(v<o.offsetHeight+b){if(!i){y=0;break}y=v-4+b,y>=38&&this.#zs(y)}u=g+(c?0:f)}if(y<38&&!i&&"middle"!==t)return void this.#Ss("top"===t?"bottom":"top",e,s,!0);if(!c)switch(e){case"center":d=h+a/2-l/2;break;case"left":d=h;break;case"right":d=h-(l-a)}o.style.left=d+"px";let w=this.#J.offset.getGlobal(o).fixedLeft,C=0;switch(c+"-"+(c?n:e)){case"true-left":w<0&&(d=h+a+1);break;case"true-right":w+l>Li.innerWidth&&(d=h-l-1);break;case"false-center":C=Li.innerWidth-(w+l),C<0&&(d+=C-4),o.style.left=d+"px",w=this.#J.offset.getGlobal(o).fixedLeft,w<0&&(d-=w-4);break;case"false-left":C=Li.innerWidth-(w+l),C<0&&(d+=C-4);break;case"false-right":w<0&&(d-=w-4)}if(s){const t=this.#ss.querySelector(s);t&&(this._onItem=t,Pe.utils.addClass(t,"se-select-on"))}o.style.left=d+"px",o.style.top=u+"px",o.style.visibility=""}#Ds(t){this.checkList&&Pe.utils.toggleClass(this.menus[t],"se-checked"),this.#rs(this.getItem(t))}#$s(){this.#Os(),this.#st={mousedown:this.#J.eventManager.addEvent(this.form,"mousedown",this.#es.mousedown),mousemove:this.#J.eventManager.addEvent(this.form,"mousemove",this.#es.mousemove),click:this.#J.eventManager.addEvent(this.form,"click",this.#es.click),keydown:this.#J.eventManager.addEvent(this.#ns,"keydown",this.#es.keydown)}}#Os(){this.#st&&(this.#J.eventManager.removeEvent(this.#st.mousedown),this.#J.eventManager.removeEvent(this.#st.mousemove),this.#J.eventManager.removeEvent(this.#st.click),this.#J.eventManager.removeEvent(this.#st.keydown),this.#st=null)}#qe(){this.#je(),this.#Le=this.#J.eventManager.addGlobalEvent("keydown",this.#Te.keydown,!0),this.#ls=this.#J.eventManager.addGlobalEvent("mousedown",this.#Te.mousedown,!0)}#je(){this.#Le&&=this.#J.eventManager.removeGlobalEvent(this.#Le),this.#ls&&=this.#J.eventManager.removeGlobalEvent(this.#ls),this.#as&&=this.#J.eventManager.removeGlobalEvent(this.#as)}#ws(t){if(this.#ms)switch(t.code){case"ArrowUp":return t.preventDefault(),t.stopPropagation(),void this.#As(-1);case"ArrowDown":return t.preventDefault(),t.stopPropagation(),void this.#As(1);case"ArrowLeft":case"ArrowRight":{t.preventDefault(),t.stopPropagation();const e=this.#ps;return this.#Es(),void(e>-1&&this.#Ns(e))}case"Enter":return void(this.#gs>-1&&(t.preventDefault(),t.stopPropagation(),this.#Ls(this.#ps,this.#gs)))}let e;switch(t.code){case"ArrowUp":if(t.preventDefault(),t.stopPropagation(),this.horizontal&&this.index>-1){const t=this.splitNum;e=this.index-t<0?t:-t}else e=-1;break;case"ArrowDown":if(t.preventDefault(),t.stopPropagation(),this.horizontal&&this.index>-1){const t=this.splitNum;e=this.index+t>this.menuLen?-t:t}else e=1;break;case"ArrowLeft":case"ArrowRight":if(t.preventDefault(),t.stopPropagation(),this.#ps>-1){const t=this.#ps;return this.#Es(),void this.#Ns(t)}if(this.subEscMethod?.())return;if(this.index>-1){if(this.#us.has(this.index))return this.#Bs(this.index),this.#ms=!0,void this.#As(1);if(this.subCheckMethod?.(this.index))return void this.#Ds(this.index)}if(!this.horizontal)return;e="ArrowLeft"===t.code?-1:1;break;case"Enter":this.index>-1&&(t.preventDefault(),t.stopPropagation(),this.#us.has(this.index)?(this.#Bs(this.index),this.#ms=!0,this.#As(1)):this.#Ds(this.index))}e&&(this.#Es(),this.subEscMethod?.(),this.#Rs(e))}#vs(t){if(Oe.isGecko){const e=Pe.query.getEventTarget(t),s=Pe.query.getParentElement(e,".se-select-item");s&&this.#J.eventManager._injectActiveEvent(s)}}#bs(t){const e=Pe.query.getEventTarget(t);Pe.utils.addClass(this.form,"se-select-menu-mouse-move");const s=e.closest?.("[data-child-index]"),i=s?.getAttribute("data-child-index");if(null!=i){this.#gs=Number(i);const t=this.#us.get(this.#ps);if(t?.element){const e=t.element.querySelectorAll(".se-select-item");Pe.utils.removeClass(e,"se-select-cursor"),Pe.utils.addClass(e[this.#gs],"se-select-cursor")}return}const n=e.closest?.("[data-index]"),o=n?.getAttribute("data-index");if(!o)return;const r=Number(o);if(this.index=r,this.#us.has(r))this.#fs&&Li.clearTimeout(this.#fs),this.#Bs(r);else if(this.#ps>-1){const t=this.#us.get(this.#ps);t?.element?.contains(e)||this.#Es()}}#ys(t){let e=Pe.query.getEventTarget(t),s=null,i=null;for(;!(s||i||/UL/i.test(e.tagName)||Pe.utils.hasClass(e,"se-select-menu"));)i=e.getAttribute("data-child-index"),i||(s=e.getAttribute("data-index")),e=e.parentElement;if(null!==i){let t=e,s=null;for(;!s&&t;)s=t.getAttribute("data-parent-index")||t.getAttribute("data-index"),t=t.parentElement;return void(null!==s&&this.#Ls(Number(s),Number(i)))}if(!s)return;const n=Number(s);this.#us.has(n)?this.#ps===n?this.#Es():this.#Bs(n):this.#Ds(n)}#Cs(t){if(Fe.isEsc(t.code)){if(this.#ps>-1){t.preventDefault(),t.stopPropagation();const e=this.#ps;return this.#Es(),void this.#Ns(e)}if(this.subEscMethod?.())return t.preventDefault(),void t.stopPropagation();this.close()}}#Pe(t){const e=Pe.query.getEventTarget(t);this.form.contains(e)||this.#J.ui.opendControllers?.some((({form:t})=>t?.contains?.(e)&&!t.contains(this.#is)))||(this.#is.contains(e)?Pe.check.isInputElement(e)||(this.#as=this.#J.eventManager.addGlobalEvent("click",this.#Te.click,!0)):this.close())}#_s(t){this.#as=this.#J.eventManager.removeGlobalEvent(this.#as),t.target===this.#is&&(t.stopPropagation(),this.close())}},{_w:Oi,ON_OVER_COMPONENT:Ri}=Oe,zi={tl:"nwse-resize",tr:"nesw-resize",bl:"nesw-resize",br:"nwse-resize",lw:"ew-resize",th:"ns-resize",rw:"ew-resize",bh:"ns-resize"};let Pi=!1,Di=!1,Fi=0,Hi=0;class qi{#J;#Fs;#Hs;#qs="";#Ws="";#Us=0;#Vs=0;#js=0;#Gs=0;#Ks="__se__float-none|__se__float-left|__se__float-center|__se__float-right";#Ys=!1;#Xs={w:"",h:""};#Zs=null;constructor(t,e,s,i){this.#J=e,this.kind=t.constructor.key||t.constructor.name,this._alignIcons={none:this.#J.icons.format_float_none,left:this.#J.icons.format_float_left,right:this.#J.icons.format_float_right,center:this.#J.icons.format_float_center},this._action={};const n=function(t,e,s){let i=null;if(s?.length>0){const{lang:n,icons:o}=e;i='<div class="se-arrow se-arrow-up"></div>';for(let e,r=0;r<s.length;r++){e=s[r],i+='<div class="se-btn-group">';for(let s,r=0,l=e.length;r<l;r++){if(s=e[r],"function"==typeof s?.action){const e=s;s={c:`__c__${e.command}`,v:e.value||"",l:e.title,i:e.icon},t._action[s.c]=e.action}else if(s=Vi(s),!s)continue;i+=`\n\t\t\t\t\t<button type="button" data-command="${s.c}" data-value="${s.v}" class="se-btn se-tooltip">\n\t\t\t\t\t\t${o[s.i]||s.i}\n\t\t\t\t\t\t<span class="se-tooltip-inner"><span class="se-tooltip-text">${n[s.l]||s.l}</span></span>\n\t\t\t\t\t</button>`}i+="</div>"}}return i?Pe.utils.createElement("DIV",{class:"se-controller se-controller-resizing"},i):null}(this,e,s||[]);if(this.controller=n?new Ii(this,e,n,{position:"bottom",disabled:!0},this.kind):null,n){this.alignButton=n.querySelector('[data-command="onalign"]');const t=function(t,e,s){if(!s)return null;const i=[t._alignIcons.none,t._alignIcons.left,t._alignIcons.center,t._alignIcons.right],n=[e.lang.basic,e.lang.left,e.lang.center,e.lang.right],o=["none","left","center","right"],r=[],l=[];for(let t=0;t<o.length;t++)r.push(`\n\t\t<button type="button" class="se-btn-list se-tooltip" data-command="${o[t]}" data-type="selectMenu" >\n\t\t\t${i[t]}\n\t\t\t<span class="se-tooltip-inner">\n\t\t\t\t<span class="se-tooltip-text">${n[t]}</span>\n\t\t\t</span>\n\t\t</button>`),l.push(o[t]);return{html:r,items:l}}(this,e,this.alignButton);t&&(this.selectMenu_align=new Ai(e,{checkList:!1,position:"bottom-center"}),this.selectMenu_align.on(this.alignButton,this.#Js.bind(this),{class:"se-figure-select-list"}),this.selectMenu_align.create(t.items,t.html)),this.asButton=n.querySelector('[data-command="onas"]');const s=function(t,e){if(!e)return null;const s=[t.icons.as_block,t.icons.as_inline],i=[t.lang.asBlock,t.lang.asInline],n=["block","inline"],o=[],r=[];for(let t=0;t<n.length;t++)o.push(`\n\t\t<button type="button" class="se-btn-list se-tooltip" data-command="${n[t]}" data-type="selectMenu" >\n\t\t\t${s[t]}\n\t\t\t<span class="se-tooltip-inner">\n\t\t\t\t<span class="se-tooltip-text">${i[t]}</span>\n\t\t\t</span>\n\t\t</button>`),r.push(n[t]);return{html:o,items:r}}(e,this.asButton);s&&(this.selectMenu_as=new Ai(e,{checkList:!1,position:"bottom-center"}),this.selectMenu_as.on(this.asButton,this.#Qs.bind(this),{class:"se-figure-select-list"}),this.selectMenu_as.create(s.items,s.html)),this.resizeButton=n.querySelector('[data-command="onresize"]');const i=function(t,e){if(!e)return null;const s=e.getAttribute("data-value").split(","),i=[];for(let e,n,o,r,l=0;l<s.length;l++)o=s[l],e=De.is(o),n=e?"resize_percent"+o:"auto",r=e?o+"%":t.lang.autoSize,i.push('<button type="button" class="se-btn-list" data-command="'+n+'" data-value="'+o+'"><span>'+r+"</span></button>");return{html:i,items:s}}(e,this.resizeButton);i&&(this.selectMenu_resize=new Ai(e,{checkList:!1,position:"bottom-left",dir:"ltr"}),this.selectMenu_resize.on(this.resizeButton,this.#ti.bind(this)),this.selectMenu_resize.create(i.items,i.html))}this.inst=t,this.sizeUnit=i.sizeUnit||"px",this.autoRatio=i.autoRatio,this.isVertical=!1,this.percentageButtons=n?.querySelectorAll('[data-command="resize_percent"]')||[],this.captionButton=n?.querySelector('[data-command="caption"]'),this.align="none",this.as="block",this.__offset={},this._element=null,this._cover=null,this._inlineCover=null,this._container=null,this._caption=null,this._resizeClientX=0,this._resizeClientY=0,this._resize_direction="",this.__containerResizingOff=this.#ei.bind(this),this.__containerResizing=this.#si.bind(this),this.__onContainerEvent=null,this.__offContainerEvent=null,this.#Fs=this.#ii.bind(this),this.#Hs=this.#ni.bind(this),this.#J.eventManager.addEvent(this.alignButton,"click",this.#oi.bind(this)),this.#J.eventManager.addEvent(this.asButton,"click",this.#ri.bind(this)),this.#J.eventManager.addEvent(this.resizeButton,"click",this.#li.bind(this)),this.#J.contextProvider.applyToRoots((t=>{if(!t.get("wrapper").querySelector(".se-controller.se-resizing-container")){const e=function(){const t='\n\t\t<div class="se-resize-dot">\n\t\t\t<span class="tl"></span>\n\t\t\t<span class="tr"></span>\n\t\t\t<span class="bl"></span>\n\t\t\t<span class="br"></span>\n\t\t\t<span class="lw"></span>\n\t\t\t<span class="th"></span>\n\t\t\t<span class="rw"></span>\n\t\t\t<span class="bh"></span>\n\t\t\t<div class="se-resize-display"></div>\n\t\t</div>';return Pe.utils.createElement("DIV",{class:"se-controller se-resizing-container",style:"display: none;"},t)}(),s=e.querySelectorAll(".se-resize-dot > span");t.set("_figure",{main:e,border:e.querySelector(".se-resize-dot"),display:e.querySelector(".se-resize-display"),handles:s}),t.get("wrapper").appendChild(e),this.#J.eventManager.addEvent(s,"mousedown",this.#ai.bind(this))}}))}static CreateContainer(t,e){return Pe.utils.createElement("DIV",{class:"se-component"+(e?" "+e:"")},Pe.utils.createElement("FIGURE",null,t)),qi.GetContainer(t)}static CreateInlineContainer(t,e){return Pe.utils.createElement("SPAN",{class:"se-component se-inline-component"+(e?" "+e:"")},t),qi.GetContainer(t)}static CreateCaption(t,e){const s=Pe.utils.createElement("FIGCAPTION",null,"<div>"+e+"</div>");return t.appendChild(s),s}static GetContainer(t){const e=Pe.query.getParentElement(t,"FIGURE",2),s=Pe.query.getParentElement(t,"SPAN",2),i=e||s;let n=Pe.query.getParentElement(t,(t=>t.parentElement===i),0)||t;if(Pe.check.isAnchor(n)){const t=n.querySelector(":scope > img");t&&(n=t)}return{target:n,container:Pe.query.getParentElement(n,qi.is,3)||e,cover:e,inlineCover:Pe.utils.hasClass(s,"se-inline-component")?s:null,caption:Pe.query.getEdgeChild(n.parentElement,"FIGCAPTION",!1),isVertical:Ui(n)}}static GetRatio(t,e,s){let i=0,n=0;if(/\d+/.test(t+"")&&/\d+/.test(e+"")){if((!De.is(t)&&String(t).replace(/\d+|\./g,"")||s||"px")===(!De.is(e)&&String(e).replace(/\d+|\./g,"")||s||"px")){const s=De.get(t,4),o=De.get(e,4);i=s/o,n=o/s}}return{w:De.get(i,4),h:De.get(n,4)}}static CalcRatio(t,e,s,i){if(i?.w&&i?.h&&/\d+/.test(t+"")&&/\d+/.test(e+"")){const n=!De.is(t)&&String(t).replace(/\d+|\./g,"")||s||"px",o=!De.is(e)&&String(e).replace(/\d+|\./g,"")||s||"px";if(n===o){const s="%"===n?2:0,r=t,l=e;e=De.get(i.h*De.get(r,s),s)+o,t=De.get(i.w*De.get(l,s),s)+n}}return{w:t,h:e}}static is(t){return Pe.check.isComponentContainer(t)||/^(HR)$/.test(t?.nodeName)}close(){this.#J.store.set("_preventBlur",!1),Pe.utils.removeClass(this._cover,"se-figure-selected"),this.#J.component.__removeDragEvent(),this.#hi(),this.controller?.close()}open(t,{nonResizing:e,nonSizeInfo:s,nonBorder:i,figureTarget:n,infoOnly:o}){if(!t)return void console.warn('[SUNEDITOR.modules.Figure.open] The "targetNode" is null.');Ci.get("__overInfo")===Ri&&(i=!0);const r=qi.GetContainer(t),l=r.target;let a=!1;if(!r.container){if(this.#J.options.get("strictMode").formatFilter)return{container:null,cover:null,width:l.style.width||l.width||"",height:l.style.height||l.height||"",isVertical:this.isVertical};r.container=l,r.cover=l,a=!0}Ci.set("__figureInst",this),this.#ci(r);const h=n&&(this._cover||this._container)||l,c=h.offsetWidth||null,d=h.offsetHeight||null,{top:u,left:p,scrollX:g,scrollY:m}=this.#J.offset.getLocal(h),f=(l.getAttribute("data-se-size")||"").split(",");let v=De.get(l.style.width,2)||c,b=De.get(l.style.height,2)||d;this.isVertical&&([v,b]=[b,v]);const y=qi.GetRatio(v,b,this.sizeUnit),w={container:r.container,cover:r.cover,caption:r.caption,align:this.align,ratio:y,isVertical:this.isVertical,w:c||"",h:d||"",t:u,l:p,width:f[0]||"auto",height:f[1]||"auto",originWidth:l.naturalWidth||l.offsetWidth,originHeight:l.naturalHeight||l.offsetHeight};if(this.#qs=w.width,this.#Ws=w.height,o)return w;const C=this.#J.frameContext.get("_figure");this.#J.ui.setFigureContainer(C.main),this.#J.ui.opendControllers=this.#J.ui.opendControllers.filter((t=>t.form!==C.main)),C.main.style.top=u+"px",C.main.style.left=p+"px",C.main.style.width=(this.isVertical?d:c)+"px",C.main.style.height=(this.isVertical?c:d)+"px",C.border.style.top="0px",C.border.style.left="0px",C.border.style.width=(this.isVertical?d:c)+"px",C.border.style.height=(this.isVertical?c:d)+"px",this.__offset={left:p+g,top:u+m},this.#J.ui.opendControllers.push({position:"none",form:C.main,target:h,inst:this,notInCarrier:!0});const _=/%$/.test(l.style.width)&&/%$/.test(r.container.style.width)?De.get(r.container.style.width,0)/100+"":"";for(let t=0,e=this.percentageButtons.length;t<e;t++)this.percentageButtons[t].getAttribute("data-value")===_?Pe.utils.addClass(this.percentageButtons[t],"active"):Pe.utils.removeClass(this.percentageButtons[t],"active");if(this.captionButton&&(r.caption?Pe.utils.addClass(this.captionButton,"active"):Pe.utils.removeClass(this.captionButton,"active")),C.display.style.display=s||this._inlineCover?"none":"",C.border.style.display=i?"none":"",C.main.style.display="block",Ci.get("__overInfo")!==Ri){const t=e?"none":"flex",s=C.handles;for(let e=0,i=s.length;e<i;e++)s[e].style.display=t;if(this.controller){const t=this.getSize(l);Pe.utils.changeTxt(C.display,this.#J.lang["none"===this.align?"basic":this.align]+" ("+t.dw+", "+t.dh+")"),this.#di(),this.#ui(),this.#J.ui._visibleControllers(!0,!0);const e=this.controller.form.querySelectorAll('[data-command="rotate"][data-value="90"], [data-command="rotate"][data-value="-90"], [data-command="caption"], [data-command="onalign"], [data-command="onresize"]'),s=this._inlineCover||a?"none":"";e?.forEach((t=>{t.style.display=s}));const i=this.controller.form.querySelector('[data-command="onas"]');i&&(i.style.display=a?"none":"")}Pe.utils.removeClass(this._cover,"se-figure-over-selected"),this.controller?.open(C.main,null,{initMethod:this.#Fs,isWWTarget:!1,addOffset:null}),Oi.setTimeout((()=>Ci.set("__overInfo",!1)),0)}else Pe.utils.addClass(this._cover,"se-figure-over-selected");return Pe.utils.addClass(this._cover,"se-figure-selected"),this.#js=this.#Us=c,this.#Gs=this.#Vs=d,this._inlineCover||Ci.get("__overInfo")===Ri&&!Pe.utils.hasClass(r.container,"se-input-component")||this.#pi(C.main),w}controllerHide(){this.controller?.hide()}controllerShow(){this.controller?.show()}controllerOpen(t,e){this._element=t,this.controller?.open(t,null,e)}setFigureSize(t,e){/%$/.test(t+"")?this._setPercentSize(t,e):t&&"auto"!==t||e&&"auto"!==e?this._applySize(t,e,""):this.autoRatio?this._setPercentSize(100,this.autoRatio.default||this.autoRatio.current):this._setAutoSize()}setSize(t,e){const s=this.isVertical;s&&([t,e]=[e,t]),this.setFigureSize(t,e),s&&this.setTransform(this._element,t,e,0)}getSize(t){t||=this._element;const e=Ui(t);let s="",i="",n="",o="";if(!t)return{w:s,h:i,dw:n,dh:o};const r=qi.GetContainer(t),l=r.target;return r.container?(s=/%$/.test(l.style.width)?(r.container&&De.get(r.container.style.width,2)||100)+"%":l.style.width,i=r.inlineCover?r.inlineCover.style.height||t.style.height||String(t.height||""):De.get(r.cover?.style.paddingBottom,0)>0&&!e?r.cover?.style.height:/%$/.test(l.style.height)&&/%$/.test(l.style.width)?(r.container&&De.get(r.container.style.height,2)||100)+"%":l.style.height,s||="auto",i||="auto"):this.#J.options.get("strictMode").formatFilter?(s="",i=l.style.height):(s=l.style.width||"auto",i=l.style.height||"auto"),n=e?i:s,o=e?s:i,{w:s,h:i,dw:n,dh:o}}setAlign(t,e){t||=this._element,this.align=e||="none";const s=qi.GetContainer(t);if(!s.cover)return;const i=s.target,n=s.container,o=s.cover;if(/%$/.test(i.style.width)&&"center"===e&&!this.#J.component.isInline(n)?(n.style.minWidth="100%",o.style.width=n.style.width):(n.style.minWidth="",o.style.width=this.isVertical?i.style.height||i.offsetHeight+"px":i.style.width&&"auto"!==i.style.width?i.style.width||"100%":""),Pe.utils.hasClass(n,"__se__float-"+e)||(Pe.utils.removeClass(n,this.#Ks),Pe.utils.addClass(n,"__se__float-"+e)),this.autoRatio){const{w:t,h:e}=this.getSize(this._element);this.__setCoverPaddingBottom(t,e)}this.#di()}convertAsFormat(t,e){t||=this._element,this.as=e||"block";const{container:s,inlineCover:i,target:n}=qi.GetContainer(t),{w:o,h:r}=this.getSize(n),l=Pe.check.isAnchor(n.parentNode)?n.parentNode:null,a=n.cloneNode(!1);a.style.width="",a.style.height="",a.removeAttribute("width"),a.removeAttribute("height");let h=a;if(l){const t=l.cloneNode(!1);t.appendChild(a),h=t}switch(e){case"inline":{if(i)break;this.#J.component.deselect();const t=s.nextElementSibling,e=s.parentElement,n=qi.CreateInlineContainer(h);Pe.utils.addClass(n.container,s.className.split(" ").filter((t=>"se-figure-selected"!==t&&"se-component-selected"!==t)).join("|")),this.#gi(n,o,r);const l=Pe.utils.createElement(this.#J.options.get("defaultLine"),null,n.container);e.insertBefore(l,t),Pe.utils.removeItem(s);break}case"block":{if(!i)break;this.#J.component.deselect(),this.#J.selection.setRange(s,0,s,1);const t=this.#J.html.remove(),e=this.#J.nodeTransform.split(t.container,t.offset,0);e?.previousElementSibling&&Pe.check.isZeroWidth(e.previousElementSibling)&&Pe.utils.removeItem(e.previousElementSibling);const n=qi.CreateContainer(h);Pe.utils.addClass(n.container,s.className.split(" ").filter((t=>"se-inline-component"!==t&&"se-figure-selected"!==t&&"se-component-selected"!==t)).join("|")),this.#gi(n,o,r),(e||t.container).parentElement.insertBefore(n.container,e);break}}return a}controllerAction(t){const e=t.getAttribute("data-command"),s=t.getAttribute("data-value"),i=t.getAttribute("data-type"),n=this._element;if(!/^on.+/.test(e)&&"selectMenu"!==i){switch(e){case"mirror":{const t=Wi(n);let e=t.x,i=t.y;"h"===s&&!this.isVertical||"v"===s&&this.isVertical?i=i?"":"180":e=e?"":"180",this._setRotate(n,t.r,e,i);break}case"rotate":this.setTransform(n,null,null,Number(s));break;case"caption":if(this._caption)Pe.utils.removeItem(this._caption),Oi.setTimeout(this.#J.component.select.bind(this.#J.component,n,this.kind),0),this._caption=null;else{const t=qi.CreateCaption(this._cover,this.#J.lang.caption),e=Pe.query.getEdgeChild(t,(t=>3===t.nodeType),!1);e?this.#J.selection.setRange(e,0,e,e.textContent.length):t.focus(),this._caption=t,this.controller.close()}(/\d+/.test(n.style.height)||this.isVertical&&this._caption)&&(/%$/.test(n.style.width)||/auto/.test(n.style.height)?this.deleteTransform():this.setTransform(n,n.style.width,n.style.height,0));break;case"revert":this._setRevert();break;case"edit":this.inst.componentEdit(n);break;case"copy":this.#J.component.copy(this._container);break;case"remove":this.inst.componentDestroy(n),this.controller.close()}/^__c__/.test(e)?this._action[e](n,s,t):"edit"!==e&&(this.#J.history.push(!1),/^remove|caption$/.test(e)||this.#J.component.select(n,this.kind))}}retainFigureFormat(t,e,s,i){const n=this.#J.component.isInline(t),o=e.parentNode,r=1===o.children?.length&&!o.textContent.replace(Re.zeroWidthRegExp,"").trim();let l=this.#J.format.isBlock(o)||Pe.check.isWysiwygFrame(o)||o.nodeType>=9?e:qi.GetContainer(e)?.container||(r?o:e);if(Pe.query.getParentElement(e,Pe.check.isExcludeFormat))l=s&&s!==e?s:e,l.parentNode.replaceChild(t,l);else if(n&&this.#J.format.isLine(l)){const s=n&&/^SPAN$/i.test(e.parentElement.nodeName)?e.parentElement:e;s.parentElement.replaceChild(t,s)}else if(Pe.check.isListCell(l)){const s=Pe.query.getParentElement(e,(t=>t.parentNode===l));l.insertBefore(t,s),Pe.utils.removeItem(e),this.#J.nodeTransform.removeEmptyNode(s,null,!0)}else if(this.#J.format.isLine(l)){const s=Pe.query.getParentElement(e,(t=>t.parentNode===l));l=this.#J.nodeTransform.split(l,s),l.parentNode.insertBefore(t,l),Pe.utils.removeItem(e),this.#J.nodeTransform.removeEmptyNode(l,null,!0)}else if(this.#J.format.isLine(l.parentNode)){const e=l.parentNode;e.parentNode.insertBefore(t,l.previousSibling?e.nextElementSibling:e),(0===i?.__updateTags.map((t=>l.contains(t))).length||Pe.check.isZeroWidth(l))&&Pe.utils.removeItem(l)}else l=Pe.check.isFigure(l.parentNode)?Pe.query.getParentElement(l.parentNode,qi.is):l,l.parentNode.replaceChild(t,l)}deleteTransform(t){t||=this._element;const e=t,s=(e.getAttribute("data-se-size")||"").split(",");this.isVertical=!1,e.style.maxWidth="",e.style.transform="",e.style.transformOrigin="",this.#mi(e),this._applySize(s[0]||"auto",s[1]||"","")}setTransform(t,e,s,i){try{this.#Ys=!0;const n=Wi(t),o=n.r+1*(i||0);i=Math.abs(o)>=360?0:o;const r=this.isVertical=Ui(i);e=De.get(e,0),s=De.get(s,0);const l=t,a=(l.getAttribute("data-se-size")||"auto,auto").split(",");r&&this._setRotate(l,i,n.x,n.y);let h="";if(/auto|%$/.test(a[0])&&!r)"auto"===a[0]&&"auto"===a[1]?this._setAutoSize():this._setPercentSize(a[0],a[1]);else{const t=qi.GetContainer(l),n=t.cover||t.inlineCover,o=e||l.offsetWidth,a=s||l.offsetHeight,c=(r?a:o)+"px",d=(r?o:a)+"px";if(this.#fi(),this._applySize(o+"px",a+"px",""),n&&(n.style.width=c,n.style.height=t.caption||t.inlineCover?"":d),r){h=90===i||-270===i?a/2+"px "+a/2+"px 0":o/2+"px "+o/2+"px 0"}}l.style.transformOrigin=h,r||this._setRotate(l,i,n.x,n.y),l.style.maxWidth=r?"none":"",this.#vi(l)}finally{this.#Ys=!1}}_displayResizeHandles(t){const e=t?"flex":"none";this.controller&&(this.controller.form.style.display=e);const s=this.#J.frameContext.get("_figure"),i=s.handles;for(let t=0,s=i.length;t<s;t++)i[t].style.display=e;"none"===e?(Pe.utils.addClass(s.main,"se-resize-ing"),this.#Zs=this.#J.eventManager.addGlobalEvent("keydown",this.#Hs)):Pe.utils.removeClass(s.main,"se-resize-ing")}#gi(t,e,s){const i=this.kind;t.target.onload=()=>this.#J.component.select(t.target,i),this.#ci(t),t.inlineCover&&(this.setAlign(t.target,"none"),this.deleteTransform()),this.setFigureSize(e,s)}#ci(t){this._inlineCover=t.inlineCover,this._cover=t.cover||this._inlineCover,this._container=t.container,this._caption=t.caption,this._element=t.target,this.align=(this._container.className.match(/(?:^|\s)__se__float-(none|left|center|right)(?:$|\s)/)||[])[1]||t.target.style.float||"none",this.as=this._inlineCover?"inline":"block",this.isVertical=Ui(t.target)}_setRotate(t,e,s,i){let n=(t.offsetWidth-t.offsetHeight)*(/^-/.test(e+"")?1:-1),o="";if(/[1-9]/.test(e+"")&&(s||i))switch(o=s?"Y":"X",e+""){case"90":o=s&&i?"X":i?o:"";break;case"270":n*=-1,o=s&&i?"Y":s?o:"";break;case"-90":o=s&&i?"Y":s?o:"";break;case"-270":n*=-1,o=s&&i?"X":i?o:"";break;default:o=""}e%180==0&&(t.style.maxWidth=""),t.style.transform="rotate("+e+"deg)"+(s?" rotateX("+s+"deg)":"")+(i?" rotateY("+i+"deg)":"")+(o?" translate"+o+"("+n+"px)":"")}_applySize(t,e,s){const i=/^(rw|lw)$/.test(s)&&/\d+/.test(this._element.style.height),n=/^(th|bh)$/.test(s)&&/\d+/.test(this._element.style.width);e=e||(this.autoRatio?this.autoRatio.current||this.autoRatio.default:e),t=De.is(t)?t+this.sizeUnit:t,/%$/.test(t)||/%$/.test(e)||i||n||this.#fi();const o=this._cover||this._element;this.autoRatio&&this._cover&&(this._cover.style.width=t),n||(o.style.width=this._element.style.width=t),i||(e=De.is(e)?e+this.sizeUnit:e,o.style.height=this._element.style.height=this.autoRatio&&!this.isVertical?"100%":e,this.autoRatio&&this._cover&&(this._cover.style.height=e,this.__setCoverPaddingBottom(t,e))),"center"===this.align&&this.setAlign(this._element,this.align),this.#bi()}__setCoverPaddingBottom(t,e){this._inlineCover!==this._cover&&(this.isVertical&&([t,e]=[e,t]),this._cover.style.height=e,/%$/.test(t)&&"center"===this.align?this._cover.style.paddingBottom=/%$/.test(e)?De.get(De.get(e,2)/100*De.get(t,2),2)+"%":e:this._cover.style.paddingBottom=e)}_setAutoSize(){this._caption&&(this._caption.style.marginTop=""),this.deleteTransform(),this.#fi(),this.autoRatio?this._setPercentSize("100%",this.autoRatio.current||this.autoRatio.default):(this._element.style.maxWidth="",this._element.style.width="",this._element.style.height="",this._cover&&(this._cover.style.width="",this._cover.style.height="")),this.setAlign(this._element,this.align),this.#bi()}_setPercentSize(t,e){e||=this.autoRatio?/%$/.test(this.autoRatio.current)?this.autoRatio.current:this.autoRatio.default:e,e=!e||/%$/.test(e+"")||De.get(e,0)?De.is(e)?e+this.sizeUnit:e||(this.autoRatio?this.autoRatio.default:""):De.is(e)?e+"%":e;const s=/%$/.test(e+"");this._container.style.width=String(De.is(t)?t+"%":t),this._container.style.height="",this._element!==this._cover||this.#J.options.get("strictMode").formatFilter?(this._inlineCover!==this._cover&&this._cover&&(this._cover.style.width="100%",this._cover.style.height=String(e)),this._element.style.width="100%",this._element.style.maxWidth="",this._element.style.height=String(this.autoRatio?"100%":s?"":e),"center"===this.align&&this.setAlign(this._element,this.align),this.autoRatio&&this.__setCoverPaddingBottom(String(t),String(e)),this.#vi(this._element),this.#bi()):this.#bi()}#fi(){this._cover&&(this._cover.style.width="",this._cover.style.height=""),this._container.style.width="",this._container.style.height="",Pe.utils.removeClass(this._container,this.#Ks),Pe.utils.addClass(this._container,"__se__float-"+this.align),"center"===this.align&&this.setAlign(this._element,this.align)}_setRevert(){this.setFigureSize(this.#Xs.w,this.#Xs.h)}#di(){this.alignButton&&Pe.utils.changeElement(this.alignButton.firstElementChild,this._alignIcons[this.align])}#ui(){this.asButton&&Pe.utils.changeElement(this.asButton.firstElementChild,this.#J.icons[`as_${this.as}`])}#bi(){if(this.#Ys)return;const t=(this._element.getAttribute("data-se-size")||",").split(",");this.#Xs.w=t[0],this.#Xs.h=t[1];const e=this.getSize(this._element);this._element.setAttribute("width",e.w.replace("px","")),this._element.setAttribute("height",e.h.replace("px","")),this._element.setAttribute("data-se-size",e.w+","+e.h),this.autoRatio&&(this.autoRatio.current=/%$/.test(e.h)?e.h:"")}#vi(t){const e=Pe.query.getEdgeChild(Pe.query.getParentElement(t,"FIGURE"),"FIGCAPTION",!1);e&&(e.style.marginTop=(this.isVertical&&!this.autoRatio?t.offsetWidth-t.offsetHeight:0)+"px",this.isVertical&&this.autoRatio?t.style.marginTop=e.offsetHeight+"px":t.style.marginTop="")}#mi(t){const e=Pe.query.getEdgeChild(Pe.query.getParentElement(t,"FIGURE"),"FIGCAPTION",!1);e&&(e.style.marginTop="")}#yi(){this.#J.component.__removeDragEvent(),this.#hi(),this._displayResizeHandles(!0),this.#J.ui.offCurrentController(),this.#J.ui.disableBackWrapper()}#hi(){this.#J.eventManager.removeGlobalEvent(this.__onContainerEvent),this.#J.eventManager.removeGlobalEvent(this.__offContainerEvent),this.#J.eventManager.removeGlobalEvent(this.#Zs)}#pi(t){const e=this.#J.frameContext.get("wrapper").querySelector(".se-drag-handle");Pe.utils.removeClass(e,"se-drag-handle-full"),e.style.opacity="",e.style.width="",e.style.height="",Ci.set("__dragHandler",e),Ci.set("__dragContainer",this._container),Ci.set("__dragCover",this._cover),Ci.set("__dragMove",this.#wi.bind(this,e,t)),Ci.get("__dragMove")(),e.style.display="block"}#wi(t,e){t.style.display="block",t.style.left=e.offsetLeft+(this.#J.options.get("_rtl")?t.offsetWidth:e.offsetWidth-1.5*t.offsetWidth)+"px",t.style.top=e.offsetTop-t.offsetHeight+.5+"px"}#ai(t){t.stopPropagation(),t.preventDefault();const e=Ci.get("__figureInst");if(!e)return;const s=Pe.query.getEventTarget(t),i=e._resize_direction=s.classList[0];e._resizeClientX=t.clientX,e._resizeClientY=t.clientY,this.#J.frameContext.get("_figure").main.style.float=/l/.test(i)?"right":/r/.test(i)?"left":"none",this.#J.ui.enableBackWrapper(zi[i]);const{w:n,h:o,dw:r,dh:l}=this.getSize(e._element);if(Pi=Di=!1,Fi=Hi=0,!this.isVertical){const t=!n||/auto|%$/.test(n),s=!o||/auto|%$/.test(o);if("tl|bl|tr|br".includes(i)&&t&&s?Pi=!0:"lw|rw".includes(i)&&t&&(Di=!0),Pi||Di){const t=e._cover||e._element;Hi=t.offsetWidth,Fi=ze.getWidthInPercentage(t,this.#J.frameContext.get("wysiwygFrame"))/100}}e.__onContainerEvent=this.#J.eventManager.addGlobalEvent("mousemove",e.__containerResizing),e.__offContainerEvent=this.#J.eventManager.addGlobalEvent("mouseup",e.__containerResizingOff),e._displayResizeHandles(!1);const a=this.#J.frameContext.get("_figure").display;a.style.display="block",Pe.utils.changeTxt(a,r+" * "+l)}#si(t){const e=this._resize_direction,s=t.clientX,i=t.clientY,n=this.isVertical;let o=n?this.#Gs:this.#js,r=n?this.#js:this.#Gs;const l=o+(/r/.test(e)?s-this._resizeClientX:this._resizeClientX-s),a=r+(/b/.test(e)?i-this._resizeClientY:this._resizeClientY-i),h=r/o*l,c=this.#J.frameContext.get("_figure").border;/t/.test(e)&&(c.style.top=r-(/h/.test(e)?a:h)+"px"),/l/.test(e)&&(c.style.left=o-l+"px"),/r|l/.test(e)&&(c.style.width=l+"px",o=l),/^(t|b)[^h]$/.test(e)?(c.style.height=h+"px",r=h):/^(t|b)h$/.test(e)&&(c.style.height=a+"px",r=a);const d=!n&&/h$/.test(e)?this.#qs:Math.round(o),u=!n&&/w$/.test(e)?this.#Ws:Math.round(r),p=Fi?d/Hi*Fi*100:d;Pe.utils.changeTxt(this.#J.frameContext.get("_figure").display,Fi?De.get(p>100?100:p,2).toFixed(2)+"%":p+" * "+u),this.#Us=d,this.#Vs=u}#ei(){this.#yi();let t=this.isVertical?this.#Vs:this.#Us,e=this.isVertical?this.#Us:this.#Vs;if(t=Math.round(t)||t,e=Math.round(e)||e,!this.isVertical&&!/%$/.test(t+"")){const s=this.#J.frameContext.get("wysiwygFrame").clientWidth-De.get(this.#J.frameContext.get("wwComputedStyle").getPropertyValue("padding-left"))+De.get(this.#J.frameContext.get("wwComputedStyle").getPropertyValue("padding-right"))-2;De.get(t,0)>s&&(e=Math.round(e/t*s),t=s)}if(Pi||Di){t=t/(this._cover||this._element).offsetWidth*Fi*100;const e=De.get(t>100?100:t,2)+"%";this._setPercentSize(e,Di?this.getSize(this._element).h:"")}else this._applySize(t,e,this._resize_direction),this.isVertical&&this.setTransform(this._element,t,e,0);this.#J.history.push(!1),this.#J.component.select(this._element,this.kind)}#ni(t){Fe.isEsc(t.code)&&(this.#yi(),this.#J.component.select(this._element,this.kind))}#Js(t){this.setAlign(this._element,t),this.selectMenu_align.close(),this.#J.component.select(this._element,this.kind),this.#J.history.push(!1)}#Qs(t){this.convertAsFormat(this._element,t),this.selectMenu_as.close(),this.#J.history.push(!1)}#ti(t){if("auto"===t)this.deleteTransform(),this._setAutoSize();else{let e=this.getSize(this._element).h;if(this.isVertical){const t=(this._element.getAttribute("data-se-size")||",").split(",");t[1]&&(e=t[1])}this.deleteTransform(),this._setPercentSize(1*t,null!==De.get(e,0)&&/%$/.test(e)?e:"")}this.selectMenu_resize.close(),this.#J.component.select(this._element,this.kind),this.#J.history.push(!1)}#ii(){const t=this.#J.frameContext.get("_figure");t.main.style.display="none",this.#J.ui.setFigureContainer(null),this.#J.ui.opendControllers=this.#J.ui.opendControllers.filter((e=>e.form!==t.main))}#oi(){this.selectMenu_align.open("",'[data-command="'+this.align+'"]')}#ri(){this.selectMenu_as.open("",'[data-command="'+this.as+'"]')}#li(){const t=this.getSize(this._element),e=t.w,s=t.h;let i="";if(this.autoRatio){if(s===this.autoRatio.default&&/%$/.test(e)){const t=De.get(e);i=100===t?"auto":"resize_percent"+t}}else"auto"===s&&("auto"===e?i="auto":/%$/.test(e)&&(i="resize_percent"+De.get(e)));this.selectMenu_resize.open("",'[data-command="'+i+'"]')}}function Wi(t){const e=t.style.transform;return e?{r:Number((e.match(/rotate\(([-0-9]+)deg\)/)||[])[1]||0),x:(e.match(/rotateX\(([-0-9]+)deg\)/)||[])[1]||"",y:(e.match(/rotateY\(([-0-9]+)deg\)/)||[])[1]||""}:{r:0,x:"",y:""}}function Ui(t){return/^(90|270)$/.test(Math.abs(De.is(t)?t:Wi(t).r).toString())}function Vi(t){const e=t.split("_"),s=e[0],i=e[1];let n,o,r,l;switch(s){case"resize":n="onresize",o=i,r="resize",l="resize";break;case"auto":n="auto",r="autoSize",l="auto_size";break;case"rotate":n="rotate",o="l"===i?-90:"r"===i?90:De.get(i),r=o<0?"rotateLeft":"rotateRight",l=o<0?"rotate_left":"rotate_right";break;case"mirror":n="mirror",o=i,r="h"===i?"mirrorHorizontal":"mirrorVertical",l="h"===i?"mirror_horizontal":"mirror_vertical";break;case"align":n="onalign",r="align",l="align_justify";break;case"caption":n="caption",r="caption",l="caption";break;case"revert":n="revert",r="revert",l="revert";break;case"edit":n="edit",r="edit",l="edit";break;case"as":n="onas",r="blockStyle",l="as_block";break;case"copy":n="copy",r="copy",l="copy";break;case"remove":n="remove",r="remove",l="delete"}return n?{c:n,v:o,l:r,t:undefined,i:l}:null}const ji=qi,{_w:Gi,ON_OVER_COMPONENT:Ki,isMobile:Yi}=Oe,Xi=/^Arrow(Left|Up|Right|Down)$/,Zi=/^Arrow(Left|Up)$/;function Ji(t,e,s){t.preventDefault(),t.stopPropagation(),Qi(e),s.setData("text/html",e.outerHTML)}function Qi(t){Pe.utils.removeClass(t,"se-component-selected"),Pe.utils.removeClass(t.querySelectorAll(".se-figure-selected"),"se-figure-selected"),Pe.utils.removeClass(t.querySelectorAll(".se-selected-table-cell"),"se-selected-table-cell"),Pe.utils.removeClass(t.querySelector(".se-selected-cell-focus"),"se-selected-cell-focus")}const tn=class{#H;#J;#t;#Ci;#ot;#rt;#X;#_i;#it;#ki=null;#xi=null;#$i=null;#ls=null;constructor(t){this.#H=t,this.#J=t.$,this.#t=t.store,this.#Ci=this.#J.contextProvider,this.#ot=this.#Ci.carrierWrapper,this.#rt=this.#J.options,this.#X=this.#J.frameContext,this.#_i=this.#J.eventManager,this.info=null,this.isSelected=!1,this.currentTarget=null,this.currentPlugin=null,this.currentPluginName="",this.currentInfo=null,this.#it={copy:this.#Si.bind(this),cut:this.#Ei.bind(this),keydown:this.#Ti.bind(this),mousedown:this.#Pe.bind(this)},this.__selectionSelected=!1,this.__prevent=!1}_init(){this.#Ci.applyToRoots((t=>{const e=Pe.utils.createElement("DIV",{class:"se-drag-handle",draggable:"true"},this.#Ci.icons.selection);t.get("wrapper").appendChild(e),this.#_i.addEvent(e,"mouseenter",this.#Mi.bind(this)),this.#_i.addEvent(e,"mouseleave",this.#Ni.bind(this)),this.#_i.addEvent(e,"dragstart",this.#Bi.bind(this)),this.#_i.addEvent(e,"dragend",this.#Ii.bind(this)),this.#_i.addEvent(e,"click",this.#Li.bind(this))}))}insert(t,{skipCharCount:e=!1,skipHistory:s=!1,scrollTo:i=!0,insertBehavior:n}={}){if(this.#X.get("isReadOnly")||!e&&!this.#J.char.check(t))return null;void 0===n&&(n=this.#rt.get("componentInsertBehavior"));const o=this.#J.html.remove(),r=this.isInline(t);this.#J.selection.getRangeAndAddLine(this.#J.selection.getRange(),o.container);const l=this.#J.selection.getNode();let a=null,h=this.#J.format.getLine(l,null);try{if(Pe.check.isListCell(h))this.#J.html.insertNode(t,{afterNode:r?null:Pe.check.isZeroWidth(l)?(l||o.container||{}).nextSibling:null,skipCharCount:!0}),r||t.nextSibling||t.parentNode.appendChild(Pe.utils.createElement("BR"));else{if(!r&&this.#J.selection.getRange().collapsed&&(3===o.container?.nodeType||Pe.check.isBreak(o.container))){const t=Pe.query.getParentElement(o.container,this.#J.format.isBlock.bind(this.#J.format));a=this.#J.nodeTransform.split(o.container,o.offset,t?Pe.query.getNodeDepth(t)+1:0),a&&(h=a.previousSibling)}this.#J.html.insertNode(t,{afterNode:r||this.#J.format.isBlock(h)?null:h,skipCharCount:!0}),!r&&h&&Pe.check.isZeroWidth(h)&&Pe.utils.removeItem(h)}if(r){const e=Pe.utils.createTextNode(Re.zeroWidthSpace);t.parentNode.insertBefore(e,t.nextSibling)}}catch(t){console.error("Component insert error:",t)}s||this.#J.history.push(!1),this.#X.has("documentType_use_header")&&this.#X.get("documentType").reHeader();const c=a||t;return i&&this.#J.selection.scrollTo(c,{behavior:"auto"}),null!==n&&this.applyInsertBehavior(t,a,n),c}applyInsertBehavior(t,e,s){const i=this.get(t);if(this.isInline(t)){const e=this.#J.selection.getNearRange(t);e?this.#J.selection.setRange(e.container,e.offset,e.container,e.offset):this.select(i.target,i.pluginName)}else switch(s){case"auto":this.#Ai(t)||this.select(i.target,i.pluginName);break;case"select":this.#J.selection.setRange(t,0,t,0),i?this.select(i.target,i.pluginName):e&&(e=Pe.query.getEdgeChildNodes(e,null).sc||e,this.#J.selection.setRange(e,0,e,0));break;case"line":if(!this.#Ai(t)){const e=this.#J.format.addLine(t,null);e&&this.#J.selection.setRange(e,0,e,0)}}}get(t){if(!t)return null;let e,s="",i={},n=!1,o=null;if(this.is(t)){if(Pe.check.isComponentContainer(t)&&!Pe.utils.hasClass(t,"se-inline-component")&&(t=t.firstElementChild||t),/^FIGURE$/i.test(t.nodeName)&&(t=t.firstElementChild),!t)return null;const n=this.#J.pluginManager.findComponentInfo(t);if(!n)return null;e=n.target,s=n.pluginName,i=n.options,o=n.launcher}if(!e&&t.nodeName){this.#Oi(t)&&(n=!0);const r=this.#J.pluginManager.findComponentInfo(t);if(!r)return null;e=r.target,s=r.pluginName,i=r.options,o=r.launcher}if(!e)return null;const r=ji.GetContainer(e),l=r.container||r.cover||e;return this.info={target:r.target,pluginName:s,options:i,container:l,cover:r.cover,inlineCover:r.inlineCover,caption:r.caption,isFile:n,launcher:o,isInputType:Pe.utils.hasClass(l,"se-input-component")}}select(t,e,{isInput:s=!1}={}){const i=this.get(t);if(!i||Pe.check.isUneditable(Pe.query.getParentElement(t,this.is.bind(this)))||Pe.check.isUneditable(t))return!1;const n=i.launcher||this.#J.plugins[e];if(!n)return;const o=_i.get("__overInfo")!==Ki;if(!s&&o){if(this.#t.get("_mousedown"))return;this.#t.set("_preventBlur",!0),this.__selectionSelected=!0,this.isInline(i.container)&&this.#J.selection.setRange(i.container,0,i.container,0),this.#J.focusManager.blur(),Gi.setTimeout((()=>{this.__selectionSelected=!1}))}let r;this.isSelected=!0,this.__prevent=!0,"function"==typeof n.componentSelect&&(r=n.componentSelect(t));const l=Pe.utils.hasClass(i.target,"se-component-line-break");(l||!r&&!Pe.utils.hasClass(i.container,"se-inline-component"))&&this._setComponentLineBreaker(i.container||i.cover||t),this.currentTarget=t,this.currentPlugin=n,this.currentPluginName=e,this.currentInfo=i,_i.set("__dragInst",this);const a=_i.get("__overInfo");if(Gi.setTimeout((()=>{_i.set("__overInfo",a===Ki&&void 0),a!==Ki&&this.#qe(),i.isFile||this.#Ri(),Pe.utils.addClass(i.container,"se-component-selected")}),0),!o||this.#t.get("hasFocus")||this.#t.get("_preventFocus")||(this.#H._eventOrchestrator.__postFocusEvent(this.#X,null),this.#t.set("_preventFocus",!0)),l||a===Ki){if(l||!Pe.utils.hasClass(i.container,"se-input-component")){const t=this.#X.get("wrapper").querySelector(".se-drag-handle");Pe.utils.addClass(t,"se-drag-handle-full"),this.#J.ui._visibleControllers(!1,!1);const e=i.caption?i.target:i.cover||i.container||i.target,s=e.offsetWidth,n=e.offsetHeight,{top:o,left:r}=this.#J.offset.getLocal(e);t.style.opacity="0",t.style.width=s+"px",t.style.height=n+"px",t.style.top=o+"px",t.style.left=r+"px",_i.set("__dragHandler",t),_i.set("__dragContainer",i.container),_i.set("__dragCover",i.cover),t.style.display="block"}}else{if(!this.isInline(i.container))return;const t=i.container;let e=null;t.previousSibling&&!Pe.check.isBreak(t.previousSibling)||(e=Pe.utils.createTextNode(Re.zeroWidthSpace),t.parentNode.insertBefore(e,t)),t.nextSibling&&!Pe.check.isBreak(t.nextSibling)||(e=Pe.utils.createTextNode(Re.zeroWidthSpace),t.parentNode.insertBefore(e,t.nextSibling)),this.#t.set("controlActive",!0)}}deselect(){Gi.setTimeout((()=>{this.#t.set("controlActive",!1)}),0),this.__deselect(),this.#J.ui.setControllerOnDisabledButtons(!1),!this.#t.get("_preventFocus")||this.#t.get("hasFocus")||this.__prevent||(this.#H._eventOrchestrator.__postBlurEvent(this.#X,null),this.#t.set("_preventFocus",!1))}is(t){return!!t&&(!(!/^FIGURE$/i.test(t.nodeName)&&!Pe.check.isComponentContainer(t))||!!this.#J.pluginManager.findComponentInfo(t))}isInline(t){if(!t)return!1;if(/^FIGURE$/i.test(t.nodeName)&&(t=t.parentElement),Pe.utils.hasClass(t,"se-inline-component"))return!0;return!(!this.#J.pluginManager.findComponentInfo(t)||!Pe.utils.hasClass(t,"se-inline-component")&&!Pe.utils.hasClass(t.parentElement,"se-inline-component"))}isBasic(t){return this.is(t)&&!this.isInline(t)}async copy(t){const e=Pe.utils.clone(t,!0);Qi(e),!1!==await this.#J.html.copy(e)&&Pe.utils.flashClass(t,"se-copy")}hoverSelect(t){const e=Pe.query.getParentElement(t,Pe.check.isFigure);let s=this.get(t);s||e?(s||=this.get(e),s&&!Pe.utils.hasClass(s.container,"se-component-selected")&&(this.#J.ui.offCurrentController(),_i.set("__overInfo",Ki),this.select(s.target,s.pluginName))):null===_i.get("__overInfo")||Pe.utils.hasClass(t,"se-drag-handle")||(this.__deselect(),_i.set("__overInfo",null))}__deselect(){if(this.#t.set("_preventBlur",!1),_i.set("__overInfo",null),this.__removeDragEvent(),this.currentInfo){const t=this.currentInfo.container,e=this.currentInfo.cover;Gi.setTimeout((()=>{Qi(t),Pe.utils.removeClass(e,"se-figure-over-selected")}),0)}this.#X.get("lineBreaker_t")&&(this.#X.get("lineBreaker_t").style.display=this.#X.get("lineBreaker_b").style.display="none"),this.currentPlugin&&this.currentPlugin.componentDeselect?.(this.currentTarget),this.isSelected=!1,this.currentPlugin=null,this.currentTarget=null,this.currentPluginName="",this.currentInfo=null,this.__removeGlobalEvent(),this.#J.ui._offControllers()}_setComponentLineBreaker(t){const e=_i.get("__overInfo")===Ki;this.#H._eventOrchestrator._lineBreakComp=null;const s=this.get(t);if(!s)return;const i=this.#X,n=s.container,o=Pe.utils.hasClass(n,"se-flex-component"),r=i.get("lineBreaker_t"),l=i.get("lineBreaker_b"),a=r.style,h=l.style,c=n.offsetWidth<t.offsetWidth?n:t,d=this.#J.ui.getVisibleFigure()||c,u=Pe.check.isListCell(n.parentNode);let p,g;const m=this.#rt.get("_rtl"),f=m?["right","left"]:["left","right"],{top:v,left:b,right:y,scrollX:w,scrollY:C}=this.#J.offset.getLocal(c),_=m?y:b;if(u?!Pe.check.isBreak(n.previousElementSibling)&&!n.previousSibling?.textContent?.trim()||this.is(n.previousElementSibling):!this.#J.format.isLine(n.previousElementSibling)){const t=Gi.getComputedStyle(r),s=De.get(t.height,1),i=De.get(t.width,1);this.#H._eventOrchestrator._lineBreakComp=n,p=v,g=d.offsetWidth/2/2,a.top=p-s/2+"px",a[f[0]]=(o?_-i/2:_+g)+"px",a[f[1]]="",r.setAttribute("data-offset",C+","+w),e?Pe.utils.removeClass(r,"se-on-selected"):Pe.utils.addClass(r,"se-on-selected"),a.display="block",a.visibility=""}else a.display="none";if(u?!Pe.check.isBreak(n.nextElementSibling)&&!n.nextSibling?.textContent?.trim()||this.is(n.nextElementSibling):!this.#J.format.isLine(n.nextElementSibling)){const t=Gi.getComputedStyle(l),s=De.get(t.height,1),i=De.get(t.width,1);p||(this.#H._eventOrchestrator._lineBreakComp=n,p=v,g=d.offsetWidth/2/2),h.top=p+d.offsetHeight-s/2+"px",h[f[0]]=_+d.offsetWidth-(o?0:g)-(o?i/2:i)+"px",h[f[1]]="",l.setAttribute("data-offset",C+","+f[0]+","+w),e?Pe.utils.removeClass(l,"se-on-selected"):Pe.utils.addClass(l,"se-on-selected"),h.display="block",h.visibility=""}else h.display="none"}__removeGlobalEvent(){this.#zi(),this.#ki&&=this.#_i.removeGlobalEvent(this.#ki),this.#xi&&=this.#_i.removeGlobalEvent(this.#xi),this.#$i&&=this.#_i.removeGlobalEvent(this.#$i)}__removeDragEvent(){this.#ot.querySelector(".se-drag-cursor").style.left="-10000px",_i.get("__dragHandler")&&(_i.get("__dragHandler").style.display="none"),Pe.utils.removeClass([_i.get("__dragHandler"),_i.get("__dragContainer")],"se-dragging"),Pe.utils.removeClass([_i.get("__dragCover"),_i.get("__dragContainer")],"se-drag-over"),_i.set("__figureInst",null),_i.set("__dragInst",null),_i.set("__dragHandler",null),_i.set("__dragContainer",null),_i.set("__dragCover",null),_i.set("__dragMove",null),_i.set("__overInfo",null)}#qe(){this.__removeGlobalEvent(),this.#ki=this.#_i.addGlobalEvent("copy",this.#it.copy),this.#xi=this.#_i.addGlobalEvent("cut",this.#it.cut),this.#$i=this.#_i.addGlobalEvent("keydown",this.#it.keydown)}#Ri(){this.#zi(),this.#ls=this.#_i.addGlobalEvent(Yi?"click":"mousedown",this.#it.mousedown,!0)}#zi(){this.#ls&&=this.#_i.removeGlobalEvent(this.#ls)}#Ai(t){const e=t.nextElementSibling;if(!e){const e=this.#J.format.addLine(t,null);return e&&this.#J.selection.setRange(e,0,e,0),!0}return!!this.#J.format.isLine(e)&&(this.#J.selection.setRange(e,0,e,0),!0)}#Oi(t){const e=t.nodeName.toLowerCase();return this.#J.pluginManager.fileInfo.regExp.test(e)&&(!this.#J.pluginManager.fileInfo.tagAttrs[e]||this.#J.pluginManager.fileInfo.tagAttrs[e]?.every((e=>t.hasAttribute(e))))}#Mi(){this.#t.set("_preventBlur",!0),this.#J.ui._visibleControllers(!1,Pe.utils.hasClass(_i.get("__dragHandler"),"se-drag-handle-full")),Pe.utils.addClass(_i.get("__dragCover")||_i.get("__dragContainer"),"se-drag-over")}#Ni(){this.#t.set("_preventBlur",!1),Pe.utils.hasClass(_i.get("__dragHandler"),"se-drag-handle-full")||this.#J.ui._visibleControllers(!0,!0),Pe.utils.removeClass([_i.get("__dragCover"),_i.get("__dragContainer")],"se-drag-over")}#Bi(t){const e=_i.get("__dragCover")||_i.get("__dragContainer");e?(this.#t.set("_preventBlur",!1),Pe.utils.addClass(_i.get("__dragHandler"),"se-dragging"),Pe.utils.addClass(_i.get("__dragContainer"),"se-dragging"),t.dataTransfer.setDragImage(e,this.#rt.get("_rtl")?e.offsetWidth:-5,-5)):t.preventDefault()}#Ii(){this.#t.set("_preventBlur",!1),Pe.utils.removeClass([_i.get("__dragHandler"),_i.get("__dragContainer")],"se-dragging"),this.__removeDragEvent()}#Li(t){const e=Pe.query.getEventTarget(t);if(!Pe.utils.hasClass(e,"se-drag-handle-full"))return;const s=_i.get("__dragInst");s&&(this.__removeDragEvent(),this.select(s.currentTarget,s.currentPluginName))}#Pe(t){const e=Pe.query.getEventTarget(t);this.currentTarget?.contains(e)||Pe.query.getParentElement(e,".se-controller")||Pe.utils.hasClass(e,"se-drag-handle")||this.currentPluginName===this.#J.ui.currentControllerName&&this.#J.ui.opendControllers.some((({form:t})=>t.contains(e)))||this.deselect()}#Si(t){const e=Pe.query.getEventTarget(t);if(Pe.check.isInputElement(e)&&Pe.query.getParentElement(e,".se-modal"))return;const s=this.info;if(!s)return;const i=s.container.cloneNode(!0);"function"==typeof this.#J.plugins[s.pluginName]?.componentCopy&&!1!==this.#J.plugins[s.pluginName].componentCopy({event:t,cloneContainer:i,info:s})||Ji(t,i,t.clipboardData),Pe.utils.flashClass(s.container,"se-copy")}#Ei(t){const e=this.info;if(!e)return;const s=e.container.cloneNode(!0);Pe.utils.removeClass(s,"se-component-selected"),Ji(t,s,t.clipboardData),this.deselect(),Pe.utils.removeItem(e.container)}async#Ti(t){if(this.#J.ui.selectMenuOn)return;const e=t.code;if(Fe.isCtrl(t)){if("ControlRight"!==e&&"ControlLeft"!==e){const s=this.#J.shortcuts.keyMap.get(e+(t.shiftKey?"1000":""));/^(redo|undo)$/.test(s?.command)&&(t.preventDefault(),t.stopPropagation(),this.#J.commandDispatcher.run(s.command,s.type,s.button))}}else if(!Fe.isRemoveKey(e)||(t.preventDefault(),t.stopPropagation(),"function"!=typeof this.currentPlugin?.componentDestroy||this.info.isInputType&&this.#t.get("hasFocus"))){if(Fe.isEnter(e)){t.preventDefault();const e=this.currentInfo||this.get(this.currentTarget),s=e.container||e.target,i=s.previousElementSibling||s.nextElementSibling;let n=null;n=Pe.check.isListCell(s.parentNode)?Pe.utils.createElement("BR"):Pe.utils.createElement(this.#J.format.isLine(i)?i.nodeName:this.#rt.get("defaultLine"),null,"<br>");const o=this.currentPluginName;return this.deselect(),s.parentNode.insertBefore(n,s),!1===this.select(e.target,o)&&this.#J.focusManager.blur(),void this.#J.history.push(!1)}if(Xi.lastIndex=0,Xi.test(e)){const{container:s}=this.get(this.currentTarget);let i=null,n=1;if(this.isInline(s||this.currentTarget))switch(e){case"ArrowLeft":i=s.previousSibling,n=3===i?.nodeType?i.textContent.length:1;break;case"ArrowRight":i=s.nextSibling,n=0;break;case"ArrowUp":{const t=this.#J.format.getLine(s,null);i=t?.previousElementSibling,n=0;break}case"ArrowDown":{const t=this.#J.format.getLine(s,null);i=t?.nextElementSibling;break}}else Zi.lastIndex=0,Zi.test(e)?i=s.previousElementSibling:(i=s.nextElementSibling,n=0);if(!i)return;this.deselect();const o=this.get(i);if(o?.container)t.stopPropagation(),t.preventDefault(),this.select(o.target,o.pluginName);else try{this.#t.set("_preventBlur",!0),t.stopPropagation(),t.preventDefault(),this.#J.selection.setRange(i,n,i,n)}finally{this.#t.set("_preventBlur",!1)}}else Fe.isEsc(e)&&this.deselect()}else{const t=this.info.container.previousSibling;if(await this.currentPlugin.componentDestroy(this.currentTarget),this.deselect(),t){const e=3===t.nodeType?t.textContent.length:1;this.#J.selection.setRange(t,e,t,e)}else this.#J.focusManager.focus()}}_destroy(){this.__removeGlobalEvent(),this.__removeDragEvent()}};const en=class{#H;#J;#Pi;#Ci;#rt;#Di;#Fi;#Hi=[];#qi=[];#Wi={tags:null,regExp:null,pluginRegExp:null,pluginMap:null};#Ui=[];#Vi=new Map;#ji=new Map([["onMouseMove",[]],["onMouseLeave",[]],["onMouseDown",[]],["onMouseUp",[]],["onScroll",[]],["onClick",[]],["onBeforeInput",[]],["onInput",[]],["onKeyDown",[]],["onKeyUp",[]],["onFocus",[]],["onBlur",[]],["onPaste",[]],["onFilePasteAndDrop",[]]]);constructor(t,e){this.#H=t,this.#J=t.$,this.#Pi=e.plugins||{},this.#Ci=this.#J.contextProvider,this.#rt=this.#J.options,this.#Di=e.pluginCallButtons,this.#Fi=e.pluginCallButtons_sub}get plugins(){return this.#Pi}get fileInfo(){return this.#Wi}findComponentInfo(t){for(const e of this.#Ui){const s=e(t);if(s)return s}return null}applyRetainFormat(t){let e;(e=this.#rt.get("__pluginRetainFilter"))&&this.#Vi.forEach(((s,i)=>{let n;try{n=t.querySelectorAll(i)}catch(t){return void console.warn(`[SUNEDITOR.retainFormat.fail]-[${s.key}]`,t.message)}for(let t=0,i=n.length;t<i;t++)if(!0===e||!1!==e[s.key])try{s.method(n[t])}catch(t){console.warn(`[SUNEDITOR.retainFormat.fail]-[${s.key}]`,t.message)}}))}emitEvent(t,e){const s=this.#ji.get(t);for(let t,i=0;i<s.length;i++)if(t=s[i](e),"boolean"==typeof t)return t}async emitEventAsync(t,e){const s=this.#ji.get(t);for(let t,i=0;i<s.length;i++)if(t=await s[i](e),"boolean"==typeof t)return t}checkFileInfo(t){for(let e=0,s=this.#Hi.length;e<s;e++)this.#Hi[e](t)}resetFileInfo(){for(let t=0,e=this.#qi.length;t<e;t++)this.#qi[t]()}register(t,e,s){let i=this.#Pi[t];if(!i)throw Error(`[SUNEDITOR.registerPlugin.fail] The called plugin does not exist or is in an invalid format. (pluginName: "${t}")`);if("function"==typeof this.#Pi[t]&&(i=this.#Pi[t]=new this.#Pi[t](this.#H,s||{})),e){const{icons:s,lang:n}=this.#Ci;for(let t=0,o=e.length;t<o;t++)fs(e[t],i,s,n);this.#J.commandDispatcher.activeCommands.includes(t)||"function"!=typeof this.#Pi[t].active||this.#J.commandDispatcher.activeCommands.push(t)}}init(t){this.#Wi.tags=[],this.#Wi.pluginMap={},this.#Wi.tagAttrs={};const e=this.#Pi,s=[];let i;for(const n in e){if(this.register(n,this.#Di[n],t[n]),this.register(n,this.#Fi[n],t[n]),i=this.#Pi[n],"object"==typeof i.__fileManagement){const t=i.__fileManagement;if(this.#Hi.push(t._checkInfo.bind(t)),this.#qi.push(t._resetInfo.bind(t)),Array.isArray(t.tagNames)){const e=t.tagNames;this.#Wi.tags=this.#Wi.tags.concat(e),s.push(n);for(let s,i=0,o=e.length;i<o;i++)s=e[i].toLowerCase(),this.#Wi.pluginMap[s]=n,t.tagAttrs&&(this.#Wi.tagAttrs[s]=t.tagAttrs)}}"function"==typeof i.constructor.component&&this.#Ui.push(function(t,e){return e&&(e=t.component?.(e))?{target:e,pluginName:t.key,options:t.options}:null}.bind(null,i.constructor));const e=i.constructor.options||{};if(this.#ji.forEach(((t,s)=>{if("function"==typeof i[s]){const n=i[s].bind(i);n.index=e[`eventIndex_${s}`]||e.eventIndex||0,t.push(n)}})),i.retainFormat){const t=i.retainFormat();this.#Vi.set(t.query,{key:i.constructor.key,method:t.method})}}for(const t of this.#ji.values())t.sort(((t,e)=>t.index-e.index));(this.#rt.get("buttons").has("pageBreak")||this.#rt.get("buttons_sub")?.has("pageBreak"))&&this.#Ui.push(function(t,e,s){if(!s||!Pe.utils.hasClass(s,"se-page-break"))return null;return{target:s,launcher:{componentDestroy:s=>{const i=s.previousElementSibling||s.nextElementSibling;Pe.utils.removeItem(s),t.focusEdge(i),e.push(!1)}}}}.bind(null,this.#J.focusManager,this.#J.history)),this.#Wi.regExp=new RegExp(`^(${this.#Wi.tags.join("|")||"\\^"})$`,"i"),this.#Wi.pluginRegExp=new RegExp(`^(${0===s.length?"\\^":s.join("|")})$`,"i"),this.#Di=null,this.#Fi=null}get(t){return this.#Pi[t]}_destroy(){for(const t in this.#Pi){const e=this.#Pi[t];e._destroy?.(),e.editor=null}this.#Pi=null,this.#Wi=null,this.#Ui=null,this.#ji?.clear(),this.#Vi?.clear()}};class sn{#H;#J;#t;#rt;#X;#Q;constructor(t){this.#H=t,this.#J=t.$,this.#t=t.store,this.#rt=this.#J.options,this.#X=this.#J.frameContext,this.#Q=this.#J.frameOptions}focus(t){if(t&&this.#J.facade.changeFrameContext(t),"none"!==this.#X.get("wysiwygFrame").style.display){if(this.#t.set("_preventBlur",!1),this.#Q.get("iframe")||!this.#X.get("wysiwyg").contains(this.#J.selection.getNode()))this.nativeFocus();else try{const t=this.#J.selection.getRange();if(t.startContainer===t.endContainer&&Pe.check.isWysiwygFrame(t.startContainer)){const e=t.commonAncestorContainer.children[t.startOffset];if(!this.#J.format.isLine(e)&&!this.#J.component.is(e)){const t=Pe.utils.createElement("BR"),s=Pe.utils.createElement(this.#rt.get("defaultLine"),null,t);return this.#X.get("wysiwyg").insertBefore(s,e),void this.#J.selection.setRange(t,0,t,0)}}this.#J.selection.setRange(t.startContainer,t.startOffset,t.endContainer,t.endOffset)}catch(t){console.warn("[SUNEDITOR.focus.warn] ",t),this.nativeFocus()}this.#t.mode.isBalloon&&this.#H._eventOrchestrator._toggleToolbarBalloon()}}focusEdge(t){this.#t.set("_preventBlur",!1),t||=this.#X.get("wysiwyg").lastElementChild;const e=this.#J.component.get(t);e?this.#J.component.select(e.target,e.pluginName):t?(3!==t.nodeType&&(t=Pe.query.getEdgeChild(t,(function(t){return 0===t.childNodes.length||3===t.nodeType}),!0)),t?this.#J.selection.setRange(t,t.textContent.length,t,t.textContent.length):this.nativeFocus()):this.focus()}nativeFocus(){this.#J.selection.__focus(),this.#J.selection.init()}blur(){this.#Q.get("iframe")?this.#X.get("wysiwygFrame").blur():this.#X.get("wysiwyg").blur()}}const nn=/^H[1-6]$/,on=/^(UL|OL)$/,rn=/^LI$/,ln=/^(THEAD|TBODY|TR|TD|TH)$/;function an(t){let e=t;for(;e&&!tt(e);){if("TABLE"===e.nodeName)return e;e=e.parentNode}return null}function hn(t){let e=t;for(;e&&!tt(e);){if(1===e.nodeType&&Q(e))return!0;e=e.parentNode}return!1}function cn(t){let e=t,s=null;for(;e&&!tt(e);)1===e.nodeType&&Q(e)&&(s=e),e=e.parentNode;return s&&s.parentNode&&tt(s.parentNode)?s:null}function dn(t,e){const s=t.querySelector(":scope > ul, :scope > ol");if(!s)return null;if(e<s.getBoundingClientRect().top)return null;const i=s.children;let n=null,o=1/0;for(let t=0;t<i.length;t++){const s=i[t];if(!rn.test(s.nodeName))continue;const r=s.getBoundingClientRect();if(e>=r.top&&e<=r.bottom)return dn(s,e)||s;const l=Math.min(Math.abs(e-r.top),Math.abs(e-r.bottom));l<o&&(o=l,n=s)}return n}function un(t,e,s){let i=t;if(void 0!==s)if(on.test(i.nodeName)){const t=function(t,e){const s=t.children;let i=null,n=1/0;for(let t=0;t<s.length;t++){const o=s[t];if(!rn.test(o.nodeName))continue;const r=o.getBoundingClientRect();if(e>=r.top&&e<=r.bottom)return dn(o,e)||o;const l=Math.min(Math.abs(e-r.top),Math.abs(e-r.bottom));l<n&&(n=l,i=o)}return i}(i,s);t&&(i=t)}else if(rn.test(i.nodeName)){const t=dn(i,s);t&&(i=t)}const{depth:n,parent:o}=function(t,e){let s=0,i=null,n=t.parentNode;for(;n&&!tt(n);)1===n.nodeType&&(e.isBlock(n)||e.isLine(n))&&(i||(i=n),s++),n=n.parentNode;return{depth:s,parent:i}}(i,e),r=function(t){return{prev:t.previousElementSibling,next:t.nextElementSibling}}(i);return{element:i,type:function(t){const e=t.nodeName;return Q(t)?"component":"P"===e||"DIV"===e?"p":nn.test(e)?"heading":"LI"===e?"list-item":on.test(e)?"list":"BLOCKQUOTE"===e?"blockquote":"PRE"===e?"pre":"FIGURE"===e?"figure":"TABLE"===e?"table":"p"}(i),depth:n,parent:o,siblings:r,rect:i.getBoundingClientRect()}}const{_w:pn}=Oe;const gn=class{#J;#Gi;#Ki;#Yi=null;#Xi;#Zi=new Map;#Ji=null;#Qi=null;#tn=[];#en=[];selectMenu;constructor(t,e,s){this.#J=e,this.#Gi=s.resolveButton,this.#Ki=Array.isArray(s.items)?s.items:[],this.#Xi="function"==typeof s.renderCustomItem?s.renderCustomItem:null,this.#Qi="function"==typeof s.prepareCommit?s.prepareCommit:null;const i=s.selectMenuParams?.closeMethod;this.selectMenu=new Ai(e,{...s.selectMenuParams,closeMethod:()=>{this.#sn(),this.#in(),i?.()},subCheckMethod:t=>this.#Zi.has(t),subEscMethod:()=>{if(!this.#Ji)return!1;const t=this.#Ji.anchorLi;this.#sn();const e=t?Number(t.getAttribute("data-index")):NaN;return Number.isNaN(e)||this.selectMenu.setItem(e),!0}})}attach(t,e,s={}){this.selectMenu.on(t,e,s),this.#J.eventManager.addEvent(this.selectMenu.form,"mousedown",(t=>{Oe.isMobile||Pe.check.isInputElement(Pe.query.getEventTarget(t))?this.#J.store.set("_preventBlur",!0):t.preventDefault()})),this.#J.eventManager.addEvent(this.selectMenu.form,"mousemove",this.#nn.bind(this))}setItems(t){this.#Ki=Array.isArray(t)?t:[],this.#Yi=null}getItems(){if(this.#Yi)return this.#Yi;const t=[];for(const i of this.#Ki)if("string"==typeof i){const e=this.#Gi(i,this.#J.plugins,this.#J.options,this.#J.icons,this.#J.lang);if(!e)continue;const s=e.type||"";if(/dropdown-free/.test(s)){t.push({kind:"dropdownFree",title:e.title,iconHTML:e.icon||"",search:(e.title+" "+i).toLowerCase(),name:i,type:s});continue}if(/dropdown/.test(s)){const s=this.#J.menu?.itemsMap?.[i]||[];if(s.length>0){t.push({kind:"submenu",title:e.title,iconHTML:e.icon||"",search:(e.title+" "+i).toLowerCase(),name:i,children:s.map((t=>({pluginName:i,element:t._element}))),childMenus:s.map((t=>{const e=t._element?.querySelector(".se-list-icon")||t._element?.querySelector("svg"),s=e?e.outerHTML:"";return`<span class="se-block-submenu-item">${s?`${s}<span>${t.title}</span>`:t.title}</span>`}))});continue}}t.push({kind:"plugin",title:e.title,iconHTML:e.icon||"",search:(e.title+" "+i).toLowerCase(),name:i,type:s,command:e.command})}else if(i&&"object"==typeof i&&"function"==typeof i.action){const n=i.title||i.key||"",o=Array.isArray(i.keywords)?i.keywords.join(" "):"";t.push({kind:"custom",title:n,iconHTML:(e=i.icon,s=this.#J.icons,e&&"string"==typeof e?"<"===e.charAt(0)?e:s[e]||"":""),search:(n+" "+o).toLowerCase(),raw:i})}var e,s;return this.#Yi=t,t}filter(t,e=1/0){const s=this.getItems(),i=(t||"").toLowerCase().trim(),n=[];for(const t of s)if(i&&-1===t.search.indexOf(i)||n.push(t),n.length>=e)break;return n}renderRows(t){const e={icons:this.#J.icons},s=`<span class="se-submenu-arrow">${this.#J.icons.menu_arrow_right}</span>`;return t.map((t=>{if("custom"===t.kind&&this.#Xi)return this.#Xi(t.raw,e);const i=(n=t.title,`<button type="button" class="se-cmd-row">${(o=t.iconHTML)?`<span class="se-block-menu-icon">${o}</span><span class="se-block-menu-label">${n}</span>`:`<span class="se-block-menu-label se-block-menu-label-full">${n}</span>`}</button>`);var n,o;return"dropdownFree"===t.kind?i+s:i}))}createRows(t){this.#in();const e=t.map((t=>"submenu"===t.kind?{children:t.children,childMenus:t.childMenus}:t));this.selectMenu.create(e,this.renderRows(t)),this.#Zi.clear(),this.#tn.length=0,t.forEach(((t,e)=>{"dropdownFree"===t.kind&&this.#Zi.set(e,{name:t.name,plugin:this.#J.plugins[t.name],li:this.selectMenu.menus[e]}),"plugin"!==t.kind&&"dropdownFree"!==t.kind||this.#tn.push({name:t.name,idx:e})})),this.selectMenu.isOpen&&this.#on()}open(t){this.selectMenu.open(t),0===this.#en.length&&this.#on()}close(){this.#in(),this.selectMenu.close()}hasOpenSubPanel(){return this.selectMenu.hasOpenSubmenu()||!!this.#Ji}#on(){const t=this.#J.commandDispatcher;for(const{name:e,idx:s}of this.#tn){const i=this.#rn(s);i&&(t.registerTargets(e,i),this.#en.push({name:e,target:i}))}this.#J.store.set("_lastSelectionNode",null),this.#J.eventManager.applyTagEffect()}#in(){if(0===this.#en.length)return;const t=this.#J.commandDispatcher;for(const{name:e,target:s}of this.#en)t.unregisterTargets(e,s);this.#en.length=0}#rn(t){const e=this.selectMenu.menus[t];return e?e.querySelector("button.se-cmd-row")||e:null}setItem(t){this.selectMenu.setItem(t)}setHidden(t){this.selectMenu.setHidden(t)}get isOpen(){return this.selectMenu.isOpen}dispatch(t,e){if(!t)return!1;const s=t;if(s.pluginName&&s.element){const t=this.#J.plugins[s.pluginName];return t?.action?.(s.element),this.#J.history.push(!1),!0}const i=t;if("custom"===i.kind){try{i.raw.action(this.#J,e)}catch(t){console.error("[SUNEDITOR.commandMenu.customAction]",t)}return!1}if("dropdownFree"===i.kind){const t=this.#J.plugins[i.name];if(!t)return!1;if(this.#Ji?.plugin===t)return this.#sn(),!1;const e=this.selectMenu.items.indexOf(i),s=e>=0?this.selectMenu.menus[e]:null;return s&&this.#ln(i.name,t,s),!1}const n=i.name?this.#J.plugins[i.name]:null;if(n){const t=i.type||"";return/modal/.test(t)?n.open?.():/browser/.test(t)?n.open?.(null):/popup/.test(t)?n.show?.():n.action?.(Pe.utils.createElement("BUTTON",{type:"button","data-command":i.name})),this.#J.history.push(!1),!0}return i.command&&this.#J.commandDispatcher.run(i.command,null,null),!1}#nn(t){if(0===this.#Zi.size)return;const e=t.target;if(this.#Ji?.dropdown?.contains(e))return;const s=e.closest?.("li[data-index]");if(!s)return;const i=Number(s.getAttribute("data-index")),n=this.#Zi.get(i);n?this.#Ji?.plugin!==n.plugin&&this.#ln(n.name,n.plugin,n.li):this.#Ji&&this.#sn()}#ln(t,e,s){this.#Ji&&this.#sn();const i=this.#J.menu?.targetMap?.[t];if(!i||!this.selectMenu.form)return;const n=i.parentNode;this.selectMenu.form.appendChild(i),this.#an(i,s,this.selectMenu.form),Pe.utils.addClass(s,"se-submenu-open"),e.on?.(s);const o=this.#hn(i),r=this.#J.menu.subscribeDropdownOff((()=>{this.#sn(),this.selectMenu.close()}));this.#Ji={dropdown:i,plugin:e,originalParent:n,anchorLi:s,unsub:r,offCommit:o}}#hn(t){if(!this.#Qi)return()=>{};let e=!1;const s=t=>{if(e)return;const s=Pe.query.getEventTarget(t);Pe.check.isInputElement(s)||(e=!0,this.#Qi())};return t.addEventListener("mousedown",s,!0),t.addEventListener("keydown",s,!0),t.addEventListener("submit",s,!0),()=>{t.removeEventListener("mousedown",s,!0),t.removeEventListener("keydown",s,!0),t.removeEventListener("submit",s,!0)}}#sn(){const t=this.#Ji;t&&(this.#Ji=null,t.unsub?.(),t.offCommit?.(),t.dropdown.style.cssText="",t.dropdown.style.display="none",t.anchorLi&&Pe.utils.removeClass(t.anchorLi,"se-submenu-open"),t.originalParent&&t.originalParent!==t.dropdown.parentNode&&t.originalParent.appendChild(t.dropdown),t.plugin?.off?.())}#an(t,e,s){const i=e.getBoundingClientRect(),n=s.getBoundingClientRect(),o=!!this.#J.options.get("_rtl");t.style.position="absolute",t.style.right="",t.style.visibility="hidden",t.style.display="block";const r=t.offsetWidth,l=t.offsetHeight,a=pn.innerWidth,h=pn.innerHeight,c=i.right+4,d=i.left-r-4,u=Math.max(0,c+r-a),p=Math.max(0,-d);let g;g="right"===(o?"left":"right")?0===u?c:0===p?d:u<=p?c-u:d+p:0===p?d:0===u?c:p<=u?d+p:c-u,t.style.left=g-n.left+"px";const m=i.top,f=i.bottom-l,v=Math.max(0,m+l-h),b=Math.max(0,-f);let y;y=0===v?m:0===b?f:v<=b?m-v:f+b,t.style.top=y-n.top+"px",t.style.visibility=""}},{_w:mn,_d:fn}=Oe;const vn=class{#J;#cn;#dn;#un;#pn;#gn;#mn;#fn;#vn;#bn=null;#yn=null;#wn=null;#Cn=null;#_n=void 0;#kn=null;#xn=[];#$n=!1;#Sn=null;#En=null;#Tn=null;#Mn=null;#Nn=null;constructor(t,e,s,i,n,o){this.#J=t,this.#cn=e,this.#dn=s,this.#un=i,this.#pn=n;const r=Array.isArray(o)?{menu:o}:o||{};this.#gn=r.menu||null,this.#mn="string"==typeof r.maxHeight?r.maxHeight:"",this.#fn="string"==typeof r.minWidth?r.minWidth:"200px",this.#vn="function"==typeof r.onPlusClick?r.onPlusClick:null,this.#J.contextProvider.carrierWrapper.appendChild(this.#dn);const l=this.#J.eventManager;l.addEvent(this.#dn,"mousedown",this.#Bn.bind(this)),this.#Sn=Pe.utils.createElement("DIV",{class:"se-block-drag-indicator"}),this.#Sn.style.display="none",this.#cn.parentElement?.appendChild(this.#Sn),l.addEvent(this.#un,"click",this.#In.bind(this)),this.#pn.draggable=!0,l.addEvent(this.#pn,"dragstart",this.#Ln.bind(this)),l.addEvent(this.#pn,"dragend",this.#An.bind(this)),l.addEvent(this.#pn,"click",this.#On.bind(this)),l.addEvent(this.#cn,"mousemove",this.#Rn.bind(this)),l.addEvent(this.#cn,"mouseleave",this.#zn.bind(this));const a=this.#cn.parentElement;a&&(l.addEvent(a,"mouseleave",this.#Pn.bind(this)),l.addEvent(a,"dragover",this.#Dn.bind(this)),l.addEvent(a,"drop",this.#Fn.bind(this))),l.addEvent(this.#J.frameContext.get("eventWysiwyg"),"keydown",this.#Hn.bind(this),!0)}#qn(){this.#dn.style.display="flex";try{this.#dn.showPopover?.()}catch{}}#Wn(){try{this.#dn.hidePopover?.()}catch{}this.#dn.style.display="none"}positionForTarget(t,e){this.#Un(),this.#bn?.isOpen||this.#$n||(this.#Cn=t,this.#_n=e,this.#wn||(this.#wn=mn.requestAnimationFrame((()=>{this.#wn=null,this.#Cn&&this.#Vn(this.#Cn,this.#_n)}))))}hide(t){if(this.#bn?.isOpen)return;const e=t?.relatedTarget;e&&(this.#cn.contains(e)||this.#dn?.contains(e))||this.#jn()}hideNow(){this.#Un(),this.#Wn(),this.#bn?.close(),this.#Gn(null)}syncScroll(){this.#yn&&(Pe.utils.addClass(this.#dn,"se-no-transition"),this.#Kn(this.#yn),this.#dn.offsetHeight,Pe.utils.removeClass(this.#dn,"se-no-transition"),this.#bn?.isOpen&&this.#bn.setHidden("none"===this.#dn.style.display))}destroy(){this.#wn&&(mn.cancelAnimationFrame(this.#wn),this.#wn=null),this.#$n=!1,this.#Un(),this.#pn&&(this.#pn.draggable=!1),this.#Sn?.remove(),this.#dn?.remove(),this.#bn?.close(),this.#bn=null,this.#Gn(null),this.#Cn=null,this.#_n=void 0,this.#J=null,this.#cn=null,this.#dn=null,this.#un=null,this.#pn=null}#Gn(t){if(this.#Yn(),this.#yn=t,!t)return;const e=this.#Xn(t);if(e){this.#xn=e;for(let t=0;t<e.length;t++)Pe.utils.addClass(e[t],"se-block-hover")}else Pe.utils.addClass(t,"se-block-hover")}#Xn(t){try{const e=this.#J.selection.getRange();if(!e||e.collapsed)return null;const s=this.#J.format.getLine(e.startContainer,null),i=this.#J.format.getLine(e.endContainer,null);if(!s||!i||s===i)return null;const n=Pe.query.getListChildren(e.commonAncestorContainer,(t=>this.#J.format.isLine(t)),null),o=n.indexOf(s),r=n.indexOf(i);if(-1===o||-1===r)return null;const l=n.slice(Math.min(o,r),Math.max(o,r)+1);return-1===l.indexOf(t)?null:l}catch{}return null}#Zn(t){this.#Yn(),this.#xn=t||[];for(let t=0;t<this.#xn.length;t++)Pe.utils.addClass(this.#xn[t],"se-block-hover")}#Yn(){this.#yn&&Pe.utils.removeClass(this.#yn,"se-block-hover");for(let t=0;t<this.#xn.length;t++)Pe.utils.removeClass(this.#xn[t],"se-block-hover");this.#xn=[]}#jn(){this.#kn||(this.#kn=mn.setTimeout((()=>{this.#kn=null,this.#Wn(),this.#bn?.close(),this.#Gn(null)}),200))}#Un(){this.#kn&&(mn.clearTimeout(this.#kn),this.#kn=null)}#Rn(t){if(!this.#J)return;if(this.#$n)return;if(this.#Un(),this.#bn?.isOpen)return;const e=this.#J.frameContext.get("wysiwyg");if(!e)return;const s=this.#J.frameContext.get("wysiwygFrame");let i;if(s&&"IFRAME"===s.nodeName){const e=s.getBoundingClientRect(),n=s.contentDocument;n&&(i=n.elementFromPoint(e.width/2,t.clientY-e.top))}else{const s=e.getBoundingClientRect();i=document.elementFromPoint(s.left+s.width/2,t.clientY)}i&&e.contains(i)&&this.#Vn(i,t.clientY)}#zn(t){this.#bn?.isOpen||this.#Jn(t?.relatedTarget)||this.hideNow()}#Pn(t){this.#bn?.isOpen||this.#Jn(t?.relatedTarget)||this.hideNow()}#Jn(t){if(!t)return!1;const e=this.#cn?.parentElement;return!(!this.#dn?.contains(t)&&!e?.contains(t))}#Vn(t,e){if(!this.#J)return;const s=this.#J.format,i=this.#J.frameContext.get("wysiwyg");if(!i)return;let n=t;if(n===i&&void 0!==e){const t=i.getBoundingClientRect(),s=document.elementFromPoint(t.left+t.width/2,e);s&&i.contains(s)&&s!==i&&(n=s)}const o=function(t,e,s,i){if(!t||!s)return null;if(3===t.nodeType&&!(t=t.parentNode))return null;if(tt(t))return null;if(hn(t)){const s=cn(t);return s?un(s,e,i):null}let n=null;if(ln.test(t.nodeName))n=an(t);else if(on.test(t.nodeName))n=t;else if(rn.test(t.nodeName))n=t;else if(X(t.parentNode))n=an(t);else{const s=e.getLine(t,null);if(s&&(n=s),!n){const s=e.getBlock(t,null);s&&(n=ln.test(s.nodeName)?an(s):s)}}if(!n){let e=t;for(;e&&!tt(e);){if(1===e.nodeType&&e.parentNode&&tt(e.parentNode)){n=e;break}e=e.parentNode}}if(!n)return null;if(hn(n)){const t=cn(n);return t?un(t,e,i):null}return un(n,e,i)}(n,{getLine:(t,e)=>s.getLine(t,e),getBlock:(t,e)=>s.getBlock(t,e),isLine:t=>s.isLine(t),isBlock:t=>s.isBlock(t)},i,e);if(o){if(o.element!==this.#yn||"flex"!==this.#dn.style.display){if(this.#yn?.isConnected&&"flex"===this.#dn.style.display&&void 0!==e&&!this.#yn.contains(o.element)){const t=this.#yn.getBoundingClientRect();if(e>=t.top&&e<=t.bottom)return}this.#Gn(o.element),this.#Kn(o.element)}}else this.#jn()}#Kn(t){if(!t.isConnected)return void this.hideNow();const e=t.getBoundingClientRect(),s=this.#cn.getBoundingClientRect(),i=this.#J.frameContext.get("wysiwygFrame"),n=/^iframe$/i.test(i.nodeName),o=n?i.getBoundingClientRect():null;if(n){const t=i.clientHeight||0;if(e.bottom<=0||e.top>=t)return void this.#Wn()}else{const t=i.getBoundingClientRect();if(e.bottom<=t.top||e.top>=t.bottom)return void this.#Wn()}const r=mn.scrollX,l=mn.scrollY,a="flex"!==this.#dn.style.display;a&&(Pe.utils.addClass(this.#dn,"se-no-transition"),this.#dn.style.display="flex");const h=this.#dn.offsetHeight||0,c=this.#Qn(t,e),d=(n?c+o.top:c)+l-h/2,u=!!this.#J.options.get("_rtl"),p=this.#to(t,u);let g=0;if(this.#J.frameOptions.get("innerWidth")){const t=this.#J.frameContext.get("wysiwyg");if(t){const e=mn.getComputedStyle(t),s=De.get(u?e.paddingRight:e.paddingLeft,-1)||0,i=function(t,e){const s=(t||"").trim(),i=De.get(s,-1);return i?/rem$/.test(s)?i*(De.get(mn.getComputedStyle(fn.documentElement).fontSize,-1)||16):/em$/.test(s)?i*(De.get(e.fontSize,-1)||16):i:0}(e.getPropertyValue("--se-edit-inner-padding"),e);g=Math.max(0,s-i)}}const m=p+g;this.#dn.style.top=d+"px",u?(this.#dn.style.left="",this.#dn.style.right=mn.innerWidth-s.right-r+m+"px"):(this.#dn.style.right="",this.#dn.style.left=s.left+r+m+"px"),this.#qn(),a&&(this.#dn.offsetHeight,Pe.utils.removeClass(this.#dn,"se-no-transition"))}#Qn(t,e){try{const e=t.ownerDocument,s=e.createTreeWalker(t,NodeFilter.SHOW_TEXT,null);let i=null;for(;(i=s.nextNode())&&!i.textContent?.trim(););if(i){const t=e.createRange();t.setStart(i,0),t.setEnd(i,Math.min(1,i.length));const s=t.getClientRects();if(s.length)return(s[0].top+s[0].bottom)/2}}catch{}const s=De.get(mn.getComputedStyle(t).lineHeight,-1)||e.height;return e.top+Math.min(s,e.height)/2}#to(t,e){const s=this.#J.frameContext.get("wysiwyg");if(!s)return 0;const i=this.#J.format,n=e?"marginRight":"marginLeft",o=e?"paddingRight":"paddingLeft";let r=0;r+=De.get(mn.getComputedStyle(t)[n],-1)||0;let l=t.parentElement;for(;l&&l!==s;){if(i.isBlock(l)){const t=mn.getComputedStyle(l);r+=(De.get(t[o],-1)||0)+(De.get(t[n],-1)||0)}l=l.parentElement}return r}#eo(){if(!this.#yn)return;const t=this.#yn,e=this.#Xn(t),s=e?e[0]:t,i=e?e[e.length-1]:t;this.#J.selection.setRange(s,0,i,i.childNodes.length)}#In(t){if(t.preventDefault(),t.stopPropagation(),!this.#yn)return;const e=this.#J.format.addLineAfter(this.#yn);e&&(this.#J.selection.setRange(e,1,e,1),this.#J.history.push(!1),this.#vn&&(this.#Gn(e),this.#Kn(e),this.#vn(this.#J,{block:e,openMenu:()=>this.#so()})))}#Bn(t){const e=this.#pn&&(t.target===this.#pn||this.#pn.contains(t.target));Oe.isMobile?this.#J.store.set("_preventBlur",!0):e||t.preventDefault()}#Hn(){this.#Yn()}#Ln(t){if(!this.#yn)return void t.preventDefault();this.#En=this.#yn,this.#$n=!0,this.#bn?.close(),Pe.utils.addClass(this.#En,"se-block-dragging");const e=this.#J.frameContext.get("wysiwyg");this.#Mn=e||null,this.#Nn=e?Array.from(e.children):null;const s=!!this.#J.options.get("_rtl"),i=this.#En;t.dataTransfer.setDragImage(i,s?i.offsetWidth:-5,-5),t.dataTransfer.effectAllowed="move",t.dataTransfer.setData("application/x-suneditor-block-drag","1")}#Dn(t){this.#$n&&(t.preventDefault(),t.stopPropagation(),t.dataTransfer.dropEffect="move",this.#io(t.clientY))}#Fn(t){this.#$n&&(t.preventDefault(),t.stopPropagation(),this.#no())}#An(){if(this.#En&&Pe.utils.removeClass(this.#En,"se-block-dragging"),this.#Sn.style.display="none",this.#$n=!1,this.#En=null,this.#Tn=null,this.#Mn=null,this.#Nn=null,this.#pn?.parentNode){const t=this.#pn.parentNode,e=this.#pn.nextSibling;t.removeChild(this.#pn),t.insertBefore(this.#pn,e)}}#io(t){if(!this.#J||!this.#En)return;const e=this.#Mn,s=this.#Nn;if(!e||!s)return;const i=e.getBoundingClientRect(),n=this.#cn.parentElement.getBoundingClientRect();let o=null,r="after",l=0,a=1/0;for(let e=0;e<s.length;e++){const i=s[e],n=i.getBoundingClientRect(),h=Math.abs(t-n.top);h<a&&(a=h,o=i,r="before",l=n.top);const c=Math.abs(t-n.bottom);c<a&&(a=c,o=i,r="after",l=n.bottom)}if(o&&o!==this.#En){this.#Tn={element:o,position:r};const t=this.#Sn;t.style.display="block",t.style.top=l-n.top+"px",t.style.left=i.left-n.left+"px",t.style.width=i.width+"px"}else this.#Tn=null,this.#Sn.style.display="none"}#no(){const t=this.#En,e=this.#Tn;if(!t||!e||e.element===t)return;t.parentNode&&("before"===e.position?e.element.parentNode.insertBefore(t,e.element):e.element.parentNode.insertBefore(t,e.element.nextSibling),this.#Gn(t),this.#Kn(t),this.#J.history.push(!1))}#On(t){if(t.preventDefault(),t.stopPropagation(),this.#$n)return;const e=this.#J.component.get(this.#yn);if(e)return this.#bn?.close(),this.#Yn(),void this.#J.component.select(e.target,e.pluginName);this.#so()}#so(){if(!this.#gn)return;if(this.#bn||(this.#bn=this.#oo()),this.#bn.isOpen)return void this.#bn.close();this.#eo();const t=this.#J.format.getLines(null);t.length>0&&this.#Zn(t);const e=this.#J.offset.getGlobal(this.#pn),s=Pe.utils.getClientSize().h-(e.top-mn.scrollY+e.height),i=e.top-mn.scrollY,n=`${this.#J.options.get("_rtl")?"left":"right"}-${s>=i?"bottom":"top"}`;this.#bn.open(n)}#oo(){const t=new gn(this,this.#J,{items:this.#gn,resolveButton:us,selectMenuParams:{position:"right-top",dir:this.#J.options.get("_rtl")?"rtl":"ltr",minWidth:this.#fn,maxHeight:this.#mn,keydownTarget:mn,closeMethod:()=>{Pe.utils.removeClass(this.#pn,"on"),this.#Yn()},openMethod:()=>{Pe.utils.addClass(this.#pn,"on")}}});return t.attach(this.#pn,this.#ro.bind(this),{class:"se-block-action-menu"}),t.createRows(t.getItems()),t}#ro(t){this.#yn&&this.#J&&t&&(this.#bn?.dispatch(t,{block:this.#yn}),"dropdownFree"!==t.kind&&this.#bn?.close())}},{NO_EVENT:bn}=Oe,yn={bold:["font-weight"],underline:["text-decoration"],italic:["font-style"],strike:["text-decoration"]};class wn{#H;#J;#t;#X;#rt;#_i;#lo=null;#ao=null;#ho=null;#co=null;constructor(t){this.#H=t,this.#J=t.$,this.#t=t.store,this.#X=this.#J.frameContext,this.#rt=this.#J.options,this.#_i=this.#J.eventManager}async execute(t,e){if(!this.#X.get("isReadOnly")||/copy|cut|selectAll|selectAll_full|codeView|markdownView|fullScreen|print|preview|showBlocks|finder/.test(t))switch(t){case"selectAll":this.#do();break;case"selectAll_full":this.#uo();break;case"copy":{const t=this.#J.selection.getRange();if(t.collapsed)break;const e=Pe.utils.createElement("div",null,t.cloneContents());await this.#J.html.copy(e.innerHTML);break}case"newDocument":this.#J.html.set(`<${this.#rt.get("defaultLine")}><br></${this.#rt.get("defaultLine")}>`),this.#J.focusManager.focus(),this.#J.history.push(!1),this.#X.has("documentType_use_header")&&this.#X.get("documentType").reHeader();break;case"finder":this.#J.finder.isOpen?this.#J.finder.close():this.#J.finder.open(!0);break;case"codeView":this.#J.viewer.codeView(!this.#X.get("isCodeView"));break;case"markdownView":this.#J.viewer.markdownView(!this.#X.get("isMarkdownView"));break;case"fullScreen":this.#J.viewer.fullScreen(!this.#X.get("isFullScreen"));break;case"indent":this.#J.format.indent();break;case"outdent":this.#J.format.outdent();break;case"undo":this.#J.history.undo();break;case"redo":this.#J.history.redo();break;case"removeFormat":this.#J.inline.remove(),this.#J.focusManager.focus();break;case"print":this.#J.viewer.print();break;case"preview":this.#J.viewer.preview();break;case"showBlocks":this.#J.viewer.showBlocks(!this.#X.get("isShowBlocks"));break;case"dir":this.#J.ui.setDir(this.#rt.get("_rtl")?"ltr":"rtl");break;case"dir_ltr":this.#J.ui.setDir("ltr");break;case"dir_rtl":this.#J.ui.setDir("rtl");break;case"save":await this.#po();break;case"copyFormat":this.#go(e);break;case"pageBreak":this.#mo();break;case"pageUp":this.#X.get("documentType").pageUp();break;case"pageDown":this.#X.get("documentType").pageDown();break;default:this.#fo(t)}}copyFormat(){if(this.#ho?.length)try{const t=[...this.#ho],e=t.pop();if(this.#J.inline.remove(),e){const s=this.#J.inline.apply(e,{stylesToModify:null,nodesToRemove:[e.nodeName],strictRemove:!1}),{parent:i,inner:n}=this.#J.nodeTransform.createNestedNode(t);s.parentNode.insertBefore(i,s),n.appendChild(s),this.#J.selection.setRange(s,Pe.check.isZeroWidth(s)?1:0,s,1)}if(this.#rt.get("copyFormatKeepOn"))return;this.#co()}catch(t){console.warn("[SUNEDITOR.copyFormat.error] ",t),this.#co?.()||(this.#ho=null,this.#co=null)}}#do(){this.#J.ui.offCurrentController(),this.#J.menu.containerOff();const t=this.#X.get("wysiwyg");let e=null,s="";const i=this.#rt.get("scopeSelectionTags"),n=this.#J.selection.getRange();if(!n.collapsed){let o=e=n.commonAncestorContainer,r=s=o.nodeName?.toLowerCase();if(0===n.startOffset&&n.endOffset===n.endContainer.textContent?.length){const t=o.parentElement;(Pe.check.isList(t)||Pe.check.isListCell(t))&&t.firstChild.contains?.(n.startContainer)&&t.lastChild?.contains(n.endContainer)&&(e=o=t.parentElement,s=o.nodeName?.toLowerCase())}for(r=o.nodeName?.toLowerCase();o&&(!o.nextSibling&&!o.previousSibling&&!i.includes(r)||Pe.check.isContentLess(r))&&o!==t;)o=o.parentElement,r=o.nodeName?.toLowerCase();i.includes(r)&&(e=o,s=r)}const o=i.filter((t=>t!==s));let r=Pe.query.getParentElement(e||this.#J.selection.getNode(),(t=>o.includes(t.nodeName?.toLowerCase())))||t,{first:l,last:a}=Cn(r);if(!l||!a)return;const h=Pe.check.isZeroWidth;for(;h(l)&&h(a)&&r!==t;)r=r.parentElement,({first:l,last:a}=Cn(Pe.query.getParentElement(r,(t=>o.includes(t.nodeName?.toLowerCase())))||t));if(!l||!a)return;let c=null;if(Pe.check.isMedia(l)||(c=this.#J.component.get(l))||Pe.check.isTableElements(l)){c||=this.#J.component.get(l);const t=Pe.utils.createElement("BR"),e=Pe.utils.createElement(this.#rt.get("defaultLine"),null,t);l=c?c.container||c.cover:l,l.parentElement.insertBefore(e,l),l=t}if(Pe.check.isMedia(a)||(c=this.#J.component.get(a))||Pe.check.isTableElements(a)){c||=this.#J.component.get(a);const t=Pe.utils.createElement("BR"),e=Pe.utils.createElement(this.#rt.get("defaultLine"),null,t);a=c?c.container||c.cover:a,a.parentElement.appendChild(e),a=t}this.#J.toolbar._showBalloon(this.#J.selection.setRange(l,0,a,a.textContent.length))}#uo(){this.#J.ui.offCurrentController(),this.#J.menu.containerOff();const t=this.#X.get("wysiwyg");let{first:e,last:s}=Cn(t);if(!e||!s)return;let i=null;if(Pe.check.isMedia(e)||(i=this.#J.component.get(e))||Pe.check.isTableElements(e)){i||=this.#J.component.get(e);const t=Pe.utils.createElement("BR"),s=Pe.utils.createElement(this.#rt.get("defaultLine"),null,t);e=i?i.container||i.cover:e,e.parentElement.insertBefore(s,e),e=t}if(Pe.check.isMedia(s)||(i=this.#J.component.get(s))||Pe.check.isTableElements(s)){i||=this.#J.component.get(s);const t=Pe.utils.createElement("BR"),e=Pe.utils.createElement(this.#rt.get("defaultLine"),null,t);s=i?i.container||i.cover:s,s.parentElement.appendChild(e),s=t}this.#J.toolbar._showBalloon(this.#J.selection.setRange(e,0,s,s.textContent.length))}async#po(){const t=this.#X;if(!t.get("isChanged"))return;const e=this.#J.html.get(),s=await this.#_i.triggerEvent("onSave",{frameContext:t,data:e});if(s===bn){const s=t.get("originElement");/^TEXTAREA$/i.test(s.nodeName)?s.value=e:s.innerHTML=e}else if(!1===s)return;t.set("isChanged",!1),t.set("savedIndex",this.#J.history.getRootStack()[this.#t.get("rootKey")].index),this.#J.commandDispatcher.applyTargets("save",(t=>{t.disabled=!0}))}#go(t){if("function"==typeof this.#co)return void this.#co();const e=this.#X.get("wysiwyg");this.#ho=[...this.#H._eventOrchestrator.__cacheStyleNodes],this.#co=this.#vo.bind(this,this.#_i,e,t),Pe.utils.addClass(e,"se-copy-format-cursor"),Pe.utils.addClass(t,"on"),this.#lo=this.#_i.addGlobalEvent("keydown",(t=>{Fe.isEsc(t.code)&&this.#co?.()})),this.#ao=this.#_i.addGlobalEvent("mousedown",(s=>{e.contains(s.target)||s.target===t||this.#co?.()}))}#vo(t,e,s){return this.#lo=t.removeGlobalEvent(this.#lo),this.#ao=t.removeGlobalEvent(this.#ao),this.#ho=null,this.#co=null,Pe.utils.removeClass(e,"se-copy-format-cursor"),Pe.utils.removeClass(s,"on"),!0}#fo(t){t=this.#rt.get("_defaultTagCommand")[t.toLowerCase()]||t;let e=this.#rt.get("convertTextTags")[t]||t;const s=this.#t.get("currentNodesMap"),i=s.includes(this.#rt.get("_styleCommandMap")[e])?null:Pe.utils.createElement(e);/^sub$/i.test(e)&&s.includes("superscript")?e="sup":/^sup$/i.test(e)&&s.includes("subscript")&&(e="sub"),this.#J.inline.apply(i,{stylesToModify:yn[t]||null,nodesToRemove:[e],strictRemove:!1}),this.#J.focusManager.focus()}#mo(){const t=Pe.utils.createElement("DIV",{class:"se-component se-component-line-break se-page-break"});this.#J.component.insert(t,{skipCharCount:!0,insertBehavior:"line"});const e=t.nextElementSibling||this.#J.format.addLine(t);this.#J.selection.setRange(e,1,e,1),this.#J.history.push(!1)}}const Cn=function(t){const e=Pe.check.isContentLess;return{first:Pe.query.getEdgeChild(Pe.query.getEdgeChild(t,(t=>!e(t)),!1),(t=>0===t.childNodes.length||3===t.nodeType||Y(t)||K(t)),!1)||t.firstChild,last:Pe.query.getEdgeChild(t.lastChild,(t=>0===t.childNodes.length||3===t.nodeType||Y(t)||K(t)),!0)||t.lastChild}},_n=".se-menu-list .se-toolbar-btn[data-command]",kn=["bold","underline","italic","strike","subscript","superscript","indent","outdent"],xn=kn.concat(["undo","redo","save","fullScreen","showBlocks","codeView","markdownView","finder","dir","dir_ltr","dir_rtl"]);class $n{#J;#e;#rt;#bo;#yo=new Map;#wo=kn;constructor(t){this.#J=t.$,this.#e=this.#J.context,this.#rt=this.#J.options,this.#bo=new wn(t),this.allCommandButtons=new Map,this.subAllCommandButtons=new Map}get targets(){return this.#yo}get activeCommands(){return this.#wo}run(t,e,s){if(e){if(/more/i.test(e)){const e=Pe.query.getParentElement(s,".se-toolbar"),i=Pe.utils.hasClass(e,"se-toolbar-sub")?this.#J.subToolbar:this.#J.toolbar;if(s!==i.currentMoreLayerActiveButton){const n=e.querySelector("."+t);n&&(i._moreLayerOn(s,n),i._showBalloon(),i._showInline()),Pe.utils.addClass(s,"on")}else i.currentMoreLayerActiveButton&&(i._moreLayerOff(),i._showBalloon(),i._showInline());return void this.#J.viewer._resetFullScreenHeight()}if(/container/.test(e)&&(null===this.#J.menu.targetMap[t]||s!==this.#J.menu.currentContainerActiveButton))return void this.#J.menu.containerOn(s);if(this.#J.ui.isButtonDisabled(s))return;if(/dropdown/.test(e)&&(null===this.#J.menu.targetMap[t]||s!==this.#J.menu.currentDropdownActiveButton))return void this.#J.menu.dropdownOn(s);if(/modal/.test(e))return void this.#J.plugins[t].open(s);/command/.test(e)?this.#J.plugins[t].action(s):/browser/.test(e)?this.#J.plugins[t].open(null):/popup/.test(e)&&this.#J.plugins[t].show()}else t&&this.#bo.execute(t,s);/dropdown/.test(e)?this.#J.menu.dropdownOff():/command/.test(e)||(this.#J.menu.dropdownOff(),this.#J.menu.containerOff())}runFromTarget(t){if(Pe.check.isInputElement(t))return;const e=Pe.query.getCommandTarget(t);if(!e)return;const s=e.getAttribute("data-command"),i=e.getAttribute("data-type");(s||i)&&(e.disabled||this.run(s,i,t))}applyTargets(t,e){this.#yo.has(t)&&this.#yo.get(t).forEach(e)}registerTargets(t,e){if(!t||!e)return;(xn.includes(t)||this.#J.plugins[t])&&(this.#yo.get(t)?this.#yo.get(t).includes(e)||this.#yo.get(t).push(e):this.#yo.set(t,[e]))}unregisterTargets(t,e){const s=this.#yo.get(t);if(!s)return;const i=s.indexOf(e);-1!==i&&s.splice(i,1),0===s.length&&this.#yo.delete(t)}resetTargets(){this.#yo=new Map,this._initCommandButtons()}_initCommandButtons(){const t=this.#e;this.#Co(this.allCommandButtons,t.get("toolbar_buttonTray")),this.#Co(this.subAllCommandButtons,t.get("toolbar_sub_buttonTray"))}_copyFormat(){this.#bo.copyFormat()}#Co(t,e){if(!e)return;const s=e.querySelectorAll(_n),i=this.#rt.get("shortcuts"),n=this.#rt.get("_reverseCommandArray"),o=this.#J.shortcuts.keyMap,r=this.#J.shortcuts.reverseKeys;for(let e,l,a=0,h=s.length;a<h;a++)e=s[a],l=e.getAttribute("data-command"),t.set(l,e),this.registerTargets(l,e),is(l,e,i[l],o,n,r)}_destroy(){this.#yo.clear(),this.allCommandButtons.clear(),this.subAllCommandButtons.clear(),this.#wo=null}}const Sn=`${_n}:not([class~="se-code-view-enabled"]):not([data-type="MORE"])`,En=`${_n}:not([class~="se-component-enabled"]):not([data-type="MORE"])`,{_w:Tn}=Oe;const Mn=class{#H;#J;#t;#Ci;#ot;#rt;#e;#O;#X;#_i;#_o;#ko;#xo;#$o;#So=null;#Eo;#To=!1;#Mo=null;#No=null;#Bo=[];#Io=[];#Lo=!1;#Ao=null;#Oo=null;#Ro=null;#zo=new Set;constructor(t){this.#H=t,this.#J=t.$,this.#t=t.store,this.#Ci=this.#J.contextProvider,this.#ot=this.#Ci.carrierWrapper,this.#rt=this.#J.options,this.#e=this.#J.context,this.#O=this.#J.frameRoots,this.#X=this.#J.frameContext,this.#_i=this.#J.eventManager;const e=function({lang:t,icons:e}){const s='<div><button type="button" class="close" data-command="close" title="'+t.close+'">'+e.cancel+"</button></div><div><span></span></div>";return Pe.utils.createElement("DIV",{class:"se-alert-content"},s)}(this.#Ci);this.alertModal=e,this.alertMessage=e.querySelector("span");const s=function(){const t='<div class="se-toast-container"><span></span></div>';return Pe.utils.createElement("DIV",{class:"se-toast"},t)}();s.setAttribute("popover","manual"),this.toastPopup=s,this.toastContainer=s.querySelector(".se-toast-container"),this.toastMessage=s.querySelector("span"),this.#ot.appendChild(s),this.#_o=this.#ot.querySelector(".se-alert"),this.#ko=this.#ot.querySelector(".se-alert .se-modal-inner"),this.#ko.appendChild(e),this.#xo=[this.#Po.bind(this),this.#Do.bind(this)],this.#$o=!1,this.#Eo=this.#ot.querySelector(".se-back-wrapper"),this.opendControllers=[],this.controllerTargetContext=null,this._figureContainer=null}get selectMenuOn(){return this.#zo.size>0}setSelectMenuOpen(t,e){e?this.#zo.add(t):this.#zo.delete(t)}setEditorStyle(t,e){e||=this.#X;const s=e.get("options");s.set("editorStyle",t);const i=ze._setDefaultOptionStyle(s,t);s.set("_defaultStyles",i),e.get("topArea").style.cssText=i.top;const n=e.get("code");if(this.#rt.get("hasCodeMirror")){const t=s.get("_defaultStyles").frame.split(";");for(let e,s=0,i=t.length;s<i;s++){if(e=t[s].trim(),!e)continue;const[i,o]=e.split(":");n.style.setProperty(i.trim(),o.trim())}}else n.style.cssText=s.get("_defaultStyles").frame;s.get("iframe")?(e.get("wysiwygFrame").style.cssText=i.frame,e.get("wysiwyg").style.cssText=i.editor):e.get("wysiwygFrame").style.cssText=i.frame+i.editor}setTheme(t){if("string"!=typeof t)return;const e=this.#rt,s=e.get("_themeClass").trim();e.set("theme",t||""),e.set("_themeClass",t?` se-theme-${t}`:""),t=e.get("_themeClass").trim();const i=e=>{e&&(s&&Pe.utils.removeClass(e,s),t&&Pe.utils.addClass(e,t))};i(this.#ot),this.#Ci.applyToRoots((t=>{i(t.get("topArea")),i(t.get("wysiwyg"))})),i(this.#e.get("statusbar_wrapper")),i(this.#e.get("toolbar_wrapper"))}setDir(t){const e="rtl"===t;if(this.#rt.get("_rtl")===e)return;const s=this.#rt.get("textDirection"),i=this.#rt.get("_editableClass"),n=this.#rt.get("printClass");try{this.#rt.set("_rtl",e),this.#rt.set("textDirection",t);const s=e?this.#rt.get("_editableClass").replace(/\s*se-rtl/,"")+" se-rtl":this.#rt.get("_editableClass").replace(/\s*se-rtl/,"");this.#rt.set("_editableClass",s),this.#rt.get("printClass")&&this.#rt.set("printClass",e?this.#rt.get("printClass").replace(/\s*se-rtl/,"")+" se-rtl":this.#rt.get("printClass").replace(/\s*se-rtl/,"")),this.offCurrentController();const i=this.#X,n=this.#J.pluginManager.plugins;for(const e in n)n[e].setDir?.(t);const o=this.#e.get("toolbar_wrapper"),r=this.#e.get("statusbar_wrapper");e?(this.#Ci.applyToRoots((t=>{Pe.utils.addClass([t.get("topArea"),t.get("wysiwyg"),t.get("documentTypePageMirror")],"se-rtl"),t.get("wysiwyg").dir="rtl"})),Pe.utils.addClass([this.#ot,o,r],"se-rtl")):(this.#Ci.applyToRoots((t=>{Pe.utils.removeClass([t.get("topArea"),t.get("wysiwyg"),t.get("documentTypePageMirror")],"se-rtl"),t.get("wysiwyg").removeAttribute("dir")})),Pe.utils.removeClass([this.#ot,o,r],"se-rtl"));const l=Pe.query.getListChildren(i.get("wysiwyg"),(t=>this.#J.format.isLine(t)&&!!(t.style.marginRight||t.style.marginLeft||t.style.textAlign)),null);for(let t,e,s,i=0;t=l[i];i++)t=l[i],s=t.style.marginRight,e=t.style.marginLeft,(s||e)&&(t.style.marginRight=e,t.style.marginLeft=s),s=t.style.textAlign,"left"===s?t.style.textAlign="right":"right"===s&&(t.style.textAlign="left");this.#Fo(e),this.#t.mode.isBalloon?this.#J.toolbar._showBalloon():this.#t.mode.isSubBalloon&&this.#J.subToolbar._showBalloon()}catch(t){this.#rt.set("_rtl",!e),this.#rt.set("textDirection",s),this.#rt.set("_editableClass",i),null!==n&&this.#rt.set("printClass",n),console.warn(`[SUNEDITOR.ui.setDir.fail] ${t.toString()}`)}this.#t.set("_lastSelectionNode",null),this.#H._eventOrchestrator.applyTagEffect()}readOnly(t,e){const s=e?this.#O.get(e):this.#X;s.set("isReadOnly",!!t),this._toggleControllerButtons(!!t),t?(this.offCurrentController(),this.offCurrentModal(),this.#J.toolbar?.currentMoreLayerActiveButton?.disabled&&this.#J.toolbar._moreLayerOff(),this.#J.subToolbar?.currentMoreLayerActiveButton?.disabled&&this.#J.subToolbar._moreLayerOff(),this.#J.menu?.currentDropdownActiveButton?.disabled&&this.#J.menu.dropdownOff(),this.#J.menu?.currentContainerActiveButton?.disabled&&this.#J.menu.containerOff(),s.get("code").setAttribute("readOnly","true"),Pe.utils.addClass(s.get("wysiwyg"),"se-read-only")):(s.get("code").removeAttribute("readOnly"),Pe.utils.removeClass(s.get("wysiwyg"),"se-read-only")),this.#rt.get("hasCodeMirror")&&this.#J.viewer._codeMirrorEditor("readonly",!!t,e)}disable(t){const e=t?this.#O.get(t):this.#X;this.#J.toolbar.disable(),this.offCurrentController(),this.offCurrentModal(),e.get("wysiwyg").setAttribute("contenteditable","false"),e.set("isDisabled",!0),this.#rt.get("hasCodeMirror")?this.#J.viewer._codeMirrorEditor("readonly",!0,t):e.get("code").disabled=!0}enable(t){const e=t?this.#O.get(t):this.#X;this.#J.toolbar.enable(),e.get("wysiwyg").setAttribute("contenteditable","true"),e.set("isDisabled",!1),this.#rt.get("hasCodeMirror")?this.#J.viewer._codeMirrorEditor("readonly",!1,t):e.get("code").disabled=!1}show(t){const e=(t?this.#O.get(t):this.#X).get("topArea").style;"none"===e.display&&(e.display="block")}hide(t){(t?this.#O.get(t):this.#X).get("topArea").style.display="none"}showLoading(t){const e=(t?this.#O.get(t).get("container"):this.#ot).querySelector(".se-loading-box");e.style.display="block",e.showPopover?.()}hideLoading(t){const e=(t?this.#O.get(t).get("container"):this.#ot).querySelector(".se-loading-box");e.hidePopover?.(),e.style.display="none"}alertOpen(t,e){this.alertMessage.textContent=t,Pe.utils.removeClass(this.alertModal,"se-alert-error|se-alert-success"),e&&Pe.utils.addClass(this.alertModal,`se-alert-${e}`),this.#$o&&(this.#So=this.#_i.addEvent(this.#ko,"click",this.#xo[1])),this.#Mo&&=this.#_i.removeGlobalEvent(this.#Mo),this.#Mo=this.#_i.addGlobalEvent("keydown",this.#xo[0]),this.#_o.style.display="block",this.#_o.showPopover?.(),Pe.utils.addClass(this.alertModal,"se-modal-show")}alertClose(){Pe.utils.removeClass(this.alertModal,"se-modal-show"),Pe.utils.removeClass(this.alertModal,"se-alert-*"),this.#_o.hidePopover?.(),this.#_o.style.display="none",this.#So&&=this.#_i.removeEvent(this.#So),this.#Mo&&=this.#_i.removeGlobalEvent(this.#Mo)}showToast(t,e=1e3,s){Pe.utils.hasClass(this.toastContainer,"se-toast-show")&&this.closeToast(),Pe.utils.removeClass(this.toastPopup,"se-toast-error|se-toast-success"),s&&Pe.utils.addClass(this.toastPopup,`se-toast-${s}`),this.toastPopup.style.display="block",this.toastPopup.showPopover?.(),this.toastMessage.textContent=t,Pe.utils.addClass(this.toastContainer,"se-toast-show"),this.#No=Tn.setTimeout((()=>{this.closeToast()}),e)}closeToast(){this.#No&&Tn.clearTimeout(this.#No),this.#No=null,Pe.utils.removeClass(this.toastContainer,"se-toast-show"),this.toastPopup.hidePopover?.(),this.toastPopup.style.display="none"}setControllerOnDisabledButtons(t){return t&&!this.#To?(this._toggleControllerButtons(!0),this.#To=!0):!t&&this.#To&&(this._toggleControllerButtons(!1),this.#To=!1),this.#To}onControllerContext(){this.controllerTargetContext=this.#X.get("topArea")}offControllerContext(){this.controllerTargetContext=null}enableBackWrapper(t){this.#Eo.style.cursor=t,this.#Eo.style.display="block",this.#Eo.showPopover?.()}disableBackWrapper(){this.#Eo.hidePopover?.(),this.#Eo.style.display="none",this.#Eo.style.cursor="default"}offCurrentController(){this.#J.component.__deselect()}offCurrentModal(){this.opendModal?.close()}getVisibleFigure(){return"block"===this._figureContainer?.style.display?this._figureContainer:null}setFigureContainer(t){this._figureContainer=t}preventToolbarHide(t){this.#Lo=t}get isPreventToolbarHide(){return this.#Lo}get blockHandle(){return this.#Ro}reset(t){t.set("_editorHeight",t.get("wysiwygFrame").offsetHeight),this.#Ao=t.get("lineBreaker_t"),this.#Oo=t.get("lineBreaker_b");const e=this.#rt.get("blockHandle");e&&t.get("blockHandleArea")&&!this.#Ro&&(this.#Ro=new vn(this.#J,t.get("blockHandleArea"),t.get("blockHandle"),t.get("blockHandlePlus"),t.get("blockHandleDrag"),e))}_offControllers(){const t=this.opendControllers,e=[];for(let s,i=0;i<t.length;i++)s=t[i],s.fixed?e.push(s):(s.inst.controllerClose?.(),s.form&&(s.form.style.display="none"));this.opendControllers=e,this.currentControllerName="",this.#t.set("_preventBlur",!1)}_syncScrollPosition(t){const e=t.scrollTop||t.scrollY||0,s=t.scrollLeft||t.scrollX||0;this.#t.mode.isBalloon&&"block"===this.#e.get("toolbar_main").style.display?(this.#e.get("toolbar_main").style.top=this.#J.toolbar.balloonOffset.top-e+"px",this.#e.get("toolbar_main").style.left=this.#J.toolbar.balloonOffset.left-s+"px"):this.#t.mode.isSubBalloon&&"block"===this.#e.get("toolbar_sub_main").style.display&&(this.#e.get("toolbar_sub_main").style.top=this.#J.subToolbar.balloonOffset.top-e+"px",this.#e.get("toolbar_sub_main").style.left=this.#J.subToolbar.balloonOffset.left-s+"px"),this.#Ro?.syncScroll(),this.controllerTargetContext!==this.#X.get("topArea")&&this.offCurrentController(),this.#Ho(s,e)}_repositionControllers(){const t=this.opendControllers;if(0!==t.length){_i.get("__dragMove")&&_i.get("__dragMove")();for(let e=0;e<t.length;e++)t[e].notInCarrier||t[e].inst?._scrollReposition()}}#Ho(t,e){if(this.#Ao){const s=this.#Ao.style;if("none"!==s.display){const i=(this.#Ao.getAttribute("data-offset")||",").split(",");s.top=De.get(s.top,0)-(e-De.get(i[0],0))+"px",s.left=De.get(s.left,0)-(t-De.get(i[1],0))+"px",this.#Ao.setAttribute("data-offset",e+","+t)}}if(this.#Oo){const s=this.#Oo.style;if("none"!==s.display){const i=(this.#Oo.getAttribute("data-offset")||",").split(",");s.top=De.get(s.top,0)-(e-De.get(i[0],0))+"px",s[i[1]]=De.get(s[i[1]],0)-(t-De.get(i[2],0))+"px",this.#Oo.setAttribute("data-offset",e+","+i[1]+","+t)}}const s=this.opendControllers;for(let i=0;i<s.length;i++)s[i].notInCarrier&&(s[i].form.style.top=s[i].inst.__offset.top-e+"px",s[i].form.style.left=s[i].inst.__offset.left-t+"px")}_visibleControllers(t,e){const s=t?"":"hidden",i=e??s?"":"hidden",n=this.opendControllers;for(let t,e=0;e<n.length;e++)t=n[e],t.form&&(t.form.style.visibility=s);this.#Ao.style.visibility=i,this.#Oo.style.visibility=i}setCurrentControllerContext;#Fo(t){const e=this.#Ci.icons,s=this.#J.commandDispatcher?.targets;if(!s)return;const i=this.#J.shortcuts?.keyMap;this.#J.shortcuts?.reverseKeys?.forEach((t=>{const e=i?.get(t);e&&([e.command,e.r]=[e.r,e.command])})),this.#J.commandDispatcher.applyTargets("dir",(s=>{Pe.utils.changeTxt(s.querySelector(".se-tooltip-text"),this.#Ci.lang[t?"dir_ltr":"dir_rtl"]),Pe.utils.changeElement(s.firstElementChild,e[t?"dir_ltr":"dir_rtl"])})),t?(Pe.utils.addClass(s.get("dir_rtl"),"active"),Pe.utils.removeClass(s.get("dir_ltr"),"active")):(Pe.utils.addClass(s.get("dir_ltr"),"active"),Pe.utils.removeClass(s.get("dir_rtl"),"active"))}_initToggleButtons(){const t=this.#e;this.#Io=ze.nodeListToArray(t.get("toolbar_buttonTray").querySelectorAll(Sn)),this.#Bo=ze.nodeListToArray(t.get("toolbar_buttonTray").querySelectorAll(En)),this.#rt.has("_subMode")&&(this.#Io=this.#Io.concat(ze.nodeListToArray(t.get("toolbar_sub_buttonTray").querySelectorAll(Sn))),this.#Bo=this.#Bo.concat(ze.nodeListToArray(t.get("toolbar_sub_buttonTray").querySelectorAll(En))))}_toggleCodeViewButtons(t){Pe.utils.setDisabled(this.#Io,t)}_toggleControllerButtons(t){Pe.utils.setDisabled(this.#Bo,t)}isButtonDisabled(t){return!(!this.#X.get("isReadOnly")||!Pe.utils.arrayIncludes(this.#Bo,t))}_updatePlaceholder(t){t||=this.#X;const e=t.get("isMarkdownView")||t.get("isCodeView"),s=!e&&this.#qo(t),i=t.get("placeholder");i&&(i.style.display=e||s||!this.#J.facade.isEmpty(t)?"none":"block")}resolveLinePlaceholder(t,e){if(!t||!e)return"";if("object"!=typeof e)return Pe.check.isListCell(t)||Pe.query.getParentElement(t,Pe.check.isTableCell)?"":e;const s=this.#J.format,i=t.nodeName.toLowerCase();if("string"==typeof e[i])return e[i];if(Pe.check.isListCell(t)&&"string"==typeof e["@list"])return e["@list"];if(s.isClosureBrLine(t)&&"string"==typeof e["@closureBrLine"])return e["@closureBrLine"];if(s.isBrLine(t)&&"string"==typeof e["@brLine"])return e["@brLine"];const n=s.getBlock(t);if(n&&n!==t){const t=n.nodeName.toLowerCase();if("string"==typeof e[t])return e[t];if(s.isClosureBlock(n)&&"string"==typeof e["@closureBlock"])return e["@closureBlock"];if("string"==typeof e["@block"])return e["@block"]}return s.isNormalLine(t)&&"string"==typeof e["@normalLine"]?e["@normalLine"]:"string"==typeof e["@line"]?e["@line"]:""}#qo(t){const e=t.get("placeholder_line");if(!e)return!1;const s=t.get("wysiwyg"),i=this.#t.get("hasFocus")?this.#J.format.getLine(this.#J.selection.selectionNode):null,n=Pe.check.isEmptyLine(i)?this.resolveLinePlaceholder(i,e):"",o=n?i:null,r=s.querySelectorAll(".se-placeholder-line");for(let t=0;t<r.length;t++){const e=r[t];e!==o&&(e.classList.remove("se-placeholder-line"),e.removeAttribute("data-se-placeholder-line"),e.getAttribute("class")||e.removeAttribute("class"))}return!!o&&(o.classList.add("se-placeholder-line"),o.setAttribute("data-se-placeholder-line",n),!0)}_syncFrameState(t){if(t&&(this._iframeAutoHeight(t),this._updatePlaceholder(t),t.has("documentType_use_page"))){const e=t.get("documentTypePageMirror"),s=e.ownerDocument.createDocumentFragment();for(let e=t.get("wysiwyg").firstChild;e;e=e.nextSibling)s.appendChild(e.cloneNode(!0));e.replaceChildren(s),t.get("documentType").rePage(!0)}}_iframeAutoHeight(t){if(!t)return;const e=t.get("_iframeAuto");if(e)Tn.setTimeout((()=>{const s=e.offsetHeight,i=t.get("wysiwygFrame");if(!i)return;i.style.height=s+"px";const n=t.get("options");if(n?.get("iframe")){const t=n.get("maxHeight");t&&i.setAttribute("scrolling",s>De.get(t)?"auto":"no")}Oe.isResizeObserverSupported||this._emitResizeEvent(t,s,null)}),0);else if(!Oe.isResizeObserverSupported){const e=t.get("wysiwygFrame");e&&this._emitResizeEvent(t,e.offsetHeight,null)}}_emitResizeEvent(t,e,s){e=-1===e?s?.borderBoxSize&&s.borderBoxSize[0]?s.borderBoxSize[0].blockSize:s.contentRect.height+De.get(t.get("wwComputedStyle").getPropertyValue("padding-left"))+De.get(t.get("wwComputedStyle").getPropertyValue("padding-right")):e,t.get("_editorHeight")!==e&&(this.#_i.triggerEvent("onResizeEditor",{height:e,prevHeight:t.get("_editorHeight"),frameContext:t,observerEntry:s}),t.set("_editorHeight",e)),t.has("documentType_use_page")&&t.get("documentType").resizePage()}init(){this.#$o=!this.#_i.addEvent(this.alertModal.querySelector('[data-command="close"]'),"click",this.alertClose.bind(this)),this._initToggleButtons()}#Do(t){const e=Pe.query.getEventTarget(t);(/close/.test(e.getAttribute("data-command"))||e===this.#ko)&&this.alertClose()}#Po(t){Fe.isEsc(t.code)&&this.alertClose()}_destroy(){this.#No&&Tn.clearTimeout(this.#No),this.#Mo&&=this.#_i.removeGlobalEvent(this.#Mo),this.#So&&=this.#_i.removeEvent(this.#So),this.opendModal=null,this.opendBrowser=null,this.#Ao=null,this.#Oo=null,this.#Ro?.destroy(),this.#Ro=null,this.#Bo=null,this.#Io=null}};function Nn(t){const e=t.$,s=t.store,i=e.contextProvider,n=e.eventManager,r=i.frameRoots,l=i.context,a=i.frameContext;let h=e.options.get("historyStackDelayTime");const c=e.options.get("historyStackSize");let d,u,p,g,m=null,f=!1,v=null;function b(i,o,r){r&&s.get("hasFocus")&&t._eventOrchestrator.applyTagEffect(),e.history.resetButtons(i.get("key"),o),n.triggerEvent("onChange",{frameContext:i,data:i.get("wysiwyg").innerHTML}),"block"===l.get("toolbar_main").style.display?e.toolbar._showBalloon():s.mode.isSubBalloon&&"block"===l.get("toolbar_sub_main").style.display&&e.subToolbar._showBalloon()}function y(t){const s=u[d],i=p[s];d+=t;const n=t<0&&s!==u[d]&&i.index>0?s:u[d],o=p[n];o.index+=t;const l=o.value[o.index];if(!l)return console.warn("[SunEditor.history.setContent.fail] History state desynchronized. Aborting undo/redo operation."),o.index-=t,void(d-=t);r.get(n).get("wysiwyg").innerHTML=l.content,s!==n&&t<0&&1===d?d=0:s!==n&&t>0&&1===o.index?d++:(t<0&&o.index<1||t>0&&o.index>o.value.length)&&(d+=t);let h=n,c=l;if(t<0&&d>0&&0===o.index){const e=u[d+t];if(e!==n){const t=p[e];h=e,c=t.value[t.index]}}e.facade.changeFrameContext(h),e.selection.setRange(vt(c.s.path,c.frame),c.s.offset,vt(c.e.path,c.frame),c.e.offset),e.focusManager.focus(),d<0?d=0:d>=u.length&&(d=u.length-1),e.ui.offCurrentController(),e.pluginManager.checkFileInfo(!1),e.char.display(),e.ui._syncFrameState(a),a.has("documentType_use_header")&&a.get("documentType").reHeader(),b(a,o.index,!0)}function w(t,e,s,i){let n,o;e?(n={path:ft(e.startContainer,null,null),offset:e.startOffset},o={path:ft(e.endContainer,null,null),offset:e.endOffset}):(n={path:[0,0],offset:[0,0]},o={path:0,offset:0}),d+=i,u[d]=s;const l=p[s];l.index+=i,l.value[l.index]={content:t,s:n,e:o,frame:r.get(s).get("wysiwyg")}}function C(t){p[t]={value:[],index:-1},g[t]=r.get(t).get("wysiwyg").innerHTML}function _(t,s){e.pluginManager.checkFileInfo(!1);const i=r.get(t),n=i.get("wysiwyg").innerHTML,o=p[t];if(n&&(!o.value[o.index]||n!==o.value[o.index].content)){if(u.length>d+1&&function(t){const s=[];for(let t=d+1,e=u.length;t<e;t++)s.includes(u[t])||s.push(u[t]);u=u.slice(0,d+1),t.value.splice(t.index+1),e.commandDispatcher.applyTargets("redo",(t=>{t.disabled=!0}));for(let t=0,e=s.length;t<e;t++)u.includes(s[t])||C(s[t])}(o),0===o.value.length&&function(t){d++,u[d]=t;const e=p[t];e.index=0,e.value[0]={content:g[t],s:{path:[0,0],offset:[0,0]},e:{path:0,offset:0},frame:r.get(t).get("wysiwyg")}}(t),w(n,s,t,1),o.value.length>c){const e=o.value.length-c;o.value.splice(0,e),o.index-=e;let s=0;for(let i=u.length-1;i>=0&&s<e;i--)if(u[i]===t)for(let e=0;e<u.length;e++)if(u[e]===t){u.splice(e,1),s++;break}d-=e}1===d&&e.commandDispatcher.applyTargets("undo",(t=>{t.disabled=!1})),e.char.display(),b(i,o.index,!1)}}return{push(t,i){if(f)return;i=i||null===i?i:s.get("rootKey");const n=s.get("_range");o.setTimeout(e.ui._syncFrameState.bind(e.ui,r.get(i)),0);const l="number"==typeof t?t>0?t:0:t?h:0;l&&!m||(o.clearTimeout(m),l)?m=o.setTimeout((()=>{o.clearTimeout(m),m=null,_(i,n)}),l):_(i,n)},check(t,e){m&&(o.clearTimeout(m),m=null,_(t,e))},undo(){d>0&&y(-1)},redo(){u.length-1>d&&y(1)},overwrite(t){w(r.get(t||s.get("rootKey")).get("wysiwyg").innerHTML,null,s.get("rootKey"),0)},pause(){f=!0,v&&(o.clearTimeout(v),v=null),v=o.setTimeout((()=>{f=!1}),5e3)},resume(){v&&(o.clearTimeout(v),v=null),f=!1},reset(){e.commandDispatcher.applyTargets("undo",(t=>t.disabled=!0)),e.commandDispatcher.applyTargets("redo",(t=>t.disabled=!0)),e.commandDispatcher.applyTargets("save",(t=>t.disabled=!0)),i.applyToRoots((t=>t.set("historyIndex",-1))),i.applyToRoots((t=>t.set("isChanged",!1))),d=-1,u=[],p={},g={},f=!1;const t=i.rootKeys;for(let e=0,s=t.length;e<s;e++)C(t[e])},resetButtons(t,s){const i=!De.is(s),o=p[void 0===t?u[d]:t];s=i?o.index:s;const l=r.get(t),a=o.value.length-1;e.commandDispatcher.applyTargets("undo",(t=>{t.disabled=!(s>0&&s<=a)})),e.commandDispatcher.applyTargets("redo",(t=>{t.disabled=!(s>-1&&s<a)}));const h=l.get("savedIndex"),c=l.get("historyIndex"),g=h>-1?h!==s:i?o.index>0:s>0&&c!==s;l.set("historyIndex",s),l.set("isChanged",g),e.commandDispatcher.applyTargets("save",(t=>{t.disabled=!g})),n.triggerEvent("onResetButtons",{rootKey:t})},getRootStack:()=>p,resetDelayTime(t){h=t},_destroy(){m&&o.clearTimeout(m),v&&o.clearTimeout(v),d=u=p=g=null}}}const{_w:Bn}=Oe;const In=class{#H;#J;#t;#Wo;#Uo;#e;#X;#rt;#_i;#Vo;#jo;#Go;#Ko="default";#Yo=null;#Xo=null;#Zo=!1;#Jo=!1;#Qo=!1;constructor(t,{keyName:e,balloon:s,inline:i,balloonAlways:n,res:o}){this.#H=t,this.#J=t.$,this.#t=t.store,this.#Wo=this.#J.icons,this.#Uo=this.#J.lang,this.#e=this.#J.context,this.#X=this.#J.frameContext,this.#rt=this.#J.options,this.#_i=this.#J.eventManager,this.isSub="toolbar_sub"===e,this.keyName={main:this.isSub?"toolbar_sub_main":"toolbar_main",buttonTray:this.isSub?"toolbar_sub_buttonTray":"toolbar_buttonTray",width:this.isSub?"toolbar_sub_width":"toolbar_width"},this.currentMoreLayerActiveButton=null,this.isBalloonMode=s,this.isInlineMode=i,this.isBalloonAlwaysMode=n,this.inlineToolbarAttr={top:"",width:"",isShow:!1},this.balloonOffset={top:0,left:0},this.#Vo=o,this.#jo=o,this.#Go="visualViewport"in Bn;const r=!this.isSub&&!s&&!i,l=this.#rt.get("_toolbar_sticky");if(this.#Zo=r&&l>=0&&!this.#rt.get("toolbar_container")&&!this.#rt.get("_toolbar_sticky_fixed")&&"undefined"!=typeof CSS&&CSS.supports("position","sticky"),this.isBottomMode=this.#t.mode.isBottom,this.#Zo){const t=this.#e.get(this.keyName.main);this.isBottomMode?(t.style.bottom=l+"px",t.style.top="auto"):l>0&&(t.style.top=l+"px")}else r&&Pe.utils.addClass(this.#e.get(this.keyName.main),"se-toolbar-relative");this._setResponsive()}get isSticky(){if(this.isSub)return!1;const t=this.#rt.get("_toolbar_sticky");if(t<0)return!1;if(this.#Zo){const e=this.#e.get(this.keyName.main);if(!e||0===e.offsetWidth||"none"===e.style.display)return!1;if(this.isBottomMode){const s=this.#Go?Bn.visualViewport.height:Bn.innerHeight;return e.getBoundingClientRect().bottom>=s-t-1}return e.getBoundingClientRect().top<=t+1}return this.#Jo}get isCSSSticky(){return this.#Zo}disable(){this._moreLayerOff(),this.#J.menu.dropdownOff(),this.#J.menu.containerOff(),Pe.utils.setDisabled(this.#e.get(this.keyName.buttonTray).querySelectorAll(".se-menu-list .se-toolbar-btn[data-type]"),!0)}enable(){Pe.utils.setDisabled(this.#e.get(this.keyName.buttonTray).querySelectorAll(".se-menu-list .se-toolbar-btn[data-type]"),!1)}show(){this.isInlineMode?this._showInline():this.isBalloonMode?this._showBalloon():(this.#e.get(this.keyName.main).style.display="",this.isSub||(this.#X.get("_stickyDummy").style.display="")),this.isSub||this.resetResponsiveToolbar()}hide(){this.isInlineMode?(this.#e.get(this.keyName.main).style.display="none",this.#e.get(this.keyName.main).style.top="0px",this.inlineToolbarAttr.isShow=!1):(this.#e.get(this.keyName.main).style.display="none",this.isSub||(this.#X.get("_stickyDummy").style.display="none"),this.isBalloonMode&&(this.balloonOffset={top:0,left:0}))}resetResponsiveToolbar(){this.#J.menu.containerOff();const t=this.#Xo;if(t){let e=0;e=(this.isBalloonMode||this.isInlineMode)&&"auto"===this.#rt.get("toolbar_width")||this.#t.mode.isSubBalloon&&"auto"===this.#rt.get("toolbar_sub_width")?this.#X.get("topArea").offsetWidth:this.#e.get(this.keyName.main).offsetWidth;let s="default";for(let i=1,n=t.length;i<n;i++)if(e<t[i]){s=t[i]+"";break}this.#Ko!==s&&(this.#Ko=s,this.setButtons(this.#Yo[s]))}}setButtons(t){this._moreLayerOff(),this.#J.menu.dropdownOff(),this.#J.menu.containerOff();const e=vs(t,this.#J.plugins,this.#rt,this.#Wo,this.#Uo,!0);e.updateButtons.forEach((t=>fs(t.button,t.plugin,this.#Wo,this.#Uo))),this.#e.get(this.keyName.main).replaceChild(e.buttonTray,this.#e.get(this.keyName.buttonTray)),this.#e.set(this.keyName.buttonTray,e.buttonTray),this.#tr(),this.#_i.triggerEvent("onSetToolbarButtons",{buttonTray:e.buttonTray,frameContext:this.#X})}_resetSticky(){if(this.#Zo)return void this.#er();const t=this.#X.get("wrapper");if(!t)return;const e=this.#e.get(this.keyName.main),s=this.#rt.get("_toolbar_sticky");if(this.#X.get("isFullScreen")||0===e.offsetWidth||s<0)return;const i=this.#Go?Bn.visualViewport.pageTop:Bn.scrollY,n=this.#X.get("_minHeight"),o=t.offsetHeight,r=this.#J.offset.getGlobal(this.#X.get("topArea"));if(this.isBottomMode){const t=i+Bn.innerHeight,l=r.top+o,a=t-s-(this.isInlineMode?e.offsetHeight:0),h=this.#rt.get("toolbar_container")?t-s-r.top-n-e.offsetHeight:a-r.top-n;a>l?this.#sr():h<0?(this.isSticky||this.#ir(1),e.style.bottom=1+h+this.#nr()+"px",e.style.top="auto"):this.#ir(1)}else{const t=i+s,l=(this.isBalloonMode||this.isInlineMode?r.top:this.#J.offset.getGlobal(this.#rt.get("toolbar_container")).top)-(this.isInlineMode?e.offsetHeight:0),a=this.#rt.get("toolbar_container")?r.top-i+o-n-s-e.offsetHeight:o+l+s-t-n;t<l?this.#sr():a<0?(this.isSticky||this.#ir(1),e.style.top=1+a+this.#nr()+"px"):this.#ir(1)}}#tr(){this.#J.shortcuts._registerShortcuts(),this.#J.commandDispatcher.resetTargets(),this.#J.ui._initToggleButtons(),this.#J.history.resetButtons(this.#X.get("key"),null),this._resetSticky(),this.#t.set("_lastSelectionNode",null),this.#J.viewer._setButtonsActive(),this.#t.get("hasFocus")&&this.#H._eventOrchestrator.applyTagEffect(),this.#X.get("isReadOnly")&&this.#J.ui.setControllerOnDisabledButtons(!0)}_setResponsive(){if(0===this.#jo?.length)return void(this.#jo=null);this.#Ko="default";const t=this.#Xo=[],e=this.#Vo,s=this.#Yo={default:e[0]};for(let i,n,o=1,r=e.length;o<r;o++)n=e[o],i=1*n[0],t.push(i),s[i]=n[1];t.sort(((t,e)=>t-e)).unshift("default")}_showBalloon(t){if(!this.isBalloonMode)return;this.isSub&&this.resetResponsiveToolbar();const e=t||this.#J.selection.getRange(),s=this.#e.get(this.keyName.main),i=this.#J.selection.get();let n;if(this.isBalloonAlwaysMode&&e.collapsed)n=!0;else if(i.focusNode===i.anchorNode)n=i.focusOffset<i.anchorOffset;else{const t=Pe.query.getListChildNodes(e.commonAncestorContainer,null,null);n=Pe.utils.getArrayIndex(t,i.focusNode)<Pe.utils.getArrayIndex(t,i.anchorNode)}this._setBalloonOffset(n,e),this.#_i.triggerEvent("onShowToolbar",{toolbar:s,mode:"balloon",frameContext:this.#X})}_setBalloonOffset(t,e){const s=this.#e.get(this.keyName.main),i=this.#X.get("topArea"),n=this.#J.offset.getGlobal(i).top;if(!this.#J.offset.setRangePosition(s,e,{position:t?"top":"bottom",addTop:n}))return void this.hide();if(this.#rt.get("toolbar_container")){const t=i.parentElement;let e=this.#rt.get("toolbar_container"),n=e.offsetLeft,o=e.offsetTop;for(;!e.parentElement.contains(t)&&!/^(BODY|HTML)$/i.test(e.parentElement.nodeName);)e=e.offsetParent,n+=e.offsetLeft,o+=e.offsetTop;s.style.left=s.offsetLeft-n+i.offsetLeft+"px",s.style.top=s.offsetTop-o+i.offsetTop+"px"}const o=this.#J.offset.getWWScroll();this.balloonOffset={top:s.offsetTop+o.top,left:s.offsetLeft+o.left,position:t?"top":"bottom"}}_showInline(){if(!this.isInlineMode)return;const t=this.#e.get(this.keyName.main);if(t.style.visibility="hidden",t.style.display="block",this.#sr(),t.style.top="0px",this.inlineToolbarAttr.width=t.style.width=this.#rt.get(this.keyName.width),this.isBottomMode){const e=this.#X.get("topArea");this.inlineToolbarAttr.top=t.style.top=this.#J.offset.getGlobal(e).top+e.offsetHeight-this.#J.offset.getGlobal(t).top+"px"}else this.inlineToolbarAttr.top=t.style.top=this.#J.offset.getGlobal(this.#X.get("topArea")).top-this.#J.offset.getGlobal(t).top-t.offsetHeight-1+"px";this._resetSticky(),this.inlineToolbarAttr.isShow=!0,this.#_i.triggerEvent("onShowToolbar",{toolbar:t,mode:"inline",frameContext:this.#X}),t.style.visibility=""}_moreLayerOn(t,e){this._moreLayerOff(),this.currentMoreLayerActiveButton=t,e.style.display="block"}_moreLayerOff(){if(this.currentMoreLayerActiveButton){this.#e.get(this.keyName.main).querySelector("."+this.currentMoreLayerActiveButton.getAttribute("data-command")).style.display="none",Pe.utils.removeClass(this.currentMoreLayerActiveButton,"on"),this.currentMoreLayerActiveButton=null}}#ir(t){const e=this.#e.get(this.keyName.main);if(!this.isInlineMode){const t=this.#rt.get("toolbar_container")?this.#e.get("_stickyDummy"):this.#X.get("_stickyDummy");t.style.height=e.offsetHeight+"px",t.style.display="block"}if(this.isBottomMode){const t=this.#rt.get("_toolbar_sticky")+this.#nr();e.style.bottom=`${t}px`,e.style.top="auto"}else{const s=this.#rt.get("_toolbar_sticky")+t+this.#nr();e.style.top=`${s}px`}e.style.width=this.isInlineMode?this.inlineToolbarAttr.width:e.offsetWidth+"px",Pe.utils.addClass(e,"se-toolbar-sticky"),this.#Jo=!0}#nr(){return this.#Go?Bn.visualViewport.offsetTop:0}#er(){if(!this.#Go)return;if(this.#H._eventOrchestrator.scrollparents.length>0)return;const t=Math.round(Bn.visualViewport.offsetTop);if(0===t&&!this.#Qo)return;const e=this.#e.get(this.keyName.main),s=this.#rt.get("_toolbar_sticky_offset");if(t>0)if(this.#Qo=!0,this.isBottomMode){const i=Math.round(Bn.innerHeight-Bn.visualViewport.height-t);e.style.bottom=s+i+"px",e.style.top="auto"}else e.style.top=s+t+"px";else{this.#Qo=!1;const t=this.#rt.get("_toolbar_sticky");this.isBottomMode?(e.style.bottom=t+"px",e.style.top="auto"):e.style.top=t>0?t+"px":""}}#sr(){(this.#rt.get("toolbar_container")?this.#e.get("_stickyDummy"):this.#X.get("_stickyDummy")).style.display="none";const t=this.#e.get(this.keyName.main);this.isBottomMode?(t.style.bottom=this.isInlineMode?-t.offsetHeight+"px":"",t.style.top="auto",this.#X.get("wrapper").style.marginBottom=""):(t.style.top=this.isInlineMode?this.inlineToolbarAttr.top:"",this.#X.get("wrapper").style.marginTop=""),t.style.width=this.isInlineMode?this.inlineToolbarAttr.width:"",Pe.utils.removeClass(t,"se-toolbar-sticky"),this.#Jo=!1}_destroy(){this._moreLayerOff()}},{isMobile:Ln,_w:An}=Oe;function On(t){return/free$/.test(t)}const Rn=class{#J;#t;#Ci;#e;#_i;#or;#rr=[];#lr=null;#ar=null;#hr=null;#cr=null;#dr=null;#ur=null;#pr=null;#gr=null;#mr=null;#fr=null;#vr=null;#br=new Set;constructor(t){this.#J=t.$,this.#t=t.store,this.#Ci=this.#J.contextProvider,this.#e=this.#J.context,this.#_i=this.#J.eventManager,this.targetMap={},this.itemsMap={},this.index=-1,this.menus=[],this.currentButton=null,this.currentDropdown=null,this.currentDropdownActiveButton=null,this.currentDropdownName="",this.currentDropdownType="",this.currentContainer=null,this.currentContainerActiveButton=null,this.currentContainerName="",this.currentDropdownPlugin=null,this.#or={mousedown:this.#yr.bind(this),containerDown:this.containerOff.bind(this),keydown:this.#wr.bind(this),esc:this.#Cr.bind(this),mousemove:this.#_r.bind(this),mouseout:this.#kr.bind(this)},this.#lr=null,this.#ar=null,this.#hr=null,this.#cr=null,this.#pr=null,this.#gr=null,this.#vr=An.visualViewport||null}initDropdownTarget({key:t,type:e},s,i){if(!t)throw Error("[SUNEDITOR.init.fail] The plugin's key is not added.");let n;if(Array.isArray(s)){n=function(t,e={}){let s="";for(let e=0,i=t.length;e<i;e++){const i=t[e];let n="";if(i.attrs){const t=Object.keys(i.attrs);for(let e=0;e<t.length;e++)n+=` ${t[e]}="${i.attrs[t[e]]}"`}s+=`\n\t\t<li>\n\t\t\t<button type="button" class="se-btn se-btn-list${i.className?" "+i.className:""}" data-command="${i.command}"${void 0!==i.value?` data-value="${i.value}"`:""} title="${i.title}" aria-label="${i.title}"${n}>${i.innerHTML}</button>\n\t\t</li>`}return Pe.utils.createElement("DIV",{class:"se-dropdown se-list-layer"+(e.className?" "+e.className:"")},`<div class="se-list-inner"><ul class="se-list-basic">${e.prependHTML||""}${s}</ul></div>`)}(s,i);const e=n.querySelectorAll(".se-list-inner li > button"),o=e.length-s.length;for(let t=0;t<s.length;t++)s[t]._element=e[o+t]||null;this.itemsMap[t]=s}else n=s;return On(e)||(n.setAttribute("data-key",t),this.#rr.push(t)),this.#e.get("menuTray").appendChild(n),this.targetMap[t]=n,n}dropdownOn(t){this.#je();const e=this.#xr(t);if(e){const s=Pe.query.getParentElement(e,".se-btn-tray").querySelector('[data-command="'+e.getAttribute("data-ref")+'"]');if(s)return this.#J.commandDispatcher.runFromTarget(s),void this.dropdownOn(t)}const s=this.currentButton=t,i=this.currentDropdownName=s.getAttribute("data-command");this.currentDropdownType=s.getAttribute("data-type");const n=this.currentDropdown=this.targetMap[i];this.currentDropdownActiveButton=s,Ln?this.#$r(s,n):this.#Sr(s,n),this.#e.get("menuTray").showPopover?.(),this.#lr=this.#_i.addGlobalEvent("mousedown",this.#or.mousedown,!1),this.#hr=this.#_i.addGlobalEvent("keydown",this.#or.esc,!0),this.#rr.includes(i)&&(this.menus=ze.nodeListToArray(n.querySelectorAll("[data-command]")),this.menus.length>0&&(this.#ar=this.#_i.addGlobalEvent("keydown",this.#or.keydown,!1),this.#dr=this.#_i.addEvent(n,"mousemove",this.#or.mousemove,!1),this.#ur=this.#_i.addEvent(n,"mouseout",this.#or.mouseout,!1))),this.currentDropdownPlugin=this.#J.plugins[i],this.currentDropdownPlugin?.on(s),this.#t.set("_preventBlur",!0)}dropdownOff(){this.#Er(),this.#je(),On(this.currentDropdownType)&&this.currentDropdownPlugin?.off?.(),this.index=-1,this.menus=[],this.#pr=null,this.#gr=null,this.currentButton=null,this.currentDropdown&&(this.currentDropdownName="",this.currentDropdownType="",this.currentDropdown.style.display="none",this.currentDropdown=null,this.currentDropdownActiveButton&&Pe.utils.removeClass(this.currentDropdownActiveButton.parentElement.children,"on"),this.currentDropdownActiveButton=null,this.#J.ui.preventToolbarHide(!1),this.#e.get("menuTray").hidePopover?.()),this.#t.set("_preventBlur",!1),this.currentDropdownPlugin=null;for(const t of[...this.#br])t()}subscribeDropdownOff(t){return this.#br.add(t),()=>this.#br.delete(t)}dropdownShow(){this.currentButton&&this.dropdownOn(this.currentButton)}dropdownHide(){this.currentDropdown&&(this.currentDropdown.style.display="none")}containerOn(t){this.#je(),this.currentContainerActiveButton=t;const e=this.currentContainerName=this.currentContainerActiveButton.getAttribute("data-command");this.currentContainer=this.targetMap[e],Ln?this.#$r(t,this.currentContainer):this.#Sr(t,this.currentContainer),this.#e.get("menuTray").showPopover?.(),this.#cr=this.#_i.addGlobalEvent("mousedown",this.#or.containerDown,!1),this.#J.plugins[e].on&&this.#J.plugins[e].on(t),this.#t.set("_preventBlur",!0)}containerOff(){this.#Er(),this.#je(),this.currentContainer&&(this.currentContainerName="",this.currentContainer.style.display="none",this.currentContainer=null,Pe.utils.removeClass(this.currentContainerActiveButton,"on"),this.currentContainerActiveButton=null,this.#J.ui.preventToolbarHide(!1),this.#e.get("menuTray").hidePopover?.()),this.#t.set("_preventBlur",!1)}__resetMenuPosition(t,e){this.#J.offset.setRelPosition(e,this.#Ci.carrierWrapper,t.parentElement,Pe.query.getParentElement(t,".se-toolbar"),{preferUp:this.#t.mode.isBottom})}__restoreMenuPosition(){this.#pr&&this.#gr&&(this.#fr||this.#mr||this.#Sr(this.#pr,this.#gr))}#Sr(t,e){e.style.visibility="hidden",e.style.display="block",e.style.height="",Pe.utils.addClass(t.parentElement.children,"on"),this.#J.offset.setRelPosition(e,this.#Ci.carrierWrapper,t.parentElement,Pe.query.getParentElement(t,".se-toolbar"),{preferUp:this.#t.mode.isBottom}),e.style.visibility="",this.#pr=t,this.#gr=e}#$r(t,e){this.#Er(),e.style.display="none",Pe.utils.addClass(t.parentElement.children,"on"),this.#pr=t,this.#gr=e;let s=!1;const i=i=>{s||(s=!0,this.#Er(),this.#mr=An.setTimeout((()=>{this.#mr=null,this.#pr===t&&this.#Sr(t,e)}),i))};this.#vr&&(this.#fr=()=>i(10),this.#vr.addEventListener("resize",this.#fr,{once:!0})),this.#mr=An.setTimeout((()=>i(0)),50)}#Er(){this.#mr&&(An.clearTimeout(this.#mr),this.#mr=null),this.#fr&&(this.#vr?.removeEventListener("resize",this.#fr),this.#fr=null)}#xr(t){const e=Pe.query.getParentElement(t,".se-more-layer");return e&&"block"!==e.style.display&&e.getAttribute("data-ref")?e:null}#Rs(t){Pe.utils.removeClass(this.currentDropdown,"se-select-menu-mouse-move"),Pe.utils.addClass(this.currentDropdown,"se-select-menu-key-action"),t=this.index+t;const e=this.menus.length,s=this.index=t>=e?0:t<0?e-1:t;for(let t=0;t<e;t++)t===s?Pe.utils.addClass(this.menus[t],"on"):Pe.utils.removeClass(this.menus[t],"on")}#je(){this.#lr&&=this.#_i.removeGlobalEvent(this.#lr),this.#hr&&=this.#_i.removeGlobalEvent(this.#hr),this.#cr&&=this.#_i.removeGlobalEvent(this.#cr),this.#ar&&(this.#ar=this.#_i.removeGlobalEvent(this.#ar),this.#dr&&=this.#_i.removeEvent(this.#dr),this.#ur&&=this.#_i.removeEvent(this.#ur),Pe.utils.removeClass(this.menus,"on"),Pe.utils.removeClass(this.currentDropdown,"se-select-menu-key-action|se-select-menu-mouse-move"))}#yr(t){const e=Pe.query.getEventTarget(t);Pe.query.getParentElement(e,".se-dropdown")||this.dropdownOff()}#kr(){this.index=-1}#wr(t){switch(t.code){case"ArrowUp":case"ArrowLeft":t.preventDefault(),t.stopPropagation(),this.#Rs(-1);break;case"ArrowDown":case"ArrowRight":t.preventDefault(),t.stopPropagation(),this.#Rs(1);break;case"Enter":case"Space":{if(this.index<0)break;const e=this.menus[this.index];if(!e||"function"!=typeof this.#J.plugins[this.currentDropdownName].action)return;t.preventDefault(),t.stopPropagation(),this.#J.plugins[this.currentDropdownName].action(e),this.dropdownOff();break}}}#Cr(t){Fe.isEsc(t.code)&&(this.#J.ui.opendControllers?.some((({form:t})=>t&&Pe.utils.hasClass(t,"se-dropdown")))||(t.preventDefault(),t.stopPropagation(),this.dropdownOff()))}#_r(t){Pe.utils.addClass(this.currentDropdown,"se-select-menu-mouse-move"),Pe.utils.removeClass(this.currentDropdown,"se-select-menu-key-action");const e=this.menus.indexOf(t.target);-1!==e&&(this.index=1*e)}_destroy(){this.#je()}},{_w:zn,_d:Pn}=Oe;function Dn(t,e){const s="markdown"===e?"markdownNumbers":"codeNumbers",i="markdown"===e?"markdown":"code",n=t.get(s);if(!n)return;const o=t.get(i),r=(o.value.match(/\n/g)||[]).length+1;let l="";for(let t=1;t<=r;t++)l+=`${t}\n`;const a=zn.getComputedStyle(o);n.style.lineHeight=a.lineHeight,n.style.fontSize=a.fontSize,n.style.fontFamily=a.fontFamily,n.style.paddingTop=a.paddingTop,n.style.paddingBottom=a.paddingBottom,n.value=l}const Fn=class{#H;#J;#t;#Wo;#Uo;#O;#e;#X;#rt;#Q;#_i;#ee;#Tr="";#Mr="";#Nr="";#Br="";#Ir="";#Lr="";#Ar="";#Or="";#Rr="";#zr="";#Pr="";#Dr=0;#Fr=!1;#Hr=!1;#qr=!1;#Wr=null;#Ur="";constructor(t){this.#H=t,this.#J=t.$,this.#t=t.store,this.#Wo=this.#J.icons,this.#Uo=this.#J.lang,this.#O=this.#J.frameRoots,this.#e=this.#J.context,this.#X=this.#J.frameContext,this.#rt=this.#J.options,this.#Q=this.#J.frameOptions,this.#_i=this.#J.eventManager,this.#ee=new RegExp(`^(${this.#rt.get("_disallowedExtraTag")})$`,"i")}codeView(t){const e=this.#X;if(!e.get("codeWrapper"))return;if(void 0===t&&(t=!e.get("isCodeView")),t===e.get("isCodeView"))return;t&&e.get("isMarkdownView")&&this.markdownView(!1),e.set("isCodeView",t),this.#J.ui.offCurrentController(),this.#J.ui.offCurrentModal();const s=e.get("codeWrapper"),i=e.get("code"),n=e.get("wysiwygFrame"),o=e.get("wrapper");t?(this.#J.finder.close(),this.#Vr(),s.style.setProperty("display","flex","important"),n.style.display="none",e.get("isFullScreen")?i.style.height="100%":"auto"!==this.#Q.get("height")||this.#rt.get("hasCodeMirror")||(i.style.height=i.scrollHeight>0?i.scrollHeight+"px":"auto"),this.#rt.get("hasCodeMirror")&&this._codeMirrorEditor("refresh",null,null),e.get("isFullScreen")||(this.#J.ui.preventToolbarHide(!0),this.#t.mode.isBalloon&&(this.#e.get("toolbar_arrow").style.display="none",this.#e.get("toolbar_main").style.left="",this.#t.mode.isInline=this.#J.toolbar.isInlineMode=!0,this.#t.mode.isBalloon=this.#J.toolbar.isBalloonMode=!1,this.#J.toolbar._showInline())),this.#t.mode.isBalloon&&this.#J.subToolbar.hide(),Dn(e),this.#t.set("_range",null),i.focus(),Pe.utils.addClass(this.#J.commandDispatcher.targets.get("codeView"),"active"),Pe.utils.addClass(o,"se-source-view-status")):(Pe.check.isNonEditable(n)||this.#jr(),n.scrollTop=0,s.style.setProperty("display","none","important"),n.style.display="block","auto"!==this.#Q.get("height")||this.#rt.get("hasCodeMirror")||(e.get("code").style.height="0px"),e.get("isFullScreen")||(this.#J.ui.preventToolbarHide(!1),/balloon/.test(this.#rt.get("mode"))&&(this.#e.get("toolbar_arrow").style.display="",this.#t.mode.isInline=this.#J.toolbar.isInlineMode=!1,this.#t.mode.isBalloon=this.#J.toolbar.isBalloonMode=!0,this.#H._eventOrchestrator._hideToolbar())),this.#J.focusManager.nativeFocus(),Pe.utils.removeClass(this.#J.commandDispatcher.targets.get("codeView"),"active"),Pe.check.isNonEditable(n)||(this.#J.history.push(!1),this.#J.history.resetButtons(e.get("key"),null)),Pe.utils.removeClass(o,"se-source-view-status")),this.#J.ui._updatePlaceholder(e),this.#J.ui._toggleCodeViewButtons(t),e.has("documentType_use_header")&&(t?e.get("documentTypeInner").style.display="none":(e.get("documentTypeInner").style.display="",e.get("documentType").reHeader())),this.#_i.triggerEvent("onToggleCodeView",{frameContext:e,is:e.get("isCodeView")})}markdownView(t){const e=this.#X;if(!e.get("markdownWrapper"))return;if(void 0===t&&(t=!e.get("isMarkdownView")),t===e.get("isMarkdownView"))return;t&&e.get("isCodeView")&&this.codeView(!1),e.set("isMarkdownView",t),this.#J.ui.offCurrentController(),this.#J.ui.offCurrentModal();const s=e.get("markdownWrapper"),i=e.get("markdown"),n=e.get("wysiwygFrame"),o=e.get("wrapper");t?(this.#J.finder.close(),this.#Gr(),s.style.setProperty("display","flex","important"),n.style.display="none",e.get("isFullScreen")?i.style.height="100%":"auto"===this.#Q.get("height")&&(i.style.height=i.scrollHeight>0?i.scrollHeight+"px":"auto"),e.get("isFullScreen")||(this.#J.ui.preventToolbarHide(!0),this.#t.mode.isBalloon&&(this.#e.get("toolbar_arrow").style.display="none",this.#e.get("toolbar_main").style.left="",this.#t.mode.isInline=this.#J.toolbar.isInlineMode=!0,this.#t.mode.isBalloon=this.#J.toolbar.isBalloonMode=!1,this.#J.toolbar._showInline())),this.#t.mode.isBalloon&&this.#J.subToolbar.hide(),Dn(e,"markdown"),this.#t.set("_range",null),i.focus(),Pe.utils.addClass(this.#J.commandDispatcher.targets.get("markdownView"),"active"),Pe.utils.addClass(o,"se-source-view-status")):(Pe.check.isNonEditable(n)||this.#Kr(),n.scrollTop=0,s.style.setProperty("display","none","important"),n.style.display="block","auto"===this.#Q.get("height")&&(i.style.height="0px"),e.get("isFullScreen")||(this.#J.ui.preventToolbarHide(!1),/balloon/.test(this.#rt.get("mode"))&&(this.#e.get("toolbar_arrow").style.display="",this.#t.mode.isInline=this.#J.toolbar.isInlineMode=!1,this.#t.mode.isBalloon=this.#J.toolbar.isBalloonMode=!0,this.#H._eventOrchestrator._hideToolbar())),this.#J.focusManager.nativeFocus(),Pe.utils.removeClass(this.#J.commandDispatcher.targets.get("markdownView"),"active"),Pe.check.isNonEditable(n)||(this.#J.history.push(!1),this.#J.history.resetButtons(e.get("key"),null)),Pe.utils.removeClass(o,"se-source-view-status")),this.#J.ui._updatePlaceholder(e),this.#J.ui._toggleCodeViewButtons(t),e.has("documentType_use_header")&&(t?e.get("documentTypeInner").style.display="none":(e.get("documentTypeInner").style.display="",e.get("documentType").reHeader())),this.#_i.triggerEvent("onToggleMarkdownView",{frameContext:e,is:e.get("isMarkdownView")})}fullScreen(t){const e=this.#X;if(void 0===t&&(t=!e.get("isFullScreen")),t===e.get("isFullScreen"))return;e.set("isFullScreen",t);const s=e.get("topArea"),i=this.#e.get("toolbar_main"),n=e.get("wrapper"),o=e.get("wysiwygFrame"),r=e.get("codeWrapper"),l=e.get("code"),a=e.get("codeNumbers"),h=e.get("markdownWrapper"),c=e.get("markdown"),d=e.get("markdownNumbers"),u=this.#X.get("isCodeView"),p=this.#X.get("isMarkdownView"),g=this.#e.get("toolbar_arrow");this.#J.ui.offCurrentController();const m="none"===i.style.display||this.#t.mode.isInline&&!this.#J.toolbar.inlineToolbarAttr.isShow;if(t){this.#Ur=s.style.cssText,this.#Mr=n.style.cssText,this.#Nr=o.style.cssText,this.#Br=r?.style.cssText,this.#Ir=l.style.cssText,this.#Lr=a?.style.cssText,this.#Ar=h?.style.cssText,this.#Or=c?.style.cssText,this.#Rr=d?.style.cssText,this.#zr=i.style.cssText,g&&(this.#Pr=g.style.cssText),(this.#t.mode.isBalloon||this.#t.mode.isInline)&&(g&&(g.style.display="none"),this.#qr=this.#t.mode.isInline,this.#Hr=this.#t.mode.isBalloon,this.#t.mode.isInline=this.#J.toolbar.isInlineMode=!1,this.#t.mode.isBalloon=this.#J.toolbar.isBalloonMode=!1),this.#rt.get("toolbar_container")&&(this.#Wr=i.parentElement,e.get("container").insertBefore(i,n)),s.style.position="fixed",s.style.top="0",s.style.left="0",s.style.width="100%",s.style.maxWidth="100%",s.style.height="100%",s.style.zIndex="2147483639","none"!==e.get("_stickyDummy").style.display&&""!==e.get("_stickyDummy").style.display&&(this.#Fr=!0,e.get("_stickyDummy").style.display="none",Pe.utils.removeClass(i,"se-toolbar-sticky")),this.#Tr=Pn.body.style.overflow,Pn.body.style.overflow="hidden",n.style.cssText=i.style.cssText="",o.style.cssText=(o.style.cssText.match(/\s?display(\s+)?:(\s+)?[a-zA-Z]+;/)||[""])[0]+this.#Q.get("_defaultStyles").editor+(u||p?"display: none;":""),r&&(r.style.cssText=(r.style.cssText.match(/\s?display(\s+)?:(\s+)?[a-zA-Z]+;/)||[""])[0]+`display: ${u?"flex":"none"} !important;`,r.style.overflow="auto",r.style.height="100%"),h&&(h.style.cssText=(h.style.cssText.match(/\s?display(\s+)?:(\s+)?[a-zA-Z]+;/)||[""])[0]+`display: ${p?"flex":"none"} !important;`,h.style.overflow="auto",h.style.height="100%"),l.style.height="",c&&(c.style.height=""),i.style.width=o.style.height="100%",i.style.position="relative",i.style.display="block",this.#Dr=zn.innerHeight-i.offsetHeight,n.style.height=this.#Dr-(e.has("statusbar")?e.get("statusbar").offsetHeight:0)-this.#rt.get("fullScreenOffset")+"px",this.#Q.get("iframe")&&"auto"===this.#Q.get("height")&&(n.style.overflow="auto",this.#J.ui._iframeAutoHeight(e)),e.get("topArea").style.marginTop=this.#rt.get("fullScreenOffset")+"px";const t=this.#Wo.reduction;this.#J.commandDispatcher.applyTargets("fullScreen",(e=>{Pe.utils.changeElement(e.firstElementChild,t),Pe.utils.addClass(e,"active")}))}else{o.style.cssText=this.#Nr.replace(/\s?display(\s+)?:(\s+)?[a-zA-Z]+;/,"")+(u||p?"display: none;":""),r&&(r.style.cssText=this.#Br.replace(/\s?display(\s+)?:(\s+)?[a-zA-Z]+;/,"")+`display: ${u?"flex":"none"} !important;`),l.style.cssText=this.#Ir,a&&(a.style.cssText=this.#Lr),h&&(h.style.cssText=this.#Ar.replace(/\s?display(\s+)?:(\s+)?[a-zA-Z]+;/,"")+`display: ${p?"flex":"none"} !important;`),c&&(c.style.cssText=this.#Or),d&&(d.style.cssText=this.#Rr),i.style.cssText=this.#zr,n.style.cssText=this.#Mr,s.style.cssText=this.#Ur,g&&(g.style.cssText=this.#Pr),Pn.body.style.overflow=this.#Tr,"auto"!==this.#Q.get("height")||this.#rt.get("hasCodeMirror")||this._codeViewAutoHeight(e.get("code"),e.get("codeNumbers"),!0),this.#Wr&&(this.#Wr.appendChild(i),this.#Wr=null),this.#rt.get("_toolbar_sticky")>-1&&Pe.utils.removeClass(i,"se-toolbar-sticky"),this.#Fr&&!this.#rt.get("toolbar_container")&&(this.#Fr=!1,e.get("_stickyDummy").style.display="block",Pe.utils.addClass(i,"se-toolbar-sticky")),this.#t.mode.isInline=this.#J.toolbar.isInlineMode=this.#qr,this.#t.mode.isBalloon=this.#J.toolbar.isBalloonMode=this.#Hr,e.get("isCodeView")||(this.#t.mode.isInline?this.#J.toolbar._showInline():this.#t.mode.isBalloon&&this.#J.toolbar._showBalloon()),this.#J.toolbar._resetSticky(),e.get("topArea").style.marginTop="";const t=this.#Wo.expansion;this.#J.commandDispatcher.applyTargets("fullScreen",(e=>{Pe.utils.changeElement(e.firstElementChild,t),Pe.utils.removeClass(e,"active")}))}!m||e.get("isCodeView")||e.get("isMarkdownView")||this.#J.toolbar.hide(),this.#_i.triggerEvent("onToggleFullScreen",{frameContext:e,is:e.get("isFullScreen")})}showBlocks(t){const e=this.#X;void 0===t&&(t=!e.get("isShowBlocks")),e.set("isShowBlocks",!!t),t?(Pe.utils.addClass(e.get("wysiwyg"),"se-show-block"),Pe.utils.addClass(this.#J.commandDispatcher.targets.get("showBlocks"),"active")):(Pe.utils.removeClass(e.get("wysiwyg"),"se-show-block"),Pe.utils.removeClass(this.#J.commandDispatcher.targets.get("showBlocks"),"active")),this.#J.ui._syncFrameState(e)}_setButtonsActive(){const t=this.#X;if(t.get("isCodeView")?Pe.utils.addClass(this.#J.commandDispatcher.targets.get("codeView"),"active"):Pe.utils.removeClass(this.#J.commandDispatcher.targets.get("codeView"),"active"),t.get("isFullScreen")){const t=this.#Wo.reduction;this.#J.commandDispatcher.applyTargets("fullScreen",(e=>{Pe.utils.changeElement(e.firstElementChild,t),Pe.utils.addClass(e,"active")}))}else{const t=this.#Wo.expansion;this.#J.commandDispatcher.applyTargets("fullScreen",(e=>{Pe.utils.changeElement(e.firstElementChild,t),Pe.utils.removeClass(e,"active")}))}t.get("isMarkdownView")?Pe.utils.addClass(this.#J.commandDispatcher.targets.get("markdownView"),"active"):Pe.utils.removeClass(this.#J.commandDispatcher.targets.get("markdownView"),"active"),t.get("isShowBlocks")?Pe.utils.addClass(this.#J.commandDispatcher.targets.get("showBlocks"),"active"):Pe.utils.removeClass(this.#J.commandDispatcher.targets.get("showBlocks"),"active")}print(){const t=Pe.utils.createElement("IFRAME",{style:"display: none;"});Pn.body.appendChild(t);const e=zn.getComputedStyle(this.#X.get("wysiwyg")).padding,s=this.#rt.get("printTemplate")?this.#rt.get("printTemplate").replace(/\{\{\s*contents\s*\}\}/i,this.#J.html.get()):this.#J.html.get(),i=Pe.query.getIframeDocument(t),n=this.#X.get("_wd"),o=this.#rt.get("_rtl")?" se-rtl":"",r=(this.#rt.get("_themeClass")||"").trim(),l=t=>r?t.replace(r,"").trim():t,a=`\n\t\t\t<style>\n\t\t\t\t@page {\n\t\t\t\t\tsize: A4;\n\t\t\t\t\tmargin: ${e};\n\t\t\t\t}\n\t\t\t</style>`;if(this.#Q.get("iframe")){const t=this.#rt.get("printClass")?'class="'+l(this.#rt.get("printClass"))+o+'"':this.#Q.get("iframe_fullPage")?Pe.utils.getAttributesToString(n.body,["contenteditable"]).replace(r,""):'class="'+l(this.#rt.get("_editableClass"))+o+'"';i.write(`\n\t\t\t\t<!DOCTYPE html>\n\t\t\t\t<html>\n\t\t\t\t\t<head>\n\t\t\t\t\t\t${n.head.innerHTML}\n\t\t\t\t\t\t${a}\n\t\t\t\t\t</head>\n\t\t\t\t\t<body ${t} style="padding: 0; padding-left: 0; padding-top: 0; padding-right: 0; padding-bottom: 0;">\n\t\t\t\t\t\t${s}\n\t\t\t\t\t</body>\n\t\t\t\t</html>`)}else{const t=Pn.head.getElementsByTagName("link"),e=Pn.head.getElementsByTagName("style");let n="";for(let e=0,s=t.length;e<s;e++)n+=t[e].outerHTML;for(let t=0,s=e.length;t<s;t++)n+=e[t].outerHTML;i.write(`\n\t\t\t\t<!DOCTYPE html>\n\t\t\t\t<html>\n\t\t\t\t\t<head>\n\t\t\t\t\t\t${n}\n\t\t\t\t\t\t${a}\n\t\t\t\t\t</head>\n\t\t\t\t\t<body class="${l(this.#rt.get("printClass")||this.#rt.get("_editableClass"))+o}" style="padding: 0; padding-left: 0; padding-top: 0; padding-right: 0; padding-bottom: 0;">\n\t\t\t\t\t\t${s}\n\t\t\t\t\t</body>\n\t\t\t\t</html>`)}this.#J.ui.showLoading(),zn.setTimeout((()=>{try{if(t.focus(),Oe.isEdge||Oe.isChromium||"StyleMedia"in Oe._w)try{t.contentWindow.document.execCommand("print",!1,null)}catch(e){console.warn("[SUNEDITOR.print.warn]",e),t.contentWindow.print()}else t.contentWindow.print()}catch(t){throw Error(`[SUNEDITOR.print.fail] error: ${t.message}`)}finally{this.#J.ui.hideLoading(),Pe.utils.removeItem(t)}}),1e3)}preview(){this.#J.menu.dropdownOff(),this.#J.menu.containerOff(),this.#J.ui.offCurrentController(),this.#J.ui.offCurrentModal();const t=this.#rt.get("previewTemplate")?this.#rt.get("previewTemplate").replace(/\{\{\s*contents\s*\}\}/i,this.#J.html.get({withFrame:!0})):this.#J.html.get({withFrame:!0}),e=zn.open("","_blank"),s=this.#X.get("_wd"),i=this.#rt.get("_rtl")?" se-rtl":"";if(this.#Q.get("iframe")){const n=this.#rt.get("printClass")?'class="'+this.#rt.get("printClass")+i+'"':this.#Q.get("iframe_fullPage")?Pe.utils.getAttributesToString(s.body,["contenteditable"]):'class="'+this.#rt.get("_editableClass")+i+'"';e.document.write(`<!DOCTYPE html>\n\t\t\t\t<html>\n\t\t\t\t\t<head>\n\t\t\t\t\t\t${s.head.innerHTML}\n\t\t\t\t\t\t<style>\n\t\t\t\t\t\t\tbody {overflow:auto !important; height:auto !important;}\n\t\t\t\t\t\t</style>\n\t\t\t\t\t</head>\n\t\t\t\t\t<body ${n}>\n\t\t\t\t\t\t${t}\n\t\t\t\t\t</body>\n\t\t\t\t</html>`)}else{const s=Pn.head.getElementsByTagName("link"),n=Pn.head.getElementsByTagName("style");let o="";for(let t=0,e=s.length;t<e;t++)o+=s[t].outerHTML;for(let t=0,e=n.length;t<e;t++)o+=n[t].outerHTML;e.document.write(`<!DOCTYPE html>\n\t\t\t\t<html>\n\t\t\t\t\t<head>\n\t\t\t\t\t\t<meta charset="utf-8" />\n\t\t\t\t\t\t<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">\n\t\t\t\t\t\t<title>${this.#Uo.preview}</title>\n\t\t\t\t\t\t${o}\n\t\t\t\t\t</head>\n\t\t\t\t\t<body class="${(this.#rt.get("printClass")?this.#rt.get("printClass"):this.#rt.get("_editableClass"))+i}" style="height:auto">\n\t\t\t\t\t\t${t}\n\t\t\t\t\t</body>\n\t\t\t\t</html>`)}}_resetFullScreenHeight(){if(this.#X.get("isFullScreen"))return this.#Dr+=zn.innerHeight-this.#e.get("toolbar_main").offsetHeight-(this.#X.has("statusbar")?this.#X.get("statusbar").offsetHeight:0)-this.#Dr,this.#X.get("wrapper").style.height=this.#Dr+"px",!0}_codeMirrorEditor(t,e,s){const i=s?this.#O.get(s).get("options"):this.#Q;switch(t){case"set":i.get("codeMirrorEditor").getDoc().setValue(e);break;case"get":return i.get("codeMirrorEditor").getDoc().getValue();case"readonly":i.get("codeMirrorEditor").setOption("readOnly",e);break;case"refresh":i.get("codeMirrorEditor").refresh()}}_setCodeView(t){this.#rt.get("hasCodeMirror")?this._codeMirrorEditor("set",t,null):this.#X.get("code").value=t}_getCodeView(){return this.#rt.get("hasCodeMirror")?this._codeMirrorEditor("get",null,null):this.#X.get("code").value}_codeViewAutoHeight(t,e,s){s&&(t.style.height=t.scrollHeight+"px"),this.#Yr(e,t)}_scrollLineNumbers(t){t.scrollTop=this.scrollTop,t.scrollLeft=this.scrollLeft}_markdownViewAutoHeight(t,e,s){s&&(t.style.height=t.scrollHeight+"px"),this.#Yr(e,t)}_scrollMarkdownLineNumbers(t){t.scrollTop=this.scrollTop,t.scrollLeft=this.scrollLeft}#jr(){const t=this._getCodeView();if(this.#Q.get("iframe_fullPage")){const e=this.#X.get("_wd"),s=(new DOMParser).parseFromString(t,"text/html");if(!this.#ee.test("script")){const t=s.head.children;for(let e=0,i=t.length;e<i;e++)/^script$/i.test(t[e].tagName)&&(s.head.removeChild(t[e]),e--,i--)}let i=s.head.innerHTML;s.head.querySelector('link[rel="stylesheet"]')&&("auto"!==this.#Q.get("height")||s.head.querySelector("style"))||(i+=ze._setIframeStyleLinks(this.#Q.get("iframe_cssFileName"))+ze._setAutoHeightStyle(this.#Q.get("height"))),e.head.innerHTML=i,e.body.innerHTML=this.#J.html.clean(s.body.innerHTML,{forceFormat:!0,whitelist:null,blacklist:null,_freeCodeViewMode:this.#rt.get("freeCodeViewMode")});const n=s.body.attributes;for(let t=0,s=n.length;t<s;t++)"contenteditable"!==n[t].name&&e.body.setAttribute(n[t].name,n[t].value);if(!Pe.utils.hasClass(e.body,"sun-editor-editable")){const t=this.#rt.get("_editableClass").split(" ");for(let s=0;s<t.length;s++)Pe.utils.addClass(e.body,t[s])}}else this.#X.get("wysiwyg").innerHTML=t.length>0?this.#J.html.clean(t,{forceFormat:!0,whitelist:null,blacklist:null,_freeCodeViewMode:this.#rt.get("freeCodeViewMode")}):"<"+this.#rt.get("defaultLine")+"><br></"+this.#rt.get("defaultLine")+">"}#Vr(){const t=this.#J.html._convertToCode(this.#X.get("wysiwyg"),!1);let e="";if(this.#Q.get("iframe_fullPage")){const s=Pe.utils.getAttributesToString(this.#X.get("_wd").body,null);e="<!DOCTYPE html>\n<html>\n"+this.#X.get("_wd").head.outerHTML.replace(/>(?!\n)/g,">\n")+"<body "+s+">\n"+t+"</body>\n</html>"}else e=t;this._setCodeView(e)}#Gr(){const t=ze.htmlToJson(this.#X.get("wysiwyg").innerHTML),e=qe.jsonToMarkdown(t);this.#X.get("markdown").value=e}#Kr(){const t=this.#X.get("markdown").value,e=qe.markdownToHtml(t,this.#rt.get("defaultLine"));this.#X.get("wysiwyg").innerHTML=e.length>0?this.#J.html.clean(e,{forceFormat:!0,whitelist:null,blacklist:null}):"<"+this.#rt.get("defaultLine")+"><br></"+this.#rt.get("defaultLine")+">"}#Yr(t,e){if(!t)return;const s=(e.value.match(/\n/g)||[]).length+1;if(s!==(t.value.match(/\n/g)||[]).length){let e="";for(let t=1;t<=s;t++)e+=`${t}\n`;t.value=e}}_destroy(){}},{_d:Hn,_w:qn}=Oe;class Wn{#J;#t;#Xr;#Zr;#Jr;#Qr;#tl;#el;#sl;#il;#nl;#ol;#rl;#ll;#al=!1;#hl=!0;#cl=[];#dl=-1;#ul="";#pl={matchCase:!1,wholeWord:!1,regex:!1};#gl;#ml=[];#fl=null;#vl=null;#bl=null;#yl=null;#wl=null;#Cl=!1;static#_l=!1;static#kl(){if(Wn.#_l)return;Wn.#_l=!0;const t=Hn.createElement("style");t.textContent="::highlight(se-find-match){background-color:var(--se-find-match-color,rgba(255,213,0,.4));color:inherit}::highlight(se-find-current){background-color:var(--se-find-current-color,rgba(255,150,50,.7));color:inherit}",Hn.head.appendChild(t)}constructor(t){if(this.#J=t.$,this.#t=t.store,this.#gl=!!qn.Highlight&&!!CSS?.highlights,this.#J.options.get("finder_panel")){const t=function({lang:t,icons:e}){const s=`\n\t<div class="se-find-replace-row">\n\t\t<div class="se-find-input-wrapper">\n\t\t\t<input class="se-find-replace-input" type="text" placeholder="${t.find||"Find"}" spellcheck="false" autocomplete="off" />\n\t\t\t<div class="se-find-replace-toggle">\n\t\t\t\t<div class="se-find-replace-info">\n\t\t\t\t\t<span class="se-find-replace-count"></span>\n\t\t\t\t</div>\n\t\t\t\t<button class="se-btn se-find-replace-btn se-find-opt-case" type="button" data-command="opt-case" title="${t.finder_matchCase}">\n\t\t\t\t\t${e.match_case}\n\t\t\t\t</button>\n\t\t\t\t<button class="se-btn se-find-replace-btn se-find-opt-word" type="button" data-command="opt-word" title="${t.finder_wholeWord}">\n\t\t\t\t\t${e.whole_word}\n\t\t\t\t</button>\n\t\t\t\t<button class="se-btn se-find-replace-btn se-find-opt-regex" type="button" data-command="opt-regex" title="${t.finder_regex}">\n\t\t\t\t\t${e.regex}\n\t\t\t\t</button>\n\t\t\t</div>\n\t\t</div>\n\t\t<div class="se-find-replace-buttons">\n\t\t\t<button class="se-btn se-find-replace-btn" type="button" data-command="prev" title="${t.finder_prev}\n(${Oe.shiftIcon} + Enter)">\n\t\t\t\t${e.arrow_up_small}\n\t\t\t</button>\n\t\t\t<button class="se-btn se-find-replace-btn" type="button" data-command="next" title="${t.finder_next}\n(Enter)">\n\t\t\t\t${e.arrow_down_small}\n\t\t\t</button>\n\t\t\t<button class="se-btn se-find-replace-btn se-find-toggle-replace" type="button" data-command="toggle-replace" title="${t.replace}">\n\t\t\t\t${e.swap_vert}\n\t\t\t</button>\n\t\t\t<button class="se-btn se-find-replace-btn" type="button" data-command="close" title="${t.close}">\n\t\t\t\t${e.cancel}\n\t\t\t</button>\n\t\t</div>\n\t</div>\n\t<div class="se-find-replace-row se-find-replace-row-replace">\n\t\t<div class="se-find-input-wrapper">\n\t\t\t<input class="se-find-replace-input se-replace-input" type="text" placeholder="${t.replace}" spellcheck="false" autocomplete="off" />\n\t\t</div>\n\t\t<div class="se-find-replace-buttons">\n\t\t\t<button class="se-btn se-find-replace-btn" type="button" data-command="replace" title="${t.replace}\n(Enter)">\n\t\t\t\t${e.replaceText}\n\t\t\t</button>\n\t\t\t<button class="se-btn se-find-replace-btn" type="button" data-command="replace-all" title="${t.replaceAll}">\n\t\t\t\t${e.relaceTextAll}\n\t\t\t</button>\n\t\t</div>\n\t</div>`,i=Pe.utils.createElement("DIV",{class:"se-find-replace"},s);return{panel:i,findInput:i.querySelector(".se-find-replace-input"),replaceInput:i.querySelector(".se-replace-input"),countDisplay:i.querySelector(".se-find-replace-count"),replaceRow:i.querySelector(".se-find-replace-row-replace"),btnCase:i.querySelector(".se-find-opt-case"),btnWord:i.querySelector(".se-find-opt-word"),btnRegex:i.querySelector(".se-find-opt-regex"),btnPrev:i.querySelector('[data-command="prev"]'),btnNext:i.querySelector('[data-command="next"]'),btnReplace:i.querySelector('[data-command="replace"]'),btnReplaceAll:i.querySelector('[data-command="replace-all"]')}}(this.#J);this.#Xr=t.panel,this.#Zr=t.findInput,this.#Jr=t.replaceInput,this.#Qr=t.countDisplay,this.#tl=t.replaceRow,this.#el=t.btnCase,this.#sl=t.btnWord,this.#il=t.btnRegex,this.#nl=t.btnPrev,this.#ol=t.btnNext,this.#rl=t.btnReplace,this.#ll=t.btnReplaceAll,this.#xl();const e=this.#J.frameRoots.values().next().value.get("container");if(this.#t.mode.isBottom){const t=this.#J.context.get("toolbar_main");e.insertBefore(this.#Xr,t)}else{const t=e.querySelector(".se-wrapper");e.insertBefore(this.#Xr,t)}Oe.isResizeObserverSupported&&(this.#bl=new ResizeObserver((()=>this.#$l())).observe(this.#J.context.get("toolbar_main")))}}get isOpen(){return this.#al}open(t=!0){const e=this.#J.frameContext;if(!e.get("isCodeView")&&!e.get("isMarkdownView")&&(this.#al=!0,Pe.utils.addClass(this.#J.commandDispatcher.targets.get("finder"),"active"),this.#Sl(),this.#Xr)){this.#nl.disabled=!0,this.#ol.disabled=!0,this.#rl.disabled=!0,this.#ll.disabled=!0,this.#$l();const e=this.#J.selection.get(),s=e&&!e.isCollapsed?e.toString().trim():"";Pe.utils.addClass(this.#Xr,"se-find-replace-open"),this.#t.set("_preventBlur",!0),this.#El(),t&&this.#Tl(t),s&&(this.#Zr.value=s),this.#Zr.focus(),this.#Zr.select(),this.#Zr.value&&this.#Ml()}}#$l(){if(!this.#al||!this.#Xr)return;const t=this.#J.options.get("_toolbar_sticky");this.#t.mode.isBottom?(this.#Xr.style.top="auto",this.#Xr.style.bottom=t>=0?t+this.#J.context.get("toolbar_main").offsetHeight+"px":"0px"):this.#Xr.style.top=t>=0?t+this.#J.context.get("toolbar_main").offsetHeight+"px":"0px"}close(){this.#al&&(this.#al=!1,Pe.utils.removeClass(this.#J.commandDispatcher.targets.get("finder"),"active"),this.#Nl(),this.#cl=[],this.#dl=-1,this.#Bl(),this.#Il(),this.#Xr&&(Pe.utils.removeClass(this.#Xr,"se-find-replace-open"),this.#Ll(),this.#t.set("_preventBlur",!1),this.#J.focusManager.nativeFocus()))}findNext(){this.#al&&0!==this.#cl.length&&(this.#dl=(this.#dl+1)%this.#cl.length,this.#Al())}findPrev(){this.#al&&0!==this.#cl.length&&(this.#dl=(this.#dl-1+this.#cl.length)%this.#cl.length,this.#Al())}search(t,{matchCase:e,wholeWord:s,regex:i}={}){return this.#al||this.open(),void 0!==e&&(this.#pl.matchCase=e),void 0!==s&&(this.#pl.wholeWord=s),void 0!==i&&(this.#pl.regex=i),this.#ul=t||"",this.#Zr&&(this.#Zr.value=this.#ul),this.#Ml(),this.#cl.length}replace(t){this.#Ol(t)}replaceAll(t){this.#Rl(t)}get matchInfo(){return{current:this.#dl+1,total:this.#cl.length}}refresh(){this.#al&&this.#ul&&!this.#Cl&&(this.#Cl=!0,this.#zl(),this.#ml=[],this.#Cl=!1,clearTimeout(this.#vl),this.#vl=setTimeout((()=>this.#Ml()),300))}#El(){this.#Ll(),this.#yl=this.#J.eventManager.addGlobalEvent("keydown",(t=>{"Escape"===t.key&&(t.preventDefault(),t.stopPropagation(),this.close())}),!0)}#Ll(){this.#yl&&=this.#J.eventManager.removeGlobalEvent(this.#yl)}#Sl(){this.#Il();const t=this.#J.frameContext.get("wysiwyg");this.#wl=new MutationObserver((()=>this.refresh())),this.#wl.observe(t,{childList:!0,subtree:!0,characterData:!0})}#Il(){this.#wl&&(this.#wl.disconnect(),this.#wl=null)}#xl(){const t=this.#J.eventManager;t.addEvent(this.#Zr,"input",this.#Pl.bind(this)),t.addEvent(this.#Zr,"keydown",this.#Dl.bind(this)),t.addEvent(this.#Jr,"keydown",this.#Fl.bind(this)),t.addEvent(this.#Xr,"click",this.#Hl.bind(this)),Oe.isGecko&&t.addEvent(this.#Xr,"mousedown",(t=>{if("BUTTON"===t.target.tagName){t.preventDefault();const e=Pe.query.getCommandTarget(t.target);e&&this.#J.eventManager._injectActiveEvent(e)}this.#t.set("_preventBlur",!0)}))}#Pl(){this.#J.options.get("finder_liveSearch")&&(clearTimeout(this.#vl),this.#vl=setTimeout((()=>this.#Ml()),120))}#Dl(t){"Escape"===t.key?(t.preventDefault(),this.close()):"Enter"===t.key&&(t.preventDefault(),this.#J.options.get("finder_liveSearch")||this.#Zr.value===this.#ul?t.shiftKey?this.findPrev():this.findNext():this.#Ml())}#Fl(t){"Escape"===t.key?(t.preventDefault(),this.close()):"Enter"===t.key&&(t.preventDefault(),this.#Ol())}#Hl(t){const e=Pe.query.getEventTarget(t),s=Pe.query.getCommandTarget(e);if(!s)return;t.preventDefault();switch(s.getAttribute("data-command")){case"prev":this.findPrev();break;case"next":this.findNext();break;case"toggle-replace":this.#Tl(!this.#hl);break;case"close":this.close();break;case"replace":this.#Ol();break;case"replace-all":this.#Rl();break;case"opt-case":this.#pl.matchCase=!this.#pl.matchCase,Pe.utils.toggleClass(this.#el,"on",this.#pl.matchCase),this.#Ml();break;case"opt-word":this.#pl.wholeWord=!this.#pl.wholeWord,Pe.utils.toggleClass(this.#sl,"on",this.#pl.wholeWord),this.#Ml();break;case"opt-regex":this.#pl.regex=!this.#pl.regex,Pe.utils.toggleClass(this.#il,"on",this.#pl.regex),this.#Ml()}}#Tl(t){this.#hl=t,this.#tl.style.display=t?"":"none",Pe.utils.toggleClass(this.#Xr.querySelector(".se-find-toggle-replace"),"on",t),t&&this.#Jr.focus()}#Ml(){const t=this.#Zr?this.#Zr.value:this.#ul;if(this.#Cl=!0,this.#Nl(),this.#cl=[],this.#dl=-1,!t)return this.#ul="",this.#Bl(),void Pe.utils.removeClass(this.#Zr,"se-find-no-match");this.#ul=t;const e=this.#J.frameContext.get("wysiwyg");this.#fl=this.#ql(),this.#cl=this.#Wl(t,e),this.#cl.length>0?(this.#dl=0,this.#Ul(),this.#Al(),Pe.utils.removeClass(this.#Zr,"se-find-no-match")):this.#Zr&&Pe.utils.toggleClass(this.#Zr,"se-find-no-match",t.length>0),this.#Bl(),this.#Cl=!1}#Wl(t,e){const s=[];if(!t||!e)return s;const i=this.#pl.matchCase?"g":"gi";let n;if(this.#pl.regex)try{n=new RegExp(t,i)}catch{return s}else{const e=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");n=this.#pl.wholeWord?new RegExp(`\\b${e}\\b`,i):new RegExp(e,i)}const o=this.#fl,r=this.#J.format,l=o.createTreeWalker(e,NodeFilter.SHOW_TEXT,null),a=[];let h,c,d="",u=null;for(;h=l.nextNode();){const t=r.getLine(h,null)||e;u&&t!==u&&(d+="\n"),u=t,a.push({node:h,start:d.length}),d+=h.textContent.replace(/\u00A0/g," ")}if(!d)return s;n.lastIndex=0;let p=0;for(;null!==(c=n.exec(d));){if(0===c[0].length){n.lastIndex++;continue}const t=c.index,e=t+c[0].length,i=o.createRange();let r=!1;for(let s=p;s<a.length;s++){const n=a[s],o=n.start+n.node.textContent.length;if(!r&&t>=n.start&&t<o&&(i.setStart(n.node,t-n.start),r=!0,p=s),r&&e>n.start&&e<=o){i.setEnd(n.node,e-n.start);break}}r&&s.push(i)}return s}#Ul(){if(0===this.#cl.length)return;const t=this.#J.frameContext.get("options").get("iframe");this.#gl&&!t?this.#Vl():this.#jl()}#Vl(){Wn.#kl();const t=new Highlight(...this.#cl);CSS.highlights.set("se-find-match",t),this.#Gl()}#Gl(){if(this.#dl>=0&&this.#dl<this.#cl.length){const t=new Highlight(this.#cl[this.#dl]);CSS.highlights.set("se-find-current",t)}else CSS.highlights.delete("se-find-current")}#jl(){this.#zl();const t=this.#fl;for(let e=this.#cl.length-1;e>=0;e--){const s=this.#cl[e],i=this.#Kl(t,s,e);for(let t=0;t<i.length;t++)this.#ml.push(i[t])}this.#ml.reverse(),this.#Yl()}#Kl(t,e,s){const i=e.startContainer,n=e.endContainer,o=[];if(i===n)o.push(this.#Xl(t,i,e.startOffset,e.endOffset,s));else{const r=[i];let l=i;for(;l&&l!==n;)l=this.#Zl(l,e.commonAncestorContainer),l&&r.push(l);for(let l=r.length-1;l>=0;l--){const a=r[l],h=a===i?e.startOffset:0,c=a===n?e.endOffset:a.textContent.length;h>=c||o.push(this.#Xl(t,a,h,c,s))}}return o}#Xl(t,e,s,i,n){const o=s>0?e.splitText(s):e;i-s<o.textContent.length&&o.splitText(i-s);const r=t.createElement("mark");return r.className="se-find-mark",r.setAttribute("data-se-find-idx",String(n)),o.parentNode.insertBefore(r,o),r.appendChild(o),r}#Zl(t,e){let s=t;for(;s;){if(s.firstChild)s=s.firstChild;else{for(;s&&!s.nextSibling;)if(s=s.parentNode,s===e)return null;if(!s)return null;s=s.nextSibling}if(3===s.nodeType)return s}return null}#Yl(){for(const t of this.#ml)Pe.utils.removeClass(t,"se-find-current");if(this.#dl>=0)for(const t of this.#ml)t.getAttribute("data-se-find-idx")===String(this.#dl)&&Pe.utils.addClass(t,"se-find-current")}#Nl(){const t=this.#J.frameContext.get("options").get("iframe");this.#gl&&!t&&(CSS.highlights.delete("se-find-match"),CSS.highlights.delete("se-find-current")),this.#zl()}#zl(){const t=this.#J.frameContext.get("wysiwyg").querySelectorAll("mark.se-find-mark");if(0!==t.length){for(const e of t){const t=e.parentNode;if(t){for(;e.firstChild;)t.insertBefore(e.firstChild,e);t.removeChild(e),t.normalize()}}this.#ml=[]}}#Al(){if(this.#dl<0||this.#dl>=this.#cl.length)return;const t=this.#J.frameContext.get("options").get("iframe");if(this.#gl&&!t){this.#Gl();const t=this.#cl[this.#dl];this.#J.selection.scrollTo(t,{behavior:"auto"})}else{this.#Yl();const t=this.#ml.find((t=>t.getAttribute("data-se-find-idx")===String(this.#dl)));t&&this.#J.selection.scrollTo(t,{behavior:"auto",noFocus:!0})}this.#Bl()}#Ol(t){if(this.#dl<0||0===this.#cl.length)return;this.#Nl();const e=this.#J.frameContext.get("wysiwyg"),s=this.#Wl(this.#ul,e);this.#dl>=s.length||(this.#Jl(s[this.#dl],t??(this.#Jr?this.#Jr.value:"")),this.#J.history.push(!1),this.#Ml(),this.#dl>=this.#cl.length&&this.#cl.length>0&&(this.#dl=0,this.#Al()))}#Rl(t){if(0===this.#cl.length)return;this.#Nl();const e=this.#J.frameContext.get("wysiwyg"),s=this.#Wl(this.#ul,e);if(0!==s.length){t=t??(this.#Jr?this.#Jr.value:"");for(let e=s.length-1;e>=0;e--)this.#Jl(s[e],t);e.normalize(),this.#J.history.push(!1),this.#Ml()}}#Jl(t,e){const s=t.startContainer,i=this.#fl.createTextNode(e);if(s===t.endContainer)return t.deleteContents(),t.insertNode(i),void s.parentNode?.normalize();t.deleteContents(),3===s.nodeType?s.parentNode&&(s.parentNode.insertBefore(i,s.nextSibling),s.parentNode.normalize()):(t.insertNode(i),i.parentNode?.normalize())}#Bl(){if(!this.#Xr)return;const t=this.#cl.length>0;this.#Qr.textContent=t?`${this.#dl+1}/${this.#cl.length}`:this.#ul?"0":"",this.#nl.disabled=!t,this.#ol.disabled=!t,this.#rl.disabled=!t,this.#ll.disabled=!t}#ql(){const t=this.#J.frameContext;return t.get("options").get("iframe")?t.get("_wd"):Hn}_destroy(){this.#Ll(),this.#Il(),this.#bl&&=this.#bl.disconnect(),clearTimeout(this.#vl)}}const Un=Wn;const Vn=class{$;constructor(t){this.$=t.$}},{isMobile:jn,_w:Gn}=Oe;function Kn(t){const e=Pe.query.getEventTarget(t);let s=e;this.$.store.mode.isBalloon&&!this.$.context.get("toolbar_sub_main")?.contains(s)&&this._hideToolbar_sub();const i=Pe.check.isInputElement(s);if(i?this.$.store.set("_preventBlur",!1):this.$.frameContext.get("wysiwyg").contains(this.$.selection.getNode())||this.$.focusManager.focus(),Pe.query.getParentElement(s,".se-dropdown"))t.stopPropagation(),this.$.ui.preventToolbarHide(!0);else{let n=s.getAttribute("data-command"),o=s.className;for(;s&&!n&&!/(se-menu-list|sun-editor-common|se-menu-tray)/.test(o);)s=s.parentElement,n=s.getAttribute("data-command"),o=s.className;if(i&&/^INPUT$/i.test(s?.getAttribute("data-type"))){if(this.$.store.set("_preventBlur",!0),this._inputFocus=!0,this.$.store.get("hasFocus")||this.applyTagEffect(),!Pe.check.isInputElement(e)||e.disabled)return;const t=this.$.plugins[n];if(!t)return;if(this.__inputBlurEvent&&this.__removeInput(),"function"==typeof t.toolbarInputChange&&(this.__inputPlugin={obj:t,target:e,value:e.value}),this.__inputBlurEvent=this.$.eventManager.addEvent(e,"blur",(s=>{if(!t.isInputActive)try{const i=e.value.trim();"function"==typeof t.toolbarInputChange&&i!==this.__inputPlugin.value&&t.toolbarInputChange({target:e,value:i,event:s})}finally{Gn.setTimeout((()=>this._inputFocus=!1),0),this.__removeInput()}})),!t)return;"function"==typeof t.toolbarInputKeyDown&&(this.__inputKeyEvent=this.$.eventManager.addEvent(e,"keydown",(s=>{t.toolbarInputKeyDown({target:e,event:s})})))}else{if(this.__inputBlurEvent&&this.__inputPlugin){const e=this.__inputPlugin.target.value.trim();return e!==this.__inputPlugin.value&&this.__inputPlugin.obj.toolbarInputChange({target:this.__inputPlugin.target,value:e,event:t}),void this.__removeInput()}this.$.frameContext.get("isCodeView")||(jn?this.$.store.set("_preventBlur",!0):(t.preventDefault(),Oe.isGecko&&n&&this.$.eventManager._injectActiveEvent(s)))}n!==this.$.menu.currentDropdownName&&n!==this.$.menu.currentContainerName||t.stopPropagation()}}function Yn(t){const e=Pe.query.getEventTarget(t),s=Pe.query.getCommandTarget(e);if(!s)return;let i=s,n="";for(;i&&!/se-menu-tray/.test(i.className)&&!n;)i=i.parentElement,n=i?.getAttribute("data-key");if(!n)return;const o=this.$.plugins[n];o&&"function"==typeof o.action&&(t.stopPropagation(),o.action(s))}function Xn(t){const e=Pe.query.getEventTarget(t);this.$.commandDispatcher.runFromTarget(e)}const{_w:Zn}=Oe,Jn=new WeakMap;async function Qn(t,e){const s=Pe.query.getEventTarget(e);this.$.store.set("_mousedown",!0),this.__onDownEv&&to.call(this),this.__onDownEv=this.$.eventManager.addGlobalEvent("mouseup",to.bind(this)),t.get("isReadOnly")||Pe.check.isNonEditable(t.get("wysiwyg"))||(this.$.format._isExcludeSelectionElement(s)?e.preventDefault():(this._setSelectionSync(),Zn.setTimeout(this.$.selection.init.bind(this.$.selection),0),!1!==await this.$.eventManager.triggerEvent("onMouseDown",{frameContext:t,event:e})&&!1!==await this._callPluginEventAsync("onMouseDown",{frameContext:t,event:e})&&(this.$.store.mode.isBalloon?this._hideToolbar():this.$.store.mode.isSubBalloon&&this._hideToolbar_sub(),/FIGURE/i.test(s?.nodeName)&&e.preventDefault())))}function to(){this.$.store.set("_mousedown",!1),this.__onDownEv=this.$.eventManager.removeGlobalEvent(this.__onDownEv)}async function eo(t,e){!1!==await this.$.eventManager.triggerEvent("onMouseUp",{frameContext:t,event:e})&&await this._callPluginEventAsync("onMouseUp",{frameContext:t,event:e})}async function so(t,e){const s=Pe.query.getEventTarget(e);if(t.get("isReadOnly"))return e.preventDefault(),Pe.check.isAnchor(s)&&Zn.open(s.href,s.target),!1;if(Pe.check.isNonEditable(t.get("wysiwyg")))return;if(!1===await this.$.eventManager.triggerEvent("onClick",{frameContext:t,event:e}))return;if(!1===await this._callPluginEventAsync("onClick",{frameContext:t,event:e}))return;const i=this.$.component.get(s);if(i)return e.preventDefault(),void this.$.component.select(i.target,i.pluginName);if(this.$.selection.init(),3===e.detail){const t=this.$.selection.getRange();this.$.format.isLine(t.endContainer)&&0===t.endOffset&&this.$.selection.setRange(t.startContainer,t.startOffset,t.startContainer,t.startContainer.textContent.length)}const n=this.$.selection.getNode(),o=this.$.format.getLine(n,null),r=this.$.format.getBlock(n,null);if(!o&&!Pe.check.isNonEditable(s)&&!Pe.check.isList(r)){const t=this.$.selection.getRange();if(this.$.format.getLine(t.startContainer)===this.$.format.getLine(t.endContainer))if(Pe.check.isList(r)){e.preventDefault();const t=n.nextElementSibling,s=Pe.utils.createElement("LI",null,n);r.insertBefore(s,t),this.$.focusManager.focus()}else Pe.check.isWysiwygFrame(n)||this.$.component.is(n)||Pe.check.isTableElements(n)&&!Pe.check.isTableCell(n)||null===this._setDefaultLine(this.$.format.isBlock(r)?"DIV":this.$.options.get("defaultLine"))||(e.preventDefault(),this.$.focusManager.focus())}this.$.commandDispatcher._copyFormat(),(this.$.store.mode.isBalloon||this.$.store.mode.isSubBalloon)&&Zn.setTimeout(this._toggleToolbarBalloon.bind(this),0)}function io(t,e){if(t.get("isReadOnly")||t.get("isDisabled"))return!1;let s=Jn.get(t);s||(s={rafId:null,event:null},Jn.set(t,s)),s.event=e,null===s.rafId&&(s.rafId=Zn.requestAnimationFrame((()=>{const e=s.event;if(s.rafId=null,s.event=null,!e)return;const i=Pe.query.getEventTarget(e);!1===_i.get("__overInfo")||this.$.ui.selectMenuOn||this.$.component.hoverSelect(i),this.$.ui.blockHandle?.positionForTarget(i,e.clientY),this._callPluginEvent("onMouseMove",{frameContext:t,event:e})})))}async function no(t,e){this.$.ui.blockHandle?.hide(e),!1!==await this.$.eventManager.triggerEvent("onMouseLeave",{frameContext:t,event:e})&&await this._callPluginEventAsync("onMouseLeave",{frameContext:t,event:e})}const oo={"event.prevent":({ctx:t})=>t.e.preventDefault(),"event.stop":({ctx:t})=>t.e.stopPropagation(),"event.prevent.stop":({ctx:t})=>{t.e.preventDefault(),t.e.stopPropagation()},"cache.styleNode":({ports:t})=>t.styleNodeCache(),"cache.formatAttrsTemp":({ports:t},{attrs:e})=>t.formatAttrsTempCache(e),"focusManager.nativeFocus":({ports:t})=>t.focusManager.nativeFocus(),"history.push":({ports:t},e)=>t.history.push(e),"documentType.refreshHeader":({ctx:t})=>{o.setTimeout((()=>{t.fc.get("documentType").reHeader()}),0)},"component.deselect":({ports:t})=>t.component.deselect(),"selection.setRange":({ports:t},{sc:e,so:s,ec:i,eo:n})=>t.selection.setRange(e,s,i,n),"format.removeBlock":({ports:t},{rangeEl:e,selectedFormats:s,newBlockElement:i,shouldDelete:n,skipHistory:o})=>t.format.removeBlock(e,{selectedFormats:s,newBlockElement:i,shouldDelete:n,skipHistory:o}),"dom.utils.removeItem":(t,{item:e})=>Pe.utils.removeItem(e),"select.component.fallback":({ports:t},{cmponentInfo:e})=>{!1===t.component.select(e.target,e.pluginName)&&t.focusManager.blur()}};function ro(t){const e=t.selection.getRange(),s=e.startContainer,i=e.endContainer,n=t.format.getBlock(s),o=t.format.getBlock(i),r=Pe.check.isTableCell(n),l=Pe.check.isTableCell(o);if((r&&!n.previousElementSibling&&!n.parentElement.previousElementSibling||l&&!o.nextElementSibling&&!o.parentElement.nextElementSibling)&&n!==o){const s=Pe.query.getParentElement(e.commonAncestorContainer,Pe.check.isFigure)?.parentElement||e.commonAncestorContainer;if(r){if(l)return Pe.utils.removeItem(Pe.query.getParentElement(n,(t=>s===t.parentNode))),t.focusManager.nativeFocus(),!0;Pe.utils.removeItem(Pe.query.getParentElement(n,(t=>s===t.parentNode)))}else Pe.utils.removeItem(Pe.query.getParentElement(o,(t=>s===t.parentNode)))}const a=1===s.nodeType?Pe.query.getParentElement(s,".se-component"):null,h=1===i.nodeType?Pe.query.getParentElement(i,".se-component"):null;return a&&Pe.utils.removeItem(a),h&&Pe.utils.removeItem(h),!1}function lo(t,e,s){const i=s?e.startContainer:e.endContainer,n=s?e.startOffset:e.endOffset,o=s?"previousSibling":"nextSibling";let r;return 1===i.nodeType?(r=ao(t,i.childNodes[n],o,i),Pe.check.isComponentContainer(r)||Pe.check.isNonEditable(r)?r:null):(r=ao(t,i,o,i),Pe.check.isEdgePoint(i,n,s?"front":"end")&&(Pe.check.isComponentContainer(r)||Pe.check.isNonEditable(r))?r:null)}function ao(t,e,s,i){if(!e)return null;let n=e[s];if(!n){if(n=t.format.getLine(i),n=n?n[s]:null,!n||t.component.is(n))return null;n="previousSibling"===s?n.firstChild:n.lastChild}return n}function ho(t,e,s,i){if(!t.collapsed||!e)return!1;const n=t.getBoundingClientRect();if(n.height<=0)return!1;const o=i.createRange();o.selectNodeContents(e);const r=o.getBoundingClientRect();return!(r.width<=2)&&("front"===s?n.left<=r.left+2:n.left>=r.right-2)}function co(t,e,s){if(!t.collapsed||!Pe.check.isBreak(e))return!1;const i="front"===s?"previousSibling":"nextSibling";let n=e[i];for(;3===n?.nodeType&&Pe.check.isZeroWidth(n);)n=n[i];return!n||Pe.check.isList(n)}function uo(t,e,s){const i="front"===s?"previousElementSibling":"nextElementSibling",n="front"===s?"lastElementChild":"firstElementChild";let o=e,r=null;for(;o&&!(r=o[i]);){const e=o.parentElement;if(!e||t.isClosureBlock(e)||Pe.check.isWysiwygFrame(e))return null;if(t.isBlock(e))o=e;else{if(!Pe.check.isListCell(e))return null;if("front"===s)return e;o=e}}for(;r&&t.isBlock(r)&&!t.isClosureBlock(r);)r=r[n];return r}function po(t,e,s){if(!e||!t.isNormalLine(e)||!Pe.check.isEmptyLine(e))return null;if(Pe.utils.arrayFind(e.children,Pe.check.isList))return null;const i="front"===s?e.previousElementSibling:e.nextElementSibling;return t.isNormalLine(i)||t.isBrLine(i)?i:null}function go(t,e){const s=Pe.utils.arrayFind(t.children,Pe.check.isList)||t.nextElementSibling||e?.parentElement?.nextElementSibling;return s&&(Pe.check.isList(s)||Pe.utils.arrayFind(s.children,Pe.check.isList))?s:null}const mo={"del.format.removeAndMove":({ports:t},{container:e,formatEl:s})=>{const i=t.html.remove();if(i.commonCon!==i.container&&s.parentElement)if(s.contains(e)){const e=function(t){const e=t.lastChild,s=t.nextElementSibling;if(!s)return e;if(Pe.check.isZeroWidth(s))return Pe.utils.removeItem(s),e;const i=s.childNodes;for(;i[0];)t.appendChild(i[0]);return Pe.utils.removeItem(s),e}(s);t.selection.setRange(e,e.textContent.length,e,e.textContent.length)}else{const{focusNode:e,focusOffset:i}=function(t){const e=t.childNodes,s=t.previousElementSibling;let i=e[0],n=0;if(!s)return{focusNode:i,focusOffset:n};if(Pe.check.isZeroWidth(s))return Pe.utils.removeItem(s),{focusNode:i,focusOffset:n};if(e.length>1||e[0]?.textContent.length>0)for(;e[0];)s.appendChild(e[0]);else i=s.lastChild,n=i.textContent.length;return Pe.utils.removeItem(t),{focusNode:i,focusOffset:n}}(s);t.selection.setRange(e,i,e,i)}},"backspace.brline.strip":({ctx:t,ports:e},{formatEl:s})=>{const i=t.options.get("defaultLine"),n=s.parentNode,o=Pe.utils.createElement(i);for(;s.firstChild&&!Pe.check.isBreak(s.firstChild);)o.appendChild(s.firstChild);s.firstChild&&Pe.check.isBreak(s.firstChild)&&s.removeChild(s.firstChild),o.firstChild||(o.innerHTML="<br>"),n.insertBefore(o,s),s.firstChild&&(s.textContent.trim()||s.querySelector("br"))||n.removeChild(s);const r=o.firstChild;e.selection.setRange(r,0,r,0)},"backspace.format.maintain":({ctx:t},{formatEl:e})=>{if(e.nodeName.toUpperCase()===t.options.get("defaultLine").toUpperCase()){e.innerHTML="<br>";const t=e.attributes;for(;t[0];)e.removeAttribute(t[0].name)}else e.parentNode.replaceChild(Pe.utils.createElement(t.options.get("defaultLine"),null,"<br>"),e)},"backspace.component.select":({ports:t},{selectionNode:e,range:s,fileComponentInfo:i})=>{let n=null;Pe.check.isBreak(e)?Pe.utils.removeItem(e):Pe.check.isBreak(n=s.startContainer.childNodes?.[s.startOffset])&&Pe.utils.removeItem(n),!1===t.component.select(i.target,i.pluginName)&&t.focusManager.blur()},"backspace.component.remove":({ports:t},{isList:e,sel:s,formatEl:i,fileComponentInfo:n})=>{e&&Pe.utils.removeItem(s),0===i.textContent.length&&Pe.utils.removeItem(i),!1===t.component.select(n.target,n.pluginName)&&t.focusManager.blur()},"backspace.list.mergePrev":({ports:t},{prev:e,formatEl:s,rangeEl:i})=>{let n=e===i.parentNode?i.previousSibling:e.lastChild;n||(n=Pe.utils.createTextNode(Re.zeroWidthSpace),i.parentNode.insertBefore(n,i.parentNode.firstChild));const o=3===n.nodeType?n.textContent.length:1;bo(s);const r=s.childNodes;let l=n,a=r[0];for(;a=r[0];)e.insertBefore(a,l.nextSibling),l=a;Pe.utils.removeItem(s),0===i.children.length&&Pe.utils.removeItem(i),t.selection.setRange(n,o,n,o)},"backspace.list.removeNested":({ports:t},{range:e})=>{t.html.remove(),3===e.startContainer.nodeType&&t.selection.setRange(e.startContainer,e.startContainer.textContent.length,e.startContainer,e.startContainer.textContent.length)},"backspace.emptyLine.mergePrev":({ports:t},{formatEl:e,prev:s})=>{Pe.utils.removeItem(e),fo(t,s,!0)},"backspace.brline.rowMerge":({ports:t},{rowEndBr:e,rowStartBr:s})=>{const i=s.nextSibling;i!==e&&3===i?.nodeType&&Pe.check.isZeroWidth(i)&&Pe.utils.removeItem(i);const n=s.previousSibling;if(Pe.utils.removeItem(s),n&&3===n.nodeType)t.selection.setRange(n,n.textContent.length,n,n.textContent.length);else if(Pe.check.isBreak(n))t.selection.setRange(e,0,e,0);else{const s=e.parentNode;t.selection.setRange(s,0,s,0)}},"backspace.softBreak.merge":({ports:t},{zws:e})=>{const s=e.previousSibling,i=e.parentNode,n=s?.previousSibling;Pe.utils.removeItem(e),s&&Pe.utils.removeItem(s),n?vo(t,n):i&&t.selection.setRange(i,0,i,0)},"delete.component.select":({ports:t},{formatEl:e,fileComponentInfo:s})=>{if(Pe.check.isListCell(e)){const t=s.container.previousSibling;Pe.check.isZeroWidth(t)&&Pe.utils.removeItem(t)}else Pe.check.isZeroWidth(e)&&Pe.utils.removeItem(e);!1===t.component.select(s.target,s.pluginName)&&t.focusManager.blur()},"delete.component.selectNext":({ports:t,ctx:e},{formatEl:s,nextEl:i})=>{if(Pe.check.isZeroWidth(s)&&(Pe.utils.removeItem(s),Pe.check.isTable(i))){let e=Pe.query.getEdgeChild(i,Pe.check.isTableCell,!1);return e=e.firstElementChild||e,void t.selection.setRange(e,0,e,0)}const n=t.component.get(i);n?(e.e.stopPropagation(),!1===t.component.select(n.target,n.pluginName)&&t.focusManager.blur()):t.component.is(i)&&(e.e.stopPropagation(),Pe.utils.removeItem(i))},"delete.list.removeNested":({ports:t,ctx:e},{range:s,formatEl:i,rangeEl:n})=>{s.startContainer!==s.endContainer&&t.html.remove();const o=go(i,n);if(o){let s,n;if(e.e.preventDefault(),Pe.check.isList(o)){const t=o.firstElementChild;for(n=t.childNodes,s=n[0];n[0];)i.insertBefore(n[0],o);Pe.utils.removeItem(t)}else{for(s=o.firstChild,n=o.childNodes;n[0];)i.appendChild(n[0]);Pe.utils.removeItem(o)}t.selection.setRange(s,0,s,0),t.history.push(!0)}},"delete.emptyLine.mergeNext":({ports:t},{formatEl:e,next:s})=>{Pe.utils.removeItem(e),fo(t,s,!1)},"line.merge":({ports:t},{into:e,from:s})=>{const i=t.format,n=s.parentElement;bo(e);const o=e.lastChild;for(bo(s);s.firstChild;)e.appendChild(s.firstChild);Pe.utils.removeItem(s);let r=n;for(;r&&r!==e.parentElement&&i.isBlock(r)&&!i.isClosureBlock(r)&&Pe.check.isZeroWidth(r);){const t=r.parentElement;Pe.utils.removeItem(r),r=t}e.firstChild||e.appendChild(Pe.utils.createElement("BR")),o?vo(t,o):t.selection.setRange(e,0,e,0)},"delete.brline.rowMerge":({ports:t},{rowEndBr:e})=>{let s=e.nextSibling;3===s?.nodeType&&Pe.check.isZeroWidth(s)&&(s=s.nextSibling);const i=e.parentNode;Pe.utils.removeItem(e),s&&(3===s.nodeType||Pe.check.isBreak(s))?t.selection.setRange(s,0,s,0):t.selection.setRange(i,i.childNodes.length,i,i.childNodes.length)},"delete.softBreak.merge":({ports:t},{br:e})=>{const s=e.previousSibling,i=e.parentNode,n=e.nextSibling;n&&3===n.nodeType&&Pe.check.isZeroWidth(n.textContent)&&Pe.utils.removeItem(n),Pe.utils.removeItem(e),s?vo(t,s):i&&t.selection.setRange(i,0,i,0)},"tab.format.indent":({ports:t,ctx:e},{range:s,formatEl:i,shift:n})=>{const o=t.format.getLines(null),r=[],l=[],a=Pe.check.isListCell(o[0]),h=Pe.check.isListCell(o.at(-1));let c={sc:s.startContainer,so:s.startOffset,ec:s.endContainer,eo:s.endOffset};for(let t,e=0,s=o.length;e<s;e++)if(t=o[e],Pe.check.isListCell(t)){if(!t.previousElementSibling&&!n)continue;r.push(t)}else l.push(t);if(r.length>0&&(c=t.listFormat.applyNested(r,n)),l.length>0)if(n){const t=l.length-1;for(let e,s=0;s<=t;s++){e=l[s].childNodes;for(let t,s=0,i=e.length;s<i&&(t=e[s],t);s++)if(!Pe.check.isZeroWidth(t)){/^\s{1,4}$/.test(t.textContent)?Pe.utils.removeItem(t):/^\s{1,4}/.test(t.textContent)&&(t.textContent=t.textContent.replace(/^\s{1,4}/,""));break}}const e=Pe.query.getEdgeChild(l[0],"text",!1),s=Pe.query.getEdgeChild(l[t],"text",!0);!a&&e&&(c.sc=e,c.so=0),!h&&s&&(c.ec=s,c.eo=s.textContent.length)}else if(1===l.length){let n=e.store.get("tabSize")+1;if(e.options.get("syncTabIndent")){const e=Pe.query.findTextIndexOnLine(i,s.startContainer,s.startOffset,(e=>t.component.is(e))),o=t.format.isLine(i.previousElementSibling)?Pe.query.findTabEndIndex(i.previousElementSibling,e,2):0;o>e&&(n=o-e)}const o=Pe.utils.createTextNode(new Array(n).join(" "));if(!t.html.insertNode(o,{afterNode:null,skipCharCount:!1}))return!1;a||(c.sc=o,c.so=o.length),h||(c.ec=o,c.eo=o.length)}else{const t=Pe.utils.createTextNode(new Array(e.store.get("tabSize")+1).join(" ")),s=l.length-1;for(let e,i=0;i<=s;i++)e=l[i].firstChild,e&&(Pe.check.isBreak(e)?l[i].insertBefore(t.cloneNode(!1),e):e.textContent=t.textContent+e.textContent);const i=Pe.query.getEdgeChild(l[0],"text",!1),n=Pe.query.getEdgeChild(l[s],"text",!0);!a&&i&&(c.sc=i,c.so=0),!h&&n&&(c.ec=n,c.eo=n.textContent.length)}t.selection.setRange(c.sc,c.so,c.ec,c.eo)},"caret.scrollTo":({ports:t},{range:e})=>{t.caretScrollTo(e)},"enter.line.addDefault":({ports:t},{formatEl:e})=>{const s=t.format.addLineAfter(e).firstChild;t.selection.setRange(s,0,s,0)},"enter.list.addItem":({ports:t},{formatEl:e,selectionNode:s})=>{const i=Pe.utils.createElement("BR"),n=Pe.utils.createElement("LI",null,i);e.parentNode.insertBefore(n,e.nextElementSibling),n.appendChild(s.nextSibling),t.selection.setRange(i,1,i,1)},"enter.format.exitEmpty":({ports:t,ctx:e},{formatEl:s,rangeEl:i})=>{let n=null;if(Pe.check.isListCell(i.parentElement)){const t=s.parentNode.parentElement;i=t.parentElement;const o=Pe.utils.createElement("LI");o.innerHTML="<br>",Pe.utils.copyTagAttributes(o,s,e.options.get("lineAttrReset")),n=o,i.insertBefore(n,t.nextElementSibling)}else{let o;o=Pe.check.isTableCell(i.parentElement)?"DIV":Pe.check.isList(i.parentElement)?"LI":t.format.isLine(i.nextElementSibling)?i.nextElementSibling.nodeName:t.format.isLine(i.previousElementSibling)?i.previousElementSibling.nodeName:e.options.get("defaultLine"),n=Pe.utils.createElement(o);const r=t.format.removeBlock(i,{selectedFormats:[s],newBlockElement:null,shouldDelete:!0,skipHistory:!0});r.cc.insertBefore(n,r.sc?r.sc.nextSibling:r.cc.firstChild)}n.innerHTML="<br>",t.nodeTransform.removeAllParents(s,null,null),t.selection.setRange(n,1,n,1)},"enter.format.cleanBrAndZWS":({ports:t},{selectionNode:e,selectionFormat:s,brBlock:i,children:n,offset:o})=>{s?Pe.utils.removeItem(n[o-1]):Pe.utils.removeItem(e);const r=i.nextElementSibling,l=t.format.addLine(i,t.format.isLine(r)?r:null);Pe.utils.copyFormatAttributes(l,i),t.selection.setRange(l,1,l,1)},"enter.format.insertBrHtml":({ports:t},{brBlock:e,range:s,wSelection:i,offset:n})=>{t.html.insert(s.collapsed&&Pe.check.isBreak(s.startContainer.childNodes[s.startOffset-1])?"<br>":"<br><br>",{selectInserted:!1,skipCharCount:!0,skipCleaning:!0});let o=i.focusNode;const r=i.focusOffset;e===o&&(o=o.childNodes[r-n>1?r-1:r]),t.selection.setRange(o,1,o,1),t.setOnShortcutKey(!0)},"enter.brline.insert":({ports:t},{range:e})=>{t.selection.setRange(e.startContainer,e.startOffset,e.endContainer,e.endOffset),e.collapsed||t.html.remove();const s=Pe.utils.createElement("BR");t.html.insertNode(s,{afterNode:null,skipCharCount:!0}),s.nextSibling||s.parentNode.appendChild(Pe.utils.createElement("BR"));const i=s.nextSibling;t.selection.setRange(i,0,i,0),t.setOnShortcutKey(!0)},"enter.shift.br":({ports:t,ctx:e},{range:s})=>{const i=e.fc.get("_wd"),n=t.selection.get(),o=n?.rangeCount>0&&e.fc.get("wysiwyg").contains(n.focusNode)?n.getRangeAt(0):s,r=i.createRange();if(r.setStart(o.startContainer,o.startOffset),r.setEnd(o.endContainer,o.endOffset),o.collapsed||(r.deleteContents(),r.collapse(!0)),1===r.startContainer.nodeType&&Pe.check.isBreak(r.startContainer)){const t=r.startContainer;r.setStart(t.parentNode,Pe.utils.getArrayIndex(t.parentNode.childNodes,t)+r.startOffset),r.collapse(!0)}const l=Pe.utils.createElement("BR");r.insertNode(l);const a=l.nextSibling;if(a&&3===a.nodeType&&!Pe.check.isZeroWidth(a.textContent))t.selection.setRange(a,0,a,0);else{const e=Pe.utils.createTextNode(Re.zeroWidthSpace);l.parentNode.insertBefore(e,l.nextSibling),t.selection.setRange(e,1,e,1)}t.history.push(!1)},"enter.brline.exit":({ports:t},{brBlock:e})=>{const s=e.lastChild;s&&(Pe.check.isBreak(s)||Pe.check.isZeroWidth(s.textContent))&&Pe.utils.removeItem(s);const i=e.nextElementSibling,n=t.format.addLine(e,t.format.isLine(i)?i:null);Pe.utils.copyFormatAttributes(n,e),t.selection.setRange(n,1,n,1)},"enter.format.insertBrNode":({ports:t},{wSelection:e})=>{const s=e.focusNode.nextSibling,i=Pe.utils.createElement("BR");t.html.insertNode(i,{afterNode:null,skipCharCount:!0});const n=i.previousSibling,o=i.nextSibling;Pe.check.isBreak(s)||Pe.check.isBreak(n)||o&&!Pe.check.isZeroWidth(o)?t.selection.setRange(o,0,o,0):(i.parentNode.insertBefore(i.cloneNode(!1),i),t.selection.setRange(i,1,i,1)),t.setOnShortcutKey(!0)},"enter.format.breakAtEdge":({ports:t,ctx:e},{formatEl:s,selectionNode:i,formatStartEdge:n,formatEndEdge:o,bidiSwapped:r})=>{const l=Pe.utils.createElement("BR"),a=Pe.utils.createElement(s.nodeName,null,l);Pe.utils.copyTagAttributes(a,s,e.options.get("lineAttrReset"));let h=l;if(!o||!e.options.get("lineBreakClearStyle")){let t=i;do{if(!Pe.check.isBreak(t)&&1===t.nodeType){const e=t.cloneNode(!1);e.appendChild(h),h=e}t=t.parentElement}while(s!==t&&s.contains(t))}if(a.appendChild(h),s.parentNode.insertBefore(a,n&&!o?s:s.nextElementSibling),o)t.selection.setRange(l,1,l,1);else if(r)t.selection.setRange(s,1,s,1);else{const e=s.firstChild||s;t.selection.setRange(e,0,e,0)}},"enter.format.breakWithSelection":({ports:t,ctx:e},{formatEl:s,range:i,formatStartEdge:n,formatEndEdge:o})=>{const r=t.format.getLine(i.startContainer,null)!==t.format.getLine(i.endContainer,null),l=s.cloneNode(!1);l.innerHTML="<br>";const a=i.commonAncestorContainer,h=a===i.startContainer&&a===i.endContainer&&Pe.check.isZeroWidth(a)?{container:a,offset:i.endOffset,prevContainer:a.previousElementSibling,commonCon:a}:t.html.remove();let c=t.format.getLine(h.container,null),d=0;if(!c)return void(Pe.check.isWysiwygFrame(h.container)&&(t.enterPrevent(e.e),e.fc.get("wysiwyg").appendChild(l),c=l,Pe.utils.copyTagAttributes(c,s,e.options.get("lineAttrReset")),t.selection.setRange(c,d,c,d)));const u=t.format.getBlock(h.container);c=c.contains(u)?Pe.query.getEdgeChild(u,(e=>Boolean(t.format.getLine(e))),!1):c,r?o&&!n?(c.parentNode.insertBefore(l,h.prevContainer&&h.container!==h.prevContainer?c:c.nextElementSibling),c=l,d=0):(d=h.offset,n&&(c.parentNode.insertBefore(l,c),o&&(d=0))):o&&n?(c.parentNode.insertBefore(l,c),d=0):o?(c=c.parentNode.insertBefore(l,c.nextElementSibling),c=l,d=0):c=t.nodeTransform.split(h.container,h.offset,Pe.query.getNodeDepth(s)),t.enterPrevent(e.e),Pe.utils.copyTagAttributes(c,s,e.options.get("lineAttrReset")),t.selection.setRange(c,d,c,d)},"enter.format.breakAtCursor":({ports:t,ctx:e},{formatEl:s,range:i})=>{let n=null;n=Pe.check.isZeroWidth(s)?t.format.addLine(s,s.cloneNode(!1)):t.nodeTransform.split(i.endContainer,i.endOffset,Pe.query.getNodeDepth(s)),t.enterPrevent(e.e),Pe.utils.copyTagAttributes(n,s,e.options.get("lineAttrReset")),t.selection.setRange(n,0,n,0)},"enter.figcaption.exitInList":({ports:t},{formatEl:e})=>{const s=t.format.addLine(e,null);t.selection.setRange(s,0,s,0)},"keydown.input.insertNbsp":({ports:t})=>{const e=t.html.insertNode(Pe.utils.createTextNode(" "),{afterNode:null,skipCharCount:!0});e&&t.selection.setRange(e,e.length,e,e.length)},"keydown.input.insertZWS":({ports:t})=>{const e=Pe.utils.createTextNode(Re.zeroWidthSpace);t.html.insertNode(e,{afterNode:null,skipCharCount:!0}),t.selection.setRange(e,1,e,1)}};function fo(t,e,s){const i=s?e.childNodes.length:0;t.selection.setRange(e,i,e,i)}function vo(t,e){const s=3===e.nodeType?e.textContent.length:e.childNodes.length;t.selection.setRange(e,s,e,s)}function bo(t){let e=t.lastChild;for(;e&&(Pe.check.isBreak(e)||3===e.nodeType&&Pe.check.isZeroWidth(e));){const t=e.previousSibling;Pe.utils.removeItem(e),e=t}}async function yo(t,e){const s={...oo,...mo};for(const i of t){if("action.stop"===i.t)return!1;const t=s[i.t];if(t){if(!1===await t(e,i.p))return!1}}}const wo=()=>({t:"event.prevent"}),Co=()=>({t:"event.prevent.stop"}),_o=()=>({t:"cache.styleNode"}),ko=t=>({t:"cache.formatAttrsTemp",p:{attrs:t}}),xo=()=>({t:"component.deselect"}),$o=()=>({t:"focusManager.nativeFocus"}),So=t=>({t:"history.push",p:t}),Eo=()=>({t:"documentType.refreshHeader"}),To=(t,e,s,i,n)=>({t:"format.removeBlock",p:{rangeEl:t,selectedFormats:e,newBlockElement:s,shouldDelete:i,skipHistory:n}}),Mo=t=>({t:"dom.utils.removeItem",p:{item:t}}),No=t=>({t:"select.component.fallback",p:{cmponentInfo:t}}),Bo=(t,e)=>({t:"del.format.removeAndMove",p:{container:t,formatEl:e}}),Io=t=>({t:"backspace.format.maintain",p:{formatEl:t}}),Lo=t=>({t:"backspace.brline.strip",p:{formatEl:t}}),Ao=(t,e,s)=>({t:"backspace.component.select",p:{selectionNode:t,range:e,fileComponentInfo:s}}),Oo=(t,e,s,i)=>({t:"backspace.component.remove",p:{isList:t,sel:e,formatEl:s,fileComponentInfo:i}}),Ro=(t,e,s)=>({t:"backspace.list.mergePrev",p:{prev:t,formatEl:e,rangeEl:s}}),zo=t=>({t:"backspace.list.removeNested",p:{range:t}}),Po=(t,e)=>({t:"backspace.emptyLine.mergePrev",p:{formatEl:t,prev:e}}),Do=(t,e)=>({t:"backspace.brline.rowMerge",p:{rowEndBr:t,rowStartBr:e}}),Fo=t=>({t:"backspace.softBreak.merge",p:{zws:t}}),Ho=(t,e)=>({t:"delete.component.select",p:{formatEl:t,fileComponentInfo:e}}),qo=(t,e)=>({t:"delete.component.selectNext",p:{formatEl:t,nextEl:e}}),Wo=(t,e,s)=>({t:"delete.list.removeNested",p:{range:t,formatEl:e,rangeEl:s}}),Uo=(t,e)=>({t:"delete.emptyLine.mergeNext",p:{formatEl:t,next:e}}),Vo=t=>({t:"delete.brline.rowMerge",p:{rowEndBr:t}}),jo=t=>({t:"delete.softBreak.merge",p:{br:t}}),Go=(t,e)=>({t:"line.merge",p:{into:t,from:e}}),Ko=(t,e,s)=>({t:"tab.format.indent",p:{range:t,formatEl:e,shift:s}}),Yo=t=>({t:"caret.scrollTo",p:{range:t}}),Xo=t=>({t:"enter.line.addDefault",p:{formatEl:t}}),Zo=(t,e)=>({t:"enter.list.addItem",p:{formatEl:t,selectionNode:e}}),Jo=(t,e)=>({t:"enter.format.exitEmpty",p:{formatEl:t,rangeEl:e}}),Qo=(t,e,s,i)=>({t:"enter.format.insertBrHtml",p:{brBlock:t,range:e,wSelection:s,offset:i}}),tr=t=>({t:"enter.format.insertBrNode",p:{wSelection:t}}),er=t=>({t:"enter.brline.insert",p:{range:t}}),sr=t=>({t:"enter.shift.br",p:{range:t}}),ir=t=>({t:"enter.brline.exit",p:{brBlock:t}}),nr=(t,e,s,i,n)=>({t:"enter.format.breakAtEdge",p:{formatEl:t,selectionNode:e,formatStartEdge:s,formatEndEdge:i,bidiSwapped:n}}),or=(t,e,s,i)=>({t:"enter.format.breakWithSelection",p:{formatEl:t,range:e,formatStartEdge:s,formatEndEdge:i}}),rr=(t,e)=>({t:"enter.format.breakAtCursor",p:{formatEl:t,range:e}}),lr=t=>({t:"enter.figcaption.exitInList",p:{formatEl:t}}),ar=()=>({t:"keydown.input.insertNbsp"}),hr=()=>({t:"keydown.input.insertZWS"});function cr(t,e,s){const{format:i,component:n}=e,{fc:o,options:r,range:l,selectionNode:a}=s;let{formatEl:h}=s;const c=!l.collapsed||l.startContainer!==l.endContainer,d=r.get("_rtl")&&!c&&0===l.startOffset&&ho(l,h,"front",o.get("_wd"));if(t.push(xo()),t.push(_o()),c&&ro(e))return t.push(Co()),t.push(Yo(l)),!0;if(!(i.isNormalLine(h)||i.isBrLine(h)||o.get("wysiwyg").firstElementChild||n.is(a)||null===function(t,e){return t.setDefaultLine(e)}(e,r.get("defaultLine"))))return t.push(Co()),!1;if(i.isLine(h)&&c&&Pe.check.isEdgePoint(l.startContainer,l.startOffset,"front")&&(!l.startContainer.previousSibling||Pe.check.isZeroWidth(l.startContainer.previousSibling))&&i.getLine(l.startContainer)!==i.getLine(l.endContainer)&&(i.isLine(h.previousElementSibling)||Pe.check.isListCell(h)))return t.push(Co()),t.push(Bo(l.startContainer,h)),t.push(So(!0)),t.push(Yo(l)),!1;if(!c&&!d&&h&&i.isNormalLine(h)&&!Pe.check.isListCell(h)&&i.isEdgeLine(l.startContainer,l.startOffset,"front")){const e=function(t,e,s){const i=uo(t,e,s);return t.isLine(i)?i:null}(i,h,"front");if(e&&e.parentElement!==h.parentElement&&i.isNormalLine(e))return t.push(Co()),t.push(Go(e,h)),t.push(So(!0)),!1}if(!c&&!d&&!h.previousElementSibling&&0===l.startOffset&&!a.previousSibling&&!Pe.check.isListCell(h)&&i.isLine(h)&&(!i.isBrLine(h)||i.isClosureBrLine(h)||Pe.check.isWysiwygFrame(h.parentNode)))return i.isClosureBlock(h.parentNode)?(t.push(Co()),!1):i.isBrLine(h)&&Pe.check.isWysiwygFrame(h.parentNode)?(t.push(Co()),t.push(Lo(h)),t.push(So(!0)),!1):(Pe.check.isWysiwygFrame(h.parentNode)&&h.childNodes.length<=1&&(!h.firstChild||Pe.check.isZeroWidth(h.textContent))&&(t.push(Co()),t.push(Io(h))),t.push($o()),t.push(Yo(l)),!1);const u=l.startContainer;if(h&&!d&&!h.previousElementSibling&&0===l.startOffset&&3===u.nodeType&&Pe.check.isZeroWidth(u)&&!0===function(t,e,s){let i=e.parentNode.previousSibling;const n=e.parentNode.nextSibling;i||(n?i=n:(i=Pe.utils.createElement("BR"),s.appendChild(i)));let o=e;for(;s.contains(o)&&!o.previousSibling;)o=o.parentNode;if(!s.contains(o))return e.textContent="",t.nodeTransform.removeAllParents(e,null,s),!0}(e,u,h))return!0;if(!c&&h&&(0===l.startOffset||a===h)){const s=a===h?lo(e,l,!0):Pe.check.isElement(a.previousSibling)?a.previousSibling:Pe.check.isEdgePoint(l.startContainer,l.startOffset)?Pe.query.getPreviousDeepestNode(l.startContainer):null;if(n.is(s)){const e=n.get(s);if(e)return t.push(Co()),t.push(Ao(a,l,e)),!0}}if(lo(e,l,!0))return t.push(Co()),!0;c||d||!i.isEdgeLine(l.startContainer,l.startOffset,"front")||i.isLine(h.previousElementSibling)&&t.push(ko(h.previousElementSibling.attributes)),h=i.getLine(l.startContainer,null);const p=i.getBlock(h,null),g=l.commonAncestorContainer;if(p&&h&&!Pe.check.isTableCell(p)&&!/^FIGCAPTION$/i.test(p.nodeName)){if(Pe.check.isListCell(h)&&Pe.check.isList(p)&&(Pe.check.isListCell(p.parentElement)||h.previousElementSibling)&&(a===h||co(l,a,"front")||3===a.nodeType&&(!a.previousSibling||Pe.check.isList(a.previousSibling)))&&(i.getLine(l.startContainer,null)!==i.getLine(l.endContainer,null)?p.contains(l.startContainer):0===l.startOffset&&l.collapsed&&!d)){if(l.startContainer!==l.endContainer)t.push(wo()),t.push(zo(l)),t.push(So(!0));else{let e=h.previousElementSibling||p.parentElement;if(Pe.check.isListCell(e)){t.push(wo());let s=e;if(!e.contains(h)&&Pe.check.isListCell(s)&&Pe.check.isList(s.lastElementChild)){for(s=s.lastElementChild.lastElementChild;Pe.check.isListCell(s)&&Pe.check.isList(s.lastElementChild);)s=s.lastElementChild&&s.lastElementChild.lastElementChild;e=s}t.push(Ro(e,h,p)),t.push(So(!0))}}return t.push(Yo(l)),!0}if(!c&&0===l.startOffset&&!d){let e=!0,s=g;for(;s&&s!==p&&!Pe.check.isWysiwygFrame(s);){if(s.previousSibling&&(1===s.previousSibling.nodeType||!Pe.check.isZeroWidth(s.previousSibling.textContent.trim()))){e=!1;break}s=s.parentNode}if(e&&p.parentNode)return t.push(wo()),t.push(To(p,Pe.check.isListCell(h)?[h]:null,null,!1,!1)),t.push(So(!0)),t.push(Yo(l)),!0}}if(!c&&h&&Pe.check.isEmptyLine(h)&&n.is(h.previousElementSibling)){const e=n.get(h.previousElementSibling);if(e)return t.push(Co()),t.push(Oo(!1,h.firstChild,h,e)),t.push(Yo(l)),!0}if(!c&&h&&(0===l.startOffset||a===h&&h.childNodes[l.startOffset])){const e=Pe.check.isListCell(h),s=a===h?h.childNodes[l.startOffset]:a,i=(e?s:h).previousSibling,o=e||(3===g.nodeType||Pe.check.isBreak(g))&&!g.previousSibling&&0===l.startOffset;if(s&&(e||!s.previousSibling)&&(g&&n.is(g.previousSibling)||o&&n.is(i))){const o=n.get(i);return o?(t.push(Co()),t.push(Oo(e,s,h,o))):n.is(i)&&(t.push(Co()),t.push(Mo(i))),t.push(Yo(l)),!0}if(s&&Pe.check.isNonEditable(s.previousSibling))return t.push(Co()),t.push(Mo(s.previousSibling)),t.push(Yo(l)),!0}if(!c&&i.isBrLine(h)&&Pe.check.isBreak(l.startContainer)&&0===l.startOffset){let e=l.startContainer.previousSibling;if(3===e?.nodeType&&Pe.check.isZeroWidth(e)&&(e=e.previousSibling),Pe.check.isBreak(e))return t.push(Co()),t.push(Do(l.startContainer,e)),t.push(So(!0)),t.push(Yo(l)),!1}if(!c&&3===l.startContainer.nodeType&&Pe.check.isZeroWidth(l.startContainer)&&l.startOffset<=1&&Pe.check.isBreak(l.startContainer.previousSibling))return t.push(Co()),t.push(Fo(l.startContainer)),t.push(So(!0)),t.push(Yo(l)),!1;const m=po(i,h,"front");return!c&&m?(t.push(Co()),t.push(Po(h,m)),t.push(So(!0)),t.push(Yo(l)),!1):(t.push(Yo(l)),!0)}function dr(t,e,s){const{format:i,char:n,selection:o}=e,{frameOptions:r,range:l,formatEl:a,selectionNode:h,shift:c,e:d}=s,u=!l.collapsed||l.startContainer!==l.endContainer;t.push(xo());const p=i.getBrLine(h,null),g=i.getBlock(a,null);if("byte-html"===r.get("charCounter_type")){let e="";if(e=!c&&p||c?"<br>":"<"+a.nodeName+"><br></"+a.nodeName+">",!n.check(e))return t.push(wo()),!1}if(c)return e.enterPrevent(d),t.push(sr(l)),t.push(Yo(l)),!0;if(!c){let n=i.isEdgeLine(l.endContainer,l.endOffset,"end"),r=i.isEdgeLine(l.startContainer,l.startOffset,"front"),c=!1;if(s.options.get("_rtl")&&a&&l.collapsed&&r!==n){const t=s.fc.get("_wd");r&&ho(l,a,"front",t)?(r=!1,n=!0,c=!0):n&&ho(l,a,"end",t)&&(n=!1,r=!0,c=!0)}if(n&&(/^H[1-6]$/i.test(a.nodeName)||/^HR$/i.test(a.nodeName)))return e.enterPrevent(d),t.push(Xo(a)),t.push(Yo(l)),!0;if(g&&a&&!Pe.check.isTableCell(g)&&!/^FIGCAPTION$/i.test(g.nodeName)){const s=o.getRange();if(Pe.check.isEdgePoint(s.endContainer,s.endOffset)&&Pe.check.isList(h.nextSibling))return e.enterPrevent(d),t.push(Zo(a,h)),t.push(Yo(l)),!0;if((3!==s.commonAncestorContainer.nodeType||!s.commonAncestorContainer.nextElementSibling)&&Pe.check.isZeroWidth(a.innerText.trim())&&!Pe.check.isListCell(a.nextElementSibling))return e.enterPrevent(d),t.push(Jo(a,g)),!0}if(p||g===a&&i.isClosureBlock(g)&&i.isLine(a)){if(e.enterPrevent(d),p&&!i.isClosureBrLine(p))return!function(t,e){const s=Array.from(t.childNodes),i=[[]];for(const t of s)Pe.check.isBreak(t)?i.push([]):i[i.length-1].push(t);s.length&&Pe.check.isBreak(s[s.length-1])&&i.pop();const n=t=>!t||t.every((t=>Pe.check.isZeroWidth(t.textContent))),o=e.anchorNode;let r=0;if(o===t)for(let t=0;t<e.anchorOffset&&t<s.length;t++)Pe.check.isBreak(s[t])&&r++;else for(const t of s){if(t===o||1===t.nodeType&&t.contains(o))break;Pe.check.isBreak(t)&&r++}const l=Math.max(i.length,1),a=Math.min(r,l-1);return{shouldExit:a===l-1&&n(i[a])&&a>=1&&n(i[a-1])}}(p,o.get()).shouldExit?t.push(er(l)):t.push(ir(p)),t.push(Yo(l)),!0;const s=o.get();return h===p?t.push(Qo(p,l,s,s.focusOffset)):t.push(tr(s)),t.push(Yo(l)),!0}if(l.collapsed&&(r||n))return e.enterPrevent(d),t.push(nr(a,h,r,n,c)),t.push(Yo(l)),!0;if(a){if(t.push(wo()),u){if(s.options.get("_rtl")&&r&&!n){const t=s.fc.get("_wd"),e=t.createRange();e.setStart(l.startContainer,l.startOffset),e.collapse(!0),ho(e,a,"front",t)&&(r=!1,n=!0,c=!0)}t.push(or(a,l,r,n))}else t.push(rr(a,l));return t.push(Yo(l)),!0}}return u?(t.push(Yo(l)),!0):(g&&Pe.query.getParentElement(g,"FIGCAPTION")&&Pe.query.getParentElement(g,Pe.check.isList)&&(e.enterPrevent(d),t.push(lr(a)),t.push(Yo(l))),!0)}const{isOSX_IOS:ur}=Oe;function pr(t,e){return t.get("_canUseBeforeInput")&&!e?.repeat}async function gr(t,e){const s=[];switch(e.keyCode){case"Backspace":if(!1===cr(s,t,e))return s;break;case"Delete":if(!1===function(t,e,s){const{format:i,component:n}=e,{fc:o,range:r,selectionNode:l}=s;let{formatEl:a}=s;const h=!r.collapsed||r.startContainer!==r.endContainer,c=s.options.get("_rtl")&&!h&&r.endOffset>=(r.endContainer.textContent?.length||0)&&ho(r,a,"end",o.get("_wd"));if(t.push(xo()),t.push(_o()),h&&ro(e))return t.push(Co()),!0;if(!h&&!c&&a&&i.isEdgeLine(r.endContainer,r.endOffset,"end")){const e=uo(i,a,"end");if(!e)return t.push(Co()),!1;if(i.isLine(e)&&e.parentElement!==a.parentElement&&i.isNormalLine(a)&&i.isNormalLine(e))return t.push(Co()),t.push(Go(a,e)),t.push(So(!0)),!1}if(i.isLine(a)&&h&&Pe.check.isEdgePoint(r.endContainer,r.endOffset,"end")&&(!r.endContainer.nextSibling||Pe.check.isZeroWidth(r.endContainer.nextSibling))&&i.getLine(r.startContainer)!==i.getLine(r.endContainer)&&(i.isLine(a.nextElementSibling)||Pe.check.isListCell(a)))return t.push(Co()),t.push(Bo(r.endContainer,a)),t.push(So(!0)),!1;if(!h&&a&&(r.endOffset===r.endContainer.textContent.length||l===a)){const s=l===a?lo(e,r,!1):Pe.check.isElement(l.nextSibling)?l.nextSibling:Pe.check.isEdgePoint(r.endContainer,r.endOffset)?Pe.query.getNextDeepestNode(r.endContainer,null):null;if(n.is(s)){const e=n.get(s);if(e)return t.push(Co()),t.push(Ho(a,e)),!0}}if(lo(e,r,!1))return t.push(Co()),!0;if((i.isLine(l)||null===l.nextSibling||Pe.check.isZeroWidth(l.nextSibling)&&null===l.nextSibling.nextSibling)&&r.startOffset===l.textContent.length){const e=a.nextElementSibling;if(!e)return!0;if(n.is(e))return t.push(wo()),t.push(qo(a,e)),!0}if(!h&&(Pe.check.isEdgePoint(r.endContainer,r.endOffset)||l===a&&a.childNodes[r.startOffset])){const e=l===a&&a.childNodes[r.startOffset]||l;if(e&&Pe.check.isNonEditable(e.nextSibling))return t.push(Co()),t.push(Mo(e.nextSibling)),!0;if(n.is(e))return t.push(Co()),t.push(Mo(e)),!0}h||c||!i.isEdgeLine(r.endContainer,r.endOffset,"end")||i.isLine(a.nextElementSibling)&&t.push(ko(a.attributes)),a=i.getLine(r.startContainer,null);const d=i.getBlock(a,null);if(Pe.check.isListCell(a)&&Pe.check.isList(d)&&(r.startContainer!==r.endContainer||go(a,d))&&(l===a||co(r,l,"end")||3===l.nodeType&&(!l.nextSibling||Pe.check.isList(l.nextSibling))&&(i.getLine(r.startContainer,null)!==i.getLine(r.endContainer,null)?d.contains(r.endContainer):r.endOffset===l.textContent.length&&r.collapsed&&!c)))return t.push(Wo(r,a,d)),!0;if(!h&&i.isBrLine(a)&&Pe.check.isBreak(r.startContainer)&&0===r.startOffset){let e=r.startContainer.previousSibling;if(3===e?.nodeType&&Pe.check.isZeroWidth(e)&&(e=e.previousSibling),Pe.check.isBreak(e))return t.push(Co()),t.push(Vo(r.startContainer)),t.push(So(!0)),!1}if(!h){const e=r.startContainer;let s=null;if(3===e.nodeType&&r.startOffset>=e.textContent.length&&Pe.check.isBreak(e.nextSibling)){const t=e.nextSibling;3===t.nextSibling?.nodeType&&Pe.check.isZeroWidth(t.nextSibling.textContent)&&(s=t)}else 3===e.nodeType&&Pe.check.isZeroWidth(e)&&0===r.startOffset&&Pe.check.isBreak(e.previousSibling)&&(s=e.previousSibling);if(s)return t.push(Co()),t.push(jo(s)),t.push(So(!0)),!1}const u=po(i,a,"end");return!(!h&&u&&(t.push(Co()),t.push(Uo(a,u)),t.push(So(!0)),1))}(s,t,e))return s;break;case"Tab":if(!1===function(t,e,s){const{options:i,selectionNode:n,range:o,formatEl:r,ctrl:l,alt:a,shift:h}=s;return!!i.get("tabDisable")||(t.push(wo()),l||a||Pe.check.isWysiwygFrame(n)||(t.push(Ko(o,r,h)),t.push(So(!1))),!0)}(s,0,e))return s;break;case"Enter":if(!pr(e.store,e.e)&&!1===dr(s,t,e))return s}const{fc:i,keyCode:n,shift:o,alt:r,ctrl:l,range:a}=e;if(o&&(ur?r:l)&&Fe.isSpace(n))return s.push(Co()),s.push(ar()),s;const h=!a.collapsed||a.startContainer!==a.endContainer;return l||r||h||Fe.isNonTextKey(n)||!Pe.check.isBreak(a.commonAncestorContainer)?!i.has("documentType_use_header")||!h||l||r||o||Fe.isDirectionKey(n)?(function(t,e,s){const{component:i}=e,{formatEl:n,range:o,selectionNode:r,keyCode:l}=s,a=s.options.get("_rtl"),h="ArrowLeft"===l?a?"forward":"back":"ArrowRight"===l?a?"back":"forward":null;let c=null;switch(l){case"ArrowUp":i.is(n.previousElementSibling)&&(c=i.get(n.previousElementSibling));break;case"ArrowLeft":case"ArrowRight":if("forward"===h){if(Pe.check.isEdgePoint(r,o.endOffset,"end")){const t=r.nextElementSibling||Pe.query.getNextDeepestNode(r);t?i.is(t)&&(c=i.get(t)):i.is(n.nextElementSibling)&&(c=i.get(n.nextElementSibling))}}else if("back"===h&&Pe.check.isEdgePoint(r,o.startOffset,"front")){const t=r.previousElementSibling||Pe.query.getPreviousDeepestNode(r);t?i.is(t)&&(c=i.get(t)):i.is(n.previousElementSibling)&&(c=i.get(n.previousElementSibling))}break;case"ArrowDown":i.is(n.nextElementSibling)&&(c=i.get(n.nextElementSibling))}c&&!c.options?.isInputComponent&&(t.push(wo()),t.push(No(c)))}(s,t,e),s):(s.push(Eo()),s):(s.push(hr()),s)}function mr(t,{_styleNodes:e}){const{frameContext:s,ui:i,focusManager:n,selection:o,format:r,listFormat:l,component:a,html:h,nodeTransform:c,history:d,char:u,menu:p,store:g}=t.$;return{focusManager:{nativeFocus:()=>n.nativeFocus(),blur:()=>n.blur()},selection:{getRange:()=>o.getRange(),getNode:()=>o.getNode(),setRange:(t,e,s,i)=>o.setRange(t,e,s,i),get:()=>o.get()},format:{isLine:t=>r.isLine(t),getLine:(t,e)=>r.getLine(t,e),getLines:t=>r.getLines(t),getBrLine:(t,e)=>r.getBrLine(t,e),getBlock:(t,e)=>r.getBlock(t,e),isNormalLine:t=>r.isNormalLine(t),isBrLine:t=>r.isBrLine(t),isClosureBrLine:t=>r.isClosureBrLine(t),isBlock:t=>r.isBlock(t),isClosureBlock:t=>r.isClosureBlock(t),isEdgeLine:(t,e,s)=>r.isEdgeLine(t,e,s),removeBlock:(t,e)=>r.removeBlock(t,e),addLine:(t,e)=>r.addLine(t,e),addLineAfter:t=>r.addLineAfter(t)},listFormat:{applyNested:(t,e)=>l.applyNested(t,e)},component:{deselect:()=>a.deselect(),is:t=>a.is(t),get:t=>a.get(t),select:(t,e)=>a.select(t,e)},html:{remove:()=>h.remove(),insert:(t,e)=>h.insert(t,e),insertNode:(t,e)=>h.insertNode(t,e)},history:{push:t=>d.push(!!t)},nodeTransform:{removeAllParents:(t,e,s)=>c.removeAllParents(t,e,s),split:(t,e,s)=>c.split(t,e,s)},char:{check:t=>u.check(t)},menu:{dropdownOff:()=>p.dropdownOff()},setDefaultLine:e=>t._setDefaultLine(e),hideToolbar:()=>t._hideToolbar(),hideToolbar_sub:()=>t._hideToolbar_sub(),styleNodeCache:()=>e.value=t.__cacheStyleNodes,formatAttrsTempCache:e=>t._formatAttrsTemp=e,setOnShortcutKey:e=>t._onShortcutKey=e,caretScrollTo(t){i._iframeAutoHeight(s),o.scrollTo(o.getRange()||t,{behavior:"auto",block:"nearest",inline:"nearest"})},enterPrevent(e){e.preventDefault(),b&&!pr(g)&&(t.__focusTemp.focus({preventScroll:!0}),s.get("wysiwyg").focus({preventScroll:!0}))}}}const fr={value:[]};async function vr(t,e){if(t.get("isReadOnly")||t.get("isDisabled"))return e.preventDefault(),e.stopPropagation(),!1;if(pr(this.$.store)&&("insertParagraph"===e.inputType||"insertLineBreak"===e.inputType))return void await br.call(this,t,e);const s=(null===e.data?"":void 0===e.data?" ":e.data)||"";if(Fe.isComposing(e))this._handledInBefore=!1;else{if(!this.$.char.test(s,!1))return e.preventDefault(),e.stopPropagation(),!1;this._handledInBefore=!0}!1!==await this.$.eventManager.triggerEvent("onBeforeInput",{frameContext:t,event:e,data:s})&&await this._callPluginEventAsync("onBeforeInput",{frameContext:t,event:e,data:s})}async function br(t,e){if(e.isComposing||this.isComposing)return;if(this.$.ui.selectMenuOn)return;let s=this.$.selection.getNode();if(Pe.check.isInputElement(s))return;if(this.$.menu.currentDropdownName)return;Pe.check.isWysiwygFrame(s)&&(this._setDefaultLine(this.$.options.get("defaultLine")),s=this.$.selection.getNode());const i=this._enterKeyShift||"insertLineBreak"===e.inputType;if(this._enterKeyShift=!1,!i){const t=this._normalizeEditRange();t&&(s=t)}const n=this.$.selection.getRange(),o=this.$.format.getLine(s,null)||s,r={e,fc:t,store:this.$.store,options:this.$.options,frameOptions:this.$.frameOptions,range:n,selectionNode:s,formatEl:o,keyCode:"Enter",ctrl:!1,alt:!1,shift:i},l=mr(this,{_styleNodes:fr}),a=[];dr(a,l,r),a.some((t=>"event.prevent"===t.t||"event.prevent.stop"===t.t))&&e.preventDefault(),await yo(a,{ports:l,ctx:r})}async function yr(t,e){if(t.get("isReadOnly")||t.get("isDisabled"))return e.preventDefault(),e.stopPropagation(),!1;const s=this.$.selection.getRange(),i=this.$.selection.getNode(),n=this.$.format.getLine(i,null);if(!this.$.format.isNormalLine(n)&&!this.$.format.isBrLine(n)&&s.collapsed&&!this.$.component.is(i)&&!Pe.check.isList(i)){const t=this.$.format.getBlock(i,null);this._setDefaultLine(this.$.format.isBlock(t)?"DIV":this.$.options.get("defaultLine"))}this.$.selection.init();const o=(null===e.data?"":void 0===e.data?" ":e.data)||"";if(!this._handledInBefore&&!this.$.char.test(o,!0))return e.preventDefault(),e.stopPropagation(),!1;this._handledInBefore=!1,!1!==await this.$.eventManager.triggerEvent("onInput",{frameContext:t,event:e,data:o})&&(await this._callPluginEventAsync("onInput",{frameContext:t,event:e,data:o}),this.$.history.push(!0))}const{_w:wr}=Oe,Cr=new RegExp(Re.zeroWidthSpace+"+",""),_r={ctrl:!1,alt:!1},kr=Object.preventExtensions({value:[]});async function xr(t,e){if(this.isComposing=Fe.isComposing(e))return!0;if(this.$.ui.selectMenuOn||!e.isTrusted)return;let s=this.$.selection.getNode();if(Pe.check.isInputElement(s))return;if(this.$.menu.currentDropdownName)return;const i=e.code,n=Fe.isShift(e),o=_r.ctrl=Fe.isCtrl(e),r=_r.alt=Fe.isAlt(e);if(Fe.isEnter(i)&&(this._enterKeyShift=n),!o&&t.get("isReadOnly")&&!Fe.isDirectionKey(i))return e.preventDefault(),!1;this.$.menu.dropdownOff(),this.$.store.mode.isBalloon?this.$.store.mode.isBalloonAlways||this._hideToolbar():this.$.store.mode.isSubBalloon&&(this.$.store.mode.isSubBalloonAlways||this._hideToolbar_sub());if(Fe.isEnter(i)&&!pr(this.$.store,e)||Fe.isRemoveKey(i)){const t=this._normalizeEditRange();t&&(s=t)}const l=this.$.selection.getRange(),a=this.$.format.getLine(s,null)||s;if(o&&!Fe.isNonTextKey(i)&&this.$.shortcuts.command(e,o,n,i,"",!1,null,null))return this._onShortcutKey=!0,e.preventDefault(),e.stopPropagation(),!1;if(!o&&!Fe.isNonTextKey(i)&&this.$.format.isLine(a)&&l.collapsed&&Pe.check.isEdgePoint(l.startContainer,0,"front")){const t=l.startContainer.substringData?.(0,l.startOffset);if(t&&this.$.shortcuts.command(e,!1,n,i,t,!0,a,l))return this._onShortcutKey=!0,e.preventDefault(),e.stopPropagation(),!1}else this._onShortcutKey&&(this._onShortcutKey=!1);const h={e,fc:t,store:this.$.store,options:this.$.options,frameOptions:this.$.frameOptions,range:l,selectionNode:s,formatEl:a,keyCode:i,ctrl:o,alt:r,shift:n},c=mr(this,{_styleNodes:kr}),d=await gr(c,h);!1!==await this.$.eventManager.triggerEvent("onKeyDown",{frameContext:t,event:e})&&!1!==await this._callPluginEventAsync("onKeyDown",{frameContext:t,event:e,range:l,line:a})&&await yo(d,{ports:c,ctx:h})}async function $r(t,e){if(this._onShortcutKey||this.$.menu.currentDropdownName)return;const s=e.code,i=Fe.isCtrl(e),n=Fe.isAlt(e);if(i&&(_r.ctrl=!1),n&&(_r.alt=!1),t.get("isReadOnly"))return;const o=this.$.selection.getRange();let r=this.$.selection.getNode();if((this.$.store.mode.isBalloon||this.$.store.mode.isSubBalloon)&&((this.$.store.mode.isBalloonAlways||this.$.store.mode.isSubBalloonAlways)&&!Fe.isEsc(s)||!o.collapsed)){if(!this.$.store.mode.isBalloonAlways&&!this.$.store.mode.isSubBalloonAlways)return void(this.$.store.mode.isSubBalloon?this.$.subToolbar._showBalloon():this.$.toolbar._showBalloon());Fe.isEsc(s)||this._showToolbarBalloonDelay()}if(Fe.isBackspace(s)&&Pe.check.isWysiwygFrame(r)&&""===r.textContent&&0===r.children.length){e.preventDefault(),e.stopPropagation(),r.innerHTML="";const i=this.$.store.get("currentNodes")[0],n=Pe.utils.createElement(this.$.format.isLine(i)&&!Pe.check.isListCell(i)?i:this.$.options.get("defaultLine"),null,"<br>");return r.appendChild(n),this.$.selection.setRange(n,0,n,0),this.applyTagEffect(),this.$.history.push(!1),void(t.has("documentType_use_header")&&Fe.isDocumentTypeObserverKey(s)&&t.get("documentType").reHeader())}const l=this.$.format.getLine(r,null),a=this.$.format.getBlock(r,null),h=this._formatAttrsTemp;if(l&&h){for(let t=0,e=h.length;t<e;t++)Fe.isEnter(s)&&/^id$/i.test(h[t].name)?l.removeAttribute("id"):l.setAttribute(h[t].name,h[t].value);this._formatAttrsTemp=null}this.$.format.isNormalLine(l)||this.$.format.isBrLine(l)||!o.collapsed||this.$.component.is(r)||Pe.check.isList(r)||null===this._setDefaultLine(this.$.format.isBlock(a)?"DIV":this.$.options.get("defaultLine"))||(r=this.$.selection.getNode());if(!_r.ctrl&&!_r.alt&&!Fe.isNonTextKey(s)&&3===r.nodeType&&Re.zeroWidthRegExp.test(r.textContent)&&!(void 0!==e.isComposing?e.isComposing:this.isComposing)){let t=o.startOffset,e=o.endOffset;const s=(r.textContent.substring(0,e).match(Cr)||"").length;t=o.startOffset-s,e=o.endOffset-s,r.textContent=r.textContent.replace(Re.zeroWidthRegExp,""),this.$.selection.setRange(r,t<0?0:t,r,e<0?0:e)}if(Fe.isRemoveKey(s)&&Pe.check.isZeroWidth(l?.textContent)&&!l.previousElementSibling&&!Pe.check.isListCell(l)){const t=this.$.options.get("retainStyleMode");"none"!==t&&kr.value?.length>0?"repeat"===t?this.__retainTimer?(this.__retainTimer=wr.clearTimeout(this.__retainTimer),this._clearRetainStyleNodes(l)):(this.__retainTimer=wr.setTimeout((()=>{this.__retainTimer=null}),0),this._retainStyleNodes(l,kr.value)):(this.__retainTimer=null,this._retainStyleNodes(l,kr.value)):this._clearRetainStyleNodes(l)}if(t.has("documentType_use_header"))if(Fe.isDocumentTypeObserverKey(s)){t.get("documentType").reHeader();const e=Pe.query.getParentElement(this.$.selection.selectionNode,this.$.format.isLine.bind(this.$.format));t.get("documentType").on(e)}else{const e=Pe.query.getParentElement(r,(t=>1===t.nodeType));t.get("documentType").onChangeText(e)}!1!==await this.$.eventManager.triggerEvent("onKeyUp",{frameContext:t,event:e})&&!1!==await this._callPluginEventAsync("onKeyUp",{frameContext:t,event:e,range:o,line:l})&&Fe.isHistoryRelevantKey(s)&&this.$.history.push(!0)}const{_w:Sr}=Oe;function Er(t,e){const s=e.clipboardData;return!s||this._dataTransferAction("paste",e,s,t)}async function Tr(t,e){const s=e.clipboardData;if(!1===await this.$.eventManager.triggerEvent("onCopy",{frameContext:t,event:e,clipboardData:s}))return e.preventDefault(),e.stopPropagation(),!1;const i=t.get("_ww").getSelection();this.__secopy=i.toString()}async function Mr(t,e){const s=e.clipboardData;if(!1===await this.$.eventManager.triggerEvent("onCut",{frameContext:t,event:e,clipboardData:s}))return e.preventDefault(),e.stopPropagation(),!1;const i=t.get("_ww").getSelection();this.__secopy=i.toString(),Sr.setTimeout((()=>{this.$.history.push(!1)}),0)}const{_w:Nr}=Oe;function Br(t,e,s,i,n){if(n.dataTransfer&&Array.from(n.dataTransfer.types||[]).includes("application/x-suneditor-block-drag"))return;const{sc:o,so:r,ec:l,eo:a}=this.$.selection.getDragEventLocationRange(n);if(!o)return;n.preventDefault();const h=t.get("_wd").createRange();h.setStart(o,r),h.setEnd(l,a);const c={y:0,x:0};if(s){const t=this.$.offset.getGlobal(s),e=i?this.$.context.get("toolbar_main").offsetHeight:0;c.y=t.top+e-Nr.scrollY,c.x=t.left-Nr.scrollX}const d=h.getBoundingClientRect();if(d.height>0){const s=t.get("wysiwygFrame");let i=0,n=0;/^iframe$/i.test(s.nodeName)&&(i=s.offsetLeft,n=s.offsetTop),e.style.left=`${d.right+Nr.scrollX+c.x+i}px`,e.style.top=`${d.top+Nr.scrollY+c.y-5+n}px`,e.style.height=`${d.height+10}px`,e.style.display="block";try{e.showPopover?.()}catch{}}else{try{e.hidePopover?.()}catch{}e.style.display="none"}}function Ir(t){try{t.hidePopover?.()}catch{}t.style.display="none"}function Lr(t,e,s){try{if(t.get("isReadOnly"))return s.preventDefault(),s.stopPropagation(),!1;const e=s.dataTransfer;if(!e)return!0;if(Array.from(e.types||[]).includes("application/x-suneditor-block-drag"))return;const{sc:i,so:n,ec:o,eo:r}=this.$.selection.getDragEventLocationRange(s);if(!i)return;if(Pe.query.getParentElement(i,".se-disable-pointer"))return void s.preventDefault();if(_i.get("__dragContainer")){if(s.preventDefault(),_i.get("__dragContainer").contains(s.target))return void this.$.component.deselect();const e=_i.get("__dragContainer");return this.$.component.deselect(),this.$.selection.setRange(i,n,o,r),this.$.html.insertNode(e,{afterNode:null,skipCharCount:!0}),void(t.has("documentType_use_page")&&(t.get("documentTypePageMirror").innerHTML=t.get("wysiwyg").innerHTML,t.get("documentType").rePage(!0)))}return this.$.html.remove(),this.$.selection.setRange(i,n,o,r),this._dataTransferAction("drop",s,e,t)}finally{try{e.hidePopover?.()}catch{}e.style.display="none"}}class Ar{#J;constructor({$:t}){this.#J=t}execute(t){if(!this.#J.options.get("__lineFormatFilter"))return null;if(this.#J.pluginManager.fileInfo.pluginRegExp.test(this.#J.ui.currentControllerName))return;const e=this.#J.selection.getRange(),s=e.commonAncestorContainer,i=e.startContainer,n=e.endOffset,o=this.#J.format.getBlock(s,null);let r,l,a;if(o)return a=Pe.utils.createElement(t||this.#J.options.get("defaultLine")),a.innerHTML=o.innerHTML,0===a.childNodes.length&&(a.innerHTML=Re.zeroWidthSpace),o.innerHTML=a.outerHTML,a=o.firstChild,r=a.childNodes[n]||Pe.query.getEdgeChildNodes(a,null).sc,r||(r=Pe.utils.createTextNode(Re.zeroWidthSpace),a.insertBefore(r,a.firstChild)),l=r.textContent.length,void this.#J.selection.setRange(r,l,r,l);if(3===s.nodeType&&this.#J.component.is(s.parentElement)){const t=this.#J.component.get(s.parentElement);if(!t)return;const e=t.container;if(s.parentElement===e){const t=s.nextElementSibling?e:e.nextElementSibling,i=Pe.utils.createElement(this.#J.options.get("defaultLine"),null,s);return e.parentElement.insertBefore(i,t),void this.#J.focusManager.focusEdge(i)}return this.#J.component.select(t.target,t.pluginName),null}if(1===s.nodeType&&"true"===s.getAttribute("data-se-embed")){let t=s.nextElementSibling;return this.#J.format.isLine(t)||(t=this.#J.format.addLine(s,this.#J.options.get("defaultLine"))),void this.#J.selection.setRange(t.firstChild,0,t.firstChild,0)}if(!this.#J.format.isBlock(i)&&!Pe.check.isWysiwygFrame(i)||!this.#J.component.is(i.children[e.startOffset])&&!this.#J.component.is(i.children[e.startOffset-1])){if(Pe.query.getParentElement(s,Pe.check.isExcludeFormat))return null;if(this.#J.format.isBlock(s)&&s.childNodes.length<=1){let t=null;return 1===s.childNodes.length&&Pe.check.isBreak(s.firstChild)?t=s.firstChild:(t=Pe.utils.createTextNode(Re.zeroWidthSpace),s.appendChild(t)),void this.#J.selection.setRange(t,1,t,1)}try{if(3===s.nodeType&&(a=Pe.utils.createElement(t||this.#J.options.get("defaultLine")),s.parentNode.insertBefore(a,s),a.appendChild(s)),Pe.check.isBreak(a.nextSibling)&&Pe.utils.removeItem(a.nextSibling),Pe.check.isBreak(a.previousSibling)&&Pe.utils.removeItem(a.previousSibling),Pe.check.isBreak(r)){const t=Pe.utils.createTextNode(Re.zeroWidthSpace);r.parentNode.insertBefore(t,r),r=t}}catch{return this.#J.frameContext.get("_wd").execCommand("formatBlock",!1,`<${t||this.#J.options.get("defaultLine")}>`),this.#J.store.set("_lastSelectionNode",null),void this.#J.selection.init()}if(a&&(Pe.check.isBreak(a.nextSibling)&&Pe.utils.removeItem(a.nextSibling),Pe.check.isBreak(a.previousSibling)&&Pe.utils.removeItem(a.previousSibling),Pe.check.isBreak(r))){const t=Pe.utils.createTextNode(Re.zeroWidthSpace);r.parentNode.insertBefore(t,r),r=t}this.#J.store.set("_lastSelectionNode",null),i?this.#J.selection.setRange(i,1,i,1):this.#J.focusManager.nativeFocus()}}}class Or{#Ql;#J;#ta;constructor(t){this.#Ql=t,this.#J=t.$,this.#ta=new RegExp(`^(${Object.keys(this.#J.options.get("_defaultStyleTagMap")).join("|")})$`,"i")}update(t){if(t||=this.#J.selection.getNode(),t===this.#J.store.get("_lastSelectionNode"))return;this.#J.store.set("_lastSelectionNode",t);const e=this.#J.options.get("_rtl")?"marginRight":"marginLeft",s=this.#J.plugins,i=this.#J.commandDispatcher.targets,n=this.#ta,o=this.#J.options.get("_styleCommandMap"),r=[],l=[],a=this.#J.options.get("_textStyleTags"),h=[],c=[],d=this.#J.commandDispatcher.activeCommands,u=d.length;let p="";if(this.#J.component.is(t)&&!this.#J.component.__selectionSelected){const e=this.#J.component.get(t);if(!e)return;return this.#J.store.set("_lastSelectionNode",null),void this.#J.component.select(e.target,e.pluginName)}for(;t.firstChild;)t=t.firstChild;const g=this.#J.frameContext,m=!g.get("isReadOnly");for(let g=t;!Pe.check.isWysiwygFrame(g)&&g;g=g.parentElement)if(1===g.nodeType&&!Pe.check.isBreak(g)){if(this.#ea(g))return void this.#J.focusManager.blur();if(p=g.nodeName.toLowerCase(),l.push(p),a.includes(p)&&!this.#J.format.isLine(p)&&h.push(g),m)for(let t,e=0;e<u;e++)t=d[e],!r.includes(t)&&!c.includes(t)&&i.get(t)&&i.get(t).filter((e=>{const i=s[t]?.active(g,e);return void 0===i&&c.push(t),i})).length>0&&r.push(t);if(this.#J.format.isLine(g)){if(!r.includes("outdent")&&i.has("outdent")&&(Pe.check.isListCell(g)||g.style[e]&&De.get(g.style[e],0)>0)&&i.get("outdent").filter((t=>!Pe.check.isImportantDisabled(t)&&(t.disabled=!1,!0))).length>0&&r.push("outdent"),!r.includes("indent")&&i.has("indent")){const t=Pe.check.isListCell(g)&&!g.previousElementSibling;i.get("indent").filter((e=>!Pe.check.isImportantDisabled(e)&&(e.disabled=t,!0))).length>0&&r.push("indent")}}else n.test(p)&&(p=o[p]||p,r.push(p),Pe.utils.addClass(i.get(p),"active"))}return this.#sa(r),this.#Ql.__cacheStyleNodes=h.reverse(),this.#J.store.set("currentNodes",l.reverse()),this.#J.store.set("currentNodesMap",r),this.#J.frameOptions.get("statusbar_showPathLabel")&&g.get("navigation")&&(g.get("navigation").textContent=this.#J.options.get("_rtl")?this.#J.store.get("currentNodes").reverse().join(" < "):this.#J.store.get("currentNodes").join(" > ")),t}reset(){this.#sa([])}#sa(t){const e=this.#J.commandDispatcher.activeCommands,s=this.#J.commandDispatcher.targets,i=this.#J.plugins;for(let n,o,r,l=0,a=e.length;l<a;l++)if(n=e[l],!t.includes(n)&&(o=s.get(n))){r=i[n];for(let t,e=0,s=o.length;e<s;e++)t=o[e],t&&(r?r.active(null,t):/^outdent$/i.test(n)?Pe.check.isImportantDisabled(t)||(t.disabled=!0):/^indent$/i.test(n)?Pe.check.isImportantDisabled(t)||(t.disabled=!1):Pe.utils.removeClass(t,"active"))}}#ea(t){return Pe.check.isElement(t)&&"true"===t.getAttribute("data-se-non-focus")}}const{_w:Rr,isMobile:zr,isTouchDevice:Pr}=Oe;function Dr(t){if("Tab"!==t.key)return;t.preventDefault();const e=t.target,s=e.selectionStart,i=e.selectionEnd;e.value=e.value.substring(0,s)+"\t"+e.value.substring(i),e.selectionStart=e.selectionEnd=s+1}const Fr=class extends Vn{#t;#Ci;#e;#rt;#_i;#o;#ia;#na;#oa=null;#ra=null;#la=null;#aa=null;constructor(t){super(t),this.#t=this.$.store,this.#Ci=this.$.contextProvider,this.#e=this.$.context,this.#rt=this.$.options,this.#_i=this.$.eventManager,this.#o=this.$.toolbar,this.#ia=this.$.ui,this.#na=this.$.menu,this.isComposing=!1,this._enterKeyShift=!1,this.scrollparents=[],this.defaultLineManager=new Ar(this),this.selectionState=new Or(this),this._onShortcutKey=!1,this._handledInBefore=!1,this._wwFrameObserver=null,this._toolbarObserver=null,this._lineBreakComp=null,this._formatAttrsTemp=null,this._resizeClientY=0,this.__cacheStyleNodes=[],this.__onDownEv=null,this._inputFocus=!1,this.__inputPlugin=null,this.__inputBlurEvent=null,this.__inputKeyEvent=null,this.__retainTimer=null,this.__eventDoc=null,this.__secopy=null,this.__focusTemp=this.#Ci.carrierWrapper.querySelector(".__se__focus__temp__")}applyTagEffect(t){return this.selectionState.update(t)}_showToolbarBalloonDelay(){this.#oa&&Rr.clearTimeout(this.#oa),this.#oa=Rr.setTimeout((()=>{Rr.clearTimeout(this.#oa),this.#oa=null,this.#t.mode.isSubBalloon?this.$.subToolbar._showBalloon():this.#o._showBalloon()}),250)}#ha(){this.#oa&&Rr.clearTimeout(this.#oa),this.#oa=Rr.setTimeout((()=>{Rr.clearTimeout(this.#oa),this.#oa=null,this._toggleToolbarBalloon()}),250)}_toggleToolbarBalloon(){this.$.selection.init();const t=this.$.selection.getRange(),e=this.#rt.has("_subMode");!(e?this.#t.mode.isSubBalloonAlways:this.#t.mode.isBalloonAlways)&&t.collapsed?e?this._hideToolbar_sub():this._hideToolbar():e?this.$.subToolbar._showBalloon(t):this.#o._showBalloon(t)}_hideToolbar(){this.#ia.isPreventToolbarHide||this.$.frameContext.get("isFullScreen")||this.#o.hide()}_hideToolbar_sub(){this.$.subToolbar&&!this.#ia.isPreventToolbarHide&&this.$.subToolbar.hide()}_setDefaultLine(t){return this.defaultLineManager.execute(t)}_normalizeEditRange(){if(!this.$.format.isLine(this.$.selection.getRange()?.startContainer))return null;this.$.selection.resetRangeToTextNode();const t=this.$.selection.getRange();if(t.startContainer===t.endContainer&&t.startOffset!==t.endOffset&&3===t.startContainer.nodeType&&Pe.check.isZeroWidth(t.startContainer)){const e=t.startContainer,s=e.nextSibling;s&&Pe.check.isBreak(s)?(Pe.utils.removeItem(e),this.$.selection.setRange(s,0,s,0)):this.$.selection.setRange(t.endContainer,t.endOffset,t.endContainer,t.endOffset)}return this.$.selection.getNode()}async _dataTransferAction(t,e,s,i){try{return this.#ia.showLoading(),await this.#ca(t,e,s,i),e.preventDefault(),e.stopPropagation(),!1}catch(t){console.warn("[SUNEDITOR.paste.error]",t)}finally{this.#ia.hideLoading()}}async#ca(t,e,s,i){e.preventDefault(),e.stopPropagation();let n=s.getData("text/plain"),o=s.getData("text/html");const r=!o,l=this.__secopy===n,a=/class=["']*Mso(Normal|List)/i.test(o)||/content=["']*Word.Document/i.test(o)||/content=["']*OneNote.File/i.test(o)||/content=["']*Excel.Sheet/i.test(o),h=!l&&!a&&Ue.isGoogleDocs(o),c=l?"SE":a?"MS":h?"GOOGLE":"";if(r?o=ze.htmlToEntity(n).replace(/\n/g,"<br>"):(o=o.replace(/^<html>\r?\n?<body>\r?\n?\x3C!--StartFragment-->|\x3C!--EndFragment-->\r?\n?<\/body>\r?\n?<\/html>$/g,""),a?(o=o.replace(/\n/g," "),n=n.replace(/\n/g," "),o=We.cleanHTML(o)):h&&(o=Ue.cleanHTML(o))),!l){if(this.#rt.get("autoLinkify")){const t=(new DOMParser).parseFromString(o,"text/html");Pe.query.getListChildNodes(t.body,ze.textToAnchor,null),o=t.body.innerHTML}}r||(o=this.$.html.clean(o,{forceFormat:!1,whitelist:null,blacklist:null}));const d=this.$.char.test("byte-html"===this.$.frameOptions.get("charCounter_type")?o:n,!1);if("paste"===t){const t=await this.#_i.triggerEvent("onPaste",{frameContext:i,event:e,data:o,maxCharCount:d,from:c});if(!1===t)return!1;if("string"==typeof t){if(!t)return!1;o=t}}if("drop"===t){const t=await this.#_i.triggerEvent("onDrop",{frameContext:i,event:e,data:o,maxCharCount:d,from:c});if(!1===t)return!1;if("string"==typeof t){if(!t)return!1;o=t}}const u=s.files;if(u.length>0&&!a){for(let t=0,s=u.length;t<s;t++)await this._callPluginEventAsync("onFilePasteAndDrop",{frameContext:i,event:e,file:u[t]});return!1}if(!d)return!1;if(o){const t=(new DOMParser).parseFromString(o,"text/html");return!1!==await this._callPluginEventAsync("onPaste",{frameContext:i,event:e,data:o,doc:t})&&this.$.html.insert(o,{selectInserted:!1,skipCharCount:!0,skipCleaning:!0}),i.has("documentType_use_header")&&i.get("documentType").reHeader(),!1}}_addCommonEvents(){const t=Kn.bind(this),e=Xn.bind(this);this.#_i.addEvent(this.#e.get("menuTray"),"mousedown",t,!1),this.#_i.addEvent(this.#e.get("menuTray"),"click",Yn.bind(this),!0),this.#_i.addEvent(this.#e.get("toolbar_main"),"mousedown",t,!1),this.#_i.addEvent(this.#e.get("toolbar_main"),"click",e,!1),this.#rt.has("_subMode")&&(this.#_i.addEvent(this.#e.get("toolbar_sub_main"),"mousedown",t,!1),this.#_i.addEvent(this.#e.get("toolbar_sub_main"),"click",e,!1)),this.#o._setResponsive(),Oe.isResizeObserverSupported&&(this._toolbarObserver=new ResizeObserver((()=>{Rr.setTimeout((()=>{this.#o.resetResponsiveToolbar()}),0)})),this._wwFrameObserver=new ResizeObserver((t=>{Rr.setTimeout((()=>{t.forEach((t=>{this.#ia._emitResizeEvent(this.$.frameRoots.get(t.target.getAttribute("data-root-key")),-1,t)})),this.#t.mode.isInline&&this.#t.mode.isBottom&&this.#o._resetSticky()}),0)}))),this.#rt.get("closeModalOutsideClick")&&this.#_i.addEvent(this.#Ci.carrierWrapper.querySelector(".se-modal .se-modal-inner"),"click",(t=>{t.target===this.#Ci.carrierWrapper.querySelector(".se-modal .se-modal-inner")&&this.#ia.offCurrentModal()}),!1),this.#_i.addEvent(Rr,"resize",this.#da.bind(this),!1),this.#_i.addEvent(Rr.visualViewport,"resize",this.#ua.bind(this),!1),this.#_i.addEvent(Rr,"scroll",this.#pa.bind(this),!1),Pr&&this.#_i.addEvent(Rr.visualViewport,"scroll",this.#ga.bind(this),!1)}_addFrameEvents(t){const e=t.get("options").get("iframe"),s=e?t.get("_ww"):t.get("wysiwyg");t.set("eventWysiwyg",s);const i=t.get("code"),n=this.#Ci.carrierWrapper.querySelector(".se-drag-cursor"),o=io.bind(this,t);this.#_i.addEvent(s,"mousemove",o,!1),this.#_i.addEvent(s,"mouseleave",no.bind(this,t),!1),this.#_i.addEvent(s,"mousedown",Qn.bind(this,t),!1),this.#_i.addEvent(s,"mouseup",eo.bind(this,t),!1),this.#_i.addEvent(s,"click",so.bind(this,t),!1),this.#_i.addEvent(s,"beforeinput",vr.bind(this,t),!1),this.#_i.addEvent(s,"input",yr.bind(this,t),!1),this.#_i.addEvent(s,"keydown",xr.bind(this,t),!1),this.#_i.addEvent(s,"keyup",$r.bind(this,t),!1),this.#_i.addEvent(s,"paste",Er.bind(this,t),!1),this.#_i.addEvent(s,"copy",Tr.bind(this,t),!1),this.#_i.addEvent(s,"cut",Mr.bind(this,t),!1),this.#_i.addEvent(s,"dragover",Br.bind(this,t,n,e?this.$.frameContext.get("topArea"):null,!this.#rt.get("toolbar_container")&&!this.#t.mode.isBalloon&&!this.#t.mode.isInline),!1),this.#_i.addEvent(s,"dragend",Ir.bind(this,n),!1),this.#_i.addEvent(s,"drop",Lr.bind(this,t,n),!1),this.#_i.addEvent(s,"scroll",this.#ma.bind(this,t,s),{passive:!0,capture:!1}),this.#_i.addEvent(s,"focus",this.#fa.bind(this,t),!1),this.#_i.addEvent(s,"blur",this.#va.bind(this,t),!1),this.#_i.addEvent(i,"mousedown",this.#ba.bind(this,t),!1);const r=t.get("wrapper").querySelector(".se-drag-handle");if(this.#_i.addEvent(r,"wheel",(t=>{t.preventDefault(),this.$.component.deselect()}),!1),this.#_i.addEvent(t.get("lineBreaker_t"),"pointerdown",this.#ya.bind(this,"t"),!1),this.#_i.addEvent(t.get("lineBreaker_b"),"pointerdown",this.#ya.bind(this,"b"),!1),Pr&&this.#_i.addEvent(s,"touchstart",o,{passive:!0,capture:!1}),!this.#rt.get("hasCodeMirror")){const e=t.get("codeNumbers"),s=this.$.viewer._codeViewAutoHeight.bind(this.$.viewer,t.get("code"),e,"auto"===this.$.frameOptions.get("height"));this.#_i.addEvent(i,"keydown",s,!1),this.#_i.addEvent(i,"keyup",s,!1),this.#_i.addEvent(i,"paste",s,!1),this.#rt.get("tabDisable")||this.#_i.addEvent(i,"keydown",Dr,!1),e&&this.#_i.addEvent(i,"scroll",this.$.viewer._scrollLineNumbers.bind(i,e),!1)}const l=t.get("markdown");if(l){this.#_i.addEvent(l,"mousedown",this.#wa.bind(this,t),!1);const e=t.get("markdownNumbers"),s=this.$.viewer._markdownViewAutoHeight.bind(this.$.viewer,l,e,"auto"===this.$.frameOptions.get("height"));this.#_i.addEvent(l,"keydown",s,!1),this.#_i.addEvent(l,"keyup",s,!1),this.#_i.addEvent(l,"paste",s,!1),this.#rt.get("tabDisable")||this.#_i.addEvent(l,"keydown",Dr,!1),e&&this.#_i.addEvent(l,"scroll",this.$.viewer._scrollMarkdownLineNumbers.bind(l,e),!1)}t.has("statusbar")&&this.__addStatusbarEvent(t,t.get("options"));const a=this.#Ca.bind(this),h=Pe.query.getScrollParents(t.get("originElement"));for(const t of h)this.scrollparents.push(t),this.#_i.addEvent(t,"scroll",a,!1);this.#_i.addEvent(this.__focusTemp,"focus",(t=>t.preventDefault()),!1),this.__eventDoc!==t.get("_wd")&&(this.__eventDoc=t.get("_wd"),this.#_i.addEvent(this.__eventDoc,"selectionchange",this.#_a.bind(this,this.__eventDoc),!1))}__addStatusbarEvent(t,e){/\d+/.test(e.get("height"))&&e.get("statusbar_resizeEnable")?e.set("__statusbarEvent",this.#_i.addEvent(t.get("statusbar"),"mousedown",this.#ka.bind(this),!1)):Pe.utils.addClass(t.get("statusbar"),"se-resizing-none")}_removeAllEvents(){this.#_i._init(),this._wwFrameObserver&&(this._wwFrameObserver.disconnect(),this._wwFrameObserver=null),this._toolbarObserver&&(this._toolbarObserver.disconnect(),this._toolbarObserver=null),this.#oa&&(Rr.clearTimeout(this.#oa),this.#oa=null),this.__retainTimer&&(Rr.clearTimeout(this.__retainTimer),this.__retainTimer=null),this.#la&&=this.#_i.removeGlobalEvent(this.#la),this.#aa&&=this.#_i.removeGlobalEvent(this.#aa),this.#ra&&=this.#_i.removeGlobalEvent(this.#ra),this._formatAttrsTemp=null,this.__cacheStyleNodes=null,this.__inputPlugin=null,this.__inputBlurEvent=null,this.__inputKeyEvent=null,this.__focusTemp=null,this.__eventDoc=null,this.__secopy=null,this._lineBreakComp=null,this.scrollparents=null}_setSelectionSync(){this.#_i.removeGlobalEvent(this.#la),this.#la=this.#_i.addGlobalEvent("mouseup",(()=>{this.$.selection.init(),this.#_i.removeGlobalEvent(this.#la)}))}_retainStyleNodes(t,e){let s=e[0].cloneNode(!1);for(let t,i=1,n=e.length;i<n;i++)t=e[i].cloneNode(!1),s.appendChild(t),s=t;const{parent:i,inner:n}=this.$.nodeTransform.createNestedNode(e,null),o=Pe.utils.createTextNode(Re.zeroWidthSpace);n.appendChild(o),t.innerHTML="",t.appendChild(i),this.$.selection.setRange(o,1,o,1)}_clearRetainStyleNodes(t){t.innerHTML="<br>",this.$.selection.setRange(t,0,t,0)}_callPluginEvent(t,e){return this.$.pluginManager.emitEvent(t,e)}async _callPluginEventAsync(t,e){return await this.$.pluginManager.emitEventAsync(t,e)}__removeInput(){this.#t.set("_preventBlur",!1),this._inputFocus=!1,this.__inputBlurEvent=this.#_i.removeEvent(this.__inputBlurEvent),this.__inputKeyEvent=this.#_i.removeEvent(this.__inputKeyEvent),this.__inputPlugin=null}__postFocusEvent(t,e){(this.#t.mode.isInline||this.#t.mode.isBalloonAlways)&&this.#o.show(),this.#t.mode.isSubBalloonAlways&&this.$.subToolbar.show(),this.#o._resetSticky(),this.#ia._updatePlaceholder(t),this.#_i.triggerEvent("onFocus",{frameContext:t,event:e}),this._callPluginEvent("onFocus",{frameContext:t,event:e})}__postBlurEvent(t,e){this.#t.mode.isInline?Rr.setTimeout((()=>{this.#t.get("hasFocus")||this._hideToolbar()}),0):this.#t.mode.isBalloon&&this._hideToolbar(),this.#t.mode.isSubBalloon&&this._hideToolbar_sub(),this.#_i.triggerEvent("onBlur",{frameContext:t,event:e}),this._callPluginEvent("onBlur",{frameContext:t,event:e})}__setViewportSize(){this.#t.set("currentViewportHeight",De.get(Rr.visualViewport.height,0))}#xa(){this.#na.currentDropdownActiveButton&&this.#na.currentDropdown&&this.#na.__resetMenuPosition(this.#na.currentDropdownActiveButton,this.#na.currentDropdown),this.#ia._repositionControllers()}#$a(){Oe.isResizeObserverSupported||(this.#o.resetResponsiveToolbar(),this.#rt.get("_subMode")&&this.$.subToolbar.resetResponsiveToolbar());const t=this.#e.get("toolbar_main"),e="none"===t.style.display||this.#t.mode.isInline&&!this.#o.inlineToolbarAttr.isShow;if(0===t.offsetWidth&&!e)return;const s=this.#ia.opendBrowser;if(s&&"block"===s.area.style.display&&(s.body.style.maxHeight=Pe.utils.getClientSize().h-s.header.offsetHeight-50+"px"),this.#na.currentDropdownActiveButton&&this.#na.currentDropdown&&this.#na.__resetMenuPosition(this.#na.currentDropdownActiveButton,this.#na.currentDropdown),this.$.viewer._resetFullScreenHeight())return;const i=this.$.frameContext;i.get("isCodeView")&&this.#t.mode.isInline?this.#o._showInline():(this.#ia._iframeAutoHeight(i),this.#o.isSticky&&(this.#o.isCSSSticky||(this.#e.get("toolbar_main").style.width=i.get("topArea").offsetWidth-2+"px"),this.#o._resetSticky()))}#ma(t,e,s){this.#ia._syncScrollPosition(e),this.#xa(),this._callPluginEvent("onScroll",{frameContext:t,event:s}),t.has("documentType_use_page")&&t.get("documentType").scrollPage(),this.#_i.triggerEvent("onScroll",{frameContext:t,event:s})}#fa(t,e){if(this.$.selection.__iframeFocus||t.get("isReadOnly")||t.get("isDisabled"))return e.preventDefault(),!1;this.#t.set("hasFocus",!0),this.$.component.__prevent=!1,this.#_i.triggerEvent("onNativeFocus",{frameContext:t,event:e});const s=t.get("key");this._inputFocus?this.#t.mode.isInline&&Rr.setTimeout((()=>{this.#o._showInline()}),0):this.#t.get("rootKey")===s&&this.#t.get("_preventBlur")||this.#t.get("_preventFocus")||(this.#t.set("_preventFocus",!0),Pe.utils.removeClass(this.$.commandDispatcher.targets.get("codeView"),"active"),this.#ia._toggleCodeViewButtons(!1),this.$.facade.changeFrameContext(s),this.$.history.resetButtons(s,null),Rr.setTimeout((()=>{this.__postFocusEvent(t,e)}),0))}#va(t,e){t.get("isCodeView")||t.get("isReadOnly")||t.get("isDisabled")||(this.#t.set("hasFocus",!1),this.#t.set("_lastSelectionNode",null),this.#_i.triggerEvent("onNativeBlur",{frameContext:t,event:e}),this.#ia._updatePlaceholder(t),this._inputFocus||this.#t.get("_preventBlur")||(this.#t.set("_preventFocus",!1),this.selectionState.reset(),this.#t.set("currentNodes",[]),this.#t.set("currentNodesMap",[]),this.#ia.offCurrentController(),this.#Ci.applyToRoots((t=>{t.get("navigation")&&(t.get("navigation").textContent="")})),this.$.history.check(t.get("key"),this.#t.get("_range")),this.__postBlurEvent(t,e)))}#ka(t){t.stopPropagation(),this._resizeClientY=t.clientY,this.#ia.enableBackWrapper("ns-resize"),this.#aa=this.#_i.addGlobalEvent("mousemove",this.#Sa.bind(this)),this.#ra=this.#_i.addGlobalEvent("mouseup",this.#Ea.bind(this))}#Sa(t){const e=this.$.frameContext,s=e.get("wrapper").offsetHeight+(t.clientY-this._resizeClientY),i=s<e.get("_minHeight")?e.get("_minHeight"):s;e.get("wysiwygFrame").style.height=e.get("code").style.height=i+"px",this._resizeClientY=t.clientY,Oe.isResizeObserverSupported||this.#ia._emitResizeEvent(e,i,null)}#Ea(){this.#ia.disableBackWrapper(),this.#aa&&=this.#_i.removeGlobalEvent(this.#aa),this.#ra&&=this.#_i.removeGlobalEvent(this.#ra)}#ya(t,e){e.preventDefault();const s=this._lineBreakComp;if(!s)return;const i=Pe.check.isListCell(s.parentElement),n=Pe.utils.createElement(i?"BR":Pe.check.isTableCell(s.parentElement)?"DIV":this.#rt.get("defaultLine"));if(i||(n.innerHTML="<br>"),"byte-html"!==this.$.frameOptions.get("charCounter_type")||this.$.char.check(n.outerHTML)){s.parentNode.insertBefore(n,"t"===t?s:s.nextSibling),this.$.component.deselect();try{const t=i?n:n.firstChild;this.$.selection.setRange(t,1,t,1),this.$.history.push(!1)}catch(t){console.warn("[SUNEDITOR.lineBreaker.error]",t)}}}#da(){this.#t.set("initViewportHeight",Rr.visualViewport.height),zr||this.#ia.offCurrentController(),this.#t.mode.isBalloon?this.#o.hide():this.#t.mode.isSubBalloon&&this.$.subToolbar.hide(),this.#$a()}#ua(){zr&&this.#rt.get("_toolbar_sticky")>-1&&(this.#o._resetSticky(),this.#na.__restoreMenuPosition()),this.#xa();const t=this.#t.get("currentViewportHeight");this.__setViewportSize(),zr&&t>0&&t-Rr.visualViewport.height>100&&this.#t.get("hasFocus")&&this.$.selection.scrollTo(this.$.selection.getRange(),{behavior:"auto",block:"nearest",inline:"nearest"})}#pa(){this.#rt.get("_toolbar_sticky")>-1&&this.#o._resetSticky(),this.#t.mode.isBalloon&&"block"===this.#e.get("toolbar_main").style.display?this.#o._setBalloonOffset("top"===this.#o.balloonOffset.position):this.#t.mode.isSubBalloon&&"block"===this.#e.get("toolbar_sub_main").style.display&&this.$.subToolbar._setBalloonOffset("top"===this.$.subToolbar.balloonOffset.position),this.#xa(),this.$.frameContext.has("documentType_use_page")&&this.$.frameContext.get("documentType").scrollWindow()}#ga(){this.#rt.get("_toolbar_sticky")>-1&&(this.#o._resetSticky(),this.#na.__restoreMenuPosition())}#_a(t){let e=t.getSelection().anchorNode;this.#Ci.applyToRoots((t=>{if(e&&t.get("wysiwyg").contains(e)){if(t.get("isReadOnly")||t.get("isDisabled"))return;if(e=null,this.$.selection.init(),this.applyTagEffect(),this.#ia._updatePlaceholder(t),Pr&&(this.#t.mode.isBalloon||this.#t.mode.isSubBalloon)&&this.#ha(),t.has("documentType_use_header")){const e=Pe.query.getParentElement(this.$.selection.selectionNode,this.$.format.isLine.bind(this.$.format));t.get("documentType").on(e)}}}))}#Ca(){this.#na.dropdownOff(),this.#xa()}#ba(t){this.$.facade.changeFrameContext(t.get("key")),Pe.utils.addClass(this.$.commandDispatcher.targets.get("codeView"),"active"),this.#ia._toggleCodeViewButtons(!0)}#wa(t){this.$.facade.changeFrameContext(t.get("key")),Pe.utils.addClass(this.$.commandDispatcher.targets.get("markdownView"),"active"),this.#ia._toggleCodeViewButtons(!0)}};const Hr=class{#Ta=new Map;#Ma=new Map;$=null;constructor(t,e){const{product:s,options:i}=e;this.store=new _s(s),this.$={facade:t,store:this.store},this.#Na(s,i),this.#Ba(),this.#Ia(s),this.#La(),this.#Aa(),this._eventOrchestrator=new Fr(this),this.#Ta.get("eventManager")._bindOrchestrator(this._eventOrchestrator)}#Na(t,e){const s=new $s(t),i=new Ss(this,t,e);this.#Ta.set("contextProvider",s),this.#Ta.set("optionProvider",i),this.#Ta.set("instanceCheck",new Es(s.frameContext)),this.#Ta.set("eventManager",new Bs(s,i,this.$))}#Ba(){const t=this.#Ta.get("contextProvider"),e=this.#Ta.get("optionProvider");Object.assign(this.$,{contextProvider:t,optionProvider:e,instanceCheck:this.#Ta.get("instanceCheck"),eventManager:this.#Ta.get("eventManager"),frameRoots:t.frameRoots,context:t.context,options:e.options,icons:t.icons,lang:t.lang,frameContext:t.frameContext,frameOptions:e.frameOptions})}#Ia(t){this.#Ma.set("offset",new Is(this)),this.#Ma.set("selection",new As(this)),this.#Ma.set("html",new fi(this)),this.#Ma.set("nodeTransform",new vi(this)),this.#Ma.set("format",new Rs(this)),this.#Ma.set("inline",new Ps(this)),this.#Ma.set("listFormat",new Fs(this)),this.#Ma.set("char",new yi(this)),this.#Ma.set("shortcuts",new wi(this)),this.#Ma.set("component",new tn(this)),this.#Ma.set("pluginManager",new en(this,t)),this.#Ma.set("focusManager",new sn(this)),this.#Ma.set("ui",new Mn(this)),this.#Ma.set("commandDispatcher",new $n(this)),this.#Ma.set("toolbar",new In(this,{keyName:"toolbar",balloon:this.store.mode.isBalloon,balloonAlways:this.store.mode.isBalloonAlways,inline:this.store.mode.isInline,res:t.responsiveButtons})),this.$.options.has("_subMode")&&this.#Ma.set("subToolbar",new In(this,{keyName:"toolbar_sub",balloon:this.store.mode.isSubBalloon,balloonAlways:this.store.mode.isSubBalloonAlways,inline:!1,res:t.responsiveButtons_sub})),this.#Ma.set("menu",new Rn(this)),this.#Ma.set("viewer",new Fn(this)),this.#Ma.set("finder",new Un(this)),this.#Ma.set("history",Nn(this))}#Aa(){for(const[,t]of this.#Ma)"function"==typeof t?._init&&t._init()}#La(){const t=this.#Ma.get("pluginManager");Object.assign(this.$,{offset:this.#Ma.get("offset"),selection:this.#Ma.get("selection"),format:this.#Ma.get("format"),inline:this.#Ma.get("inline"),listFormat:this.#Ma.get("listFormat"),html:this.#Ma.get("html"),nodeTransform:this.#Ma.get("nodeTransform"),char:this.#Ma.get("char"),component:this.#Ma.get("component"),focusManager:this.#Ma.get("focusManager"),pluginManager:t,plugins:t.plugins,ui:this.#Ma.get("ui"),commandDispatcher:this.#Ma.get("commandDispatcher"),history:this.#Ma.get("history"),shortcuts:this.#Ma.get("shortcuts"),toolbar:this.#Ma.get("toolbar"),subToolbar:this.#Ma.get("subToolbar"),menu:this.#Ma.get("menu"),viewer:this.#Ma.get("viewer"),finder:this.#Ma.get("finder")})}_destroy(){if(null===this.$)return;const t=[];for(const[e,s]of this.#Ma)try{s?._destroy?.()}catch(s){t.push(`[Logic:${e}] ${s.message}`)}this.#Ma.clear();try{this._eventOrchestrator?._removeAllEvents()}catch(e){t.push(`[EventOrchestrator] ${e.message}`)}this._eventOrchestrator=null;for(const[e,s]of this.#Ta)try{s?._destroy?.()}catch(s){t.push(`[Config:${e}] ${s.message}`)}this.#Ta.clear(),t.length>0&&console.warn("[CoreKernel._destroy] Cleanup completed with errors:",t),this.$=null,this.store._destroy(),this.store=null,this.facade=null}};const qr=class{#H;$;constructor(t,e){const s=bs(t,e),i=new Hr(this,{product:s,options:e});this.#H=i,this.$=i.$,this.#Oa(e).catch((t=>{console.error("[SUNEDITOR:E_CREATE_FAIL] Failed to create editor instance.",t)}))}isEmpty(t){const e=(t||this.$.frameContext).get("wysiwyg");return Pe.check.isZeroWidth(e.textContent)&&!e.querySelector(this.$.options.get("allowedEmptyTags"))&&(e.innerText.match(/\n/g)||"").length<=1}resetOptions(t){this.$.optionProvider.reset(t),this.$.store.set("_lastSelectionNode",null),this.#Ra(this.$.frameRoots.get(this.$.store.get("rootKey")));for(const t of Object.values(this.$.plugins))t.init?.()}changeFrameContext(t){t!==this.$.store.get("rootKey")&&(this.$.store.set("rootKey",t),this.#Ra(this.$.frameRoots.get(t)),this.$.toolbar._resetSticky())}destroy(){this.$.options.get("hasCodeMirror")&&this.$.contextProvider.applyToRoots((t=>{const e=t.get("options").get("codeMirrorEditor");e&&e.toTextArea()})),Pe.utils.removeItem(this.$.context.get("toolbar_wrapper")),Pe.utils.removeItem(this.$.context.get("toolbar_sub_wrapper")),Pe.utils.removeItem(this.$.context.get("statusbar_wrapper"));for(const t in this.events)this.events[t]=null;return this.events=null,this.#H._destroy(),null}#Ra(t){this.$.contextProvider.reset(t),this.$.optionProvider.resetFrame(t.get("options")),this.$.ui.reset(t)}#za(t){this.$.store.set("initViewportHeight",Oe._w.visualViewport.height),this.#H._eventOrchestrator.__setViewportSize(),this.$.store.set("_canUseBeforeInput",Oe.canUseBeforeInput()),this.$.contextProvider.init(),this.#Ra(this.$.frameRoots.get(this.$.store.get("rootKey"))),this.#Ts(t),this.$.contextProvider.applyToRoots((t=>{this.#H._eventOrchestrator._addFrameEvents(t),this.#Pa(t,t.get("options").get("value")),t.get("options").get("iframe")&&"auto"===t.get("options").get("height")&&this.$.ui._emitResizeEvent(t,t.get("wysiwygFrame").offsetHeight,null)})),this.#H._eventOrchestrator.__eventDoc=null,this.$.store._editorInitFinished=!0,this.$.pluginManager.checkFileInfo(!0),this.$.history.reset(),Oe._w.setTimeout((()=>{if(this.$.context?.size){this.$.context.get("toolbar_main").style.visibility="",this.$.contextProvider.applyToRoots((t=>{this.#H._eventOrchestrator._wwFrameObserver&&this.#H._eventOrchestrator._wwFrameObserver.observe(t.get("wysiwygFrame")),this.#H._eventOrchestrator._toolbarObserver&&this.#H._eventOrchestrator._toolbarObserver.observe(t.get("_toolbarShadow")),this.$.ui._syncFrameState(t)}));for(const t of Object.values(this.$.plugins))t.init?.();this.$.selection.__init(),this.$.eventManager.triggerEvent("onload",{})}else console.warn("[SUNEDITOR:E_INIT_FAIL] Editor instance was destroyed before initialization completed. Check if destroy() was called.")}),0)}#Pa(t,e){if(t.get("wysiwyg").innerHTML=this.$.html.clean("string"==typeof e?e:(/^TEXTAREA$/i.test(t.get("originElement").nodeName)?t.get("originElement").value:t.get("originElement").innerHTML)||"",{forceFormat:!0,whitelist:null,blacklist:null,_freeCodeViewMode:this.$.options.get("freeCodeViewMode")})||"<"+this.$.options.get("defaultLine")+"><br></"+this.$.options.get("defaultLine")+">",t.has("charCounter")&&(t.get("charCounter").textContent=String(this.$.char.getLength())),t.has("wordCounter")&&(t.get("wordCounter").textContent=String(this.$.char.getWordCount())),"document"===this.$.options.get("type")&&(t.set("documentType",new Cs(this.#H,t)),t.get("documentType").useHeader&&t.set("documentType_use_header",!0),t.get("documentType").usePage)){t.set("documentType_use_page",!0);const e=t.get("documentTypePageMirror"),s=e.ownerDocument.createDocumentFragment();for(let e=t.get("wysiwyg").firstChild;e;e=e.nextSibling)s.appendChild(e.cloneNode(!0));e.replaceChildren(s)}}#Ts(t){this.$.pluginManager.init(t),this.$.shortcuts._registerShortcuts(),this.$.commandDispatcher._initCommandButtons(),this.$.ui.init()}#Da(t,e,s){t.contentDocument.documentElement.className="sun-editor",t.contentDocument.head.innerHTML='<meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">'+ze._setIframeStyleLinks(s.get("iframe_cssFileName"))+ze._setAutoHeightStyle(s.get("height")),t.contentDocument.body.className=e.get("_editableClass"),t.contentDocument.body.setAttribute("contenteditable","true"),e.get("_rtl")&&(t.contentDocument.body.dir="rtl")}async#Oa(t){this.#H._eventOrchestrator._addCommonEvents();const e=[];this.$.contextProvider.applyToRoots((t=>{const s=t.get("originElement"),i=t.get("topArea");if(s.style.display="none",i.style.display="block",s.parentNode.insertBefore(i,s.nextElementSibling),t.get("options").get("iframe")){const s=new Promise((e=>{const s=s=>{this.#Da(s,this.$.optionProvider.options,t.get("options")),e()};if(Oe.isGecko){let e=null;this.$.eventManager.addEvent(t.get("wysiwygFrame"),"load",(({target:t})=>{clearTimeout(e),e=setTimeout((()=>{this.$&&s(t)}),60)}))}else this.$.eventManager.addEvent(t.get("wysiwygFrame"),"load",(({target:t})=>{s(t)}))}));e.push(s)}})),this.$.contextProvider.applyToRoots((t=>{t.get("wrapper").appendChild(t.get("wysiwygFrame")),t.get("documentTypeInner")&&t.get("wrapper").insertBefore(t.get("documentTypeInner"),t.get("wysiwygFrame")),t.get("documentTypePage")&&(t.get("wrapper").appendChild(t.get("documentTypePage")),t.get("wrapper").appendChild(t.get("documentTypePageMirror"))),t.get("blockHandleArea")&&t.get("wrapper").insertBefore(t.get("blockHandleArea"),t.get("wysiwygFrame"))})),e.length>0&&await Promise.all(e),this.#za(t)}};function Wr(t){let e;try{e=t.responseText}catch{return`status ${t.status}`}if(!e)return`status ${t.status}`;try{return JSON.parse(e)}catch{return e}}const Ur=class{#J;#Fa;constructor(t,e,s){this.#J=e,this.kind=t.constructor.key||t.constructor.name,this.#Fa=Oe.getXMLHttpRequest(),this.method=s?.method,this.url=s?.url,this.headers=s?.headers,this.data=s?.data,this.callBack=s?.callBack,this.errorCallBack=s?.errorCallBack,this.responseType=s?.responseType}call({method:t,url:e,headers:s,data:i,callBack:n,errorCallBack:o,responseType:r}){if(this.cancel(),t||=this.method,e=this.#Ha(e||this.url),s||=this.headers,i||=this.data,n||=this.callBack,o||=this.errorCallBack,r||=this.responseType,"function"!=typeof n)throw new Error(`[SUNEDITOR.ApiManager[${this.kind}].upload.callBack.fail] callBack is not a function`);const l=this.#Fa;if(r&&(l.responseType=r),l.onreadystatechange=this.#qa.bind(this,l,n,o),l.open(t,e,!0),null!==s&&"object"==typeof s&&Object.keys(s).length>0)for(const t in s)l.setRequestHeader(t,s[t]);l.send(i)}asyncCall({method:t,url:e,headers:s,data:i,responseType:n}){this.cancel(),t||=this.method,e=this.#Ha(e||this.url),s||=this.headers,i||=this.data,n||=this.responseType;const o=this.#Fa;return n&&(o.responseType=n),new Promise(((n,r)=>{if(o.open(t,e,!0),null!==s&&"object"==typeof s&&Object.keys(s).length>0)for(const t in s)o.setRequestHeader(t,s[t]);o.onload=()=>{if(200===o.status)try{n(o)}finally{this.#J.ui.hideLoading()}else{console.error(`[SUNEDITOR.ApiManager[${this.kind}].upload.serverException]`,o);try{r(Wr(o))}finally{this.#J.ui.hideLoading()}}},o.onerror=()=>{this.#J.ui.hideLoading(),r(new Error("Network error"))},o.send(i)}))}cancel(){this.#Fa&&(this.#Fa.onreadystatechange=null,this.#Fa.onload=null,this.#Fa.onerror=null,this.#Fa.abort())}#Ha(t){return t?t.replace(/([^:])\/+/g,"$1/").replace(/\/(\?|#|$)/,"$1"):""}async#qa(t,e,s){if(4===t.readyState)if(200===t.status)try{await e(t)}catch(t){throw Error(`[SUNEDITOR.ApiManager[${this.kind}].upload.callBack.fail] ${t.message}`)}finally{this.#J.ui.hideLoading()}else{console.error(`[SUNEDITOR.ApiManager[${this.kind}].upload.serverException]`,t);try{const e=Wr(t);let i="";"function"==typeof s&&(i=await s(e,t));const n=`[SUNEDITOR.ApiManager[${this.kind}].upload.serverException] status: ${t.status}, response: ${i||e.errorMessage||("string"==typeof e?e:JSON.stringify(e))}`;this.#J.ui.alertOpen(n,"error")}catch(t){throw Error(`[SUNEDITOR.ApiManager[${this.kind}].upload.errorCallBack.fail] ${t.message}`)}finally{this.#J.ui.hideLoading()}}}};function Vr(t){const e=t.src.split("/").pop(),s=t.thumbnail||"",i=s||t.src,n=this.props?.map((e=>`data-${e}="${t[e]}"`)).join(" ")||"",o=`data-type="${t.type}" data-command="${t.src}" data-name="${t.name||e}" data-thumbnail="${s}" data-extension="${t.src.split(".").pop()}" ${n}`,r=`class="${s||"se-browser-empty-image"}" src="${i}" alt="${t.alt||e}" ${o}`;return`\n\t\t<div class="se-file-item-img">\n\t\t\t${this.thumbnail&&!s&&"image"!==t.type?`<div class="se-browser-empty-thumbnail" ${r}>${this.thumbnail(t)}</div>`:`<img class="${s||"se-browser-empty-image"}" ${r}>`}\n\t\t\t<div class="se-file-name-image se-file-name-back"></div>\n\t\t\t<div class="se-file-name-image">${t.name||e}</div>\n\t\t</div>`}const jr=class{#J;#Wa;#or;#Ua=[];#Va;#ja;#$o=!1;#Mo=null;constructor(t,e,s){this.#J=e,this.useSearch=s.useSearch??!0;const i=Pe.utils.createElement("DIV",{class:"se-browser sun-editor-common"+(s.className?` ${s.className}`:"")}),n=function(t,e){const s=t.lang,i=t.icons,n=`\n\t\t<div class="se-browser-content">\n\t\t\t<div class="se-browser-header">\n\t\t\t\t<button type="button" data-command="close" class="se-btn se-browser-close" class="close" title="${s.close}" aria-label="${s.close}">\n\t\t\t\t\t${i.cancel}\n\t\t\t\t</button>\n\t\t\t\t<span class="se-browser-title"></span>\n\t\t\t</div>\n\t\t\t<div class="se-browser-wrapper">\n\t\t\t\t<div class="se-browser-side"></div>\n\t\t\t\t<div class="se-browser-main"> \n\t\t\t\t\t<div class="se-browser-bar">\n\t\t\t\t\t\t<div class="se-browser-search">\n\t\t\t\t\t\t\t<button type="button" class="se-btn se-side-open-btn">${i.side_menu_hamburger}</button>\n\t\t\t\t\t\t\t${e?`\n\t\t\t\t\t\t\t\t\t\t<form class="se-browser-search-form">\n\t\t\t\t\t\t\t\t\t\t\t<div class="se-browser-search-input-wrap">\n\t\t\t\t\t\t\t\t\t\t\t\t<input type="text" class="se-input-form" placeholder="${s.search}" aria-label="${s.search}">\n\t\t\t\t\t\t\t\t\t\t\t\t<button type="button" class="se-btn se-btn-plain se-browser-search-clear" title="${s.cancel}" aria-label="${s.cancel}" style="display:none">${i.cancel}</button>\n\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t\t<button type="submit" class="se-btn" title="${s.search}" aria-label="${s.search}">${i.search}</button>\n\t\t\t\t\t\t\t\t\t\t</form>`:""}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class="se-browser-body">\n\t\t\t\t\t\t<div class="se-browser-tags"></div>\n\t\t\t\t\t\t<div class="se-loading-box sun-editor-common"><div class="se-loading-effect"></div></div>\n\t\t\t\t\t\t<div class="se-browser-menus"></div>\n\t\t\t\t\t\t<div class="se-browser-list"></div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>`,o=Pe.utils.createElement("DIV",{class:"se-browser-inner"},n);return{html:o,header:o.querySelector(".se-browser-header"),titleArea:o.querySelector(".se-browser-title"),tagArea:o.querySelector(".se-browser-tags"),body:o.querySelector(".se-browser-body"),list:o.querySelector(".se-browser-list"),side:o.querySelector(".se-browser-side"),wrapper:o.querySelector(".se-browser-wrapper"),_loading:o.querySelector(".se-loading-box")}}(this.#J,this.useSearch),o=n.html;this.kind=t.constructor.key||t.constructor.name,this.host=t,this.area=i,this.header=n.header,this.titleArea=n.titleArea,this.tagArea=n.tagArea,this.body=n.body,this.list=n.list,this.side=n.side,this.wrapper=n.wrapper,this.#Wa=n._loading,this.title=s.title,this.listClass=s.listClass||"se-preview-list",this.directData=s.data,this.url=s.url,this.headers=s.headers,this.searchUrl=s.searchUrl,this.searchHeaders=s.searchHeaders,this.drawItemHandler=(s.drawItemHandler||Vr).bind({thumbnail:s.thumbnail,props:s.props||[]}),this.selectorHandler=s.selectorHandler,this.columnSize=s.columnSize||4,this.expand=s.expand??1,this.folderDefaultPath="",this.closeArrow=this.#J.icons.menu_arrow_right,this.openArrow=this.#J.icons.menu_arrow_down,this.icon_folder=this.#J.icons.side_menu_folder_item,this.icon_folder_item=this.#J.icons.side_menu_folder,this.icon_item=this.#J.icons.side_menu_item,this.items=[],this.folders={},this.tree={},this.data={},this.selectedTags=[],this.keyword="",this.sideInner=null,this.apiManager=new Ur(this,e,{method:"GET"}),this.#or=t=>{Fe.isEsc(t.code)&&this.close()},i.appendChild(Pe.utils.createElement("DIV",{class:"se-browser-back"})),i.appendChild(o),i.setAttribute("popover","manual"),this.#J.contextProvider.carrierWrapper.appendChild(i),this.#J.eventManager.addEvent(this.tagArea,"click",this.#Ga.bind(this)),this.#J.eventManager.addEvent(this.list,"click",this.#Ka.bind(this)),this.#J.eventManager.addEvent(this.side,"click",this.#Ya.bind(this)),this.#J.eventManager.addEvent(o,"mousedown",this.#Xa.bind(this)),this.#J.eventManager.addEvent(o,"click",this.#Za.bind(this)),this.#J.eventManager.addEvent(this.sideOpenBtn=i.querySelector(".se-side-open-btn"),"click",this.#Ja.bind(this)),this.#J.eventManager.addEvent([this.header,i.querySelector(".se-browser-main")],"mousedown",this.#Qa.bind(this));const r=i.querySelector("form.se-browser-search-form");this.#Va=r?.querySelector('input[type="text"]'),this.#ja=i.querySelector(".se-browser-search-clear"),this.#J.eventManager.addEvent(r,"submit",this.#th.bind(this)),this.#J.eventManager.addEvent(this.#ja,"click",this.#eh.bind(this))}open(t={}){this.#qe();const e=t.listClass||this.listClass;Pe.utils.hasClass(this.list,e)||(this.list.className="se-browser-list "+e),this.titleArea.textContent=t.title||this.title,this.area.style.display="block",this.area.showPopover?.(),this.#J.ui.opendBrowser=this,this.closeArrow=this.#J.options.get("_rtl")?this.#J.icons.menu_arrow_left:this.#J.icons.menu_arrow_right,this.directData?this.#sh(this.directData):this.#ih(t.url||this.url,t.headers||this.headers,!1),this.body.style.maxHeight=Pe.utils.getClientSize().h-(this.#J.offset.getGlobal(this.body).top-o.scrollY)-20+"px"}close(){this.#je(),this.apiManager.cancel(),this.area.hidePopover?.(),this.area.style.display="none",this.selectedTags=[],this.items=[],this.#Ua=[],this.folders={},this.tree={},this.data={},this.keyword="",this.list.innerHTML=this.tagArea.innerHTML=this.titleArea.textContent="",this.#Va&&(this.#Va.value=""),this.#ja&&(this.#ja.style.display="none"),this.#J.ui.opendBrowser=null,this.sideInner=null,this.host.browserInit?.()}search(t){if(this.searchUrl){this.keyword=t;const e=this.searchUrl.includes("?")?"&":"?";this.#ih(this.searchUrl+e+"keyword="+o.encodeURIComponent(t),this.searchHeaders,!1)}else this.keyword=t.toLowerCase(),this.#nh(this.#Ua.length>0?this.#Ua:this.items,!1)}#oh(){const t=[];for(const e in this.data){const s=this.data[e];if(Array.isArray(s))for(let e=0;e<s.length;e++)t.push(s[e])}return t}tagfilter(t){const e=this.selectedTags;return 0===e.length?t:t.filter((t=>!Array.isArray(t.tag)||t.tag.some((t=>e.includes(t)))))}showBrowserLoading(){this.#Wa.style.display="block"}closeBrowserLoading(){this.#Wa.style.display="none"}#ih(t,e,s){this.apiManager.call({method:"GET",url:t,headers:e,callBack:this.#rh.bind(this),errorCallBack:this.#lh.bind(this)}),s||(this.sideOpenBtn.style.display="none",this.showBrowserLoading())}#nh(t,e){const s=this.keyword,i=[],n=(t=this.tagfilter(t).filter((t=>t.name.toLowerCase().indexOf(s)>-1))).length,o=this.columnSize,r=o<=1?1:Math.round(n/o)||1,l=this.drawItemHandler;let a="",h='<div class="se-file-item-column">',c=1;for(let s,d,u=0;u<n;u++)if(s=t[u],d=s.tag?"string"==typeof s.tag?s.tag.split(","):s.tag:[],d=s.tag=d.map((t=>t.trim())),h+=l(s),(u+1)%r==0&&c<o&&u+1<n&&(c++,h+='</div><div class="se-file-item-column">'),e&&d.length>0)for(let t,e=0,s=d.length;e<s;e++)t=d[e],t&&!i.includes(t)&&(i.push(t),a+=`<a title="${t}" aria-label="${t}">${t}</a>`);h+="</div>",this.list.innerHTML=h,s&&this.#ah(s),e&&(this.items=t,this.tagArea.innerHTML=a)}#qe(){this.#je(),this.#Mo=this.#J.eventManager.addGlobalEvent("keydown",this.#or,!0)}#je(){this.#Mo&&=this.#J.eventManager.removeGlobalEvent(this.#Mo)}#sh(t){if(Array.isArray(t))return t.length>0&&this.#nh(t,!0),!0;if("object"==typeof t){this.sideOpenBtn.style.display="",this.#hh(t),this.#Ua=this.#oh(),this.side.innerHTML="";const e=this.sideInner=Pe.utils.createElement("div",null);if(this.#ch(this.tree,e),this.side.appendChild(e),this.folderDefaultPath){const t=e.querySelector(`[data-command="${this.folderDefaultPath}"]`);t.click(),this.folderDefaultPath.includes("/")&&(Pe.utils.removeClass(t.parentElement,"se-menu-hidden"),t.parentElement.previousElementSibling.querySelector("button").innerHTML=this.openArrow)}return!0}return!1}#hh(t,e){let s=this.tree;if(t._data){this.data[e]=t._data,this.folderDefaultPath&&!t.default||(this.folderDefaultPath=e);const i=e.split("/"),n=i.length-1;i.forEach(((t,i)=>{s[t]||={children:{}},i===n?(s[t].key=e,s[t].name=this.folders[e].name):s=s[t].children}))}else e&&(s[e]={name:this.folders[e].name,children:{}});Object.entries(t).forEach((([t,s])=>{if("_data"===t||!s||"object"!=typeof s)return;const i=s,n=e?`${e}/${t}`:t;this.folders[n]={name:i.name||t,meta:i.meta||{}},this.#hh(i,n)}))}#ch(t,e,s=0){const i=s<this.expand;for(const n in t){const o=t[n];if(o)if(Object.keys(o.children).length>0){const t=Pe.utils.createElement("div",o.key?{"data-command":o.key,"aria-label":o.name}:null,`<span class="se-menu-icon">${o.key?this.icon_folder:this.icon_folder_item}</span><span>${o.name}</span>`),n=Pe.utils.createElement("div",{class:"se-menu-folder"},t);t.insertBefore(Pe.utils.createElement("button",{type:"button"},i?this.openArrow:this.closeArrow),t.firstElementChild);const r=document.createElement("div");Pe.utils.addClass(r,i?"se-menu-child":"se-menu-child|se-menu-hidden"),this.#ch(o.children,r,s+1),n.appendChild(r),e.appendChild(n)}else{const t=Pe.utils.createElement("div",{"data-command":o.key,"aria-label":o.name,class:"se-menu-folder-item"},`<span class="se-menu-icon">${this.icon_item}</span><span>${o.name}</span>`);if(e===this.sideInner){const s=Pe.utils.createElement("div",{class:"se-menu-folder"},t);e.appendChild(s)}else e.appendChild(t)}}}#rh(t){try{const e=JSON.parse(t.responseText),s=e.result;if(this.#sh(s))return;e.nullMessage&&(this.list.innerHTML=e.nullMessage)}catch(t){throw Error(`[SUNEDITOR.browser.drawList.fail] cause: "${t.message}"`)}finally{this.closeBrowserLoading()}}#lh(t,e){throw this.closeBrowserLoading(),Error(`[SUNEDITOR.browser.get.serverException] status: ${e.status}, response: ${t.errorMessage||e.responseText}`)}#Ga(t){const e=Pe.query.getEventTarget(t);if(!Pe.check.isAnchor(e))return;const s=e.textContent,i=this.tagArea.querySelector('a[title="'+s+'"]'),n=this.selectedTags.indexOf(s);n>-1?(this.selectedTags.splice(n,1),Pe.utils.removeClass(i,"on")):(this.selectedTags.push(s),Pe.utils.addClass(i,"on")),this.#nh(this.items,!1)}#Ka(t){const e=Pe.query.getEventTarget(t);if(t.preventDefault(),t.stopPropagation(),e===this.list)return;const s=Pe.query.getCommandTarget(e);s&&(this.close(),this.selectorHandler(s))}#Ya(t){const e=Pe.query.getEventTarget(t);if(t.stopPropagation(),/^button$/i.test(e.nodeName)){const t=e.parentElement.parentElement.querySelector(".se-menu-child");return void(Pe.utils.hasClass(t,"se-menu-hidden")?(Pe.utils.removeClass(t,"se-menu-hidden"),e.innerHTML=this.openArrow):(Pe.utils.addClass(t,"se-menu-hidden"),e.innerHTML=this.closeArrow))}const s=Pe.query.getCommandTarget(e);if(!s||Pe.utils.hasClass(s,"active"))return;const i=this.data[s.getAttribute("data-command")];Pe.utils.removeClass(this.side.querySelectorAll(".active"),"active"),Pe.utils.addClass([s,Pe.query.getParentElement(s,".se-menu-folder")],"active"),this.tagArea.innerHTML="",this.selectedTags=[],"string"==typeof i?this.#ih(i,this.headers,!0):this.#nh(i,!0)}#Xa(t){const e=Pe.query.getEventTarget(t);/se-browser-inner/.test(e.className)?this.#$o=!0:this.#$o=!1}#Za(t){const e=Pe.query.getEventTarget(t);t.stopPropagation(),(/close/.test(e.getAttribute("data-command"))||this.#$o)&&this.close()}#th(t){t.preventDefault();const e=this.#Va.value;this.search(e),this.#ja&&(this.#ja.style.display=e?"":"none")}#eh(){this.#Va&&(this.#Va.value=""),this.#ja&&(this.#ja.style.display="none"),this.keyword="",this.#nh(this.items,!1)}#ah(t){const e=this.list.querySelectorAll(".se-file-name-image:not(.se-file-name-back)");for(let s=0;s<e.length;s++){const i=e[s],n=i.textContent,o=n.toLowerCase().indexOf(t);o>-1&&(i.innerHTML=n.substring(0,o)+"<mark>"+n.substring(o,o+t.length)+"</mark>"+n.substring(o+t.length))}}#Ja(t){const e=Pe.query.getEventTarget(t);Pe.utils.hasClass(e,"active")?(Pe.utils.removeClass(this.side,"se-side-show"),Pe.utils.removeClass(e,"active")):(Pe.utils.addClass(this.side,"se-side-show"),Pe.utils.addClass(e,"active"))}#Qa({target:t}){t!==this.sideOpenBtn&&Pe.utils.hasClass(this.sideOpenBtn,"active")&&(Pe.utils.removeClass(this.side,"se-side-show"),Pe.utils.removeClass(this.sideOpenBtn,"active"))}},{isTouchDevice:Gr}=Oe,Kr=240,Yr=120,Xr={hex:"#FFFFFF",r:255,g:255,b:255,h:0,s:1,l:1};let Zr,Jr=0,Qr=!1,tl=!1,el=120,sl=120,il=Xr,nl=!1;const{slider:ol,offscreenCanvas:rl,offscreenCtx:ll,wheel:al,wheelCtx:hl,wheelPointer:cl,gradientBar:dl,gradientPointer:ul,fanalColorHex:pl,fanalColorBackground:gl}=function(){const t=document.createElement("canvas");t.width=Kr,t.height=Kr;const e=`\n\t<div class="se-hue-slider-container" style="width: 240px; height: 240px;">\n <canvas class="se-hue-wheel" width="240" height="240"></canvas>\n <div class="se-hue-wheel-pointer"></div>\n </div>\n <div class="se-hue-gradient-container">\n <canvas class="se-hue-gradient" width="240" height="28"></canvas>\n <div class="se-hue-gradient-pointer"></div>\n </div>\n <div class="se-hue-final-hex" style="width:240px; height: 28px;">\n\t\t<div style="flex: 3; line-height: 1.5;">${Xr.hex}</div>\n\t\t<div style="flex: 1; height: 100%; border: 1px solid #fff; outline: 1px solid #000;"></div>\n\t</div>\n\t`,s=Pe.utils.createElement("DIV",{class:"se-hue-slider"},e),i=s.querySelector(".se-hue-wheel"),n=s.querySelector(".se-hue-gradient"),o=s.querySelector(".se-hue-final-hex").children;return{slider:s,offscreenCanvas:t,offscreenCtx:t.getContext("2d"),wheel:i,wheelCtx:i.getContext("2d"),wheelPointer:s.querySelector(".se-hue-wheel-pointer"),gradientBar:n,gradientPointer:s.querySelector(".se-hue-gradient-pointer"),fanalColorHex:o[0],fanalColorBackground:o[1]}}();function ml(t){const{target:e,touches:s}=t,i=s[0].clientX,n=s[0].clientY;e===al?(t.preventDefault(),tl=!1,Qr=!0,yl(i,n)):e===dl&&(t.preventDefault(),tl=!0,Qr=!1,wl(i))}function fl(t){t.preventDefault();const{touches:e}=t,s=e[0].clientX,i=e[0].clientY;Qr?yl(s,i):tl&&wl(s)}function vl({target:t,clientX:e,clientY:s}){t===al?(tl=!1,Qr=!0,yl(e,s)):t===dl&&(tl=!0,Qr=!1,wl(e))}function bl({clientX:t,clientY:e}){Qr?yl(t,e):tl&&wl(t)}function yl(t,e){const s=al.getBoundingClientRect();t=t-s.left-Yr,e=e-s.top-Yr;const i=180*Math.atan2(e,t)/Math.PI,n=Math.min(Math.sqrt(t*t+e*e),Yr),o=Yr+n*Math.cos(i*Math.PI/180),r=Yr+n*Math.sin(i*Math.PI/180);cl.style.left=`${o}px`,cl.style.top=`${r}px`,function(t,e){el=t,sl=e,Cl(_l())}(o,r),kl()}function wl(t){const e=dl.getBoundingClientRect();let s=t-e.left;s=Math.max(14,Math.min(s,e.width-14)),ul.style.left=`${s}px`,function(t){const e=dl.getBoundingClientRect();let s=t-e.left;s<0&&(s=0);s>e.width&&(s=e.width);const i=14;s>=dl.width-i?s=dl.width:s<=i&&(s=0);const n=1-s/e.width;Jr=n,Sl()}(t),kl()}function Cl(t){const e=dl.getContext("2d"),s=e.createLinearGradient(0,0,dl.width,0);s.addColorStop(0,"black"),s.addColorStop(1,t.hex),e.fillStyle=s,e.fillRect(0,0,dl.width,dl.height)}function _l(){return $l(ll)}function kl(){Zr.color=il=$l(hl),xl(il.hex)}function xl(t){gl.style.backgroundColor=pl.textContent=t}function $l(t){const e=t.getImageData(el,sl,1,1).data;let[s,i,n]=function([t,e,s]){t/=255,e/=255,s/=255;const i=Math.max(t,e,s),n=Math.min(t,e,s);let o,r;const l=(i+n)/2;if(i===n)o=r=0;else{const a=i-n;switch(r=l>.5?a/(2-i-n):a/(i+n),i){case t:o=(e-s)/a+(e<s?6:0);break;case e:o=(s-t)/a+2;break;case s:o=(t-e)/a+4}o/=6}return[Tl(o),Tl(r),Tl(l)]}(e);const o=el-Yr,r=sl-Yr;Math.sqrt(o*o+r*r)<3&&(n=1-Jr),n>1&&(n=1),n<0&&(n=0);const{r:l,g:a,b:h}=function([t,e,s]){let i,n,o;if(0===e)i=n=o=s;else{const r=function(t,e,s){return s<0&&(s+=1),s>1&&(s-=1),s<1/6?t+6*(e-t)*s:s<.5?e:s<2/3?t+(e-t)*(2/3-s)*6:t},l=s<.5?s*(1+e):s+e-s*e,a=2*s-l;i=r(a,l,t+1/3),n=r(a,l,t),o=r(a,l,t-1/3)}return{r:Math.round(255*i),g:Math.round(255*n),b:Math.round(255*o)}}([s,i,n]),c=`#${function({r:t,g:e,b:s}){let i=Math.floor(t).toString(16);t<16&&(i=`0${i}`);let n=Math.floor(e).toString(16);e<16&&(n=`0${n}`);let o=Math.floor(s).toString(16);s<16&&(o=`0${o}`);return`${i}${n}${o}`.toUpperCase()}({r:l,g:a,b:h})}`;return{hex:c,r:l,g:a,b:h,h:s,s:i,l:Tl(n)}}function Sl(){hl.clearRect(0,0,Kr,Kr),hl.drawImage(rl,0,0),hl.globalAlpha=Jr,hl.fillStyle="black",hl.beginPath(),hl.arc(Yr,Yr,Yr,0,2*Math.PI),hl.fill(),hl.globalAlpha=1}function El(t){return t*Math.PI/180}function Tl(t){const e=Math.pow(10,10);return Math.round(t*e)/e}function Ml(){!function(t){if(!t)return void console.warn("[HueSlider.fail] Context not found.");for(let e=0;e<=360;e+=.5)for(let s=0;s<=Yr;s+=1){t.beginPath();const i=50+(Yr-s)/Yr*50;t.fillStyle=`hsl(${e}, 100%, ${i}%)`;const n=Yr+Math.cos(El(e))*s,o=Yr-Math.sin(El(e))*s;t.arc(n,o,1.5,0,2*Math.PI),t.fill()}nl=!0}(ll),nl&&Sl()}Ml();const Nl=class{#J;#dh;#uh;#ph;#gh;#mh;#fh;constructor(t,e,s={},i=""){if(this.#J=e,this.inst=t,this.ctx={wheelX:el,wheelY:sl,lightness:Jr,wheelPointerX:"50%",wheelPointerY:"50%",gradientPointerX:"calc(100% - 14px)",color:Xr},this.isOpen=!1,this.controlle=null,this.#dh=null,this.#uh=null,this.#ph=null,this.#gh=null,this.#mh=null,this.#fh=null,!s.isNewForm){const n=function({lang:t,icons:e},s){const i=Pe.utils.createElement("DIV",{class:`se-controller ${s}`},`\n\t\t<div class="se-hue"></div>\n\t\t<div class="se-form-group se-form-w0 se-form-flex-btn">\n\t\t\t<button type="button" class="se-btn se-btn-success" title="${t.submitButton}" aria-label="${t.submitButton}" data-command="submit">${e.checked}</button>\n\t\t\t<button type="button" class="se-btn se-btn-danger" title="${t.close}" aria-label="${t.close}" data-command="close">${e.cancel}</button>\n\t\t</div>\n\t`);return i}(e,i);this.circle=n.querySelector(".se-hue"),this.controller=new Ii(this,e,n,{position:"bottom",isWWTarget:!1,parents:[t.form],parentsHide:!0,...s.controllerOptions})}}controllerAction(t){const e=t.getAttribute("data-command");"submit"===e?(this.inst.hueSliderAction?.(this.get()),this.close()):"close"===e&&this.close()}controllerClose(){this.init(),this.inst.hueSliderCancelAction?.()}get(){return il}open(t){this.attach(),this.controller.open(t,null,{isWWTarget:!1,initMethod:null,addOffset:null})}close(){this.ctx={gradientPointerX:ul.style.left,wheelPointerX:cl.style.left,wheelPointerY:cl.style.top,wheelX:el,wheelY:sl,lightness:Jr,color:Zr?.color||""},this.controller.close()}attach(t){nl||Ml(),this.init(),(t||this.circle).appendChild(ol),Zr=this.ctx,Zr&&(el=Zr.wheelX,sl=Zr.wheelY,Jr=Zr.lightness,cl.style.left=Zr.wheelPointerX,cl.style.top=Zr.wheelPointerY,ul.style.left=Zr.gradientPointerX,xl(Zr.color.hex),Sl(),Cl(_l())),Gr&&(this.#mh=this.#J.eventManager.addGlobalEvent("touchstart",ml,{passive:!1,capture:!0}),this.#uh=this.#J.eventManager.addGlobalEvent("touchmove",fl,!0),this.#fh=this.#J.eventManager.addGlobalEvent("touchend",(()=>{Qr=!1,tl=!1}),!0)),this.#dh=this.#J.eventManager.addGlobalEvent("mousedown",vl,{passive:!1,capture:!0}),this.#gh=this.#J.eventManager.addGlobalEvent("mousemove",bl,!0),this.#ph=this.#J.eventManager.addGlobalEvent("mouseup",(()=>{Qr=!1,tl=!1}),!0),this.isOpen=!0}init(){this.isOpen=!1,Qr=!1,tl=!1,this.#dh&&=this.#J.eventManager.removeGlobalEvent(this.#dh),this.#gh&&=this.#J.eventManager.removeGlobalEvent(this.#gh),this.#ph&&=this.#J.eventManager.removeGlobalEvent(this.#ph),this.#mh&&=this.#J.eventManager.removeGlobalEvent(this.#mh),this.#uh&&=this.#J.eventManager.removeGlobalEvent(this.#uh),this.#fh&&=this.#J.eventManager.removeGlobalEvent(this.#fh)}},Bl=["#ef4444","#f97316","#eab308","#22c55e","#06b6d4","#3b82f6","#8b5cf6","#ec4899","#000000","#fca5a5","#fdba74","#fcd34d","#6ee7b7","#5eead4","#7dd3fc","#c4b5fd","#f9a8d4","#e5e7eb","#fee2e2","#ffedd5","#fef9c3","#dcfce7","#cffafe","#dbeafe","#ede9fe","#fce7f3","#f3f4f6","#f87171","#fb923c","#facc15","#4ade80","#22d3ee","#60a5fa","#a78bfa","#f472b6","#9ca3af","#b91c1c","#c2410c","#a16207","#15803d","#0e7490","#1d4ed8","#6d28d9","#be185d","#4b5563","#7f1d1d","#7c2d12","#713f12","#14532d","#164e63","#1e3a8a","#4c1d95","#831843","#1f2937"];function Il(t,e){const s=`<ul class="se-color-pallet${e?" se-list-horizontal":""}">`;let i=s;for(let n,o,r,l=0,a=t.length;l<a;l++)n=t[l],"string"==typeof n?(o=n,r=n):"object"==typeof n&&(o=n.value,r=n.name||o),l>0&&l%e==0&&(i+=`</ul>${s}`),i+=`<li><button type="button" data-value="${o}" title="${r}" aria-label="${r}" style="background-color:${o};"></button></li>`;return i+="</ul>",i}const Ll=class{#J;constructor(t,e,s,i){this.#J=e,this.kind=t.constructor.key||t.constructor.name,this.host=t,this.form=i.form,this.target=function({lang:t,icons:e},{colorList:s,disableHEXInput:i,disableRemove:n,splitNum:o}){s||=Bl,o=s===Bl?9:o;let r="";for(let t,e=0,i=s.length,n=[];e<i;e++)t=s[e],t&&(("string"==typeof t||t.value)&&(n.push(t),e<i-1)||(n.length>0&&(r+=`<div class="se-selector-color">${Il(n,o)}</div>`,n=[]),"object"==typeof t&&(r+=`<div class="se-selector-color">${Il(t,o)}</div>`)));return r+=`\n\t\t<form class="se-form-group se-form-w0">\n\t\t\t${i?"":`<button type="button" class="se-btn __se_hue" title="${t.colorPicker}" aria-label="${t.colorPicker}">${e.color_palette}</button>`}\n\t\t\t<input type="text" class="se-color-input" ${i?"readonly":""} placeholder="${t.color}" />\n\t\t\t${i?"":`<button type="submit" class="se-btn se-btn-success" title="${t.submitButton}" aria-label="${t.submitButton}">${e.checked}</button>`}\n\t\t\t${n?"":`<button type="button" class="se-btn __se_remove" title="${t.remove}" aria-label="${t.remove}">${e.remove_color}</button>`}\n\t\t</form>`,Pe.utils.createElement("DIV",{class:"se-list-inner"},r)}(this.#J,i),this.targetButton=null,this.inputElement=this.target.querySelector(".se-color-input"),this.styleProperties=s,this.splitNum=i.splitNum||0,this.defaultColor=i.defaultColor||"",this.hueSliderOptions=i.hueSliderOptions,this.currentColor="",this.colorList=this.target.querySelectorAll("li button")||[],this.hueSlider=null;const n=(new DOMParser).parseFromString(this.#J.icons.color_checked,"image/svg+xml");this.checkedIcon=n.documentElement,i.disableHEXInput||(this.hueSlider=new Nl(this,e,i.hueSliderOptions,"se-dropdown"),this.#J.eventManager.addEvent(this.target.querySelector(".__se_hue"),"click",this.#vh.bind(this)),this.#J.eventManager.addEvent(this.inputElement,"input",this.#bh.bind(this)),this.#J.eventManager.addEvent(this.target.querySelector("form"),"submit",this.#yh.bind(this))),i.disableRemove||this.#J.eventManager.addEvent(this.target.querySelector(".__se_remove"),"click",this.#wh.bind(this)),this.#J.eventManager.addEvent(this.target,"click",this.#Ch.bind(this)),this.form.appendChild(this.target)}init(t,e,s){this.targetButton=e,"function"!=typeof s&&(s=()=>!1);let i=("string"==typeof t?t:this.#_h(t,s))||this.defaultColor;i=ze.isHexColor(i)?i:ze.rgb2hex(i)||i||"";const n=this.colorList;for(let t,e=0,s=n.length;e<s;e++)t=n[e],i.toLowerCase()===t.getAttribute("data-value").toLowerCase()?(t.appendChild(this.checkedIcon),Pe.utils.addClass(t,"active")):(Pe.utils.removeClass(t,"active"),t.contains(this.checkedIcon)&&Pe.utils.removeItem(this.checkedIcon));this.#kh(this.#xh(i))}setHexColor(t){this.currentColor=t,this.inputElement.style.borderColor=t}hueSliderClose(){this.hueSlider.close()}hueSliderAction(t){this.#kh(t.hex)}hueSliderCancelAction(){this.form.style.display="block",this.host.colorPickerHueSliderClose?.()}#kh(t){t=!t||/^#/.test(t)?t:"#"+t,this.inputElement.value=t,this.setHexColor.call(this,t)}#_h(t,e){let s="";const i=this.styleProperties;for(;t&&!e(t)&&!Pe.check.isWysiwygFrame(t)&&0===s.length;)G(t)&&t.style[i]&&(s=t.style[i]),t=t.parentNode;return s}#xh(t){if(!t||/^#/.test(t))return t;const e=Pe.utils.createElement("div",{style:"display: none; color: "+t}),s=Oe._w.getComputedStyle(Oe._d.body.appendChild(e)).color.match(/\d+/g).map((function(t){return parseInt(t,10)}));return Pe.utils.removeItem(e),s.length>=3?"#"+((1<<24)+(s[0]<<16)+(s[1]<<8)+s[2]).toString(16).substring(1):""}#vh(){this.hueSlider.open(this.targetButton),this.host.colorPickerHueSliderOpen?.()}#yh(t){t.preventDefault(),this.host.colorPickerAction?.(this.currentColor)}#Ch(t){const e=Pe.query.getEventTarget(t).getAttribute("data-value");e&&this.host.colorPickerAction?.(e)}#wh(){this.host.colorPickerAction?.(null)}#bh(t){const e=Pe.query.getEventTarget(t);this.setHexColor(e.value)}},{_w:Al}=Oe,Ol={w:"ns-resize",h:"ew-resize",c:"nwse-resize",wRTL:"ns-resize",hRTL:"ew-resize",cRTL:"nesw-resize"};const Rl=class{#J;#$h;#Sh;#Eh;#Th;#xo;#Te;#Mo=null;#Mh=!1;#Nh=null;#Bh=null;#Ih="";#Lh=0;#Ah=0;#Oh=null;#Rh=null;constructor(t,e,s){this.#J=e,this.inst=t,this.kind=t.constructor.key||t.constructor.name,this.form=s,this.isUpdate=!1,this.focusElement=s.querySelector("[data-focus]"),this.#Sh=this.#J.contextProvider.carrierWrapper.querySelector(".se-modal"),this.#Eh=this.#J.contextProvider.carrierWrapper.querySelector(".se-modal .se-modal-inner"),this.#xo=[this.#zh.bind(this),this.#Ph.bind(this)],this.#Eh.appendChild(s),this.#J.eventManager.addEvent(s.querySelector("form"),"submit",this.#De.bind(this)),this.#Mh=!this.#J.eventManager.addEvent(s.querySelector('[data-command="close"]'),"click",this.close.bind(this)),(s.querySelector(".se-modal-resize-handle-w")||s.querySelector(".se-modal-resize-handle-h")||s.querySelector(".se-modal-resize-handle-c")||s.querySelector(".se-modal-resize-form"))&&!(this.#Th=s.querySelector(".se-modal-resize-form"))&&(this.#Th=s.querySelector(".se-modal-body"))&&(this.#J.eventManager.addEvent(s.querySelector(".se-modal-resize-handle-w"),"mousedown",this.#Dh.bind(this,"w")),this.#J.eventManager.addEvent(s.querySelector(".se-modal-resize-handle-h"),"mousedown",this.#Dh.bind(this,"h")),this.#J.eventManager.addEvent(s.querySelector(".se-modal-resize-handle-c"),"mousedown",this.#Dh.bind(this,"c")),this.#Te={mousemove:this.#Fh.bind(this),mouseup:this.#Hh.bind(this)})}static CreateFileInput({icons:t,lang:e},{acceptedFormats:s,allowMultiple:i}){return`\n\t\t<div class="se-modal-form-files">\n\t\t\t<div class="se-flex-input-wrapper">\n\t\t\t\t<div class="se-input-form-abs">\n\t\t\t\t\t<div>\n\t\t\t\t\t\t<div class="se-input-file-w">\n\t\t\t\t\t\t\t<div class="se-input-file-icon-up">${t.upload_tray}</div>\n\t\t\t\t\t\t\t<div class="se-input-file-icon-files">${t.file_plus}</div>\n\t\t\t\t\t\t\t<span class="se-input-file-cnt"></span>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t\t<input class="se-input-form __se__file_input" data-focus type="file" accept="${s}"${i?' multiple="multiple"':""}/>\n\t\t\t</div>\n\t\t\t<button type="button" class="se-btn se-modal-files-edge-button se-file-remove se-tooltip" aria-label="${e.remove}">\n\t\t\t\t${t.selection_remove}\n\t\t\t\t${Pe.utils.createTooltipInner(e.remove)}\n\t\t\t</button>\n\t\t</div>`}static OnChangeFile(t,e){if(!t||!e)return;const s=t.querySelector(".se-input-file-cnt"),i=t.querySelector(".se-input-file-icon-up"),n=t.querySelector(".se-input-file-icon-files");e.length>1?(i.style.display="none",n.style.display="inline-block",s.style.display="",s.textContent=` ..${e.length}`):e.length>0?(i.style.display="none",n.style.display="none",s.style.display="block",s.textContent=e[0].name):(i.style.display="inline-block",n.style.display="none",s.style.display="",s.textContent="")}open(){if(this.#J.ui.offCurrentModal(),this.#qh(!0),this.#Mh&&(this.#Nh&&this.#J.eventManager.removeEvent(this.#Nh),this.#Nh=this.#J.eventManager.addEvent(this.#Eh,"click",this.#xo[1])),this.#Mo&&=this.#J.eventManager.removeGlobalEvent(this.#Mo),this.#Mo=this.#J.eventManager.addGlobalEvent("keydown",this.#xo[0]),this.isUpdate=this.kind===this.#J.ui.currentControllerName,this.#J.ui.opendModal=this,this.isUpdate||this.inst.modalInit?.(),this.inst.modalOn?.(this.isUpdate),Pe.utils.addClass(this.#Sh,"se-backdrop-show"),Pe.utils.addClass(this.form,"se-modal-show"),this.#Sh.showPopover?.(),this.#Th){const t=this.#Wh(),{maxWidth:e,maxHeight:s}=Al.getComputedStyle(this.form),i=this.form.offsetWidth-t.width+"px",n=`${this.form.offsetTop+(this.form.offsetHeight-this.#Th.offsetHeight)}px`;e&&"string"==typeof this.#Ih&&Pe.utils.setStyle(this.#Th,"max-width",`calc(${e} - ${i})`),s&&Pe.utils.setStyle(this.#Th,"max-height",`calc(${s} - ${n})`)}this.focusElement&&this.focusElement.focus(),this.#$h=this.#J.component.currentTarget}close(){this.#je(),this.#qh(!1),Al.setTimeout((()=>{this.#J.ui.opendModal=null}),0),this.#Mh&&this.#Nh&&(this.#J.eventManager.removeEvent(this.#Nh),this.#Nh=null),this.#Mo&&=this.#J.eventManager.removeGlobalEvent(this.#Mo),this.#Sh.hidePopover?.(),Pe.utils.removeClass(this.#Sh,"se-backdrop-show"),Pe.utils.removeClass(this.form,"se-modal-show"),this.inst.modalInit?.(),this.inst.modalOff?.(this.isUpdate),this.isUpdate?this.#$h&&this.inst.componentSelect?.(this.#$h):this.#J.focusManager.focus(),this.#$h=null}#qh(t){const e=this.#J.ui.opendControllers;for(let s=0;s<e.length;s++)e[s].fixed=t,e[s].form.style.display=t?"none":"block"}#Wh(){const t=this.#J.offset.getGlobal(this.#Th);return this.#Lh=t.top,this.#Ah=t.left,t}#qe(t){this.#je(),this.#J.ui.enableBackWrapper(Ol[t]),this.#Oh=this.#J.eventManager.addGlobalEvent("mousemove",this.#Te.mousemove,!0),this.#Rh=this.#J.eventManager.addGlobalEvent("mouseup",this.#Te.mouseup,!0)}#je(){this.#J.ui.disableBackWrapper(),this.#Oh&&=this.#J.eventManager.removeGlobalEvent(this.#Oh),this.#Rh&&=this.#J.eventManager.removeGlobalEvent(this.#Rh)}async#De(t){t.preventDefault(),t.stopPropagation(),this.#J.ui.showLoading();try{const t=await this.inst.modalAction();!1===t?this.#J.ui.hideLoading():void 0===t?this.close():(this.close(),this.#J.ui.hideLoading())}catch(t){throw this.close(),this.#J.ui.hideLoading(),Error(`[SUNEDITOR.Modal[${this.kind}].warn] ${t.message}`)}}#Ph(t){const e=Pe.query.getEventTarget(t);(/close/.test(e.getAttribute("data-command"))||e===this.#Eh)&&this.close()}#zh(t){Fe.isEsc(t.code)&&this.close()}#Dh(t,e){this.#Bh=Pe.query.getEventTarget(e),Pe.utils.addClass(this.#Bh,"active"),this.#qe(this.#Ih=t+(this.#J.options.get("_rtl")?"RTL":""))}#Fh(t){switch(this.#Ih){case"w":case"wRTL":{const e=t.clientY-this.#Lh-this.#Th.offsetHeight;this.#Th.style.height=this.#Th.offsetHeight+e+"px";break}case"h":{const e=t.clientX-this.#Ah-this.#Th.offsetWidth;this.#Th.style.width=this.#Th.offsetWidth+e+"px";break}case"hRTL":{const e=this.#Ah-t.clientX;this.#Th.style.width=this.#Th.offsetWidth+e+"px";break}case"c":{const e=t.clientX-this.#Ah-this.#Th.offsetWidth,s=t.clientY-this.#Lh-this.#Th.offsetHeight;this.#Th.style.width=this.#Th.offsetWidth+e+"px",this.#Th.style.height=this.#Th.offsetHeight+s+"px";break}case"cRTL":{const e=this.#Ah-t.clientX,s=t.clientY-this.#Lh-this.#Th.offsetHeight;this.#Th.style.width=this.#Th.offsetWidth+e+"px",this.#Th.style.height=this.#Th.offsetHeight+s+"px";break}}this.#Wh(),this.inst.modalResize?.()}#Hh(){Pe.utils.removeClass(this.#Bh,"active"),this.#Bh=null,this.#je()}};function zl(t,e){const s=t.getAttribute(`data-se-${e}`);if(s)return s;const i=t.getAttribute(`data-${e}`);return i?(t.removeAttribute(`data-${e}`),t.setAttribute(`data-se-${e}`,i),i):null}const Pl=class{#J;constructor(t,e,s){this.#J=e,t.__fileManagement=this,this.kind=t.constructor.key||t.constructor.name,this.inst=t,this.query=s.query,this.loadEventName=s.loadEventName,this.actionEventName=s.actionEventName,this.infoList=[],this.infoIndex=0,this.uploadFileLength=0,this.__updateTags=[],this.apiManager=new Ur(this,e),this._resetInfo,this._checkInfo}upload(t,e,s,i,n){this.#J.ui.showLoading();let o=null;if("length"in s){o=new FormData;for(let t=0,e=s.length;t<e;t++)o.append("file-"+t,s[t]);this.uploadFileLength=s.length}else o=s.formData,this.uploadFileLength=s.size;this.apiManager.call({method:"POST",url:t,headers:e,data:o,callBack:i,errorCallBack:n})}async asyncUpload(t,e,s){this.#J.ui.showLoading();let i=null;if("length"in s){i=new FormData;for(let t=0,e=s.length;t<e;t++)i.append("file-"+t,s[t]);this.uploadFileLength=s.length}else i=s.formData,this.uploadFileLength=s.size;return await this.apiManager.asyncCall({method:"POST",url:t,headers:e,data:i})}setFileData(t,{name:e,size:s}){t&&(t.setAttribute("data-se-file-name",e),t.setAttribute("data-se-file-size",s+""))}getSize(){let t=0;for(let e=0,s=this.infoList.length;e<s;e++)t+=1*this.infoList[e].size;return t}_checkInfo(t){const e=[].slice.call(this.#J.frameContext.get("wysiwyg").querySelectorAll(this.query)),s=this.infoList;if(e.length===s.length){let t=!1;for(let i,n=0,o=s.length;n<o;n++)if(i=s[n],0===e.filter((function(t){return i.src===t.src&&i.index.toString()===zl(t,"index")})).length){t=!0;break}if(!t)return}const i=[],n=[];for(let t=0,e=s.length;t<e;t++)n[t]=s[t].index;for(this.__updateTags=e;e.length>0;){const t=e.shift();zl(t,"index")&&n.includes(Number(zl(t,"index")))?i.push(Number(zl(t,"index"))):(i.push(this.infoIndex),t.removeAttribute("data-se-index"),this.#Uh(t,null))}if(t&&this.loadEventName)this.#J.eventManager.triggerEvent(this.loadEventName,{infoList:s});else for(let t,e=0;e<s.length;e++){if(t=s[e].index,i.includes(t))continue;s.splice(e,1);const n={element:null,index:t,state:"delete",info:null,remainingFilesCount:0,pluginName:this.kind};this.actionEventName&&this.#J.eventManager.triggerEvent(this.actionEventName,n),this.#J.eventManager.triggerEvent("onFileManagerAction",{...n,pluginName:this.kind}),e--}}_resetInfo(){const t={element:null,state:"delete",info:null,remainingFilesCount:0,pluginName:this.kind};for(let e=0,s=this.infoList.length;e<s;e++)this.actionEventName&&this.#J.eventManager.triggerEvent(this.actionEventName,{...t,index:this.infoList[e].index,pluginName:this.kind}),this.#J.eventManager.triggerEvent("onFileManagerAction",{...t,index:this.infoList[e].index,pluginName:this.kind});this.infoList=[],this.infoIndex=0}#Vh(t){if(t>=0)for(let e=0,s=this.infoList.length;e<s;e++)if(t===this.infoList[e].index)return this.infoList.splice(e,1),void(this.actionEventName&&this.#J.eventManager.triggerEvent(this.actionEventName,{element:null,index:t,state:"delete",info:null,remainingFilesCount:0,pluginName:this.kind}))}#Uh(t,e){let s=Number(zl(t,"index")),i=null,n="";if(e||={name:zl(t,"file-name")||("string"==typeof t.src?t.src.split("/").pop():""),size:Number(zl(t,"file-size"))||0},s&&this.#J.store._editorInitFinished){n="update",s*=1;for(let t=0,e=this.infoList.length;t<e;t++)if(s===this.infoList[t].index){i=this.infoList[t];break}i||(s=this.infoIndex++,i={index:s},this.infoList.push(i)),i.src=t.src,i.name=zl(t,"file-name"),i.size=Number(zl(t,"file-size"))}else n="create",s=this.infoIndex++,t.setAttribute("data-se-index",s+""),t.setAttribute("data-se-file-name",e.name),t.setAttribute("data-se-file-size",e.size+""),i={src:t.src,index:s,name:e.name,size:e.size},this.infoList.push(i);i.element=t,i.delete=function(t,e){this.inst.componentDestroy?.(e),t(Number(zl(e,"index")))}.bind(this,this.#Vh.bind(this),t),i.select=function(t,e){e.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"});const s=t.get(e);s?t.select(s.target,s.pluginName):this.inst.componentSelect?.(e)}.bind(this,this.#J.component,t);const o={element:t,index:s,state:n,info:i,remainingFilesCount:--this.uploadFileLength<0?0:this.uploadFileLength,pluginName:this.kind};this.actionEventName&&this.#J.eventManager.triggerEvent(this.actionEventName,o),this.#J.eventManager.triggerEvent("onFileManagerAction",{...o,pluginName:this.kind})}},{_w:Dl,NO_EVENT:Fl}=Oe;const Hl=class{#J;#jh;#Gh;#Kh;#Yh;constructor(t,e,s){this.#J=t,this.openNewWindow=!!s.openNewWindow,this.relList=Array.isArray(s.relList)?s.relList:[],this.defaultRel=s.defaultRel||{},this.noAutoPrefix=!!s.noAutoPrefix,s.enableFileUpload&&(this.uploadUrl="string"==typeof s.uploadUrl?s.uploadUrl:null,this.uploadHeaders=s.uploadHeaders||null,this.uploadSizeLimit=De.get(s.uploadSizeLimit,0)||null,this.uploadSingleSizeLimit=De.get(s.uploadSingleSizeLimit,0)||null,this.input=Pe.utils.createElement("input",{type:"file",accept:s.acceptedFormats||"*"}),this.#J.eventManager.addEvent(this.input,"change",this.#Xh.bind(this)),this.fileManager=new Pl(this,t,{query:"a[download]:not([data-se-file-download])",loadEventName:"onFileLoad",actionEventName:"onFileAction"}));const i=function(t,e,s){const i=t.lang,n=t.icons,o=e.textToDisplay?"":'style="display: none;"',r=e.title?"":'style="display: none;"';let l=`\n\t\t<div class="se-modal-body">\n\t\t\t<div class="se-modal-form">\n\t\t\t\t<label>${i.link_modal_url}</label>\n\t\t\t\t<div class="se-modal-form-files">\n\t\t\t\t\t<input data-focus class="se-input-form se-input-url" type="text" placeholder="${t.options.get("defaultUrlProtocol")||""}" />\n\t\t\t\t\t${e.enableFileUpload?`<button type="button" class="se-btn se-tooltip se-modal-files-edge-button _se_upload_button" aria-label="${i.fileUpload}">\n\t\t\t\t\t\t\t\t\t${n.file_upload}\n\t\t\t\t\t\t\t\t\t${Pe.utils.createTooltipInner(i.fileUpload)}\n\t\t\t\t\t\t\t\t</button>`:""}\n\t\t\t\t\t<button type="button" class="se-btn se-tooltip se-modal-files-edge-button _se_bookmark_button" aria-label="${i.link_modal_bookmark}">\n\t\t\t\t\t\t${n.bookmark}\n\t\t\t\t\t\t${Pe.utils.createTooltipInner(i.link_modal_bookmark)}\n\t\t\t\t\t</button>\n\t\t\t\t</div>\n\t\t\t\t<div class="se-anchor-preview-form">\n\t\t\t\t\t<span class="se-svg se-anchor-preview-icon _se_anchor_bookmark_icon">${n.bookmark}</span>\n\t\t\t\t\t<span class="se-svg se-anchor-preview-icon _se_anchor_download_icon">${n.download}</span>\n\t\t\t\t\t<pre class="se-link-preview"></pre>\n\t\t\t\t</div>\n\t\t\t\t<label ${o}>${i.link_modal_text}</label>\n\t\t\t\t<input class="se-input-form _se_display_text" type="text" ${o} />\n\t\t\t\t<label ${r}>${i.title}</label>\n\t\t\t\t<input class="se-input-form _se_title" type="text" ${r} />\n\t\t\t</div>\n\t\t\t<div class="se-modal-form-footer">\n\t\t\t\t<label><input type="checkbox" class="se-modal-btn-check _se_anchor_check" /> ${i.link_modal_newWindowCheck}</label>\n\t\t\t\t<label><input type="checkbox" class="se-modal-btn-check _se_anchor_download" /> ${i.link_modal_downloadLinkCheck}</label>`;s.length>0&&(l+=`\n\t\t\t<div class="se-anchor-rel">\n\t\t\t\t<button type="button" class="se-btn se-tooltip se-anchor-rel-btn" title="${i.link_modal_relAttribute}" aria-label="${i.link_modal_relAttribute}">\n\t\t\t\t\t${n.link_rel}\n\t\t\t\t\t${Pe.utils.createTooltipInner(i.link_modal_relAttribute)}\n\t\t\t\t</button>\n\t\t\t\t<div class="se-anchor-rel-wrapper"><pre class="se-link-preview se-anchor-rel-preview"></pre></div>\n\t\t\t</div>\n\t\t</div>`);return l+="</div></div>",Pe.utils.createElement("DIV",null,l)}(t,s,this.relList);if(this.host=(Dl.location.origin+Dl.location.pathname).replace(/\/$/,""),this.urlInput=i.querySelector(".se-input-url"),this.displayInput=i.querySelector("._se_display_text"),this.titleInput=i.querySelector("._se_title"),this.newWindowCheck=i.querySelector("._se_anchor_check"),this.downloadCheck=i.querySelector("._se_anchor_download"),this.download=i.querySelector("._se_anchor_download_icon"),this.preview=i.querySelector(".se-link-preview"),this.bookmark=i.querySelector("._se_anchor_bookmark_icon"),this.bookmarkButton=i.querySelector("._se_bookmark_button"),this.currentRel=[],this.currentTarget=null,this.linkValue="",this.#Gh=this.relList.length>0,this.#Gh){this.relButton=i.querySelector(".se-anchor-rel-btn"),this.relPreview=i.querySelector(".se-anchor-rel-preview");const e=this.relList,s=(this.defaultRel.default||"").split(" "),n=[];for(let t,i=0,o=e.length;i<o;i++)t=e[i],n.push(Pe.utils.createElement("BUTTON",{type:"button",class:"se-btn-list"+(s.includes(t)?" se-checked":""),"data-command":t,title:t,"aria-label":t},t+'<span class="se-svg">'+this.#J.icons.checked+"</span>"));this.#Kh=new Ai(t,{checkList:!0,position:"right-middle",dir:"ltr"}),this.#Kh.on(this.relButton,this.#Zh.bind(this)),this.#Kh.create(n),this.#J.eventManager.addEvent(this.relButton,"click",this.#Jh.bind(this))}this.#jh=e,this.#jh.querySelector(".se-anchor-editor").appendChild(i),this.#Yh=new Ai(t,{checkList:!1,position:"bottom-left",dir:"ltr"}),this.#Yh.on(this.urlInput,this.#Qh.bind(this)),this.#J.eventManager.addEvent(this.newWindowCheck,"change",this.#tc.bind(this)),this.#J.eventManager.addEvent(this.downloadCheck,"change",this.#ec.bind(this)),this.#J.eventManager.addEvent(this.urlInput,"input",this.#sc.bind(this)),this.#J.eventManager.addEvent(this.urlInput,"focus",this.#ic.bind(this)),this.#J.eventManager.addEvent(this.bookmarkButton,"click",this.#nc.bind(this)),this.#J.eventManager.addEvent(i.querySelector("._se_upload_button"),"click",(()=>this.input.click()))}set(t){this.currentTarget=t}on(t){if(t){if(this.currentTarget){const t=this.currentTarget.href;this.linkValue=this.preview.textContent=this.urlInput.value=this.#oc(t)?t.substring(t.lastIndexOf("#")):t,this.displayInput.value=this.currentTarget.textContent,this.titleInput.value=this.currentTarget.title,this.newWindowCheck.checked=!!/_blank/i.test(this.currentTarget.target),this.downloadCheck.checked=!!this.currentTarget.download}}else this.init(),this.displayInput.value=this.#J.selection.get().toString().trim(),this.newWindowCheck.checked=this.openNewWindow,this.titleInput.value="";this.#rc(t&&this.currentTarget?this.currentTarget.rel:this.defaultRel.default||""),this.#lc(this.linkValue)}create(t,e){const s=this.linkValue||e||"";if(0===s.length)return null;const i=0===this.displayInput.value.length?s:this.displayInput.value,n=this.currentTarget||Pe.utils.createElement("A");return this.#ac(n,s,i,this.titleInput.value,t),this.linkValue=this.preview.textContent=this.urlInput.value=this.displayInput.value="",n}init(){this.currentTarget=null,this.linkValue=this.preview.textContent=this.urlInput.value="",this.displayInput.value="",this.newWindowCheck.checked=!1,this.downloadCheck.checked=!1,this.#rc(this.defaultRel.default||"")}#ac(t,e,s,i,n){!this.#oc(e)&&this.downloadCheck.checked?t.setAttribute("download",s||e):t.removeAttribute("download"),this.newWindowCheck.checked?t.target="_blank":t.removeAttribute("target");const o=this.currentRel.join(" ");o?t.rel=o:t.removeAttribute("rel"),t.href=e,i?t.title=i:t.removeAttribute("title"),n?0===t.children.length&&(t.textContent=""):t.textContent=s}#oc(t){const e=Dl.location.href.replace(/\/$/,"");return 0===t.indexOf("#")||0===t.indexOf(e)&&t.indexOf("#")===(e.includes("#")?e.substring(0,e.indexOf("#")).length:e.length)}#rc(t){if(!this.#Gh)return;const e=this.currentRel=t?t.split(" "):[],s=this.#Kh.form.querySelectorAll("button");for(let t,i=0,n=s.length;i<n;i++)t=s[i].getAttribute("data-command"),e.includes(t)?Pe.utils.addClass(s[i],"se-checked"):Pe.utils.removeClass(s[i],"se-checked");this.relPreview.title=this.relPreview.textContent=e.join(" "),e.length>0?Pe.utils.addClass(this.relButton,"on"):Pe.utils.removeClass(this.relButton,"on")}#hc(t){const e=Pe.query.getListChildren(this.#J.frameContext.get("wysiwyg"),(t=>/h[1-6]/i.test(t.nodeName)||Pe.check.isAnchor(t)&&!!t.id),null);if(0===e.length)return;const s=new RegExp(`^${t.replace(/^#/,"")}`,"i"),i=[],n=[];for(let t,o=0,r=e.length;o<r;o++)t=e[o],s.test(t.textContent)&&(i.push(t),n.push(Pe.check.isAnchor(t)?`<div><span class="se-text-prefix-icon">${this.#J.icons.bookmark_anchor}</span>${t.id}</div>`:`<div style="${t.style.cssText}">${t.textContent}</div>`));0===i.length?this.#Yh.close():(this.#Yh.create(i,n),this.#Yh.open(this.#J.options.get("_rtl")?"bottom-right":""))}#lc(t){const e=this.preview,s=this.#J.options.get("defaultUrlProtocol"),i=this.noAutoPrefix,n=/^(mailto:|tel:|sms:|https*:\/\/|#)/.test(t)||0===t.indexOf(s),o=!!s&&RegExp("^"+Re.escapeStringRegexp(t.substring(0,s.length))).test(s);t=this.linkValue=e.textContent=t?i?t:!s||n||o?n?t:/^www\./.test(t)?"http://"+t:this.host+(/^\//.test(t)?"":"/")+t:s+t:"",this.#oc(t)?(this.bookmark.style.display="block",Pe.utils.addClass(this.bookmarkButton,"active")):(this.bookmark.style.display="none",Pe.utils.removeClass(this.bookmarkButton,"active")),!this.#oc(t)&&this.downloadCheck.checked?this.download.style.display="block":this.download.style.display="none"}#cc(t){const e=this.currentRel;if(!t)return e.join(" ");if(/^only:/.test(t))return t=t.replace(/^only:/,"").trim(),this.currentRel=t.split(" "),t;const s=t.split(" ");for(let t=0,i=s.length;t<i;t++)e.includes(s[t])||e.push(s[t]);return e.join(" ")}#dc(t){if(!t)return this.currentRel.join(" ");/^only:/.test(t)&&(t=t.replace(/^only:/,"").trim());const e=this.currentRel.join(" ").replace(RegExp(t+"\\s*"),"");return this.currentRel=e.split(" "),e}#uc(t){const e=t.result[0];this.linkValue=this.preview.textContent=this.urlInput.value=e.url,this.displayInput.value=e.name,this.downloadCheck.checked=!0,this.download.style.display="block"}async#pc(t){const e=await this.#J.eventManager.triggerEvent("onFileUploadError",{error:t});if(!1===e)return;const s=e===Fl?t.errorMessage:e||t.errorMessage;this.#J.ui.alertOpen(s,"error"),console.error("[SUNEDITOR.plugin.fileUpload.error]",s)}#gc(t){const e=JSON.parse(t.responseText);e.errorMessage?this.#pc(e):this.#uc(e)}async#Xh(t){const e=Pe.query.getEventTarget(t).files;if(!e[0])return;const s={url:this.uploadUrl,uploadHeaders:this.uploadHeaders,files:e},i=async function(t,e,s){e=s||e;t(await this.fileManager.asyncUpload(e.url,e.uploadHeaders,e.files))}.bind(this,this.#gc.bind(this),s),n=await this.#J.eventManager.triggerEvent("onFileUploadBefore",{info:s,handler:i});return void 0===n||!1!==n&&(null!==n&&"object"==typeof n&&i(n),void(!0!==n&&n!==Fl||i(null)))}#Jh(){this.#Kh.open(this.#J.options.get("_rtl")?"left-middle":"")}#Qh(t){const e=t.id||"h_"+Math.random().toString().replace(/.+\./,"");t.id=e,this.urlInput.value="#"+e,this.#lc(this.urlInput.value),this.#Yh.close(),this.urlInput.focus()}#Zh(t){const e=t.getAttribute("data-command");if(!e)return;const s=this.currentRel,i=s.indexOf(e);-1===i?s.push(e):s.splice(i,1),this.relPreview.title=this.relPreview.textContent=s.join(", ")}#sc(t){const e=Pe.query.getEventTarget(t).value.trim();this.#lc(e),this.#oc(e)?this.#hc(e):this.#Yh.close()}#ic(){const t=this.urlInput.value;this.#oc(t)&&this.#hc(t)}#nc(){let t=this.urlInput.value;this.#oc(t)?(t=t.substring(1),this.bookmark.style.display="none",Pe.utils.removeClass(this.bookmarkButton,"active")):(t="#"+t,this.bookmark.style.display="block",Pe.utils.addClass(this.bookmarkButton,"active"),this.downloadCheck.checked=!1,this.download.style.display="none",this.#hc(t)),this.urlInput.value=t,this.#lc(t),this.urlInput.focus()}#tc(t){if("string"!=typeof this.defaultRel.check_new_window)return;Pe.query.getEventTarget(t).checked?this.#rc(this.#cc(this.defaultRel.check_new_window)):this.#rc(this.#dc(this.defaultRel.check_new_window))}#ec(t){Pe.query.getEventTarget(t).checked?(this.download.style.display="block",this.bookmark.style.display="none",Pe.utils.removeClass(this.bookmarkButton,"active"),this.linkValue=this.preview.textContent=this.urlInput.value=this.urlInput.value.replace(/^#+/,""),"string"==typeof this.defaultRel.check_bookmark&&this.#rc(this.#cc(this.defaultRel.check_bookmark))):(this.download.style.display="none","string"==typeof this.defaultRel.check_bookmark&&this.#rc(this.#dc(this.defaultRel.check_bookmark)))}},ql={init(t){return{create:(e,s)=>this.create(e,s,t)}},create(t,e,s){if("object"!=typeof e&&(e={}),s&&(e=[s,e].reduce(((t,e)=>(Object.entries(e).forEach((([e,s])=>{if("plugins"===e&&s&&t[e]){const i=Array.isArray(t[e])?t[e]:Object.values(t[e]),n=Array.isArray(s)?s:Object.values(s);t[e]=[...n.filter((t=>!i.includes(t))),...i]}else t[e]=s})),t)),{})),!t)throw Error('[SUNEDITOR.create.fail] The first parameter "target" is missing.');const i=[];if("string"==typeof t){const e=document.querySelector(t);if(!e)throw Error(`[SUNEDITOR.create.fail]-[document.querySelector(${t})] Cannot find target element. Make sure "${t}" is a valid selector and exists in the document.`);i.push({key:null,target:e})}else if(1===t.nodeType)i.push({key:null,target:t});else{let e;for(const s in t){if(e=t[s],!e.target||1!==e.target.nodeType)throw Error('[SUNEDITOR.create.fail] suneditor multi root requires textarea\'s element at the "target" property.');e.key=s,i.push(e)}}return new qr(i,e)}};class Wl extends Vn{static type="";static key="";static className="";static options={};constructor(t){super(t),this.title="",this.icon="",this.inner=null,this.beforeItem=null,this.afterItem=null,this.replaceButton=null}}class Ul extends Wl{static type="browser";open(t){throw new Error(`[${this.constructor.name}] Abstract method 'open()' must be implemented`)}close(){throw new Error(`[${this.constructor.name}] Abstract method 'close()' must be implemented`)}}class Vl extends Wl{static type="command";action(t){throw new Error(`[${this.constructor.name}] Abstract method 'action()' must be implemented`)}}class jl extends Wl{static type="dropdown";on(t){}action(t){throw new Error(`[${this.constructor.name}] Abstract method 'action()' must be implemented`)}}class Gl extends Wl{static type="dropdown-free";on(t){}off(){}}class Kl extends Wl{static type="field"}class Yl extends Wl{static type="input";toolbarInputKeyDown(t){}toolbarInputChange(t){}}class Xl extends Wl{static type="modal";open(t){throw new Error(`[${this.constructor.name}] Abstract method 'open()' must be implemented`)}}class Zl extends Wl{static type="popup";show(){throw new Error(`[${this.constructor.name}] Abstract method 'show()' must be implemented`)}}const Jl=class extends Vl{static key="blockquote";static className="";constructor(t){super(t),this.title=this.$.lang.tag_blockquote,this.icon="blockquote",this.quoteTag=Pe.utils.createElement("BLOCKQUOTE")}active(t,e){return/blockquote/i.test(t?.nodeName)?(Pe.utils.addClass(e,"active"),!0):(Pe.utils.removeClass(e,"active"),!1)}action(){const t=Pe.query.getParentElement(this.$.selection.getNode(),"blockquote");t?this.$.format.removeBlock(t,{selectedFormats:null,newBlockElement:null,shouldDelete:!1,skipHistory:!1}):this.$.format.applyBlock(this.quoteTag.cloneNode(!1))}},Ql=["javascript","typescript","html","css","json","python","java","c","cpp","csharp","go","rust","ruby","php","swift","kotlin","sql","bash","markdown","xml","yaml"];class ta extends Vl{static key="codeBlock";static className="";#mc;#fc;#vc;#bc;#yc;#wc;#Cc;#_c;#kc;constructor(t,e){if(super(t),this.title=this.$.lang.codeBlock||"Code Block",this.icon="code_block",this.#mc=Pe.utils.createElement("PRE"),this.#vc=e?.langs??Ql,!this.#vc.length)return;this.afterItem=Pe.utils.createElement("button",{class:"se-btn se-tooltip se-sub-arrow-btn",type:"button","data-command":ta.key,"data-type":"dropdown"},`${this.$.icons.arrow_down}<span class="se-tooltip-inner"><span class="se-tooltip-text">${this.$.lang.codeLanguage||"Language"}</span></span>`);const s=function(t,e){const s=t.lang.codeLanguage_none||"None";let i='<div class="se-list-inner"><ul class="se-list-basic">';i+=`<li><button type="button" class="se-btn se-btn-list" data-command="codeBlock" data-value="" title="${s}">${s}</button></li>`;for(const t of e)i+=`<li><button type="button" class="se-btn se-btn-list" data-command="codeBlock" data-value="${t}" title="${t}">${t}</button></li>`;return i+="</ul></div>",Pe.utils.createElement("DIV",{class:"se-dropdown se-list-layer se-list-code-block"},i)}(this.$,this.#vc);this.#fc=s.querySelectorAll("li button"),this.$.menu.initDropdownTarget({key:ta.key,type:"dropdown"},s);const i=Pe.utils.createElement("DIV",{class:"se-controller se-code-lang"});this.#bc=Pe.utils.createElement("DIV",{class:"se-code-lang-button"}),this.#xc(""),i.appendChild(this.#bc),this.#wc=new Ii(this,this.$,i,{position:"top",isWWTarget:!0}),this.#kc=ze.debounce((t=>{this.#_c=this.$.eventManager.removeEvent(this.#_c),t&&i.contains(t.relatedTarget)?this.#$c():this.#Sc()}),0),this.#yc=new Ai(this.$,{position:"bottom-right",dir:this.$.options.get("_rtl")?"rtl":"ltr",maxHeight:"214px",minWidth:"132px",closeMethod:this.#kc}),this.#yc.on(this.#bc,this.#Ec.bind(this)),this.#Tc(""),this.$.eventManager.addEvent(this.#bc,"click",(t=>{if(t.preventDefault(),t.stopPropagation(),this.#yc.isOpen)this.#yc.close();else{const t=this.#Mc(this.#Cc);this.#Tc(t);const e=this.#yc.items,s=t?e.indexOf(t):0;this.#yc.open(null,s>=0?`[data-index="${s}"]`:null)}}))}onMouseMove({event:t}){if(!this.#wc)return;const e=Pe.query.getEventTarget(t).closest("pre");e&&!this.#Nc()&&0===this.$.ui.opendControllers.length&&this.#Bc(e)}active(t,e){return/^PRE$/i.test(t?.nodeName)?(Pe.utils.addClass(e,"active"),!0):(Pe.utils.removeClass(e,"active"),!1)}action(t){const e=t?.getAttribute("data-value")||"",s=this.$.selection.getNode(),i=Pe.query.getParentElement(s,(t=>/^PRE$/i.test(t.nodeName)));if(i&&!e)this.$.format.setLine(Pe.utils.createElement(this.$.options.get("defaultLine")));else if(i||this.$.format.setBrLine(this.#mc.cloneNode(!1)),e){const t=Pe.query.getParentElement(this.$.selection.getNode(),(t=>/^PRE$/i.test(t.nodeName)));t&&this.#Ic(t,e)}this.$.menu.dropdownOff(),this.$.focusManager.focus(),this.$.history.push(!1)}on(){if(!this.#fc)return;const t=this.#Mc(this.$.selection.getNode());for(let e=0,s=this.#fc.length;e<s;e++){const s=this.#fc[e];Pe.utils.toggleClass(s,"active",s.getAttribute("data-value")===t)}}#Bc(t){this.#Cc===t&&this.#wc.isOpen||(this.#Cc&&this.#Cc!==t&&Pe.utils.removeClass(this.#Cc,"se-pre-code-focus"),this.#Cc=t,Pe.utils.addClass(t,"se-pre-code-focus"),this.#wc.open(t,null,{passive:!0,addOffset:{right:t.offsetWidth}}),this.#xc(this.#Mc(t)),this.#Lc())}#Sc(){this.#yc?.isOpen||this.#Ac()}#Ac(){this.#yc?.isOpen&&this.#yc.close(),Pe.utils.removeClass(this.#Cc,"se-pre-code-focus"),this.#wc.close(!0)}controllerClose(){this.#Cc&&(Pe.utils.removeClass(this.#Cc,"se-pre-code-focus"),this.#Cc=null)}#Ec(t){this.#Cc&&(this.#Ic(this.#Cc,t),this.#xc(t),this.#yc.close(),this.#Sc(),this.$.focusManager.focus(),this.$.history.push(!1))}#Lc(){this.#_c??=this.$.eventManager.addEvent(this.#Cc,"mouseleave",this.#kc)}#$c(){this.#_c??=this.$.eventManager.addEvent(this.#wc.form,"mouseleave",this.#kc)}#Tc(t){const e=this.$.lang.codeLanguage_none||"None",s=t&&!this.#vc.includes(t),i=s?["",t,...this.#vc]:["",...this.#vc],n=s?[e,t,...this.#vc]:[e,...this.#vc];this.#yc.create(i,n)}#xc(t){this.#bc.innerHTML=`<span class="se-code-lang-icon"></></span><span class="se-code-lang-text">${t||this.$.lang.codeLanguage||"Language"}</span>`}#Nc(){return this.#yc?.isOpen||this.#wc?.isOpen}#Mc(t){const e="PRE"===t?.nodeName?t:Pe.query.getParentElement(t,(t=>/^PRE$/i.test(t.nodeName)));return e&&e.className.match(/language-(\S+)/)?.[1]||""}#Ic(t,e){t.className=t.className.replace(/\s*language-\S+/g,"").trim(),e?(Pe.utils.addClass(t,"language-"+e),t.setAttribute("data-se-lang",e)):t.removeAttribute("data-se-lang")}destroy(){this.#Cc&&Pe.utils.removeClass(this.#Cc,"se-pre-code-focus"),this.#wc?.form?.parentNode?.removeChild(this.#wc.form),this.#Cc=null}}const ea=ta,{_w:sa,_d:ia}=Oe;const na=class extends Vl{static key="exportPDF";static className="se-component-enabled";constructor(t,e){super(t),this.title=this.$.lang.exportPDF,this.icon="PDF",this.apiUrl=e.apiUrl,this.fileName=e.fileName||"suneditor-pdf",this.apiUrl?this.apiManager=new Ur(this,this.$,{method:"POST",url:this.apiUrl,headers:{"Content-Type":"application/json"},responseType:"blob"}):console.warn('[SUNEDITOR.plugins.exportPDF.error] Requires exportPDF."apiUrl" options.')}async action(){if(!this.apiUrl)return void console.warn('[SUNEDITOR.plugins.exportPDF.error] Requires exportPDF."apiUrl" options.');this.$.ui.showLoading();let t=null;try{const e=this.$.frameContext.get("documentTypePageMirror")||this.$.frameContext.get("wysiwygFrame"),s=(this.$.options.get("_themeClass")||"").trim(),i=s?e.className.replace(s,"").trim():e.className,n=Pe.utils.createElement("div",{class:i},e.innerHTML);t=Pe.utils.createElement("div",{style:"position: absolute; top: -10000px; left: -10000px; width: 21cm; columns: 21cm; height: auto;"},n);const o=sa.getComputedStyle(e).padding,r=Pe.utils.applyInlineStylesAll(n,!0,this.$.options.get("allUsedStyles"));if(r.style.padding=r.style.paddingTop=r.style.paddingBottom=r.style.paddingLeft=r.style.paddingRight="0",t.innerHTML=`\n\t\t\t\t<style>\n\t\t\t\t\t@page {\n\t\t\t\t\t\tsize: A4;\n\t\t\t\t\t\tmargin: ${o};\n\t\t\t\t\t}\n\t\t\t\t</style>\n\t\t\t\t${r.outerHTML}`,ia.body.appendChild(t),!1===await this.$.eventManager.triggerEvent("onExportPDFBefore",{target:t}))return;return void await this.#Oc(t)}catch(t){console.error("[SUNEDITOR.plugins.exportPDF.error]",t.message)}finally{Pe.utils.removeItem(t),this.$.ui.hideLoading()}}async#Oc(t){const e={fileName:this.fileName,htmlContent:t.innerHTML},s=await this.apiManager.asyncCall({data:JSON.stringify(e)});if(200!==s.status){let t;try{t=JSON.parse(s.responseText).errorMessage}catch{}throw Error(`[SUNEDITOR.plugins.exportPDF.error] ${t||s.statusText}`)}const i=new Blob([s.response],{type:"application/pdf"}),n=s.getResponseHeader("Content-Disposition"),o=URL.createObjectURL(i),r=(n.match(/filename="([^"]+)/)||[])[1]||this.fileName+".pdf",l=Pe.utils.createElement("A",{href:o,download:r,style:"display: none;"},null);try{ia.body.appendChild(l),l.click()}finally{sa.setTimeout((()=>{Pe.utils.removeItem(l),URL.revokeObjectURL(o)}),100)}}},{NO_EVENT:oa}=Oe;class ra extends Vl{static key="fileUpload";static className="";static options={eventIndex:1e4};static component(t){return Pe.check.isAnchor(t)&&t.hasAttribute("data-se-file-download")?t:null}#Rc;#zc=null;constructor(t,e){super(t),this.title=this.$.lang.fileUpload,this.icon="file_upload",e.uploadUrl||console.warn('[SUNEDITOR.fileUpload.warn] "fileUpload" plugin must be have "uploadUrl" option.'),this.uploadUrl=e.uploadUrl,this.uploadHeaders=e.uploadHeaders,this.uploadSizeLimit=De.get(e.uploadSizeLimit,0),this.uploadSingleSizeLimit=De.get(e.uploadSingleSizeLimit,0),this.allowMultiple=!!e.allowMultiple,this.acceptedFormats="string"!=typeof e.acceptedFormats?"*":e.acceptedFormats.trim()||"*",this.as=e.as||"box",this.insertBehavior=e.insertBehavior,this.input=Pe.utils.createElement("input",{type:"file",accept:this.acceptedFormats}),this.allowMultiple&&this.input.setAttribute("multiple","multiple"),this.#Rc=this.acceptedFormats.split(", ");const s={"custom-download":{command:"download",title:this.$.lang.download,icon:"download",action:t=>{const e=t.getAttribute("href");e&&Pe.utils.createElement("A",{href:e},null).click()}},"custom-as":{command:"as",value:"link",title:this.$.lang.asLink,icon:"reduction",action:(t,e)=>{this.convertFormat(t,e)}}},i=(e.controls||[["custom-as","align","edit","custom-download","copy","remove"]]).map((t=>t.map((t=>t.startsWith("custom-")?s[t]:t))));if(this.figure=new ji(this,this.$,i,{}),this.fileManager=new Pl(this,this.$,{query:"a[download][data-se-file-download]",loadEventName:"onFileLoad",actionEventName:"onFileAction"}),/\bedit\b/.test(JSON.stringify(i))){const t=function({lang:t,icons:e}){const s=`\n\t\t<div class="se-arrow se-arrow-up"></div>\n\t\t<form>\n\t\t\t<div class="se-btn-group se-form-group">\n\t\t\t\t<input type="text" />\n\t\t\t\t<button type="submit" data-command="edit" class="se-btn se-tooltip se-btn-success">\n\t\t\t\t\t${e.checked}\n\t\t\t\t\t<span class="se-tooltip-inner"><span class="se-tooltip-text">${t.save}</span></span>\n\t\t\t\t</button>\n\t\t\t\t<button type="button" data-command="cancel" class="se-btn se-tooltip se-btn-danger">\n\t\t\t\t\t${e.cancel}\n\t\t\t\t\t<span class="se-tooltip-inner"><span class="se-tooltip-text">${t.cancel}</span></span>\n\t\t\t\t</button>\n\t\t\t</div>\n\t\t</form>\n\t\t`;return Pe.utils.createElement("DIV",{class:"se-controller se-controller-simple-input"},s)}(this.$);this.controller=new Ii(this,this.$,t,{position:"bottom",disabled:!0},ra.key),this.editInput=t.querySelector("input")}this.$.eventManager.addEvent(this.input,"change",this.#Xh.bind(this))}action(){this.$.store.set("_preventBlur",!0),this.input.click()}onFilePasteAndDrop({file:t}){const e=t.type;this.#Rc.some((t=>!!t.startsWith("*")||(!!t.startsWith(e)||void 0)))&&(this.submitFile([t]),this.$.focusManager.focus())}controllerAction(t){const e=t.getAttribute("data-command");if(e){if("edit"===e){if(0===this.editInput.value.trim().length)return;this.#zc.textContent=this.editInput.value}this.controller.close(),this.$.component.select(this.#zc,ra.key)}}componentSelect(t){this.#zc=t;const e=this.figure.controller.form.querySelector('[data-command="__c__as"]');if(e)return Pe.check.isFigure(t.parentElement)?(e.innerHTML=this.$.icons.reduction+Pe.utils.createTooltipInner(this.$.lang.asLink),e.setAttribute("data-value","link"),void this.figure.open(t,{nonResizing:!0,nonSizeInfo:!0,nonBorder:!0,figureTarget:!0,infoOnly:!1})):(e.innerHTML=this.$.icons.expansion+Pe.utils.createTooltipInner(this.$.lang.asBlock),e.setAttribute("data-value","box"),this.figure.controllerOpen(t,{isWWTarget:!0}),!0)}componentEdit(t){this.editInput.value=t.textContent,this.figure.controllerHide(),this.controller.open(t,null,{isWWTarget:!Pe.check.isFigure(t.parentElement),initMethod:null,addOffset:null}),this.editInput.focus()}async componentDestroy(t){if(!t)return;const e=ji.GetContainer(t),s=Pe.query.getParentElement(t,".se-component")||t;if(!1===await this.$.eventManager.triggerEvent("onFileDeleteBefore",{element:e.target,container:e,url:e.target.getAttribute("href")}))return;const i=this.$.component.isInline(s)?s.previousSibling||s.nextSibling:s.previousElementSibling||s.nextElementSibling;Pe.utils.removeItem(s),this.$.ui.offCurrentController(),this.$.focusManager.focusEdge(i),this.$.history.push(!1)}async submitFile(t){if(0===t.length)return;let e=0;const s=[],i=this.uploadSingleSizeLimit;for(let n,o,r=0,l=t.length;r<l;r++){if(n=t[r],o=n.size,i>0&&o>i){const t="[SUNEDITOR.fileUpload.fail] Size of uploadable single file: "+i/1e3+"KB",e=await this.$.eventManager.triggerEvent("onFileUploadError",{error:t,limitSize:i,uploadSize:o,file:n});return this.$.ui.alertOpen(e===oa?t:e||t,"error"),!1}s.push(n),e+=o}const n=this.uploadSizeLimit,o=this.fileManager.getSize();if(n>0&&e+o>n){const t="[SUNEDITOR.fileUpload.fail] Size of uploadable total files: "+n/1e3+"KB",s=await this.$.eventManager.triggerEvent("onFileUploadError",{error:t,limitSize:n,currentSize:o,uploadSize:e});return this.$.ui.alertOpen(s===oa?t:s||t,"error"),!1}const r={url:this.uploadUrl,uploadHeaders:this.uploadHeaders,files:s},l=async function(t,e,s){e=s||e;t(await this.fileManager.asyncUpload(e.url,e.uploadHeaders,e.files))}.bind(this,this.#gc.bind(this),r),a=await this.$.eventManager.triggerEvent("onFileUploadBefore",{info:r,handler:l});return void 0===a||!1!==a&&(null!==a&&"object"==typeof a&&l(a),void(!0!==a&&a!==oa||l(null)))}convertFormat(t,e){if("link"===e){this.figure.close();const{container:e}=ji.GetContainer(t),s=e.nextElementSibling,i=e.parentElement;t.removeAttribute("data-se-non-focus"),t.setAttribute("contenteditable","false"),Pe.utils.addClass(t,"se-component|se-inline-component");const n=Pe.utils.createElement(this.$.options.get("defaultLine"),null,t);i.insertBefore(n,s),Pe.utils.removeItem(e)}else{this.$.selection.setRange(t,0,t,1);const e=this.$.html.remove(),s=this.$.nodeTransform.split(e.container,e.offset,0);s?.previousElementSibling&&Pe.check.isZeroWidth(s.previousElementSibling)&&Pe.utils.removeItem(s.previousElementSibling),t.setAttribute("data-se-non-focus","true"),t.removeAttribute("contenteditable"),Pe.utils.removeClass(t,"se-component|se-component-selected|se-inline-component");const i=ji.CreateContainer(t,"se-file-figure se-flex-component");(s||e.container).parentElement.insertBefore(i.container,s)}this.$.history.push(!1),this.$.component.select(t,ra.key)}create(t,e,s){const i=e.name||t,n=Pe.utils.createElement("A",{href:t,title:i,download:i,"data-se-file-download":"",contenteditable:"false","data-se-non-focus":"true","data-se-non-link":"true"},i);if(this.fileManager.setFileData(n,e),"link"===this.as)return n.className="se-component se-inline-component",void this.$.component.insert(n,{scrollTo:!!s,insertBehavior:s?this.insertBehavior:null});const o=ji.CreateContainer(n);if(Pe.utils.addClass(o.container,"se-file-figure|se-flex-component"),this.$.component.insert(o.container,{scrollTo:!!s,insertBehavior:s?this.insertBehavior:null})){if(s)if(this.$.options.get("componentInsertBehavior"))this.$.component.select(n,ra.key);else{const t=this.$.format.addLine(o.container,null);t&&this.$.selection.setRange(t,0,t,0)}}else this.$.focusManager.focus()}#uc(t){t.result.forEach(((t,e,s)=>{this.create(t.url,{name:t.name,size:t.size},e===s.length-1)}))}async#pc(t){const e=await this.$.eventManager.triggerEvent("onFileUploadError",{error:t});if(!1===e)return;const s=e===oa?t.errorMessage:e||t.errorMessage;this.$.ui.alertOpen(s,"error"),console.error("[SUNEDITOR.plugin.fileUpload.error]",s)}#gc(t){const e=JSON.parse(t.responseText);e.errorMessage?this.#pc(e):this.#uc(e)}async#Xh(t){const e=Pe.query.getEventTarget(t);await this.submitFile(e.files)}}const la=ra;class aa extends Vl{static key="list_bulleted";static className="se-icon-flip-rtl";#Pc;constructor(t){super(t),this.title=this.$.lang.bulletedList,this.icon="list_bulleted",this.afterItem=Pe.utils.createElement("button",{class:"se-btn se-tooltip se-sub-arrow-btn",type:"button","data-command":aa.key,"data-type":"dropdown"},`${this.$.icons.arrow_down}<span class="se-tooltip-inner"><span class="se-tooltip-text">${this.$.lang.bulletedList}</span></span>`);const e=function(){const t=`\n\t<div class="se-list-inner">\n\t\t<ul class="se-list-basic se-list-horizontal se-list-carrier">\n\t\t\t${e=["disc","circle","square"],e.map((t=>`\n\t\t\t<li>\n\t\t\t\t<button type="button" class="se-btn se-btn-list se-icon-flip-rtl" data-command="${t}" title="${t}" aria-label="${t}">\n\t\t\t\t\t<ul style="list-style-type: ${t};">\n\t\t\t\t\t\t<li></li><li></li><li></li>\n\t\t\t\t\t</ul>\n\t\t\t\t</button>\n\t\t\t</li>\n\t\t`)).join("")}\n\t\t</ul>\n\t</div>`;var e;return Pe.utils.createElement("DIV",{class:"se-dropdown se-list-layer"},t)}();this.#Pc=e.querySelectorAll("li button ul"),this.$.menu.initDropdownTarget({key:aa.key,type:"dropdown"},e)}active(t,e){return Pe.check.isListCell(t)&&/^UL$/i.test(t.parentElement.nodeName)?(Pe.utils.addClass(e,"active"),!0):(Pe.utils.removeClass(e,"active"),!1)}action(t){const e=this.$.format.getBlock(this.$.selection.getNode()),s=t?.querySelector("ul")?.style.listStyleType;Pe.check.isList(e)&&s?e.style.listStyleType=s:this.submit(s),this.$.menu.dropdownOff()}on(){const t=this.#Pc,e=this.$.format.getBlock(this.$.selection.getNode()),s=e?.style?e.style.listStyleType||"disc":"";for(let e,i=0,n=t.length;i<n;i++)e=t[i],s===e.style.listStyleType?Pe.utils.addClass(e.parentElement,"active"):Pe.utils.removeClass(e.parentElement,"active")}shortcut({range:t,info:e}){const{startContainer:s}=t;if(Pe.check.isText(s)){const t=s.substringData(e.key.length,s.textContent.length-1);s.textContent=t}this.submit()}submit(t){const e=this.$.listFormat.apply(`ul:${t||""}`,null,!1);e&&this.$.selection.setRange(e.sc,e.so,e.ec,e.eo),this.$.focusManager.focus(),this.$.history.push(!1)}}const ha=aa;class ca extends Vl{static key="list_numbered";static className="se-icon-flip-rtl";#Pc;constructor(t){super(t),this.title=this.$.lang.numberedList,this.icon="list_numbered",this.afterItem=Pe.utils.createElement("button",{class:"se-btn se-tooltip se-sub-arrow-btn",type:"button","data-command":ca.key,"data-type":"dropdown"},`${this.$.icons.arrow_down}<span class="se-tooltip-inner"><span class="se-tooltip-text">${this.$.lang.numberedList}</span></span>`);const e=function(){const t=`\n\t<div class="se-list-inner">\n\t\t<ul class="se-list-basic se-list-horizontal se-list-carrier">\n\t\t\t${da(["decimal","upper-roman","lower-roman"])}\n\t\t</ul>\n\t\t<ul class="se-list-basic se-list-horizontal se-list-carrier">\n\t\t${da(["lower-latin","upper-latin","lower-greek"])}\n\t\t</ul>\n\t</div>`;return Pe.utils.createElement("DIV",{class:"se-dropdown se-list-layer"},t)}();this.#Pc=e.querySelectorAll("li button ol"),this.$.menu.initDropdownTarget({key:ca.key,type:"dropdown"},e)}active(t,e){return Pe.check.isListCell(t)&&/^OL$/i.test(t.parentElement.nodeName)?(Pe.utils.addClass(e,"active"),!0):(Pe.utils.removeClass(e,"active"),!1)}action(t){const e=this.$.format.getBlock(this.$.selection.getNode()),s=t?.querySelector("ol")?.style.listStyleType;Pe.check.isList(e)&&s?e.style.listStyleType=s:this.submit(s),this.$.menu.dropdownOff()}on(){const t=this.#Pc,e=this.$.format.getBlock(this.$.selection.getNode()),s=e?.style?e.style.listStyleType||"decimal":"";for(let e,i=0,n=t.length;i<n;i++)e=t[i],s===e.style.listStyleType?Pe.utils.addClass(e.parentElement,"active"):Pe.utils.removeClass(e.parentElement,"active")}shortcut({range:t,info:e}){const{startContainer:s}=t;if(Pe.check.isText(s)){const t=s.substringData(e.key.length,s.textContent.length-1);s.textContent=t}this.submit()}submit(t){const e=this.$.listFormat.apply(`ol:${t||""}`,null,!1);e&&this.$.selection.setRange(e.sc,e.so,e.ec,e.eo),this.$.focusManager.focus(),this.$.history.push(!1)}}function da(t){return t.map((t=>`\n\t\t\t<li>\n\t\t\t\t<button type="button" class="se-btn se-btn-list se-icon-flip-rtl" data-command="${t}" title="${t}" aria-label="${t}">\n\t\t\t\t\t<ol style="list-style-type: ${t};">\n\t\t\t\t\t\t<li></li><li></li><li></li>\n\t\t\t\t\t</ol>\n\t\t\t\t</button>\n\t\t\t</li>\n\t\t`)).join("")}const ua=ca,{debounce:pa}=ze;function ga(t){return`<div class="se-autocomplete-item"><span>${t.key}</span>${t.name?`<span>${t.name}</span>`:""}</div>`}function ma(t,e){return{tag:"span",attrs:{"data-se-autocomplete":e+t.key},text:e+t.key}}const fa=class extends Kl{static key="autocomplete";static className="";#Dc=0;#Fc=0;#Hc=null;#qc=null;constructor(t,e){super(t);const s=e.limitSize||5,i=e.searchStartLength||0,n="number"==typeof e.delayTime?e.delayTime:120,o=e.useCachingData??!0,r=e.useCachingFieldData??!0;this.triggerContexts=new Map;const l=e.triggers||{};for(const[t,e]of Object.entries(l)){const n=e.limitSize??s;this.triggerContexts.set(t,{trigger:t,limitSize:n,searchStartLength:e.searchStartLength??i,directData:e.data||null,apiUrl:e.apiUrl?.replace(/\s/g,"").replace(/\{limitSize\}/i,String(n))||"",apiHeaders:e.apiHeaders||null,transformResponse:e.transformResponse||null,renderItem:e.renderItem||ga,onSelect:e.onSelect||ma,apiManager:e.apiUrl?new Ur(this,this.$,{headers:e.apiHeaders}):null,cachingData:e.useCachingData??o?new Map:null,cachingFieldData:e.useCachingFieldData??r?[]:null})}this.sortedTriggers=[...this.triggerContexts.keys()].sort(((t,e)=>e.length-t.length));const a=Pe.utils.createElement("DIV",{class:"se-controller se-empty-controller"},"<div></div>");this.selectMenu=new Ai(this.$,{position:"right-bottom",dir:"ltr",closeMethod:()=>this.controller.close()}),this.controller=new Ii(this,this.$,a,{position:"bottom",initMethod:()=>{this.#Wc(),this.selectMenu.close()}},null),this.selectMenu.on(a.firstElementChild,this.#Uc.bind(this)),this.onInput=pa(this.onInput.bind(this),n)}#Wc(){this.#qc?.apiManager&&this.#qc.apiManager.cancel()}async onInput(){this.#Wc();const t=this.$.selection.get();if(!t.rangeCount)return void this.selectMenu.close();const e=t.anchorNode,s=t.anchorOffset,i=e.textContent.substring(0,s);for(const t of this.sortedTriggers){const n=i.lastIndexOf(t);if(-1===n)continue;const o=i.substring(n+t.length,s),r=i[n-1]?.trim();if(!/\s/.test(o)&&(!r||Pe.check.isZeroWidth(r))){const i=this.triggerContexts.get(t);if(o.length<i.searchStartLength)return;const r=e.parentNode;if(Pe.check.isAnchor(r)&&!r.getAttribute("data-se-autocomplete"))return;try{return this.#qc=i,await this.#Vc(i,o,e),this.#Dc=n,this.#Hc=e,void(this.#Fc=s)}catch(t){console.warn("[SUNEDITOR.autocomplete.api] ",t)}}}this.selectMenu.close()}async#Vc(t,e,s){const i=t.limitSize,n=e.toLowerCase();let o=null;if(t.cachingData&&(o=t.cachingData.get(e)),!o)if(t.directData)o=t.directData.filter((t=>t.key.toLowerCase().startsWith(n))).slice(0,i);else{const s=await t.apiManager.asyncCall({method:"GET",url:this.#jc(t,e)}),i=JSON.parse(s.responseText);o=t.transformResponse?t.transformResponse(i,s):i}if(t.cachingFieldData){const e=new Set;o=t.cachingFieldData.concat(o).filter((({key:t})=>!e.has(t)&&(e.add(t),t.toLowerCase().startsWith(n)))).slice(0,i)}if(!o?.length)return this.selectMenu.close(),!1;const r=[],l=[];for(let e,s=0,i=o.length;s<i;s++)e=o[s],r.push(e),l.push(t.renderItem(e,t.trigger));return this.controller.open(s,null,{isWWTarget:!0,initMethod:null,addOffset:null}),this.selectMenu.create(r,l),this.selectMenu.open(),this.selectMenu.setItem(0),t.cachingData&&t.cachingData.set(e,r),!0}#jc(t,e){return t.apiUrl.replace(/\{key\}/i,e)}#Uc(t){if(!t)return!1;const e=this.#qc;if(!e)return!1;const s=e.onSelect(t,e.trigger);let i=null;const n=this.#Hc.parentNode;if("string"==typeof s){if(this.$.selection.setRange(this.#Hc,this.#Dc,this.#Hc,this.#Fc),i=Pe.utils.createTextNode(s),!this.$.html.insertNode(i,{afterNode:null,skipCharCount:!1}))return!1}else{let t;if(s?.nodeType)t=s;else{if(!s?.tag)return!1;t=Pe.utils.createElement(s.tag.toUpperCase(),s.attrs||{},s.text||"")}if(n.getAttribute?.("data-se-autocomplete")){for(const t of[...n.attributes])n.removeAttribute(t.name);for(const e of[...t.attributes])n.setAttribute(e.name,e.value);n.textContent=t.textContent,i=n}else{if(this.$.selection.setRange(this.#Hc,this.#Dc,this.#Hc,this.#Fc),!this.$.html.insertNode(t,{afterNode:null,skipCharCount:!1}))return!1;i=t}}this.selectMenu.close();const o=Pe.utils.createTextNode(" ");i.parentNode.insertBefore(o,i.nextSibling),this.$.selection.setRange(o,1,o,1),e.cachingFieldData&&!e.cachingFieldData.some((e=>e.key===t.key))&&e.cachingFieldData.push(t)}},{debounce:va}=ze;const ba=class extends Kl{static key="slashCommand";static className="";#Gc;#Kc;#Yc;#na;#Dc=0;#Fc=0;#Hc=null;#Xc=!1;constructor(t,e){super(t),this.#Gc="string"==typeof e.triggerChar&&e.triggerChar.length>0?e.triggerChar:"/",this.#Kc="number"==typeof e.limitSize&&e.limitSize>0?e.limitSize:1/0,this.#Yc="string"==typeof e.emptyMessage?e.emptyMessage:"";const s="number"==typeof e.delayTime?e.delayTime:120;this.#na=new gn(this,this.$,{items:Array.isArray(e.items)?e.items:[],resolveButton:us,renderCustomItem:"function"==typeof e.renderItem?e.renderItem:null,prepareCommit:()=>this.#Zc(),selectMenuParams:{position:"bottom-left",dir:"ltr",minWidth:"string"==typeof e.minWidth?e.minWidth:"200px",maxHeight:"string"==typeof e.maxHeight?e.maxHeight:"320px",closeMethod:()=>this.#Jc()}});const i=Pe.utils.createElement("DIV",{class:"se-controller se-empty-controller"},"<div></div>");this.controller=new Ii(this,this.$,i,{position:"bottom",escGuard:()=>this.#na.hasOpenSubPanel()},null),this.#na.attach(i.firstElementChild,this.#Uc.bind(this),{class:"se-block-action-menu se-slash-command-menu"}),this.onInput=va(this.onInput.bind(this),s)}onKeyDown({event:t}){Fe.isEsc(t.code)&&this.onInput.cancel?.()}onInput(){if(0===this.#na.getItems().length)return;const t=this.$.selection.get();if(!t.rangeCount)return void this.#Qc();const e=t.anchorNode,s=t.anchorOffset;if(!e||"string"!=typeof e.textContent)return void this.#Qc();const i=e.textContent.substring(0,s),n=this.#Gc,o=i.lastIndexOf(n);if(-1===o)return void this.#Qc();const r=i.substring(o+n.length,s);if(/\s/.test(r))return void this.#Qc();const l=i[o-1];if(l&&""!==l.trim()&&!Pe.check.isZeroWidth(l))return void this.#Qc();const a=this.#na.filter(r,this.#Kc);0!==a.length?(this.controller.open(e,null,{isWWTarget:!0,initMethod:null,addOffset:null}),this.#na.createRows(a),this.#na.open(),this.#na.setItem(0),this.#td(e,o,s)):this.#Yc?(this.#ed(e),this.#td(e,o,s)):this.#Qc()}open(t){if(!t)return!1;const e=this.#na.filter("",this.#Kc);return 0!==e.length&&(this.controller.open(t,null,{isWWTarget:!0,initMethod:null,addOffset:null}),this.#na.createRows(e),this.#na.open(),this.#na.setItem(0),this.#td(t,0,0),!0)}#Qc(){this.#Xc=!0,this.#na.close(),this.#Xc=!1}#Jc(){this.#Xc||this.#Zc(),this.#Hc=null,this.controller.close()}#Zc(){const t=this.#Hc;if(!t||!t.parentNode)return;if(t.textContent?.[this.#Dc]!==this.#Gc)return;this.$.selection.setRange(t,this.#Dc,t,this.#Fc);const e=this.$.selection.getRange();e&&!e.collapsed&&this.$.html.remove()}#td(t,e,s){this.#Hc=t,this.#Dc=e,this.#Fc=s}#ed(t){this.controller.open(t,null,{isWWTarget:!0,initMethod:null,addOffset:null}),this.#na.selectMenu.create([null],[`<span class="se-slash-empty">${this.#Yc}</span>`]),this.#na.open()}#Uc(t){if(!t)return!1;const e=this.#Hc;if(!e)return!1;const s=this.#Gc,i=(e.textContent||"").substring(this.#Dc+s.length,this.#Fc);if("dropdownFree"!==t.kind)return this.#Zc(),this.#Qc(),void this.#na.dispatch(t,{triggerChar:s,query:i,item:t.raw});const n=this.#na.hasOpenSubPanel();this.#na.dispatch(t,{triggerChar:s,query:i,item:t.raw}),n||this.#na.hasOpenSubPanel()||this.#Qc()}};class ya extends jl{static key="align";static className="";constructor(t,e){super(t),this.title=this.$.lang.align,this.icon=this.$.options.get("_rtl")?"align_right":"align_left",this.defaultDir="",this.alignIcons={justify:this.$.icons.align_justify,left:this.$.icons.align_left,right:this.$.icons.align_right,center:this.$.icons.align_center};const s=this.$.menu.initDropdownTarget(ya,function({lang:t,icons:e,options:s},i){return(Array.isArray(i)?i:s.get("_rtl")?["right","center","left","justify"]:["left","center","right","justify"]).map((s=>{const i=t["align"+s.charAt(0).toUpperCase()+s.slice(1)];return{command:s,title:i,innerHTML:`<span class="se-list-icon">${e["align_"+s]}</span>${i}`}}))}(this.$,e.items),{className:"se-list-align"});this._itemMenu=s.querySelector("ul"),this.alignList=s.querySelectorAll("li button")}active(t,e){const s=e.firstElementChild;if(t){if(this.$.format.isLine(t)){const i=t.style.textAlign;return i?(Pe.utils.changeElement(s,this.alignIcons[i]||this.alignIcons[this.defaultDir]),e.setAttribute("data-focus",i),!0):void 0}}else Pe.utils.changeElement(s,this.alignIcons[this.defaultDir]),e.removeAttribute("data-focus");return!1}on(t){const e=t.getAttribute("data-focus")||this.defaultDir;if(!e)return;const s=this.alignList;for(let t=0,i=s.length;t<i;t++)e===s[t].getAttribute("data-command")?Pe.utils.addClass(s[t],"active"):Pe.utils.removeClass(s[t],"active")}action(t){const e=t.getAttribute("data-command");if(!e)return;const s=this.defaultDir,i=this.$.format.getLines();for(let t=0,n=i.length;t<n;t++)Pe.utils.setStyle(i[t],"textAlign",e===s?"":e);this.$.store.set("_lastSelectionNode",null),this.$.menu.dropdownOff(),this.$.focusManager.focus(),this.$.history.push(!1)}setDir(){const t=this.#sd();if(this.defaultDir===t)return;this.defaultDir=t;const e=this._itemMenu.querySelector('[data-command="left"]'),s=this._itemMenu.querySelector('[data-command="right"]');if(e&&s){const t=e.parentElement,i=s.parentElement;t.appendChild(s),i.appendChild(e)}}init(){this.defaultDir=this.#sd()}#sd(){const t=this.$.frameContext.get("wwComputedStyle").getPropertyValue("text-align");return["left","center","right","justify"].includes(t)?t:this.$.options.get("_rtl")?"right":"left"}}const wa=ya;class Ca extends jl{static key="font";static className="se-btn-select se-btn-tool-font";#id;constructor(t,e){super(t),this.title=this.$.lang.font,this.inner='<span class="se-txt">'+this.$.lang.font+"</span>"+this.$.icons.arrow_down;const s=e.items||["Arial","Comic Sans MS","Courier New","Impact","Georgia","tahoma","Trebuchet MS","Verdana"],i=`<li><button type="button" class="se-btn se-btn-list default_value" data-command="" title="${this.$.lang.default}" aria-label="${this.$.lang.default}">${this.$.lang.default}</button></li><li class="se-btn-list se-sub-list"><span></span></li>`,n=this.$.menu.initDropdownTarget(Ca,function(t){return t.map((t=>{const e=t.split(",")[0];return{command:t,title:e,innerHTML:e,attrs:{"data-txt":e,style:`font-family:${t};`}}}))}(s),{className:"se-list-font-family",prependHTML:i});this.currentFont="",this.fontList=n.querySelectorAll("ul li button"),this.fontArray=s,this.#id=n.querySelector(".se-sub-list span")}active(t,e){const s=e.querySelector(".se-txt"),i=e.parentNode.querySelector(".se-tooltip-text");let n="";if(t){if(this.$.format.isLine(t))return;if(n=Pe.utils.getStyle(t,"fontFamily")){const t=n.replace(/["']/g,"");return Pe.utils.changeTxt(s,t),Pe.utils.changeTxt(i,this.$.lang.font+" ("+t+")"),!0}}else{const t=this.$.store.get("hasFocus")?this.$.frameContext.get("wwComputedStyle").fontFamily:this.$.lang.font;Pe.utils.changeTxt(s,t),Pe.utils.changeTxt(i,this.$.store.get("hasFocus")?this.$.lang.font+(t?" ("+t+")":""):t)}return!1}on(t){const e=this.fontList,s=t.querySelector(".se-txt").textContent;if(s!==this.currentFont){let t=!1;for(let i=0,n=e.length;i<n;i++)s===(e[i].getAttribute("data-command")||"").replace(/'|"/g,"")?(Pe.utils.addClass(e[i],"active"),t=!0):Pe.utils.removeClass(e[i],"active");this.currentFont=s,t?this.#id.style.display="none":(this.#id.textContent=s,this.#id.style.display="block")}}async action(t){let e=t.getAttribute("data-command");if(e){if(/[\s\d\W]/.test(e)&&!/^['"].*['"]$/.test(e)&&(e=`"${e}"`),!1===await this.$.eventManager.triggerEvent("onFontActionBefore",{value:e}))return;const t=Pe.utils.createElement("SPAN",{style:"font-family: "+e+";"});this.$.inline.apply(t,{stylesToModify:["font-family"],nodesToRemove:null,strictRemove:null})}else this.$.inline.apply(null,{stylesToModify:["font-family"],nodesToRemove:["span"],strictRemove:!0});this.$.menu.dropdownOff()}}const _a=Ca;class ka extends Gl{static key="fontColor";static className="";constructor(t,e){super(t),this.title=this.$.lang.fontColor,this.icon="font_color";const s=Pe.utils.createElement("DIV",{class:"se-dropdown se-list-layer"},null);this.colorPicker=new Ll(this,this.$,"color",{form:s,colorList:e.items,splitNum:e.splitNum,disableHEXInput:e.disableHEXInput,hueSliderOptions:{controllerOptions:{isOutsideForm:!0}}}),this.$.menu.initDropdownTarget(ka,s)}active(t,e){const s=e.querySelector(".se-svg-color-helper");if(!s)return;let i="";if(t){if(this.$.format.isLine(t))return;if(i=Pe.utils.getStyle(t,"color"))return s.style.color=i,!0}else s.style.color=i;return!1}on(t){this.colorPicker.init(this.$.selection.getNode(),t,(t=>this.$.format.isLine(t)))}off(){this.colorPicker.hueSliderClose()}colorPickerAction(t){if(t){const e=Pe.utils.createElement("SPAN",{style:"color: "+t+";"});this.$.inline.apply(e,{stylesToModify:["color"],nodesToRemove:null,strictRemove:null})}else this.$.inline.apply(null,{stylesToModify:["color"],nodesToRemove:["span"],strictRemove:!0});this.$.menu.dropdownOff()}}const xa=ka;class $a extends Gl{static key="backgroundColor";static className="";constructor(t,e){super(t),this.title=this.$.lang.backgroundColor,this.icon="background_color";const s=Pe.utils.createElement("DIV",{class:"se-dropdown se-list-layer"},null);this.colorPicker=new Ll(this,this.$,"backgroundColor",{form:s,colorList:e.items,splitNum:e.splitNum,disableHEXInput:e.disableHEXInput,hueSliderOptions:{controllerOptions:{isOutsideForm:!0}}}),this.$.menu.initDropdownTarget($a,s)}active(t,e){const s=e.querySelector("path.se-svg-color-helper");if(!s)return;let i="";if(t){if(this.$.format.isLine(t))return;if(i=Pe.utils.getStyle(t,"backgroundColor"))return s.style.color=i,!0}else s.style.color=i;return!1}on(t){this.colorPicker.init(this.$.selection.getNode(),t,(t=>this.$.format.isLine(t)))}off(){this.colorPicker.hueSliderClose()}colorPickerAction(t){if(t){const e=Pe.utils.createElement("SPAN",{style:"background-color: "+t+";"});this.$.inline.apply(e,{stylesToModify:["background-color"],nodesToRemove:null,strictRemove:null})}else this.$.inline.apply(null,{stylesToModify:["background-color"],nodesToRemove:["span"],strictRemove:!0});this.$.menu.dropdownOff()}}const Sa=$a;class Ea extends jl{static key="hr";static className="";static component(t){return/^hr$/i.test(t?.nodeName)?t:null}constructor(t,e){super(t),this.title=this.$.lang.horizontalLine,this.icon="horizontal_line";const s=this.$.menu.initDropdownTarget(Ea,function({lang:t},e){return(e||[{name:t.hr_solid,class:"__se__solid",style:null},{name:t.hr_dashed,class:"__se__dashed",style:null},{name:t.hr_dotted,class:"__se__dotted",style:null}]).map((t=>({command:"hr",title:t.name,innerHTML:`<hr${t.class?` class="${t.class}"`:""}${t.style?` style="${t.style}"`:""}/>`})))}(this.$,e.items),{className:"se-list-line"});this.list=s.querySelectorAll("button")}componentSelect(t){Pe.utils.addClass(t,"on")}componentDeselect(t){Pe.utils.removeClass(t,"on")}componentDestroy(t){if(!t)return;const e=t.previousElementSibling||t.nextElementSibling;Pe.utils.removeItem(t),this.$.focusManager.focusEdge(e),this.$.history.push(!1)}shortcut({line:t,range:e}){const s=this.$.nodeTransform.split(e.endContainer,e.endOffset,0);this.submit("__se__solid"),Pe.utils.removeItem(t),this.$.selection.setRange(s,0,s,0)}action(t){const e=this.submit(t.firstElementChild.className),s=this.$.format.addLine(e);this.$.selection.setRange(s,1,s,1),this.$.menu.dropdownOff()}submit(t){const e=Pe.utils.createElement("hr",{class:t});return this.$.focusManager.focus(),this.$.component.insert(e,{insertBehavior:"line"}),e}}const Ta=Ea;class Ma extends jl{static key="list";static className="se-icon-flip-rtl";#Pc;#nd;constructor(t){super(t),this.title=this.$.lang.list,this.icon="list_numbered",this.#nd={bulleted:this.$.icons.list_bulleted,numbered:this.$.icons.list_numbered};const e=this.$.menu.initDropdownTarget(Ma,function({lang:t,icons:e}){return[{command:"ol",title:t.numberedList,innerHTML:e.list_numbered,className:"se-tooltip se-icon-flip-rtl"},{command:"ul",title:t.bulletedList,innerHTML:e.list_bulleted,className:"se-tooltip se-icon-flip-rtl"}]}(this.$));this.#Pc=e.querySelectorAll("li button")}active(t,e){const s=e.firstElementChild;if(Pe.check.isList(t)){const i=t.nodeName.toLowerCase();return e.setAttribute("data-focus",i),Pe.utils.addClass(e,"active"),/^ul$/.test(i)?Pe.utils.changeElement(s,this.#nd.bulleted):Pe.utils.changeElement(s,this.#nd.numbered),!0}return e.removeAttribute("data-focus"),Pe.utils.changeElement(s,this.#nd.numbered),Pe.utils.removeClass(e,"active"),!1}on(t){const e=t.getAttribute("data-focus")||"",s=this.#Pc;for(let t=0,i=s.length;t<i;t++)e===s[t].getAttribute("data-command")?Pe.utils.addClass(s[t],"active"):Pe.utils.removeClass(s[t],"active")}action(t){const e=t.getAttribute("data-command"),s=t.getAttribute("data-value")||"",i=this.$.listFormat.apply(`${e}:${s}`,null,!1);i&&this.$.selection.setRange(i.sc,i.so,i.ec,i.eo),this.$.menu.dropdownOff(),this.$.history.push(!1)}}const Na=Ma,Ba=[3,3],Ia=".se-table-resize-line",La=".se-table-resize-line-prev",Aa=".se-table-resize-row",Oa=".se-table-resize-row-prev",Ra=["none","solid","dotted","dashed","double","groove","ridge","inset","outset"],za={all:"border_all",inside:"border_inside",horizon:"border_horizontal",vertical:"border_vertical",outside:"border_outside",left:"border_left",top:"border_top",right:"border_right",bottom:"border_bottom",none:"border_none"},Pa=["all","inside","horizon","vertical"],Da="borderLeft",Fa="borderTop",Ha="borderRight",qa="borderBottom",Wa=["#bbf7d0","#fde68a","#fecaca","#e9d5ff","#bfdbfe","#22c55e","#eab308","#ef4444","#a855f7","#3b82f6","#15803d","#ca8a04","#b91c1c","#7e22ce","#1d4ed8","#e5e7eb","#9ca3af","#6b7280","#374151","#000000"],Ua={physical_cellCnt:0,logical_cellCnt:0,cellCnt:0,rowCnt:0,rowIndex:0,physical_cellIndex:0,logical_cellIndex:0,current_colSpan:0,current_rowSpan:0,isShiftPressed:!1,ref:null,figureElement:null,selectedTable:null,trElement:null,trElements:null,tdElement:null,fixedCell:null,selectedCell:null,selectedCells:null},{_w:Va}=Oe,ja=new WeakMap,Ga=new WeakMap;function Ka(t){return/^(TD|TH|TR)$/i.test(t?.nodeName)}function Ya(t){return/^CAPTION$/i.test(t.nodeName)}function Xa(t,e){const s=t.clientX,i=De.get(Va.getComputedStyle(e).width,0),n=e.getBoundingClientRect(),o=Math.round(s-n.left),r=o<=6;return{is:r||i-o<=6,isLeft:r,startX:s}}function Za(t,e){const s=t.clientY,i=De.get(Va.getComputedStyle(e).height,0),n=e.getBoundingClientRect();return{is:Math.ceil(i+n.top-s)<=6,startY:s}}function Ja(t,e){return`<${t=t.toLowerCase()}><div><br></div></${t}>`.repeat(e)}function Qa(t){return t=t.toLowerCase(),Pe.utils.createElement(t,null,"<div><br></div>")}function th(t,e,s){let i=Ga.get(t);return i||(i=function(t){const e=[],s=t.rows,i=[];for(let t=0,n=s.length;t<n;t++){const n=s[t].cells;e[t]=[];let o=0;for(let s=0,r=n.length;s<r;s++){for(;i[t]?.[o];)o++;e[t][s]=o;const r=n[s],l=r.colSpan||1,a=r.rowSpan||1;if(a>1)for(let e=1;e<a;e++){i[t+e]||(i[t+e]=[]);for(let s=0;s<l;s++)i[t+e][o+s]=!0}o+=l}}return e}(t),Ga.set(t,i)),i[e]?.[s]??0}function eh(t,e){const s=Pe.utils.clone(t,!0),i=Array.from(t.querySelectorAll("td, th")),n=Array.from(s.querySelectorAll("td, th"));return{clonedTable:s,clonedSelectedCells:e.map((t=>{const e=i.indexOf(t);return e>-1?n[e]:null})).filter((t=>null!==t))}}function sh(t){t&&(ja.delete(t),Ga.delete(t))}function ih(t,e,s){const i=[];let n="";for(const o in za){if(s.includes(o))continue;const r=za[o];i.push(o),n+=`\n\t\t\t<button type="button" class="se-btn se-tooltip">\n\t\t\t\t${e[r]}\n\t\t\t\t<span class="se-tooltip-inner">\n\t\t\t\t\t<span class="se-tooltip-text">${t[r]}</span>\n\t\t\t\t</span>\n\t\t\t</button>`}return{items:i,menus:Pe.utils.createElement("DIV",null,n).querySelectorAll("button")}}const nh=class{#od;#J;#I;constructor(t,{mergeButton:e,unmergeButton:s,splitButton:i,openCellMenuFunc:n,closeCellMenuFunc:o}){this.#od=t,this.#J=t.$,this.#I=t.state,this.mergeButton=e,this.unmergeButton=s,this.splitButton=i;const r=(l=this.#J.lang,{items:["vertical","horizontal"],menus:Pe.utils.createElement("DIV",null,`\n\t\t<div title="${l.verticalSplit}" aria-label="${l.verticalSplit}">\n\t\t\t${l.verticalSplit}\n\t\t</div>\n\t\t<div title="${l.horizontalSplit}" aria-label="${l.horizontalSplit}">\n\t\t\t${l.horizontalSplit}\n\t\t</div>`).querySelectorAll("div")});var l;this.selectMenu_split=new Ai(this.#J,{checkList:!1,position:"bottom-center",openMethod:n,closeMethod:o}),this.selectMenu_split.on(this.splitButton,this._OnSplitCells.bind(this)),this.selectMenu_split.create(r.items,r.menus)}get#rd(){return this.#od.selectionService}openSplitMenu(){this.selectMenu_split.open()}mergeCells(t,e=!1){const s=t[0].closest("table");sh(s);const{clonedTable:i,clonedSelectedCells:n}=e?{clonedTable:s,clonedSelectedCells:t}:eh(s,t);this.#od.setTableInfo(i),t=n,this.#od.setState("ref",null),this.#rd.setMultiCells(t[0],Pe.query.findVisualLastCell(t));const o=this.#I.ref,r=t[0];let l=null,a=null;const h=o.ce-o.cs+1;let c=o.re-o.rs+1,d="",u=null;for(let e,s,i=1,n=t.length;i<n;i++){e=t[i],u!==e.parentNode&&(u=e.parentNode),s=e.children;for(let t=0,e=s.length;t<e;t++)this.#J.format.isLine(s[t])&&Pe.check.isZeroWidth(s[t].textContent)&&Pe.utils.removeItem(s[t]);d+=e.innerHTML,Pe.utils.removeItem(e),0===u.cells.length&&(l?a=u:l=u,c-=1)}if(l){const t=this.#I.trElements,e=Pe.utils.getArrayIndex(t,l),s=Pe.utils.getArrayIndex(t,a||l),i=[];for(let n,o=0;o<=s;o++)if(n=t[o].cells,0!==n.length)for(let t,i,r=0,l=n.length;r<l;r++)t=n[r],i=t.rowSpan-1,i>0&&o+i>=e&&(t.rowSpan-=De.getOverlapRangeAtIndex(e,s,o,o+i));else i.push(t[o]);for(let t=0,e=i.length;t<e;t++)Pe.utils.removeItem(i[t])}r.innerHTML+=d,r.colSpan=h,r.rowSpan=c,e||(s.replaceWith(i),this.#od._closeTableSelectInfo(),this.#od._setController(r),this.#rd.focusCellEdge(r),this.#rd.initCellSelection(r),this.#od.setState("ref",null),this.#od.setState("selectedCells",[r]),this.#od.setCellInfo(r,!0),this.setUnMergeButton(),this.setMergeSplitButton(),this.#od.historyPush())}unmergeCells(t,e=!1){if(!t?.length)return;const s=t[0].closest("table");sh(s);const{clonedTable:i,clonedSelectedCells:n}=e?{clonedTable:s,clonedSelectedCells:t}:eh(s,t);this.#od.setState("ref",null),this.#od.setTableInfo(i);let o=(t=n)[0],r=Pe.query.findVisualLastCell(t),l=null;const a=o.closest("table"),h=a.rows;for(const e of t){const t=e.parentElement.rowIndex,s=e.cellIndex,i=e.rowSpan,n=e.colSpan;if(1===i&&1===n)continue;this.#od.setCellInfo(e,!0);const a=e.innerHTML;e.remove();for(let c=0;c<i;c++){const i=h[t+c];for(let t=0;t<n;t++){const n=Qa("td");0===c&&0===t?(o===e&&(o=n),r===e&&(r=n),n.innerHTML=a,i.insertBefore(n,i.cells[s])):(i.insertBefore(n,i.cells[s+t]),l=n)}}}this.#od.setState("selectedCells",null),e||(s.replaceWith(i),this.#od._closeTableSelectInfo(),this.#od.setTableInfo(i),o!==r?(r=!l||r.closest("tr").rowIndex>l.closest("tr").rowIndex||r.cellIndex>l.cellIndex?r:l,this.#rd.setMultiCells(o,r),this.#od.setState("selectedCells",Array.from(a.querySelectorAll(".se-selected-table-cell")))):this.#od.setCellInfo(r,!0),this.#rd.initCellSelection(o),this.#od.setState("selectedCell",r),this.setUnMergeButton(),this.#od.controller_cell.resetPosition(r),this.#od.historyPush())}findMergedCells(t){const e=[];return t?.forEach((t=>{t&&(t.rowSpan>1||t.colSpan>1)&&e.push(t)})),e}setMergeSplitButton(){this.#I.ref?(this.splitButton.style.display="none",this.mergeButton.style.display="block"):(this.splitButton.style.display="block",this.mergeButton.style.display="none")}setUnMergeButton(){const t=this.findMergedCells(this.#I.selectedCells?.length?this.#I.selectedCells:[this.#I.fixedCell]).length>0;this.unmergeButton.style.display=t?"block":"none"}_OnSplitCells(t){sh(this.#od._element);const e="vertical"===t,s=this.#I.tdElement,i=this.#I.trElements,n=this.#I.trElement,o=this.#I.logical_cellIndex,r=this.#I.rowIndex,l=Qa(s.nodeName);if(e){const t=s.colSpan;if(l.rowSpan=s.rowSpan,t>1)l.colSpan=Math.floor(t/2),s.colSpan=t-l.colSpan,n.insertBefore(l,s.nextElementSibling);else{let e=[],r=[];for(let n,l,a=0,h=this.#I.rowCnt;a<h;a++){n=i[a].cells,l=0;for(let i,h,c,d,u=0,p=n.length;u<p;u++){if(i=n[u],h=i.colSpan-1,c=i.rowSpan-1,d=u+l,r.length>0)for(let t,e=0;e<r.length;e++)t=r[e],t.row>a||(d>=t.index?(l+=t.cs,d+=t.cs,t.rs-=1,t.row=a+1,t.rs<1&&(r.splice(e,1),e--)):u===p-1&&(t.rs-=1,t.row=a+1,t.rs<1&&(r.splice(e,1),e--)));if(d<=o&&c>0&&e.push({index:d,cs:h+1,rs:c,row:-1}),i!==s&&d<=o&&d+h>=o+t-1){i.colSpan+=1;break}if(d>o)break;l+=h}r=r.concat(e).sort((function(t,e){return t.index-e.index})),e=[]}n.insertBefore(l,s.nextElementSibling)}}else{const t=s.rowSpan;if(l.colSpan=s.colSpan,t>1){l.rowSpan=Math.floor(t/2);const e=t-l.rowSpan,r=[],a=Pe.utils.getArrayIndex(i,n)+e;for(let t,e,s=0;s<a;s++){t=i[s].cells,e=0;for(let i,n,l,h=0,c=t.length;h<c&&(l=h+e,!(l>=o));h++)i=t[h],n=i.rowSpan-1,n>0&&n+s>=a&&l<o&&r.push({index:l,cs:i.colSpan}),e+=i.colSpan-1}const h=i[a],c=h.cells;let d=r.shift();for(let t,e,s,i,n=0,a=c.length,u=0;n<a;n++){if(s=n+u,t=c[n],e=t.colSpan-1,i=s+e+1,d&&i>=d.index&&(u+=d.cs,i+=d.cs,d=r.shift()),i>=o||n===a-1){h.insertBefore(l,t.nextElementSibling);break}u+=e}s.rowSpan=e}else{l.rowSpan=s.rowSpan;const t=Pe.utils.createElement("TR");t.appendChild(l);for(let t,e=0;e<r;e++){if(t=i[e].cells,0===t.length)return;for(let s=0,i=t.length;s<i;s++)e+t[s].rowSpan-1>=r&&(t[s].rowSpan+=1)}const e=this.#I.physical_cellIndex,o=n.cells;for(let t=0,s=o.length;t<s;t++)t!==e&&(o[t].rowSpan+=1);n.parentNode.insertBefore(t,n.nextElementSibling)}}this.selectMenu_split.close(),this.#rd.focusCellEdge(s),this.#rd.deleteStyleSelectedCells(),this.#J.history.push(!1),this.#od._setController(s),this.#od.setState("selectedCell",s),this.#od.setState("fixedCell",s),this.#I.selectedCells?.length||this.#od.setState("selectedCells",[s])}};const oh=class{#od;#I;constructor(t){this.#od=t,this.#I=t.state}get#rd(){return this.#od.selectionService}get#ld(){return this.#od.gridService}get#ad(){return this.#od.cellService}copySelectedTableCells(t,e,s){t.preventDefault(),t.stopPropagation();const i=s[0].closest("table"),n=i.cloneNode(!1),o=Pe.utils.createElement("tbody");n.appendChild(o);const r=new Map;s.forEach((t=>{r.set(t,!0)}));const l=i.rows,a=l.length,h=Array.from(l[0].cells).reduce(((t,e)=>t+(e.colSpan||1)),0),c=Array.from({length:a},(()=>Array(h).fill(null)));for(let t=0;t<a;t++){const e=l[t].cells;for(let s=0,n=e.length;s<n;s++){const n=th(i,t,s),o=e[s],r=o.rowSpan||1,l=o.colSpan||1;for(let e=0;e<r;e++)for(let s=0;s<l;s++)c[t+e][n+s]=o}}for(let t=0;t<a;t++){let e;for(let s=0;s<h;s++){const i=c[t][s];if(!i||!r.has(i))continue;if(e||(e=Pe.utils.createElement("tr"),o.appendChild(e)),e.lastChild&&c[t][s-1]===i)continue;if(t>0&&c[t-1][s]===i)continue;const n=i.cloneNode(!0);let l=1,d=1;for(;t+l<a&&c[t+l][s]===i;)l++;for(;s+d<h&&c[t][s+d]===i;)d++;l>1&&(n.rowSpan=l),d>1&&(n.colSpan=d),e.appendChild(n)}}const d=Pe.utils.createElement("figure");d.className=e.className,d.appendChild(n);const u=`<html><body>\x3c!--StartFragment--\x3e${d.outerHTML}\x3c!--EndFragment--\x3e</body></html>`;t.clipboardData.setData("text/html",u)}pasteTableCellMatrix(t,e){if(!t||!e)return;sh(e.closest("table"));const s=t.rows;let i=0;const n=[];for(let t=0;t<s.length;t++){const e=s[t].cells;let o=0;for(let s=0;s<e.length;s++){const r=e[s];for(;n[t]?.[o];)o++;const l=r.rowSpan||1,a=r.colSpan||1;0===o&&(i+=l);for(let e=0;e<l;e++)for(let s=0;s<a;s++)n[t+e]||(n[t+e]=[]),n[t+e][o+s]=!0;o+=a}}let o=0;for(let t=0,e=s[0].cells,i=e.length;t<i;t++){o+=e[t].colSpan||1}const r={rowCnt:i,logicalCellCnt:o};this.#rd.deleteStyleSelectedCells();const l=e.closest("table"),{clonedTable:a,clonedSelectedCells:h}=eh(l,[e]),c=a;e=h[0];let d=c.rows;this.#od.setTableInfo(c),this.#od.setCellInfo(e,!0);const u={physicalCellCnt:this.#I.physical_cellCnt,logicalCellCnt:this.#I.logical_cellCnt,rowCnt:this.#I.rowCnt,rowIndex:this.#I.rowIndex,physicalCellIndex:this.#I.physical_cellIndex,logicalCellIndex:this.#I.logical_cellIndex,currentColSpan:this.#I.current_colSpan,currentRowSpan:this.#I.current_rowSpan},p=r.rowCnt-(u.rowCnt-(u.rowIndex+1))-1,g=r.logicalCellCnt-(u.logicalCellCnt-(u.logicalCellIndex+1))-1;if(u.rowCnt+=p,u.logicalCellCnt+=g,u.physicalCellCnt+=g,p>0||g>0){const t=d[d.length-1],e=t.cells[t.cells.length-1];for(let t=0;t<p;t++)this.#ld.editRow("down",e);for(let t=0;t<g;t++)this.#ld.editColumn("right",e);this.#od.setState("trElements",d=c.rows)}const m=u.rowIndex,f=u.logicalCellIndex,v=f+r.logicalCellCnt-1,b=[],y=[];for(let t=0,e=m+r.rowCnt;t<e;t++){const e=d[t]?.cells;if(!e)continue;let s=0,i=0;for(let n=0;n<e.length;n++){for(;y[t]?.[s];)s++;const n=e[i++];if(!n)break;const o=n.colSpan||1,r=n.rowSpan||1,l=s,a=s+o-1;if(r>1||o>1)for(let e=1;e<r;e++){const i=t+e;y[i]||=[];for(let t=0;t<o;t++)y[i][s+t]=!0}l<=v&&a>=f&&(o>1||r>1)&&b.push(n),s+=o}}b.length>0&&(this.#ad.unmergeCells(b,!0),this.#od.setState("trElements",d=c.rows));const w=[],C=[],_=[];for(let t=0,e=r.rowCnt;t<e;t++){const e=s[t]?.cells;if(!e)break;let i=0;for(let s=0;s<e.length;s++){const n=e[s],o=n.colSpan||1,r=n.rowSpan||1;for(;C[t]?.[i];)i++;for(let e=1;e<r;e++){const s=t+e;C[s]||=[];for(let t=0;t<o;t++)C[s][i+t]=!0}if(o<=1&&r<=1){i+=o;continue}const l=i+u.logicalCellIndex,a=l+o-1,h=[];for(let e=u.rowIndex+t,s=e+r,i=0;e<s;e++,i++){const t=d[e].cells;let s=0,i=0;for(;i<t.length&&s<=a;){for(;_[e]?.[s];)s++;const n=t[i++],o=n.colSpan||1,r=n.rowSpan||1,c=s,d=s+o-1;if(r>1)for(let t=1;t<r;t++){const i=e+t;_[i]||=[];for(let t=0;t<o;t++)_[i][s+t]=!0}d>=l&&c<=a&&h.push(n),s+=o}}h.length>0&&w.push(h),i+=o}}if(w.length>0){for(const t of w)this.#od.setState("ref",null),this.#od.setState("trElements",c.rows),this.#ad.mergeCells(t,!0);this.#od.setState("trElements",d=c.rows)}const k=[],x=[];for(let t=0;t<r.rowCnt;t++){const e=d[u.rowIndex+t],i=s[t];if(!e||!i)break;const n=e.cells,o=i.cells;let r=0,l=0,a=0;for(;l<n.length&&a<o.length&&r<=v;){for(;x[t]?.[r];)r++;const e=n[l++],s=o[a];if(!e||!s)break;const i=e.colSpan||1,h=e.rowSpan||1;if(h>1)for(let e=1;e<h;e++){const s=t+e;x[s]||=[];for(let t=0;t<i;t++)x[s][r+t]=!0}r>=f&&r+i-1<=v&&(e.innerHTML=s.innerHTML,k.push(e),a++),r+=i}}return l.replaceWith(c),this.#od._closeTableSelectInfo(),this.#od.setTableInfo(c),this.#ad.setMergeSplitButton(),this.#ad.setUnMergeButton(),this.#rd.focusCellEdge(k[0]),this.#od.historyPush(),k}};const rh=class{#od;#J;#I;constructor(t,{columnButton:e,rowButton:s,openCellMenuFunc:i,closeCellMenuFunc:n}){this.#od=t,this.#J=t.$,this.#I=t.state;const o=(r=this.#J.lang,l=this.#J.icons,{items:["insert-left","insert-right","delete"],menus:Pe.utils.createElement("DIV",null,`\n\t\t<div title="${r.insertColumnBefore}" aria-label="${r.insertColumnBefore}">\n\t\t\t<span class="se-list-icon">${l.insert_column_left}</span><span class="se-txt">${r.insertColumnBefore}</span>\n\t\t</div>\n\t\t<div title="${r.insertColumnAfter}" aria-label="${r.insertColumnAfter}">\n\t\t\t<span class="se-list-icon">${l.insert_column_right}</span><span class="se-txt">${r.insertColumnAfter}</span>\n\t\t</div>\n\t\t<div title="${r.deleteColumn}" aria-label="${r.deleteColumn}">\n\t\t\t<span class="se-list-icon">${l.delete_column}</span><span class="se-txt">${r.deleteColumn}</span>\n\t\t</div>`).querySelectorAll("div")});var r,l;this.selectMenu_column=new Ai(this.#J,{checkList:!1,position:"bottom-center",openMethod:i,closeMethod:n}),this.selectMenu_column.on(e,this.#hd.bind(this)),this.selectMenu_column.create(o.items,o.menus);const a=function(t,e){return{items:["insert-above","insert-below","delete"],menus:Pe.utils.createElement("DIV",null,`\n\t\t<div title="${t.insertRowAbove}" aria-label="${t.insertRowAbove}">\n\t\t\t<span class="se-list-icon">${e.insert_row_above}</span><span class="se-txt">${t.insertRowAbove}</span>\n\t\t</div>\n\t\t<div title="${t.insertRowBelow}" aria-label="${t.insertRowBelow}">\n\t\t\t<span class="se-list-icon">${e.insert_row_below}</span><span class="se-txt">${t.insertRowBelow}</span>\n\t\t</div>\n\t\t<div title="${t.deleteRow}" aria-label="${t.deleteRow}">\n\t\t\t<span class="se-list-icon">${e.delete_row}</span><span class="se-txt">${t.deleteRow}</span>\n\t\t</div>`).querySelectorAll("div")}}(this.#J.lang,this.#J.icons);this.selectMenu_row=new Ai(this.#J,{checkList:!1,position:"bottom-center",openMethod:i,closeMethod:n}),this.selectMenu_row.on(s,this.#cd.bind(this)),this.selectMenu_row.create(a.items,a.menus)}get#rd(){return this.#od.selectionService}openColumnMenu(){this.selectMenu_column.open()}openRowMenu(){this.selectMenu_row.menus[0].style.display=this.selectMenu_row.menus[1].style.display=/^TH$/i.test(this.#I.tdElement?.nodeName)?"none":"",this.selectMenu_row.open()}editTable(t,e){const s=this.#od._element,i="row"===t;if(i){const t=this.#I.trElement.parentElement;if(/^THEAD$/i.test(t.nodeName)){if("up"===e)return;if(!t.nextElementSibling||!/^TBODY$/i.test(t.nextElementSibling.nodeName))return void(e?s.innerHTML+="<tbody><tr>"+Ja("td",this.#I.logical_cellCnt)+"</tr></tbody>":(Pe.utils.removeItem(this.#I.figureElement),this.#od._closeTableSelectInfo()))}}if(this.#I.ref){const t=this.#I.tdElement,s=this.#I.selectedCells;if(i)if(e)this.#od.setCellInfo("up"===e?s[0]:s.at(-1),!0),this.editRow(e,null,t);else{let t=s[0].parentNode;const i=[s[0]];for(let e,n=1,o=s.length;n<o;n++)e=s[n],t!==e.parentNode&&(i.push(e),t=e.parentNode);for(let t=0,s=i.length;t<s;t++)this.#od.setCellInfo(i[t],!0),this.editRow(e)}else{const i=s[0].parentNode;if(e){let n=null;for(let t=0,e=s.length-1;t<e;t++)if(i!==s[t+1].parentNode){n=s[t];break}this.#od.setCellInfo("left"===e?s[0]:n||s[0],!0),this.editColumn(e,null,t)}else{const t=[s[0]];for(let e,n=1,o=s.length;n<o&&(e=s[n],i===e.parentNode);n++)t.push(e);for(let s=0,i=t.length;s<i;s++)this.#od.setCellInfo(t[s],!0),this.editColumn(e)}}e||this.#od.resetInfo()}else this[i?"editRow":"editColumn"](e);if(!e){const t=s.children;for(let e=0;e<t.length;e++)0===t[e].children.length&&(Pe.utils.removeItem(t[e]),e--);0===s.children.length&&Pe.utils.removeItem(s)}}editColumn(t,e,s){e&&this.#od.setCellInfo(e,!0);const i=!t,n="left"===t,o=this.#I.current_colSpan,r=this.#I.logical_cellIndex+(i||n?0:o+1),l=this.#I.trElements;let a,h=[],c=[],d=0;const u=[],p=[];for(let t,e,s,n,g,m=0,f=this.#I.rowCnt;m<f;m++){t=l[m],a=r,n=!1,e=t.cells,g=0;for(let t,s,l,f,v=0,b=e.length;v<b&&(t=e[v],t);v++)if(s=t.rowSpan-1,l=t.colSpan-1,i){if(f=v+g,c.length>0){const t=!e[v+1];for(let e,s=0;s<c.length;s++)e=c[s],e.row>m||(f>=e.index?(g+=e.cs,f=v+g,e.rs-=1,e.row=m+1,e.rs<1&&(c.splice(s,1),s--)):t&&(e.rs-=1,e.row=m+1,e.rs<1&&(c.splice(s,1),s--)))}s>0&&h.push({rs:s,cs:l+1,index:f,row:-1}),f>=a&&f+l<=a+o?u.push(t):f<=a+o&&f+l>=a?t.colSpan-=De.getOverlapRangeAtIndex(r,r+o,f,f+l):s>0&&(f<a||f+l>a+o)&&p.push({cell:t,i:m,rs:m+s}),g+=l}else{if(v>=a)break;if(l>0){if(d<1&&l+v>=a){t.colSpan+=1,a=null,d=s+1;break}a-=l}if(!n){for(let t,e=0;e<c.length;e++)t=c[e],a-=t.cs,t.rs-=1,t.rs<1&&(c.splice(e,1),e--);n=!0}}if(c=c.concat(h).sort((function(t,e){return t.index-e.index})),h=[],!i){if(d>0){d-=1;continue}null!==a&&e.length>0&&(s=Qa(e[0].nodeName),s=t.insertBefore(s,e[a]))}}const g=this.#od._element.querySelector("colgroup");if(g){const t=g.querySelectorAll("col");if(i)Pe.utils.removeItem(t[a]);else{if(!(!Pe.utils.hasClass(this.#od._element,"se-table-layout-fixed")&&"fixed"!==this.#od._element.style.tableLayout)&&Array.prototype.some.call(t,(t=>De.get(t.style.width)>0))){let e=0;for(let s,i=0,n=t.length;i<n;i++)s=De.get(t[i].style.width),s-=Math.round(s*n*.1/2),e+=s,t[i].style.width=`${s}%`;const s=Pe.utils.createElement("col",{style:`width:${100-e}%`});g.insertBefore(s,t[a])}else g.insertBefore(Pe.utils.createElement("col"),t[a]||null)}}if(i){let t,e;for(let s,i=0,n=u.length;i<n;i++)s=u[i].parentNode,Pe.utils.removeItem(u[i]),0===s.cells.length&&(t||=Pe.utils.getArrayIndex(l,s),e=Pe.utils.getArrayIndex(l,s),Pe.utils.removeItem(s));for(let s,i=0,n=p.length;i<n;i++)s=p[i],s.cell.rowSpan=De.getOverlapRangeAtIndex(t,e,s.i,s.rs);this.#od._closeController()}else this.#od._setCellControllerPosition(s||this.#I.tdElement,!0);return s||this.#I.tdElement}editRow(t,e,s){this.#rd.deleteStyleSelectedCells(),e&&this.#od.setCellInfo(e,!0);const i=!t,n="up"===t,o=this.#I.rowIndex,r=i||n?o:o+this.#I.current_rowSpan+1,l=i?-1:1,a=this.#I.trElements;let h=this.#I.logical_cellCnt;for(let t,e=0,s=o+(i?-1:0);e<=s;e++){if(t=a[e].cells,0===t.length)return;for(let s,i,n=0,o=t.length;n<o;n++)s=t[n].rowSpan,i=t[n].colSpan,s<2&&i<2||s+e>r&&r>e&&(t[n].rowSpan=s+l,h-=i)}if(i){const t=a[o+1];if(t){const e=[];let s=a[o].cells,i=0;for(let t,n,o=0,r=s.length;o<r;o++)t=s[o],n=o+i,i+=t.colSpan-1,t.rowSpan>1&&(t.rowSpan-=1,e.push({cell:t.cloneNode(!0),index:n}));if(e.length>0){let n=e.shift();s=t.cells,i=0;for(let o,r,l=0,a=s.length;l<a&&(o=s[l],r=l+i,i+=o.colSpan-1,!(r>=n.index)||(l--,i--,i+=n.cell.colSpan-1,t.insertBefore(n.cell,o),n=e.shift(),n));l++);if(n){t.appendChild(n.cell);for(let s=0,i=e.length;s<i;s++)t.appendChild(e[s].cell)}}}this.#od._element.deleteRow(r)}else this.insertBodyRow(this.#od._element,r,h);i?this.#od._closeController():this.#od._setCellControllerPosition(s||this.#I.tdElement,!0)}insertBodyRow(t,e,s){const i=t.insertRow(e);return i.innerHTML=Ja("td",s),i}#hd(t){switch(sh(this.#od._element),t){case"insert-left":this.editTable("cell","left");break;case"insert-right":this.editTable("cell","right");break;case"delete":this.editTable("cell",null)}this.#od.historyPush()}#cd(t){switch(sh(this.#od._element),t){case"insert-above":this.editTable("row","up");break;case"insert-below":this.editTable("row","down");break;case"delete":this.editTable("row",null)}this.#od.historyPush()}},{_w:lh}=Oe;const ah=class{#od;#J;#I;#it;#dd=!1;#ud=null;#pd=null;constructor(t){this.#od=t,this.#J=t.$,this.#I=t.state,this.#it={resize:null,resizeStop:null,resizeKeyDown:null}}get#rd(){return this.#od.selectionService}isResizing(){return this.#dd}onResizeGuide(t,e){const s=Xa(t,e);if(s.is)return this.#od._element&&(this.#od._element.style.cursor=""),this.#hi(),"block"===this.#ud?.style.display&&(this.#ud.style.display="none"),this.#ud=this.#J.frameContext.get("wrapper").querySelector(Ia),this.#gd(Pe.query.getParentElement(e,Pe.check.isTable),e,this.#ud,s.isLeft),this.#ud.style.display="block",!1;return Za(t,e).is?(this.#hi(),this.#od._element=Pe.query.getParentElement(e,Pe.check.isTable),this.#od._element.style.cursor="ns-resize","block"===this.#ud?.style.display&&(this.#ud.style.display="none"),this.#ud=this.#J.frameContext.get("wrapper").querySelector(Aa),this.#md(Pe.query.getParentElement(e,Pe.check.isTable),e,this.#ud),this.#ud.style.display="block",!1):void 0}offResizeGuide(){this.#fd()}readyResizeFromEdge(t,e){const s=Xa(t,e);if(s.is){try{this.#rd.deleteStyleSelectedCells(),this.#od.setCellInfo(e,!0);const t=this.#I.logical_cellIndex+this.#I.current_colSpan-(s.isLeft?1:0);if(this.#J.ui.enableBackWrapper("ew-resize"),this.#ud||=this.#J.frameContext.get("wrapper").querySelector(Ia),this.#pd=this.#J.frameContext.get("wrapper").querySelector(La),t<0||t===this.#I.logical_cellCnt-1)return this._startFigureResizing(s.startX,t<0),this.#od._editorEnable(!1),!1;const i=this.#od._element.querySelector("colgroup").querySelectorAll("col")[t<0?0:t];this._startCellResizing(i,s.startX,De.get(lh.getComputedStyle(i).width,0),s.isLeft),this.#od._editorEnable(!1)}catch(t){console.warn("[SUNEDITOR.plugins.table.error]",t),this.#od._editorEnable(!0),this.#hi()}finally{this.#od.setState("fixedCell",null),this.#od.setState("selectedCell",null),this.#od.controller_table.hide(),this.#od.controller_cell.hide()}return!1}const i=Za(t,e);if(i.is){try{let t=Pe.query.getParentElement(e,Pe.check.isTableRow),s=e.rowSpan;if(s>1)for(;Pe.check.isTableRow(t)&&s>1;)t=t.nextElementSibling,--s;this.#rd.deleteStyleSelectedCells(),this.#od.setRowInfo(t),this.#J.ui.enableBackWrapper("ns-resize"),this.#ud||=this.#J.frameContext.get("wrapper").querySelector(Aa),this.#pd=this.#J.frameContext.get("wrapper").querySelector(Oa),this._startRowResizing(t,i.startY,De.get(lh.getComputedStyle(t).height,0)),this.#od._editorEnable(!1)}catch(t){console.warn("[SUNEDITOR.plugins.table.error]",t),this.#od._editorEnable(!0),this.#hi()}finally{this.#od.setState("fixedCell",null),this.#od.setState("selectedCell",null),this.#od.controller_table.hide(),this.#od.controller_cell.hide()}return!1}}#vd(t){const e=t.querySelector("colgroup").querySelectorAll("col"),s=t.offsetWidth;e.forEach((t=>{const e=t.style.width;if(!e.endsWith("%")){const i=(t.offsetWidth||De.get(e,0))/s*100;t.style.width=i+"%"}}))}_startCellResizing(t,e,s,i){const n=this.#I.figureElement;Pe.utils.removeClass(n,"se-component-selected"),this.#vd(this.#od._element),this.#gd(n,this.#I.tdElement,this.#pd,i),this.#pd.style.display="block";const o=t.style.width,r=t.nextElementSibling,l=r.style.width,a=Pe.utils.hasClass(this.#od._element,"se-table-layout-fixed")?l:ze.getWidthInPercentage(r||t);_i.get("__dragHandler")&&(_i.get("__dragHandler").style.display="none"),this.#bd(this.#yd.bind(this,t,r,n,this.#I.tdElement,this.#ud,i,e,s,De.get(o,0),De.get(a,0),this.#od._element.offsetWidth),(()=>{this.#hi(),this.#vd(this.#od._element),this.#J.history.push(!0),this.#J.component.hoverSelect(this.#od._element),this.#od._editorEnable(!0)}),(e=>{this._stopResize(t,o,"width",e),this._stopResize(r,l,"width",e)}))}#yd(t,e,s,i,n,o,r,l,a,h,c,d){const u=(l+(d.clientX-r))/c*100;if(u>0){t.style.width=`${u}%`;const r=a-u;e.style.width=`${h+r}%`,this.#gd(s,i,n,o)}}_startRowResizing(t,e,s){const i=this.#I.figureElement;Pe.utils.removeClass(i,"se-component-selected"),this.#md(i,t,this.#pd),this.#pd.style.display="block";const n=t.style.height;_i.get("__dragHandler")&&(_i.get("__dragHandler").style.display="none"),this.#bd(this.#wd.bind(this,t,i,this.#ud,e,s),(()=>{this.#hi(),this.#J.history.push(!0),this.#J.component.hoverSelect(this.#od._element),this.#od._editorEnable(!0)}),this._stopResize.bind(this,t,n,"height"))}#wd(t,e,s,i,n,o){const r=n+(o.clientY-i);t.style.height=`${r}px`,this.#md(e,t,s)}_startFigureResizing(t,e){const s=this.#I.figureElement;Pe.utils.removeClass(s,"se-component-selected"),this.#gd(s,s,this.#pd,e),this.#pd.style.display="block";const i=ze.getWidthInPercentage(s);_i.get("__dragHandler")&&(_i.get("__dragHandler").style.display="none"),this.#bd(this.#Cd.bind(this,s,this.#ud,e,t,s.offsetWidth,De.get(i,0)),(()=>{this.#hi(),De.get(s.style.width,0)>100&&(s.style.width="100%"),this.#J.history.push(!0),this.#J.component.hoverSelect(this.#od._element),this.#od._editorEnable(!0)}),this._stopResize.bind(this,s,s.style.width,"width"))}#Cd(t,e,s,i,n,o,r){const l=(n+(s?i-r.clientX:r.clientX-i))/n*o;l>0&&(t.style.width=`${l}%`,this.#gd(t,t,e,s))}#gd(t,e,s,i){const n=this.#J.offset.getLocal(e),o=this.#J.offset.getLocal(t);s.style.left=`${n.left+(i?0:e.offsetWidth)}px`,s.style.top=`${o.top}px`,s.style.height=`${t.offsetHeight}px`}#md(t,e,s){const i=this.#J.offset.getLocal(e),n=this.#J.offset.getLocal(t);s.style.top=`${i.top+e.offsetHeight}px`,s.style.left=`${n.left}px`,s.style.width=`${t.offsetWidth}px`}_stopResize(t,e,s,i){Fe.isEsc(i.code)&&(this.#hi(),this.#J.component.hoverSelect(this.#od._element),this.#od._editorEnable(!0),t.style[s]=e,"width"===s&&this.#J.component.select(this.#od._element,this.#od.constructor.key,{isInput:!0}))}#bd(t,e,s){this.#it.resize=this.#J.eventManager.addGlobalEvent("mousemove",t,!1),this.#it.resizeStop=this.#J.eventManager.addGlobalEvent("mouseup",e,!1),this.#it.resizeKeyDown=this.#J.eventManager.addGlobalEvent("keydown",s,!1),this.#dd=!0}#hi(){this.#dd=!1,this.#J.ui.disableBackWrapper(),this.#fd(),this.#pd&&(this.#pd.style.display="none",this.#pd=null);const t=this.#it;for(const e in t)t[e]&&=this.#J.eventManager.removeGlobalEvent(t[e]);this.#dd=!1,this.#ud=null}#fd(){this.#ud&&(this.#ud.style.display="none",this.#ud=null),this.#od._element&&(this.#od._element.style.cursor="")}init(){this.#hi()}};const hh=class{#od;#J;#I;#_d;#kd;#xd;#$d;#it;#Sd=null;constructor(t){this.#od=t,this.#J=t.$,this.#I=t.state,this.#_d=this.#Ed.bind(this),this.#kd=this.#Td.bind(this),this.#xd=this.#Md.bind(this),this.#$d=this.#Nd.bind(this),this.#it={on:null,off:null,shiftOff:null,touchOff:null,resize:null,resizeStop:null,resizeKeyDown:null}}get#ad(){return this.#od.cellService}selectCells(t){const e=t[0],s=Pe.query.findVisualLastCell(t);return this.#Sd=e.nodeName,this.setMultiCells(e,s),{fixedCell:e,selectedCell:s}}setMultiCells(t,e){const s=this.#I.selectedTable,i=s.rows;if(this.deleteStyleSelectedCells(),Pe.utils.addClass(t,"se-selected-table-cell"),t===e&&!this.#I.isShiftPressed)return;const n=function(t,e){const s=t.parentNode,i=e.parentNode;return`${s.rowIndex},${t.cellIndex}-${i.rowIndex},${e.cellIndex}`}(t,e);let o=ja.get(s);const r=o?.get(n);if(r)return this.#od.setState("ref",r),void this.#Bd(i,r);const l=this.#Id(i,t,e);this.#od.setState("ref",l),o||(o=new Map,ja.set(s,o)),o.set(n,l),this.#Bd(i,l)}#Id(t,e,s){let i=!0,n=[],o=[];const r={_i:0,cs:null,ce:null,rs:null,re:null};for(let l,a,h=0,c=t.length;h<c;h++){l=t[h].cells,a=0;for(let t,c,d,u,p=0,g=l.length;p<g;p++){if(t=l[p],d=t.colSpan-1,u=t.rowSpan-1,c=p+a,n.length>0)for(let t,e=0;e<n.length;e++)t=n[e],t.row>h||(c>=t.index?(a+=t.cs,c+=t.cs,t.rs-=1,t.row=h+1,t.rs<1&&(n.splice(e,1),e--)):p===g-1&&(t.rs-=1,t.row=h+1,t.rs<1&&(n.splice(e,1),e--)));if(i){if(t!==e&&t!==s||(r.cs=null!==r.cs&&r.cs<c?r.cs:c,r.ce=null!==r.ce&&r.ce>c+d?r.ce:c+d,r.rs=null!==r.rs&&r.rs<h?r.rs:h,r.re=null!==r.re&&r.re>h+u?r.re:h+u,r._i+=1),2===r._i){i=!1,n=[],o=[],h=-1;break}}else{const t=r.cs<c?r.cs:c,e=r.ce>c+d?r.ce:c+d,s=r.rs<h?r.rs:h,i=r.re>h+u?r.re:h+u;if(De.getOverlapRangeAtIndex(r.cs,r.ce,c,c+d)&&De.getOverlapRangeAtIndex(r.rs,r.re,h,h+u)&&(r.cs!==t||r.ce!==e||r.rs!==s||r.re!==i)){r.cs=t,r.ce=e,r.rs=s,r.re=i,h=-1,n=[],o=[];break}}u>0&&o.push({index:c,cs:d+1,rs:u,row:-1}),a+=t.colSpan-1}n=n.concat(o).sort(((t,e)=>t.index-e.index)),o=[]}return r}#Bd(t,e){let s=[],i=[];for(let n,o,r=0,l=t.length;r<l;r++){n=t[r].cells,o=0;for(let t,l,a,h,c=0,d=n.length;c<d;c++){if(t=n[c],a=t.colSpan-1,h=t.rowSpan-1,l=c+o,s.length>0)for(let t,e=0;e<s.length;e++)t=s[e],t.row>r||(l>=t.index?(o+=t.cs,l+=t.cs,t.rs-=1,t.row=r+1,t.rs<1&&(s.splice(e,1),e--)):c===d-1&&(t.rs-=1,t.row=r+1,t.rs<1&&(s.splice(e,1),e--)));De.getOverlapRangeAtIndex(e.cs,e.ce,l,l+a)&&De.getOverlapRangeAtIndex(e.rs,e.re,r,r+h)&&Pe.utils.addClass(t,"se-selected-table-cell"),h>0&&i.push({index:l,cs:a+1,rs:h,row:-1}),o+=t.colSpan-1}s=s.concat(i).sort(((t,e)=>t.index-e.index)),i=[]}}initCellSelection(t){this.#od.setState("fixedCell",t),this.#I.selectedCells?.length||this.#od.setState("selectedCells",[t]),this.#Sd=t.nodeName,this.#od.setState("selectedTable",Pe.query.getParentElement(t,"TABLE")),this.deleteStyleSelectedCells(),Pe.utils.addClass(t,"se-selected-cell-focus")}startCellSelection(t,e){this.#I.isShiftPressed||this.#I.ref||this.#hi(),this.#od.setState("isShiftPressed",e),this.initCellSelection(t),e?(this.#it.shiftOff=this.#J.eventManager.addGlobalEvent("keyup",this.#xd,!1),this.#it.on=this.#J.eventManager.addGlobalEvent("mousedown",this.#_d,!1)):this.#it.on=this.#J.eventManager.addGlobalEvent("mousemove",this.#_d,!1),this.#it.off=this.#J.eventManager.addGlobalEvent("mouseup",this.#kd,!1),this.#it.touchOff=this.#J.eventManager.addGlobalEvent("touchmove",this.#$d,!1)}deleteStyleSelectedCells(){Pe.utils.removeClass([this.#I.fixedCell,this.#I.selectedCell],"se-selected-cell-focus");const t=this.#I.fixedCell?.closest("table");if(t){const e=t.querySelectorAll(".se-selected-table-cell");for(let t=0,s=e.length;t<s;t++)Pe.utils.removeClass(e[t],"se-selected-table-cell")}}recallStyleSelectedCells(){if(this.#I.selectedCells){const t=this.#I.selectedCells;for(let e=0,s=t.length;e<s;e++)Pe.utils.addClass(t[e],"se-selected-table-cell")}}focusCellEdge(t){Oe.isMobile||this.#J.focusManager.focusEdge(t)}#Ed(t){this.#J.store.set("_preventBlur",!0);const e=Pe.query.getParentElement(Pe.query.getEventTarget(t),Pe.check.isTableCell);if(this.#I.isShiftPressed){if(e===this.#I.fixedCell)return this.#od.setState("isShiftPressed",!1),this.deleteStyleSelectedCells(),this.#od._editorEnable(!0),void this.#hi();this.#od._editorEnable(!1)}else if(!this.#I.ref){if(e===this.#I.fixedCell)return;this.#od._editorEnable(!1)}e&&e!==this.#I.selectedCell&&this.#Sd===e.nodeName&&this.#I.selectedTable===Pe.query.getParentElement(e,"TABLE")&&(this.#od.setState("selectedCell",e),this.setMultiCells(this.#I.fixedCell,this.#I.selectedCell))}#Td(t){t.stopPropagation(),this.#I.isShiftPressed?this.#it.touchOff&&=this.#J.eventManager.removeGlobalEvent(this.#it.touchOff):(this.#od._editorEnable(!0),this.#hi());const e=this.#I.fixedCell;if(!e||!this.#I.selectedTable)return;if(this.#ad.setMergeSplitButton(),this.#od.setState("selectedCells",Array.from(this.#I.selectedTable.querySelectorAll(".se-selected-table-cell"))),this.#I.isShiftPressed)return;e&&this.#I.selectedCell&&(this.focusCellEdge(e),e===this.#I.selectedCell&&Pe.utils.removeClass(e,"se-selected-table-cell"));const s=this.#I.selectedCells?.length>0?this.#I.selectedCell:e;this.#od._setController(s)}#Md(){if(this.#I.ref){this.#hi(),this.#od._editorEnable(!0),this.focusCellEdge(this.#I.fixedCell);const t=this.#I.selectedCells?.length>0?this.#I.selectedCell:this.#I.fixedCell;this.#od._setController(t)}else this.#od._closeController()}#Nd(){this.#od.resetInfo()}#hi(){this.#J.ui.disableBackWrapper();const t=this.#it;for(const e in t)t[e]&&=this.#J.eventManager.removeGlobalEvent(t[e])}init(){this.#hi()}},{_w:ch}=Oe;const dh=class{#od;#I;#J;constructor(t,{pluginOptions:e,controller_table:s}){this.#od=t,this.#I=t.state,this.#J=t.$,this.sliderType="",this.resizeButton=s.querySelector("._se_table_resize"),this.resizeText=s.querySelector("._se_table_resize > span > span"),this.columnFixedButton=s.querySelector("._se_table_fixed_column"),this.headerButton=s.querySelector("._se_table_header"),this.captionButton=s.querySelector("._se_table_caption");const i=function({lang:t,icons:e,options:s}){const i=s.get("_rtl")?["right","center","left","justify"]:["left","center","right","justify"];let n="";for(let s,o,r=0;r<i.length;r++)s=i[r],o=t["align"+s.charAt(0).toUpperCase()+s.slice(1)],n+=`\n\t\t<button type="button" class="se-btn se-tooltip" data-command="props_align" data-value="${s}" title="${o}" aria-label="${o}">\n\t\t\t${e["align_"+s]}\n\t\t\t<span class="se-tooltip-inner">\n\t\t\t\t<span class="se-tooltip-text">${o}</span>\n\t\t\t</span>\n\t\t</button>`;const o=["top","middle","bottom"];let r="";for(let s,i,n=0;n<o.length;n++)s=o[n],i=t["align"+s.charAt(0).toUpperCase()+s.slice(1)],r+=`\n\t\t<button type="button" class="se-btn se-tooltip" data-command="props_align_vertical" data-value="${s}" title="${i}" aria-label="${i}">\n\t\t\t${e["align_"+s]}\n\t\t\t<span class="se-tooltip-inner">\n\t\t\t\t<span class="se-tooltip-text">${i}</span>\n\t\t\t</span>\n\t\t</button>`;const l=`\n\t\t<div class="se-controller-content">\n\t\t\t<div class="se-controller-header">\n\t\t\t\t<button type="button" data-command="close" class="se-btn se-close-btn close" title="${t.close}" aria-label="${t.close}">${e.cancel}</button>\n\t\t\t\t<span class="se-controller-title">${t.tableProperties}</span>\n\t\t\t</div>\n\t\t\t<div class="se-controller-body">\n\n\t\t\t\t<span>${t.border}</span>\n\t\t\t\t<div class="se-form-group se-form-w0">\n\t\t\t\t\t<button type="button" data-command="props_onborder_format" class="se-btn se-tooltip">\n\t\t\t\t\t\t${e[za.all]}\n\t\t\t\t\t\t<span class="se-tooltip-inner">\n\t\t\t\t\t\t\t<span class="se-tooltip-text">${t.border}</span>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</button>\n\t\t\t\t\t<button type="button" data-command="props_onborder_style" class="se-btn se-btn-select se-tooltip se-border-style">\n\t\t\t\t\t\t<span class="se-txt"></span>\n\t\t\t\t\t\t${e.arrow_down}\n\t\t\t\t\t\t<span class="se-tooltip-inner">\n\t\t\t\t\t\t\t<span class="se-tooltip-text">${t.border}</span>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</button>\n\t\t\t\t\t<input type="text" class="se-color-input __se_border_color" placeholder="${t.color}" />\n\t\t\t\t\t<button type="button" data-command="props_onpalette" data-value="border" class="se-btn se-tooltip">\n\t\t\t\t\t\t${e.color_palette}\n\t\t\t\t\t\t<span class="se-tooltip-inner">\n\t\t\t\t\t\t\t<span class="se-tooltip-text">${t.colorPicker}</span>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</button>\n\t\t\t\t\t<input type="text" class="se-input-control __se__border_size" placeholder="${t.width}" />\n\t\t\t\t</div>\n\n\t\t\t\t<span>${t.color}</span>\n\t\t\t\t<div class="se-form-group se-form-w0">\n\t\t\t\t\t<button type="button" data-command="props_onpalette" data-value="font" class="se-btn se-tooltip">\n\t\t\t\t\t\t${e.font_color}\n\t\t\t\t\t\t<span class="se-tooltip-inner">\n\t\t\t\t\t\t\t<span class="se-tooltip-text">${t.fontColor}</span>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</button>\n\t\t\t\t\t<input type="text" class="se-color-input __se_font_color" placeholder="${t.fontColor}" />\n\t\t\t\t\t<button type="button" data-command="props_onpalette" data-value="back" class="se-btn se-tooltip">\n\t\t\t\t\t\t${e.background_color}\n\t\t\t\t\t\t<span class="se-tooltip-inner">\n\t\t\t\t\t\t\t<span class="se-tooltip-text">${t.backgroundColor}</span>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</button>\n\t\t\t\t\t<input type="text" class="se-color-input __se_back_color" placeholder="${t.backgroundColor}" />\n\t\t\t\t</div>\n\n\t\t\t\t<span>${t.font}</span>\n\t\t\t\t<div class="se-form-group se-form-w0">\n\t\t\t\t\t<button type="button" data-command="props_font_style" data-value="bold" class="se-btn se-tooltip">\n\t\t\t\t\t\t${e.bold}\n\t\t\t\t\t\t<span class="se-tooltip-inner">\n\t\t\t\t\t\t\t<span class="se-tooltip-text">${t.bold}</span>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</button>\n\t\t\t\t\t<button type="button" data-command="props_font_style" data-value="underline" class="se-btn se-tooltip">\n\t\t\t\t\t\t${e.underline}\n\t\t\t\t\t\t<span class="se-tooltip-inner">\n\t\t\t\t\t\t\t<span class="se-tooltip-text">${t.underline}</span>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</button>\n\t\t\t\t\t<button type="button" data-command="props_font_style" data-value="italic" class="se-btn se-tooltip">\n\t\t\t\t\t\t${e.italic}\n\t\t\t\t\t\t<span class="se-tooltip-inner">\n\t\t\t\t\t\t\t<span class="se-tooltip-text">${t.italic}</span>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</button>\n\t\t\t\t\t<button type="button" data-command="props_font_style" data-value="strike" class="se-btn se-tooltip">\n\t\t\t\t\t\t${e.strike}\n\t\t\t\t\t\t<span class="se-tooltip-inner">\n\t\t\t\t\t\t\t<span class="se-tooltip-text">${t.strike}</span>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</button>\n\t\t\t\t</div>\n\n\t\t\t\t<div class="se-table-props-align">\n\t\t\t\t\t<span>${t.align} <span class="__se__a_table_t">( ${t.table} )</span></span>\n\t\t\t\t\t<div class="se-form-group se-form-w0 se-list-inner">\n\t\t\t\t\t\t<div class="__se__a_h">\n\t\t\t\t\t\t\t${n}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class="__se__a_v">\n\t\t\t\t\t\t\t${r}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t<div class="se-form-group se-form-w0 se-form-flex-btn">\n\t\t\t\t<button type="button" class="se-btn se-btn-success" data-command="props_submit" title="${t.submitButton}" aria-label="${t.submitButton}">${e.checked}</button>\n\t\t\t\t<button type="button" class="se-btn se-btn-danger" data-command="revert" title="${t.revert}" aria-label="${t.revert}">${e.revert}</button>\n\t\t\t</div>\n\t\t</div>`,a=Pe.utils.createElement("DIV",{class:"se-controller se-table-props"},l);return{html:a,controller_props_title:a.querySelector(".se-controller-title"),borderButton:a.querySelector('[data-command="props_onborder_style"]'),borderFormatButton:a.querySelector('[data-command="props_onborder_format"]'),cell_alignment:a.querySelector(".se-table-props-align .__se__a_h"),cell_alignment_vertical:a.querySelector(".se-table-props-align .__se__a_v"),cell_alignment_table_text:a.querySelector(".se-table-props-align .__se__a_table_t"),border_style:a.querySelector('[data-command="props_onborder_style"] .se-txt'),border_color:a.querySelector(".__se_border_color"),border_width:a.querySelector(".__se__border_size"),back_color:a.querySelector(".__se_back_color"),font_color:a.querySelector(".__se_font_color"),palette_border_button:a.querySelector('[data-command="props_onpalette"][data-value="border"]'),font_bold:a.querySelector('[data-command="props_font_style"][data-value="bold"]'),font_underline:a.querySelector('[data-command="props_font_style"][data-value="underline"]'),font_italic:a.querySelector('[data-command="props_font_style"][data-value="italic"]'),font_strike:a.querySelector('[data-command="props_font_style"][data-value="strike"]')}}(this.#J),n=[this.#od.controller_table,this.#od.controller_cell];this.controller_props=new Ii(this,this.#J,i.html,{position:"bottom",parents:n,isInsideForm:!0}),this.controller_props_title=i.controller_props_title;const o=Pe.utils.createElement("DIV",{class:"se-controller se-list-layer"},null);this.controller_colorPicker=new Ii(this,this.#J,o,{position:"bottom",parents:[this.controller_props].concat(n),isInsideForm:!0,isWWTarget:!1,initMethod:()=>{this.colorPicker.hueSlider.close(),Pe.utils.removeClass(this.controller_colorPicker.currentTarget,"on")}}),this.colorPicker=new Ll(this,this.#J,"",{form:o,colorList:e.colorList||Wa,splitNum:5,disableRemove:!0,hueSliderOptions:{controllerOptions:{isOutsideForm:!0,parents:[this.controller_colorPicker],parentsHide:!0}}});const r=function(){let t="";for(let e,s=0,i=Ra.length;s<i;s++)e=Ra[s],t+=`\n\t\t<div title="${e}" aria-label="${e}" style="padding: 0 12px;">\n\t\t\t<span class="se-txt">${e}</span>\n\t\t</div>`;const e=Pe.utils.createElement("DIV",null,t);return{items:Ra,menus:e.querySelectorAll("div")}}(),l=i.borderButton;this.selectMenu_props_border=new Ai(this.#J,{checkList:!1,position:"bottom-center"}),this.selectMenu_props_border.on(l,this.#Ld.bind(this)),this.selectMenu_props_border.create(r.items,r.menus);const a=ih(this.#J.lang,this.#J.icons,[]),h=i.borderFormatButton;this.selectMenu_props_border_format=new Ai(this.#J,{checkList:!1,position:"bottom-left",dir:"ltr",splitNum:5}),this.selectMenu_props_border_format.on(h,this.#Ad.bind(this,"all")),this.selectMenu_props_border_format.create(a.items,a.menus);const c=ih(this.#J.lang,this.#J.icons,Pa);this.selectMenu_props_border_format_oneCell=new Ai(this.#J,{checkList:!1,position:"bottom-left",dir:"ltr",splitNum:6}),this.selectMenu_props_border_format_oneCell.on(h,this.#Ad.bind(this,"outside")),this.selectMenu_props_border_format_oneCell.create(c.items,c.menus),this.maxText=this.#J.lang.maxSize,this.minText=this.#J.lang.minSize,this.propTargets={cell_alignment:i.cell_alignment,cell_alignment_vertical:i.cell_alignment_vertical,cell_alignment_table_text:i.cell_alignment_table_text,border_format:h,border_style:i.border_style,border_color:i.border_color,border_width:i.border_width,back_color:i.back_color,font_color:i.font_color,palette_border_button:i.palette_border_button,font_bold:i.font_bold,font_underline:i.font_underline,font_italic:i.font_italic,font_strike:i.font_strike},this._propsCache=[],this._currentFontStyles=[],this._propsAlignCache="",this._propsVerticalAlignCache="",this._typeCache=""}get#rd(){return this.#od.selectionService}colorPickerAction(t){this.applyColorPicker(t)}controllerAction(t){const e=t.getAttribute("data-command");if(!e)return;const s=t.getAttribute("data-value");switch(e){case"props_onborder_format":this.openBorderFormatMenu();break;case"props_onborder_style":this.openBorderStyleMenu();break;case"props_onpalette":this.openColorPalette(t,s);break;case"props_font_style":this.toggleFontStyle(s);break;case"props_submit":this.submitProps(t);break;case"props_align":this.setAlignProps(t.getAttribute("data-value"));break;case"props_align_vertical":this.setVerticalAlignProps(t.getAttribute("data-value"))}}openTableProps(t){this.controller_props.currentTarget===t&&"block"===this.controller_props.form?.style.display?this.controller_props.close():(this.controller_props_title.textContent=this.#J.lang.tableProperties,this.#Od("table"),this.controller_props.open(t,this.#od.controller_table.form,{isWWTarget:!1,initMethod:null,addOffset:null}))}openCellProps(t){this.controller_props.currentTarget===t&&"block"===this.controller_props.form?.style.display?this.controller_props.close():(this.controller_props_title.textContent=this.#J.lang.cellProperties,this.#Od("cell"),this.controller_props.open(t,this.#od.controller_cell.form,{isWWTarget:!1,initMethod:null,addOffset:null}))}openBorderFormatMenu(){1===this._propsCache.length?this.selectMenu_props_border_format_oneCell.open():this.selectMenu_props_border_format.open()}openBorderStyleMenu(){this.selectMenu_props_border.open()}openColorPalette(t,e){const{back_color:s,font_color:i,border_color:n}=this.propTargets,o="border"===e?n:"back"===e?s:i;this.controller_colorPicker.isOpen&&e===this.sliderType?this.controller_colorPicker.close():(this.sliderType=e,Pe.utils.addClass(t,"on"),this.colorPicker.init(o?.value||"",t),this.controller_colorPicker.open(t,null,{isWWTarget:!1,initMethod:null,addOffset:null}))}toggleFontStyle(t){Pe.utils.toggleClass(this.propTargets[`font_${t}`],"on")}toggleHeader(){const t=this.headerButton,e=Pe.utils.hasClass(t,"active"),s=this.#od._element;if(sh(s),e)Pe.utils.removeItem(s.querySelector("thead"));else{const t=Pe.utils.createElement("THEAD");t.innerHTML="<tr>"+Ja("th",this.#I.logical_cellCnt)+"</tr>",s.insertBefore(t,s.querySelector("tbody"))}Pe.utils.toggleClass(t,"active"),/TH/i.test(this.#I.tdElement.nodeName)?this.#od._closeController():this.#od._setCellControllerPosition(this.#I.tdElement,!1)}toggleCaption(){const t=this.captionButton,e=Pe.utils.hasClass(t,"active"),s=this.#od._element;if(e)Pe.utils.removeItem(s.querySelector("caption"));else{const t=Pe.utils.createElement("CAPTION",{class:`se-table-caption-${this.#od.captionPosition}`});t.innerHTML="<div><br></div>",s.insertBefore(t,s.firstElementChild)}Pe.utils.toggleClass(t,"active"),this.#od._setCellControllerPosition(this.#I.tdElement,!1)}resetHeaderButton(t){t.querySelector("thead")?Pe.utils.addClass(this.headerButton,"active"):Pe.utils.removeClass(this.headerButton,"active")}resetCaptionButton(t){t.querySelector("caption")?Pe.utils.addClass(this.captionButton,"active"):Pe.utils.removeClass(this.captionButton,"active")}resetPropsAlign(){const{cell_alignment:t}=this.propTargets,e=t.querySelector('[data-value="left"]'),s=t.querySelector('[data-value="right"]'),i=e.parentElement,n=s.parentElement;i.appendChild(s),n.appendChild(e)}revertProps(){const t=this._propsCache;for(let e=0,s=t.length;e<s;e++)t[e][0].style.cssText=t[e][1];this.#Rd(this.propTargets.cell_alignment,this._propsAlignCache,!0),this.#Rd(this.propTargets.cell_alignment_vertical,this._propsVerticalAlignCache,!0),Pe.check.isTable(t[0][0])&&this.#I.figureElement&&(this.#I.figureElement.style.float=this._propsAlignCache)}applyColorPicker(t){const e=this.propTargets[`${this.sliderType}_color`];e.style.borderColor=e.value=t,this.controller_colorPicker.close()}setAlignProps(t){this.#Rd(this.propTargets.cell_alignment,t,!1)}setVerticalAlignProps(t){this.#Rd(this.propTargets.cell_alignment_vertical,t,!1)}setTableLayout(t,e,s,i){if(t.includes("width")){const t=this.#I.figureElement;if(!t)return;let s,n;e?(s=this.#J.icons.reduction,n=this.minText,i||(t.style.width="100%")):(s=this.#J.icons.expansion,n=this.maxText,i||(t.style.width="max-content")),Pe.utils.changeElement(this.resizeButton.firstElementChild,s),Pe.utils.changeTxt(this.resizeText,n)}t.includes("column")&&(s?(Pe.utils.removeClass(this.#od._element,"se-table-layout-auto"),Pe.utils.addClass(this.#od._element,"se-table-layout-fixed"),Pe.utils.addClass(this.columnFixedButton,"active")):(Pe.utils.removeClass(this.#od._element,"se-table-layout-fixed"),Pe.utils.addClass(this.#od._element,"se-table-layout-auto"),Pe.utils.removeClass(this.columnFixedButton,"active")))}submitProps(t){try{t.disabled=!0;const e=this.#od.controller_table.form.contains(this.controller_props.currentTarget),s=e?[this.#od._element]:this.#I.selectedCells,i=s[0],n=ch.getComputedStyle(i),{border_format:o,border_color:r,border_style:l,border_width:a,back_color:h,font_color:c,cell_alignment:d,cell_alignment_vertical:u}=this.propTargets,p=o.getAttribute("se-border-format")||"",g="all"!==p,m=("none"===l.textContent?"":l.textContent)||"",f="none"===p||!m,v=d.getAttribute("se-cell-align")||"",b=u.getAttribute("se-cell-align")||"",y=f?"":r.value.trim()||n.borderColor;let w=f?"":a.value.trim()||n.borderWidth;w+=De.is(w)?"px":"";const C=h.value.trim(),_=c.value.trim(),k=g&&!f&&w,x=`${w} ${m} ${y}`,$={left:[],top:[],right:[],bottom:[],middle:[],all:null};if(e){const t=i.style;this.#I.figureElement&&(this.#I.figureElement.style.float=v,this.#I.figureElement.style.verticalAlign=b),t.backgroundColor=C,t.color=_,this.#zd(t),k||(t.border=f?t.borderLeft=t.borderTop=t.borderRight=t.borderBottom="":x),$.left=$.top=$.right=$.bottom=s}else{const t=i.parentElement;let{rs:e,re:n,cs:o,ce:r}=this.#I.ref||{rs:t.rowIndex||0,re:t.rowIndex||0,cs:i.cellIndex||0,ce:i.cellIndex||0};const l=new Array(n-e+1).fill(0).map((()=>new Array(r-o+1).fill(0))),a=o;n-=e,e-=e,r-=o,o-=o;let h=t;for(let t,i,c,d,u,p=0,g=0,m=s.length,y=0;p<m;p++,g++){t=s[p],d=t.colSpan,u=t.rowSpan,c=t.cellIndex-a,h!==t.parentElement&&(y++,g=0,h=t.parentElement);let m=0;for(;m<=c;)c+=l[y][m]||0,m++;try{if(u>1){const t=u-1;for(let e=y;e<=y+t;e++)l[e][c]+=d-(y===e?1:0)}else d>1&&(l[y][c]+=d-1)}catch{}const w=y+u-1===n;y===e&&$.top.push(t),(y===n||w)&&$.bottom.push(t),c===o&&$.left.push(t),c!==r&&c+d-1!==r||$.right.push(t),w||y===e||y===n||c===o||c===r||$.middle.push(t),i=t.style,i.textAlign=v,i.verticalAlign=b,i.backgroundColor=C,i.color=_,this.#zd(i),k||(i.border=f?i.borderLeft=i.borderTop=i.borderRight=i.borderBottom="":x)}0===$.middle.length&&($.middle=s)}$.all=s,k&&this.#Pd($,p,x),this.#od.historyPush(),this.controller_props.close(),this.#I.tdElement&&(this.#rd.recallStyleSelectedCells(),this.#od.setCellInfo(this.#I.tdElement,!0),Pe.utils.addClass(this.#I.tdElement,"se-selected-cell-focus"))}catch(t){console.warn("[SUNEDITOR.plugins.table.setProps.error]",t)}finally{t.disabled=!1}}closeProps(){this.controller_props.close(),this.controller_colorPicker.close()}#Od(t){this._typeCache=t;const e="table"===t,s=e?[this.#od._element]:this.#I.selectedCells;if(!s?.[0])return;const{border_format:i,border_color:n,border_style:o,border_width:r,back_color:l,font_color:a,cell_alignment:h,cell_alignment_vertical:c,cell_alignment_table_text:d,font_bold:u,font_underline:p,font_italic:g,font_strike:m}=this.propTargets,{border:f,backgroundColor:v,color:b,textAlign:y,verticalAlign:w,fontWeight:C,textDecoration:_,fontStyle:k}=ch.getComputedStyle(s[0]),x=this.#Dd(f);h.querySelector('[data-value="justify"]').style.display=e?"none":"",d.style.display=e?"":"none",c.style.display=e?"none":"";let $=ze.rgb2hex(x.c),S=x.s,E=x.w,T=ze.rgb2hex(v),M=ze.rgb2hex(b),N=/.+/.test(C),B=/underline/i.test(_),I=/line-through/i.test(_),L=/italic/i.test(k),A=e?this.#I.figureElement?.style.float:y,O=w;this._propsCache=[];for(let t,i,n=0;t=s[n];n++){const{cssText:s,border:n,backgroundColor:o,color:r,textAlign:l,verticalAlign:a,fontWeight:h,textDecoration:c,fontStyle:d}=t.style;if(this._propsCache.push([t,s]),i)continue;const{c:u,s:p,w:g}=this.#Dd(n);let m=o,f=r;if(m||f){const e=ch.getComputedStyle(t);m&&(m=e.backgroundColor),f&&(f=e.color)}$&&x.c!==u&&($=""),S&&x.s!==p&&(S=""),E&&x.w!==g&&(E=""),T!==ze.rgb2hex(m)&&(T=""),M!==ze.rgb2hex(f)&&(M=""),A!==(e?this.#I.figureElement?.style.float:l)&&(A=""),O&&O!==a&&(O=""),N&&N!==/.+/.test(h)&&(N=!1),B&&B!==/underline/i.test(c)&&(B=!1),I&&I!==/line-through/i.test(c)&&(I=!1),L&&L!==/italic/i.test(d)&&(L=!1),$&&S&&E&&T&&M||(i=!0)}i.firstElementChild.innerHTML=this.#J.icons[za[1===s.length?"outside":"all"]],i.setAttribute("se-border-format","all"),Pe.utils.removeClass(i,"active"),S||=Ra[0],o.textContent=S,n.style.borderColor=n.value=$,r.value=E,this.#Fd(S===Ra[0]),l.value=l.style.borderColor=T,a.value=a.style.borderColor=M,N&&Pe.utils.addClass(u,"on"),B&&Pe.utils.addClass(p,"on"),I&&Pe.utils.addClass(m,"on"),L&&Pe.utils.addClass(g,"on"),this.#Rd(h,this._propsAlignCache=A,!0),this.#Rd(c,this._propsVerticalAlignCache=O,!0)}#zd(t){const{font_bold:e,font_italic:s,font_strike:i,font_underline:n}=this.propTargets;t.fontWeight=Pe.utils.hasClass(e,"on")?"bold":"",t.fontStyle=Pe.utils.hasClass(s,"on")?"italic":"",t.textDecoration=((Pe.utils.hasClass(i,"on")?"line-through ":"")+(Pe.utils.hasClass(n,"on")?"underline":"")).trim()}#Dd(t){const e=t.split(/\s(?![^()]*\))/);let s="",i="",n="";return 3===e.length?(s=e[0],i=e[1],n=e[2]):2===e.length?/\d/.test(e[0])?(s=e[0],i=e[1]):(i=e[0],n=e[1]):1===e.length&&(/\d/.test(e[0])?s=e[0]:i=e[0]),{w:s,s:i,c:ze.rgb2hex(n)}}#Pd(t,e,s){const{left:i,top:n,right:o,bottom:r,all:l}=t;switch(e){case"inside":if(1===l.length)return;Pe.utils.setStyle(l.filter((t=>!r.includes(t))),qa,s),Pe.utils.setStyle(l.filter((t=>!o.includes(t))),Ha,s);break;case"horizon":if(1===l.length)return;Pe.utils.setStyle(l.filter((t=>!r.includes(t))),qa,s);break;case"vertical":if(1===l.length)return;Pe.utils.setStyle(l.filter((t=>!o.includes(t))),Ha,s);break;case"outside":Pe.utils.setStyle(i,Da,s),Pe.utils.setStyle(n,Fa,s),Pe.utils.setStyle(o,Ha,s),Pe.utils.setStyle(r,qa,s);break;case"left":Pe.utils.setStyle(i,Da,s);break;case"top":Pe.utils.setStyle(n,Fa,s);break;case"right":Pe.utils.setStyle(o,Ha,s);break;case"bottom":Pe.utils.setStyle(r,qa,s)}}#Fd(t){const{border_color:e,border_width:s,palette_border_button:i}=this.propTargets;t?(e.disabled=!0,s.disabled=!0,i.disabled=!0,s.disabled=!0):(e.disabled=!1,s.disabled=!1,i.disabled=!1,s.disabled=!1)}#Rd(t,e,s){Pe.utils.removeClass(t.querySelectorAll("button"),"on"),s||t.getAttribute("se-cell-align")!==e?(Pe.utils.addClass(t.querySelector(`[data-value="${e}"]`),"on"),t.setAttribute("se-cell-align",e)):t.setAttribute("se-cell-align","")}#Ld(t){this.propTargets.border_style.textContent=t,this.#Fd(t===Ra[0]),this.selectMenu_props_border.close()}#Ad(t,e){const{border_format:s}=this.propTargets;s.setAttribute("se-border-format",e),s.firstElementChild.innerHTML=this.#J.icons[za[e]],e!==t?Pe.utils.addClass(s,"active"):Pe.utils.removeClass(s,"active"),this.selectMenu_props_border_format.close(),this.selectMenu_props_border_format_oneCell.close()}init(){const{border_format:t,border_color:e,border_style:s,border_width:i,back_color:n,font_color:o,cell_alignment:r,cell_alignment_vertical:l,font_bold:a,font_underline:h,font_italic:c,font_strike:d}=this.propTargets;Pe.utils.removeClass([t,e,s,i,n,o,r,l,a,h,c,d],"on")}},{_w:uh,ON_OVER_COMPONENT:ph}=Oe;class gh extends Gl{static key="table";static className="";static options={isInputComponent:!0};static component(t){return Pe.check.isTable(t)?t:null}#Hd;#qd;#Wd;#Ud;#Vd;#jd=[];#Gd=!0;#Kd=!1;#Yd=!1;constructor(t,e){super(t),this.title=this.$.lang.table,this.icon="table",this.figureScrollList=["se-scroll-figure-xy","se-scroll-figure-x","se-scroll-figure-y"],this.figureScroll="string"==typeof e.scrollType?e.scrollType.toLowerCase():"x",this.captionPosition="bottom"!==e.captionPosition?"top":"bottom",this.cellControllerTop="table"==("cell"!==e.cellControllerPosition?"table":"cell");const s=Pe.utils.createElement("DIV",{class:"se-dropdown se-selector-table"},'\n\t<div class="se-table-size">\n\t\t<div class="se-table-size-picker se-controller-table-picker"></div>\n\t\t<div class="se-table-size-highlighted"></div>\n\t\t<div class="se-table-size-unhighlighted"></div>\n\t</div>\n\t<div class="se-table-size-display">1 x 1</div>'),i=s.querySelector(".se-controller-table-picker"),n=function({lang:t,icons:e}){const s=`\n\t<div class="se-arrow se-arrow-down se-visible-hidden"></div>\n\t<div class="se-btn-group">\n\t\t<button type="button" data-command="openTableProperties" class="se-btn se-tooltip">\n\t\t\t${e.table_properties}\n\t\t\t<span class="se-tooltip-inner">\n\t\t\t\t<span class="se-tooltip-text">${t.tableProperties}</span>\n\t\t\t</span>\n\t\t</button>\n\t\t<button type="button" data-command="layout" class="se-btn se-tooltip _se_table_fixed_column">\n\t\t\t${e.fixed_column_width}\n\t\t\t<span class="se-tooltip-inner">\n\t\t\t\t<span class="se-tooltip-text">${t.fixedColumnWidth}</span>\n\t\t\t</span>\n\t\t</button>\n\t\t<button type="button" data-command="header" class="se-btn se-tooltip _se_table_header">\n\t\t\t${e.table_header}\n\t\t\t<span class="se-tooltip-inner">\n\t\t\t\t<span class="se-tooltip-text">${t.tableHeader}</span>\n\t\t\t</span>\n\t\t</button>\n\t\t<button type="button" data-command="caption" class="se-btn se-tooltip _se_table_caption">\n\t\t\t${e.caption}\n\t\t\t<span class="se-tooltip-inner">\n\t\t\t\t<span class="se-tooltip-text">${t.caption}</span>\n\t\t\t</span>\n\t\t</button>\n\t\t<button type="button" data-command="resize" class="se-btn se-tooltip _se_table_resize">\n\t\t\t${e.reduction}\n\t\t\t<span class="se-tooltip-inner">\n\t\t\t\t<span class="se-tooltip-text">${t.minSize}</span>\n\t\t\t</span>\n\t\t</button>\n\t\t<button type="button" data-command="copy" class="se-btn se-tooltip">\n\t\t\t${e.copy}\n\t\t\t<span class="se-tooltip-inner">\n\t\t\t\t<span class="se-tooltip-text">${t.copy}</span>\n\t\t\t</span>\n\t\t</button>\n\t\t<button type="button" data-command="remove" class="se-btn se-tooltip">\n\t\t\t${e.delete}\n\t\t\t<span class="se-tooltip-inner">\n\t\t\t\t<span class="se-tooltip-text">${t.remove}</span>\n\t\t\t</span>\n\t\t</button>\n\t</div>`;return Pe.utils.createElement("DIV",{class:"se-controller se-controller-table"},s)}(this.$),o=function({lang:t,icons:e},s){const i=`\n\t<div class="se-arrow se-arrow-${s?"down se-visible-hidden":"up"}"></div>\n <div class="se-btn-group">\n\t\t<button type="button" data-command="openCellProperties" class="se-btn se-tooltip">\n\t\t\t${e.cell_properties}\n\t\t\t<span class="se-tooltip-inner">\n\t\t\t\t<span class="se-tooltip-text">${t.cellProperties}</span>\n\t\t\t</span>\n\t\t</button>\n <button type="button" data-command="oncolumn" class="se-btn se-tooltip">\n ${e.table_column}\n <span class="se-tooltip-inner">\n <span class="se-tooltip-text">${t.column}</span>\n </span>\n </button>\n <button type="button" data-command="onrow" class="se-btn se-tooltip">\n ${e.table_row}\n <span class="se-tooltip-inner">\n <span class="se-tooltip-text">${t.row}</span>\n </span>\n </button>\n <button type="button" data-command="merge" class="se-btn se-tooltip" style="display: none;">\n ${e.merge_cell}\n <span class="se-tooltip-inner">\n <span class="se-tooltip-text">${t.mergeCells}</span>\n </span>\n </button>\n <button type="button" data-command="onsplit" class="se-btn se-tooltip">\n ${e.split_cell}\n <span class="se-tooltip-inner">\n <span class="se-tooltip-text">${t.splitCells}</span>\n </span>\n </button>\n\t\t<button type="button" data-command="unmerge" class="se-btn se-tooltip">\n ${e.unmerge_cell}\n <span class="se-tooltip-inner">\n <span class="se-tooltip-text">${t.unmergeCells}</span>\n </span>\n </button>\n </div>`,n=Pe.utils.createElement("DIV",{class:"se-controller se-controller-table-cell"},i);return{html:n,splitButton:n.querySelector('[data-command="onsplit"]'),columnButton:n.querySelector('[data-command="oncolumn"]'),rowButton:n.querySelector('[data-command="onrow"]'),mergeButton:n.querySelector('[data-command="merge"]'),unmergeButton:n.querySelector('[data-command="unmerge"]')}}(this.$,this.cellControllerTop);this.$.contextProvider.applyToRoots((t=>{t.get("wrapper").appendChild(Pe.utils.createElement("DIV",{class:Ia.replace(/^\./,"")})),t.get("wrapper").appendChild(Pe.utils.createElement("DIV",{class:La.replace(/^\./,"")})),t.get("wrapper").appendChild(Pe.utils.createElement("DIV",{class:Aa.replace(/^\./,"")})),t.get("wrapper").appendChild(Pe.utils.createElement("DIV",{class:Oa.replace(/^\./,"")}))})),this.cellControllerTop?(this.controller_cell=new Ii(this,this.$,o.html,{position:"top"}),this.controller_table=new Ii(this,this.$,n,{position:"top"}),this.controller_cell.sibling=this.controller_table.form,this.controller_table.sibling=this.controller_cell.form,this.controller_table.siblingMain=!0):(this.controller_table=new Ii(this,this.$,n,{position:"top"}),this.controller_cell=new Ii(this,this.$,o.html,{position:"bottom"})),this.figure=new ji(this,this.$,null,{}),this._element=null,this.state=Ua,this.#Hd=s,this.#qd=s.querySelector(".se-table-size-highlighted"),this.#Wd=s.querySelector(".se-table-size-unhighlighted"),this.#Ud=s.querySelector(".se-table-size-display");const r=mh.bind(this,!0),l=mh.bind(this,!1),a={...o,openCellMenuFunc:r,closeCellMenuFunc:l};this.cellService=new nh(this,a),this.clipboardService=new oh(this),this.gridService=new rh(this,a),this.resizeService=new ah(this),this.selectionService=new hh(this),this.styleService=new dh(this,{pluginOptions:e,controller_table:n}),this.$.menu.initDropdownTarget(gh,s),this.$.eventManager.addEvent(i,"mousemove",this.#Xd.bind(this)),this.$.eventManager.addEvent(i,"click",this.#Zd.bind(this))}setState(t,e){this.state[t]=e}#Jd(){Object.assign(this.state,Ua)}off(){this.#Qd()}componentSelect(t){if(this.#tu(t),this.state.figureElement||this.setTableInfo(t),this.#Gd="100%"===this.state.figureElement?.style.width,this.#Kd=Pe.utils.hasClass(t,"se-table-layout-fixed")||"fixed"===t.style.tableLayout,this.styleService.setTableLayout(this.#Gd?"width|column":"width",this.#Gd,this.#Kd,!0),_i.get("__overInfo")===ph)return;if(!this.state.tdElement)return;this.setCellInfo(this.state.tdElement,!0);const e=this.state.selectedCells?.length>1,s=Pe.query.getParentElement(t,Pe.check.isFigure);this.controller_table.open(s,null,{isWWTarget:!1,initMethod:null,addOffset:null,disabled:e}),this.state.fixedCell&&(this.cellService.setUnMergeButton(),this.controller_cell.open(this.state.tdElement,this.cellControllerTop?s:null,{isWWTarget:!1,initMethod:null,addOffset:null,disabled:e}))}componentDeselect(){this.resetInfo()}componentDestroy(t){if(!t)return;const e=t.parentNode;Pe.utils.removeItem(t),this._closeTableSelectInfo(),e!==this.$.frameContext.get("wysiwyg")&&this.$.nodeTransform.removeAllParents(e,(function(t){return 0===t.childNodes.length}),null),this.$.focusManager.focus(),this.$.history.push(!1)}componentCopy({event:t,cloneContainer:e}){const s=e.querySelectorAll(".se-selected-table-cell");Pe.utils.removeClass(s,"se-selected-table-cell|se-selected-cell-focus"),s.length>0&&(this.clipboardService.copySelectedTableCells(t,e,s),this.$.ui.showToast(this.$.lang.message_copy_success,550))}onPaste({event:t,doc:e}){const s=Pe.query.getParentElement(Pe.query.getEventTarget(t),Pe.check.isTableCell);if(!s)return;const i=e.body;if(1!==i.childElementCount)return;const n=this.$.component.get(i.firstElementChild);if(n?.pluginName!==gh.key)return;const o=n.target,r=this.clipboardService.pasteTableCellMatrix(o,s),{fixedCell:l,selectedCell:a}=this.selectionService.selectCells(r);return this.setState("selectedCells",r),this.setState("fixedCell",l),this.setState("selectedCell",a),this.setState("selectedTable",Pe.query.getParentElement(l,"TABLE")),!1}retainFormat(){return{query:"table",method:t=>{const e=t.querySelector("colgroup");let s=Pe.check.isFigure(t.parentNode)?t.parentNode:null;if(!e){const e=t.rows,s=function(t){const e=t.rows;let s=0;for(let t=0,i=e.length;t<i;t++){const i=e[t].cells;let n=0;for(let t=0,e=i.length;t<e;t++)n+=i[t].colSpan;s=Math.max(s,n)}return s}(t),i=new Array(s).fill(null);for(let t,n=0,o=e.length;n<o;n++){const o=e[n].cells;t=o.length;let r=0;const l=new Array(s).fill(!1);for(let e=0;e<t;e++){const t=o[e],n=t.style.width,a=t.colSpan||1;for(;r<s&&l[r];)r++;if(r>=s)break;n&&!i[r]&&(i[r]=n);for(let t=0;t<a;t++){if(r+t>=s||!n)continue;l[r+t]=!0;const e=De.get(n,-1);for(let t=0;t<a;t++){const o=r+t;if(o>=s)continue;const l=i[o];if(null===l)i[o]=`width: ${n};`;else{const t=De.get(l.replace("width: ","").replace(";",""),-1);1===a&&e!==t&&(i[o]=`width: ${n};`)}}}r+=a}if(t===s)break}const n=[];for(let t=0;t<s;t++){const e=i[t]?` style="${i[t]}"`:"";n.push(`<col${e}>`)}const o=Pe.utils.createElement("colgroup",null,n.join(""));t.insertBefore(o,t.firstElementChild);for(let t=0;t<e.length;t++){const s=e[t].cells;for(let t=0;t<s.length;t++)Pe.utils.setStyle(s[t],"width","")}}s?Pe.utils.addClass(s,"se-flex-component|se-input-component"):(s=Pe.utils.createElement("FIGURE",{class:"se-flex-component se-input-component"}),t.parentNode.insertBefore(s,t),s.appendChild(t));const i=t.style.width;if(i&&(s.style.width="auto"===i?"max-content":i,Pe.utils.setStyle(t,"width","")),this.figureScroll){const t=`se-scroll-figure-${this.figureScroll}`;Pe.utils.addClass(s,t),Pe.utils.removeClass(s,this.figureScrollList.filter((e=>e!==t)).join("|"))}else Pe.utils.removeClass(s,this.figureScrollList.join("|"))}}}setDir(){this.#Qd(),this.styleService.resetPropsAlign()}onMouseMove({event:t}){if(this.resizeService.isResizing())return;const e=Pe.query.getEventTarget(t),s=Pe.query.getParentElement(e,Ka);s&&1!==t.buttons?!1!==this.resizeService.onResizeGuide(t,s)&&(this._element&&(this._element.style.cursor=""),this.resizeService.offResizeGuide()):this.resizeService.offResizeGuide()}onMouseDown({event:t}){this.setState("ref",null),this.setState("selectedCell",null);const e=Pe.query.getEventTarget(t);if(this._element&&Pe.query.getParentElement(e,Ya))return void this._closeController();const s=Pe.query.getParentElement(e,Ka);s&&(this.cellControllerTop||this.controller_cell.hide(),!1!==this.resizeService.readyResizeFromEdge(t,s)&&(this.state.isShiftPressed&&s!==this.state.fixedCell||(this.selectionService.deleteStyleSelectedCells(),/^TR$/i.test(s.nodeName)||(this.#Yd=!1,this.selectionService.startCellSelection(s,!1)))))}onMouseUp(){this.setState("isShiftPressed",!1)}onMouseLeave(){this.resizeService.offResizeGuide()}onKeyDown({event:t,range:e,line:s}){this.setState("ref",null);const i=t.code,n=Fe.isTab(i);if(this.$.ui.selectMenuOn||this.resizeService.isResizing()||!n&&this.#Yd||Fe.isCtrl(t))return;if(this.cellControllerTop||this.controller_cell.hide(),this.#Yd=Fe.isShift(t),n){this.selectionService.deleteStyleSelectedCells();const i=Pe.query.getParentElement(s,Pe.check.isTableCell);if(i&&e.collapsed&&Pe.check.isEdgePoint(e.startContainer,e.startOffset)){this._closeController();const e=this.#Yd;this.setState("isShiftPressed",this.#Yd=!1);const s=Pe.query.getParentElement(i,"table"),n=Pe.query.getListChildren(s,Pe.check.isTableCell,null),o=e?Pe.utils.prevIndex(n,i):Pe.utils.nextIndex(n,i);if(o===n.length&&!e){if(!Pe.query.getParentElement(i,"thead")){const t=s.rows,e=this.gridService.insertBodyRow(s,t.length,this.state.cellCnt).querySelector("td div");this.$.selection.setRange(e,0,e,0)}return t.preventDefault(),t.stopPropagation(),!1}if(-1===o&&e)return!1;const r=n[o];if(!r)return;const l=r.firstElementChild||r;return this.$.selection.setRange(l,0,l,0),t.preventDefault(),t.stopPropagation(),!1}}let o=null;if(!Fe.isShift(t)){if(o=Pe.query.getParentElement(s,Pe.check.isTableCell),!Pe.utils.hasClass(o,"se-selected-cell-focus"))return;return this.selectionService.deleteStyleSelectedCells(),this._editorEnable(!0),this.#eu(),void this._closeController()}return this.state.isShiftPressed||this.state.ref?void 0:(o||=Pe.query.getParentElement(s,Pe.check.isTableCell),o?(this.#Yd=t.shiftKey,this.setState("fixedCell",o),this._closeController(),this.selectionService.startCellSelection(o,this.#Yd),!1):void 0)}onKeyUp({line:t}){this.#Yd=!1,this.state.isShiftPressed&&Pe.query.getParentElement(t,Pe.check.isTableCell)===this.state.fixedCell&&(this.selectionService.deleteStyleSelectedCells(),this._editorEnable(!0),this.#eu()),this.setState("isShiftPressed",!1)}onScroll(){this.resizeService.offResizeGuide()}controllerAction(t){const e=t.getAttribute("data-command");if(e){switch(e){case"header":this.styleService.toggleHeader(),this.historyPush();break;case"caption":this.styleService.toggleCaption(),this.historyPush();break;case"onsplit":this.cellService.openSplitMenu();break;case"oncolumn":this.gridService.openColumnMenu();break;case"onrow":this.gridService.openRowMenu();break;case"openTableProperties":this.styleService.openTableProps(t);break;case"openCellProperties":this.styleService.openCellProps(t);break;case"revert":this.styleService.revertProps();break;case"merge":this.cellService.mergeCells(this.state.selectedCells);break;case"unmerge":this.cellService.unmergeCells(this.state.selectedCells);break;case"resize":this.#Gd=!this.#Gd,this.styleService.setTableLayout("width",this.#Gd,this.#Kd,!1),this.historyPush(),uh.setTimeout((()=>{this.$.component.select(this._element,gh.key,{isInput:!0})}),0);break;case"layout":this.#Kd=!this.#Kd,this.styleService.setTableLayout("column",this.#Gd,this.#Kd,!1),this.historyPush(),uh.setTimeout((()=>{this.$.component.select(this._element,gh.key,{isInput:!0})}),0);break;case"copy":this.$.component.copy(this.state.figureElement);break;case"remove":this.componentDestroy(this.state.figureElement)}/(^revert|Properties$)/.test(e)||this.styleService.closeProps(),/^(remove|on|open)/.test(e)||this._setCellControllerPosition(this.state.tdElement,this.state.isShiftPressed)}}setCellInfo(t,e){const s=this.setTableInfo(t);if(s&&(this.setState("fixedCell",t),this.setState("trElement",t.parentNode),this.styleService.resetHeaderButton(s),this.styleService.resetCaptionButton(s),e||0===this.state.physical_cellCnt)){this.state.tdElement!==t&&this.setState("tdElement",t),this.state.selectedCells?.length||this.setState("selectedCells",[t]);const e=s.rows;this.setState("trElements",e);const i=t.cellIndex;let n=0;for(let t=0,s=e[0].cells,i=e[0].cells.length;t<i;t++)n+=s[t].colSpan;const o=this.state.trElement.rowIndex;this.setState("rowIndex",o),this.setState("rowCnt",e.length),this.setState("physical_cellCnt",this.state.trElement.cells.length),this.setState("logical_cellCnt",n),this.setState("cellCnt",n),this.setState("physical_cellIndex",i),this.setState("current_colSpan",this.state.tdElement.colSpan-1),this.setState("current_rowSpan",this.state.trElement.cells[i].rowSpan-1);const r=th(s,o,i);this.setState("logical_cellIndex",r)}}setRowInfo(t){const e=this.setTableInfo(t).rows;this.setState("trElements",e),this.setState("rowCnt",e.length),this.setState("rowIndex",t.rowIndex)}setTableInfo(t){const e=this._element=Pe.query.getParentElement(t,"TABLE");return this.setState("selectedTable",e),this.setState("figureElement",Pe.query.getParentElement(e,Pe.check.isFigure)||e),e}resetInfo(){this.#eu(),this.selectionService.deleteStyleSelectedCells(),this._editorEnable(!0),this._element=null,this.#Jd(),this.#jd=[],this.#Gd=!1,this.#Kd=!1}historyPush(){this.selectionService.deleteStyleSelectedCells(),this.$.history.push(!1),this.selectionService.recallStyleSelectedCells()}_setController(t){if(!this.$.selection.get().isCollapsed&&!this.state.selectedCell)return void this.selectionService.deleteStyleSelectedCells();this.cellService.setUnMergeButton(),this.setState("tdElement",t),this.state.fixedCell===t&&Pe.utils.addClass(t,"se-selected-cell-focus"),this.state.selectedCells?.length||this.setState("selectedCells",[t]);const e=this.state.selectedTable||this._element||Pe.query.getParentElement(t,"TABLE");this.$.component.select(e,gh.key,{isInput:!0})}_setCellControllerPosition(t,e){this.setCellInfo(t,e),this.cellControllerTop||this.controller_cell.resetPosition(t)}_editorEnable(t){const e=this.$.frameContext.get("wysiwyg");e.setAttribute("contenteditable",t.toString()),t?Pe.utils.removeClass(e,"se-disabled"):Pe.utils.addClass(e,"se-disabled")}_closeController(){this.controller_table.close(!0),this.controller_cell.close(!0)}_closeTableSelectInfo(){this.$.component.deselect(),this._closeController()}#tu(t){this.figure.open(t,{nonResizing:!0,nonSizeInfo:!0,nonBorder:!0,figureTarget:!0,infoOnly:!1})}#Qd(){if(!this.#qd)return;const t=this.#qd.style,e=this.#Wd.style;t.width="1em",t.height="1em",e.width="5em",e.height="5em",Pe.utils.changeTxt(this.#Ud,"1 x 1")}#Xd(t){t.stopPropagation();let e=Math.ceil(t.offsetX/18),s=Math.ceil(t.offsetY/18);e=e<1?1:e,s=s<1?1:s;const i=this.$.options.get("_rtl");i&&(e=11-e),this.#qd.style.width=e+"em",this.#qd.style.height=s+"em";const n=e<5?5:e>8?10:e+2,o=s<5?5:s>8?10:s+2;if(this.#Wd.style.width=n+"em",this.#Wd.style.height=o+"em",i){const t=n-(this.#Vd||5);if(0!==t){const e=De.get(this.#Hd.style.left);this.#Hd.style.left=e-18*t+"px",this.#Vd=n}}Pe.utils.changeTxt(this.#Ud,e+" x "+s),this.#jd=[e,s]}#Zd(){this.insert(this.#jd[0],this.#jd[1])}insert(t,e){const s=t>0?t:Ba[0],i=e>0?e:Ba[1],n=Pe.utils.createElement("TABLE"),o=`<tbody>${`<tr>${Ja("td",s)}</tr>`.repeat(i)}</tbody>`,r=`<colgroup>${`<col style="width: ${De.get(100/s,0)}%;">`.repeat(s)}</colgroup>`;n.innerHTML=r+o;let l="";this.figureScroll&&(l=` se-scroll-figure-${this.figureScroll}`);const a=Pe.utils.createElement("FIGURE",{class:"se-flex-component se-input-component"+l,style:"width: 100%;"});if(a.appendChild(n),this.#Gd=!0,!this.$.component.insert(a,{insertBehavior:"none"}))return!1;this.#Qd(),this.$.menu.dropdownOff();const h=n.querySelector("td div");return this.$.selection.setRange(h,0,h,0),!0}#eu(){this.resizeService.init(),this.selectionService.init(),this.styleService.init()}}function mh(t){this.controller_cell.bringToTop(t)}const fh=gh;class vh extends jl{static key="blockStyle";static className="se-btn-select se-btn-tool-format";constructor(t,e){super(t),this.title=this.$.lang.formats,this.inner='<span class="se-txt">'+this.$.lang.formats+"</span>"+this.$.icons.arrow_down;const s=this.$.menu.initDropdownTarget(vh,function({lang:t},e){const s=["p","blockquote","h1","h2","h3","h4","h5","h6"],i=e&&0!==e.length?e:s,n=[];for(let e,o,r,l,a,h,c,d=0,u=i.length;d<u;d++){if(e=i[d],"string"==typeof e){if(!s.includes(e))continue;o=e.toLowerCase(),r="blockquote"===o?"block":"pre"===o?"br-line":"line",a=/^h/.test(o)?o.match(/\d+/)[0]:"",l=t["tag_"+(a?"h":o)]+a,c="",h=""}else o=e.tag.toLowerCase(),r=e.command,l=e.name||o,c=e.class,h=c?' class="'+c+'"':"";n.push({command:r,value:o,title:l,innerHTML:`<${o}${h}>${l}</${o}>`,attrs:{"data-class":c||""}})}return n}(this.$,e.items),{className:"se-list-format"});this.formatList=s.querySelectorAll("li button"),this.currentFormat=""}active(t,e){let s=this.$.lang.formats;const i=e.querySelector(".se-txt");if(t){if(this.$.format.isLine(t)){const e=this.formatList,n=t.nodeName.toLowerCase(),o=(t.className.match(/(\s|^)__se__format__[^\s]+/)||[""])[0].trim();for(let t,i=0,r=e.length;i<r;i++)if(t=e[i],n===t.getAttribute("data-value")&&o===t.getAttribute("data-class")){s=t.title;break}return Pe.utils.changeTxt(i,s),i.setAttribute("data-value",n),i.setAttribute("data-class",o),!0}}else Pe.utils.changeTxt(i,s);return!1}on(t){const e=this.formatList,s=t.querySelector(".se-txt"),i=(s.getAttribute("data-value")||"")+(s.getAttribute("data-class")||"");if(i!==this.currentFormat){for(let t,s=0,n=e.length;s<n;s++)t=e[s],i===t.getAttribute("data-value")+t.getAttribute("data-class")?Pe.utils.addClass(t,"active"):Pe.utils.removeClass(t,"active");this.currentFormat=i}}action(t){const e=t.getAttribute("data-command"),s=t.firstElementChild;"block"===e?this.$.format.applyBlock(s):"br-line"===e?this.$.format.setBrLine(s):this.$.format.setLine(s),this.$.menu.dropdownOff()}applyHeaderByShortcut({keyCode:t}){const e=t.match(/\d+$/)?.[0],s=Pe.utils.createElement(`H${e}`);this.$.format.setLine(s)}}const bh=vh;class yh extends jl{static key="layout";static className="";constructor(t,e){super(t),this.title=this.$.lang.layout,this.icon="layout",this.selectedIndex=-1,this.items=e.items,this.$.menu.initDropdownTarget(yh,function(t){t&&0!==t.length||console.warn('[SUNEDITOR.plugins.layout.warn] To use the "layout" plugin, please define the "layouts" option.');return(t||[]).map(((t,e)=>({command:"layout",value:String(e),title:t.name,innerHTML:t.name})))}(this.items))}action(t){const e=Number(t.getAttribute("data-value")),s=this.items[this.selectedIndex=e];if(!s.html)throw this.$.menu.dropdownOff(),Error('[SUNEDITOR.layout.fail] cause : "layouts[i].html not found"');this.$.html.set(s.html),this.$.menu.dropdownOff()}}const wh=yh;class Ch extends jl{static key="lineHeight";static className="";#id;constructor(t,e){super(t),this.title=this.$.lang.lineHeight,this.icon="line_height";const s=`<li><button type="button" class="se-btn se-btn-list default_value" data-command="" title="${this.$.lang.default}" aria-label="${this.$.lang.default}">${this.$.lang.default}</button></li><li class="se-btn-list se-sub-list"><span></span></li>`,i=this.$.menu.initDropdownTarget(Ch,(e.items||[{text:"1",value:"1em"},{text:"1.2",value:"1.2em"},{text:"1.7",value:"1.7em"},{text:"2",value:"2em"}]).map((t=>({command:t.value,title:t.text,innerHTML:t.text}))),{prependHTML:s});this.sizeList=i.querySelectorAll("li button"),this.currentSize=null,this.#id=i.querySelector(".se-sub-list span")}active(t,e){return this.$.format.isLine(t)&&t.style.lineHeight.length>0?(Pe.utils.addClass(e,"active"),!0):(Pe.utils.removeClass(e,"active"),!1)}on(){const t=this.$.format.getLine(this.$.selection.getNode()),e=t?t.style.lineHeight+"":"";if(e!==this.currentSize){let t=!1;const s=this.sizeList;for(let i=0,n=s.length;i<n;i++)e===s[i].getAttribute("data-command")?(Pe.utils.addClass(s[i],"active"),t=!0):Pe.utils.removeClass(s[i],"active");this.currentSize=e,t?this.#id.style.display="none":(this.#id.textContent=e,this.#id.style.display="block")}}action(t){const e=t.getAttribute("data-command")||"",s=this.$.format.getLines();for(let t=0,i=s.length;t<i;t++)s[t].style.lineHeight=e;this.$.menu.dropdownOff(),this.$.store.set("_lastSelectionNode",null),this.$.history.push(!1)}}const _h=Ch;class kh extends jl{static key="template";static className="";constructor(t,e){super(t),this.title=this.$.lang.template,this.icon="template",this.selectedIndex=-1,this.items=e.items,this.$.menu.initDropdownTarget(kh,function(t){t&&0!==t.length||console.warn('[SUNEDITOR.plugins.template.warn] To use the "template" plugin, please define the "templates" option.');return(t||[]).map(((t,e)=>({command:"template",value:String(e),title:t.name,innerHTML:t.name})))}(this.items))}action(t){const e=Number(t.getAttribute("data-value")),s=this.items[this.selectedIndex=e];if(!s.html)throw this.$.menu.dropdownOff(),Error('[SUNEDITOR.template.fail] cause : "templates[i].html not found"');this.$.html.insert(s.html,{selectInserted:!1,skipCharCount:!1,skipCleaning:!1}),this.$.menu.dropdownOff()}}const xh=kh;class $h extends jl{static key="paragraphStyle";static className="";constructor(t,e){super(t),this.title=this.$.lang.paragraphStyle,this.icon="paragraph_style";const s=this.$.menu.initDropdownTarget($h,function({lang:t},e){const s={spaced:{name:t.menu_spaced,class:"__se__p-spaced",_class:""},bordered:{name:t.menu_bordered,class:"__se__p-bordered",_class:""},neon:{name:t.menu_neon,class:"__se__p-neon",_class:""}},i=e&&0!==e.length?e:["spaced","bordered","neon"],n=[];for(let t,e,o,r=0,l=i.length;r<l;r++){if(t=i[r],"string"==typeof t){const e=s[t.toLowerCase()];if(!e)continue;t=e}e=t.name,o=t.class?` class="${t.class}"`:"",n.push({command:t.class,title:e,innerHTML:`<div${o}>${e}</div>`,className:t._class||void 0})}return n}(this.$,e.items),{className:"se-list-format"});this.classList=s.querySelectorAll("li button")}on(){const t=this.classList,e=this.$.format.getLine(this.$.selection.getNode());for(let s=0,i=t.length;s<i;s++)Pe.utils.hasClass(e,t[s].getAttribute("data-command"))?Pe.utils.addClass(t[s],"active"):Pe.utils.removeClass(t[s],"active")}action(t){const e=t.getAttribute("data-command");let s=this.$.format.getLines();if(0!==s.length||(this.$.selection.getRangeAndAddLine(this.$.selection.getRange(),null),s=this.$.format.getLines(),0!==s.length)){for(let t=0,i=s.length;t<i;t++)Pe.utils.toggleClass(s[t],e);this.$.menu.dropdownOff(),this.$.history.push(!1)}}}const Sh=$h;class Eh extends jl{static key="textStyle";static className="";constructor(t,e){super(t),this.title=this.$.lang.textStyle,this.icon="text_style";const s=this.$.menu.initDropdownTarget(Eh,function({lang:t},e){const s={code:{name:t.menu_code,class:"__se__t-code",tag:"code"},shadow:{name:t.menu_shadow,class:"__se__t-shadow",tag:"span"}},i=e||Object.keys(s),n=[];for(let t,e,o,r,l=0,a=i.length;l<a;l++){if(t=i[l],"string"==typeof t){const e=s[t.toLowerCase()];if(!e)continue;t=e}o=t.name,e=t.tag||"span",r=`.${t.class.trim().replace(/\s+/g,",.")}`.replace(/,$/,""),n.push({command:e,value:r,title:o,innerHTML:`<${e} class="${t.class}">${o}</${e}>`})}return n}(this.$,e.items),{className:"se-list-format"});this.styleList=s.querySelectorAll("li button")}on(){const t=this.styleList,e=this.$.selection.getNode();for(let s,i,n,o=0,r=t.length;o<r;o++){s=t[o],i=s.getAttribute("data-value").split(",");for(let t,o,r=0;r<i.length;r++){for(t=e,n=!1;t&&!this.$.format.isLine(t)&&!this.$.component.is(t);){if(t.nodeName.toLowerCase()===s.getAttribute("data-command").toLowerCase()&&(o=i[r],/^\./.test(o)?Pe.utils.hasClass(t,o.replace(/^\./,"")):t.style[o])){n=!0;break}t=t.parentNode}if(!n)break}n?Pe.utils.addClass(s,"active"):Pe.utils.removeClass(s,"active")}}action(t){const e=t.firstElementChild,s=e.style.cssText.replace(/:.+(;|$)/g,",").split(",");s.pop();const i=e.classList;for(let t=0,e=i.length;t<e;t++)s.push("."+i[t]);const n=Pe.utils.hasClass(t,"active")?null:e.cloneNode(!1),o=n?null:[e.nodeName];this.$.inline.apply(n,{stylesToModify:s,nodesToRemove:o,strictRemove:!0}),this.$.menu.dropdownOff()}}const Th=Eh;const Mh=class extends Xl{static key="link";static className="se-icon-flip-rtl";#su;constructor(t,e){super(t),this.title=this.$.lang.link,this.icon="link",e.textToDisplay=!0,e.title=!0;const s=function({lang:t,icons:e}){const s=`\n\t<form>\n\t\t<div class="se-modal-header">\n\t\t\t<button type="button" data-command="close" class="se-btn se-close-btn" title="${t.close}" aria-label="${t.close}">\n\t\t\t\t${e.cancel}\n\t\t\t</button>\n\t\t\t<span class="se-modal-title">${t.link_modal_title}</span>\n\t\t</div>\n\t\t<div class="se-anchor-editor"></div>\n\t\t<div class="se-modal-footer">\n\t\t\t<button type="submit" class="se-btn-primary" title="${t.submitButton}" aria-label="${t.submitButton}">\n\t\t\t\t<span>${t.submitButton}</span>\n\t\t\t</button>\n\t\t</div>\n\t</form>`;return Pe.utils.createElement("DIV",{class:"se-modal-content"},s)}(this.$),i=function({lang:t,icons:e}){const s=`\n\t<div class="se-arrow se-arrow-up"></div>\n\t<div class="link-content">\n\t\t<span><a target="_blank" href=""></a> </span>\n\t\t<div class="se-btn-group">\n\t\t\t<button type="button" data-command="update" tabindex="-1" class="se-btn se-tooltip">\n\t\t\t\t${e.edit}\n\t\t\t\t<span class="se-tooltip-inner">\n\t\t\t\t\t<span class="se-tooltip-text">${t.edit}</span>\n\t\t\t\t</span>\n\t\t\t</button>\n\t\t\t<button type="button" data-command="copy" tabindex="-1" class="se-btn se-tooltip">\n\t\t\t\t${e.copy}\n\t\t\t\t<span class="se-tooltip-inner">\n\t\t\t\t\t<span class="se-tooltip-text">${t.copy}</span>\n\t\t\t\t</span>\n\t\t\t</button>\n\t\t\t<button type="button" data-command="unlink" tabindex="-1" class="se-btn se-tooltip se-icon-flip-rtl">\n\t\t\t\t${e.unlink}\n\t\t\t\t<span class="se-tooltip-inner">\n\t\t\t\t\t<span class="se-tooltip-text">${t.unlink}</span>\n\t\t\t\t</span>\n\t\t\t</button>\n\t\t\t<button type="button" data-command="delete" tabindex="-1" class="se-btn se-tooltip">\n\t\t\t\t${e.delete}\n\t\t\t\t<span class="se-tooltip-inner">\n\t\t\t\t\t<span class="se-tooltip-text">${t.remove}</span>\n\t\t\t\t</span>\n\t\t\t</button>\n\t\t</div>\n\t</div>`;return Pe.utils.createElement("DIV",{class:"se-controller se-controller-link"},s)}(this.$),n="string"==typeof e.uploadUrl?e.uploadUrl:null;this.target=null,this.isUpdateState=!1,this.pluginOptions={...e,uploadUrl:n,uploadHeaders:e.uploadHeaders||null,uploadSizeLimit:De.get(e.uploadSizeLimit,0),uploadSingleSizeLimit:De.get(e.uploadSingleSizeLimit,0),acceptedFormats:"string"==typeof e.acceptedFormats?e.acceptedFormats.trim():null,enableFileUpload:!!n},this.anchor=new Hl(this.$,s,this.pluginOptions),this.modal=new Rl(this,this.$,s),this.controller=new Ii(this,this.$,i,{position:"bottom",disabled:!1}),this.#su=this.controller.form.querySelector("a")}active(t){if(Pe.check.isAnchor(t)&&!t.hasAttribute("data-se-non-link")){const e=this.#su,s=t.getAttribute("href");return e.href=s,e.textContent=e.title=t.textContent,e.target=s?.startsWith("#")?t.target:"_blank",Pe.utils.addClass(t,"on"),this.anchor.set(t),this.controller.open(t,null,{isWWTarget:!1,initMethod:null,addOffset:null}),this.target=t,!0}return this.controller.close(),!1}open(){this.modal.open()}modalOn(t){this.isUpdateState=t,this.anchor.on(t)}async modalAction(){const t=this.anchor.create(!1);if(null===t)return!1;if(this.isUpdateState){const t=this.controller.currentTarget.childNodes[0];this.$.selection.setRange(t,0,t,t.textContent.length)}else{const e=this.$.format.getLines();if(e.length>1){if(!this.$.html.insertNode(Pe.utils.createElement(e[0].nodeName,null,t),{afterNode:null,skipCharCount:!1}))return!0}else if(!this.$.html.insertNode(t,{afterNode:null,skipCharCount:!1}))return!0;this.$.selection.setRange(t.childNodes[0],0,t.childNodes[0],t.textContent.length)}return this.$.history.push(!1),!0}modalInit(){this.controller.close(),this.anchor.init()}controllerAction(t){const e=t.getAttribute("data-command");if(/update/.test(e))this.modal.open();else if(/copy/.test(e))this.$.html.copy(this.target);else if(/unlink/.test(e)){const t=Pe.query.getEdgeChild(this.controller.currentTarget,(function(t){return 0===t.childNodes.length||3===t.nodeType}),!1),e=Pe.query.getEdgeChild(this.controller.currentTarget,(function(t){return 0===t.childNodes.length||3===t.nodeType}),!0);this.$.selection.setRange(t,0,e,e.textContent.length),this.$.inline.apply(null,{stylesToModify:null,nodesToRemove:["A"],strictRemove:!1})}else Pe.utils.removeItem(this.controller.currentTarget),this.controller.currentTarget=null,this.$.focusManager.focus(),this.$.history.push(!1)}controllerClose(){Pe.utils.removeClass(this.controller.currentTarget,"on")}},Nh="%",Bh="px",Ih={BLOCK:"block",INLINE:"inline"},Lh="image/*";const Ah=class{#od;#J;#I;#iu;#dd;#nu;#ou;#ru={w:0,h:0};#lu=null;#au=null;#hu=null;constructor(t,e){if(this.#od=t,this.#J=t.$,this.#I=t.state,this.#iu=t.pluginOptions,this.#dd=this.#iu.canResize,this.#nu="auto"===this.#iu.defaultWidth?"":this.#iu.defaultWidth,this.#ou="auto"===this.#iu.defaultHeight?"":this.#iu.defaultHeight,this.#dd){this.#lu=e.proportion,this.#au=e.inputX,this.#hu=e.inputY,this.#au.value=this.#iu.defaultWidth,this.#hu.value=this.#iu.defaultHeight;const t=this.#cu.bind(this);this.#J.eventManager.addEvent(this.#au,"keyup",this.#du.bind(this,"x")),this.#J.eventManager.addEvent(this.#hu,"keyup",this.#du.bind(this,"y")),this.#J.eventManager.addEvent(this.#au,"change",t),this.#J.eventManager.addEvent(this.#hu,"change",t),this.#J.eventManager.addEvent(this.#lu,"change",t),this.#J.eventManager.addEvent(e.revertBtn,"click",this.#uu.bind(this))}}setInputSize(t,e){this.#au.value="auto"===t?"":t,this.#I.onlyPercentage||(this.#hu.value="auto"===e?"":e)}getInputSize(){return{w:this.#au?.value||"",h:this.#hu?.value||""}}setOriginSize(t,e){this.#nu=t,this.#ou=e}applySize(t,e){t||=this.#au?.value||this.#iu.defaultWidth,e||=this.#hu?.value||this.#iu.defaultHeight,this.#I.onlyPercentage&&(t?/%$/.test(t)||(t+=Nh):t="100%"),this.#od.figure.setSize(t,e)}on(){if(!this.#dd)return;const t=this.#iu.defaultWidth,e=this.#iu.defaultHeight;this.setInputSize(t,e),this.setOriginSize(t,e)}ready(t,e,s){this.setInputSize(e,s);const i=this.#I.onlyPercentage&&this.#od.figure.isVertical;this.#lu.checked=!0,this.#au.disabled=i,this.#hu.disabled=i,this.#lu.disabled=i,this.#ru=this.#lu.checked?t.ratio:{w:0,h:0}}init(){this.#ru={w:0,h:0},this.#dd&&(this.setInputSize(this.#iu.defaultWidth,this.#iu.defaultHeight),this.#lu.checked=!0)}#du(t,e){if(Fe.isSpace(e.code))return void e.preventDefault();const s=e.target;if("x"===t&&this.#I.onlyPercentage&&Number(s.value)>100)s.value="100";else if(this.#lu.checked){const e=ji.CalcRatio(this.#au.value,this.#hu.value,this.#I.sizeUnit,this.#ru);"x"===t?this.#hu.value=String(e.h):this.#au.value=String(e.w)}}#cu(){this.#ru=this.#lu.checked?ji.GetRatio(this.#au.value,this.#hu.value,this.#I.sizeUnit):{w:0,h:0}}#uu(){this.#I.onlyPercentage?this.#au.value=Number(this.#nu)>100?"100":this.#nu:(this.#au.value=this.#nu,this.#hu.value=this.#ou)}},{NO_EVENT:Oh}=Oe;const Rh=class{#od;#J;#iu;#dd;constructor(t){this.#od=t,this.#J=t.$,this.#iu=t.pluginOptions,this.#dd=this.#iu.canResize,this._base64RenderIndex=0}get#pu(){return this.#od.sizeService}serverUpload(t){if(!t.files)return;const e=this.#iu.uploadUrl;"string"==typeof e&&e.length>0?this.#od.fileManager.upload(e,this.#iu.uploadHeaders,t.files,this.#gu.bind(this,t),this.#pc.bind(this)):this.#mu(t)}urlUpload(t){this.#od.setState("produceIndex",0);const e=t.url;this.#od.modal.isUpdate?this.#fu(e,t.element,t.files):this.#vu(e,t.anchor,t.inputWidth,t.inputHeight,t.align,t.files,t.alt,!0)}#vu(t,e,s,i,n,o,r,l){this.#od.as!==Ih.INLINE?this.#od.create(t,e,s,i,n,o,r,l):this.#od.createInline(t,e,s,i,o,r,l)}#fu(t,e,s){e.src=t,this.#od.fileManager.setFileData(e,s),this.#J.component.select(e,this.#od.constructor.key)}#uc(t,e){this.#od.setState("produceIndex",0);const s=e.result;for(let e,i=0,n=s.length;i<n;i++){if(e={name:s[i].name,size:s[i].size},t.isUpdate){this.#fu(s[i].url,t.element,e);break}this.#vu(s[i].url,t.anchor,t.inputWidth,t.inputHeight,t.align,e,t.alt,i===n-1)}}#mu(t){try{const{files:e,element:s,anchor:i,inputWidth:n,inputHeight:o,align:r,alt:l,isUpdate:a}=t,h=this.#od.modal.isUpdate?1:e.length;if(0===h)return this.#J.ui.hideLoading(),void console.warn("[SUNEDITOR.image.base64.fail] cause : No applicable files");this._base64RenderIndex=h;const c=new Array(h);this.#dd&&this.#pu.setInputSize(n,o);for(let t,d,u=0,p=this.#bu.bind(this);u<h;u++)t=new FileReader,d=e[u],t.onload=function(t,e,s,a,h,d){c[d]={result:e.result,file:h},0==--this._base64RenderIndex&&(t(s,c,a,i,n,o,r,l),this.#J.ui.hideLoading())}.bind(this,p,t,a,s,d,u),t.readAsDataURL(d)}catch(t){throw this.#J.ui.hideLoading(),Error(`[SUNEDITOR.plugins.image._setBase64.fail] ${t.message}`)}}#bu(t,e,s,i,n,o,r,l){this.#od.setState("produceIndex",0);for(let a=0,h=e.length;a<h;a++)t?this.#fu(e[a].result,s,e[a].file):this.#vu(e[a].result,i,n,o,r,e[a].file,l,a===h-1)}async#pc(t){const e=await this.#J.eventManager.triggerEvent("onImageUploadError",{error:t}),s=e===Oh?t.errorMessage:e||t.errorMessage;this.#J.ui.alertOpen(s,"error"),console.error("[SUNEDITOR.plugin.image.error]",s)}async#gu(t,e){if(await this.#J.eventManager.triggerEvent("imageUploadHandler",{xmlHttp:e,info:t})===Oh){const s=JSON.parse(e.responseText);s.errorMessage?this.#pc(s):this.#uc(t,s)}}},{NO_EVENT:zh}=Oe;const Ph=class extends Xl{static key="image";static className="";static component(t){const e=Pe.check.isFigure(t)||/^span$/i.test(t.nodeName)&&Pe.check.isComponentContainer(t)?t.firstElementChild:t;return/^IMG$/i.test(e?.nodeName)?e:Pe.check.isAnchor(e)&&/^IMG$/i.test(e?.firstElementChild?.nodeName)?e?.firstElementChild:null}#dd;#yu;#wu=null;#Cu="";#_u="none";#ku="30%";#zc=null;#xu=null;#$u=null;#Su=null;constructor(t,e){super(t),this.title=this.$.lang.image,this.icon="image",this.pluginOptions={canResize:void 0===e.canResize||e.canResize,showHeightInput:void 0===e.showHeightInput||!!e.showHeightInput,defaultWidth:e.defaultWidth?De.is(e.defaultWidth)?e.defaultWidth+Bh:e.defaultWidth:"auto",defaultHeight:e.defaultHeight?De.is(e.defaultHeight)?e.defaultHeight+Bh:e.defaultHeight:"auto",percentageOnlySize:!!e.percentageOnlySize,createFileInput:void 0===e.createFileInput||e.createFileInput,createUrlInput:void 0===e.createUrlInput||!e.createFileInput||e.createUrlInput,uploadUrl:"string"==typeof e.uploadUrl?e.uploadUrl:null,uploadHeaders:e.uploadHeaders||null,uploadSizeLimit:De.get(e.uploadSizeLimit,0),uploadSingleSizeLimit:De.get(e.uploadSingleSizeLimit,0),allowMultiple:!!e.allowMultiple,acceptedFormats:"string"!=typeof e.acceptedFormats||"*"===e.acceptedFormats.trim()?Lh:e.acceptedFormats.trim()||Lh,useFormatType:e.useFormatType??!0,defaultFormatType:[Ih.BLOCK,Ih.INLINE].includes(e.defaultFormatType)?e.defaultFormatType:Ih.BLOCK,keepFormatType:e.keepFormatType??!1,insertBehavior:e.insertBehavior};const s=this.pluginOptions.percentageOnlySize?Nh:Bh,i=function({lang:t,icons:e,plugins:s},i){const n=i.createFileInput?`\n\t\t<div class="se-modal-form">\n\t\t\t<label>${t.image_modal_file}</label>\n\t\t\t${Rl.CreateFileInput({icons:e,lang:t},i)}\n\t\t</div>`:"",o=i.createUrlInput?`\n\t\t<div class="se-modal-form">\n\t\t\t<label>${t.image_modal_url}</label>\n\t\t\t<div class="se-modal-form-files">\n\t\t\t\t<input class="se-input-form se-input-url" data-focus type="text" />\n\t\t\t\t${s.imageGallery?`<button type="button" class="se-btn se-tooltip se-modal-files-edge-button __se__gallery" aria-label="${t.imageGallery}">\n\t\t\t\t\t\t\t${e.image_gallery}\n\t\t\t\t\t\t\t${Pe.utils.createTooltipInner(t.imageGallery)}\n\t\t\t\t\t\t\t</button>`:""}\n\t\t\t</div>\n\t\t\t<pre class="se-link-preview"></pre>\n\t\t</div>`:"",r=i.canResize?`\n\t\t<div class="se-modal-form">\n\t\t\t<div class="se-modal-size-text">\n\t\t\t\t<label class="size-w">${t.width}</label>\n\t\t\t\t<label class="se-modal-size-x"> </label>\n\t\t\t\t<label class="size-h">${t.height}</label>\n\t\t\t</div>\n\t\t\t<input class="se-input-control _se_size_x" placeholder="auto" type="text" />\n\t\t\t<label class="se-modal-size-x">x</label>\n\t\t\t<input type="text" class="se-input-control _se_size_y" placeholder="auto" />\n\t\t\t<label><input type="checkbox" class="se-modal-btn-check _se_check_proportion" checked/> ${t.proportion}</label>\n\t\t\t<button type="button" aria-label="${t.revert}" class="se-btn se-tooltip se-modal-btn-revert">\n\t\t\t\t${e.revert}\n\t\t\t\t${Pe.utils.createTooltipInner(t.revert)}\n\t\t\t</button>\n\t\t</div>`:"",l=i.useFormatType?`\n\t\t<div class="se-modal-form">\n\t\t\t<div class="se-modal-flex-form">\n\t\t\t\t<button type="button" data-command="asBlock" class="se-btn se-tooltip" aria-label="${t.inlineStyle}">\n\t\t\t\t\t${e.as_block}\n\t\t\t\t\t${Pe.utils.createTooltipInner(t.blockStyle)}\n\t\t\t\t</button>\n\t\t\t\t<button type="button" data-command="asInline" class="se-btn se-tooltip" aria-label="${t.inlineStyle}">\n\t\t\t\t\t${e.as_inline}\n\t\t\t\t\t${Pe.utils.createTooltipInner(t.inlineStyle)}\n\t\t\t\t</button>\n\t\t\t</div>\n\t\t</div>`:"",a=`\n\t\t<div class="se-modal-header">\n\t\t\t<button type="button" data-command="close" class="se-btn se-close-btn close" title="${t.close}" aria-label="${t.close}">${e.cancel}</button>\n\t\t\t<span class="se-modal-title">${t.image_modal_title}</span>\n\t\t</div>\n\t\t<div class="se-modal-tabs">\n\t\t\t<button type="button" class="_se_tab_link active" data-tab-link="image">${t.image}</button>\n\t\t\t<button type="button" class="_se_tab_link" data-tab-link="url">${t.link}</button>\n\t\t</div>\n\t\t<form method="post" enctype="multipart/form-data">\n\t\t\t<div class="_se_tab_content _se_tab_content_image">\n\t\t\t\t<div class="se-modal-body">\n\t\t\t\t\t${n}\n\t\t\t\t\t${o}\n\t\t\t\t\t<div class="se-modal-hr"></div>\n\t\t\t\t\t<div class="se-modal-form">\n\t\t\t\t\t\t<label>${t.image_modal_altText}</label><input class="se-input-form _se_image_alt" type="text" />\n\t\t\t\t\t</div>\n\t\t\t\t\t${r}\n\t\t\t\t\t${l}\n\t\t\t\t\t<div class="se-modal-form se-modal-form-footer">\n\t\t\t\t\t\t<label><input type="checkbox" class="se-modal-btn-check _se_image_check_caption" /> ${t.caption}</label>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t<div class="se-anchor-editor _se_tab_content _se_tab_content_url" style="display: none;">\n\t\t\t</div>\n\t\t\t<div class="se-modal-footer">\n\t\t\t\t<div class="se-figure-align">\n\t\t\t\t\t<label><input type="radio" name="suneditor_image_radio" class="se-modal-btn-radio" value="none" checked>${t.basic}</label>\n\t\t\t\t\t<label><input type="radio" name="suneditor_image_radio" class="se-modal-btn-radio" value="left">${t.left}</label>\n\t\t\t\t\t<label><input type="radio" name="suneditor_image_radio" class="se-modal-btn-radio" value="center">${t.center}</label>\n\t\t\t\t\t<label><input type="radio" name="suneditor_image_radio" class="se-modal-btn-radio" value="right">${t.right}</label>\n\t\t\t\t</div>\n\t\t\t\t<button type="submit" class="se-btn-primary" title="${t.submitButton}" aria-label="${t.submitButton}"><span>${t.submitButton}</span></button>\n\t\t\t</div>\n\t\t</form>`,h=Pe.utils.createElement("DIV",{class:"se-modal-content"},a);return{html:h,alignForm:h.querySelector(".se-figure-align"),fileModalWrapper:h.querySelector(".se-flex-input-wrapper"),imgInputFile:h.querySelector(".__se__file_input"),imgUrlFile:h.querySelector(".se-input-url"),altText:h.querySelector("._se_image_alt"),captionCheckEl:h.querySelector("._se_image_check_caption"),previewSrc:h.querySelector("._se_tab_content_image .se-link-preview"),tabs:h.querySelector(".se-modal-tabs"),galleryButton:h.querySelector(".__se__gallery"),proportion:h.querySelector("._se_check_proportion"),inputX:h.querySelector("._se_size_x"),inputY:h.querySelector("._se_size_y"),revertBtn:h.querySelector(".se-modal-btn-revert"),asBlock:h.querySelector('[data-command="asBlock"]'),asInline:h.querySelector('[data-command="asInline"]'),fileRemoveBtn:h.querySelector(".se-file-remove")}}(this.$,this.pluginOptions),n=this.pluginOptions.useFormatType?"as":"",o=e.controls||(this.pluginOptions.canResize?[[n,"resize_auto,100,75,50","rotate_l","rotate_r","mirror_h","mirror_v"],["edit","align","caption","revert","copy","remove"]]:[[n,"mirror_h","mirror_v","align","caption","edit","revert","copy","remove"]]);this.alignForm=i.alignForm,o.some((t=>t.includes("align")))||(this.alignForm.style.display="none");const r=this.$.plugins.link?this.$.plugins.link.pluginOptions:{};this.anchor=new Hl(this.$,i.html,{...r,textToDisplay:!1,title:!0}),this.modal=new Rl(this,this.$,i.html),this.figure=new ji(this,this.$,o,{sizeUnit:s}),this.fileManager=new Pl(this,this.$,{query:"img",loadEventName:"onImageLoad",actionEventName:"onImageAction"}),this.state={sizeUnit:s,onlyPercentage:this.pluginOptions.percentageOnlySize,produceIndex:0},this.fileModalWrapper=i.fileModalWrapper,this.imgInputFile=i.imgInputFile,this.imgUrlFile=i.imgUrlFile,this.focusElement=this.imgInputFile||this.imgUrlFile,this.altText=i.altText,this.captionCheckEl=i.captionCheckEl,this.captionEl=this.captionCheckEl?.parentElement,this.previewSrc=i.previewSrc,this.as=Ih.BLOCK,this.#dd=this.pluginOptions.canResize,this.#yu=!this.#dd||!this.pluginOptions.showHeightInput||this.pluginOptions.percentageOnlySize,this.sizeService=new Ah(this,i),this.uploadService=new Rh(this),this.$.eventManager.addEvent(i.tabs,"click",this.#Eu.bind(this)),this.imgInputFile&&this.$.eventManager.addEvent(i.fileRemoveBtn,"click",this.#Tu.bind(this)),this.imgUrlFile&&this.$.eventManager.addEvent(this.imgUrlFile,"input",this.#Mu.bind(this)),this.imgInputFile&&this.imgUrlFile&&this.$.eventManager.addEvent(this.imgInputFile,"change",this.#Nu.bind(this));const l=i.galleryButton;l&&this.$.eventManager.addEvent(l,"click",this.#Bu.bind(this)),this.pluginOptions.useFormatType&&(this.as=this.pluginOptions.defaultFormatType,this.asBlock=i.asBlock,this.asInline=i.asInline,this.$.eventManager.addEvent([this.asBlock,this.asInline],"click",this.#Iu.bind(this)))}setState(t,e){this.state[t]=e}open(){this.state.produceIndex=0,this.modal.open()}retainFormat(){return{query:"img",method:t=>{const e=ji.GetContainer(t);if(e&&e.container&&(e.cover||e.inlineCover))return;const{w:s,h:i}=this.#Lu(t,!0);this.#Au(s,i)}}}onFilePasteAndDrop({file:t}){/^image/.test(t.type)&&(this.submitFile([t]),this.$.focusManager.focus())}modalOn(t){t?this.imgInputFile&&this.pluginOptions.allowMultiple&&this.imgInputFile.removeAttribute("multiple"):(this.sizeService.on(),this.imgInputFile&&this.pluginOptions.allowMultiple&&this.imgInputFile.setAttribute("multiple","multiple")),this.anchor.on(t)}async modalAction(){return this.#_u=this.modal.form.querySelector('input[name="suneditor_image_radio"]:checked').value,this.modal.isUpdate&&(this.#Ou(),this.$.history.push(!1)),this.imgInputFile&&this.imgInputFile.files.length>0?await this.submitFile(this.imgInputFile.files):!!(this.imgUrlFile&&this.#Cu.length>0)&&await this.submitURL(this.#Cu)}modalInit(){Rl.OnChangeFile(this.fileModalWrapper,[]),this.imgInputFile&&(this.imgInputFile.value=""),this.imgUrlFile&&(this.#Cu=this.previewSrc.textContent=this.imgUrlFile.value=""),this.imgInputFile&&this.imgUrlFile&&(this.imgUrlFile.disabled=!1,this.previewSrc.style.textDecoration=""),this.altText.value="",this.modal.form.querySelector('input[name="suneditor_image_radio"][value="none"]').checked=!0,this.captionCheckEl.checked=!1,this.#zc=null,this.#Eu("init"),this.sizeService.init(),this.pluginOptions.useFormatType&&this.#Ru((this.pluginOptions.keepFormatType?this.as:this.pluginOptions.defaultFormatType)===Ih.INLINE),this.anchor.init()}componentSelect(t){this.#Lu(t)}componentEdit(){this.modal.open()}async componentDestroy(t){const e=t||this.#zc,s=Pe.query.getParentElement(e,ji.is)||e,i=s.previousElementSibling||s.nextElementSibling,n=s.parentNode;!1!==await this.$.eventManager.triggerEvent("onImageDeleteBefore",{element:e,container:s,align:this.#_u,alt:this.altText.value,url:this.#Cu})&&(Pe.utils.removeItem(s),this.modalInit(),n!==this.$.frameContext.get("wysiwyg")&&this.$.nodeTransform.removeAllParents(n,(function(t){return 0===t.childNodes.length}),null),this.$.focusManager.focusEdge(i),this.$.history.push(!1))}async submitFile(t){if(0===t.length)return!1;let e=0;const s=[],i=this.pluginOptions.uploadSingleSizeLimit;for(let n,o,r=0,l=t.length;r<l;r++)if(n=t[r],/image/i.test(n.type)){if(o=n.size,i>0&&o>i){const t="[SUNEDITOR.imageUpload.fail] Size of uploadable single file: "+i/1e3+"KB",e=await this.$.eventManager.triggerEvent("onImageUploadError",{error:t,limitSize:i,uploadSize:o,file:n});return this.$.ui.alertOpen(e===zh?t:e||t,"error"),!1}s.push(n),e+=o}const n=this.pluginOptions.uploadSizeLimit,o=this.fileManager.getSize();if(n>0&&e+o>n){const t="[SUNEDITOR.imageUpload.fail] Size of uploadable total images: "+n/1e3+"KB",s=await this.$.eventManager.triggerEvent("onImageUploadError",{error:t,limitSize:n,currentSize:o,uploadSize:e});return this.$.ui.alertOpen(s===zh?t:s||t,"error"),!1}const r={files:s,...this.#zu()},l=function(t,e,s){t(e=s||e)}.bind(this,this.uploadService.serverUpload.bind(this.uploadService),r),a=await this.$.eventManager.triggerEvent("onImageUploadBefore",{info:r,handler:l});return void 0===a||!1!==a&&(null!==a&&"object"==typeof a&&l(a),void(!0!==a&&a!==zh||l(null)))}async submitURL(t){if(!(t||=this.#Cu))return!1;const e={name:t.split("/").pop(),size:0},s={url:t,files:e,...this.#zu()},i=function(t,e,s){t(e=s||e)}.bind(this,this.uploadService.urlUpload.bind(this.uploadService),s),n=await this.$.eventManager.triggerEvent("onImageUploadBefore",{info:s,handler:i});return void 0===n||!1!==n&&(null!==n&&"object"==typeof n&&i(n),!0!==n&&n!==zh||i(null),!0)}create(t,e,s,i,n,o,r,l){const a=Pe.utils.createElement("IMG");a.src=t,a.alt=r,e=this.#Pu(a,e?e.cloneNode(!1):null);const h=ji.CreateContainer(e,"se-image-container"),c=h.cover,d=h.container;this.captionCheckEl.checked&&(this.#Su=ji.CreateCaption(c,this.$.lang.caption)),this.#zc=a,this.#xu=c,this.#$u=d,this.figure.open(a,{nonResizing:this.#yu,nonSizeInfo:!1,nonBorder:!1,figureTarget:!1,infoOnly:!0}),this.sizeService.applySize(s,i),this.figure.setAlign(a,n),this.fileManager.setFileData(a,o),this.setState("produceIndex",this.state.produceIndex+1),a.onload=this.#Du.bind(this,a,this.#ku,d),this.$.component.insert(d,{scrollTo:!!l,insertBehavior:l?null:"line"})}createInline(t,e,s,i,n,o,r){const l=Pe.utils.createElement("IMG");l.src=t,l.alt=o,e=this.#Pu(l,e?e.cloneNode(!1):null);const a=ji.CreateInlineContainer(e,"se-image-container").container;this.#zc=l,this.#$u=a,this.figure.open(l,{nonResizing:this.#yu,nonSizeInfo:!1,nonBorder:!1,figureTarget:!1,infoOnly:!0}),this.sizeService.applySize(s,i),this.fileManager.setFileData(l,n),this.setState("produceIndex",this.state.produceIndex+1),l.onload=this.#Du.bind(this,l,this.#ku,a),this.$.component.insert(a,{scrollTo:!!r,insertBehavior:r?null:"line"})}#Lu(t,e=!1){if(!t)return;const s=this.figure.open(t,{nonResizing:this.#yu,nonSizeInfo:!1,nonBorder:!1,figureTarget:!1,infoOnly:e});this.anchor.set(Pe.check.isAnchor(t.parentNode)?t.parentNode:null),this.#wu=this.anchor.currentTarget,this.#zc=t,this.#xu=s.cover,this.#$u=s.container,this.#Su=s.caption,this.#_u=s.align,t.style.float="",this.sizeService.setOriginSize(String(s.originWidth||s.w||""),String(s.originHeight||s.h||"")),this.altText.value=this.#zc.alt,this.imgUrlFile&&(this.#Cu=this.previewSrc.textContent=this.imgUrlFile.value=this.#zc.src);(this.modal.form.querySelector('input[name="suneditor_image_radio"][value="'+this.#_u+'"]')||this.modal.form.querySelector('input[name="suneditor_image_radio"][value="none"]')).checked=!0,this.captionCheckEl.checked=!!this.#Su;const{dw:i,dh:n}=this.figure.getSize(t);return this.#dd?(this.sizeService.ready(s,i,n),this.pluginOptions.useFormatType&&this.#Ru(this.$.component.isInline(s.container)),{w:i,h:n}):{w:i,h:n}}#zu(){const{w:t,h:e}=this.sizeService.getInputSize();return{element:this.#zc,anchor:this.anchor.create(!0),inputWidth:t,inputHeight:e,align:this.#_u,isUpdate:this.modal.isUpdate,alt:this.altText.value}}#Ru(t){t?(Pe.utils.addClass(this.asInline,"on"),Pe.utils.removeClass(this.asBlock,"on"),this.as=Ih.INLINE,this.alignForm&&(this.alignForm.style.display="none"),this.captionEl&&(this.captionEl.style.display="none")):(Pe.utils.addClass(this.asBlock,"on"),Pe.utils.removeClass(this.asInline,"on"),this.as=Ih.BLOCK,this.alignForm&&(this.alignForm.style.display=""),this.captionEl&&(this.captionEl.style.display=""))}#Ou(){const{w:t,h:e}=this.sizeService.getInputSize(),s=t||"auto",i=e||"auto";let n=this.#zc;(this.as===Ih.BLOCK&&!this.#xu||this.as===Ih.INLINE&&this.#xu)&&(n=this.figure.convertAsFormat(n,this.as));const o=this.#xu,r=this.#$u===this.#xu?null:this.#$u;let l;const a=De.is(s)?s+this.state.sizeUnit:s,h=De.is(i)?i+this.state.sizeUnit:i;l=/%$/.test(n.style.width)?a!==r.style.width||h!==r.style.height:a!==n.style.width||h!==n.style.height,n.alt=this.altText.value;let c=!1;this.captionCheckEl.checked?this.#Su||(this.#Su=ji.CreateCaption(o,this.$.lang.caption),c=!0):this.#Su&&(Pe.utils.removeItem(this.#Su),this.#Su=null,c=!0);let d=!1;const u=this.anchor.create(!0);if(u)this.#wu===u&&r.contains(u)||(this.#wu=u.cloneNode(!1),o.insertBefore(this.#Pu(n,this.#wu),this.#Su),d=!0);else if(null!==this.#wu&&o.contains(this.#wu)){const t=n.cloneNode(!0);o.removeChild(this.#wu),o.insertBefore(t,this.#Su),n=t}d&&Pe.utils.removeItem(u),this.#dd&&l&&this.sizeService.applySize(s,i),(c||!this.state.onlyPercentage&&l)&&(/\d+/.test(n.style.height)||this.figure.isVertical&&this.captionCheckEl.checked)&&(/auto|%$/.test(s)||/auto|%$/.test(i)?this.figure.deleteTransform(n):this.#dd&&l&&this.figure.isVertical||this.figure.setTransform(n,s,i,0)),this.figure.setAlign(n,this.#_u),n.onload=()=>{this.componentSelect(n)}}#Au(t,e){const{w:s,h:i}=this.sizeService.getInputSize();t||=s||"auto",e||=i||"auto";let n=this.#zc,o=this.#xu,r=null,l=this.#$u===this.#xu?null:this.#$u,a=!1;if(!o||!l){a=!0,n=this.#zc.cloneNode(!0);const e=this.pluginOptions.useFormatType&&"auto"!==t&&(/^span$/i.test(this.#zc.parentElement?.nodeName)||this.$.format.isLine(this.#zc.parentElement))?ji.CreateInlineContainer(n,"se-image-container"):ji.CreateContainer(n,"se-image-container");o=e.cover,l=e.container,r=e.inlineCover,this.figure.open(n,{nonResizing:!0,nonSizeInfo:!1,nonBorder:!1,figureTarget:!1,infoOnly:!0})}n.alt=this.altText.value;let h=!1;r||(this.captionCheckEl.checked?this.#Su&&!a||(this.#Su=ji.CreateCaption(o,this.$.lang.caption),h=!0):this.#Su&&(Pe.utils.removeItem(this.#Su),this.#Su=null,h=!0));let c=null;const d=this.anchor.create(!0,Pe.check.isAnchor(this.#zc.parentElement)?this.#zc.parentElement.href:null);if(d)(this.#wu!==d||a&&!l.contains(d))&&(this.#wu=d.cloneNode(!1),o.insertBefore(this.#Pu(n,this.#wu),this.#Su),c=this.#zc);else if(null!==this.#wu&&o.contains(this.#wu)){const t=n.cloneNode(!0);o.removeChild(this.#wu),o.insertBefore(t,this.#Su),n=t}a&&(n=this.#zc,this.figure.retainFigureFormat(l,this.#zc,c?d:null,this.fileManager),this.#zc=n=l.querySelector("img"),this.#xu=o,this.#$u=l),n.style.width="",n.style.height="",n.removeAttribute("width"),n.removeAttribute("height"),this.sizeService.applySize(t,e),c&&(a?(Pe.utils.removeItem(c),0===Pe.query.getListChildren(d,(t=>/IMG/i.test(t.tagName)),null).length&&Pe.utils.removeItem(d)):Pe.utils.removeItem(d)),!h&&this.state.onlyPercentage||(/\d+/.test(n.style.height)||this.figure.isVertical&&this.captionCheckEl.checked)&&(/auto|%$/.test(t)||/auto|%$/.test(e)?this.figure.deleteTransform(n):this.figure.setTransform(n,t,e,0)),this.figure.setAlign(n,this.#_u)}#Pu(t,e){return e?(e.setAttribute("data-se-non-link","true"),e.appendChild(t),e):t}#Eu(t){const e=this.modal.form,s="string"==typeof t?e.querySelector("._se_tab_link"):Pe.query.getEventTarget(t);if(!/^BUTTON$/i.test(s.tagName))return!1;const i=s.getAttribute("data-tab-link");let n;const o=e.getElementsByClassName("_se_tab_content");for(n=0;n<o.length;n++)o[n].style.display="none";const r=e.getElementsByClassName("_se_tab_link");for(n=0;n<r.length;n++)Pe.utils.removeClass(r[n],"active");return e.querySelector("._se_tab_content_"+i).style.display="block",Pe.utils.addClass(s,"active"),"init"!==t&&("image"===i?this.focusElement.focus():"url"===i&&this.anchor.urlInput.focus()),!1}#Tu(){this.imgInputFile.value="",this.imgUrlFile&&(this.imgUrlFile.disabled=!1,this.previewSrc.style.textDecoration=""),Rl.OnChangeFile(this.fileModalWrapper,[])}#Iu({target:t}){this.#Ru("asInline"===t.getAttribute("data-command"))}#Mu(t){const e=t.target.value.trim();this.#Cu=this.previewSrc.textContent=e?this.$.options.get("defaultUrlProtocol")&&!e.includes("://")&&0!==e.indexOf("#")?this.$.options.get("defaultUrlProtocol")+e:e.includes("://")?e:"/"+e:""}#Nu({target:t}){this.imgInputFile.value?(this.imgUrlFile.disabled=!0,this.previewSrc.style.textDecoration="line-through"):(this.imgUrlFile.disabled=!1,this.previewSrc.style.textDecoration=""),Rl.OnChangeFile(this.fileModalWrapper,t.files)}#Bu(){this.$.plugins.imageGallery.open(this.#Fu.bind(this))}#Fu(t){this.altText.value=t.getAttribute("data-value")||t.alt,this.#Cu=this.previewSrc.textContent=this.imgUrlFile.value=t.getAttribute("data-command")||t.src,this.imgUrlFile.focus()}#Du(t,e,s){this.setState("produceIndex",this.state.produceIndex-1),delete t.onload,0===t.offsetWidth&&this.sizeService.applySize(e,""),0===this.state.produceIndex&&(this.$.component.applyInsertBehavior(s,null,this.pluginOptions.insertBehavior||this.$.options.get("componentInsertBehavior")),this.$.ui._iframeAutoHeight(this.$.frameContext),this.$.history.push(!1))}};const Dh=class{#od;#J;#I;#iu;#dd;#Hu;#qu;#Wu;#nu;#ou;#ru={w:0,h:0};#lu=null;#au=null;#hu=null;#Uu=null;constructor(t,e){if(this.#od=t,this.#J=t.$,this.#I=t.state,this.#iu=t.pluginOptions,this.#dd=this.#iu.canResize,this.#Hu=this.#I.defaultRatio,this.#qu="100%",this.#Wu=100*this.#iu.defaultRatio+"%",this.#nu="100%"===this.#iu.defaultWidth?"":this.#iu.defaultWidth,this.#ou=this.#iu.defaultHeight===this.#I.defaultRatio?"":this.#iu.defaultHeight,this.#dd){this.#lu=e.proportion,this.frameRatioOption=e.frameRatioOption,this.#au=e.inputX,this.#hu=e.inputY,this.#au.value=this.#iu.defaultWidth,this.#hu.value=this.#iu.defaultHeight;const t=this.#cu.bind(this);this.#J.eventManager.addEvent(this.#au,"keyup",this.#du.bind(this,"x")),this.#J.eventManager.addEvent(this.#hu,"keyup",this.#du.bind(this,"y")),this.#J.eventManager.addEvent(this.#au,"change",t),this.#J.eventManager.addEvent(this.#hu,"change",t),this.#J.eventManager.addEvent(this.#lu,"change",t),this.#J.eventManager.addEvent(this.frameRatioOption,"change",this.#Vu.bind(this)),this.#J.eventManager.addEvent(e.revertBtn,"click",this.#uu.bind(this))}}setInputSize(t,e){this.#au.value=t===this.#qu?"":t,this.#I.onlyPercentage||(this.#hu.value=e===this.#Wu?"":e)}getInputSize(){return{w:this.#au?.value||"",h:this.#hu?.value||""}}setOriginSize(t,e){this.#nu=t,this.#ou=e}applySize(t,e){t||=this.#au?.value||this.#iu.defaultWidth,e||=this.#hu?.value||this.#iu.defaultHeight,this.#I.onlyPercentage&&(t?/%$/.test(t+"")||(t+="%"):t="100%"),this.#od.figure.setSize(t,e)}resolveSize(t,e,s,i){t||=this.#qu,e||=this.#Hu;const n=this.#od.figure.getSize(s),o=n.w!==t||n.h!==e,r=!i||o;return r&&(this.#Uu!==this.frameRatioOption?.value&&this.#od.figure.deleteTransform(),this.applySize(t,e)),{width:t,height:e,isChanged:r}}on(t){if(this.#dd){if(!t){const t=this.#iu.defaultWidth,e=this.#iu.defaultHeight;this.setInputSize(t,e),this.setOriginSize(t,e),this.#lu.disabled=!0}this.#ju(this.#od.figure.isVertical?"":this.#ou||this.#I.defaultRatio),this.#Uu=this.frameRatioOption?.value}}ready(t,e){const{dw:s,dh:i}=this.#od.figure.getSize(e);this.setInputSize(s,i);const n=t.height||t.h||this.#ou||"";this.#ju(n)||(this.#hu.value=String(this.#I.onlyPercentage?De.get(n,2):n));const o=this.#I.onlyPercentage&&this.#od.figure.isVertical;this.#au.disabled=o,this.#hu.disabled=o,this.#lu.checked=!t.isVertical,this.#lu.disabled=o,this.#ru=this.#lu.checked?t.ratio:{w:0,h:0}}init(){this.#ru={w:0,h:0},this.#dd&&(this.setInputSize(this.#iu.defaultWidth,this.#iu.defaultHeight),this.#lu.checked=!1,this.#lu.disabled=!0,this.#ju(this.#I.defaultRatio))}#uu(){this.#I.onlyPercentage?this.#au.value=Number(this.#nu)>100?"100":this.#nu:(this.#au.value=this.#nu,this.#hu.value=this.#ou)}#ju(t){if(!this.frameRatioOption)return;let e=!1;const s=this.frameRatioOption.options;/%$/.test(t+"")||this.#I.onlyPercentage?t=De.get(t,2)/100+"":(!De.is(t)||Number(t)>=1)&&(t=""),this.#hu.placeholder="";for(let i=0,n=s.length;i<n;i++)s[i].value===t?(e=s[i].selected=!0,this.#hu.placeholder=t?100*Number(t)+"%":""):s[i].selected=!1;return e}#Vu(t){const e=Pe.query.getEventTarget(t),s=e.options[e.selectedIndex].value;this.#Wu=this.#od.figure.autoRatio.current=this.#Hu=s?100*Number(s)+"%":this.#Wu,this.#hu.placeholder=s?100*Number(s)+"%":"",this.#hu.value=""}#cu(){this.#ru=this.#lu.checked?ji.GetRatio(this.#au.value,this.#hu.value,this.#I.sizeUnit):{w:0,h:0}}#du(t,e){if(Fe.isSpace(e.code))return void e.preventDefault();const s=Pe.query.getEventTarget(e);if("x"===t&&this.#I.onlyPercentage&&Number(s.value)>100)s.value="100";else if(this.#lu.checked&&!this.frameRatioOption?.value){const e=ji.CalcRatio(this.#au.value,this.#hu.value,this.#I.sizeUnit,this.#ru);"x"===t?this.#hu.value=String(e.h):this.#au.value=String(e.w)}"y"===t&&this.#ju(s.value||this.#I.defaultRatio)}},{NO_EVENT:Fh}=Oe;const Hh=class{#od;#J;#iu;constructor(t){this.#od=t,this.#J=t.$,this.#iu=t.pluginOptions}serverUpload(t,e){if(!e)return;const s=this.#iu.uploadUrl;"string"==typeof s&&s.length>0&&this.#od.fileManager.upload(s,this.#iu.uploadHeaders,e,this.#gu.bind(this,t),this.#pc.bind(this))}#uc(t,e){const s=e.result,i=this.#od.createVideoTag();for(let e=0,n=s.length;e<n;e++){const o=t.isUpdate?t.element:i.cloneNode(!1);this.#od.create(o,s[e].url,t.inputWidth,t.inputHeight,t.align,t.isUpdate,{name:s[e].name,size:s[e].size},e===n-1)}}async#pc(t){const e=await this.#J.eventManager.triggerEvent("onVideoUploadError",{error:t}),s=e===Fh?t.errorMessage:e||t.errorMessage;this.#J.ui.alertOpen(s,"error"),console.error("[SUNEDITOR.plugin.video.error]",e)}async#gu(t,e){if(await this.#J.eventManager.triggerEvent("videoUploadHandler",{xmlHttp:e,info:t})===Fh){const s=JSON.parse(e.responseText);s.errorMessage?this.#pc(s):this.#uc(t,s)}}};const{_w:qh,NO_EVENT:Wh}=Oe;class Uh extends Xl{static key="video";static className="";static component(t){return/^(VIDEO)$/i.test(t?.nodeName)||/^(IFRAME)$/i.test(t?.nodeName)&&this.#Gu(t.src)?t:null}static#Gu(t){return t=t?.toLowerCase()||"",!(!this.#Ku.some((e=>t.endsWith(e)))&&!this.#Yu.some((e=>e.test(t))))}static#Ku=[".mp4",".avi",".mov",".webm",".flv",".mkv",".m4v",".ogv"];static#Yu=[/youtu\.?be/,/vimeo\.com\//,/dailymotion\.com\/video\//,/facebook\.com\/.+\/videos\//,/facebook\.com\/watch\/\?v=/,/twitter\.com\/.+\/status\//,/twitch\.tv\/videos\//,/twitch\.tv\/[^/]+$/,/tiktok\.com\/@[^/]+\/video\//,/instagram\.com\/p\//,/instagram\.com\/tv\//,/instagram\.com\/reel\//,/linkedin\.com\/posts\//,/\.(wistia\.com|wi\.st)\/(medias|embed)\//,/loom\.com\/share\//];#dd;#yu;#Cu="";#_u="none";#zc=null;#$u=null;constructor(t,e){super(t),this.title=this.$.lang.video,this.icon="video",this.pluginOptions={canResize:void 0===e.canResize||e.canResize,showHeightInput:void 0===e.showHeightInput||!!e.showHeightInput,defaultWidth:e.defaultWidth&&De.get(e.defaultWidth,0)?De.is(e.defaultWidth)?e.defaultWidth+"px":e.defaultWidth:"",defaultHeight:e.defaultHeight&&De.get(e.defaultHeight,0)?De.is(e.defaultHeight)?e.defaultHeight+"px":e.defaultHeight:"",percentageOnlySize:!!e.percentageOnlySize,createFileInput:!!e.createFileInput,createUrlInput:void 0===e.createUrlInput||!e.createFileInput||e.createUrlInput,uploadUrl:"string"==typeof e.uploadUrl?e.uploadUrl:null,uploadHeaders:e.uploadHeaders||null,uploadSizeLimit:De.get(e.uploadSizeLimit,0),uploadSingleSizeLimit:De.get(e.uploadSingleSizeLimit,0),allowMultiple:!!e.allowMultiple,acceptedFormats:"string"!=typeof e.acceptedFormats||"*"===e.acceptedFormats.trim()?"video/*":e.acceptedFormats.trim()||"video/*",defaultRatio:De.get(e.defaultRatio,4)||.5625,showRatioOption:void 0===e.showRatioOption||!!e.showRatioOption,ratioOptions:e.ratioOptions?e.ratioOptions:null,videoTagAttributes:e.videoTagAttributes||null,iframeTagAttributes:e.iframeTagAttributes||null,query_youtube:e.query_youtube||"",query_vimeo:e.query_vimeo||"",insertBehavior:e.insertBehavior};const s=this.pluginOptions.percentageOnlySize?"%":"px",i=function({lang:t,icons:e,plugins:s},i){let n=`\n\t<form method="post" enctype="multipart/form-data">\n\t\t<div class="se-modal-header">\n\t\t\t<button type="button" data-command="close" class="se-btn se-close-btn" title="${t.close}" aria-label="${t.close}">\n\t\t\t${e.cancel}\n\t\t\t</button>\n\t\t\t<span class="se-modal-title">${t.video_modal_title}</span>\n\t\t</div>\n\t\t<div class="se-modal-body">`;if(i.createFileInput&&(n+=`\n\t\t\t<div class="se-modal-form">\n\t\t\t\t<label>${t.video_modal_file}</label>\n\t\t\t\t${Rl.CreateFileInput({lang:t,icons:e},i)}\n\t\t\t</div>`),i.createUrlInput&&(n+=`\n\t\t\t<div class="se-modal-form">\n\t\t\t\t<label>${t.video_modal_url}</label>\n\t\t\t\t<div class="se-modal-form-files">\n\t\t\t\t\t<input class="se-input-form se-input-url" type="text" data-focus />\n\t\t\t\t\t${s.videoGallery?`<button type="button" class="se-btn se-tooltip se-modal-files-edge-button __se__gallery" aria-label="${t.videoGallery}">\n\t\t\t\t\t\t\t\t${e.video_gallery}\n\t\t\t\t\t\t\t\t${Pe.utils.createTooltipInner(t.videoGallery)}\n\t\t\t\t\t\t\t\t</button>`:""}\n\t\t\t\t</div>\n\t\t\t\t<pre class="se-link-preview"></pre>\n\t\t\t</div>`),i.canResize){const s=i.ratioOptions||[{name:"16:9",value:.5625},{name:"4:3",value:.75},{name:"21:9",value:.4285},{name:"9:16",value:1.78}],o=i.defaultRatio,r=i.percentageOnlySize,l=r?' style="display: none !important;"':"",a=i.showHeightInput?"":' style="display: none !important;"',h=i.showRatioOption?"":' style="display: none !important;"',c=r||i.showHeightInput||i.showRatioOption?"":' style="display: none !important;"';n+=`\n\t\t\t<div class="se-modal-form">\n\t\t\t\t<div class="se-modal-size-text">\n\t\t\t\t\t<label class="size-w">${t.width}</label>\n\t\t\t\t\t<label class="se-modal-size-x"> </label>\n\t\t\t\t\t<label class="size-h"${a}>${t.height}</label>\n\t\t\t\t\t<label class="size-h"${h}>(${t.ratio})</label>\n\t\t\t\t</div>\n\t\t\t\t<input class="se-input-control _se_size_x" placeholder="100%"${r?' type="number" min="1"':'type="text"'}${r?' max="100"':""}/>\n\t\t\t\t<label class="se-modal-size-x"${c}>${r?"%":"x"}</label>\n\t\t\t\t<input class="se-input-control _se_size_y" placeholder="${100*i.defaultRatio}%"\n\t\t\t\t${r?' type="number" min="1"':'type="text"'}${r?' max="100"':""}${a}/>\n\t\t\t\t<select class="se-input-select se-modal-ratio" title="${t.ratio}" aria-label="${t.ratio}"${h}>\n\t\t\t\t\t${a?"":'<option value=""> - </option>'} \n\t\t\t\t\t${s.map((t=>`<option value="${t.value}"${o.toString()===t.value.toString()?" selected":""}>${t.name}</option>`)).join("")}\n\t\t\t\t</select>\n\t\t\t\t<button type="button" title="${t.revert}" aria-label="${t.revert}" class="se-btn se-modal-btn-revert">${e.revert}</button>\n\t\t\t</div>\n\t\t\t<div class="se-modal-form se-modal-form-footer"${l}${c}>\n\t\t\t\t<label>\n\t\t\t\t\t<input type="checkbox" class="se-modal-btn-check _se_check_proportion" /> \n\t\t\t\t\t<span>${t.proportion}</span>\n\t\t\t\t</label>\n\t\t\t</div>`}n+=`\n\t\t</div>\n\t\t<div class="se-modal-footer">\n\t\t\t<div class="se-figure-align">\n\t\t\t\t<label><input type="radio" name="suneditor_video_radio" class="se-modal-btn-radio" value="none" checked>${t.basic}</label>\n\t\t\t\t<label><input type="radio" name="suneditor_video_radio" class="se-modal-btn-radio" value="left">${t.left}</label>\n\t\t\t\t<label><input type="radio" name="suneditor_video_radio" class="se-modal-btn-radio" value="center">${t.center}</label>\n\t\t\t\t<label><input type="radio" name="suneditor_video_radio" class="se-modal-btn-radio" value="right">${t.right}</label>\n\t\t\t</div>\n\t\t\t<button type="submit" class="se-btn-primary" title="${t.submitButton}" aria-label="${t.submitButton}"><span>${t.submitButton}</span></button>\n\t\t</div>\n\t</form>`;const o=Pe.utils.createElement("DIV",{class:"se-modal-content"},n);return{html:o,alignForm:o.querySelector(".se-figure-align"),fileModalWrapper:o.querySelector(".se-flex-input-wrapper"),videoInputFile:o.querySelector(".__se__file_input"),videoUrlFile:o.querySelector(".se-input-url"),previewSrc:o.querySelector(".se-link-preview"),galleryButton:o.querySelector(".__se__gallery"),proportion:o.querySelector("._se_check_proportion"),frameRatioOption:o.querySelector(".se-modal-ratio"),inputX:o.querySelector("._se_size_x"),inputY:o.querySelector("._se_size_y"),revertBtn:o.querySelector(".se-modal-btn-revert"),fileRemoveBtn:o.querySelector(".se-file-remove")}}(this.$,this.pluginOptions),n=e.controls||(this.pluginOptions.canResize?[["resize_auto,75,50","align","edit","revert","copy","remove"]]:[["align","edit","copy","remove"]]);n.some((t=>t.includes("align")))||(i.alignForm.style.display="none");const o=100*this.pluginOptions.defaultRatio+"%";this.modal=new Rl(this,this.$,i.html),this.figure=new ji(this,this.$,n,{sizeUnit:s,autoRatio:{current:o,default:o}}),this.fileManager=new Pl(this,this.$,{query:"iframe, video",loadEventName:"onVideoLoad",actionEventName:"onVideoAction"}),this.fileModalWrapper=i.fileModalWrapper,this.videoInputFile=i.videoInputFile,this.videoUrlFile=i.videoUrlFile,this.focusElement=this.videoUrlFile||this.videoInputFile,this.previewSrc=i.previewSrc,this.#dd=this.pluginOptions.canResize,this.#yu=!this.#dd||!this.pluginOptions.showHeightInput||this.pluginOptions.percentageOnlySize,this.query={youtube:{pattern:/youtu\.?be/i,action:t=>(t=this.convertUrlYoutube(t),ze.addUrlQuery(t,this.pluginOptions.query_youtube)),tag:"iframe"},vimeo:{pattern:/vimeo\.com/i,action:t=>(t=this.convertUrlVimeo(t),ze.addUrlQuery(t,this.pluginOptions.query_vimeo)),tag:"iframe"},...e.embedQuery};const r=[];for(const t in this.query)r.push(this.query[t].pattern);Uh.#Ku=Uh.#Ku.concat(this.pluginOptions.extensions||[]),Uh.#Yu=Uh.#Yu.concat(e.urlPatterns||[]),this.state={onlyPercentage:this.pluginOptions.percentageOnlySize,sizeUnit:s,defaultRatio:100*this.pluginOptions.defaultRatio+"%"},this.sizeService=new Dh(this,i),this.uploadService=new Hh(this);const l=i.galleryButton;l&&this.$.eventManager.addEvent(l,"click",this.#Bu.bind(this)),this.videoInputFile&&this.$.eventManager.addEvent(i.fileRemoveBtn,"click",this.#Tu.bind(this)),this.videoUrlFile&&this.$.eventManager.addEvent(this.videoUrlFile,"input",this.#Mu.bind(this)),this.videoInputFile&&this.videoUrlFile&&this.$.eventManager.addEvent(this.videoInputFile,"change",this.#Nu.bind(this))}setState(t,e){this.state[t]=e}open(){this.modal.open()}retainFormat(){return{query:"iframe, video",method:async t=>{if(/^(iframe)$/i.test(t?.nodeName)&&!Uh.#Gu(t.src))return;const e=ji.GetContainer(t);if(e&&e.container&&e.cover)return;this.#Lu(t,!0);const s=this.$.format.getLine(t);s&&(this.#_u=s.style.textAlign||s.style.float),this.#Ou(t)}}}onFilePasteAndDrop({file:t}){/^video/.test(t.type)&&(this.submitFile([t]),this.$.focusManager.focus())}modalOn(t){t?this.videoInputFile&&this.pluginOptions.allowMultiple&&this.videoInputFile.removeAttribute("multiple"):this.videoInputFile&&this.pluginOptions.allowMultiple&&this.videoInputFile.setAttribute("multiple","multiple"),this.sizeService.on(t)}async modalAction(){this.#_u=this.modal.form.querySelector('input[name="suneditor_video_radio"]:checked').value;let t=!1;return this.videoInputFile&&this.videoInputFile.files.length>0?t=await this.submitFile(this.videoInputFile.files):this.videoUrlFile&&this.#Cu.length>0&&(t=await this.submitURL(this.#Cu)),t&&qh.setTimeout(this.$.component.select.bind(this.$.component,this.#zc,Uh.key),0),t}modalInit(){Rl.OnChangeFile(this.fileModalWrapper,[]),this.videoInputFile&&(this.videoInputFile.value=""),this.videoUrlFile&&(this.#Cu=this.previewSrc.textContent=this.videoUrlFile.value=""),this.videoInputFile&&this.videoUrlFile&&(this.videoUrlFile.disabled=!1,this.previewSrc.style.textDecoration=""),this.modal.form.querySelector('input[name="suneditor_video_radio"][value="none"]').checked=!0,this.#yu=!1,this.sizeService.init()}componentSelect(t){this.#Lu(t)}componentEdit(){this.modal.open()}async componentDestroy(t){const e=t||this.#zc,s=Pe.query.getParentElement(e,ji.is)||e,i=s.previousElementSibling||s.nextElementSibling,n=s.parentNode;!1!==await this.$.eventManager.triggerEvent("onVideoDeleteBefore",{element:e,container:s,align:this.#_u,url:this.#Cu})&&(Pe.utils.removeItem(s),this.modalInit(),n!==this.$.frameContext.get("wysiwyg")&&this.$.nodeTransform.removeAllParents(n,(function(t){return 0===t.childNodes.length}),null),this.$.focusManager.focusEdge(i),this.$.history.push(!1))}findProcessUrl(t){const e=this.query;for(const s in e){const i=e[s];if(i.pattern.test(t))return{origin:t,url:i.action(t),tag:i.tag}}return null}convertUrlYoutube(t){return/^http/.test(t)||(t="https://"+t),t=t.replace("watch?v=",""),/^\/\/.+\/embed\//.test(t)||(t=t.replace(t.match(/\/\/.+\//)[0],"//www.youtube.com/embed/").replace("&","?&")),t}convertUrlVimeo(t){return t.endsWith("/")&&(t=t.slice(0,-1)),t="https://player.vimeo.com/video/"+t.slice(t.lastIndexOf("/")+1)}addQuery(t,e){if(e.length>0)if(/\?/.test(t)){const s=t.split("?");t=s[0]+"?"+e+"&"+s[1]}else t+="?"+e;return t}create(t,e,s,i,n,o,r,l){let a=null;if(o){if((t=this.#zc).src!==e){const s=this.findProcessUrl(e);if(/^iframe$/i.test(s?.tag)&&!/^iframe$/i.test(t.nodeName)){const s=this.createIframeTag();s.src=e,t.replaceWith(s),this.#zc=t=s}else if(/^video$/i.test(s?.tag)&&!/^video$/i.test(t.nodeName)){const s=this.createVideoTag();s.src=e,t.replaceWith(s),this.#zc=t=s}else t.src=e}a=this.#$u}else{t.src=e,this.#zc=t;a=ji.CreateContainer(t,"se-video-container").container}this.#zc=t,this.#$u=a,this.figure.open(t,{nonResizing:this.#yu,nonSizeInfo:!1,nonBorder:!1,figureTarget:!1,infoOnly:!0});const h=this.sizeService.resolveSize(s,i,t,o);s=h.width,i=h.height,this.figure.setAlign(t,n),this.fileManager.setFileData(t,r),o?(this.#dd&&h.isChanged&&this.figure.isVertical||this.figure.setTransform(t,s,i,0),this.$.history.push(!1)):this.$.component.insert(a,{scrollTo:!!l,insertBehavior:l?this.pluginOptions.insertBehavior:"line"})}createIframeTag(t){const e=Pe.utils.createElement("IFRAME");if(t)for(const s in t)e[s]=t[s];return this.#Xu(e),e}createVideoTag(t){const e=Pe.utils.createElement("VIDEO");if(t)for(const s in t)e[s]=t[s];return this.#Zu(e),e}async submitFile(t){if(0===t.length)return;let e=0;const s=[],i=this.pluginOptions.uploadSingleSizeLimit;for(let n,o,r=0,l=t.length;r<l;r++)if(n=t[r],/video/i.test(n.type)){if(o=n.size,i>0&&o>i){const t="[SUNEDITOR.videoUpload.fail] Size of uploadable single file: "+i/1e3+"KB",e=await this.$.eventManager.triggerEvent("onVideoUploadError",{error:t,limitSize:i,uploadSize:o,file:n});return this.$.ui.alertOpen(e===Wh?t:e||t,"error"),!1}s.push(n),e+=o}const n=this.pluginOptions.uploadSizeLimit,o=this.fileManager.getSize();if(n>0&&e+o>n){const t="[SUNEDITOR.videoUpload.fail] Size of uploadable total videos: "+n/1e3+"KB",s=await this.$.eventManager.triggerEvent("onVideoUploadError",{error:t,limitSize:n,currentSize:o,uploadSize:e});return this.$.ui.alertOpen(s===Wh?t:s||t,"error"),!1}const r={url:null,files:s,...this.#zu()},l=function(t,e,s){t(e=s||e,e.files)}.bind(this,this.uploadService.serverUpload.bind(this.uploadService),r),a=await this.$.eventManager.triggerEvent("onVideoUploadBefore",{info:r,handler:l});return void 0===a||!1!==a&&(null!==a&&"object"==typeof a&&l(a),void(!0!==a&&a!==Wh||l(null)))}async submitURL(t){if(!(t=this.#Cu))return!1;if(/^<iframe.*\/iframe>$/.test(t)){if(0===(t=(new DOMParser).parseFromString(t,"text/html").querySelector("iframe").src).length)return!1}const e=this.findProcessUrl(t);e&&(t=e.url);const s={name:t.split("/").pop(),size:0},i={url:t,files:s,...this.#zu(),process:e},n=function(t,e){t=e||t,this.create(this[/^iframe$/i.test(t.process?.tag)?"createIframeTag":"createVideoTag"](),t.url,t.inputWidth,t.inputHeight,t.align,t.isUpdate,t.files,!0)}.bind(this,i),o=await this.$.eventManager.triggerEvent("onVideoUploadBefore",{info:i,handler:n});return void 0===o||!1!==o&&(null!==o&&"object"==typeof o&&n(o),!0!==o&&o!==Wh||n(null),!0)}#Lu(t,e=!1){if(!t)return;const s=this.figure.open(t,{nonResizing:this.#yu,nonSizeInfo:!1,nonBorder:!1,figureTarget:!1,infoOnly:e});this.#zc=t,this.#$u=s.container,this.#_u=s.align,t.style.float="";const i=String(s.width||s.originWidth||s.w||""),n=String(s.height||s.originHeight||s.h||"");this.sizeService.setOriginSize(i,n),this.videoUrlFile&&(this.#Cu=this.previewSrc.textContent=this.videoUrlFile.value=this.#zc.src||this.#zc.querySelector("source")?.src||"");(this.modal.form.querySelector('input[name="suneditor_video_radio"][value="'+this.#_u+'"]')||this.modal.form.querySelector('input[name="suneditor_video_radio"][value="none"]')).checked=!0,this.#dd&&this.sizeService.ready(s,t)}#zu(){const{w:t,h:e}=this.sizeService.getInputSize();return{inputWidth:t,inputHeight:e,align:this.#_u,isUpdate:this.modal.isUpdate,element:this.#zc}}#Ou(t){if(!t)return;/^video$/i.test(t.nodeName)?this.#Zu(t):/^iframe$/i.test(t.nodeName)&&this.#Xu(t);const e=t,s=t.cloneNode(!0),i=ji.CreateContainer(s,"se-video-container"),n=i.container,o=ji.GetContainer(e)?.container?.querySelector("figcaption");let r=null;o&&(r=Pe.utils.createElement("figcaption"),r.innerHTML=o.innerHTML,Pe.utils.removeItem(o),i.cover.appendChild(r)),this.figure.open(s,{nonResizing:this.#yu,nonSizeInfo:!1,nonBorder:!1,figureTarget:!1,infoOnly:!0});const l=(s.getAttribute("data-se-size")||",").split(","),a=l[0]||e.width||"",h=l[1]||e.height||this.state.defaultRatio||"";this.sizeService.applySize(a,h);const c=this.$.format.getLine(e);return c&&(this.#_u=c.style.textAlign||c.style.float),this.figure.setAlign(s,this.#_u),this.figure.retainFigureFormat(n,this.#zc,null,this.fileManager),s}#Zu(t){t.setAttribute("controls","true");const e=this.pluginOptions.videoTagAttributes;if(e)for(const s in e)t.setAttribute(s,e[s])}#Xu(t){t.frameBorder="0",t.allowFullscreen=!0;const e=this.pluginOptions.iframeTagAttributes;if(e)for(const s in e)t.setAttribute(s,e[s])}#Tu(){this.videoInputFile.value="",this.videoUrlFile&&(this.videoUrlFile.disabled=!1,this.previewSrc.style.textDecoration=""),Rl.OnChangeFile(this.fileModalWrapper,[])}#Mu(t){const e=Pe.query.getEventTarget(t).value.trim();/^<iframe.*\/iframe>$/.test(e)?(this.#Cu=e,this.previewSrc.textContent='<IFrame :src=".."></IFrame>'):this.#Cu=this.previewSrc.textContent=e?this.$.options.get("defaultUrlProtocol")&&!e.includes("://")&&0!==e.indexOf("#")?this.$.options.get("defaultUrlProtocol")+e:e.includes("://")?e:"/"+e:""}#Bu(){this.$.plugins.videoGallery.open(this.#Fu.bind(this))}#Fu(t){this.#Cu=this.previewSrc.textContent=this.videoUrlFile.value=t.getAttribute("data-command")||t.src,this.videoUrlFile.focus()}#Nu(t){this.videoInputFile.value?(this.videoUrlFile.disabled=!0,this.previewSrc.style.textDecoration="line-through"):(this.videoUrlFile.disabled=!1,this.previewSrc.style.textDecoration="");const e=Pe.query.getEventTarget(t);Rl.OnChangeFile(this.fileModalWrapper,e.files)}}const Vh=Uh,{NO_EVENT:jh,ON_OVER_COMPONENT:Gh}=Oe;class Kh extends Xl{static key="audio";static className="";static component(t){return/^AUDIO$/i.test(t?.nodeName)?t:null}#Ju;#Qu;#tp="";#zc=null;constructor(t,e){super(t),this.title=this.$.lang.audio,this.icon="audio",this.pluginOptions={defaultWidth:e.defaultWidth?De.is(e.defaultWidth)?e.defaultWidth+"px":e.defaultWidth:"",defaultHeight:e.defaultHeight?De.is(e.defaultHeight)?e.defaultHeight+"px":e.defaultHeight:"",createFileInput:!!e.createFileInput,createUrlInput:void 0===e.createUrlInput||!e.createFileInput||e.createUrlInput,uploadUrl:"string"==typeof e.uploadUrl?e.uploadUrl:null,uploadHeaders:e.uploadHeaders||null,uploadSizeLimit:De.get(e.uploadSizeLimit,0),uploadSingleSizeLimit:De.get(e.uploadSingleSizeLimit,0),allowMultiple:!!e.allowMultiple,acceptedFormats:"string"!=typeof e.acceptedFormats||"*"===e.acceptedFormats.trim()?"audio/*":e.acceptedFormats.trim()||"audio/*",audioTagAttributes:e.audioTagAttributes||null,insertBehavior:e.insertBehavior};const s=function({lang:t,icons:e,plugins:s},i){let n=`\n <form method="post" enctype="multipart/form-data">\n <div class="se-modal-header">\n <button type="button" data-command="close" class="se-btn se-close-btn" title="${t.close}" aria-label="${t.close}">\n ${e.cancel}\n </button>\n <span class="se-modal-title">${t.audio_modal_title}</span>\n </div>\n <div class="se-modal-body">`;i.createFileInput&&(n+=`\n <div class="se-modal-form">\n <label>${t.audio_modal_file}</label>\n ${Rl.CreateFileInput({lang:t,icons:e},i)}\n </div>`);i.createUrlInput&&(n+=`\n <div class="se-modal-form">\n <label>${t.audio_modal_url}</label>\n\t\t\t<div class="se-modal-form-files">\n\t\t\t\t<input class="se-input-form se-input-url" data-focus type="text" />\n\t\t\t\t${s.audioGallery?`<button type="button" class="se-btn se-tooltip se-modal-files-edge-button __se__gallery" aria-label="${t.audioGallery}">\n\t\t\t\t\t\t\t${e.audio_gallery}\n\t\t\t\t\t\t\t${Pe.utils.createTooltipInner(t.audioGallery)}\n\t\t\t\t\t\t\t</button>`:""}\n\t\t\t</div>\n <pre class="se-link-preview"></pre>\n </div>`);return n+=`\n </div>\n <div class="se-modal-footer">\n <button type="submit" class="se-btn-primary" title="${t.submitButton}" aria-label="${t.submitButton}">\n <span>${t.submitButton}</span>\n </button>\n </div>\n </form>`,Pe.utils.createElement("DIV",{class:"se-modal-content"},n)}(this.$,this.pluginOptions),i=function({lang:t,icons:e}){const s=`\n <div class="se-arrow se-arrow-up"></div>\n <div class="link-content">\n <div class="se-btn-group">\n <button type="button" data-command="update" tabindex="-1" class="se-btn se-tooltip">\n ${e.edit}\n <span class="se-tooltip-inner">\n <span class="se-tooltip-text">${t.edit}</span>\n </span>\n </button>\n <button type="button" data-command="copy" tabindex="-1" class="se-btn se-tooltip">\n ${e.copy}\n <span class="se-tooltip-inner">\n <span class="se-tooltip-text">${t.copy}</span>\n </span>\n </button>\n <button type="button" data-command="delete" tabindex="-1" class="se-btn se-tooltip">\n ${e.delete}\n <span class="se-tooltip-inner">\n <span class="se-tooltip-text">${t.remove}</span>\n </span>\n </button>\n </div>\n </div>`;return Pe.utils.createElement("DIV",{class:"se-controller"},s)}(this.$);this.modal=new Rl(this,this.$,s),this.controller=new Ii(this,this.$,i,{position:"bottom",disabled:!0}),this.fileManager=new Pl(this,this.$,{query:"audio",loadEventName:"onAudioLoad",actionEventName:"onAudioAction"}),this.figure=new ji(this,this.$,null,{}),this.fileModalWrapper=s.querySelector(".se-flex-input-wrapper"),this.audioInputFile=s.querySelector(".__se__file_input"),this.audioUrlFile=s.querySelector(".se-input-url"),this.preview=s.querySelector(".se-link-preview"),this.#Ju=this.pluginOptions.defaultWidth,this.#Qu=this.pluginOptions.defaultHeight;const n=s.querySelector(".__se__gallery");n&&this.$.eventManager.addEvent(n,"click",this.#Bu.bind(this)),this.audioInputFile&&(this.$.eventManager.addEvent(s.querySelector(".se-modal-files-edge-button"),"click",this.#Tu.bind(this,this.audioUrlFile,this.preview)),this.audioUrlFile&&this.$.eventManager.addEvent(this.audioInputFile,"change",this.#ep.bind(this))),this.audioUrlFile&&this.$.eventManager.addEvent(this.audioUrlFile,"input",this.#Mu.bind(this))}open(){this.modal.open()}retainFormat(){return{query:"audio",method:t=>{const e=ji.GetContainer(t);if(e&&e.container&&e.cover)return;this.#Zu(t);const s=ji.CreateContainer(t.cloneNode(!0),"se-flex-component");this.figure.retainFigureFormat(s.container,t,null,this.fileManager)}}}onFilePasteAndDrop({file:t}){/^audio/.test(t.type)&&(this.submitFile([t]),this.$.focusManager.focus())}modalOn(t){t?this.#zc?(this.#tp=this.preview.textContent=this.audioUrlFile.value=this.#zc.src,this.audioInputFile&&this.pluginOptions.allowMultiple&&this.audioInputFile.removeAttribute("multiple")):this.audioInputFile&&this.pluginOptions.allowMultiple&&this.audioInputFile.removeAttribute("multiple"):this.audioInputFile&&this.pluginOptions.allowMultiple&&this.audioInputFile.setAttribute("multiple","multiple")}async modalAction(){return this.audioInputFile&&this.audioInputFile?.files.length>0?await this.submitFile(this.audioInputFile.files):!!(this.audioUrlFile&&this.#tp.length>0)&&await this.submitURL(this.#tp)}modalInit(){Rl.OnChangeFile(this.fileModalWrapper,[]),this.audioInputFile&&(this.audioInputFile.value=""),this.audioUrlFile&&(this.#tp=this.preview.textContent=this.audioUrlFile.value=""),this.audioInputFile&&this.audioUrlFile&&(this.audioUrlFile.disabled=!1,this.preview.style.textDecoration="")}controllerAction(t){switch(t.getAttribute("data-command")){case"update":this.audioUrlFile&&(this.#tp=this.preview.textContent=this.audioUrlFile.value=this.#zc.src),this.open();break;case"copy":{const t=ji.GetContainer(this.#zc);this.$.component.copy(t.container);break}case"delete":this.componentDestroy(null)}}componentSelect(t){this.figure.open(t,{nonResizing:!0,nonSizeInfo:!0,nonBorder:!0,figureTarget:!0,infoOnly:!1}),this.#Lu(t)}async componentDestroy(t){const e=t||this.#zc,s=ji.GetContainer(e),i=s.container||e,n=i.previousElementSibling||i.nextElementSibling;if(!1===await this.$.eventManager.triggerEvent("onAudioDeleteBefore",{element:e,container:s,url:e.getAttribute("src")}))return;const o=i.parentNode;Pe.utils.removeItem(i),this.modalInit(),this.controller.close(),o!==this.$.frameContext.get("wysiwyg")&&this.$.nodeTransform.removeAllParents(o,(function(t){return 0===t.childNodes.length}),null),this.$.focusManager.focusEdge(n),this.$.history.push(!1)}async submitFile(t){if(0===t.length)return!1;let e=0;const s=[],i=this.pluginOptions.uploadSingleSizeLimit;for(let n,o,r=0,l=t.length;r<l;r++)if(n=t[r],/audio/i.test(n.type)){if(o=n.size,i>0&&o>i){const t="[SUNEDITOR.audioUpload.fail] Size of uploadable single file: "+i/1e3+"KB",e=await this.$.eventManager.triggerEvent("onAudioUploadError",{error:t,limitSize:i,uploadSize:o,file:n});return this.$.ui.alertOpen(e===jh?t:e||t,"error"),!1}s.push(n),e+=o}const n=this.pluginOptions.uploadSizeLimit;if(n>0&&e+this.fileManager.getSize()>n){const t="[SUNEDITOR.audioUpload.fail] Size of uploadable total audios: "+n/1e3+"KB",s=await this.$.eventManager.triggerEvent("onAudioUploadError",{error:t,limitSize:n,currentSize:this.fileManager.getSize(),uploadSize:e});return this.$.ui.alertOpen(s===jh?t:s||t,"error"),!1}const o={files:s,isUpdate:this.modal.isUpdate,element:this.#zc},r=function(t,e,s){t(s=e||s,s.files)}.bind(this,this.#sp.bind(this),o),l=await this.$.eventManager.triggerEvent("onAudioUploadBefore",{info:o,handler:r});return void 0===l||!!l&&(null!==l&&"object"==typeof l&&r(l),!0!==l&&l!==jh||r(null),!0)}async submitURL(t){if(0===t.length)return!1;const e={name:t.split("/").pop(),size:0},s={url:t,files:e,isUpdate:this.modal.isUpdate,element:this.#ip()},i=function(t,e,s){t((s=e||s).element,s.url,s.files,s.isUpdate,!0)}.bind(this,this.create.bind(this),s),n=await this.$.eventManager.triggerEvent("onAudioUploadBefore",{info:s,handler:i});return void 0===n||!!n&&(null!==n&&"object"==typeof n&&i(n),!0!==n&&n!==jh||i(null),!0)}create(t,e,s,i,n){if(i){if(this.#zc&&(t=this.#zc),this.fileManager.setFileData(t,s),!t||t.src===e)return void this.$.component.select(t,Kh.key);t.src=e,this.$.component.select(t,Kh.key)}else{this.fileManager.setFileData(t,s),t.src=e;const i=ji.CreateContainer(t,"se-flex-component");if(!this.$.component.insert(i.container,{scrollTo:!!n,insertBehavior:n?this.pluginOptions.insertBehavior:"line"}))return void(n&&this.$.focusManager.focus());if(!this.$.options.get("componentInsertBehavior")){const t=this.$.format.addLine(i.container,null);t&&this.$.selection.setRange(t,0,t,0)}}i&&this.$.history.push(!1)}#Lu(t){_i.get("__overInfo")!==Gh&&(this.#zc=t,this.controller.open(t,null,{isWWTarget:!1,addOffset:null}))}#uc(t,e){const s=e.result;for(let e,i,n=0,o=s.length;n<o;n++)i=t.isUpdate?t.element:this.#ip(),e={name:s[n].name,size:s[n].size},this.create(i,s[n].url,e,t.isUpdate,n===o-1)}#ip(){const t=this.#Ju,e=this.#Qu,s=Pe.utils.createElement("AUDIO",{style:(t?"width:"+t+"; ":"")+(e?"height:"+e+";":"")});return this.#Zu(s),s}#Zu(t){t.setAttribute("controls","true");const e=this.pluginOptions.audioTagAttributes;if(e)for(const s in e)t.setAttribute(s,e[s])}#sp(t,e){if(!e)return;const s=this.modal.isUpdate?[e[0]]:e;this.fileManager.upload(this.pluginOptions.uploadUrl,this.pluginOptions.uploadHeaders,s,this.#gu.bind(this,t),this.#pc.bind(this))}async#pc(t){const e=await this.$.eventManager.triggerEvent("onAudioUploadError",{error:t}),s=e===jh?t.errorMessage:e||t.errorMessage;this.$.ui.alertOpen(s,"error"),console.error("[SUNEDITOR.plugin.audio.error]",s)}async#gu(t,e){if(await this.$.eventManager.triggerEvent("audioUploadHandler",{xmlHttp:e,info:t})===jh){const s=JSON.parse(e.responseText);s.errorMessage?this.#pc(s):this.#uc(t,s)}}#Mu(t){const e=Pe.query.getEventTarget(t).value.trim();this.#tp=this.preview.textContent=e?this.$.options.get("defaultUrlProtocol")&&!e.includes("://")&&0!==e.indexOf("#")?this.$.options.get("defaultUrlProtocol")+e:e.includes("://")?e:"/"+e:""}#Bu(){this.$.plugins.audioGallery.open(this.#Fu.bind(this))}#Fu(t){this.#tp=this.preview.textContent=this.audioUrlFile.value=t.getAttribute("data-command")||t.src,this.audioUrlFile.focus()}#Tu(t,e){this.audioInputFile.value="",t&&(t.disabled=!1,e.style.textDecoration=""),Rl.OnChangeFile(this.fileModalWrapper,[])}#ep(t){const e=Pe.query.getEventTarget(t);this.audioInputFile.value?(this.audioUrlFile.disabled=!0,this.preview.style.textDecoration="line-through"):(this.audioUrlFile.disabled=!1,this.preview.style.textDecoration=""),Rl.OnChangeFile(this.fileModalWrapper,e.files)}}const Yh=Kh,{_w:Xh,NO_EVENT:Zh}=Oe;class Jh extends Xl{static key="embed";static className="";static component(t){const e=t.children;let s="",i=null;if(Pe.check.isIFrame(t)&&(i=t,s=t.src),!s&&/^DIV$/i.test(t?.nodeName)&&Pe.check.isIFrame(e[0])&&(i=e[0],s=i.src),!s&&Pe.utils.hasClass(t,"se-embed-container")){i=Pe.query.getChildNode(t,(t=>t.src||t.href)),s=i?.src||i?.href}if(/^BLOCKQUOTE$/i.test(t?.nodeName)){const e=t.querySelector("a");if(e&&e.href)return i=t,s=e.href,this.#Gu(s)?i:null}return s?this.#Gu(s)?i:null:i}static#Gu(t){return t=t?.toLowerCase()||"",!!this.#Yu.some((e=>e.test(t)))}static#np(t,e){return!!t&&e.some((e=>e instanceof RegExp?e.test(t):t.startsWith(e)))}static#Yu=null;#qu;#Wu;#nu;#ou;#dd;#op;#yu;#Cu="";#_u="none";#zc=null;#xu=null;#$u=null;#ru={w:0,h:0};constructor(t,e){super(t),this.title=this.$.lang.embed,this.icon="embed",this.pluginOptions={canResize:void 0===e.canResize||e.canResize,showHeightInput:void 0===e.showHeightInput||!!e.showHeightInput,defaultWidth:e.defaultWidth&&De.get(e.defaultWidth,0)?De.is(e.defaultWidth)?e.defaultWidth+"px":e.defaultWidth:"",defaultHeight:e.defaultHeight&&De.get(e.defaultHeight,0)?De.is(e.defaultHeight)?e.defaultHeight+"px":e.defaultHeight:"",percentageOnlySize:!!e.percentageOnlySize,uploadUrl:"string"==typeof e.uploadUrl?e.uploadUrl:null,uploadHeaders:e.uploadHeaders||null,uploadSizeLimit:De.get(e.uploadSizeLimit,0),uploadSingleSizeLimit:De.get(e.uploadSingleSizeLimit,0),iframeTagAttributes:e.iframeTagAttributes||null,query_youtube:e.query_youtube||"",query_vimeo:e.query_vimeo||"",scriptSrcWhitelist:Array.isArray(e.scriptSrcWhitelist)?e.scriptSrcWhitelist:[],insertBehavior:e.insertBehavior};const s=this.pluginOptions.percentageOnlySize?"%":"px",i=function({lang:t,icons:e},s){let i=`\n\t<form method="post" enctype="multipart/form-data">\n\t\t<div class="se-modal-header">\n\t\t\t<button type="button" data-command="close" class="se-btn se-close-btn" title="${t.close}" aria-label="${t.close}">\n\t\t\t${e.cancel}\n\t\t\t</button>\n\t\t\t<span class="se-modal-title">${t.embed_modal_title}</span>\n\t\t</div>\n\t\t<div class="se-modal-body">\n\t\t\t<div class='se-modal-form'>\n\t\t\t\t<label>${t.embed_modal_source}</label>\n\t\t\t\t<input class='se-input-form se-input-url' type='text' data-focus />\n\t\t\t\t<pre class='se-link-preview'></pre>\n\t\t\t</div>`;if(s.canResize){const n=s.percentageOnlySize,o=n?' style="display: none !important;"':"",r=s.showHeightInput?"":' style="display: none !important;"',l=s.showRatioOption?"":' style="display: none !important;"',a=n||s.showHeightInput||s.showRatioOption?"":' style="display: none !important;"';i+=`\n\t\t\t<div class="se-modal-form">\n\t\t\t\t<div class="se-modal-size-text">\n\t\t\t\t\t<label class="size-w">${t.width}</label>\n\t\t\t\t\t<label class="se-modal-size-x"> </label>\n\t\t\t\t\t<label class="size-h"${r}>${t.height}</label>\n\t\t\t\t\t<label class="size-h"${l}>(${t.ratio})</label>\n\t\t\t\t</div>\n\t\t\t\t<input class="se-input-control _se_size_x" placeholder="auto"${n?' type="number" min="1"':'type="text"'}${n?' max="100"':""}/>\n\t\t\t\t<label class="se-modal-size-x"${a}>${n?"%":"x"}</label>\n\t\t\t\t<input class="se-input-control _se_size_y" placeholder="auto"\n\t\t\t\t${n?' type="number" min="1"':'type="text"'}${n?' max="100"':""}${r}/>\n\t\t\t\t<button type="button" title="${t.revert}" aria-label="${t.revert}" class="se-btn se-modal-btn-revert">${e.revert}</button>\n\t\t\t</div>\n\t\t\t<div class="se-modal-form se-modal-form-footer"${o}${a}>\n\t\t\t\t<label>\n\t\t\t\t\t<input type="checkbox" class="se-modal-btn-check _se_check_proportion" /> \n\t\t\t\t\t<span>${t.proportion}</span>\n\t\t\t\t</label>\n\t\t\t</div>`}i+=`\n\t\t</div>\n\t\t<div class="se-modal-footer">\n\t\t\t<div class="se-figure-align">\n\t\t\t\t<label><input type="radio" name="suneditor_embed_radio" class="se-modal-btn-radio" value="none" checked>${t.basic}</label>\n\t\t\t\t<label><input type="radio" name="suneditor_embed_radio" class="se-modal-btn-radio" value="left">${t.left}</label>\n\t\t\t\t<label><input type="radio" name="suneditor_embed_radio" class="se-modal-btn-radio" value="center">${t.center}</label>\n\t\t\t\t<label><input type="radio" name="suneditor_embed_radio" class="se-modal-btn-radio" value="right">${t.right}</label>\n\t\t\t</div>\n\t\t\t<button type="submit" class="se-btn-primary" title="${t.submitButton}" aria-label="${t.submitButton}"><span>${t.submitButton}</span></button>\n\t\t</div>\n\t</form>`;const n=Pe.utils.createElement("DIV",{class:"se-modal-content"},i);return{html:n,figureAlignBtn:n.querySelector(".se-figure-align"),fileModalWrapper:n.querySelector(".se-flex-input-wrapper"),embedInput:n.querySelector(".se-input-url"),previewSrc:n.querySelector(".se-link-preview"),proportion:n.querySelector("._se_check_proportion"),inputX:n.querySelector("._se_size_x"),inputY:n.querySelector("._se_size_y"),revertBtn:n.querySelector(".se-modal-btn-revert")}}(this.$,this.pluginOptions),n=e.controls||(this.pluginOptions.canResize?[["resize_auto,75,50","align","edit","revert","copy","remove"]]:[["align","edit","copy","remove"]]);n.some((t=>t.includes("align")))||(i.figureAlignBtn.style.display="none"),this.modal=new Rl(this,this.$,i.html),this.figure=new ji(this,this.$,n,{sizeUnit:s}),this.fileModalWrapper=i.fileModalWrapper,this.embedInput=i.embedInput,this.focusElement=this.embedInput,this.previewSrc=i.previewSrc,this.sizeUnit=s,this.proportion=null,this.inputX=null,this.inputY=null,this.#qu=this.pluginOptions.defaultWidth,this.#Wu=this.pluginOptions.defaultHeight,this.#nu="auto"===this.pluginOptions.defaultWidth?"":this.pluginOptions.defaultWidth,this.#ou="auto"===this.pluginOptions.defaultHeight?"":this.pluginOptions.defaultHeight,this.#dd=this.pluginOptions.canResize,this.#op=this.pluginOptions.percentageOnlySize,this.#yu=!this.#dd||!this.pluginOptions.showHeightInput||this.#op,this.query={facebook:{pattern:/(?:https?:\/\/)?(?:www\.)?(?:facebook\.com)\/(.+)/i,action:t=>`https://www.facebook.com/plugins/post.php?href=${encodeURIComponent(t)}&show_text=true&width=500`,tag:"iframe"},twitter:{pattern:/^(?:https?:\/\/)?(?:(?:www\.)?(?:twitter\.com|x\.com)\/(?:[^/?#]+\/)?status\/\d+(?:[/?#]|$)|platform\.twitter\.com\/embed\/Tweet\.html(?:[?#].*)?$)/i,action:t=>`https://platform.twitter.com/embed/Tweet.html?url=${encodeURIComponent(t)}`,tag:"iframe"},instagram:{pattern:/(?:https?:\/\/)?(?:www\.)?(?:instagram\.com)\/p\/(.+)/i,action:t=>`https://www.instagram.com/p/${t.match(this.query.instagram.pattern)[1]}/embed`,tag:"iframe"},linkedin:{pattern:/(?:https?:\/\/)?(?:www\.)?(?:linkedin\.com)\/(.+)\/(.+)/i,action:t=>`https://www.linkedin.com/embed/feed/update/${encodeURIComponent(t.split("/").pop())}`,tag:"iframe"},pinterest:{pattern:/(?:https?:\/\/)?(?:www\.)?(?:pinterest\.com)\/pin\/(.+)/i,action:t=>`https://assets.pinterest.com/ext/embed.html?id=${t.match(this.query.pinterest.pattern)[1]}`,tag:"iframe"},spotify:{pattern:/(?:https?:\/\/)?(?:open\.)?(?:spotify\.com)\/(track|album|playlist|show|episode)\/(.+)/i,action:t=>{const e=t.match(this.query.spotify.pattern);return`https://open.spotify.com/embed/${e[1]}/${e[2]}`},tag:"iframe"},codepen:{pattern:/(?:https?:\/\/)?(?:www\.)?(?:codepen\.io)\/(.+)\/pen\/(.+)/i,action:t=>{const[,e,s]=t.match(this.query.codepen.pattern);return`https://codepen.io/${e}/embed/${s}`},tag:"iframe"},...e.embedQuery};const o=[];for(const t in this.query)o.push(this.query[t].pattern);Jh.#Yu=o.concat(e.urlPatterns||[]),this.$.eventManager.addEvent(this.embedInput,"input",this.#Mu.bind(this)),this.#dd&&(this.proportion=i.proportion,this.inputX=i.inputX,this.inputY=i.inputY,this.inputX.value=this.pluginOptions.defaultWidth,this.inputY.value=this.pluginOptions.defaultHeight,this.$.eventManager.addEvent(this.inputX,"keyup",this.#du.bind(this,"x")),this.$.eventManager.addEvent(this.inputY,"keyup",this.#du.bind(this,"y")),this.$.eventManager.addEvent(i.revertBtn,"click",this.#uu.bind(this)))}open(){this.modal.open()}retainFormat(){return{query:"iframe",method:async t=>{if(!Jh.#Gu(t.src))return;const e=ji.GetContainer(t);if(e&&e.container&&e.cover)return;this.#Lu(t,!0);const s=this.$.format.getLine(t);s&&(this.#_u=s.style.textAlign||s.style.float),this.#Ou(t)}}}modalOn(t){!t&&this.#dd?(this.inputX.value=this.#nu="auto"===this.pluginOptions.defaultWidth?"":this.pluginOptions.defaultWidth,this.inputY.value=this.#ou="auto"===this.pluginOptions.defaultHeight?"":this.pluginOptions.defaultHeight,this.proportion.disabled=!0):t&&(this.#Cu=this.previewSrc.textContent=this.embedInput.value=this.#xu.getAttribute("data-se-origin")||"")}async modalAction(){this.#_u=this.modal.form.querySelector('input[name="suneditor_embed_radio"]:checked').value;let t=!1;return this.#Cu.length>0&&(t=await this.submitSRC(this.#Cu)),t&&Xh.setTimeout(this.$.component.select.bind(this.$.component,this.#zc,Jh.key),0),t}modalInit(){Rl.OnChangeFile(this.fileModalWrapper,[]),this.#Cu=this.previewSrc.textContent=this.embedInput.value="",this.modal.form.querySelector('input[name="suneditor_embed_radio"][value="none"]').checked=!0,this.#ru={w:0,h:0},this.#yu=!1,this.#dd&&(this.inputX.value=this.pluginOptions.defaultWidth===this.#qu?"":this.pluginOptions.defaultWidth,this.inputY.value=this.pluginOptions.defaultHeight===this.#Wu?"":this.pluginOptions.defaultHeight,this.proportion.checked=!1,this.proportion.disabled=!0)}componentSelect(t){this.#Lu(t)}componentEdit(){this.modal.open()}async componentDestroy(t){const e=t||this.#zc,s=Pe.query.getParentElement(e,ji.is)||e,i=s.previousElementSibling||s.nextElementSibling,n=s.parentNode;!1!==await this.$.eventManager.triggerEvent("onEmbedDeleteBefore",{element:e,container:s,align:this.#_u,url:this.#Cu})&&(Pe.utils.removeItem(s),this.modalInit(),n!==this.$.frameContext.get("wysiwyg")&&this.$.nodeTransform.removeAllParents(n,(function(t){return 0===t.childNodes.length}),null),this.$.focusManager.focusEdge(i),this.$.history.push(!1))}findProcessUrl(t){const e=this.query;for(const s in e){const i=e[s];if(i.pattern.test(t))return{origin:t,url:i.action(t),tag:i.tag}}return null}async submitSRC(t){if(!(t||=this.#Cu))return!1;let e=null;if(/^<iframe\s|^<blockquote\s/i.test(t)){const s=(new DOMParser).parseFromString(t,"text/html").body.children;if(0===s.length)return!1;for(let t=0;t<s.length;t++){const e=s[t];if(/^iframe$/i.test(e.nodeName)&&!Jh.#Gu(e.getAttribute("src")||""))return!1;const i=e.querySelectorAll?.("iframe");if(i)for(let t=0;t<i.length;t++)if(!Jh.#Gu(i[t].getAttribute("src")||""))return!1}e={children:s,...this.#zu(),process:null}}else{const s=this.findProcessUrl(t);if(!s)return!1;t=s.url,e={...this.#zu(),url:t,process:s}}const s=function(e,s,i){e(t,(s=i||s).process,s.url,s.children,s.inputWidth,s.inputHeight,s.align,s.isUpdate)}.bind(this,this.#rp.bind(this),e),i=await this.$.eventManager.triggerEvent("onEmbedInputBefore",{...e,handler:s});return void 0===i||!1!==i&&(null!==i&&"object"==typeof i&&s(i),!0!==i&&i!==Zh||s(null),!0)}#Lu(t,e=!1){if(!t)return;const s=this.figure.open(t,{nonResizing:this.#yu,nonSizeInfo:!1,nonBorder:!1,figureTarget:!1,infoOnly:e});if(this.#zc=t,this.#xu=s.cover,this.#$u=s.container,this._caption=s.caption,this.#_u=s.align,!this.#xu?.getAttribute?.("data-se-origin")){const e=t?.getAttribute?.("src")||t?.querySelector?.("a")?.href;e&&Jh.#Gu(e)&&this.#xu.setAttribute("data-se-origin",e)}t.style.float="",this.#nu=String(s.originWidth||s.w||""),this.#ou=String(s.originHeight||s.h||"");if((this.modal.form.querySelector('input[name="suneditor_embed_radio"][value="'+this.#_u+'"]')||this.modal.form.querySelector('input[name="suneditor_embed_radio"][value="none"]')).checked=!0,!this.#dd)return;const i=this.#op&&this.figure.isVertical,{dw:n,dh:o}=this.figure.getSize(t);this.inputX.value="auto"===n?"":n,this.inputY.value="auto"===o?"":o,this.proportion.checked=!0,this.inputX.disabled=!!i,this.inputY.disabled=!!i,this.proportion.disabled=!!i,this.#ru=this.proportion.checked?s.ratio:{w:0,h:0}}#lp(){const t=Pe.utils.createElement("IFRAME");return this.#Xu(t),t}#ap(){return Pe.utils.createElement("BLOCKQUOTE")}#rp(t,e,s,i,n,o,r,l){let a=null,h=null,c=null,d=null;if(l){if(a=this.#zc,a.src!==s){const t=this.findProcessUrl(s);if(/^iframe$/i.test(t?.tag)&&!/^iframe$/i.test(a.nodeName)){const t=this.#lp();t.src=s,a.replaceWith(t),a=t}else if(/^blockquote$/i.test(t?.tag)&&!/^blockquote$/i.test(a.nodeName)){const t=this.#ap();t.setAttribute("src",s),a.replaceWith(t),a=t}else a.src=s}c=this.#$u,h=Pe.query.getParentElement(a,"FIGURE")}else if(e){a=this.#lp(),a.src=s;const t=ji.CreateContainer(a,"se-embed-container");h=t.cover,c=t.container}else{a=i[0];const t=ji.CreateContainer(a,"se-embed-container");h=t.cover,c=t.container;const e=Array.from(i),s=this.pluginOptions.scriptSrcWhitelist;for(const t of e)if(/^script$/i.test(t.nodeName)){const e=t.getAttribute("src")||"";if(!Jh.#np(e,s))continue;d=Pe.utils.createElement("script",{src:e,async:"true"},null)}else h.appendChild(t)}this.#zc=a,this.#xu=h,this.#$u=c,this.figure.open(a,{nonResizing:this.#yu,nonSizeInfo:!1,nonBorder:!1,figureTarget:!1,infoOnly:!0}),n||=this.#qu,o||=this.#Wu;const u=this.figure.getSize(a),p=u.w!==n||u.h!==o,g=!l||p;if(g&&this.#hp(n,o),this.figure.setAlign(a,r),h.setAttribute("data-se-origin",t),l)this.#dd&&g&&this.figure.isVertical||this.figure.setTransform(a,n,o,0),d||this.$.history.push(!1);else{if(this.$.component.insert(c,{skipHistory:!0,scrollTo:!1,insertBehavior:this.pluginOptions.insertBehavior}),d)try{this.$.history.pause(),d.onload=()=>{Pe.utils.removeItem(d),d=null},h.appendChild(d);const t=new MutationObserver((e=>{for(const s of e)if("childList"===s.type&&!a.parentElement){this.$.history.resume(),this.$.history.push(!1),t.disconnect();break}}));t.observe(this.$.frameContext.get("wysiwyg"),{subtree:!0,childList:!0})}catch(t){this.$.history.resume(),console.warn("[SUNEDITOR] Embed tag script load error.",t)}if(!this.$.options.get("componentInsertBehavior")){const t=this.$.format.addLine(c,null);t&&this.$.selection.setRange(t,0,t,0)}}}#Ou(t){if(!t)return;this.#Xu(t);const e=t;t=t.cloneNode(!0);const s=ji.CreateContainer(t,"se-embed-container").container;this.figure.open(t,{nonResizing:this.#yu,nonSizeInfo:!1,nonBorder:!1,figureTarget:!1,infoOnly:!0});const i=(t.getAttribute("data-se-size")||",").split(","),n=i[0]||e.width||"",o=i[1]||e.height||"";this.#hp(n,o);const r=this.$.format.getLine(e);return r&&(this.#_u=r.style.textAlign||r.style.float),this.figure.setAlign(t,this.#_u),this.figure.retainFigureFormat(s,this.#zc,null,null),t}#hp(t,e){t||=this.inputX?.value||this.pluginOptions.defaultWidth,e||=this.inputY?.value||this.pluginOptions.defaultHeight,this.#op&&(t?/%$/.test(t+"")||(t+="%"):t="100%"),this.figure.setSize(t,e)}#zu(){return{inputWidth:this.inputX?.value||"",inputHeight:this.inputY?.value||"",align:this.#_u,isUpdate:this.modal.isUpdate,element:this.#zc}}#Xu(t){t.frameBorder="0",t.allowFullscreen=!0;const e=this.pluginOptions.iframeTagAttributes;if(e)for(const s in e)t.setAttribute(s,e[s])}#Mu(t){const e=Pe.query.getEventTarget(t).value.trim();/^<iframe.*\/iframe>$/.test(e)?(this.#Cu=e,this.previewSrc.textContent='<IFrame :src=".."></IFrame>'):this.#Cu=this.previewSrc.textContent=e?this.$.options.get("defaultUrlProtocol")&&!e.includes("://")&&0!==e.indexOf("#")?this.$.options.get("defaultUrlProtocol")+e:e.includes("://")?e:"/"+e:""}#uu(){this.#op?this.inputX.value=Number(this.#nu)>100?"100":this.#nu:(this.inputX.value=this.#nu,this.inputY.value=this.#ou)}#du(t,e){if(Fe.isSpace(e.code))return void e.preventDefault();const s=Pe.query.getEventTarget(e);if("x"===t&&this.#op&&Number(s.value)>100)s.value="100";else if(this.proportion.checked){const e=ji.CalcRatio(this.inputX.value,this.inputY.value,this.sizeUnit,this.#ru);"x"===t?this.inputY.value=String(e.h):this.inputX.value=String(e.w)}}}const Qh=Jh,{_w:tc,_d:ec}=Oe;class sc extends Xl{static key="math";static className="";static component(t){return Pe.utils.hasClass(t,"se-math|katex")&&Pe.check.isComponentContainer(t)?t:null}#zc=null;constructor(t,e){super(t),this.title=this.$.lang.math,this.icon="math",this.katex=null,this.mathjax=null,(this.katex=this.#cp())||(this.mathjax=this.#dp())||console.warn('[SUNEDITOR.plugins.math.warn] The math plugin must need either "KaTeX" or "MathJax" library. Please add the katex or mathjax option. See: https://github.com/ARA-developer/suneditor/blob/develop/guide/external-libraries.md'),this.pluginOptions={formSize:{width:"460px",height:"14em",maxWidth:"",maxHeight:"",minWidth:"400px",minHeight:"40px",...e.formSize},canResize:e.canResize??!0,autoHeight:!!e.autoHeight,fontSizeList:e.fontSizeList||[{text:"1",value:"1em"},{text:"1.5",value:"1.5em"},{text:"2",value:"2em"},{text:"2.5",value:"2.5em"}],onPaste:"function"==typeof e.onPaste?e.onPaste:null},this.pluginOptions.autoHeight&&(this.pluginOptions.formSize.height=this.pluginOptions.formSize.minHeight),this.defaultFontSize=null;const s=function(t){const{$:e,pluginOptions:s,katex:i}=t,{lang:n,icons:o}=e,{formSize:r,fontSizeList:l,canResize:a,autoHeight:h}=s,{width:c,height:d,maxWidth:u,maxHeight:p,minWidth:g,minHeight:m}=r,f=a?h?"horizontal":"auto":"none";let v=l[0].value,b=`\n <form>\n <div class="se-modal-header">\n <button type="button" data-command="close" class="se-btn se-close-btn" title="${n.close}" aria-label="${n.close}">\n ${o.cancel}\n </button>\n <span class="se-modal-title">${n.math_modal_title}</span>\n </div>\n <div class="se-modal-body">\n <div class="se-modal-form">\n <label>${n.math_modal_inputLabel} ${i?`(<a href="${Oe.KATEX_WEBSITE}" target="_blank">KaTeX</a>)`:`(<a href="${Oe.MATHJAX_WEBSITE}" target="_blank">MathJax</a>)`}</label>\n <textarea class="se-input-form se-math-exp se-modal-resize-form" type="text" data-focus style="width: ${c}; height: ${d}; min-width: ${g}; min-height: ${m}; resize: ${f};"></textarea>\n </div>\n <div class="se-modal-form">\n <label>${n.math_modal_fontSizeLabel}</label>\n <select class="se-input-select se-math-size">`;for(let t,e=0,s=l.length;e<s;e++)t=l[e],t.default&&(v=t.value),b+=`<option value="${t.value}"${t.default?" selected":""}>${t.text}</option>`;return b+=`</select>\n </div>\n <div class="se-modal-form">\n <label>${n.math_modal_previewLabel}</label>\n <p class="se-math-preview"></p>\n </div>\n </div>\n <div class="se-modal-footer">\n <button type="submit" class="se-btn-primary" title="${n.submitButton}" aria-label="${n.submitButton}">\n <span>${n.submitButton}</span>\n </button>\n </div>\n </form>`,t.defaultFontSize=v,Pe.utils.createElement("DIV",{class:"se-modal-content se-modal-responsive",style:`max-width: ${u}; max-height: ${p};`},b)}(this),i=function({lang:t,icons:e}){const s=`\n <div class="se-arrow se-arrow-up"></div>\n <div class="link-content">\n <div class="se-btn-group">\n <button type="button" data-command="update" tabindex="-1" class="se-btn se-tooltip">\n ${e.edit}\n <span class="se-tooltip-inner">\n <span class="se-tooltip-text">${t.edit}</span>\n </span>\n </button>\n <button type="button" data-command="copy" tabindex="-1" class="se-btn se-tooltip">\n ${e.copy}\n <span class="se-tooltip-inner">\n <span class="se-tooltip-text">${t.copy}</span>\n </span>\n </button>\n <button type="button" data-command="delete" tabindex="-1" class="se-btn se-tooltip">\n ${e.delete}\n <span class="se-tooltip-inner">\n <span class="se-tooltip-text">${t.remove}</span>\n </span>\n </button>\n </div>\n </div>`;return Pe.utils.createElement("DIV",{class:"se-controller se-controller-link"},s)}(this.$);this.modal=new Rl(this,this.$,s),this.controller=new Ii(this,this.$,i,{position:"bottom",disabled:!0}),this.textArea=s.querySelector(".se-math-exp"),this.previewElement=s.querySelector(".se-math-preview"),this.fontSizeElement=s.querySelector(".se-math-size"),this.isUpdateState=!1,this.previewElement.style.fontSize=this.defaultFontSize,this.$.eventManager.addEvent(this.textArea,"input",this.#up.bind(this)),this.$.eventManager.addEvent(this.fontSizeElement,"change",function(t){this.fontSize=t.target.value}.bind(this.previewElement.style)),this.pluginOptions.onPaste&&this.$.eventManager.addEvent(this.textArea,"paste",this.pluginOptions.onPaste.bind(this))}open(){this.modal.open()}retainFormat(){return{query:".se-math, .katex, .MathJax",method:t=>{if(!this.katex&&!this.mathjax)return;const e=ic(t);if(!e)return;const s=ec.createRange().createContextualFragment(this.#pp(ze.entityToHTML(this.#gp(e,!0))));t.innerHTML=s.querySelector(".se-math, .katex").innerHTML,t.setAttribute("contenteditable","false"),Pe.utils.addClass(t,"se-component|se-inline-component|se-disable-pointer|se-math"),this.katex?Pe.utils.addClass(t,"katex"):Pe.utils.removeClass(t,"katex"),this.mathjax&&this.#mp(this.mathjax)}}}modalOn(t){if(this.isUpdateState=t,t){if(this.controller.currentTarget){const t=this.controller.currentTarget,e=ze.entityToHTML(this.#gp(ic(t),!0)),s=function(t){const e=t.getAttribute("data-se-type");if(e)return e;const s=t.getAttribute("data-font-size");return s?(t.removeAttribute("data-font-size"),t.setAttribute("data-se-type",s),s):null}(t)||"1em";this.textArea.value=e,this.fontSizeElement.value=s,this.previewElement.innerHTML=this.#pp(e),this.previewElement.style.fontSize=s}}else this.modalInit()}async modalAction(){if(0===this.textArea.value.trim().length||Pe.utils.hasClass(this.textArea,"se-error"))return this.textArea.focus(),!1;const t=this.textArea.value,e=this.previewElement.querySelector(".se-math, .katex");if(!e)return!1;if(Pe.utils.addClass(e,"se-component|se-inline-component|se-disable-pointer|se-math"),e.setAttribute("contenteditable","false"),e.setAttribute("data-se-value",ze.htmlToEntity(this.#gp(t,!1))),e.setAttribute("data-se-type",this.fontSizeElement.value),e.style.fontSize=this.fontSizeElement.value,this.katex?(Pe.utils.addClass(e,"katex"),Pe.utils.removeClass(e,"MathJax")):Pe.utils.removeClass(e,"katex"),this.isUpdateState){Pe.query.getParentElement(this.controller.currentTarget,".se-component").replaceWith(e);const t=this.$.component.get(e);return this.$.component.select(t.target,t.pluginName),!0}{const t=this.$.format.getLines();if(t.length>1){const s=Pe.utils.createElement(t[0].nodeName,null,e);this.$.component.insert(s,{insertBehavior:"none",scrollTo:!1})}else this.$.component.insert(e,{insertBehavior:"none",scrollTo:!1})}this.mathjax&&this.#mp(this.mathjax);const s=this.$.selection.getNearRange(e);return s?this.$.selection.setRange(s.container,s.offset,s.container,s.offset):this.$.component.select(e,sc.key),!0}modalInit(){this.textArea.value="",this.previewElement.innerHTML="",Pe.utils.removeClass(this.textArea,"se-error")}controllerAction(t){switch(t.getAttribute("data-command")){case"update":this.modal.open();break;case"copy":this.#fp(this.#zc);break;case"delete":this.componentDestroy(this.controller.currentTarget)}}controllerClose(){this.#zc=null}componentSelect(t){if(Pe.utils.hasClass(t,"se-math|katex")&&ic(t))return this.#zc=t,void this.controller.open(t,null,{isWWTarget:!1,initMethod:null,addOffset:null})}async componentDestroy(t){Pe.utils.removeItem(t),this.controller.close(),this.$.focusManager.focus(),this.$.history.push(!1)}#pp(t){let e="";try{if(Pe.utils.removeClass(this.textArea,"se-error"),this.katex)e=this.katex.src.renderToString(t,{throwOnError:!0,displayMode:!0});else{if(!this.mathjax){const t=new Error('404 Not found. "KaTeX" or "MathJax" library');throw t.code="MATH_LIB_NOT_FOUND",t}e=this.mathjax.convert(t).outerHTML,/<mjx-merror/.test(e)?(Pe.utils.addClass(this.textArea,"se-error"),e=`<span class="se-math-error">${e}</span>`):e=`<span class="se-math">${e}</span>`}}catch(t){Pe.utils.addClass(this.textArea,"se-error"),e="MATH_LIB_NOT_FOUND"===t.code?`<span class="se-math-error">${t.message}</span>`:`<span class="se-math-error">Math syntax error. (Refer ${this.katex?`<a href="${Oe.KATEX_WEBSITE}" target="_blank">KaTeX</a>`:`<a href="${Oe.MATHJAX_WEBSITE}" target="_blank">MathJax</a>`})</span>`,console.warn("[SUNEDITOR.math.error] ",t.message)}return e}#gp(t,e){return t.replace(/\\{2}/g,e?"\\":"\\\\")}async#fp(t){if(navigator.clipboard&&t)try{const e=ic(t);await this.$.html.copy(e),Pe.utils.addClass(t,"se-copy"),tc.setTimeout((()=>{Pe.utils.removeClass(t,"se-copy")}),120)}catch(t){console.error("[SUNEDITOR.math.copy.fail]",t)}}#up(t){const e=Pe.query.getEventTarget(t);this.pluginOptions.autoHeight&&(e.style.height="5px",e.style.height=e.scrollHeight+5+"px"),this.previewElement.innerHTML=this.#pp(e.value),this.mathjax&&this.#mp(this.mathjax)}#mp(t){t.clear(),t.updateDocument()}#cp(){const t=this.$.options.get("externalLibs").katex;if(!t)return null;if(!t.src)return console.warn("[SUNEDITOR.math.katex.fail] The katex option is set incorrectly."),null;const e=[{throwOnError:!1},t.options||{}].reduce(((t,e)=>{for(const s in e)t[s]=e[s];return t}),{});return t.options=e,t}#dp(){const t=this.$.options.get("externalLibs").mathjax;if(!t)return null;this.$.frameOptions.get("iframe")&&console.warn("[SUNEDITOR.math.mathjax.fail] The MathJax option is not supported in the iframe.");try{const e=t.browserAdaptor();t.RegisterHTMLHandler(e);const s=new t.TeX,i=new t.CHTML;return t.src.document(document,{InputJax:s,OutputJax:i})}catch(t){return console.warn("[SUNEDITOR.math.mathjax.fail] The MathJax option is set incorrectly.",t),null}}}function ic(t){const e=t.getAttribute("data-se-value");if(e)return e;const s=t.getAttribute("data-exp");return s?(t.removeAttribute("data-exp"),t.setAttribute("data-se-value",s),s):null}const nc=sc,{_w:oc}=Oe;const rc=class extends Xl{static key="drawing";static className="";#st;#vp;constructor(t,e){super(t),this.title=this.$.lang.drawing,this.icon="drawing",this.pluginOptions={outputFormat:e.outputFormat||"dataurl",useFormatType:e.useFormatType??!1,defaultFormatType:["block","inline"].includes(e.defaultFormatType)?e.defaultFormatType:"block",keepFormatType:e.keepFormatType??!1,lineWidth:e.lineWidth||5,lineReconnect:!!e.lineReconnect,lineCap:["butt","round","square"].includes(e.lineCap)?e.lineCap:"round",lineColor:e.lineColor||"",formSize:{width:"750px",height:"50vh",maxWidth:"",maxHeight:"",minWidth:"150px",minHeight:"100px",...e.formSize},canResize:e.canResize??!0,maintainRatio:e.maintainRatio??!0},this.$.plugins.image?"svg"!==this.pluginOptions.outputFormat||this.$.plugins.image.pluginOptions.uploadUrl||console.warn('[SUNEDITOR.plugins.drawing.warn] The drawing plugin must need the "image" plugin with the "uploadUrl" option. Please add the "image" plugin with the "uploadUrl" option.'):console.warn('[SUNEDITOR.plugins.drawing.warn] The drawing plugin must need either "image" plugin. Please add the "image" plugin.');const s=function({lang:t,icons:e},s){const{width:i,height:n,maxWidth:o,maxHeight:r,minWidth:l,minHeight:a}=s.formSize,h=`\n <form>\n <div class="se-modal-header">\n <button type="button" data-command="close" class="se-btn se-close-btn" title="${t.close}" aria-label="${t.close}">\n ${e.cancel}\n </button>\n <span class="se-modal-title">${t.drawing_modal_title}</span>\n </div>\n <div class="se-modal-body" style="width: ${i}; height: ${n}; min-width: ${l}; min-height: ${a};">\n <canvas class="se-drawing-canvas" style="width: 100%; height: 100%;"></canvas>\n\t\t\t${s.canResize?'<div class="se-modal-resize-handle-w"></div><div class="se-modal-resize-handle-h"></div><div class="se-modal-resize-handle-c"></div>':""}\n\t\t</div>\n\t\t<div class="se-modal-body-bottom">\n\t\t\t<div class="se-modal-form">\n\t\t\t\t<div class="se-modal-flex-form">\n\t\t\t\t\t${s.useFormatType?`\n\t\t\t\t\t\t\t<div class="se-modal-flex-group">\n\t\t\t\t\t\t\t\t<button type="button" class="se-btn se-tooltip" data-command="asBlock" aria-label="${t.blockStyle}">\n\t\t\t\t\t\t\t\t\t${e.as_block}\n\t\t\t\t\t\t\t\t\t${Pe.utils.createTooltipInner(t.blockStyle)}\n\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t<button type="button" class="se-btn se-tooltip" data-command="asInline" aria-label="${t.inlineStyle}">\n\t\t\t\t\t\t\t\t\t${e.as_inline}\n\t\t\t\t\t\t\t\t\t${Pe.utils.createTooltipInner(t.inlineStyle)}\n\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t</div>`:""}\n\t\t\t\t\t<div class="se-modal-flex-group">\n\t\t\t\t\t\t<button type="button" class="se-btn se-tooltip" data-command="remove" aria-label="${t.remove}">\n\t\t\t\t\t\t\t${e.eraser}\n\t\t\t\t\t\t\t${Pe.utils.createTooltipInner(t.remove)}\n\t\t\t\t\t\t</button>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n <div class="se-modal-footer">\n\t\t\t<button type="submit" class="se-btn-primary" title="${t.submitButton}" aria-label="${t.submitButton}">\n\t\t\t\t<span>${t.submitButton}</span>\n\t\t\t</button>\n </div>\n </form>`;return Pe.utils.createElement("DIV",{class:"se-modal-content se-modal-responsive",style:`max-width: ${o}; max-height: ${r};`},h)}(this.$,this.pluginOptions);this.modal=new Rl(this,this.$,s),this.as=this.pluginOptions.defaultFormatType,this.pluginOptions.useFormatType&&(this.asBlock=s.querySelector('[data-command="asBlock"]'),this.asInline=s.querySelector('[data-command="asInline"]'),this.$.eventManager.addEvent([this.asBlock,this.asInline],"click",this.#Iu.bind(this))),this.canvas=null,this.ctx=null,this.isDrawing=!1,this.points=[],this.paths=[],this.resizeObserver=null,this.#st={touchstart:this.#bp.bind(this),touchmove:this.#yp.bind(this),mousedown:this.#wp.bind(this),mousemove:this.#Cp.bind(this),mouseup:this.#_p.bind(this),mouseleave:this.#kp.bind(this),mouseenter:this.#xp.bind(this)},this.#vp={touchstart:null,touchmove:null,mousedown:null,mousemove:null,mouseup:null,mouseleave:null,mouseenter:null},this.$.eventManager.addEvent(s.querySelector('[data-command="remove"]'),"click",this.#$p.bind(this))}open(){this.pluginOptions.useFormatType&&this.#Ru("inline"===(this.pluginOptions.keepFormatType?this.as:this.pluginOptions.defaultFormatType)),this.modal.open(),this.#Sp()}modalOff(){this.#Ep()}async modalAction(){if("svg"===this.pluginOptions.outputFormat){const t=this.#Tp();this.$.plugins.image.modalInit(),this.$.plugins.image.submitFile(t)}else{const t=this.canvas.toDataURL(),e={name:"drawing",size:0};this.$.plugins.image.modalInit(),"inline"!==this.as?this.$.plugins.image.create(t,null,"auto","","none",e,""):this.$.plugins.image.createInline(t,null,"auto","","none",e,"")}return!0}#Sp(){const t=this.canvas=this.modal.form.querySelector(".se-drawing-canvas");this.ctx=t.getContext("2d"),t.width=t.offsetWidth,t.height=t.offsetHeight,this.points=[],this.paths=[],this.#Mp(),this.#vp.touchstart=this.$.eventManager.addEvent(t,"touchstart",this.#st.touchstart,{passive:!1,capture:!0}),this.#vp.touchmove=this.$.eventManager.addEvent(t,"touchmove",this.#st.touchmove,!0),this.#vp.mousedown=this.$.eventManager.addEvent(t,"mousedown",this.#st.mousedown,{passive:!1,capture:!0}),this.#vp.mousemove=this.$.eventManager.addEvent(t,"mousemove",this.#st.mousemove,!0),this.#vp.mouseup=this.$.eventManager.addEvent(t,"mouseup",this.#st.mouseup,!0),this.#vp.mouseleave=this.$.eventManager.addEvent(t,"mouseleave",this.#st.mouseleave),this.#vp.mouseenter=this.$.eventManager.addEvent(t,"mouseenter",this.#st.mouseenter),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),Oe.isResizeObserverSupported&&(this.resizeObserver=new ResizeObserver((()=>{const e=t.width,s=t.height,i=t.offsetWidth,n=t.offsetHeight;t.width=i,t.height=n,e===t.width&&s===t.height||(this.pluginOptions.maintainRatio&&this.#Np(e,s,i,n),this.#Bp())})),this.resizeObserver.observe(t))}#Ep(){this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.canvas&&(this.$.eventManager.removeEvent(this.#vp.mousedown),this.$.eventManager.removeEvent(this.#vp.mousemove),this.$.eventManager.removeEvent(this.#vp.mouseup),this.$.eventManager.removeEvent(this.#vp.mouseleave),this.$.eventManager.removeEvent(this.#vp.mouseenter)),this.canvas=null,this.ctx=null,this.points=[],this.paths=[],this.isDrawing=!1}#Mp(){this.ctx.lineWidth=this.pluginOptions.lineWidth,this.ctx.lineCap=this.pluginOptions.lineCap,this.ctx.strokeStyle=this.pluginOptions.lineColor||oc.getComputedStyle(this.$.contextProvider.carrierWrapper).color}#Ip(){this.#Mp(),this.ctx.beginPath(),this.points.forEach((([t,e],s)=>{0===s?this.ctx.moveTo(t,e):this.ctx.lineTo(t,e)})),this.ctx.stroke()}#Bp(){this.#Mp(),this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.paths.forEach((t=>{this.points=t,this.#Ip()})),this.points=[]}#Np(t,e,s,i){const n=s/t,o=i/e;this.paths=this.paths.map((t=>t.map((([t,e])=>[t*n,e*o]))))}#Lp(){this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.points=[],this.paths=[]}#Ap(){const t="http://www.w3.org/2000/svg",e=document.createElementNS(t,"svg");return e.setAttribute("width",this.canvas.width+""),e.setAttribute("height",this.canvas.height+""),e.setAttribute("viewBox",`0 0 ${this.canvas.width} ${this.canvas.height}`),e.setAttribute("xmlns",t),this.paths.forEach((s=>{const i=s.reduce(((t,[e,s],i)=>t+(0===i?`M ${e} ${s}`:` L ${e} ${s}`)),""),n=document.createElementNS(t,"path");n.setAttribute("d",i),n.setAttribute("fill","none"),n.setAttribute("stroke",String(this.ctx.strokeStyle)),n.setAttribute("stroke-width",this.ctx.lineWidth+""),e.appendChild(n)})),e}#Tp(){const t=this.#Ap(),e=(new XMLSerializer).serializeToString(t),s=new Blob([e],{type:"image/svg+xml"}),i=new File([s],"drawing.svg",{type:"image/svg+xml"}),n=new DataTransfer;return n.items.add(i),n.files}#Op(t){const{touches:e}=t,s=this.canvas.getBoundingClientRect();return{x:e[0].clientX-s.left,y:e[0].clientY-s.top}}#Ru(t){t?(Pe.utils.addClass(this.asInline,"on"),Pe.utils.removeClass(this.asBlock,"on"),this.as="inline"):(Pe.utils.addClass(this.asBlock,"on"),Pe.utils.removeClass(this.asInline,"on"),this.as="block")}#wp(t){t.preventDefault(),this.isDrawing=!0,this.points.push([t.offsetX,t.offsetY]),this.#Ip()}#Cp(t){t.preventDefault(),this.isDrawing&&(this.points.push([t.offsetX,t.offsetY]),this.#Ip())}#bp(t){t.preventDefault();const{x:e,y:s}=this.#Op(t);this.isDrawing=!0,this.points.push([e,s]),this.#Ip()}#yp(t){t.preventDefault();const{x:e,y:s}=this.#Op(t);this.isDrawing&&(this.points.push([e,s]),this.#Ip())}#_p(){this.isDrawing=!1,this.points.length>0&&(this.paths.push([...this.points]),this.points=[])}#kp(){this.isDrawing&&(this.paths.push([...this.points]),this.pluginOptions.lineReconnect||(this.points=[],this.isDrawing=!1))}#xp(t){if(1===t.buttons){if(this.isDrawing=!0,this.pluginOptions.lineReconnect){const e=this.paths.at(-1).at(-1);this.points.push([e[0],e[1]]),this.points.push([t.offsetX,t.offsetY])}else this.points.push([t.offsetX,t.offsetY]);this.#Ip()}}#$p(){this.#Lp()}#Iu(t){this.#Ru("asInline"===Pe.query.getEventTarget(t).getAttribute("data-command"))}};const lc=class extends Ul{static key="imageGallery";static className="";constructor(t,e){super(t),this.title=this.$.lang.imageGallery,this.icon="image_gallery",this.onSelectfunction=null,this.browser=new jr(this,this.$,{title:this.$.lang.imageGallery,data:e.data,url:e.url,headers:e.headers,searchUrl:e.searchUrl,searchHeaders:e.searchHeaders,selectorHandler:this.#Rp.bind(this),columnSize:4,className:"se-image-gallery"}),this.width="auto"===this.$.plugins.image.pluginOptions.defaultWidth?"":this.$.plugins.image.pluginOptions.defaultWidth,this.height="auto"===this.$.plugins.image.pluginOptions.defaultHeight?"":this.$.plugins.image.pluginOptions.defaultHeight}open(t){this.onSelectfunction=t,this.browser.open()}close(){this.onSelectfunction=null,this.browser.close()}#Rp(t){if(this.onSelectfunction)this.onSelectfunction(t);else{const e={name:t.getAttribute("data-name"),size:0};this.$.plugins.image.modalInit(),this.$.plugins.image.create(t.getAttribute("data-command"),null,this.width,this.height,"none",e,t.alt,!0)}}};const ac=class extends Ul{static key="videoGallery";static className="";constructor(t,e){super(t),this.title=this.$.lang.videoGallery,this.icon="video_gallery",this.onSelectfunction=null;const s="string"==typeof e.thumbnail?e.thumbnail:this.$.icons.video_thumbnail;this.browser=new jr(this,this.$,{title:this.$.lang.videoGallery,data:e.data,url:e.url,headers:e.headers,searchUrl:e.searchUrl,searchHeaders:e.searchHeaders,selectorHandler:this.#Rp.bind(this),columnSize:4,className:"se-video-gallery",thumbnail:"function"==typeof e.thumbnail?e.thumbnail:()=>s,props:["frame"]}),this.width="auto"===this.$.plugins.video.pluginOptions.defaultWidth?"":this.$.plugins.video.pluginOptions.defaultWidth,this.height="auto"===this.$.plugins.video.pluginOptions.defaultHeight?"":this.$.plugins.video.pluginOptions.defaultHeight}open(t){this.onSelectfunction=t,this.browser.open()}close(){this.onSelectfunction=null,this.browser.close()}#Rp(t){if(this.onSelectfunction)this.onSelectfunction(t);else{let e=t.getAttribute("data-command");const s=this.$.plugins.video.findProcessUrl(e);s&&(e=s.url);const i={name:t.getAttribute("data-name"),size:0};this.$.plugins.video.modalInit(),this.$.plugins.video.create(this.$.plugins.video["iframe"===t.getAttribute("data-frame")?"createIframeTag":"createVideoTag"]({poster:t.getAttribute("data-thumbnail")}),e,null,this.width,this.height,!1,i,!0)}}};const hc=class extends Ul{static key="audioGallery";static className="";constructor(t,e){super(t),this.title=this.$.lang.audioGallery,this.icon="audio_gallery",this.onSelectfunction=null;const s="string"==typeof e.thumbnail?e.thumbnail:this.$.icons.audio_thumbnail;this.browser=new jr(this,this.$,{title:this.$.lang.audioGallery,data:e.data,url:e.url,headers:e.headers,searchUrl:e.searchUrl,searchHeaders:e.searchHeaders,selectorHandler:this.#Rp.bind(this),columnSize:4,className:"se-audio-gallery",thumbnail:"function"==typeof e.thumbnail?e.thumbnail:()=>s})}open(t){this.onSelectfunction=t,this.browser.open()}close(){this.onSelectfunction=null,this.browser.close()}#Rp(t){this.onSelectfunction?this.onSelectfunction(t):(this.$.plugins.audio.modalInit(),this.$.plugins.audio.submitURL(t.getAttribute("data-command")))}};const cc=class extends Ul{static key="fileGallery";static className="";constructor(t,e){super(t),this.title=this.$.lang.fileGallery,this.icon="file_gallery",this.onSelectfunction=null;const s="string"==typeof e.thumbnail?e.thumbnail:this.$.icons.file_thumbnail;this.browser=new jr(this,this.$,{title:this.$.lang.fileGallery,data:e.data,url:e.url,headers:e.headers,searchUrl:e.searchUrl,searchHeaders:e.searchHeaders,selectorHandler:this.#Rp.bind(this),columnSize:4,className:"se-file-gallery",thumbnail:"function"==typeof e.thumbnail?e.thumbnail:()=>s})}open(t){this.onSelectfunction=t,this.browser.open()}close(){this.onSelectfunction=null,this.browser.close()}#Rp(t){if(this.onSelectfunction)this.onSelectfunction(t);else{const e={name:t.getAttribute("data-name"),size:0};this.$.plugins.fileUpload.create(t.getAttribute("data-command"),e,!0)}}};const dc=class extends Ul{static key="fileBrowser";static className="";constructor(t,e){super(t),this.title=this.$.lang.fileBrowser,this.icon="file_browser",this.onSelectfunction=null;const s={video:this.$.icons.video_thumbnail,audio:this.$.icons.audio_thumbnail,file:this.$.icons.file_thumbnail},i=this.$.icons.file_thumbnail;this.browser=new jr(this,this.$,{title:this.$.lang.fileBrowser,data:e.data,url:e.url,headers:e.headers,searchUrl:e.searchUrl,searchHeaders:e.searchHeaders,selectorHandler:this.#Rp.bind(this),columnSize:4,className:"se-file-browser",thumbnail:"function"==typeof e.thumbnail?e.thumbnail:t=>s[t.type]||i,props:[...new Set((e.props??[]).concat(["frame"]))],expand:e.expand})}open(t){this.onSelectfunction=t,this.browser.open()}close(){this.onSelectfunction=null,this.browser.close()}#Rp(t){if(this.onSelectfunction)this.onSelectfunction(t);else{switch(t.getAttribute("data-type")){case"image":this.$.plugins.imageGallery.browser.selectorHandler(t);break;case"video":this.$.plugins.videoGallery.browser.selectorHandler(t);break;case"audio":this.$.plugins.audioGallery.browser.selectorHandler(t);break;case"file":this.$.plugins.fileGallery.browser.selectorHandler(t)}}}},uc={text:{default:"16px",list:[{title:"XX-Small",size:"8px"},{title:"X-Small",size:"10px"},{title:"Small",size:"13px"},{title:"Medium",size:"16px"},{title:"Large",size:"18px"},{title:"X-Large",size:"24px"},{title:"XX-Large",size:"32px"}]},px:{default:13,inc:1,min:8,max:72,list:[8,10,13,15,18,20,22,26,28,36,48,72]},pt:{default:10,inc:1,min:6,max:72,list:[6,8,10,12,14,18,22,26,32]},em:{default:1,inc:.1,min:.5,max:5,list:[.5,.75,1,1.25,1.5,1.75,2,2.5,3]},rem:{default:1,inc:.1,min:.5,max:5,list:[.5,.75,1,1.25,1.5,1.75,2,2.5,3]},vw:{inc:.1,min:.5,max:10,list:[2,3.5,4,4.5,6,8]},vh:{default:1.5,inc:.1,min:.5,max:10,list:[1,1.5,2,2.5,3,3.5,4]},"%":{default:100,inc:1,min:50,max:200,list:[50,70,90,100,120,140,160,180,200]}};class pc extends Yl{static key="fontSize";static className="se-btn-select se-btn-input se-btn-tool-font-size";#zp;constructor(t,e){super(t),this.unitMap={...uc,...e.unitMap||{}},this.sizeUnit=/text/.test(e.sizeUnit)?"":e.sizeUnit||this.$.options.get("fontSizeUnits")[0];const s=this.unitMap[this.sizeUnit||"text"],i=function({lang:t},e,s,i){const n=e.list,o=e.default,r=i?t.default:"";let l='\n\t<div class="se-list-inner">\n\t\t<ul class="se-list-basic">';for(let t,e,i,a,h,c=0,d=n.length;c<d;c++)t=n[c],"object"==typeof t?(e=t.title,i=t.size):e=i=t+s,a=o===i?" default_value":"",h=a&&r||e,l+=`\n\t\t\t<li>\n\t\t\t\t<button type="button" class="se-btn se-btn-list${a}" data-command="${i}" data-value="${e}" title="${h}" aria-label="${h}" style="font-size:${i};">${h}</button>\n\t\t\t</li>`;return l+="\n\t\t</ul>\n\t</div>",Pe.utils.createElement("DIV",{class:"se-dropdown se-list-layer se-list-font-size"},l)}(this.$,s,this.sizeUnit,e.showDefaultSizeLabel),n=!!this.sizeUnit&&(e.showIncDecControls??!1),o=!this.sizeUnit||(e.disableInput??!1);this.title=this.$.lang.fontSize,this.inner=!(o&&!n)&&(o?`<span class="se-txt se-not-arrow-text __se__font_size">${this.$.lang.fontSize}</span>`:`<input type="text" class="__se__font_size se-not-arrow-text" placeholder="${this.$.lang.fontSize}" />`),n?(this.beforeItem=Pe.utils.createElement("button",{class:"se-btn se-tooltip se-sub-btn",type:"button","data-command":pc.key,"data-type":"command","data-value":"dec"},`${this.$.icons.minus}<span class="se-tooltip-inner"><span class="se-tooltip-text">${this.$.lang.decrease}</span></span>`),this.afterItem=Pe.utils.createElement("button",{class:"se-btn se-tooltip se-sub-btn",type:"button","data-command":pc.key,"data-type":"command","data-value":"inc"},`${this.$.icons.plus}<span class="se-tooltip-inner"><span class="se-tooltip-text">${this.$.lang.increase}</span></span>`)):o?o&&!n&&(this.replaceButton=Pe.utils.createElement("button",{class:"se-btn se-tooltip se-btn-select se-btn-tool-font-size",type:"button","data-command":pc.key,"data-type":"dropdown"},`<span class="se-txt __se__font_size">${this.$.lang.fontSize}</span>${this.$.icons.arrow_down}<span class="se-tooltip-inner"><span class="se-tooltip-text">${this.$.lang.fontSize}</span></span>`),this.$.menu.initDropdownTarget({key:pc.key,type:"dropdown"},i)):(this.afterItem=Pe.utils.createElement("button",{class:"se-btn se-tooltip se-sub-arrow-btn",type:"button","data-command":pc.key,"data-type":"dropdown"},`${this.$.icons.arrow_down}<span class="se-tooltip-inner"><span class="se-tooltip-text">${this.$.lang.fontSize}</span></span>`),this.$.menu.initDropdownTarget({key:pc.key,type:"dropdown"},i)),this.currentSize="",this.sizeList=i.querySelectorAll("li button"),this.hasInputFocus=!1,this.isInputActive=!1,this.#zp=o,this.$.menu.initDropdownTarget(pc,i)}active(t,e){if(!Pe.utils.hasClass(e,"__se__font_size"))return!1;let s="";if(t){if(this.$.format.isLine(t))return;if(s=Pe.utils.getStyle(t,"fontSize"))return this.#Pp(e,s),!0}else this.#Pp(e,this.#Dp());return!1}toolbarInputKeyDown({target:t,event:e}){const s=e.code;if(this.#zp||Fe.isSpace(s))return void e.preventDefault();if(!/^(ArrowUp|ArrowDown|Enter)$/.test(s))return;const{value:i,unit:n}=this.#Fp(t);if(!i)return;const o=De.get(i),r=this.unitMap[n];let l=o;switch(s){case"ArrowUp":l+=r.inc,l>r.max&&(l=o);break;case"ArrowDown":l-=r.inc,l<r.min&&(l=o)}e.preventDefault();try{this.isInputActive=!0;const e=this.#Pp(t,l+n);if(this.#zp)return;const i=Pe.utils.createElement("SPAN",{style:"font-size: "+e+";"});this.$.inline.apply(i,{stylesToModify:["font-size"],nodesToRemove:null,strictRemove:null}),Fe.isEnter(s)||t.focus()}finally{this.isInputActive=!1}}toolbarInputChange({target:t,value:e,event:s}){if(!this.#zp)try{this.isInputActive=!0;let{value:s,unit:i}=this.#Fp(e);const{max:n,min:o}=this.unitMap[i];s=s>n?n:s<o?o:s;const r=Pe.utils.createElement("SPAN",{style:"font-size: "+this.#Pp(t,s+i)+";"});this.$.inline.apply(r,{stylesToModify:["font-size"],nodesToRemove:null,strictRemove:null})}finally{this.isInputActive=!1,s.preventDefault(),this.$.focusManager.focus()}}on(t){const{value:e,unit:s}=this.#Fp(t),i=e+s;if(i===this.currentSize)return;const n=this.sizeList;for(let t=0,e=n.length;t<e;t++)i===n[t].getAttribute("data-value")?Pe.utils.addClass(n[t],"active"):Pe.utils.removeClass(n[t],"active");this.currentSize=i}action(t){const e=t.getAttribute("data-command");if(e===pc.key){const{value:e,unit:s}=this.#Fp(t);let i=De.get(e)+("inc"===t.getAttribute("data-value")?1:-1);const{min:n,max:o}=this.unitMap[s];i=i<n?n:i>o?o:i;const r=Pe.utils.createElement("SPAN",{style:"font-size: "+i+s+";"});this.$.inline.apply(r,{stylesToModify:["font-size"],nodesToRemove:null,strictRemove:null})}else if(e){const t=Pe.utils.createElement("SPAN",{style:"font-size: "+e+";"});this.$.inline.apply(t,{stylesToModify:["font-size"],nodesToRemove:null,strictRemove:null})}else this.$.inline.apply(null,{stylesToModify:["font-size"],nodesToRemove:["span"],strictRemove:!0});this.$.menu.dropdownOff()}#Dp(){return this.$.frameContext.get("wwComputedStyle").fontSize}#Fp(t){if(!(t="string"==typeof t?t:t.parentElement.querySelector(".__se__font_size")))return{unit:this.sizeUnit,value:this.sizeUnit?0:""};const e="string"==typeof t?t:Pe.check.isInputElement(t)?t.value:t.textContent,s=this.sizeUnit?e.split(/(\d+)/):[e,""];let i=(s.pop()||"").trim().toLowerCase();i=this.$.options.get("fontSizeUnits").includes(i)?i:this.sizeUnit;const n=s.pop();return{unit:i,value:i?Number(n):n}}#Pp(t,e){return(t=t.parentElement.querySelector(".__se__font_size"))?Pe.check.isInputElement(t)?t.value=String(e):t.textContent=String(this.sizeUnit?e:this.unitMap.text.list.find((t=>t.size===e))?.title||e):0}}const gc=pc;const mc=class extends Yl{static key="pageNavigator";static className="se-btn-input se-btn-tool-pageNavigator";constructor(t){super(t),this.title=this.$.lang.pageNumber,this.inner=Pe.utils.createElement("input",{type:"number",class:"se-not-arrow-text",placeholder:"1",value:"1",min:"1"},null),this.afterItem=Pe.utils.createElement("span",{class:"se-btn se-sub-btn"},""),this.pageNum=1,this.totalPages=1,this.$.eventManager.addEvent(this.inner,"change",this.#Hp.bind(this))}display(t,e){this.pageNum=t,this.totalPages=e,this.inner.value=String(t),this.afterItem.textContent=this.inner.max=String(e)}#Hp(t){if(!this.$.frameContext.has("documentType_use_page"))return;const e=Pe.query.getEventTarget(t),s=Number(e.value)||1;this.$.frameContext.get("documentType").pageGo(s)}},{_w:fc}=Oe;class vc extends Zl{static key="anchor";static className="";static component(t){return Pe.check.isAnchor(t)&&t.hasAttribute("id")&&t.hasAttribute("data-se-anchor")?t:null}#zc=null;#qp=null;constructor(t){super(t),this.title=this.$.lang.anchor,this.icon="bookmark_anchor";const e=(new DOMParser).parseFromString(this.$.icons.bookmark_anchor,"image/svg+xml");this.bookmarkIcon=e.documentElement;const s=function({lang:t,icons:e}){const s=`\n\t<div class="se-arrow se-arrow-up"></div>\n\t<div class="link-content">\n\t\t<div class="se-controller-display"></div>\n\t\t<div class="se-btn-group">\n\t\t\t<button type="button" data-command="edit" tabindex="-1" class="se-btn se-tooltip">\n\t\t\t\t${e.edit}\n\t\t\t\t<span class="se-tooltip-inner">\n\t\t\t\t\t<span class="se-tooltip-text">${t.edit}</span>\n\t\t\t\t</span>\n\t\t\t</button>\n\t\t\t<button type="button" data-command="delete" tabindex="-1" class="se-btn se-tooltip">\n\t\t\t\t${e.delete}\n\t\t\t\t<span class="se-tooltip-inner">\n\t\t\t\t\t<span class="se-tooltip-text">${t.remove}</span>\n\t\t\t\t</span>\n\t\t\t</button>\n\t\t</div>\n\t</div>`;return Pe.utils.createElement("DIV",{class:"se-controller se-controller-link"},s)}(this.$);this.displayId=s.querySelector(".se-controller-display"),this.controllerSelect=new Ii(this,this.$,s,{position:"bottom",disabled:!0},vc.key);const i=function({lang:t,icons:e}){const s=`\n\t\t<div class="se-arrow se-arrow-up"></div>\n\t\t<form>\n\t\t\t<div class="se-controller-display">${t.id}</div>\n\t\t\t<div class="se-btn-group se-form-group">\n\t\t\t\t<input type="text" required />\n\t\t\t\t<button type="submit" data-command="submit" class="se-btn se-tooltip se-btn-success">\n\t\t\t\t\t${e.checked}\n\t\t\t\t\t<span class="se-tooltip-inner"><span class="se-tooltip-text">${t.save}</span></span>\n\t\t\t\t</button>\n\t\t\t\t<button type="button" data-command="cancel" class="se-btn se-tooltip se-btn-danger">\n\t\t\t\t\t${e.cancel}\n\t\t\t\t\t<span class="se-tooltip-inner"><span class="se-tooltip-text">${t.cancel}</span></span>\n\t\t\t\t</button>\n\t\t\t</div>\n\t\t</form>\n\t\t`;return Pe.utils.createElement("DIV",{class:"se-controller se-controller-simple-input"},s)}(this.$);this.inputEl=i.querySelector("input"),this.controller=new Ii(this,this.$,i,{position:"bottom",disabled:!0,parents:[this.controllerSelect.form],parentsHide:!0},vc.key)}show(){this.controller.open(this.#qp=this.$.selection.getRange()),fc.setTimeout((()=>{this.inputEl.focus()}),0)}componentSelect(t){this.#zc=t,this.displayId.textContent=t.getAttribute("id"),this.controllerSelect.open(t)}componentDeselect(){this.#Ts()}controllerAction(t){const e=t.getAttribute("data-command");if(!e)return;const s=this.#zc;switch(e){case"submit":if(this.controller.close(),s)s.id=this.inputEl.value,this.$.component.select(s,vc.key);else{const t=this.inputEl.value.trim();if(!t)return void this.inputEl.focus();const e=Pe.utils.createElement("A",{id:t,"data-se-anchor":this.inputEl.value,"data-se-non-link":"true",contenteditable:"false",class:"se-component se-inline-component"});this.$.component.insert(e,{insertBehavior:"none",scrollTo:!1});const s=this.$.selection.getNearRange(e);s?this.$.selection.setRange(s.container,s.offset,s.container,s.offset):this.$.component.select(e,vc.key),this.#Ts()}break;case"cancel":this.controller.close(!s),this.#qp&&this.$.selection.setRange(this.#qp),this.#Ts(),s&&this.componentSelect(s);break;case"edit":this.inputEl.value=this.displayId.textContent,this.controllerSelect.hide(),this.controller.open(s),this.inputEl.focus();break;case"delete":{const t=this.$.selection.getNearRange(s);Pe.utils.removeItem(s),this.controllerSelect.close(!0),t&&this.$.selection.setRange(t.container,t.offset,t.container,t.offset),this.#Ts();break}}}#Ts(){this.#zc=null,this.#qp=null,this.inputEl.value="",this.displayId.textContent=""}}const bc={blockquote:Jl,codeBlock:ea,exportPDF:na,fileUpload:la,list_bulleted:ha,list_numbered:ua,autocomplete:fa,slashCommand:ba,align:wa,font:_a,fontColor:xa,backgroundColor:Sa,list:Na,table:fh,blockStyle:bh,hr:Ta,layout:wh,lineHeight:_h,template:xh,paragraphStyle:Sh,textStyle:Th,link:Mh,image:Ph,video:Vh,audio:Yh,embed:Qh,math:nc,drawing:rc,imageGallery:lc,videoGallery:ac,audioGallery:hc,fileGallery:cc,fileBrowser:dc,fontSize:gc,pageNavigator:mc,anchor:vc};class yc{async modalAction(){return!0}modalOn(t){}modalInit(){}modalOff(t){}modalResize(){}}class wc{controllerAction(t){}controllerOn(t,e){}controllerClose(){}}class Cc{browserInit(){}}class _c{colorPickerAction(t){}colorPickerHueSliderOpen(){}colorPickerHueSliderClose(){}}class kc{hueSliderAction(){}hueSliderCancelAction(){}}class xc{componentSelect(t){}componentDeselect(t){}componentEdit(t){}async componentDestroy(t){}componentCopy(t){}}const $c={contract:t,manager:e,ui:i};Object.defineProperty(window,"SUNEDITOR",{enumerable:!0,writable:!1,configurable:!1,value:{...ql,plugins:bc,modules:$c,helper:Ve,interfaces:n}})})()})();
|