UNPKG

suneditor

Version:

Vanilla JavaScript based WYSIWYG web editor

1 lines 814 kB
(()=>{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:()=>Il,ColorPicker:()=>_r,Controller:()=>Ti,Figure:()=>Fi,HueSlider:()=>yr,Modal:()=>kr});var e={};s.r(e),s.d(e,{ApiManager:()=>Al,FileManager:()=>Er});var i={};s.r(i),s.d(i,{CommandMenu:()=>hn,ModalAnchorEditor:()=>Hr,SelectMenu:()=>Hi,_DragHandle:()=>yi});var n={};s.r(n),s.d(n,{EditorComponent:()=>uc,ModuleBrowser:()=>hc,ModuleColorPicker:()=>cc,ModuleController:()=>ac,ModuleHueSlider:()=>dc,ModuleModal:()=>rc,PluginBrowser:()=>Ar,PluginCommand:()=>Br,PluginDropdown:()=>Ir,PluginDropdownFree:()=>Vr,PluginField:()=>Or,PluginInput:()=>Rr,PluginModal:()=>Pr,PluginPopup:()=>zr});const o=window,l=document,r=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,C=h.includes("android"),w=p?"⌘":"CTRL",_=p?"⇧":"+SHIFT",x=o.devicePixelRatio;let $=null;const k={_w:o,_d:l,NO_EVENT:r,ON_OVER_COMPONENT:a,getXMLHttpRequest:function(){return new XMLHttpRequest},getPageStyle:function(t){let e="";const s=(t||l).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 r="(?:";for(let e=0,s=t.length;e<s;e++)r+=t[e]+(e<s-1?"|":")");const a=new RegExp(`(^|.*[\\/])${r}(\\.[^\\/]+)?.${e}(?:\\?.*|;.*)?$`,"i"),h=new RegExp(`.+\\.${e}(?:\\?.*|;.*)?$`,"i");for(let t=l.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:C,isMobile:b,isTouchDevice:y,canUseBeforeInput:function(){if(null!==$)return $;if(!l.body||"function"!=typeof l.execCommand)return!0;let t=!1;try{const e=l.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=l.activeElement;l.body.appendChild(e);const i=()=>{t=!0};e.addEventListener("beforeinput",i,!0),e.addEventListener("input",i,!0),e.focus({preventScroll:!0}),l.execCommand("insertText",!1,"​"),e.removeEventListener("beforeinput",i,!0),e.removeEventListener("input",i,!0),e.remove(),s&&s!==l.body&&"function"==typeof s.focus&&s.focus({preventScroll:!0})}catch{t=!0}return $=t},cmdIcon:w,shiftIcon:_,DPI:x,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 H={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 L(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 N={is:function(t){return/^-?\d+(\.\d+)?$/.test(t+"")},get:L,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)}},A=/&|\u00A0|'|"|<|>/g,B=/&amp;|&nbsp;|&apos;|&quot;|&lt;|&gt;/g,I={"&":"&amp;"," ":"&nbsp;","'":"&apos;",'"':"&quot;","<":"&lt;",">":"&gt;"},V={"&amp;":"&","&nbsp;":" ","&apos;":"'","&quot;":'"',"&lt;":"<","&gt;":">"},O=/[A-Z]/g,R=/-[a-zA-Z]/g,P={"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 z(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=z(s);t&&e.children.push(t)}return e}return null}function D(t){return t.replace(A,(t=>I[t]||t))}function F(t){return/^#[0-9a-f]{3}(?:[0-9a-f]{3})?$/i.test(t)}const q={htmlToJson:function(t){return z((new DOMParser).parseFromString(t,"text/html").body)},jsonToHtml:function t(e){if(!e)return"";if("text"===e.type)return D(e.content||"");if("element"===e.type){const{tag:s,attributes:i={},children:n=[]}=e,o=Object.entries(i).map((([t,e])=>`${t}="${D(e)}"`)).join(" "),l=`</${s}>`;return`${o?`<${s} ${o}>`:`<${s}>`}${n.map(t).join("")}${l}`}return""},htmlToEntity:D,entityToHTML:function(t){return t.replace(B,(t=>V[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(O,(t=>"-"+t.toLowerCase())):e.map((function(e){return t(e)}))},kebabToCamelCase:function t(e){return"string"==typeof e?e.replace(R,(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]):P[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:F,rgb2hex:function(t){if(F(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=L(i.paddingLeft,-1),l=L(i.paddingRight,-1),r=s.offsetWidth-s.clientWidth,a=s.offsetWidth-n-l-r;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=l.createDocumentFragment();let n=0;return s.replace(e,((t,e)=>{e>n&&i.appendChild(l.createTextNode(s.slice(n,e)));const o=l.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(l.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=l.createElement(t[e].tag);i.push(s)}})),i.length>0){const t=l.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 l=(e=s+e).split(";");for(let e,s=0,r=l.length;s<r;s++)e=l[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=l.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>":""}},W=q,U=/(\s|^)(katex|MathJax|se-exclude-format)(\s|$)/;function Z(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 j(t){return/^(OL|UL)$/i.test("string"==typeof t?t:t?.nodeName)}function K(t){return/^TABLE$/i.test("string"==typeof t?t:t?.nodeName)}function Y(t){return/^(TD|TH)$/i.test("string"==typeof t?t:t?.nodeName)}function X(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:Z,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:j,isListCell:function(t){return/^LI$/i.test("string"==typeof t?t:t?.nodeName)},isTable:K,isTableElements:function(t){return/^(TABLE|THEAD|TBODY|TR|TH|TD|COL)$/i.test("string"==typeof t?t:t?.nodeName)},isTableCell:Y,isTableRow:function(t){return/^TR$/i.test("string"==typeof t?t:t?.nodeName)},isBreak:X,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||X(e.firstElementChild))&&Z(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 l=0;for(let t=0,e=n.length;t<e;t++)n[n[t]]===o[n[t]]&&l++;const r=s.classList,a=i.classList;let h=0;for(let t=0,e=r.length;t<e;t++)a.contains(r[t])&&h++;return l===o.length&&l===n.length&&h===a.length&&h===r.length},isExcludeFormat:function(t){return U.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=l.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 lt(t){return l.createTextNode(t||"")}function rt(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=l){return{w:t.documentElement.clientWidth,h:t.documentElement.clientHeight}}const gt={clone:function(t,e=!1){return t.cloneNode(e)},createElement:ot,createTextNode:lt,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+'="'+D(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:rt,nextIndex:function(t,e){const s=rt(t,e);return-1===s?-1:s+1},prevIndex:function(t,e){const s=rt(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=l.createElement("DIV");if(n.style.display="none",/body/i.test(i.nodeName)){const t=l.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),l.body.appendChild(n);const r=Array.from(i.querySelectorAll("*")),a=e?[i].concat(r):r;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 l.body.removeChild(n),i},waitForMediaLoad:function(t,e=5e3){const s=t||l;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 l.documentElement.style.getPropertyValue(t)},setRootCssVar:function(t,e){l.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 Ct(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 l=n.childNodes;for(let e=0,s=l.length;e<s;e++)t(l[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 Ct(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 wt={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,l){if(!(l>s)&&(l>0&&n!==o&&e(o)&&i.push(o),l!==s&&o.children))for(let e=0,s=o.children.length;e<s;e++)t(o.children[e],l+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 l=s.parentNode.childNodes,r=gt.getArrayIndex(l,s),a=gt.getArrayIndex(l,i);return{ancestor:s.parentElement,a:s,b:i,result:r>a?1:r<a?-1:0}},getParentElement:Ct,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(l){if(!o&&8!==l.nodeType&&!i(l))if(3===l.nodeType){if(l===e)return n+=s,void(o=!0);n+=l.textContent.length}else if(1===l.nodeType){const e=l.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,l=o.rowSpan||1,r=o.colSpan||1;e[t]||=[];let a=0;const h=e[t];for(;h[a];)a++;for(let t=0;t<r;t++)h[a+t]=!0;for(let s=1;s<l;s++){const i=t+s;e[i]||=[];for(let t=0;t<r;t++)e[i][a+t]=!0}const c=t+l-1,d=a+r-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:l}=t;[i,n,l].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:wt,check:it,utils:gt},xt="ArrowLeft|ArrowUp|ArrowRight|ArrowDown",$t="F1|F2|F3|F4|F5|F6|F7|F8|F9|F10|F11|F12",kt=xt.split("|"),St="Backspace|Delete".split("|"),Et=`Backspace|Tab|Enter|ShiftLeft|ShiftRight|ControlLeft|ControlRight|AltLeft|AltRight|Pause|CapsLock|Escape|PageUp|PageDown|End|Home|${xt}|Insert|Delete|${$t}|NumLock|ScrollLock`.split("|"),Tt="Backspace|Enter|Delete".split("|"),Mt="Backspace|Enter|Delete".split("|"),Ht=`ControlLeft|ControlRight|AltLeft|AltRight|Pause|CapsLock|Escape|Insert|${$t}|NumLock|ScrollLock`.split("|");const Lt={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)}}}},Nt=/^(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/i,At=/^[\u200B\uFEFF]+$/;function Bt(t){const e=t.trim();return""===e||At.test(e)}const It={strong:"**",b:"**",em:"*",i:"*",del:"~~",s:"~~",mark:"=="};function Vt(t){if(!t||0===t.length)return"";const e=[];for(let s=0;s<t.length;s++){const i=Ft(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 Ot(t){return t?"text"===t.type?t.content||"":t.children?t.children.map(Ot).join(""):"":""}function Rt(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(Nt.test(e))return o;return`${o}${i.map(Rt).join("")}</${e}>`}function Pt(t,e){return t?t.split("\n").map((t=>t?e+t:"")).join("\n")+"\n":""}function zt(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}. `:"- ",l=t.children||[];let r="",a="";const h=e+" ".repeat(i.length);let c="";const d=l[0];d&&"element"===d.type&&"input"===d.tag&&"checkbox"===d.attributes?.type&&(c=void 0!==d.attributes.checked?"[x] ":"[ ] ");for(let t=0;t<l.length;t++){const e=l[t];if(0===t&&c)continue;if("element"!==e.type){r+=Ft(e,"",!1);continue}const s=e.tag;if("ul"===s||"ol"===s)a+=zt(e,h,"ol"===s);else if("table"===s)a+=Pt(Dt(e),h);else if("figure"===s){const t=(e.children||[]).find((t=>"element"===t.type&&"table"===t.tag));a+=Pt(t?Dt(t):Ft(e,"",!0),h)}else"blockquote"===s||"pre"===s?a+=Pt(Ft(e,"",!0),h):r+=Ft(e,"",!1)}n+=`${e}${i}${c}${r.trim()}\n`,a&&(n+=a),o++}return n}function Dt(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=Vt(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 l=0;for(const t of o){let e=0;for(const s of t.cells)e+=s.colspan;e>l&&(l=e)}const r=Array.from({length:o.length},(()=>new Array(l).fill(null)));for(let t=0;t<o.length;t++){let e=0;for(const s of o[t].cells){for(;e<l&&null!==r[t][e];)e++;if(e>=l)break;for(let i=0;i<s.rowspan&&t+i<o.length;i++)for(let n=0;n<s.colspan&&e+n<l;n++)r[t+i][e+n]=0===i&&0===n?s.content:"";e+=s.colspan}for(let e=0;e<l;e++)null===r[t][e]&&(r[t][e]="")}let a="";if(i.length>0){a+="| "+r[0].join(" | ")+" |\n",a+="| "+r[0].map((()=>"---")).join(" | ")+" |\n";for(let t=1;t<r.length;t++)a+="| "+r[t].join(" | ")+" |\n"}else{a+="| "+new Array(l).fill(" ").join(" | ")+" |\n",a+="| "+new Array(l).fill("---").join(" | ")+" |\n";for(let t=0;t<r.length;t++)a+="| "+r[t].join(" | ")+" |\n"}return a}function Ft(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=>Ft(t,"",!0))).join("");const l=/^h([1-6])$/.exec(i);if(l){const t=Vt(o).trim();if(!t)return"\n";const e=parseInt(l[1],10);return`${"#".repeat(e)} ${t}\n\n`}if("p"===i){const t=Vt(o);return t.trim()?`${t.trim()}\n\n`:"\n"}if("br"===i)return"\n";if("hr"===i)return"---\n\n";const r=It[i];if(r){return`${r}${Vt(o)}${r}`}if("code"===i){const t=Ot({children:o});return t.includes("`")?"`` "+t+" ``":"`"+t+"`"}if("kbd"===i){return`<kbd>${Ot({children:o})}</kbd>`}if("sub"===i){return`<sub>${Vt(o)}</sub>`}if("sup"===i){return`<sup>${Vt(o)}</sup>`}if("a"===i){const t=n.href||"",e=Vt(o),s=n.title;return s?`[${e}](${t} "${s}")`:`[${e}](${t})`}if("img"===i){const t=n.src||"";return`![${n.alt||""}](${t})`}if("blockquote"===i){return o.map((t=>Ft(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=Ot(i)):(e=(t.attributes?.class||"").match(/language-(\S+)/)?.[1]||"",s=Ot({children:o})),"```"+e+"\n"+s+"\n```\n\n"}if("details"===i)return Rt(t)+"\n\n";if("summary"===i)return Rt(t);if("ul"===i)return zt(t,e,!1)+"\n";if("ol"===i)return zt(t,e,!0)+"\n";if("table"===i)return Dt(t)+"\n";if("dl"===i){let t="";for(const e of o)"element"===e.type&&("dt"===e.tag?t+=Vt(e.children).trim()+"\n":"dd"===e.tag&&(t+=": "+Vt(e.children).trim()+"\n"));return t+"\n"}if("dt"===i||"dd"===i)return Vt(o).trim();if("div"===i){if(n.class&&/se-component/.test(n.class))return o.map((t=>Ft(t,e,!0))).join("");const t=Vt(o);return s?t+"\n\n":t}if("span"===i)return n.style||n.class?Rt(t):Vt(o);if("figure"===i){const t=o.map((t=>Ft(t,e,!0))).join("");return/\n$/.test(t)?t:t+"\n\n"}if("figcaption"===i){const t=Vt(o).trim();return t?t+"\n\n":""}return"video"===i||"audio"===i||"iframe"===i?Rt(t)+"\n\n":Rt(t)}function qt(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 Wt(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,l=s.every((t=>""===t));let r="<table>";const a=t=>{const e=i[t];return e?` style="text-align: ${e};"`:""};if(!l){r+="<thead><tr>";for(let t=0;t<o;t++)r+=`<th${a(t)}>${qt(s[t])}</th>`;r+="</tr></thead>"}if(n.length>0||l){r+="<tbody>";for(const t of n){r+="<tr>";for(let e=0;e<o;e++)r+=`<td${a(e)}>${qt(t[e]||"")}</td>`;r+="</tr>"}r+="</tbody>"}return r+="</table>",r}function Ut(t,e,s){const i=s?"ol":"ul",n=s?/^(\s*)\d+\.\s+(.*)/:/^(\s*)([-*+])\s+(.*)/;let o=`<${i}>`,l=e;const r=(t[l].match(/^(\s*)/)[1]||"").length;for(;l<t.length;){const e=t[l];if(Bt(e)){l++;continue}const i=(e.match(/^(\s*)/)[1]||"").length;if(i<r)break;if(i!==r)break;{if(!n.exec(e))break;const i=s?e.replace(/^\s*\d+\.\s+/,""):e.replace(/^\s*[-*+]\s+/,"");l++;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(;l<t.length;){const e=t[l];if(Bt(e)){l++;continue}if((e.match(/^(\s*)/)[1]||"").length<=r)break;if(/^\s*[-*+]\s+/.test(e)||/^\s*\d+\.\s+/.test(e)){const s=Ut(t,l,/^\s*\d+\.\s+/.test(e));u+=s.html,l=s.index;continue}const s=e.trimStart();if(!(/^\|.*\|/.test(s)&&l+1<t.length&&/^\s*\|[\s:]*-{3,}/.test(t[l+1])))break;{const e=[];for(;l<t.length;){const s=t[l];if(Bt(s)||(s.match(/^(\s*)/)[1]||"").length<=r)break;if(!/^\s*\|/.test(s))break;e.push(s.trimStart()),l++}u+=Wt(e)}}if(a){o+=`<li class="task-list-item">${h?'<input type="checkbox" checked disabled> ':'<input type="checkbox" disabled> '}${qt(c)}${u}</li>`}else o+=`<li>${qt(i)}${u}</li>`}}return o+=`</${i}>`,{html:o,index:l}}const Zt={jsonToMarkdown:function(t){return t?Ft(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(Bt(e)){o++;continue}const r=/^(`{3,}|~{3,})(\w*)/.exec(e);if(r){const t=r[1].charAt(0),e=r[1].length,s=r[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}>${l=a.join("\n"),l.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}</code></pre>`);continue}const a=/^(#{1,6})\s+(.+)/.exec(e);if(a){const t=a[1].length;n.push(`<h${t}>${qt(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 l=t(e.join("\n"),s);n.push(`<blockquote>${l}</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(Wt(t));continue}if(/^(\s*)([-*+])\s+/.test(e)){const t=Ut(i,o,!1);n.push(t.html),o=t.index;continue}if(/^(\s*)\d+\.\s+/.test(e)){const t=Ut(i,o,!0);n.push(t.html),o=t.index;continue}if(/^\s*<[a-zA-Z]/.test(e)){let t=e;if(o++,Nt.test(e.match(/<(\w+)/)?.[1]||"")){n.push(t);continue}for(;o<i.length&&!Bt(i[o]);)t+="\n"+i[o],o++;n.push(t);continue}const h=[];for(;o<i.length&&!Bt(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=qt(h.join("\n"));n.push(`<${s}>${t}</${s}>`)}else n.push(`<${s}>${qt(i[o])}</${s}>`),o++}var l;return n.join("")}},Gt=/<!--\[if[^>]*>[\s\S]*?<!\[endif\]-->/gi,jt=/<\/?(?:\w+:)\w+[^>]*>/gi,Kt=/<xml>[\s\S]*?<\/xml>/gi,Yt=/<style[^>]*>[\s\S]*?<\/style>/gi,Xt=/\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,le=/<span\s+style\s*=\s*["'][^"']*mso-tab-count:\s*\d+[^"']*["']\s*>[^<]*<\/span>/gi,re=/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,Ce=/page-break-before\s*:\s*always/i,we=/mso-break-type\s*:\s*section-break/i,_e=/mso-column-break-before\s*:\s*always/i,xe=/^(?:Word)?Section\d+$/i;function $e(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 ke(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(Xt,"").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=Le(s.el);s.type=$e(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:l,startAt:r}=e;ke(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=He(t.ownerDocument,i,l,r),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=He(t.ownerDocument,i,l,r);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 He(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 Le(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 Ne={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}`,l=he.exec(i),r=ce.exec(i),a=de.exec(i);let h="ol",c="";if(l){const t=l[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:r?parseInt(r[1],10):1})}return e}(t);let s=t;s=s.replace(Yt,""),s=s.replace(Kt,""),s=s.replace(Gt,""),s=s.replace(jt,""),s=s.replace(/<!--(?:Start|End)Fragment-->/gi,""),s=s.replace(/<(?:meta|link)[^>]*>/gi,""),s=s.replace(oe," "),s=s.replace(le," "),s=s.replace(/(&nbsp;){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 l=t.body.querySelectorAll('a[name^="_msocom"], a[name^="_msoanchor"]');for(const t of l)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=re.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.getAtt