@livingdocs/editable.js 5.1.12 → 5.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/editable.js CHANGED
@@ -1,2 +1,2 @@
1
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Editable=e():t.Editable=e()}(self,()=>(()=>{"use strict";const t={d:(e,n)=>{for(var r in n)t.o(n,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})}};t.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),t.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),t.r=t=>{Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};let e={};t.d(e,{Editable:()=>So});var n={};t.r(n),t.d(n,{getHost:()=>L,getNodeIndex:()=>P,isBeginningOfHost:()=>W,isDocumentFragmentWithoutChildren:()=>Y,isEndOfHost:()=>q,isEndOffset:()=>$,isInlineElement:()=>J,isLinebreak:()=>H,isSameNode:()=>Q,isStartOffset:()=>U,isTextEndOfHost:()=>z,isTextEndOffset:()=>K,isVoid:()=>M,isVoidTextNode:()=>F,isWhitespaceOnly:()=>D,lastChild:()=>X,lastOffsetWithContent:()=>V,latestChild:()=>G});var r={};t.r(r),t.d(r,{adoptElement:()=>Ct,areSameAttributes:()=>_t,cleanInternals:()=>bt,cloneRangeContents:()=>At,containsString:()=>Yt,createFragmentFromString:()=>kt,deleteCharacter:()=>Gt,expandTo:()=>Ft,extractContent:()=>St,forceWrap:()=>Vt,getAncestorTags:()=>Ot,getContainedTags:()=>Bt,getInnerHtmlOfFragment:()=>wt,getInnerTags:()=>Rt,getTagNames:()=>It,getTags:()=>xt,getTagsByName:()=>Nt,getTagsByNameAndAttributes:()=>jt,insertCharacter:()=>Qt,isAffectedBy:()=>Lt,isExactSelection:()=>Mt,isWrappable:()=>Ht,normalizeTags:()=>yt,normalizeWhitespace:()=>mt,nuke:()=>zt,nukeElem:()=>Kt,nukeTag:()=>Jt,removeFormatting:()=>$t,removeFormattingElem:()=>Ut,selectNodeContents:()=>Pt,surround:()=>Xt,tidyHtml:()=>gt,toggleTag:()=>Dt,unwrap:()=>qt,unwrapInternalNodes:()=>Tt,wrap:()=>Wt});const i={log:!1,logErrors:!0,editableClass:"js-editable",editableDisabledClass:"js-editable-disabled",pastingAttribute:"data-editable-is-pasting",trimLeadingAndTrailingWhitespaces:!0,boldMarkup:{type:"tag",name:"strong",attribs:{},trim:!0},italicMarkup:{type:"tag",name:"em",attribs:{},trim:!0},underlineMarkup:{type:"tag",name:"u",attribs:{},trim:!1},linkMarkup:{type:"tag",name:"a",attribs:{},trim:!0},pastedHtmlRules:{allowedElements:{a:{href:!0,rel:!0,target:!0},strong:{},em:{},br:{}},allowedPlainTextElements:{br:{}},requiredAttributes:{a:["href"]},transformElements:{b:"strong",i:"em"},splitIntoBlocks:["h1","h2","h3","h4","h5","h6","p","blockquote"],blockLevelElements:["h1","h2","h3","h4","h5","h6","div","p","pre","hr","blockquote","article","figure","header","footer","ul","ol","li","section","table","video"],blacklistedElements:["style","script"],keepInternalRelativeLinks:!1,replaceQuotes:{}}};function o(){if(!1!==i.logErrors){var e=1===arguments.length?arguments[0]:Array.from(arguments);if(t.g.console)return"function"==typeof console.error?console.error(e):void console.log(e)}}var a=Object.prototype.toString,s={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function u(t){return t.replace(/\s+$/,"")}function c(t){return t.replace(/^\s+|\s+$/g,"")}function l(t){return"[object String]"===a.call(t)}var f=1,h=3,d=11;function v(t){return v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},v(t)}function p(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,g(r.key),r)}}function g(t){var e=function(t){if("object"!=v(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=v(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==v(e)?e:e+""}var y=function(){return t=function t(e,n){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.current=this.previous=this.nextNode=this.root=e,this.iteratorFunc=this[n||"getNext"]},(e=[{key:Symbol.iterator,value:function(){return this}},{key:"getNextTextNode",value:function(){for(var t;t=this.getNext();)if(t.nodeType===h&&""!==t.data)return t}},{key:"getPreviousTextNode",value:function(){for(var t;t=this.getPrevious();)if(t.nodeType===h&&""!==t.data)return t}},{key:"next",value:function(){var t=this.iteratorFunc();return t?{value:t}:{done:!0}}},{key:"getNext",value:function(){var t=this.current=this.nextNode,e=this.nextNode=void 0;if(this.current)if((e=t.firstChild)&&"remove"!==t.getAttribute("data-editable"))this.nextNode=e;else for(;t!==this.root&&!(this.nextNode=t.nextSibling);)t=t.parentNode;return this.current}},{key:"getPrevious",value:function(){var t=this.current=this.previous,e=this.previous=void 0;if(this.current)if((e=t.lastChild)&&"remove"!==t.getAttribute("data-editable"))this.previous=e;else for(;t!==this.root&&!(this.previous=t.previousSibling);)t=t.parentNode;return this.current}},{key:"replaceCurrent",value:function(t){this.current=t,this.nextNode=void 0,this.previous=void 0;for(var e=this.current;e!==this.root&&!(this.nextNode=e.nextSibling);)e=e.parentNode}}])&&p(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}(),m=function(t,e){return"string"==typeof t?Array.from(e.querySelectorAll(t)):t.tagName?[t]:Array.isArray(t)?t:Array.from(t)},b=function(t,e){return"string"==typeof t?e.querySelector(t):t.tagName?t:t[0]?t[0]:t},S=function(t){var e=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:window).document.createElement("div");return e.innerHTML=t,e.firstElementChild},w=function(t,e){if(t.closest||(t=t.parentNode),t&&t.closest)return t.closest(e)},k=function(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:window).document.createRange()},C=function(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:window).document.getSelection()},A=function(t,e,n){for(var r,i=[],o=(arguments.length>3&&void 0!==arguments[3]?arguments[3]:window).document.createNodeIterator(t.commonAncestorContainer,NodeFilter.SHOW_ALL,{acceptNode:function(r){return t.intersectsNode(r)&&e.includes(r.nodeType)&&r!==t.commonAncestorContainer?"function"==typeof n?n(r)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}},!1);r=o.nextNode();)i.push(r);return i},E=function(t){t.startContainer.compareDocumentPosition(t.endContainer)===Node.DOCUMENT_POSITION_FOLLOWING&&t.setStartBefore(t.endContainer),t.endContainer.compareDocumentPosition(t.startContainer)===Node.DOCUMENT_POSITION_PRECEDING&&t.setEndAfter(t.startContainer)},T=function(t,e){var n=document.createRange();n.selectNodeContents(e);var r=t.compareBoundaryPoints(Range.START_TO_START,n),i=t.compareBoundaryPoints(Range.END_TO_END,n);return r<=0&&i>=0},x=function(t){return t&&(t.nodeType===Node.TEXT_NODE||t.nodeType===Node.COMMENT_NODE)},O=function(t,e){return t.splitText(e)},N=function(t){var e=t.startContainer,n=t.startOffset,r=t.endContainer,i=t.endOffset;if(x(r)&&i>0&&i<r.length&&O(r,i),x(e)&&n>0&&n<e.length){var o=O(e,n);t.setStart(o,0)}},j=function(t,e){var n=t.cloneRange();n.setStart(e,0),n.setEnd(t.startContainer,t.startOffset);var r=t.toString().replace(/\uFEFF/g,""),i=n.toString().length;return{start:i,end:i+r.length,text:r}},_=function(t,e){return t.startContainer===e.startContainer&&t.startOffset===e.startOffset&&t.endContainer===e.endContainer&&t.endOffset===e.endOffset};function R(t){var e=t.root,n=t.startContainer,r=t.startOffset,i=t.whitespacesOnTheLeft;if(n.nodeType!==h)return R({root:e,startContainer:n.childNodes[r],startOffset:0,whitespacesOnTheLeft:i});var o=r+i;if(n.length>o)return[n,o];var a=new y(e);a.nextNode=n,a.getNextTextNode();var s=a.getNextTextNode();if(!s){var u=a.getPreviousTextNode();return[u,u.length]}return R({root:e,startContainer:s,startOffset:0,whitespacesOnTheLeft:o-n.length})}function B(t){var e=t.root,n=t.endContainer,r=t.endOffset,i=t.whitespacesOnTheRight;if(n.nodeType!==h){var o=!n.childNodes[r-1],a=o?n.childNodes[r]:n.childNodes[r-1],s=0;return o||(s=a.nodeType===h?a.length:a.childNodes.length),B({root:e,endContainer:a,endOffset:s,whitespacesOnTheRight:i})}var u=r-i;if(u>0)return[n,u];var c=new y(e);c.previous=n,c.getPreviousTextNode();var l=c.getPreviousTextNode();return l?B({root:e,endContainer:l,endOffset:l.length,whitespacesOnTheRight:i-r}):[c.getNextTextNode(),0]}function I(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function L(t){return t=t.jquery?t[0]:t,w(t,".".concat(i.editableClass))}function P(t){for(var e=0;null!==(t=t.previousSibling);)e++;return e}function M(t){var e,n=function(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return I(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?I(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}(t.childNodes);try{for(n.s();!(e=n.n()).done;){var r=e.value;if(r.nodeType===h&&!F(r))return!1;if(r.nodeType===f)return!1}}catch(t){n.e(t)}finally{n.f()}return!0}function F(t){return t.nodeType===h&&!t.nodeValue}function D(t){return t.nodeType===h&&0===V(t)}function H(t){return t.nodeType===f&&"BR"===t.tagName}function V(t){if(t.nodeType===h)return u(t.nodeValue).length;var e=0;return Array.from(t.childNodes).reverse().every(function(t,n,r){return!(!D(t)&&!H(t)&&(e=r.length-n,1))}),e}function W(t,e,n){if(e===t)return U(e,n);if(U(e,n)){var r=P(e);return W(t,e.parentNode,r)}return!1}function q(t,e,n){if(e===t)return $(e,n);if($(e,n)){var r=P(e)+1;return q(t,e.parentNode,r)}return!1}function U(t,e){return t.nodeType===h?0===e:0===t.childNodes.length||1===t.childNodes.length&&t.firstChild.nodeType===f&&"remove"===t.firstChild.getAttribute("data-editable")||t.childNodes[e]===t.firstChild}function $(t,e){return t.nodeType===h?e===t.length:0===t.childNodes.length||e>0&&t.childNodes[e-1]===t.lastChild}function z(t,e,n){if(e===t)return K(e,n);if(K(e,n)){var r=P(e)+1;return z(t,e.parentNode,r)}return!1}function K(t,e){return t.nodeType===h?e>=u(t.nodeValue).length:0===t.childNodes.length||e>=V(t)}function Q(t,e){var n,r,i;if(t.nodeType!==e.nodeType)return!1;if(t.nodeName!==e.nodeName)return!1;for(n=0,r=t.attributes.length;n<r;n++)if(i=t.attributes[n],e.getAttribute(i.name)!==i.value)return!1;return!0}function X(t){return t.lastChild?X(t.lastChild):t}function G(t){return console.warn("Editable.js: Using obsolete function parser.latestCild(), use lastChild() instead"),X(t)}function Y(t){return t&&t.nodeType===d&&0===t.childNodes.length}function J(t,e){switch((e.currentStyle||t.getComputedStyle(e,"")).display){case"inline":case"inline-block":return!0;default:return!1}}var Z=0,tt="\ufeff";function et(t,e){var n=t.commonAncestorContainer;if(3===n.nodeType)return!1;var r=e.parentElement;return(null==r?void 0:r.parentElement)===n}function nt(t,e){var n=t.commonAncestorContainer;n.ownerDocument||o("Cannot save range: range is empty");var r=n.ownerDocument.defaultView.document,i=r.createElement("span");i.id="editable-range-boundary-".concat(++Z),i.setAttribute("data-editable","remove"),i.style.lineHeight="0",i.style.display="none",i.appendChild(r.createTextNode(tt));var a=e&&et(t,t.startContainer),s=!e&&et(t,t.endContainer);if(a){var u=t.startContainer.parentElement;u.parentElement.insertBefore(i,u)}else if(s){var c=t.endContainer.parentElement;c.parentElement.insertBefore(i,c.nextSibling)}else{var l=t.cloneRange();l.collapse(e),l.insertNode(i)}return i}function rt(t,e,n,r){var i=at(t,n);if(!i)return console.log("Marker element has been removed. Cannot restore selection.");e[r?"setStartBefore":"setEndBefore"](i),i.remove()}function it(t){var e,n,r;return t.collapsed?e={markerId:(r=nt(t,!1)).id,collapsed:!0}:(r=nt(t,!1),e={startMarkerId:(n=nt(t,!0)).id,endMarkerId:r.id,collapsed:!1}),t.collapsed?(t.setStartBefore(r),t.collapse(!0)):(t.setEndBefore(r),t.setStartAfter(n)),e}function ot(t,e){if(!e.restored){var n=k();if(e.collapsed){var r=at(t,e.markerId);if(r){r.style.display="inline";var i=r.previousSibling;i&&i.nodeType===h?(r.remove(),n.setStart(i,i.length)):(n.setStartBefore(r),n.collapse(!0),r.remove())}else console.log("Marker element has been removed. Cannot restore selection.")}else rt(t,n,e.startMarkerId,!0),rt(t,n,e.endMarkerId,!1);return E(n),n}}function at(t,e){return t.querySelector("#".concat(e))}function st(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return ut(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ut(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function ut(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function ct(t,e,n){return e=it(e),n(),ot(t,e)}var lt=/\u200B/g,ft=/\uFEFF/g,ht=/[^\S ]/g,dt=/^\s+$/,vt=/^\s+/,pt=/\s+$/;function gt(t){yt(t)}function yt(t){var e=document.createDocumentFragment();Et(t,"firstChild"),Et(t,"lastChild");var n,r=st(t.childNodes);try{for(r.s();!(n=r.n()).done;){var i=n.value;if("BR"===i.nodeName||i.textContent){if(i.nodeType===f&&"BR"!==i.nodeName){for(var o=i;null!==(o=o.nextSibling)&&Q(o,i);){var a,s=st(o.childNodes);try{for(s.s();!(a=s.n()).done;){var u=a.value;i.appendChild(u.cloneNode(!0))}}catch(t){s.e(t)}finally{s.f()}o.remove()}yt(i)}e.appendChild(i.cloneNode(!0))}}}catch(t){r.e(t)}finally{r.f()}for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(e)}function mt(t){return t.replace(ht," ")}function bt(t){t.innerHTML=St(t,!0)}function St(t,e){var n=(t.nodeType===d?wt(t):t.innerHTML).replace(ft,"").replace(lt,""),r=document.createElement("div");return r.innerHTML=n,Tt(r,e),Et(r,"firstChild"),Et(r,"lastChild"),r.innerHTML}function wt(t){var e=t.cloneNode(!0),n=document.createElement("div");return n.appendChild(e),n.innerHTML}function kt(t){var e=document.createElement("div");e.innerHTML=t;for(var n=document.createDocumentFragment();e.firstChild;)n.appendChild(e.firstChild);return n}function Ct(t,e){return t.ownerDocument!==e?e.adoptNode(t):t}function At(t){for(var e=t.cloneContents().childNodes[0],n=document.createDocumentFragment();e.childNodes.length;)n.appendChild(e.childNodes[0]);return n}function Et(t,e){for(var n,r,o=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];r=t[e];)if(r.nodeType===h){if(!dt.test(r.textContent))break;t.removeChild(r)}else{if("BR"!==r.nodeName){r[e]&&Et(r,e,!1);break}r.remove()}o&&(null===(n=r=t[e])||void 0===n?void 0:n.nodeType)===h&&i.trimLeadingAndTrailingWhitespaces&&(r.textContent=r.textContent.replace(e.startsWith("last")?pt:vt,""))}function Tt(t,e){for(;t;){var n=t.nextSibling;if(t.nodeType===f){var r=t.getAttribute("data-editable");t.firstChild&&Tt(t.firstChild,e),("remove"===r||"ui-remove"===r&&!e)&&t.remove(),("unwrap"===r||"ui-unwrap"===r&&!e)&&qt(t),t=n}else t=n}}function xt(t,e,n){var r=Rt(e,n),i=Ot(t,e,n);return r.concat(i)}function Ot(t,e,n){for(var r=[],i=e.commonAncestorContainer;i!==t;)n&&!n(i)||r.push(i),i=i.parentNode;return r}function Nt(t,e,n){return xt(t,e,function(t){return t.nodeName.toUpperCase()===n.toUpperCase()})}function jt(t,e,n){return xt(t,e,function(t){return t.nodeName.toUpperCase()===n.nodeName.toUpperCase()&&_t(t.attributes,n.attributes)})}function _t(t,e){if(t.length!==e.length)return!1;for(var n=0;n<t.length;n++){var r=e[t[n].name];if(!r||r.value!==t[n].value)return!1}return!0}function Rt(t,e){return A(t,[f],e)}function Bt(t,e){return A(t,[f],e).filter(function(e){return T(t,e)})}function It(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).map(function(t){return t.nodeName})}function Lt(t,e,n){return xt(t,e).some(function(t){return t.nodeName===n.toUpperCase()})}function Pt(t){var e=k();return e.selectNodeContents(t),e}function Mt(t,e,n){var r,i,o=k();if(o.selectNodeContents(e),i=o,-1!==(r=t).compareBoundaryPoints(Range.END_TO_START,i)||-1!==i.compareBoundaryPoints(Range.END_TO_START,r))return!1;var a=t.toString(),s=(e.jquery?e[0]:e).textContent;return n&&(a=c(a),s=c(s)),""!==a&&a===s}function Ft(t,e,n){return e.selectNodeContents(n),e}function Dt(t,e,n){var r=jt(t,e,n);return 1===r.length&&Mt(e,r[0],"visible")?Ut(t,e,n):Vt(t,e,n)}function Ht(t){return function(t){if(!t||!t.startContainer||!t.endContainer)return!1;if(t.startContainer===t.endContainer)return!0;for(var e,n=function(t){var e=t,n=null;return{next:function(){if(!e)return null;if(e.firstChild&&n!==e.firstChild)n=e,e=e.firstChild;else if(e.nextSibling)n=e,e=e.nextSibling;else{for(var r=e.parentNode;r&&r!==t;){if(r.nextSibling){n=e=r.nextSibling;break}r=r.parentNode}r&&r!==t||(n=e=null)}return e}}}(t.commonAncestorContainer),r=!1;e=n.next();)if(e.nodeType===Node.ELEMENT_NODE&&!Zt(e,t)){r=!0;break}return!r}(t)}function Vt(t,e,n){var r=ct(t,e,function(){Kt(t,e,n)});return Ht(r)||(r=ct(t,r,function(){zt(t,r)})),Wt(r,n),r}function Wt(t,e){Ht(t)?("string"==typeof e&&(e=S(e)),t.surroundContents(e)):console.log("content.wrap(): can not surround range")}function qt(t){for(var e=(t=t.jquery?t[0]:t).parentNode;t.firstChild;)e.insertBefore(t.firstChild,t);e.removeChild(t)}function Ut(t,e,n){return ct(t,e,function(){Kt(t,e,n)})}function $t(t,e,n){return ct(t,e,function(){zt(t,e,n)})}function zt(t,e,n){xt(t,e).forEach(function(t){"BR"===t.nodeName.toUpperCase()||n&&!t.matches(n)||qt(t)})}function Kt(t,e,n){xt(t,e).forEach(function(t){"BR"!==t.nodeName.toUpperCase()&&(!n||t.nodeName.toUpperCase()===n.nodeName.toUpperCase()&&_t(t.attributes,n.attributes))&&qt(t)})}function Qt(t,e,n){var r=document.createTextNode(e),i=t.cloneRange();i.collapse(n),i.insertNode(r),t[n?"setStartBefore":"setEndAfter"](r),E(t)}function Xt(t,e,n,r){return Qt(e,r||n,!1),Qt(e,n,!0),e}function Gt(t,e,n){if(!Yt(e,n))return e;window.getSelection().rangeCount>0&&N(e);var r=ct(t,e,function(){A(e,[h],function(t){return t.nodeValue.indexOf(n)>=0}).forEach(function(t){t.nodeValue=t.nodeValue.replaceAll(n,"")})});return E(r),r}function Yt(t,e){return t.toString().indexOf(e)>=0}function Jt(t,e,n){xt(t,e).forEach(function(t){t.nodeName.toUpperCase()===n.toUpperCase()&&qt(t)})}function Zt(t,e){var n=document.createRange();return n.selectNodeContents(t),e.compareBoundaryPoints(Range.START_TO_START,n)<=0&&e.compareBoundaryPoints(Range.END_TO_END,n)>=0}var te=1,ee={},ne=se("nextElementSibling"),re=se("previousElementSibling");function ie(t,e){var n=e.normalize,r=e.plainText,o=e.shouldSpellcheck;!function(t){t.hasAttribute("data-editable")||(t.setAttribute("data-editable","id-".concat(te)),te+=1)}(t),t.setAttribute("contenteditable",!0),t.setAttribute("spellcheck",Boolean(o)),t.setAttribute("data-plaintext",Boolean(r)),t.classList.remove(i.editableDisabledClass),t.classList.add(i.editableClass),n&&gt(t)}function oe(t){t.removeAttribute("contenteditable"),t.removeAttribute("spellcheck"),t.removeAttribute("data-plaintext"),function(t){if(t.hasAttribute("data-editable")){var e=t.getAttribute("data-editable");ee[e]=void 0}}(t),t.classList.remove(i.editableClass),t.classList.add(i.editableDisabledClass)}function ae(t){return"true"===t.getAttribute("data-plaintext")}function se(t){return function(e){var n=e[t];return n&&n.getAttribute("contenteditable")?n:null}}function ue(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}var ce,le,fe,he,de,ve,pe,ge,ye,me=[["«","»"],["»","«"],['"','"'],["“","”"],["”","”"],["“","“"],["„","“"]],be=[["‘","’"],["‹","›"],["‚","‘"],["’","’"],["›","‹"],["'","'"],["‘","’"]],Se=["’","'"],we=/([‘’‹›‚'«»"“”„])(?![^<]*?>)/g,ke=/\s|[>\-–—«»”"“„]/,Ce=/\s|[<\-–—«»”"“‘’‹›'.;?:,]/;function Ae(t,e){(ce=e||{}).quotes=ce.quotes||[void 0,void 0],ce.singleQuotes=ce.singleQuotes||[void 0,void 0];var n=function(t){return(e=t.matchAll(we),function(t){if(Array.isArray(t))return ue(t)}(e)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(e)||function(t,e){if(t){if("string"==typeof t)return ue(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ue(t,e):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).map(function(e){var n=e.index;return{char:e[1],before:n>0?t[n-1]:"",after:n+1<t.length?t[n+1]:""}});var e}(t);return n.length>0?(Ee(n,0),function(t,e){var n=0;return t.replace(we,function(t){var r=e[n].replace||e[n].char;return n+=1,r})}(t,n)):t}function Ee(t,e){for(;e<t.length;){var n=Te(t,e);if(n){if(t[e].replace="double"===n.type?ce.quotes[0]:ce.singleQuotes[0],t[n.position].replace="double"===n.type?ce.quotes[1]:ce.singleQuotes[1],n.position!==e+1){var r=t.slice(e+1,n.position);r&&Ee(r,0)}e=n.position+1}else t[e].replace=Oe(t[e].char),e+=1}}function Te(t,e){if(e!==t.length-1){var n=t[e],r=n.char;if(!n.before||ke.test(n.before))for(var i=xe(r,be),o=xe(r,me),a=e+1;a<t.length;a++)if(t[a].after&&Ce.test(t[a].after)||!t[a].after){if(i.includes(t[a].char))return{position:a,type:"single"};if(o.includes(t[a].char))return{position:a,type:"double"}}}}function xe(t,e){return e.filter(function(e){return e[0]===t}).map(function(t){return t[1]})}function Oe(t){if(Se.includes(t))return ce.apostrophe}var Ne,je=/^\s*$/,_e="\x3c!-- BLOCK --\x3e";function Re(t){var e=t.pastedHtmlRules;le=e.allowedElements||{},fe=e.allowedPlainTextElements||{},he=e.requiredAttributes||{},de=e.transformElements||{},ye=e.blacklistedElements||[],Ne=e.keepInternalRelativeLinks||!1,pe=e.replaceQuotes||{},ve={},e.blockLevelElements.forEach(function(t){ve[t]=!0}),ge={},e.splitIntoBlocks.forEach(function(t){ge[t]=!0})}function Be(t,e,n){var r=t.ownerDocument;t.setAttribute(i.pastingAttribute,!0),e.isSelection&&(e=e.deleteExactSurroundingTags().deleteContainedTags().deleteContent());var o=r.createElement("div");o.innerHTML=n;var a=function(t){var e=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).plainText,n=void 0!==e&&e;return Ie(t,{allowedElements:n?fe:le,keepInternalRelativeLinks:!n&&Ne}).split(_e).map(function(t){return c((e=t,pe.quotes||pe.singleQuotes||pe.apostrophe?Ae(e,pe):e).replace(/\n/g," ").replace(/ {2,}/g," ").replace(/(.)\u00A0/g,function(t,e){return e+(/[\u0020]/.test(e)?" ":" ")}));var e}).filter(function(t){return!je.test(t)})}(o,{plainText:ae(t)});return t.removeAttribute(i.pastingAttribute),{blocks:a,cursor:e}}function Ie(t,e){return Array.from(t.childNodes).reduce(function(t,n){if(-1!==ye.indexOf(n.nodeName.toLowerCase()))return"";if(e.keepInternalRelativeLinks&&"A"===n.nodeName&&n.href){var r=n.getAttribute("href").replace(window.location.origin,"");n.setAttribute("href",r)}return n.nodeType===f?t+function(t,e,n){var r=t.nodeName.toLowerCase();if(function(t,e,n){return n.allowedElements[t]&&function(t,e){var n=he[t];return!n||!n.some(function(t){return!e.getAttribute(t)})}(t,e)}(r=function(t){return de[t]||t}(r),t,n)){var i=function(t,e){return Array.from(e.attributes).reduce(function(e,n){var r,i=n.name,o=n.value;return null!==(r=le[t])&&void 0!==r&&r[i]&&o?"".concat(e," ").concat(i,'="').concat(o,'"'):e},"")}(r,t);return"br"===r?"<".concat(r+i,">"):je.test(e)?e:"<".concat(r+i,">").concat(e,"</").concat(r,">")}return ge[r]?_e+e+_e:ve[r]?"".concat(e," "):e}(n,Ie(n,e),e):n.nodeType===h?t+n.nodeValue.replace(/[&<>]/g,function(t){return s[t]}):t},"")}Re(i),document.documentElement.contentEditable;var Le=/(apple)?webkit\/537\.36/i.test(window.navigator.userAgent),Pe=/(apple)?webkit/i.test(window.navigator.userAgent),Me=!Le&&Pe,Fe=function(t){var e=t,n=e.onselectionchange;if(void 0!==n)try{return e.onselectionchange=0,null===e.onselectionchange}catch(t){}finally{e.onselectionchange=n}return!1}(document),De=!!Me;function He(t,e){var n=function(t){var e={};function n(t,n){t.split(" ").forEach(function(t){e[t]=e[t]||[],e[t].unshift(n)})}return{on:function(t,e){if(2===arguments.length)n(t,e);else if(1===arguments.length)for(var r in t)n(r,t[r]);return this},off:function(t,n){2===arguments.length?function(t,n){var r=e[t];if(r){var i=r.indexOf(n);i<0||r.splice(i,1)}}(t,n):1===arguments.length?e[t]=[]:e={}},notify:function(n,r){var i=Array.from(arguments);t?(r=n,n=t,i.splice(0,1)):i.splice(0,2),this.switchContext&&r!==this.switchContext.events.shift()&&(this.switchContext=void 0);var o=e[r];o&&o.every(function(t){return!1!==t.apply(n,i)})}}}(e);t.on=n.on,t.off=n.off,t.notify=n.notify}function Ve(t){return{x:void 0!==t.pageXOffset?t.pageXOffset:(t.document.documentElement||t.document.body.parentNode||t.document.body).scrollLeft,y:void 0!==t.pageYOffset?t.pageYOffset:(t.document.documentElement||t.document.body.parentNode||t.document.body).scrollTop}}function We(t){return We="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},We(t)}function qe(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Ue(r.key),r)}}function Ue(t){var e=function(t){if("object"!=We(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=We(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==We(e)?e:e+""}var $e=function(){function t(e,n){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.setHost(e),this.range=n,this.isCursor=!0}return e=t,n=[{key:"getTags",value:function(t){return xt(this.host,this.range,t)}},{key:"getTagNames",value:function(t){return It(this.getTags(t))}},{key:"getTagsByName",value:function(t){return Nt(this.host,this.range,t)}},{key:"getInnerTags",value:function(t){return Rt(this.range,t)}},{key:"getContainedTags",value:function(t){return Bt(this.range,t)}},{key:"getAncestorTags",value:function(t){return Ot(this.host,this.range,t)}},{key:"isAtEnd",value:function(){return q(this.host,this.range.endContainer,this.range.endOffset)}},{key:"isAtTextEnd",value:function(){return z(this.host,this.range.endContainer,this.range.endOffset)}},{key:"isAtLastLine",value:function(){var t=this.win.document.createRange();t.selectNodeContents(this.host),t.collapse(!1);var e=ze(t,this.win),n=ze(this.range,this.win);return Ke(e.bottom,n.bottom)}},{key:"isAtFirstLine",value:function(){var t=this.win.document.createRange();t.selectNodeContents(this.host),t.collapse(!0);var e=ze(t,this.win),n=ze(this.range,this.win);return Ke(e.top,n.top)}},{key:"isAtBeginning",value:function(){return W(this.host,this.range.startContainer,this.range.startOffset)}},{key:"insertBefore",value:function(t){if(l(t)&&(t=kt(t)),!Y(t)){var e=t=this.adoptElement(t);if(t.nodeType===d){var n=t.childNodes.length-1;e=t.childNodes[n]}this.range.insertNode(t),this.range.setStartAfter(e),this.range.setEndAfter(e),this.host.normalize()}}},{key:"insertAfter",value:function(t){if(l(t)&&(t=kt(t)),!Y(t)){t=this.adoptElement(t);var e=this.range.cloneRange();e.setStart(e.endContainer,e.endOffset),e.collapse(!0),e.insertNode(t),this.host.normalize()}}},{key:"setSelection",value:function(){this.setVisibleSelection()}},{key:"setVisibleSelection",value:function(){if(this.win.document.activeElement!==this.host){var t=Ve(this.win),e=t.x,n=t.y;this.win.scrollTo(e,n)}var r=C(this.win);r.removeAllRanges(),r.addRange(this.range)}},{key:"before",value:function(){var t=this.range.cloneRange();return t.collapse(!0),t.setStartBefore(this.host),At(t)}},{key:"textBefore",value:function(){var t=this.range.cloneRange();return t.collapse(!0),t.setStartBefore(this.host),t.toString()}},{key:"beforeHtml",value:function(){return wt(this.before())}},{key:"after",value:function(){var t=this.range.cloneRange();return t.collapse(!1),t.setEndAfter(this.host),At(t)}},{key:"textAfter",value:function(){var t=this.range.cloneRange();return t.collapse(!1),t.setEndAfter(this.host),t.toString()}},{key:"afterHtml",value:function(){return wt(this.after())}},{key:"getBoundingClientRect",value:function(){return this.range.getBoundingClientRect()}},{key:"getCoordinates",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"absolute",e=this.range.getBoundingClientRect();if("fixed"===t)return e;var n=Ve(this.win),r=n.x,i=n.y;return{top:e.top+i,bottom:e.bottom+i,left:e.left+r,right:e.right+r,height:e.height,width:e.width}}},{key:"moveBefore",value:function(e){if(this.updateHost(e),this.range.setStartBefore(e),this.range.setEndBefore(e),this.isSelection)return new t(this.host,this.range)}},{key:"moveAfter",value:function(e){if(this.updateHost(e),this.range.setStartAfter(e),this.range.setEndAfter(e),this.isSelection)return new t(this.host,this.range)}},{key:"moveAtBeginning",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.host;if(this.updateHost(e),this.range.selectNodeContents(e),this.range.collapse(!0),this.isSelection)return new t(this.host,this.range)}},{key:"moveAtEnd",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.host;if(this.updateHost(e),this.range.selectNodeContents(e),this.range.collapse(!1),this.isSelection)return new t(this.host,this.range)}},{key:"moveAtTextEnd",value:function(t){return this.moveAtEnd(X(t))}},{key:"setHost",value:function(t){t.jquery&&(t=t[0]),this.host=t,this.win=null==t?window:t.ownerDocument.defaultView}},{key:"updateHost",value:function(t){var e=L(t);e||o("Can not set cursor outside of an editable block"),this.setHost(e)}},{key:"retainVisibleSelection",value:function(t){this.save(),t(),this.restore(),this.setVisibleSelection()}},{key:"save",value:function(){this.savedRangeInfo=it(this.range),this.savedRangeInfo.host=this.host}},{key:"restore",value:function(){this.savedRangeInfo||o("Could not restore selection"),this.host=this.savedRangeInfo.host,this.range=ot(this.host,this.savedRangeInfo),this.savedRangeInfo=void 0}},{key:"equals",value:function(t){return!!(t&&t.host&&t.host.isEqualNode(this.host)&&t.range&&_(t.range,this.range))}},{key:"createElement",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=this.win.document.createElement(t);for(var r in e){var i=e[r];n.setAttribute(r,i)}return n}},{key:"createTextNode",value:function(t){return this.win.document.createTextNode(t)}},{key:"adoptElement",value:function(t){return Ct(t,this.win.document)}},{key:"triggerChange",value:function(){var t=new Event("formatEditable",{bubbles:!0,cancelable:!1});this.host.dispatchEvent(t)}}],r=[{key:"findHost",value:function(t,e){return w(t,e)}}],n&&qe(e.prototype,n),r&&qe(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,n,r}();function ze(t,e){if(t.startContainer.nodeType!==f)return t.getBoundingClientRect();var n=e.document.createElement("span");n.setAttribute("doc-editable","unwrap"),t.insertNode(n);var r=n.getBoundingClientRect();return n.remove(),r}function Ke(t,e){return t===e||Math.abs(t-e)<=2}const Qe={extractText:function(t){var e="";return function(t,e,n){for(var r,i=new y(t);r=i.getNext();)r.nodeType===h&&""!==r.data?n(r.data):e&&r.nodeType===f&&"BR"===r.nodeName&&n("\n")}(t,!(arguments.length>1&&void 0!==arguments[1])||arguments[1],function(t){e+=t}),e},highlightMatches:function(t,e){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(e&&0!==e.length){t.normalize();for(var r,i,o,a=new y(t),s=0,u=0,c=e[s],l=[];r=a.getNext();)if(r.nodeType===h&&""!==r.data){var d=(o=r).data,v=u+d.length;if(c.startIndex<v&&u<c.endIndex){var p=u<=c.startIndex,g=v>=c.endIndex;p&&(i=c.id||c.startIndex);var m;m=p?c.startIndex-u:0;var b;b=g?c.endIndex-u-m:d.length-m;var S={element:o,text:d.substring(m,m+b),offset:m,length:b,isLastPortion:g,wordId:i};if(l.push(S),g){var w=this.wrapMatch(l,c.marker,c.title);a.replaceCurrent(w),v=u+S.length+S.offset,l=[],(s+=1)<e.length&&(c=e[s])}}u=v}else if(n&&r.nodeType===f&&"BR"===r.nodeName){u+=1;continue}}},wrapMatch:function(t,e,n){var r=this;return t.map(function(t){return r.wrapPortion(t,e,n)}).pop()},wrapPortion:function(t,e,n){var r=k();r.setStart(t.element,t.offset),r.setEnd(t.element,t.offset+t.length);var i=e.cloneNode(!0);if(i.setAttribute("data-word-id",t.wordId),n&&i.setAttribute("title",n),r.surroundContents(i),i.nextSibling){var o=i.nextSibling;o.nodeType===h&&""===o.data&&o.remove()}return i}};function Xe(t){return Xe="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Xe(t)}function Ge(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function Ye(t,e,n,r){if(!t||""===t)return[];if(r&&!function(t){try{var e;return!!t&&t instanceof(null===(e=t.ownerDocument)||void 0===e?void 0:e.defaultView.HTMLElement)}catch(e){return"object"===Xe(t)&&1===t.nodeType&&"object"===Xe(t.style)&&"object"===Xe(t.ownerDocument)}}(r))return[];if(null==e||!e.length)return[];var i,o=("word"===n?tn:Je)(e);return(i=t.matchAll(o),function(t){if(Array.isArray(t))return Ge(t)}(i)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(i)||function(t,e){if(t){if("string"==typeof t)return Ge(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ge(t,e):void 0}}(i)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).map(function(t){var e,i;return"word"===n?(e=t.index+t[1].length,i=t[2]):(e=t.index,i=t[0]),{startIndex:e,endIndex:e+i.length,match:i,marker:r}})}function Je(){var t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).map(function(t){return en(t)}),e="(".concat(t.join("|"),")");return new RegExp(e,"g")}var Ze="\\u0041-\\u005A\\u0061-\\u007A\\u0030-\\u0039\\u00AA\\u00B5\\u00BA\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u00FF\\u0100-\\u017F\\u0180-\\u024F";function tn(){var t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).map(function(t){return en(t)}),e="([^".concat(Ze,"]|^)")+"(".concat(t.join("|"),")")+"(?=[^".concat(Ze,"]|$)");return new RegExp(e,"g")}function en(t){return String(t).replace(/([.*+?^=!:${}()|[\]/\\])/g,"\\$1")}function nn(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return rn(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?rn(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function rn(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}var on={highlightText:function(t,e,n,r,i){if(!this.hasHighlight(t,n)){var o=Qe.extractText(t),a='<span class="highlight-'.concat(r,'"></span>'),s=function(t,e,n){return Ye(t,[e],"text",n)}(o,e,on.createMarkerNode(a,r,this.win));return s&&s.length?(n&&(s[0].id=n),Qe.highlightMatches(t,s),i&&i.notify("change",t),s[0].startIndex):void 0}},highlightRange:function(t,e,n,r,i,o){var a=arguments.length>6&&void 0!==arguments[6]?arguments[6]:"comment";this.hasHighlight(t,n)&&this.removeHighlight(t,n);var s=Qe.extractText(t,!1);if(""===s)return-1;var u=on.createMarkerNode('<span class="highlight-'.concat(a,'"></span>'),a,this.win);if(e){var c=document.createElement("div");if(c.innerHTML=e,c.textContent!==s.slice(r,i))return-1}return Qe.highlightMatches(t,[{startIndex:r,endIndex:i,id:n,marker:u}],!1),o&&o.notify("change",t),r},updateHighlight:function(t,e,n,r){if(document.documentElement.classList){var i,o=nn(t.querySelectorAll('[data-word-id="'.concat(e,'"]')));try{for(o.s();!(i=o.n()).done;){var a=i.value;r&&a.classList.remove(r),n&&a.classList.add(n)}}catch(t){o.e(t)}finally{o.f()}}},removeHighlight:function(t,e,n){var r,i=nn(t.querySelectorAll('[data-word-id="'.concat(e,'"]')));try{for(i.s();!(r=i.n()).done;)qt(r.value)}catch(t){i.e(t)}finally{i.f()}t.normalize(),n&&n.notify("change",t)},hasHighlight:function(t,e){return!!t.querySelectorAll('[data-word-id="'.concat(e,'"]')).length},extractHighlightedRanges:function(t,e){var n="[data-word-id]";e&&(n+='[data-highlight="'.concat(e,'"]'));var r=t.querySelectorAll(n);if(r.length){var i,o={},a=nn(r);try{for(a.s();!(i=a.n()).done;){var s=i.value.getAttribute("data-word-id");o[s]||(o[s]=t.querySelectorAll('[data-word-id="'.concat(s,'"]')))}}catch(t){a.e(t)}finally{a.f()}var u={};for(var c in o){var l=this.extractMarkerNodePosition(t,o[c]);l&&(u[c]=l)}return u}},extractMarkerNodePosition:function(t,e){var n=k();e.length>1?(n.setStartBefore(e[0]),n.setEndAfter(e[e.length-1])):n.selectNode(e[0]);var r=j(n,t);return{start:r.start,end:r.end,text:r.text,nativeRange:n}},cleanupStaleMarkerNodes:function(t,e){var n,r=nn(t.querySelectorAll('span[data-highlight="'.concat(e,'"]')));try{for(r.s();!(n=r.n()).done;){var i=n.value;i.textContent.length||i.remove()}}catch(t){r.e(t)}finally{r.f()}},createMarkerNode:function(t,e,n){var r=S(t,n);return r.setAttribute("data-editable","ui-unwrap"),r.setAttribute("data-highlight",e),r}};const an=on;function sn(t){return sn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},sn(t)}function un(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,o,a,s=[],u=!0,c=!1;try{if(o=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=o.call(n)).done)&&(s.push(r.value),s.length!==e);u=!0);}catch(t){c=!0,i=t}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw i}}return s}}(t,e)||cn(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function cn(t,e){if(t){if("string"==typeof t)return ln(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ln(t,e):void 0}}function ln(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function fn(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,hn(r.key),r)}}function hn(t){var e=function(t){if("object"!=sn(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=sn(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==sn(e)?e:e+""}function dn(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(dn=function(){return!!t})()}function vn(t){return vn=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},vn(t)}function pn(t,e){return pn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},pn(t,e)}var gn=function(t){function e(){var t;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),delete(t=function(t,e,n){return e=vn(e),function(t,e){if(e&&("object"==sn(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,dn()?Reflect.construct(e,n||[],vn(t).constructor):e.apply(t,n))}(this,e,arguments)).isCursor,t.isSelection=!0,t}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&pn(t,e)}(e,t),n=e,r=[{key:"text",value:function(){return this.range.toString()}},{key:"html",value:function(){return function(t){var e=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:window).document.createElement("div");return e.appendChild(t.cloneContents()),e.innerHTML}(this.range)}},{key:"isAllSelected",value:function(){return W(this.host,this.range.startContainer,this.range.startOffset)&&z(this.host,this.range.endContainer,this.range.endOffset)}},{key:"getTextRange",value:function(){return j(this.range,this.host)}},{key:"toString",value:function(){return this.range.toString()}},{key:"isWrappable",value:function(){return Ht(this.range)}},{key:"getRects",value:function(){return this.range.getClientRects()}},{key:"link",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t&&(e.href=t);var n=this.createElement(i.linkMarkup.name,i.linkMarkup.attribs);for(var r in e){var o=e[r];void 0!==o&&(null===o?n.removeAttribute(r):n.setAttribute(r,o))}i.linkMarkup.trim&&this.trimRange(),this.forceWrap(n)}},{key:"trimRange",value:function(){var t=this.range.toString(),e=t.search(/\S|$/),n=t.search(/\S[\s]+$/),r=-1===n?0:t.length-(n+1),i=un(R({root:this.range.commonAncestorContainer,startContainer:this.range.startContainer,startOffset:this.range.startOffset,whitespacesOnTheLeft:e}),2),o=i[0],a=i[1];this.range.setStart(o,a);var s=un(B({root:this.range.commonAncestorContainer,endContainer:this.range.endContainer,endOffset:this.range.endOffset,whitespacesOnTheRight:r}),2),u=s[0],c=s[1];this.range.setEnd(u,c)}},{key:"unlink",value:function(){this.removeFormatting(i.linkMarkup.name)}},{key:"toggleLink",value:function(t,e){var n=this.getTagsByName(i.linkMarkup.name);if(n.length>=1){var r=n[0];this.isExactSelection(r,"visible")?this.unlink():this.expandTo(r)}else this.link(t,e)}},{key:"highlightComment",value:function(t){var e=t.highlightId,n=t.textRange;an.highlightRange(this.host,e,n.text,n.start,n.end,void 0,"comment")}},{key:"highlight",value:function(t){t.highlightId;var e=this.textBefore(),n=this.text(),r=an.createMarkerNode('<span class="highlight-comment"></span>',this.win);r.setAttribute("data-match",n);var i={startIndex:e.length,endIndex:e.length+n.length,match:n,marker:r};Qe.highlightMatches(this.host,[i])}},{key:"toggle",value:function(t){ae(this.host)||this.range.collapsed||(t=this.adoptElement(t),this.range=Dt(this.host,this.range,t),this.setVisibleSelection())}},{key:"toggleCustom",value:function(t){var e=t.tagName,n=t.attributes,r=t.trim,i=void 0!==r&&r,o=this.createElement(e,n);i&&this.trimRange(),this.toggle(o)}},{key:"makeCustom",value:function(t){var e=t.tagName,n=t.attributes,r=t.trim,i=void 0!==r&&r,o=this.createElement(e,n);i&&this.trimRange(),this.forceWrap(o)}},{key:"makeBold",value:function(){var t=this.createElement(i.boldMarkup.name,i.boldMarkup.attribs);i.boldMarkup.trim&&this.trimRange(),this.forceWrap(t)}},{key:"toggleBold",value:function(){var t=this.createElement(i.boldMarkup.name,i.boldMarkup.attribs);i.boldMarkup.trim&&this.trimRange(),this.toggle(t)}},{key:"giveEmphasis",value:function(){var t=this.createElement(i.italicMarkup.name,i.italicMarkup.attribs);i.italicMarkup.trim&&this.trimRange(),this.forceWrap(t)}},{key:"toggleEmphasis",value:function(){var t=this.createElement(i.italicMarkup.name,i.italicMarkup.attribs);i.italicMarkup.trim&&this.trimRange(),this.toggle(t)}},{key:"makeUnderline",value:function(){var t=this.createElement(i.underlineMarkup.name,i.underlineMarkup.attribs);i.underlineMarkup.trim&&this.trimRange(),this.forceWrap(t)}},{key:"toggleUnderline",value:function(){var t=this.createElement(i.underlineMarkup.name,i.underlineMarkup.attribs);i.underlineMarkup.trim&&this.trimRange(),this.toggle(t)}},{key:"insertCharacter",value:function(t){var e=this.deleteContent(),n=e.createTextNode(t);return e.insertBefore(n),e.setVisibleSelection(),e}},{key:"surround",value:function(t,e){this.range=Xt(this.host,this.range,t,e),this.setVisibleSelection()}},{key:"removeSurround",value:function(t,e){this.range=Gt(this.host,this.range,t),this.range=Gt(this.host,this.range,e),this.setVisibleSelection()}},{key:"removeChars",value:function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=0;e<t.length;e++){var n=t[e];this.range=Gt(this.host,this.range,n)}this.setVisibleSelection()}},{key:"toggleSurround",value:function(t,e){this.containsString(t)&&this.containsString(e)?this.removeSurround(t,e):this.surround(t,e)}},{key:"removeFormatting",value:function(t){this.range=$t(this.host,this.range,t),this.setVisibleSelection()}},{key:"deleteExactSurroundingTags",value:function(){var t,n=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=cn(t))){e&&(t=e);var n=0,r=function(){};return{s:r,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,a=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return o=t.done,t},e:function(t){a=!0,i=t},f:function(){try{o||null==e.return||e.return()}finally{if(a)throw i}}}}(this.getAncestorTags().reverse());try{for(n.s();!(t=n.n()).done;){var r=t.value;if(this.isExactSelection(r)){r.remove();break}}}catch(t){n.e(t)}finally{n.f()}return new e(this.host,this.range)}},{key:"deleteContainedTags",value:function(){return this.getContainedTags().forEach(function(t){return t.remove()}),new e(this.host,this.range)}},{key:"deleteContent",value:function(){return this.range.deleteContents(),new $e(this.host,this.range)}},{key:"expandTo",value:function(t){this.range=Ft(this.host,this.range,t),this.setVisibleSelection()}},{key:"collapseAtBeginning",value:function(t){return this.range.collapse(!0),this.setVisibleSelection(),new $e(this.host,this.range)}},{key:"collapseAtEnd",value:function(t){return this.range.collapse(!1),this.setVisibleSelection(),new $e(this.host,this.range)}},{key:"forceWrap",value:function(t){ae(this.host)||this.range.collapsed||(t=this.adoptElement(t),this.range=Vt(this.host,this.range,t),this.setVisibleSelection())}},{key:"isExactSelection",value:function(t,e){return Mt(this.range,t,e)}},{key:"containsString",value:function(t){return Yt(this.range,t)}},{key:"deleteCharacter",value:function(t){this.range=Gt(this.host,this.range,t),this.setVisibleSelection()}}],r&&fn(n.prototype,r),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r}($e);function yn(t){return yn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},yn(t)}function mn(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,bn(r.key),r)}}function bn(t){var e=function(t){if("object"!=yn(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=yn(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==yn(e)?e:e+""}var Sn=function(){function t(e,n){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.host=e&&e.jquery?e[0]:e,this.range=null==n?void 0:n.cloneRange(),this.isAnythingSelected=void 0!==n,this.isCursor=this.isAnythingSelected&&n.collapsed,this.isSelection=this.isAnythingSelected&&!this.isCursor}return e=t,n=[{key:"getCursor",value:function(){if(this.isCursor)return new $e(this.host,this.range)}},{key:"getSelection",value:function(){if(this.isSelection)return new gn(this.host,this.range)}},{key:"forceCursor",value:function(){return this.isSelection?this.getSelection().deleteContent():this.getCursor()}},{key:"isDifferentFrom",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new t,n=this.range,r=e.range;return n&&r?!_(n,r):!(!n&&!r)}}],n&&mn(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,n}();function wn(t){return wn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},wn(t)}function kn(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Cn(r.key),r)}}function Cn(t){var e=function(t){if("object"!=wn(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=wn(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==wn(e)?e:e+""}var An=function(){return t=function t(e,n){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.dispatcher=e,this.win=n||window,this.selection=void 0,this.currentSelection=void 0,this.currentRange=void 0},(e=[{key:"syncSelection",value:function(){try{this.selection=C(this.win)}catch(t){return!1}return!0}},{key:"getRangeContainer",value:function(){var t,e=this.syncSelection();if(null!==(t=this.selection)&&void 0!==t&&t.rangeCount&&e){var n=this.selection.getRangeAt(0),r=L(n.commonAncestorContainer);if(r)return new Sn(r,n)}return new Sn}},{key:"getFreshRange",value:function(){return this.getRangeContainer()}},{key:"getFreshSelection",value:function(){var t=this.getRangeContainer();return t.isCursor?t.getCursor(this.win):t.getSelection(this.win)}},{key:"getSelection",value:function(){return this.currentSelection}},{key:"forceCursor",value:function(){return this.getRangeContainer().forceCursor()}},{key:"selectionChanged",value:function(){var t=this.getRangeContainer();if(t.isDifferentFrom(this.currentRange)){var e=this.currentSelection;this.currentRange=t,e&&(e.isCursor&&!this.currentRange.isCursor?this.dispatcher.notify("cursor",e.host):e.isSelection&&!this.currentRange.isSelection&&this.dispatcher.notify("selection",e.host)),this.currentRange.isCursor?(this.currentSelection=new $e(this.currentRange.host,this.currentRange.range),this.dispatcher.notify("cursor",this.currentSelection.host,this.currentSelection)):this.currentRange.isSelection?(this.currentSelection=new gn(this.currentRange.host,this.currentRange.range),this.dispatcher.notify("selection",this.currentSelection.host,this.currentSelection)):this.currentSelection=void 0}}}])&&kn(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function En(t){return En="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},En(t)}function Tn(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,xn(r.key),r)}}function xn(t){var e=function(t){if("object"!=En(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=En(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==En(e)?e:e+""}var On=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),He(this),this.selectionWatcher=e}return e=t,r=[{key:"getNodeToRemove",value:function(e,n){if(0===e.startOffset){var r=e.startContainer;if(r.nodeType===h&&(r=r.parentNode),r!==n){var i=k();if(i.setStartBefore(r.firstChild),i.setEndAfter(r.lastChild),a=e,!((o=i).compareBoundaryPoints(Range.START_TO_START,a)<=0&&o.compareBoundaryPoints(Range.END_TO_END,a)>=0)){var o,a;if(e.startContainer.nodeType===h){var s=[h,f],u=r.firstChild;do{if(-1!==s.indexOf(u.nodeType))break}while(u=u.nextSibling);if(u!==e.startContainer)return}var c=e.cloneRange();return c.setStartBefore(r),t.getNodeToRemove(c,n)||r}}}}}],(n=[{key:"dispatchKeyEvent",value:function(t,e,n){switch(t.keyCode){case this.key.left:return this.notify(e,"left",t);case this.key.right:return this.notify(e,"right",t);case this.key.up:return this.notify(e,"up",t);case this.key.down:return this.notify(e,"down",t);case this.key.tab:return t.shiftKey?this.notify(e,"shiftTab",t):this.notify(e,"tab",t);case this.key.esc:return this.notify(e,"esc",t);case this.key.backspace:return this.preventContenteditableBug(e,t),this.notify(e,"backspace",t);case this.key.delete:return this.preventContenteditableBug(e,t),this.notify(e,"delete",t);case this.key.enter:return t.shiftKey?this.notify(e,"shiftEnter",t):this.notify(e,"enter",t);case this.key.ctrl:case this.key.shift:case this.key.alt:case 224:case 17:case 91:case 93:return;default:if(t.keyCode===this.key.b&&(t.ctrlKey||t.metaKey))return this.notify(e,"bold",t);if(t.keyCode===this.key.i&&(t.ctrlKey||t.metaKey))return this.notify(e,"italic",t);if(this.preventContenteditableBug(e,t),!n)return;if(!t.ctrlKey&&!t.metaKey)return this.notify(e,"character",t)}}},{key:"preventContenteditableBug",value:function(e,n){if(De&&!n.ctrlKey&&!n.metaKey){var r=this.selectionWatcher.getFreshRange();if(r.isSelection){var i=t.getNodeToRemove(r.range,e);i&&i.remove()}}}}])&&Tn(e.prototype,n),r&&Tn(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,n,r}();function Nn(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}On.key=On.prototype.key={left:37,up:38,right:39,down:40,tab:9,esc:27,backspace:8,delete:46,enter:13,shift:16,ctrl:17,alt:18,b:66,i:73};var jn=function(t){return Array.isArray(t)&&2===t.length},_n=function(t){return/^[«»"“”„]$/.test(t)},Rn=function(t){return/^[‘’‹›‚']$/.test(t)},Bn=function(t){return/^[’']$/.test(t)},In=function(t){return/\s|[>\-–—]/.test(t)},Ln=function(t,e,n){var r=null==t?void 0:t.startContainer,i=null==r?void 0:r.nodeValue;if(!i)return null;var o="".concat(i.substring(0,e)).concat(n).concat(i.substring(e+1)),a=document.createTextNode(o);return r.replaceWith(a),a},Pn=function(t,e,n,r,i){var o,a=Rn(n);if(_n(n)||a){var s=e.quotes,u=e.singleQuotes;if(n!==s[0]&&n!==s[1]&&n!==u[0]&&n!==u[1]){var c,l,f,h=t.startOffset,d=function(t){if(Array.isArray(t))return Nn(t)}(o=t.startContainer.textContent)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(o)||function(t,e){if(t){if("string"==typeof t)return Nn(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Nn(t,e):void 0}}(o)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}();if(a&&(l=d)[f=h-2]&&_n(l[f]))c=Ln(t,h-1,u[0]);else if(function(t,e){return!!t[e]&&!In(t[e])}(d,h-2)){if(a){if(function(t,e){return!!t[e]&&(n=t[e],!/^\s$/.test(n));var n}(d,h))return;if(!function(t,e,n){if(e<=0)return!1;for(var r=e-1;r>=0;r--)if(Rn(t[r])&&!Bn(n)&&!Bn(t[r]))return t[r]===n;return!1}(d,h,u[0]))return}var v=a?u[1]:s[1];c=Ln(t,h-1,v)}else if(function(t,e){return e<0||In(t[e])}(d,h-2)){var p=a?u[0]:s[0];c=Ln(t,h-1,p)}c&&r.ownerDocument.defaultView.getSelection().collapse(c,null!=i?i:h)}}};function Mn(t){return Mn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Mn(t)}function Fn(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return Dn(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Dn(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function Dn(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function Hn(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Vn(r.key),r)}}function Vn(t){var e=function(t){if("object"!=Mn(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=Mn(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Mn(e)?e:e+""}var Wn=function(){return t=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t);var n=e.win;He(this,e),this.document=n.document,this.config=e.config,this.editable=e,this.editableSelector=e.editableSelector,this.selectionWatcher=new An(this,n),this.keyboard=new On(this.selectionWatcher),this.activeListeners=[],this.setup(),this.getEditableBlockByEvent=function(t){return w(t.target,e.editableSelector)}},e=[{key:"setupDocumentListener",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r={event:t,listener:e.bind(this),capture:n};return this.activeListeners.push(r),this.document.addEventListener(t,r.listener,n),this}},{key:"setup",value:function(){this.setupKeyboardEvents(),this.setupEventListeners()}},{key:"unload",value:function(){this.off();var t,e=Fn(this.activeListeners);try{for(e.s();!(t=e.n()).done;){var n=t.value;this.document.removeEventListener(n.event,n.listener,n.capture)}}catch(t){e.e(t)}finally{e.f()}this.activeListeners.length=0}},{key:"suspend",value:function(){if(!this.suspended){this.suspended=!0;var t,e=Fn(this.activeListeners);try{for(e.s();!(t=e.n()).done;){var n=t.value;this.document.removeEventListener(n.event,n.listener,n.capture)}}catch(t){e.e(t)}finally{e.f()}this.activeListeners.length=0}}},{key:"continue",value:function(){this.suspended&&(this.suspended=!1,this.setupEventListeners())}},{key:"setupEventListeners",value:function(){this.setupElementListeners(),this.setupKeydownListener(),Fe?this.setupSelectionChangeListeners():this.setupSelectionChangeFallbackListeners()}},{key:"setupElementListeners",value:function(){var t={offset:void 0};this.setupDocumentListener("focus",function(t){var e=this.getEditableBlockByEvent(t);e&&(t.target.getAttribute(i.pastingAttribute)||(this.selectionWatcher.syncSelection(),this.notify("focus",e)))},!0).setupDocumentListener("blur",function(t){var e=this.getEditableBlockByEvent(t);e&&(e.getAttribute(i.pastingAttribute)||this.notify("blur",e))},!0).setupDocumentListener("copy",function(t){var e=this.getEditableBlockByEvent(t);if(e){var n=this.selectionWatcher.getFreshSelection();n&&n.isSelection&&this.notify("clipboard",e,"copy",n)}}).setupDocumentListener("cut",function(t){var e=this.getEditableBlockByEvent(t);if(e){var n=this.selectionWatcher.getFreshSelection();n&&n.isSelection&&this.notify("clipboard",e,"cut",n)}}).setupDocumentListener("paste",function(t){var e=this.getEditableBlockByEvent(t);if(e){t.preventDefault();var n,r=this.selectionWatcher.getFreshSelection(),i=t.clipboardData.getData("text/html")||t.clipboardData.getData("text/plain"),o=Be(e,r,i),a=o.blocks,s=o.cursor;a.length?(n=t.target.innerText,/\S+\s{1}$/.test(n)&&s.retainVisibleSelection(function(){e.innerHTML=function(t,e){if(!t)return"";var n=(t="".concat(t)).lastIndexOf(e);return-1===n?t:"".concat(t.slice(0,n)).concat(" ").concat(t.slice(n+6))}(e.innerHTML,"&nbsp;")}),this.notify("paste",e,a,s),this.notify("change",e)):s.setVisibleSelection()}}).setupDocumentListener("input",function(e){var n=this.getEditableBlockByEvent(e);if(n){if(function(t,e){var n=t.smartQuotes,r=t.quotes,i=t.singleQuotes;return!!n&&jn(r)&&jn(i)&&e.isContentEditable}(i,e.target)){var r,o=this.selectionWatcher.getFreshSelection();t.offset=null===(r=o.range)||void 0===r?void 0:r.startOffset,setTimeout(function(){Pn(o.range,i,e.data,e.target,t.offset)},300)}this.notify("change",n)}}).setupDocumentListener("formatEditable",function(t){var e=this.getEditableBlockByEvent(t);e&&this.notify("change",e)})}},{key:"dispatchSwitchEvent",value:function(t,e,n){if(!(t.altKey||t.ctrlKey||t.metaKey||t.shiftKey)){var r=this.selectionWatcher.getFreshSelection();r&&!r.isSelection&&(this.switchContext?this.switchContext.events=["cursor"]:this.switchContext={positionX:r.getBoundingClientRect().left,events:["cursor"]},"up"===n&&r.isAtFirstLine()&&(t.preventDefault(),t.stopPropagation(),this.switchContext.events=["switch","blur","focus","cursor"],this.notify("switch",e,n,r)),"down"===n&&r.isAtLastLine()&&(t.preventDefault(),t.stopPropagation(),this.switchContext.events=["switch","blur","focus","cursor"],this.notify("switch",e,n,r)))}}},{key:"setupKeydownListener",value:function(){this.setupDocumentListener("keydown",function(t){var e=this.getEditableBlockByEvent(t);e&&this.keyboard.dispatchKeyEvent(t,e,!1)},!0)}},{key:"setupKeyboardEvents",value:function(){var t=this;this.keyboard.on("up",function(e){t.dispatchSwitchEvent(e,this,"up")}).on("down",function(e){t.dispatchSwitchEvent(e,this,"down")}).on("backspace",function(e){var n=t.selectionWatcher.getFreshRange();if(n.isCursor){var r=n.getCursor();r.isAtBeginning()&&(e.preventDefault(),e.stopPropagation(),t.notify("merge",this,"before",r))}}).on("delete",function(e){var n=t.selectionWatcher.getFreshRange();if(n.isCursor){var r=n.getCursor();r.isAtTextEnd()&&(e.preventDefault(),e.stopPropagation(),t.notify("merge",this,"after",r))}}).on("enter",function(e){e.preventDefault(),e.stopPropagation();var n=t.selectionWatcher.getFreshRange().forceCursor();n.isAtTextEnd()?t.notify("insert",this,"after",n):n.isAtBeginning()?t.notify("insert",this,"before",n):t.notify("split",this,n.before(),n.after(),n)}).on("shiftEnter",function(e){e.preventDefault(),e.stopPropagation();var n=t.selectionWatcher.forceCursor();t.notify("newline",this,n)}).on("bold",function(e){e.preventDefault(),e.stopPropagation();var n=t.selectionWatcher.getFreshSelection();n.isSelection&&t.notify("toggleBold",n)}).on("italic",function(e){e.preventDefault(),e.stopPropagation();var n=t.selectionWatcher.getFreshSelection();n.isSelection&&t.notify("toggleEmphasis",n)}).on("character",function(e){t.notify("change",this)})}},{key:"setupSelectionChangeListeners",value:function(){var t=this,e=!1,n=!1,r=this.selectionWatcher;this.setupDocumentListener("selectionchange",function(i){var o=t.selectionWatcher.getFreshSelection();o&&o.isSelection&&o.isAtBeginning()&&o.isAtEnd()?t.notify("selectToBoundary",o.host,i,"both"):o&&o.isSelection&&o.isAtBeginning()?t.notify("selectToBoundary",o.host,i,"start"):o&&o.isSelection&&o.isAtEnd()&&t.notify("selectToBoundary",o.host,i,"end"),n?e=!0:r.selectionChanged()}),this.setupDocumentListener("mousedown",function(t){this.getEditableBlockByEvent(t)&&(!1===this.config.mouseMoveSelectionChanges&&(n=!0,setTimeout(function(){return r.selectionChanged()},0)),this.document.addEventListener("mouseup",function(){n=!1,e&&(e=!1,r.selectionChanged())},{capture:!0,once:!0}))})}},{key:"setupSelectionChangeFallbackListeners",value:function(){var t=this;this.setupDocumentListener("mouseup",function(){setTimeout(function(){return t.selectionWatcher.selectionChanged()},0)}),this.setupDocumentListener("keyup",function(e){t.getEditableBlockByEvent(e)&&t.selectionWatcher.selectionChanged()})}}],e&&Hn(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();const qn=function(t,e){return t===e||t!=t&&e!=e},Un=function(t,e){for(var n=t.length;n--;)if(qn(t[n][0],e))return n;return-1};var $n=Array.prototype.splice;function zn(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}zn.prototype.clear=function(){this.__data__=[],this.size=0},zn.prototype.delete=function(t){var e=this.__data__,n=Un(e,t);return!(n<0||(n==e.length-1?e.pop():$n.call(e,n,1),--this.size,0))},zn.prototype.get=function(t){var e=this.__data__,n=Un(e,t);return n<0?void 0:e[n][1]},zn.prototype.has=function(t){return Un(this.__data__,t)>-1},zn.prototype.set=function(t,e){var n=this.__data__,r=Un(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this};const Kn=zn,Qn="object"==typeof t.g&&t.g&&t.g.Object===Object&&t.g;var Xn="object"==typeof self&&self&&self.Object===Object&&self;const Gn=Qn||Xn||Function("return this")(),Yn=Gn.Symbol;var Jn=Object.prototype,Zn=Jn.hasOwnProperty,tr=Jn.toString,er=Yn?Yn.toStringTag:void 0;var nr=Object.prototype.toString;var rr=Yn?Yn.toStringTag:void 0;const ir=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":rr&&rr in Object(t)?function(t){var e=Zn.call(t,er),n=t[er];try{t[er]=void 0;var r=!0}catch(t){}var i=tr.call(t);return r&&(e?t[er]=n:delete t[er]),i}(t):function(t){return nr.call(t)}(t)},or=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)},ar=function(t){if(!or(t))return!1;var e=ir(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e},sr=Gn["__core-js_shared__"];var ur,cr=(ur=/[^.]+$/.exec(sr&&sr.keys&&sr.keys.IE_PROTO||""))?"Symbol(src)_1."+ur:"";var lr=Function.prototype.toString;var fr=/^\[object .+?Constructor\]$/,hr=Function.prototype,dr=Object.prototype,vr=hr.toString,pr=dr.hasOwnProperty,gr=RegExp("^"+vr.call(pr).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");const yr=function(t){return!(!or(t)||(e=t,cr&&cr in e))&&(ar(t)?gr:fr).test(function(t){if(null!=t){try{return lr.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t));var e},mr=function(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return yr(n)?n:void 0},br=mr(Gn,"Map"),Sr=mr(Object,"create");var wr=Object.prototype.hasOwnProperty;var kr=Object.prototype.hasOwnProperty;function Cr(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}Cr.prototype.clear=function(){this.__data__=Sr?Sr(null):{},this.size=0},Cr.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},Cr.prototype.get=function(t){var e=this.__data__;if(Sr){var n=e[t];return"__lodash_hash_undefined__"===n?void 0:n}return wr.call(e,t)?e[t]:void 0},Cr.prototype.has=function(t){var e=this.__data__;return Sr?void 0!==e[t]:kr.call(e,t)},Cr.prototype.set=function(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=Sr&&void 0===e?"__lodash_hash_undefined__":e,this};const Ar=Cr,Er=function(t,e){var n,r,i=t.__data__;return("string"==(r=typeof(n=e))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?i["string"==typeof e?"string":"hash"]:i.map};function Tr(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}Tr.prototype.clear=function(){this.size=0,this.__data__={hash:new Ar,map:new(br||Kn),string:new Ar}},Tr.prototype.delete=function(t){var e=Er(this,t).delete(t);return this.size-=e?1:0,e},Tr.prototype.get=function(t){return Er(this,t).get(t)},Tr.prototype.has=function(t){return Er(this,t).has(t)},Tr.prototype.set=function(t,e){var n=Er(this,t),r=n.size;return n.set(t,e),this.size+=n.size==r?0:1,this};const xr=Tr;function Or(t){var e=this.__data__=new Kn(t);this.size=e.size}Or.prototype.clear=function(){this.__data__=new Kn,this.size=0},Or.prototype.delete=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n},Or.prototype.get=function(t){return this.__data__.get(t)},Or.prototype.has=function(t){return this.__data__.has(t)},Or.prototype.set=function(t,e){var n=this.__data__;if(n instanceof Kn){var r=n.__data__;if(!br||r.length<199)return r.push([t,e]),this.size=++n.size,this;n=this.__data__=new xr(r)}return n.set(t,e),this.size=n.size,this};const Nr=Or,jr=function(){try{var t=mr(Object,"defineProperty");return t({},"",{}),t}catch(t){}}(),_r=function(t,e,n){"__proto__"==e&&jr?jr(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n},Rr=function(t,e,n){(void 0!==n&&!qn(t[e],n)||void 0===n&&!(e in t))&&_r(t,e,n)},Br=function(t,e,n){for(var r=-1,i=Object(t),o=n(t),a=o.length;a--;){var s=o[++r];if(!1===e(i[s],s,i))break}return t};var Ir="object"==typeof exports&&exports&&!exports.nodeType&&exports,Lr=Ir&&"object"==typeof module&&module&&!module.nodeType&&module,Pr=Lr&&Lr.exports===Ir?Gn.Buffer:void 0,Mr=Pr?Pr.allocUnsafe:void 0;const Fr=Gn.Uint8Array,Dr=function(t,e){var n,r,i=e?(n=t.buffer,r=new n.constructor(n.byteLength),new Fr(r).set(new Fr(n)),r):t.buffer;return new t.constructor(i,t.byteOffset,t.length)};var Hr=Object.create;const Vr=function(){function t(){}return function(e){if(!or(e))return{};if(Hr)return Hr(e);t.prototype=e;var n=new t;return t.prototype=void 0,n}}(),Wr=(qr=Object.getPrototypeOf,Ur=Object,function(t){return qr(Ur(t))});var qr,Ur,$r=Object.prototype;const zr=function(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||$r)},Kr=function(t){return null!=t&&"object"==typeof t},Qr=function(t){return Kr(t)&&"[object Arguments]"==ir(t)};var Xr=Object.prototype,Gr=Xr.hasOwnProperty,Yr=Xr.propertyIsEnumerable;const Jr=Qr(function(){return arguments}())?Qr:function(t){return Kr(t)&&Gr.call(t,"callee")&&!Yr.call(t,"callee")},Zr=Array.isArray,ti=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991},ei=function(t){return null!=t&&ti(t.length)&&!ar(t)};var ni="object"==typeof exports&&exports&&!exports.nodeType&&exports,ri=ni&&"object"==typeof module&&module&&!module.nodeType&&module,ii=ri&&ri.exports===ni?Gn.Buffer:void 0;const oi=(ii?ii.isBuffer:void 0)||function(){return!1};var ai=Function.prototype,si=Object.prototype,ui=ai.toString,ci=si.hasOwnProperty,li=ui.call(Object);var fi={};fi["[object Float32Array]"]=fi["[object Float64Array]"]=fi["[object Int8Array]"]=fi["[object Int16Array]"]=fi["[object Int32Array]"]=fi["[object Uint8Array]"]=fi["[object Uint8ClampedArray]"]=fi["[object Uint16Array]"]=fi["[object Uint32Array]"]=!0,fi["[object Arguments]"]=fi["[object Array]"]=fi["[object ArrayBuffer]"]=fi["[object Boolean]"]=fi["[object DataView]"]=fi["[object Date]"]=fi["[object Error]"]=fi["[object Function]"]=fi["[object Map]"]=fi["[object Number]"]=fi["[object Object]"]=fi["[object RegExp]"]=fi["[object Set]"]=fi["[object String]"]=fi["[object WeakMap]"]=!1;var hi="object"==typeof exports&&exports&&!exports.nodeType&&exports,di=hi&&"object"==typeof module&&module&&!module.nodeType&&module,vi=di&&di.exports===hi&&Qn.process,pi=function(){try{return di&&di.require&&di.require("util").types||vi&&vi.binding&&vi.binding("util")}catch(t){}}(),gi=pi&&pi.isTypedArray;const yi=gi?function(t){return function(e){return t(e)}}(gi):function(t){return Kr(t)&&ti(t.length)&&!!fi[ir(t)]},mi=function(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]};var bi=Object.prototype.hasOwnProperty;const Si=function(t,e,n){var r=t[e];bi.call(t,e)&&qn(r,n)&&(void 0!==n||e in t)||_r(t,e,n)};var wi=/^(?:0|[1-9]\d*)$/;const ki=function(t,e){var n=typeof t;return!!(e=e??9007199254740991)&&("number"==n||"symbol"!=n&&wi.test(t))&&t>-1&&t%1==0&&t<e};var Ci=Object.prototype.hasOwnProperty;const Ai=function(t,e){var n=Zr(t),r=!n&&Jr(t),i=!n&&!r&&oi(t),o=!n&&!r&&!i&&yi(t),a=n||r||i||o,s=a?function(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}(t.length,String):[],u=s.length;for(var c in t)!e&&!Ci.call(t,c)||a&&("length"==c||i&&("offset"==c||"parent"==c)||o&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||ki(c,u))||s.push(c);return s};var Ei=Object.prototype.hasOwnProperty;const Ti=function(t){if(!or(t))return function(t){var e=[];if(null!=t)for(var n in Object(t))e.push(n);return e}(t);var e=zr(t),n=[];for(var r in t)("constructor"!=r||!e&&Ei.call(t,r))&&n.push(r);return n},xi=function(t){return ei(t)?Ai(t,!0):Ti(t)},Oi=function(t){return function(t,e,n,r){var i=!n;n||(n={});for(var o=-1,a=e.length;++o<a;){var s=e[o],u=r?r(n[s],t[s],s,n,t):void 0;void 0===u&&(u=t[s]),i?_r(n,s,u):Si(n,s,u)}return n}(t,xi(t))},Ni=function(t,e,n,r,i,o,a){var s,u=mi(t,n),c=mi(e,n),l=a.get(c);if(l)Rr(t,n,l);else{var f=o?o(u,c,n+"",t,e,a):void 0,h=void 0===f;if(h){var d=Zr(c),v=!d&&oi(c),p=!d&&!v&&yi(c);f=c,d||v||p?Zr(u)?f=u:Kr(s=u)&&ei(s)?f=function(t,e){var n=-1,r=t.length;for(e||(e=Array(r));++n<r;)e[n]=t[n];return e}(u):v?(h=!1,f=function(t,e){if(e)return t.slice();var n=t.length,r=Mr?Mr(n):new t.constructor(n);return t.copy(r),r}(c,!0)):p?(h=!1,f=Dr(c,!0)):f=[]:function(t){if(!Kr(t)||"[object Object]"!=ir(t))return!1;var e=Wr(t);if(null===e)return!0;var n=ci.call(e,"constructor")&&e.constructor;return"function"==typeof n&&n instanceof n&&ui.call(n)==li}(c)||Jr(c)?(f=u,Jr(u)?f=Oi(u):or(u)&&!ar(u)||(f=function(t){return"function"!=typeof t.constructor||zr(t)?{}:Vr(Wr(t))}(c))):h=!1}h&&(a.set(c,f),i(f,c,r,o,a),a.delete(c)),Rr(t,n,f)}},ji=function t(e,n,r,i,o){e!==n&&Br(n,function(a,s){if(o||(o=new Nr),or(a))Ni(e,n,s,r,t,i,o);else{var u=i?i(mi(e,s),a,s+"",e,n,o):void 0;void 0===u&&(u=a),Rr(e,s,u)}},xi)},_i=function(t){return t};var Ri=Math.max;const Bi=jr?function(t,e){return jr(t,"toString",{configurable:!0,enumerable:!1,value:(n=e,function(){return n}),writable:!0});var n}:_i;var Ii=Date.now;const Li=function(t){var e=0,n=0;return function(){var r=Ii(),i=16-(r-n);if(n=r,i>0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(Bi),Pi=function(t,e){return Li(function(t,e,n){return e=Ri(void 0===e?t.length-1:e,0),function(){for(var r=arguments,i=-1,o=Ri(r.length-e,0),a=Array(o);++i<o;)a[i]=r[e+i];i=-1;for(var s=Array(e+1);++i<e;)s[i]=r[i];return s[e]=n(a),function(t,e,n){switch(n.length){case 0:return t.call(e);case 1:return t.call(e,n[0]);case 2:return t.call(e,n[0],n[1]);case 3:return t.call(e,n[0],n[1],n[2])}return t.apply(e,n)}(t,this,s)}}(t,e,_i),t+"")},Mi=(Fi=function(t,e,n){ji(t,e,n)},Pi(function(t,e){var n=-1,r=e.length,i=r>1?e[r-1]:void 0,o=r>2?e[2]:void 0;for(i=Fi.length>3&&"function"==typeof i?(r--,i):void 0,o&&function(t,e,n){if(!or(n))return!1;var r=typeof e;return!!("number"==r?ei(n)&&ki(e,n.length):"string"==r&&e in n)&&qn(n[e],t)}(e[0],e[1],o)&&(i=r<3?void 0:i,r=1),t=Object(t);++n<r;){var a=e[n];a&&Fi(t,a,n)}return t}));var Fi;function Di(t){return Di="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Di(t)}function Hi(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Vi(r.key),r)}}function Vi(t){var e=function(t){if("object"!=Di(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=Di(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Di(e)?e:e+""}var Wi=function(){return t=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.spellcheckService=e},(e=[{key:"check",value:function(t,e){if(!t)return e(null);var n=mt(t);this.spellcheckService(n,function(t){return t&&t.length>0?e(null,t):e(null)})}}])&&Hi(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function qi(t){return qi="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},qi(t)}function Ui(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function $i(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,zi(r.key),r)}}function zi(t){var e=function(t){if("object"!=qi(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=qi(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==qi(e)?e:e+""}var Ki={A0:"no-break space",2e3:"en quad",2001:"em quad",2002:"en space",2003:"em space",2004:"three-per-em space",2005:"four-per-em space",2006:"six-per-em space",2007:"figure space",2008:"punctuation space",2009:"thin space","200A":"hair space","202F":"narrow no-break space","205F":"medium mathematical space",3e3:"ideographic space"},Qi=new RegExp("[".concat("\\u2000-\\u200A\\u202F\\u205F\\u3000","]"),"g"),Xi=function(){return t=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.marker=e},(e=[{key:"findMatches",value:function(t){var e=this;if(t)return function(t){return function(t){if(Array.isArray(t))return Ui(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return Ui(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ui(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(t.matchAll(Qi)).map(function(t){return e.prepareMatch(t)})}},{key:"prepareMatch",value:function(t){var e,n=t.index,r=(e=t[0].charCodeAt(0),"".concat(e.toString(16).toUpperCase())),i=Ki[r];return{startIndex:n,endIndex:n+t.length,match:t[0],title:"".concat(i," (\\u").concat(r,")"),marker:this.marker}}}])&&$i(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function Gi(t){return Gi="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Gi(t)}function Yi(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Ji(r.key),r)}}function Ji(t){var e=function(t){if("object"!=Gi(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=Gi(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Gi(e)?e:e+""}var Zi=function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.matches=[]},e=[{key:"addMatches",value:function(t){null!=t&&t.length&&(this.matches=function(t,e){for(var n,r=t.length,i=e.length,o=-1,a=[],s={a1:t,i1:0,a2:e,i2:0};s.i1<r||s.i2<i;)(n=to(s)).startIndex>=o&&a.push(n),o=n.endIndex;return a}(this.matches,t))}}],e&&Yi(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function to(t){var e=t.i1,n=t.i2,r=t.a1[e],i=t.a2[n];return r&&i&&r.startIndex<i.startIndex?(t.i1=e+1,r):r&&i?(t.i2=n+1,i):r?(t.i1=e+1,r):i?(t.i2=n+1,i):void 0}function eo(t){return eo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},eo(t)}function no(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return ro(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ro(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function ro(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function io(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,oo(r.key),r)}}function oo(t){var e=function(t){if("object"!=eo(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=eo(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==eo(e)?e:e+""}var ao=function(){return t=function t(e,n,r){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.editable=e,this.win=e.win,this.focusedEditableHost=void 0,this.currentlyCheckedEditableHost=void 0,this.timeout={},this.config=Mi({},{checkOnInit:!1,checkOnFocus:!1,checkOnChange:!0,throttle:1e3,removeOnCorrection:!0,spellcheck:{marker:'<span class="highlight-spellcheck"></span>',throttle:1e3,spellcheckService:function(){}},whitespace:{marker:'<span class="highlight-whitespace"></span>'}},n);var i=this.config.spellcheck.spellcheckService,o=this.config.spellcheck.marker,a=this.config.whitespace.marker,s=an.createMarkerNode(a,"whitespace",this.win);this.spellcheckMarkerNode=an.createMarkerNode(o,"spellcheck",this.win),this.spellcheckService=new Wi(i),this.whitespace=new Xi(s),this.setupListeners()},e=[{key:"setupListeners",value:function(){var t=this;this.config.checkOnFocus&&(this.editable.on("focus",function(){return t.onFocus.apply(t,arguments)}),this.editable.on("blur",function(){return t.onBlur.apply(t,arguments)})),(this.config.checkOnChange||this.config.removeOnCorrection)&&this.editable.on("change",function(){return t.onChange.apply(t,arguments)}),this.config.checkOnInit&&this.editable.on("init",function(){return t.onInit.apply(t,arguments)})}},{key:"onInit",value:function(t){this.highlight(t)}},{key:"onFocus",value:function(t){this.focusedEditableHost!==t&&(this.focusedEditableHost=t,this.editableHasChanged(t))}},{key:"onBlur",value:function(t){this.focusedEditableHost===t&&(this.focusedEditableHost=void 0)}},{key:"onChange",value:function(t){this.config.checkOnChange&&this.editableHasChanged(t,this.config.throttle),this.config.removeOnCorrection&&this.removeHighlightsAtCursor(t)}},{key:"editableHasChanged",value:function(t,e){var n=this;this.timeout.id&&this.timeout.editableHost===t&&clearTimeout(this.timeout.id);var r=setTimeout(function(){n.highlight(t),n.timeout={}},e||0);this.timeout={id:r,editableHost:t}}},{key:"highlight",value:function(t){var e=this,n=Qe.extractText(t);this.spellcheckService.check(n,function(n,r){if(!n&&t.isConnected){var i=Qe.extractText(t),o=new Zi,a=function(t,e,n){return Ye(t,e,"word",n)}(i,r,e.spellcheckMarkerNode);o.addMatches(a),a=e.whitespace.findMatches(i),o.addMatches(a),e.safeHighlightMatches(t,o.matches)}})}},{key:"safeHighlightMatches",value:function(t,e){var n=this,r=this.editable.getSelection(t);r?r.retainVisibleSelection(function(){n.highlightMatches(t,e)}):this.highlightMatches(t,e),this.editable.dispatcher&&this.editable.dispatcher.notify("spellcheckUpdated",t)}},{key:"highlightMatches",value:function(t,e){this.removeHighlights(t),e&&e.length>0&&Qe.highlightMatches(t,e)}},{key:"removeHighlights",value:function(t){t=b(t,this.win.document);var e,n=no(m('[data-highlight="spellcheck"], [data-highlight="whitespace"]',t));try{for(n.s();!(e=n.n()).done;)qt(e.value)}catch(t){n.e(t)}finally{n.f()}}},{key:"removeHighlightsAtCursor",value:function(t){t=b(t,this.win.document);var e=this.editable.getSelection(t);if(e&&e.isCursor){var n,r=e.range.startContainer;r.nodeType===h&&(r=r.parentNode);do{if(r===t)return;var i=r.getAttribute("data-highlight");if("spellcheck"===i||"whitespace"===i){n=r.getAttribute("data-word-id");break}}while(r=r.parentNode);n&&e.retainVisibleSelection(function(){var e,r=no(m('[data-word-id="'.concat(n,'"]'),t));try{for(r.s();!(e=r.n()).done;)qt(e.value)}catch(t){r.e(t)}finally{r.f()}})}}}],e&&io(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function so(){if(!1!==i.log&&t.g.console){var e=1===arguments.length?arguments[0]:Array.from(arguments);return 1!==arguments.length&&"trace"===e[e.length-1]&&(e.pop(),console.trace&&console.trace()),console.log(e)}}function uo(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function co(t){return function(t){if(Array.isArray(t))return uo(t)}(e=new y(t,"getNextTextNode"))||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(e)||function(t,e){if(t){if("string"==typeof t)return uo(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?uo(t,e):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}();var e}function lo(t){for(var e,n=t.textNodes,r=t.absOffset,i=0,o=0,a=0;a<n.length;a++){var s=n[a];if(r<=i+s.textContent.length){e=s,o=r-i;break}i+=s.textContent.length}return{node:e,relativeOffset:o}}function fo(t){t.rightLimit=t.currentOffset,t.currentOffset=Math.floor((t.currentOffset+t.leftLimit)/2)}function ho(t){t.leftLimit=t.currentOffset,t.currentOffset=Math.ceil((t.currentOffset+t.rightLimit)/2)}function vo(t){var e=lo({textNodes:t.textNodes,absOffset:t.offset}),n=e.node,r=e.relativeOffset,i=n.ownerDocument.createRange();return i.setStart(n,r),i.collapse(!0),i}function po(t){return po="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},po(t)}function go(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return yo(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?yo(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function yo(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function mo(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,bo(r.key),r)}}function bo(t){var e=function(t){if("object"!=po(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=po(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==po(e)?e:e+""}var So=function(){return t=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t);var n,r={window,defaultBehavior:!0,mouseMoveSelectionChanges:!1,browserSpellcheck:!0};this.config=Object.assign(r,e),this.win=this.config.window,this.editableSelector=".".concat(i.editableClass),this.dispatcher=new Wn(this),!0===this.config.defaultBehavior&&this.dispatcher.on((n=function(t){var e=t.win.document;return{focus:function(t){M(t)&&t.appendChild(e.createTextNode("\ufeff"))},blur:function(t){e.activeElement!==t&&bt(t)},selection:function(t,e){so(e?"Default selection behavior":"Default selection empty behavior")},cursor:function(t,e){so(e?"Default cursor behavior":"Default cursor empty behavior")},newline:function(t,n){if(n.isAtTextEnd()){var r,i=e.createElement("br");n.insertBefore(i),(null===(r=i.nextSibling)||void 0===r?void 0:r.nodeType)===h&&"\ufeff"===i.nextSibling.textContent[0]||n.insertAfter(e.createTextNode("\ufeff"))}else n.insertBefore(e.createElement("br"));n.setVisibleSelection()},insert:function(t,e,n){var r=t.parentNode,i=t.cloneNode(!1);switch(i.id&&i.removeAttribute("id"),e){case"before":r.insertBefore(i,t),t.focus();break;case"after":r.insertBefore(i,t.nextSibling),i.focus()}},split:function(t,e,n,r){var i=t.cloneNode(!1);for(i.appendChild(e),t.parentNode.insertBefore(i,t);t.firstChild;)t.removeChild(t.firstChild);t.appendChild(n),gt(i),gt(t),t.focus()},merge:function(e,n,r){var i,o;switch(n){case"before":i=re(e),o=e;break;case"after":i=e,o=ne(e)}i&&o&&(r=i.childNodes.length>0?t.appendTo(i,o.innerHTML):t.prependTo(i,o.innerHTML),o.remove(),r.save(),gt(i),r.restore(),r.setVisibleSelection())},empty:function(t){so("Default empty behavior")},switch:function(t,e,n){switch(e){case"before":var r=re(t);r&&(n.moveAtTextEnd(r),n.setVisibleSelection());break;case"after":var i=ne(t);i&&(n.moveAtBeginning(i),n.setVisibleSelection())}},move:function(t,e,n){so("Default move behavior")},paste:function(e,n,r){if(0!==n.length){if(r.insertBefore(n.shift()),0===n.length)return r.setVisibleSelection();var i=e.parentNode,o=e;n.forEach(function(t){var n=e.cloneNode(!1);n.id&&n.removeAttribute("id");var r=kt(t);n.appendChild(r),i.insertBefore(n,o.nextSibling),o=n}),t.createCursorAtEnd(o).setVisibleSelection()}},clipboard:function(t,e,n){so("Default clipboard behavior")},toggleBold:function(t){t.toggleBold()},toggleEmphasis:function(t){t.toggleEmphasis()}}}(this),{focus:function(t){n.focus(t)},blur:function(t){n.blur(t)},flow:function(t,e){n.flow(t,e)},selection:function(t,e){n.selection(t,e)},cursor:function(t,e){n.cursor(t,e)},newline:function(t,e){n.newline(t,e)},split:function(t,e,r,i){n.split(t,e,r,i)},insert:function(t,e,r){n.insert(t,e,r)},merge:function(t,e,r){n.merge(t,e,r)},empty:function(t){n.empty(t)},switch:function(t,e,r){n.switch(t,e,r)},move:function(t,e,r){n.move(t,e,r)},clipboard:function(t,e,r){n.clipboard(t,e,r)},paste:function(t,e,r){n.paste(t,e,r)},toggleBold:function(t){n.toggleBold(t)},toggleEmphasis:function(t){n.toggleEmphasis(t)}}))},e=[{key:"add",value:function(t,e){return this.enable(t,e),this}},{key:"remove",value:function(t){var e=m(t,this.win.document);this.disable(e);var n,r=go(e);try{for(r.s();!(n=r.n()).done;)n.value.classList.remove(i.editableDisabledClass)}catch(t){r.e(t)}finally{r.f()}return this}},{key:"disable",value:function(t){var e,n=go(m(t||".".concat(i.editableClass),this.win.document));try{for(n.s();!(e=n.n()).done;)oe(e.value)}catch(t){n.e(t)}finally{n.f()}return this}},{key:"enable",value:function(t,e){var n,r=null!=e?e:{},o=r.normalize,a=void 0===o?"boolean"==typeof e&&e:o,s=r.plainText,u=void 0!==s&&s,c=this.config.browserSpellcheck,l=go(m(t||".".concat(i.editableDisabledClass),this.win.document));try{for(l.s();!(n=l.n()).done;){var f=n.value;ie(f,{normalize:a,plainText:u,shouldSpellcheck:c}),this.dispatcher.notify("init",f)}}catch(t){l.e(t)}finally{l.f()}return this}},{key:"suspend",value:function(t){var e,n=go(m(t||".".concat(i.editableClass),this.win.document));try{for(n.s();!(e=n.n()).done;)e.value.removeAttribute("contenteditable")}catch(t){n.e(t)}finally{n.f()}return this.dispatcher.suspend(),this}},{key:"continue",value:function(t){var e,n=go(m(t||".".concat(i.editableClass),this.win.document));try{for(n.s();!(e=n.n()).done;)e.value.setAttribute("contenteditable",!0)}catch(t){n.e(t)}finally{n.f()}return this.dispatcher.continue(),this}},{key:"createCursor",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"beginning",n=$e.findHost(t,this.editableSelector);if(n){var r=k();return"beginning"===e||"end"===e?(r.selectNodeContents(t),r.collapse("beginning"===e)):t!==n?"before"===e?(r.setStartBefore(t),r.setEndBefore(t)):"after"===e&&(r.setStartAfter(t),r.setEndAfter(t)):o("EditableJS: cannot create cursor outside of an editable block."),new $e(n,r)}}},{key:"createCursorAtCharacterOffset",value:function(t){var e=t.element,n=t.offset,r=lo({textNodes:co(e),absOffset:n}),i=r.node,o=r.relativeOffset,a=k();a.setStart(i,o),a.collapse(!0);var s=$e.findHost(e,this.editableSelector),u=new $e(s,a);return u.setVisibleSelection(),u}},{key:"createCursorAtBeginning",value:function(t){return this.createCursor(t,"beginning")}},{key:"createCursorAtEnd",value:function(t){return this.createCursor(t,"end")}},{key:"createCursorBefore",value:function(t){return this.createCursor(t,"before")}},{key:"createCursorAfter",value:function(t){return this.createCursor(t,"after")}},{key:"getContent",value:function(t){return St(t)}},{key:"appendTo",value:function(t,e){var n=Ct(t,this.win.document),r=this.createCursor(n,"end");return r.insertAfter("string"==typeof e?kt(e):e),r}},{key:"prependTo",value:function(t,e){var n=Ct(t,this.win.document),r=this.createCursor(n,"beginning");return r.insertBefore("string"==typeof e?kt(e):e),r}},{key:"getSelection",value:function(t){var e=this.dispatcher.selectionWatcher.getFreshSelection();if(!t||!e)return e;var n=e.range;return null!=t&&t.isConnected&&function(t,e){var n=document.createRange();n.selectNodeContents(t);var r=e.compareBoundaryPoints(Range.START_TO_START,n),i=e.compareBoundaryPoints(Range.END_TO_END,n);return r>=0&&i<=0}(t,n)?e:void 0}},{key:"setupHighlighting",value:function(t){return this.highlighting=new ao(this,t),this}},{key:"setupSpellcheck",value:function(t){var e,n=this;t.markerNode&&(e=t.markerNode.outerHTML),this.setupHighlighting({throttle:t.throttle,spellcheck:{marker:e,spellcheckService:t.spellcheckService}}),this.spellcheck={checkSpelling:function(t){n.highlighting.highlight(t)}}}},{key:"highlight",value:function(t){var e=t.editableHost,n=t.text,r=t.highlightId,i=t.textRange,a=t.raiseEvents,s=t.type,u=void 0===s?"comment":s;return i?"number"!=typeof i.start||"number"!=typeof i.end?(o("Error in Editable.highlight: You passed a textRange object with invalid keys. Expected shape: { start: Number, end: Number }"),-1):i.start===i.end?(o("Error in Editable.highlight: You passed a textRange object with equal start and end offsets, which is considered a cursor and therefore unfit to create a highlight."),-1):an.highlightRange(e,n,r,i.start,i.end,a?this.dispatcher:void 0,u):an.highlightText(e,n,r,u,a?this.dispatcher:void 0)}},{key:"getHighlightPositions",value:function(t){var e=t.editableHost,n=t.type;return an.extractHighlightedRanges(e,n)}},{key:"removeHighlight",value:function(t){var e=t.editableHost,n=t.highlightId,r=t.raiseEvents;an.removeHighlight(e,n,r?this.dispatcher:void 0)}},{key:"decorateHighlight",value:function(t){var e=t.editableHost,n=t.highlightId,r=t.addCssClass,i=t.removeCssClass;an.updateHighlight(e,n,r,i)}},{key:"on",value:function(t,e){return this.dispatcher.on(t,e),this}},{key:"off",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return this.dispatcher.off.apply(this.dispatcher,e),this}},{key:"unload",value:function(){return this.dispatcher.unload(),this}},{key:"findClosestCursorOffset",value:function(t){var e=t.element,n=t.origCoordinates,r=t.requiredOnFirstLine,i=void 0!==r&&r,o=t.requiredOnLastLine;return function(t){var e=t.host,n=t.requiredOnFirstLine,r=t.requiredOnLastLine,i=t.positionX,o=e.ownerDocument.createRange();o.selectNodeContents(e);var a=o.getBoundingClientRect(),s=co(e).reduce(function(t,e){return t+e.textContent.length},0),u=co(e);if(0===s)return{wasFound:!1};for(var c,l={currentOffset:Math.floor(s/2),leftLimit:0,rightLimit:s},f=l.currentOffset,h=20;l.leftLimit<l.rightLimit&&h>0;){h=h-=1,f=l.currentOffset;var d=vo({textNodes:u,offset:l.currentOffset}).getBoundingClientRect();c=Math.abs(d.left-i),n&&a.top!==d.top?fo(l):r&&a.bottom!==d.bottom?ho(l):i<d.left?fo(l):ho(l)}var v=vo({textNodes:u,offset:l.currentOffset}).getBoundingClientRect(),p=Math.abs(v.left-i);return p<c&&(c=p,f=l.currentOffset),{distance:c,offset:f,wasFound:!0}}({host:e,requiredOnFirstLine:i,requiredOnLastLine:void 0!==o&&o,positionX:this.dispatcher.switchContext?this.dispatcher.switchContext.positionX:n.left})}}],n=[{key:"getGlobalConfig",value:function(){return i}},{key:"globalConfig",value:function(t){Object.assign(i,t),Re(i)}}],e&&mo(t.prototype,e),n&&mo(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,n}();return So.parser=n,So.content=r,["focus","blur","flow","selection","cursor","newline","insert","split","merge","empty","change","switch","move","clipboard","paste","spellcheckUpdated","selectToBoundary"].forEach(function(t){So.prototype[t]=function(e){return this.on(t,e)}}),e=e.Editable,e})());
1
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Editable=e():t.Editable=e()}(self,()=>(()=>{"use strict";const t={d:(e,n)=>{for(var r in n)t.o(n,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})}};t.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),t.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),t.r=t=>{Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};let e={};t.d(e,{Editable:()=>Ho});var n={};t.r(n),t.d(n,{getHost:()=>I,getNodeIndex:()=>P,isBeginningOfHost:()=>W,isDocumentFragmentWithoutChildren:()=>Y,isEndOfHost:()=>q,isEndOffset:()=>$,isInlineElement:()=>J,isLinebreak:()=>D,isSameNode:()=>Q,isStartOffset:()=>U,isTextEndOfHost:()=>z,isTextEndOffset:()=>K,isVoid:()=>L,isVoidTextNode:()=>H,isWhitespaceOnly:()=>F,lastChild:()=>X,lastOffsetWithContent:()=>V,latestChild:()=>G});var r={};t.r(r),t.d(r,{adoptElement:()=>qt,areSameAttributes:()=>Yt,cleanInternals:()=>Ft,cloneRangeContents:()=>Ut,containsString:()=>ye,createFragmentFromString:()=>Wt,deleteCharacter:()=>ge,expandTo:()=>ie,extractContent:()=>Dt,forceWrap:()=>se,getAncestorTags:()=>Qt,getContainedTags:()=>Zt,getInnerHtmlOfFragment:()=>Vt,getInnerTags:()=>Jt,getTagNames:()=>te,getTags:()=>Kt,getTagsByName:()=>Xt,getTagsByNameAndAttributes:()=>Gt,insertCharacter:()=>ve,isAffectedBy:()=>ee,isExactSelection:()=>re,isWrappable:()=>ae,normalizeTags:()=>Lt,normalizeWhitespace:()=>Ht,nuke:()=>he,nukeElem:()=>de,nukeTag:()=>me,removeFormatting:()=>fe,removeFormattingElem:()=>le,selectNodeContents:()=>ne,surround:()=>pe,tidyHtml:()=>Pt,toggleTag:()=>oe,unwrap:()=>ce,unwrapInternalNodes:()=>zt,wrap:()=>ue});const i={log:!1,logErrors:!0,editableClass:"js-editable",editableDisabledClass:"js-editable-disabled",pastingAttribute:"data-editable-is-pasting",trimLeadingAndTrailingWhitespaces:!0,boldMarkup:{type:"tag",name:"strong",attribs:{},trim:!0},italicMarkup:{type:"tag",name:"em",attribs:{},trim:!0},underlineMarkup:{type:"tag",name:"u",attribs:{},trim:!1},linkMarkup:{type:"tag",name:"a",attribs:{},trim:!0},pastedHtmlRules:{allowedElements:{a:{href:!0,rel:!0,target:!0},strong:{},em:{},br:{}},allowedPlainTextElements:{br:{}},requiredAttributes:{a:["href"]},transformElements:{b:"strong",i:"em"},splitIntoBlocks:["h1","h2","h3","h4","h5","h6","p","blockquote"],blockLevelElements:["h1","h2","h3","h4","h5","h6","div","p","pre","hr","blockquote","article","figure","header","footer","ul","ol","li","section","table","video"],blacklistedElements:["style","script"],keepInternalRelativeLinks:!1,replaceQuotes:{}}};function o(){if(!1!==i.logErrors){var e=1===arguments.length?arguments[0]:Array.from(arguments);if(t.g.console)return"function"==typeof console.error?console.error(e):void console.log(e)}}var a=Object.prototype.toString,s={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function u(t){return t.replace(/\s+$/,"")}function c(t){return t.replace(/^\s+|\s+$/g,"")}function l(t){return"[object String]"===a.call(t)}var f=1,h=3,d=11;function v(t){return v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},v(t)}function p(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,g(r.key),r)}}function g(t){var e=function(t){if("object"!=v(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=v(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==v(e)?e:e+""}var y=function(){return t=function t(e,n){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.current=this.previous=this.nextNode=this.root=e,this.iteratorFunc=this[n||"getNext"]},(e=[{key:Symbol.iterator,value:function(){return this}},{key:"getNextTextNode",value:function(){for(var t;t=this.getNext();)if(t.nodeType===h&&""!==t.data)return t}},{key:"getPreviousTextNode",value:function(){for(var t;t=this.getPrevious();)if(t.nodeType===h&&""!==t.data)return t}},{key:"next",value:function(){var t=this.iteratorFunc();return t?{value:t}:{done:!0}}},{key:"getNext",value:function(){var t=this.current=this.nextNode,e=this.nextNode=void 0;if(this.current)if((e=t.firstChild)&&"remove"!==t.getAttribute("data-editable"))this.nextNode=e;else for(;t!==this.root&&!(this.nextNode=t.nextSibling);)t=t.parentNode;return this.current}},{key:"getPrevious",value:function(){var t=this.current=this.previous,e=this.previous=void 0;if(this.current)if((e=t.lastChild)&&"remove"!==t.getAttribute("data-editable"))this.previous=e;else for(;t!==this.root&&!(this.previous=t.previousSibling);)t=t.parentNode;return this.current}},{key:"replaceCurrent",value:function(t){this.current=t,this.nextNode=void 0,this.previous=void 0;for(var e=this.current;e!==this.root&&!(this.nextNode=e.nextSibling);)e=e.parentNode}}])&&p(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}(),m=function(t,e){return"string"==typeof t?Array.from(e.querySelectorAll(t)):t.tagName?[t]:Array.isArray(t)?t:Array.from(t)},b=function(t,e){return"string"==typeof t?e.querySelector(t):t.tagName?t:t[0]?t[0]:t},w=function(t){var e=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:window).document.createElement("div");return e.innerHTML=t,e.firstElementChild},S=function(t,e){if(t.closest||(t=t.parentNode),t&&t.closest)return t.closest(e)},k=function(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:window).document.createRange()},C=function(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:window).document.getSelection()},A=function(t,e,n){for(var r,i=[],o=(arguments.length>3&&void 0!==arguments[3]?arguments[3]:window).document.createNodeIterator(t.commonAncestorContainer,NodeFilter.SHOW_ALL,{acceptNode:function(r){return t.intersectsNode(r)&&e.includes(r.nodeType)&&r!==t.commonAncestorContainer?"function"==typeof n?n(r)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}},!1);r=o.nextNode();)i.push(r);return i},E=function(t){t.startContainer.compareDocumentPosition(t.endContainer)===Node.DOCUMENT_POSITION_FOLLOWING&&t.setStartBefore(t.endContainer),t.endContainer.compareDocumentPosition(t.startContainer)===Node.DOCUMENT_POSITION_PRECEDING&&t.setEndAfter(t.startContainer)},T=function(t,e){var n=document.createRange();n.selectNodeContents(e);var r=t.compareBoundaryPoints(Range.START_TO_START,n),i=t.compareBoundaryPoints(Range.END_TO_END,n);return r<=0&&i>=0},x=function(t){return t&&(t.nodeType===Node.TEXT_NODE||t.nodeType===Node.COMMENT_NODE)},O=function(t,e){return t.splitText(e)},N=function(t){var e=t.startContainer,n=t.startOffset,r=t.endContainer,i=t.endOffset;if(x(r)&&i>0&&i<r.length&&O(r,i),x(e)&&n>0&&n<e.length){var o=O(e,n);t.setStart(o,0)}},j=function(t,e){var n=t.cloneRange();n.setStart(e,0),n.setEnd(t.startContainer,t.startOffset);var r=t.toString().replace(/\uFEFF/g,""),i=n.toString().length;return{start:i,end:i+r.length,text:r}},_=function(t,e){return t.startContainer===e.startContainer&&t.startOffset===e.startOffset&&t.endContainer===e.endContainer&&t.endOffset===e.endOffset};function R(t){var e=t.root,n=t.startContainer,r=t.startOffset,i=t.whitespacesOnTheLeft;if(n.nodeType!==h)return R({root:e,startContainer:n.childNodes[r],startOffset:0,whitespacesOnTheLeft:i});var o=r+i;if(n.length>o)return[n,o];var a=new y(e);a.nextNode=n,a.getNextTextNode();var s=a.getNextTextNode();if(!s){var u=a.getPreviousTextNode();return[u,u.length]}return R({root:e,startContainer:s,startOffset:0,whitespacesOnTheLeft:o-n.length})}function B(t){var e=t.root,n=t.endContainer,r=t.endOffset,i=t.whitespacesOnTheRight;if(n.nodeType!==h){var o=!n.childNodes[r-1],a=o?n.childNodes[r]:n.childNodes[r-1],s=0;return o||(s=a.nodeType===h?a.length:a.childNodes.length),B({root:e,endContainer:a,endOffset:s,whitespacesOnTheRight:i})}var u=r-i;if(u>0)return[n,u];var c=new y(e);c.previous=n,c.getPreviousTextNode();var l=c.getPreviousTextNode();return l?B({root:e,endContainer:l,endOffset:l.length,whitespacesOnTheRight:i-r}):[c.getNextTextNode(),0]}function M(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function I(t){return t=t.jquery?t[0]:t,S(t,".".concat(i.editableClass))}function P(t){for(var e=0;null!==(t=t.previousSibling);)e++;return e}function L(t){var e,n=function(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return M(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?M(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}(t.childNodes);try{for(n.s();!(e=n.n()).done;){var r=e.value;if(r.nodeType===h&&!H(r))return!1;if(r.nodeType===f)return!1}}catch(t){n.e(t)}finally{n.f()}return!0}function H(t){return t.nodeType===h&&!t.nodeValue}function F(t){return t.nodeType===h&&0===V(t)}function D(t){return t.nodeType===f&&"BR"===t.tagName}function V(t){if(t.nodeType===h)return u(t.nodeValue).length;var e=0;return Array.from(t.childNodes).reverse().every(function(t,n,r){return!(!F(t)&&!D(t)&&(e=r.length-n,1))}),e}function W(t,e,n){if(e===t)return U(e,n);if(U(e,n)){var r=P(e);return W(t,e.parentNode,r)}return!1}function q(t,e,n){if(e===t)return $(e,n);if($(e,n)){var r=P(e)+1;return q(t,e.parentNode,r)}return!1}function U(t,e){return t.nodeType===h?0===e:0===t.childNodes.length||1===t.childNodes.length&&t.firstChild.nodeType===f&&"remove"===t.firstChild.getAttribute("data-editable")||t.childNodes[e]===t.firstChild}function $(t,e){return t.nodeType===h?e===t.length:0===t.childNodes.length||e>0&&t.childNodes[e-1]===t.lastChild}function z(t,e,n){if(e===t)return K(e,n);if(K(e,n)){var r=P(e)+1;return z(t,e.parentNode,r)}return!1}function K(t,e){return t.nodeType===h?e>=u(t.nodeValue).length:0===t.childNodes.length||e>=V(t)}function Q(t,e){var n,r,i;if(t.nodeType!==e.nodeType)return!1;if(t.nodeName!==e.nodeName)return!1;for(n=0,r=t.attributes.length;n<r;n++)if(i=t.attributes[n],e.getAttribute(i.name)!==i.value)return!1;return!0}function X(t){return t.lastChild?X(t.lastChild):t}function G(t){return console.warn("Editable.js: Using obsolete function parser.latestCild(), use lastChild() instead"),X(t)}function Y(t){return t&&t.nodeType===d&&0===t.childNodes.length}function J(t,e){switch((e.currentStyle||t.getComputedStyle(e,"")).display){case"inline":case"inline-block":return!0;default:return!1}}var Z=0,tt="\ufeff";function et(t,e){var n=t.commonAncestorContainer;if(3===n.nodeType)return!1;var r=e.parentElement;return(null==r?void 0:r.parentElement)===n}function nt(t,e){var n=t.commonAncestorContainer;n.ownerDocument||o("Cannot save range: range is empty");var r=n.ownerDocument.defaultView.document,i=r.createElement("span");i.id="editable-range-boundary-".concat(++Z),i.setAttribute("data-editable","remove"),i.style.lineHeight="0",i.style.display="none",i.appendChild(r.createTextNode(tt));var a=e&&et(t,t.startContainer),s=!e&&et(t,t.endContainer);if(a){var u=t.startContainer.parentElement;u.parentElement.insertBefore(i,u)}else if(s){var c=t.endContainer.parentElement;c.parentElement.insertBefore(i,c.nextSibling)}else{var l=t.cloneRange();l.collapse(e),l.insertNode(i)}return i}function rt(t,e,n,r){var i=at(t,n);if(!i)return console.log("Marker element has been removed. Cannot restore selection.");e[r?"setStartBefore":"setEndBefore"](i),i.remove()}function it(t){var e,n,r;return t.collapsed?e={markerId:(r=nt(t,!1)).id,collapsed:!0}:(r=nt(t,!1),e={startMarkerId:(n=nt(t,!0)).id,endMarkerId:r.id,collapsed:!1}),t.collapsed?(t.setStartBefore(r),t.collapse(!0)):(t.setEndBefore(r),t.setStartAfter(n)),e}function ot(t,e){if(!e.restored){var n=k();if(e.collapsed){var r=at(t,e.markerId);if(r){r.style.display="inline";var i=r.previousSibling;i&&i.nodeType===h?(r.remove(),n.setStart(i,i.length)):(n.setStartBefore(r),n.collapse(!0),r.remove())}else console.log("Marker element has been removed. Cannot restore selection.")}else rt(t,n,e.startMarkerId,!0),rt(t,n,e.endMarkerId,!1);return E(n),n}}function at(t,e){return t.querySelector("#".concat(e))}function st(t){return{x:void 0!==t.pageXOffset?t.pageXOffset:(t.document.documentElement||t.document.body.parentNode||t.document.body).scrollLeft,y:void 0!==t.pageYOffset?t.pageYOffset:(t.document.documentElement||t.document.body.parentNode||t.document.body).scrollTop}}function ut(t,e){return ut=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},ut(t,e)}function ct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(ct=function(){return!!t})()}function lt(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,o,a,s=[],u=!0,c=!1;try{if(o=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=o.call(n)).done)&&(s.push(r.value),s.length!==e);u=!0);}catch(t){c=!0,i=t}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw i}}return s}}(t,e)||ht(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ft(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=ht(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function ht(t,e){if(t){if("string"==typeof t)return dt(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?dt(t,e):void 0}}function dt(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}var vt=new WeakMap,pt=/[\uFEFF\u200B]/g,gt=function(t){return"\ufeff"===t||"​"===t},yt=function(t){return t.indexOf("\ufeff")>=0||t.indexOf("​")>=0},mt=function(t){return yt(t)?t.replace(pt,""):t};function bt(t){var e,n=t.editableHost,r=t.win,i=void 0===r?null==n||null===(e=n.ownerDocument)||void 0===e?void 0:e.defaultView:r,o=vt.get(i);if(null!=o&&o.size){var a,s=ft(o);try{for(s.s();!(a=s.n()).done;){var u=lt(a.value,2),c=u[0],l=u[1];if(l.has(n)){var f,h=ft(l.keys());try{for(h.s();!(f=h.n()).done;){var d=f.value;null!=d&&d.isConnected||l.delete(d)}}catch(t){h.e(t)}finally{h.f()}l.size?kt({name:c,hosts:l,win:i}):St({name:c,win:i})}}}catch(t){s.e(t)}finally{s.f()}}}function wt(t){var e=t.editableHost,n=t.start,r=t.end,i=t.win,o=void 0===i?window:i;return At({segments:Ct(e).segments,start:n,end:r,win:o})}function St(t){var e,n=t.name,r=t.win,i=void 0===r?window:r;null===(e=vt.get(i))||void 0===e||e.delete(n),i.CSS.highlights.delete(n)}function kt(t){var e,n=t.name,r=t.hosts,i=t.win,o=[],a=ft(r);try{for(a.s();!(e=a.n()).done;){var s=lt(e.value,2),u=s[0],c=s[1],l=Ct(u).segments;if(l.length){var f,h=ft(c);try{for(h.s();!(f=h.n()).done;){var d=f.value,v=At({segments:l,start:d.start,end:d.end,win:i});v&&o.push(v)}}catch(t){h.e(t)}finally{h.f()}}}}catch(t){a.e(t)}finally{a.f()}if(!o.length)return i.CSS.highlights.delete(n);i.CSS.highlights.set(n,function(t,e,n){if(ct())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,e);var i=new(t.bind.apply(t,r));return n&&ut(i,n.prototype),i}(i.Highlight,o))}function Ct(t){var e,n=[],r="",i=function(t,e,i){n.push({node:t,nodeOffset:e,start:r.length,end:r.length+i.length}),r+=i},o=ft(new y(t));try{for(o.s();!(e=o.n()).done;){var a=e.value;if(a.nodeType!==f||"BR"!==a.nodeName){if(a.nodeType===h&&""!==a.data){var s=a.data;if(yt(s)){for(var u=0,c=0,l=0;l<s.length;l++)gt(s[l])?(c&&i(a,u,s.slice(u,u+c)),c=0):(0===c&&(u=l),c+=1);c&&i(a,u,s.slice(u,u+c))}else i(a,0,s)}}else r+="\n"}}catch(t){o.e(t)}finally{o.f()}for(var d=r.length-r.trimStart().length,v=r.trimEnd().length,p=[],g=0,m=n;g<m.length;g++){var b=m[g],w=Math.max(b.start,d),S=Math.min(b.end,v);w>=S||p.push({node:b.node,nodeOffset:b.nodeOffset+(w-b.start),start:w-d,end:S-d})}return{text:r.slice(d,Math.max(d,v)),leading:d,segments:p}}function At(t){var e=t.segments,n=t.start,r=t.end,i=t.win,o=Et(e,n,!1),a=Et(e,r,!0);if(o&&a){var s=k(i);return s.setStart(o.node,o.offset),s.setEnd(a.node,a.offset),s}}function Et(t,e,n){for(var r=0,i=t.length;r<i;){var o=r+i>>1,a=t[o].end;(n?a>=e:a>e)?i=o:r=o+1}var s=t[r];if(s)return{node:s.node,offset:s.nodeOffset+Math.max(0,e-s.start)}}function Tt(t,e,n){return{top:t.top+n,bottom:t.bottom+n,left:t.left+e,right:t.right+e,width:t.width,height:t.height}}function xt(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return Ot(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ot(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function Ot(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function Nt(t,e,n){return e=it(e),n(),ot(t,e)}var jt=/\u200B/g,_t=/\uFEFF/g,Rt=/[^\S ]/g,Bt=/^\s+$/,Mt=/^\s+/,It=/\s+$/;function Pt(t){Lt(t)}function Lt(t){var e=document.createDocumentFragment();$t(t,"firstChild"),$t(t,"lastChild");var n,r=xt(t.childNodes);try{for(r.s();!(n=r.n()).done;){var i=n.value;if("BR"===i.nodeName||i.textContent){if(i.nodeType===f&&"BR"!==i.nodeName){for(var o=i;null!==(o=o.nextSibling)&&Q(o,i);){var a,s=xt(o.childNodes);try{for(s.s();!(a=s.n()).done;){var u=a.value;i.appendChild(u.cloneNode(!0))}}catch(t){s.e(t)}finally{s.f()}o.remove()}Lt(i)}e.appendChild(i.cloneNode(!0))}}}catch(t){r.e(t)}finally{r.f()}for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(e)}function Ht(t){return t.replace(Rt," ")}function Ft(t){t.innerHTML=Dt(t,!0),bt({editableHost:t})}function Dt(t,e){var n=(t.nodeType===d?Vt(t):t.innerHTML).replace(_t,"").replace(jt,""),r=document.createElement("div");return r.innerHTML=n,zt(r,e),$t(r,"firstChild"),$t(r,"lastChild"),r.innerHTML}function Vt(t){var e=t.cloneNode(!0),n=document.createElement("div");return n.appendChild(e),n.innerHTML}function Wt(t){var e=document.createElement("div");e.innerHTML=t;for(var n=document.createDocumentFragment();e.firstChild;)n.appendChild(e.firstChild);return n}function qt(t,e){return t.ownerDocument!==e?e.adoptNode(t):t}function Ut(t){for(var e=t.cloneContents().childNodes[0],n=document.createDocumentFragment();e.childNodes.length;)n.appendChild(e.childNodes[0]);return n}function $t(t,e){for(var n,r,o=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];r=t[e];)if(r.nodeType===h){if(!Bt.test(r.textContent))break;t.removeChild(r)}else{if("BR"!==r.nodeName){r[e]&&$t(r,e,!1);break}r.remove()}o&&(null===(n=r=t[e])||void 0===n?void 0:n.nodeType)===h&&i.trimLeadingAndTrailingWhitespaces&&(r.textContent=r.textContent.replace(e.startsWith("last")?It:Mt,""))}function zt(t,e){for(;t;){var n=t.nextSibling;if(t.nodeType===f){var r=t.getAttribute("data-editable");t.firstChild&&zt(t.firstChild,e),("remove"===r||"ui-remove"===r&&!e)&&t.remove(),("unwrap"===r||"ui-unwrap"===r&&!e)&&ce(t),t=n}else t=n}}function Kt(t,e,n){var r=Jt(e,n),i=Qt(t,e,n);return r.concat(i)}function Qt(t,e,n){for(var r=[],i=e.commonAncestorContainer;i!==t;)n&&!n(i)||r.push(i),i=i.parentNode;return r}function Xt(t,e,n){return Kt(t,e,function(t){return t.nodeName.toUpperCase()===n.toUpperCase()})}function Gt(t,e,n){return Kt(t,e,function(t){return t.nodeName.toUpperCase()===n.nodeName.toUpperCase()&&Yt(t.attributes,n.attributes)})}function Yt(t,e){if(t.length!==e.length)return!1;for(var n=0;n<t.length;n++){var r=e[t[n].name];if(!r||r.value!==t[n].value)return!1}return!0}function Jt(t,e){return A(t,[f],e)}function Zt(t,e){return A(t,[f],e).filter(function(e){return T(t,e)})}function te(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).map(function(t){return t.nodeName})}function ee(t,e,n){return Kt(t,e).some(function(t){return t.nodeName===n.toUpperCase()})}function ne(t){var e=k();return e.selectNodeContents(t),e}function re(t,e,n){var r,i,o=k();if(o.selectNodeContents(e),i=o,-1!==(r=t).compareBoundaryPoints(Range.END_TO_START,i)||-1!==i.compareBoundaryPoints(Range.END_TO_START,r))return!1;var a=t.toString(),s=(e.jquery?e[0]:e).textContent;return n&&(a=c(a),s=c(s)),""!==a&&a===s}function ie(t,e,n){return e.selectNodeContents(n),e}function oe(t,e,n){var r=Gt(t,e,n);return 1===r.length&&re(e,r[0],"visible")?le(t,e,n):se(t,e,n)}function ae(t){return function(t){if(!t||!t.startContainer||!t.endContainer)return!1;if(t.startContainer===t.endContainer)return!0;for(var e,n=function(t){var e=t,n=null;return{next:function(){if(!e)return null;if(e.firstChild&&n!==e.firstChild)n=e,e=e.firstChild;else if(e.nextSibling)n=e,e=e.nextSibling;else{for(var r=e.parentNode;r&&r!==t;){if(r.nextSibling){n=e=r.nextSibling;break}r=r.parentNode}r&&r!==t||(n=e=null)}return e}}}(t.commonAncestorContainer),r=!1;e=n.next();)if(e.nodeType===Node.ELEMENT_NODE&&!be(e,t)){r=!0;break}return!r}(t)}function se(t,e,n){var r=Nt(t,e,function(){de(t,e,n)});return ae(r)||(r=Nt(t,r,function(){he(t,r)})),ue(r,n),bt({editableHost:t}),r}function ue(t,e){ae(t)?("string"==typeof e&&(e=w(e)),t.surroundContents(e)):console.log("content.wrap(): can not surround range")}function ce(t){for(var e=(t=t.jquery?t[0]:t).parentNode;t.firstChild;)e.insertBefore(t.firstChild,t);e.removeChild(t)}function le(t,e,n){var r=Nt(t,e,function(){de(t,e,n)});return bt({editableHost:t}),r}function fe(t,e,n){var r=Nt(t,e,function(){he(t,e,n)});return bt({editableHost:t}),r}function he(t,e,n){Kt(t,e).forEach(function(t){"BR"===t.nodeName.toUpperCase()||n&&!t.matches(n)||ce(t)})}function de(t,e,n){Kt(t,e).forEach(function(t){"BR"!==t.nodeName.toUpperCase()&&(!n||t.nodeName.toUpperCase()===n.nodeName.toUpperCase()&&Yt(t.attributes,n.attributes))&&ce(t)})}function ve(t,e,n){var r=document.createTextNode(e),i=t.cloneRange();i.collapse(n),i.insertNode(r),t[n?"setStartBefore":"setEndAfter"](r),E(t)}function pe(t,e,n,r){return ve(e,r||n,!1),ve(e,n,!0),e}function ge(t,e,n){if(!ye(e,n))return e;window.getSelection().rangeCount>0&&N(e);var r=Nt(t,e,function(){A(e,[h],function(t){return t.nodeValue.indexOf(n)>=0}).forEach(function(t){t.nodeValue=t.nodeValue.replaceAll(n,"")})});return E(r),r}function ye(t,e){return t.toString().indexOf(e)>=0}function me(t,e,n){Kt(t,e).forEach(function(t){t.nodeName.toUpperCase()===n.toUpperCase()&&ce(t)})}function be(t,e){var n=document.createRange();return n.selectNodeContents(t),e.compareBoundaryPoints(Range.START_TO_START,n)<=0&&e.compareBoundaryPoints(Range.END_TO_END,n)>=0}var we=1,Se={},ke=xe("nextElementSibling"),Ce=xe("previousElementSibling");function Ae(t,e){var n=e.normalize,r=e.plainText,o=e.shouldSpellcheck;!function(t){t.hasAttribute("data-editable")||(t.setAttribute("data-editable","id-".concat(we)),we+=1)}(t),t.setAttribute("contenteditable",!0),t.setAttribute("spellcheck",Boolean(o)),t.setAttribute("data-plaintext",Boolean(r)),t.classList.remove(i.editableDisabledClass),t.classList.add(i.editableClass),n&&Pt(t)}function Ee(t){t.removeAttribute("contenteditable"),t.removeAttribute("spellcheck"),t.removeAttribute("data-plaintext"),function(t){if(t.hasAttribute("data-editable")){var e=t.getAttribute("data-editable");Se[e]=void 0}}(t),t.classList.remove(i.editableClass),t.classList.add(i.editableDisabledClass)}function Te(t){return"true"===t.getAttribute("data-plaintext")}function xe(t){return function(e){var n=e[t];return n&&n.getAttribute("contenteditable")?n:null}}function Oe(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}var Ne,je,_e,Re,Be,Me,Ie,Pe,Le,He=[["«","»"],["»","«"],['"','"'],["“","”"],["”","”"],["“","“"],["„","“"]],Fe=[["‘","’"],["‹","›"],["‚","‘"],["’","’"],["›","‹"],["'","'"],["‘","’"]],De=["’","'"],Ve=/([‘’‹›‚'«»"“”„])(?![^<]*?>)/g,We=/\s|[>\-–—«»”"“„]/,qe=/\s|[<\-–—«»”"“‘’‹›'.;?:,]/;function Ue(t,e){(Ne=e||{}).quotes=Ne.quotes||[void 0,void 0],Ne.singleQuotes=Ne.singleQuotes||[void 0,void 0];var n=function(t){return(e=t.matchAll(Ve),function(t){if(Array.isArray(t))return Oe(t)}(e)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(e)||function(t,e){if(t){if("string"==typeof t)return Oe(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Oe(t,e):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).map(function(e){var n=e.index;return{char:e[1],before:n>0?t[n-1]:"",after:n+1<t.length?t[n+1]:""}});var e}(t);return n.length>0?($e(n,0),function(t,e){var n=0;return t.replace(Ve,function(t){var r=e[n].replace||e[n].char;return n+=1,r})}(t,n)):t}function $e(t,e){for(;e<t.length;){var n=ze(t,e);if(n){if(t[e].replace="double"===n.type?Ne.quotes[0]:Ne.singleQuotes[0],t[n.position].replace="double"===n.type?Ne.quotes[1]:Ne.singleQuotes[1],n.position!==e+1){var r=t.slice(e+1,n.position);r&&$e(r,0)}e=n.position+1}else t[e].replace=Qe(t[e].char),e+=1}}function ze(t,e){if(e!==t.length-1){var n=t[e],r=n.char;if(!n.before||We.test(n.before))for(var i=Ke(r,Fe),o=Ke(r,He),a=e+1;a<t.length;a++)if(t[a].after&&qe.test(t[a].after)||!t[a].after){if(i.includes(t[a].char))return{position:a,type:"single"};if(o.includes(t[a].char))return{position:a,type:"double"}}}}function Ke(t,e){return e.filter(function(e){return e[0]===t}).map(function(t){return t[1]})}function Qe(t){if(De.includes(t))return Ne.apostrophe}var Xe,Ge=/^\s*$/,Ye="\x3c!-- BLOCK --\x3e";function Je(t){var e=t.pastedHtmlRules;je=e.allowedElements||{},_e=e.allowedPlainTextElements||{},Re=e.requiredAttributes||{},Be=e.transformElements||{},Le=e.blacklistedElements||[],Xe=e.keepInternalRelativeLinks||!1,Ie=e.replaceQuotes||{},Me={},e.blockLevelElements.forEach(function(t){Me[t]=!0}),Pe={},e.splitIntoBlocks.forEach(function(t){Pe[t]=!0})}function Ze(t,e,n){var r=t.ownerDocument;t.setAttribute(i.pastingAttribute,!0),e.isSelection&&(e=e.deleteExactSurroundingTags().deleteContainedTags().deleteContent());var o=r.createElement("div");o.innerHTML=n;var a=function(t){var e=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).plainText,n=void 0!==e&&e;return tn(t,{allowedElements:n?_e:je,keepInternalRelativeLinks:!n&&Xe}).split(Ye).map(function(t){return c((e=t,Ie.quotes||Ie.singleQuotes||Ie.apostrophe?Ue(e,Ie):e).replace(/\n/g," ").replace(/ {2,}/g," ").replace(/(.)\u00A0/g,function(t,e){return e+(/[\u0020]/.test(e)?" ":" ")}));var e}).filter(function(t){return!Ge.test(t)})}(o,{plainText:Te(t)});return t.removeAttribute(i.pastingAttribute),{blocks:a,cursor:e}}function tn(t,e){return Array.from(t.childNodes).reduce(function(t,n){if(-1!==Le.indexOf(n.nodeName.toLowerCase()))return"";if(e.keepInternalRelativeLinks&&"A"===n.nodeName&&n.href){var r=n.getAttribute("href").replace(window.location.origin,"");n.setAttribute("href",r)}return n.nodeType===f?t+function(t,e,n){var r=t.nodeName.toLowerCase();if(function(t,e,n){return n.allowedElements[t]&&function(t,e){var n=Re[t];return!n||!n.some(function(t){return!e.getAttribute(t)})}(t,e)}(r=function(t){return Be[t]||t}(r),t,n)){var i=function(t,e){return Array.from(e.attributes).reduce(function(e,n){var r,i=n.name,o=n.value;return null!==(r=je[t])&&void 0!==r&&r[i]&&o?"".concat(e," ").concat(i,'="').concat(o,'"'):e},"")}(r,t);return"br"===r?"<".concat(r+i,">"):Ge.test(e)?e:"<".concat(r+i,">").concat(e,"</").concat(r,">")}return Pe[r]?Ye+e+Ye:Me[r]?"".concat(e," "):e}(n,tn(n,e),e):n.nodeType===h?t+n.nodeValue.replace(/[&<>]/g,function(t){return s[t]}):t},"")}Je(i),document.documentElement.contentEditable;var en=/(apple)?webkit\/537\.36/i.test(window.navigator.userAgent),nn=/(apple)?webkit/i.test(window.navigator.userAgent),rn=!en&&nn,on=function(t){var e=t,n=e.onselectionchange;if(void 0!==n)try{return e.onselectionchange=0,null===e.onselectionchange}catch(t){}finally{e.onselectionchange=n}return!1}(document),an=!!rn;function sn(t,e){var n=function(t){var e={};function n(t,n){t.split(" ").forEach(function(t){e[t]=e[t]||[],e[t].unshift(n)})}return{on:function(t,e){if(2===arguments.length)n(t,e);else if(1===arguments.length)for(var r in t)n(r,t[r]);return this},off:function(t,n){2===arguments.length?function(t,n){var r=e[t];if(r){var i=r.indexOf(n);i<0||r.splice(i,1)}}(t,n):1===arguments.length?e[t]=[]:e={}},notify:function(n,r){var i=Array.from(arguments);t?(r=n,n=t,i.splice(0,1)):i.splice(0,2),this.switchContext&&r!==this.switchContext.events.shift()&&(this.switchContext=void 0);var o=e[r];o&&o.every(function(t){return!1!==t.apply(n,i)})}}}(e);t.on=n.on,t.off=n.off,t.notify=n.notify}function un(t){return un="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},un(t)}function cn(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,ln(r.key),r)}}function ln(t){var e=function(t){if("object"!=un(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=un(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==un(e)?e:e+""}var fn=function(){function t(e,n){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.setHost(e),this.range=n,this.isCursor=!0}return e=t,n=[{key:"getTags",value:function(t){return Kt(this.host,this.range,t)}},{key:"getTagNames",value:function(t){return te(this.getTags(t))}},{key:"getTagsByName",value:function(t){return Xt(this.host,this.range,t)}},{key:"getInnerTags",value:function(t){return Jt(this.range,t)}},{key:"getContainedTags",value:function(t){return Zt(this.range,t)}},{key:"getAncestorTags",value:function(t){return Qt(this.host,this.range,t)}},{key:"isAtEnd",value:function(){return q(this.host,this.range.endContainer,this.range.endOffset)}},{key:"isAtTextEnd",value:function(){return z(this.host,this.range.endContainer,this.range.endOffset)}},{key:"isAtLastLine",value:function(){var t=this.win.document.createRange();t.selectNodeContents(this.host),t.collapse(!1);var e=hn(t,this.win),n=hn(this.range,this.win);return dn(e.bottom,n.bottom)}},{key:"isAtFirstLine",value:function(){var t=this.win.document.createRange();t.selectNodeContents(this.host),t.collapse(!0);var e=hn(t,this.win),n=hn(this.range,this.win);return dn(e.top,n.top)}},{key:"isAtBeginning",value:function(){return W(this.host,this.range.startContainer,this.range.startOffset)}},{key:"insertBefore",value:function(t){if(l(t)&&(t=Wt(t)),!Y(t)){var e=t=this.adoptElement(t);if(t.nodeType===d){var n=t.childNodes.length-1;e=t.childNodes[n]}this.range.insertNode(t),this.range.setStartAfter(e),this.range.setEndAfter(e),this.host.normalize()}}},{key:"insertAfter",value:function(t){if(l(t)&&(t=Wt(t)),!Y(t)){t=this.adoptElement(t);var e=this.range.cloneRange();e.setStart(e.endContainer,e.endOffset),e.collapse(!0),e.insertNode(t),this.host.normalize()}}},{key:"setSelection",value:function(){this.setVisibleSelection()}},{key:"setVisibleSelection",value:function(){if(this.win.document.activeElement!==this.host){var t=st(this.win),e=t.x,n=t.y;this.win.scrollTo(e,n)}var r=C(this.win);r.removeAllRanges(),r.addRange(this.range)}},{key:"before",value:function(){var t=this.range.cloneRange();return t.collapse(!0),t.setStartBefore(this.host),Ut(t)}},{key:"textBefore",value:function(){var t=this.range.cloneRange();return t.collapse(!0),t.setStartBefore(this.host),t.toString()}},{key:"beforeHtml",value:function(){return Vt(this.before())}},{key:"after",value:function(){var t=this.range.cloneRange();return t.collapse(!1),t.setEndAfter(this.host),Ut(t)}},{key:"textAfter",value:function(){var t=this.range.cloneRange();return t.collapse(!1),t.setEndAfter(this.host),t.toString()}},{key:"afterHtml",value:function(){return Vt(this.after())}},{key:"getBoundingClientRect",value:function(){return this.range.getBoundingClientRect()}},{key:"getCoordinates",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"absolute",e=this.range.getBoundingClientRect();if("fixed"===t)return e;var n=st(this.win),r=n.x,i=n.y;return{top:e.top+i,bottom:e.bottom+i,left:e.left+r,right:e.right+r,height:e.height,width:e.width}}},{key:"moveBefore",value:function(e){if(this.updateHost(e),this.range.setStartBefore(e),this.range.setEndBefore(e),this.isSelection)return new t(this.host,this.range)}},{key:"moveAfter",value:function(e){if(this.updateHost(e),this.range.setStartAfter(e),this.range.setEndAfter(e),this.isSelection)return new t(this.host,this.range)}},{key:"moveAtBeginning",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.host;if(this.updateHost(e),this.range.selectNodeContents(e),this.range.collapse(!0),this.isSelection)return new t(this.host,this.range)}},{key:"moveAtEnd",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.host;if(this.updateHost(e),this.range.selectNodeContents(e),this.range.collapse(!1),this.isSelection)return new t(this.host,this.range)}},{key:"moveAtTextEnd",value:function(t){return this.moveAtEnd(X(t))}},{key:"setHost",value:function(t){t.jquery&&(t=t[0]),this.host=t,this.win=null==t?window:t.ownerDocument.defaultView}},{key:"updateHost",value:function(t){var e=I(t);e||o("Can not set cursor outside of an editable block"),this.setHost(e)}},{key:"retainVisibleSelection",value:function(t){this.save(),t(),this.restore(),this.setVisibleSelection()}},{key:"save",value:function(){this.savedRangeInfo=it(this.range),this.savedRangeInfo.host=this.host}},{key:"restore",value:function(){this.savedRangeInfo||o("Could not restore selection"),this.host=this.savedRangeInfo.host,this.range=ot(this.host,this.savedRangeInfo),this.savedRangeInfo=void 0}},{key:"equals",value:function(t){return!!(t&&t.host&&t.host.isEqualNode(this.host)&&t.range&&_(t.range,this.range))}},{key:"createElement",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=this.win.document.createElement(t);for(var r in e){var i=e[r];n.setAttribute(r,i)}return n}},{key:"createTextNode",value:function(t){return this.win.document.createTextNode(t)}},{key:"adoptElement",value:function(t){return qt(t,this.win.document)}},{key:"triggerChange",value:function(){var t=new Event("formatEditable",{bubbles:!0,cancelable:!1});this.host.dispatchEvent(t)}}],r=[{key:"findHost",value:function(t,e){return S(t,e)}}],n&&cn(e.prototype,n),r&&cn(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,n,r}();function hn(t,e){if(t.startContainer.nodeType!==f)return t.getBoundingClientRect();var n=e.document.createElement("span");n.setAttribute("doc-editable","unwrap"),t.insertNode(n);var r=n.getBoundingClientRect();return n.remove(),r}function dn(t,e){return t===e||Math.abs(t-e)<=2}const vn={extractText:function(t){var e="";return function(t,e,n){for(var r,i=new y(t);r=i.getNext();)r.nodeType===h&&""!==r.data?n(r.data):e&&r.nodeType===f&&"BR"===r.nodeName&&n("\n")}(t,!(arguments.length>1&&void 0!==arguments[1])||arguments[1],function(t){e+=t}),e},highlightMatches:function(t,e){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(e&&0!==e.length){t.normalize();for(var r,i,o,a=new y(t),s=0,u=0,c=e[s],l=[];r=a.getNext();)if(r.nodeType===h&&""!==r.data){var d=(o=r).data,v=u+d.length;if(c.startIndex<v&&u<c.endIndex){var p=u<=c.startIndex,g=v>=c.endIndex;p&&(i=c.id||c.startIndex);var m;m=p?c.startIndex-u:0;var b;b=g?c.endIndex-u-m:d.length-m;var w={element:o,text:d.substring(m,m+b),offset:m,length:b,isLastPortion:g,wordId:i};if(l.push(w),g){var S=this.wrapMatch(l,c.marker,c.title);a.replaceCurrent(S),v=u+w.length+w.offset,l=[],(s+=1)<e.length&&(c=e[s])}}u=v}else if(n&&r.nodeType===f&&"BR"===r.nodeName){u+=1;continue}}},wrapMatch:function(t,e,n){var r=this;return t.map(function(t){return r.wrapPortion(t,e,n)}).pop()},wrapPortion:function(t,e,n){var r=k();r.setStart(t.element,t.offset),r.setEnd(t.element,t.offset+t.length);var i=e.cloneNode(!0);if(i.setAttribute("data-word-id",t.wordId),n&&i.setAttribute("title",n),r.surroundContents(i),i.nextSibling){var o=i.nextSibling;o.nodeType===h&&""===o.data&&o.remove()}return i}};function pn(t){return pn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},pn(t)}function gn(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function yn(t,e,n,r){if(!t||""===t)return[];if(r&&!function(t){try{var e;return!!t&&t instanceof(null===(e=t.ownerDocument)||void 0===e?void 0:e.defaultView.HTMLElement)}catch(e){return"object"===pn(t)&&1===t.nodeType&&"object"===pn(t.style)&&"object"===pn(t.ownerDocument)}}(r))return[];if(null==e||!e.length)return[];var i,o=("word"===n?wn:mn)(e);return(i=t.matchAll(o),function(t){if(Array.isArray(t))return gn(t)}(i)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(i)||function(t,e){if(t){if("string"==typeof t)return gn(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?gn(t,e):void 0}}(i)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).map(function(t){var e,i;return"word"===n?(e=t.index+t[1].length,i=t[2]):(e=t.index,i=t[0]),{startIndex:e,endIndex:e+i.length,match:i,marker:r}})}function mn(){var t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).map(function(t){return Sn(t)}),e="(".concat(t.join("|"),")");return new RegExp(e,"g")}var bn="\\u0041-\\u005A\\u0061-\\u007A\\u0030-\\u0039\\u00AA\\u00B5\\u00BA\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u00FF\\u0100-\\u017F\\u0180-\\u024F";function wn(){var t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).map(function(t){return Sn(t)}),e="([^".concat(bn,"]|^)")+"(".concat(t.join("|"),")")+"(?=[^".concat(bn,"]|$)");return new RegExp(e,"g")}function Sn(t){return String(t).replace(/([.*+?^=!:${}()|[\]/\\])/g,"\\$1")}function kn(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return Cn(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Cn(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function Cn(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}var An={highlightText:function(t,e,n,r,i){if(!this.hasHighlight(t,n)){var o=vn.extractText(t),a='<span class="highlight-'.concat(r,'"></span>'),s=function(t,e,n){return yn(t,[e],"text",n)}(o,e,An.createMarkerNode(a,r,this.win));return s&&s.length?(n&&(s[0].id=n),vn.highlightMatches(t,s),bt({editableHost:t}),i&&i.notify("change",t),s[0].startIndex):void 0}},highlightRange:function(t,e,n,r,i,o){var a=arguments.length>6&&void 0!==arguments[6]?arguments[6]:"comment";this.hasHighlight(t,n)&&this.removeHighlight(t,n);var s=vn.extractText(t,!1);if(""===s)return-1;var u=An.createMarkerNode('<span class="highlight-'.concat(a,'"></span>'),a,this.win);if(e){var c=document.createElement("div");if(c.innerHTML=e,c.textContent!==s.slice(r,i))return-1}return vn.highlightMatches(t,[{startIndex:r,endIndex:i,id:n,marker:u}],!1),bt({editableHost:t}),o&&o.notify("change",t),r},updateHighlight:function(t,e,n,r){if(document.documentElement.classList){var i,o=kn(t.querySelectorAll('[data-word-id="'.concat(e,'"]')));try{for(o.s();!(i=o.n()).done;){var a=i.value;r&&a.classList.remove(r),n&&a.classList.add(n)}}catch(t){o.e(t)}finally{o.f()}}},removeHighlight:function(t,e,n){var r,i=kn(t.querySelectorAll('[data-word-id="'.concat(e,'"]')));try{for(i.s();!(r=i.n()).done;)ce(r.value)}catch(t){i.e(t)}finally{i.f()}t.normalize(),bt({editableHost:t}),n&&n.notify("change",t)},hasHighlight:function(t,e){return!!t.querySelectorAll('[data-word-id="'.concat(e,'"]')).length},extractHighlightedRanges:function(t,e){var n="[data-word-id]";e&&(n+='[data-highlight="'.concat(e,'"]'));var r=t.querySelectorAll(n);if(r.length){var i,o={},a=kn(r);try{for(a.s();!(i=a.n()).done;){var s=i.value.getAttribute("data-word-id");o[s]||(o[s]=t.querySelectorAll('[data-word-id="'.concat(s,'"]')))}}catch(t){a.e(t)}finally{a.f()}var u={};for(var c in o){var l=this.extractMarkerNodePosition(t,o[c]);l&&(u[c]=l)}return u}},extractMarkerNodePosition:function(t,e){var n=k();e.length>1?(n.setStartBefore(e[0]),n.setEndAfter(e[e.length-1])):n.selectNode(e[0]);var r=j(n,t);return{start:r.start,end:r.end,text:r.text,nativeRange:n}},cleanupStaleMarkerNodes:function(t,e){var n,r=kn(t.querySelectorAll('span[data-highlight="'.concat(e,'"]')));try{for(r.s();!(n=r.n()).done;){var i=n.value;i.textContent.length||i.remove()}}catch(t){r.e(t)}finally{r.f()}},createMarkerNode:function(t,e,n){var r=w(t,n);return r.setAttribute("data-editable","ui-unwrap"),r.setAttribute("data-highlight",e),r}};const En=An;function Tn(t){return Tn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Tn(t)}function xn(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,o,a,s=[],u=!0,c=!1;try{if(o=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=o.call(n)).done)&&(s.push(r.value),s.length!==e);u=!0);}catch(t){c=!0,i=t}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw i}}return s}}(t,e)||On(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function On(t,e){if(t){if("string"==typeof t)return Nn(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Nn(t,e):void 0}}function Nn(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function jn(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,_n(r.key),r)}}function _n(t){var e=function(t){if("object"!=Tn(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=Tn(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Tn(e)?e:e+""}function Rn(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(Rn=function(){return!!t})()}function Bn(t){return Bn=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Bn(t)}function Mn(t,e){return Mn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Mn(t,e)}var In=function(t){function e(){var t;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),delete(t=function(t,e,n){return e=Bn(e),function(t,e){if(e&&("object"==Tn(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,Rn()?Reflect.construct(e,n||[],Bn(t).constructor):e.apply(t,n))}(this,e,arguments)).isCursor,t.isSelection=!0,t}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Mn(t,e)}(e,t),n=e,r=[{key:"text",value:function(){return this.range.toString()}},{key:"html",value:function(){return function(t){var e=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:window).document.createElement("div");return e.appendChild(t.cloneContents()),e.innerHTML}(this.range)}},{key:"isAllSelected",value:function(){return W(this.host,this.range.startContainer,this.range.startOffset)&&z(this.host,this.range.endContainer,this.range.endOffset)}},{key:"getTextRange",value:function(){return j(this.range,this.host)}},{key:"toString",value:function(){return this.range.toString()}},{key:"isWrappable",value:function(){return ae(this.range)}},{key:"getRects",value:function(){return this.range.getClientRects()}},{key:"link",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t&&(e.href=t);var n=this.createElement(i.linkMarkup.name,i.linkMarkup.attribs);for(var r in e){var o=e[r];void 0!==o&&(null===o?n.removeAttribute(r):n.setAttribute(r,o))}i.linkMarkup.trim&&this.trimRange(),this.forceWrap(n)}},{key:"trimRange",value:function(){var t=this.range.toString(),e=t.search(/\S|$/),n=t.search(/\S[\s]+$/),r=-1===n?0:t.length-(n+1),i=xn(R({root:this.range.commonAncestorContainer,startContainer:this.range.startContainer,startOffset:this.range.startOffset,whitespacesOnTheLeft:e}),2),o=i[0],a=i[1];this.range.setStart(o,a);var s=xn(B({root:this.range.commonAncestorContainer,endContainer:this.range.endContainer,endOffset:this.range.endOffset,whitespacesOnTheRight:r}),2),u=s[0],c=s[1];this.range.setEnd(u,c)}},{key:"unlink",value:function(){this.removeFormatting(i.linkMarkup.name)}},{key:"toggleLink",value:function(t,e){var n=this.getTagsByName(i.linkMarkup.name);if(n.length>=1){var r=n[0];this.isExactSelection(r,"visible")?this.unlink():this.expandTo(r)}else this.link(t,e)}},{key:"highlightComment",value:function(t){var e=t.highlightId,n=t.textRange;En.highlightRange(this.host,e,n.text,n.start,n.end,void 0,"comment")}},{key:"highlight",value:function(t){t.highlightId;var e=this.textBefore(),n=this.text(),r=En.createMarkerNode('<span class="highlight-comment"></span>',this.win);r.setAttribute("data-match",n);var i={startIndex:e.length,endIndex:e.length+n.length,match:n,marker:r};vn.highlightMatches(this.host,[i])}},{key:"toggle",value:function(t){Te(this.host)||this.range.collapsed||(t=this.adoptElement(t),this.range=oe(this.host,this.range,t),this.setVisibleSelection())}},{key:"toggleCustom",value:function(t){var e=t.tagName,n=t.attributes,r=t.trim,i=void 0!==r&&r,o=this.createElement(e,n);i&&this.trimRange(),this.toggle(o)}},{key:"makeCustom",value:function(t){var e=t.tagName,n=t.attributes,r=t.trim,i=void 0!==r&&r,o=this.createElement(e,n);i&&this.trimRange(),this.forceWrap(o)}},{key:"makeBold",value:function(){var t=this.createElement(i.boldMarkup.name,i.boldMarkup.attribs);i.boldMarkup.trim&&this.trimRange(),this.forceWrap(t)}},{key:"toggleBold",value:function(){var t=this.createElement(i.boldMarkup.name,i.boldMarkup.attribs);i.boldMarkup.trim&&this.trimRange(),this.toggle(t)}},{key:"giveEmphasis",value:function(){var t=this.createElement(i.italicMarkup.name,i.italicMarkup.attribs);i.italicMarkup.trim&&this.trimRange(),this.forceWrap(t)}},{key:"toggleEmphasis",value:function(){var t=this.createElement(i.italicMarkup.name,i.italicMarkup.attribs);i.italicMarkup.trim&&this.trimRange(),this.toggle(t)}},{key:"makeUnderline",value:function(){var t=this.createElement(i.underlineMarkup.name,i.underlineMarkup.attribs);i.underlineMarkup.trim&&this.trimRange(),this.forceWrap(t)}},{key:"toggleUnderline",value:function(){var t=this.createElement(i.underlineMarkup.name,i.underlineMarkup.attribs);i.underlineMarkup.trim&&this.trimRange(),this.toggle(t)}},{key:"insertCharacter",value:function(t){var e=this.deleteContent(),n=e.createTextNode(t);return e.insertBefore(n),e.setVisibleSelection(),e}},{key:"surround",value:function(t,e){this.range=pe(this.host,this.range,t,e),this.setVisibleSelection()}},{key:"removeSurround",value:function(t,e){this.range=ge(this.host,this.range,t),this.range=ge(this.host,this.range,e),this.setVisibleSelection()}},{key:"removeChars",value:function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=0;e<t.length;e++){var n=t[e];this.range=ge(this.host,this.range,n)}this.setVisibleSelection()}},{key:"toggleSurround",value:function(t,e){this.containsString(t)&&this.containsString(e)?this.removeSurround(t,e):this.surround(t,e)}},{key:"removeFormatting",value:function(t){this.range=fe(this.host,this.range,t),this.setVisibleSelection()}},{key:"deleteExactSurroundingTags",value:function(){var t,n=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=On(t))){e&&(t=e);var n=0,r=function(){};return{s:r,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,a=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return o=t.done,t},e:function(t){a=!0,i=t},f:function(){try{o||null==e.return||e.return()}finally{if(a)throw i}}}}(this.getAncestorTags().reverse());try{for(n.s();!(t=n.n()).done;){var r=t.value;if(this.isExactSelection(r)){r.remove();break}}}catch(t){n.e(t)}finally{n.f()}return new e(this.host,this.range)}},{key:"deleteContainedTags",value:function(){return this.getContainedTags().forEach(function(t){return t.remove()}),new e(this.host,this.range)}},{key:"deleteContent",value:function(){return this.range.deleteContents(),new fn(this.host,this.range)}},{key:"expandTo",value:function(t){this.range=ie(this.host,this.range,t),this.setVisibleSelection()}},{key:"collapseAtBeginning",value:function(t){return this.range.collapse(!0),this.setVisibleSelection(),new fn(this.host,this.range)}},{key:"collapseAtEnd",value:function(t){return this.range.collapse(!1),this.setVisibleSelection(),new fn(this.host,this.range)}},{key:"forceWrap",value:function(t){Te(this.host)||this.range.collapsed||(t=this.adoptElement(t),this.range=se(this.host,this.range,t),this.setVisibleSelection())}},{key:"isExactSelection",value:function(t,e){return re(this.range,t,e)}},{key:"containsString",value:function(t){return ye(this.range,t)}},{key:"deleteCharacter",value:function(t){this.range=ge(this.host,this.range,t),this.setVisibleSelection()}}],r&&jn(n.prototype,r),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r}(fn);function Pn(t){return Pn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Pn(t)}function Ln(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Hn(r.key),r)}}function Hn(t){var e=function(t){if("object"!=Pn(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=Pn(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Pn(e)?e:e+""}var Fn=function(){function t(e,n){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.host=e&&e.jquery?e[0]:e,this.range=null==n?void 0:n.cloneRange(),this.isAnythingSelected=void 0!==n,this.isCursor=this.isAnythingSelected&&n.collapsed,this.isSelection=this.isAnythingSelected&&!this.isCursor}return e=t,n=[{key:"getCursor",value:function(){if(this.isCursor)return new fn(this.host,this.range)}},{key:"getSelection",value:function(){if(this.isSelection)return new In(this.host,this.range)}},{key:"forceCursor",value:function(){return this.isSelection?this.getSelection().deleteContent():this.getCursor()}},{key:"isDifferentFrom",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new t,n=this.range,r=e.range;return n&&r?!_(n,r):!(!n&&!r)}}],n&&Ln(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,n}();function Dn(t){return Dn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Dn(t)}function Vn(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Wn(r.key),r)}}function Wn(t){var e=function(t){if("object"!=Dn(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=Dn(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Dn(e)?e:e+""}var qn=function(){return t=function t(e,n){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.dispatcher=e,this.win=n||window,this.selection=void 0,this.currentSelection=void 0,this.currentRange=void 0},(e=[{key:"syncSelection",value:function(){try{this.selection=C(this.win)}catch(t){return!1}return!0}},{key:"getRangeContainer",value:function(){var t,e=this.syncSelection();if(null!==(t=this.selection)&&void 0!==t&&t.rangeCount&&e){var n=this.selection.getRangeAt(0),r=I(n.commonAncestorContainer);if(r)return new Fn(r,n)}return new Fn}},{key:"getFreshRange",value:function(){return this.getRangeContainer()}},{key:"getFreshSelection",value:function(){var t=this.getRangeContainer();return t.isCursor?t.getCursor(this.win):t.getSelection(this.win)}},{key:"getSelection",value:function(){return this.currentSelection}},{key:"forceCursor",value:function(){return this.getRangeContainer().forceCursor()}},{key:"selectionChanged",value:function(){var t=this.getRangeContainer();if(t.isDifferentFrom(this.currentRange)){var e=this.currentSelection;this.currentRange=t,e&&(e.isCursor&&!this.currentRange.isCursor?this.dispatcher.notify("cursor",e.host):e.isSelection&&!this.currentRange.isSelection&&this.dispatcher.notify("selection",e.host)),this.currentRange.isCursor?(this.currentSelection=new fn(this.currentRange.host,this.currentRange.range),this.dispatcher.notify("cursor",this.currentSelection.host,this.currentSelection)):this.currentRange.isSelection?(this.currentSelection=new In(this.currentRange.host,this.currentRange.range),this.dispatcher.notify("selection",this.currentSelection.host,this.currentSelection)):this.currentSelection=void 0}}}])&&Vn(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function Un(t){return Un="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Un(t)}function $n(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,zn(r.key),r)}}function zn(t){var e=function(t){if("object"!=Un(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=Un(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Un(e)?e:e+""}var Kn=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),sn(this),this.selectionWatcher=e}return e=t,r=[{key:"getNodeToRemove",value:function(e,n){if(0===e.startOffset){var r=e.startContainer;if(r.nodeType===h&&(r=r.parentNode),r!==n){var i=k();if(i.setStartBefore(r.firstChild),i.setEndAfter(r.lastChild),a=e,!((o=i).compareBoundaryPoints(Range.START_TO_START,a)<=0&&o.compareBoundaryPoints(Range.END_TO_END,a)>=0)){var o,a;if(e.startContainer.nodeType===h){var s=[h,f],u=r.firstChild;do{if(-1!==s.indexOf(u.nodeType))break}while(u=u.nextSibling);if(u!==e.startContainer)return}var c=e.cloneRange();return c.setStartBefore(r),t.getNodeToRemove(c,n)||r}}}}}],(n=[{key:"dispatchKeyEvent",value:function(t,e,n){switch(t.keyCode){case this.key.left:return this.notify(e,"left",t);case this.key.right:return this.notify(e,"right",t);case this.key.up:return this.notify(e,"up",t);case this.key.down:return this.notify(e,"down",t);case this.key.tab:return t.shiftKey?this.notify(e,"shiftTab",t):this.notify(e,"tab",t);case this.key.esc:return this.notify(e,"esc",t);case this.key.backspace:return this.preventContenteditableBug(e,t),this.notify(e,"backspace",t);case this.key.delete:return this.preventContenteditableBug(e,t),this.notify(e,"delete",t);case this.key.enter:return t.shiftKey?this.notify(e,"shiftEnter",t):this.notify(e,"enter",t);case this.key.ctrl:case this.key.shift:case this.key.alt:case 224:case 17:case 91:case 93:return;default:if(t.keyCode===this.key.b&&(t.ctrlKey||t.metaKey))return this.notify(e,"bold",t);if(t.keyCode===this.key.i&&(t.ctrlKey||t.metaKey))return this.notify(e,"italic",t);if(this.preventContenteditableBug(e,t),!n)return;if(!t.ctrlKey&&!t.metaKey)return this.notify(e,"character",t)}}},{key:"preventContenteditableBug",value:function(e,n){if(an&&!n.ctrlKey&&!n.metaKey){var r=this.selectionWatcher.getFreshRange();if(r.isSelection){var i=t.getNodeToRemove(r.range,e);i&&i.remove()}}}}])&&$n(e.prototype,n),r&&$n(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,n,r}();function Qn(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}Kn.key=Kn.prototype.key={left:37,up:38,right:39,down:40,tab:9,esc:27,backspace:8,delete:46,enter:13,shift:16,ctrl:17,alt:18,b:66,i:73};var Xn=function(t){return Array.isArray(t)&&2===t.length},Gn=function(t){return/^[«»"“”„]$/.test(t)},Yn=function(t){return/^[‘’‹›‚']$/.test(t)},Jn=function(t){return/^[’']$/.test(t)},Zn=function(t){return/\s|[>\-–—]/.test(t)},tr=function(t,e,n,r,i){var o,a=Yn(n);if(Gn(n)||a){var s=e.quotes,u=e.singleQuotes;if(n!==s[0]&&n!==s[1]&&n!==u[0]&&n!==u[1]){var c=t.startOffset,l=function(t,e,n,r){var i,o,a=r.quotes,s=r.singleQuotes;if(n&&(i=t)[o=e-2]&&Gn(i[o]))return s[0];if(function(t,e){return!!t[e]&&!Zn(t[e])}(t,e-2)){if(n){if(function(t,e){return!!t[e]&&(n=t[e],!/^\s$/.test(n));var n}(t,e))return;if(!function(t,e,n){if(e<=0)return!1;for(var r=e-1;r>=0;r--)if(Yn(t[r])&&!Jn(n)&&!Jn(t[r]))return t[r]===n;return!1}(t,e,s[0]))return;return s[1]}return a[1]}return function(t,e){return e<0||Zn(t[e])}(t,e-2)?n?s[0]:a[0]:void 0}(function(t){if(Array.isArray(t))return Qn(t)}(o=t.startContainer.textContent)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(o)||function(t,e){if(t){if("string"==typeof t)return Qn(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Qn(t,e):void 0}}(o)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),c,a,e);l&&function(t,e,n){var r=null==t?void 0:t.startContainer,i=null==r?void 0:r.nodeValue;if(!i)return!1;var o=Math.min(e,i.length);return r.insertData(o,n),r.deleteData(o+n.length,1),!0}(t,c-1,l)&&r.ownerDocument.defaultView.getSelection().collapse(t.startContainer,null!=i?i:c)}}};function er(t){return er="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},er(t)}function nr(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return rr(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?rr(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function rr(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function ir(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,or(r.key),r)}}function or(t){var e=function(t){if("object"!=er(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=er(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==er(e)?e:e+""}var ar=function(){return t=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t);var n=e.win;sn(this,e),this.document=n.document,this.config=e.config,this.editable=e,this.editableSelector=e.editableSelector,this.selectionWatcher=new qn(this,n),this.keyboard=new Kn(this.selectionWatcher),this.activeListeners=[],this.setup(),this.getEditableBlockByEvent=function(t){return S(t.target,e.editableSelector)}},e=[{key:"setupDocumentListener",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r={event:t,listener:e.bind(this),capture:n};return this.activeListeners.push(r),this.document.addEventListener(t,r.listener,n),this}},{key:"setup",value:function(){this.setupKeyboardEvents(),this.setupEventListeners()}},{key:"unload",value:function(){this.off();var t,e=nr(this.activeListeners);try{for(e.s();!(t=e.n()).done;){var n=t.value;this.document.removeEventListener(n.event,n.listener,n.capture)}}catch(t){e.e(t)}finally{e.f()}this.activeListeners.length=0}},{key:"suspend",value:function(){if(!this.suspended){this.suspended=!0;var t,e=nr(this.activeListeners);try{for(e.s();!(t=e.n()).done;){var n=t.value;this.document.removeEventListener(n.event,n.listener,n.capture)}}catch(t){e.e(t)}finally{e.f()}this.activeListeners.length=0}}},{key:"continue",value:function(){this.suspended&&(this.suspended=!1,this.setupEventListeners())}},{key:"setupEventListeners",value:function(){this.setupElementListeners(),this.setupKeydownListener(),on?this.setupSelectionChangeListeners():this.setupSelectionChangeFallbackListeners()}},{key:"setupElementListeners",value:function(){var t={offset:void 0};this.setupDocumentListener("focus",function(t){var e=this.getEditableBlockByEvent(t);e&&(t.target.getAttribute(i.pastingAttribute)||(this.selectionWatcher.syncSelection(),this.notify("focus",e)))},!0).setupDocumentListener("blur",function(t){var e=this.getEditableBlockByEvent(t);e&&(e.getAttribute(i.pastingAttribute)||this.notify("blur",e))},!0).setupDocumentListener("copy",function(t){var e=this.getEditableBlockByEvent(t);if(e){var n=this.selectionWatcher.getFreshSelection();n&&n.isSelection&&this.notify("clipboard",e,"copy",n)}}).setupDocumentListener("cut",function(t){var e=this.getEditableBlockByEvent(t);if(e){var n=this.selectionWatcher.getFreshSelection();n&&n.isSelection&&this.notify("clipboard",e,"cut",n)}}).setupDocumentListener("paste",function(t){var e=this.getEditableBlockByEvent(t);if(e){t.preventDefault();var n,r=this.selectionWatcher.getFreshSelection(),i=t.clipboardData.getData("text/html")||t.clipboardData.getData("text/plain"),o=Ze(e,r,i),a=o.blocks,s=o.cursor;a.length?(n=t.target.innerText,/\S+\s{1}$/.test(n)&&s.retainVisibleSelection(function(){e.innerHTML=function(t,e){if(!t)return"";var n=(t="".concat(t)).lastIndexOf(e);return-1===n?t:"".concat(t.slice(0,n)).concat(" ").concat(t.slice(n+6))}(e.innerHTML,"&nbsp;")}),this.notify("paste",e,a,s),this.notify("change",e)):s.setVisibleSelection()}}).setupDocumentListener("input",function(e){var n=this.getEditableBlockByEvent(e);if(n){if(function(t,e){var n=t.smartQuotes,r=t.quotes,i=t.singleQuotes;return!!n&&Xn(r)&&Xn(i)&&e.isContentEditable}(i,e.target)){var r,o=this.selectionWatcher.getFreshSelection();t.offset=null===(r=o.range)||void 0===r?void 0:r.startOffset,setTimeout(function(){tr(o.range,i,e.data,e.target,t.offset)},300)}this.notify("change",n)}}).setupDocumentListener("formatEditable",function(t){var e=this.getEditableBlockByEvent(t);e&&this.notify("change",e)})}},{key:"dispatchSwitchEvent",value:function(t,e,n){if(!(t.altKey||t.ctrlKey||t.metaKey||t.shiftKey)){var r=this.selectionWatcher.getFreshSelection();r&&!r.isSelection&&(this.switchContext?this.switchContext.events=["cursor"]:this.switchContext={positionX:r.getBoundingClientRect().left,events:["cursor"]},"up"===n&&r.isAtFirstLine()&&(t.preventDefault(),t.stopPropagation(),this.switchContext.events=["switch","blur","focus","cursor"],this.notify("switch",e,n,r)),"down"===n&&r.isAtLastLine()&&(t.preventDefault(),t.stopPropagation(),this.switchContext.events=["switch","blur","focus","cursor"],this.notify("switch",e,n,r)))}}},{key:"setupKeydownListener",value:function(){this.setupDocumentListener("keydown",function(t){var e=this.getEditableBlockByEvent(t);e&&this.keyboard.dispatchKeyEvent(t,e,!1)},!0)}},{key:"setupKeyboardEvents",value:function(){var t=this;this.keyboard.on("up",function(e){t.dispatchSwitchEvent(e,this,"up")}).on("down",function(e){t.dispatchSwitchEvent(e,this,"down")}).on("backspace",function(e){var n=t.selectionWatcher.getFreshRange();if(n.isCursor){var r=n.getCursor();r.isAtBeginning()&&(e.preventDefault(),e.stopPropagation(),t.notify("merge",this,"before",r))}}).on("delete",function(e){var n=t.selectionWatcher.getFreshRange();if(n.isCursor){var r=n.getCursor();r.isAtTextEnd()&&(e.preventDefault(),e.stopPropagation(),t.notify("merge",this,"after",r))}}).on("enter",function(e){e.preventDefault(),e.stopPropagation();var n=t.selectionWatcher.getFreshRange().forceCursor();n.isAtTextEnd()?t.notify("insert",this,"after",n):n.isAtBeginning()?t.notify("insert",this,"before",n):t.notify("split",this,n.before(),n.after(),n)}).on("shiftEnter",function(e){e.preventDefault(),e.stopPropagation();var n=t.selectionWatcher.forceCursor();t.notify("newline",this,n)}).on("bold",function(e){e.preventDefault(),e.stopPropagation();var n=t.selectionWatcher.getFreshSelection();n.isSelection&&t.notify("toggleBold",n)}).on("italic",function(e){e.preventDefault(),e.stopPropagation();var n=t.selectionWatcher.getFreshSelection();n.isSelection&&t.notify("toggleEmphasis",n)}).on("character",function(e){t.notify("change",this)})}},{key:"setupSelectionChangeListeners",value:function(){var t=this,e=!1,n=!1,r=this.selectionWatcher;this.setupDocumentListener("selectionchange",function(i){var o=t.selectionWatcher.getFreshSelection();o&&o.isSelection&&o.isAtBeginning()&&o.isAtEnd()?t.notify("selectToBoundary",o.host,i,"both"):o&&o.isSelection&&o.isAtBeginning()?t.notify("selectToBoundary",o.host,i,"start"):o&&o.isSelection&&o.isAtEnd()&&t.notify("selectToBoundary",o.host,i,"end"),n?e=!0:r.selectionChanged()}),this.setupDocumentListener("mousedown",function(t){this.getEditableBlockByEvent(t)&&(!1===this.config.mouseMoveSelectionChanges&&(n=!0,setTimeout(function(){return r.selectionChanged()},0)),this.document.addEventListener("mouseup",function(){n=!1,e&&(e=!1,r.selectionChanged())},{capture:!0,once:!0}))})}},{key:"setupSelectionChangeFallbackListeners",value:function(){var t=this;this.setupDocumentListener("mouseup",function(){setTimeout(function(){return t.selectionWatcher.selectionChanged()},0)}),this.setupDocumentListener("keyup",function(e){t.getEditableBlockByEvent(e)&&t.selectionWatcher.selectionChanged()})}}],e&&ir(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();const sr=function(t,e){return t===e||t!=t&&e!=e},ur=function(t,e){for(var n=t.length;n--;)if(sr(t[n][0],e))return n;return-1};var cr=Array.prototype.splice;function lr(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}lr.prototype.clear=function(){this.__data__=[],this.size=0},lr.prototype.delete=function(t){var e=this.__data__,n=ur(e,t);return!(n<0||(n==e.length-1?e.pop():cr.call(e,n,1),--this.size,0))},lr.prototype.get=function(t){var e=this.__data__,n=ur(e,t);return n<0?void 0:e[n][1]},lr.prototype.has=function(t){return ur(this.__data__,t)>-1},lr.prototype.set=function(t,e){var n=this.__data__,r=ur(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this};const fr=lr,hr="object"==typeof t.g&&t.g&&t.g.Object===Object&&t.g;var dr="object"==typeof self&&self&&self.Object===Object&&self;const vr=hr||dr||Function("return this")(),pr=vr.Symbol;var gr=Object.prototype,yr=gr.hasOwnProperty,mr=gr.toString,br=pr?pr.toStringTag:void 0;var wr=Object.prototype.toString;var Sr=pr?pr.toStringTag:void 0;const kr=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":Sr&&Sr in Object(t)?function(t){var e=yr.call(t,br),n=t[br];try{t[br]=void 0;var r=!0}catch(t){}var i=mr.call(t);return r&&(e?t[br]=n:delete t[br]),i}(t):function(t){return wr.call(t)}(t)},Cr=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)},Ar=function(t){if(!Cr(t))return!1;var e=kr(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e},Er=vr["__core-js_shared__"];var Tr,xr=(Tr=/[^.]+$/.exec(Er&&Er.keys&&Er.keys.IE_PROTO||""))?"Symbol(src)_1."+Tr:"";var Or=Function.prototype.toString;var Nr=/^\[object .+?Constructor\]$/,jr=Function.prototype,_r=Object.prototype,Rr=jr.toString,Br=_r.hasOwnProperty,Mr=RegExp("^"+Rr.call(Br).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");const Ir=function(t){return!(!Cr(t)||(e=t,xr&&xr in e))&&(Ar(t)?Mr:Nr).test(function(t){if(null!=t){try{return Or.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t));var e},Pr=function(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return Ir(n)?n:void 0},Lr=Pr(vr,"Map"),Hr=Pr(Object,"create");var Fr=Object.prototype.hasOwnProperty;var Dr=Object.prototype.hasOwnProperty;function Vr(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}Vr.prototype.clear=function(){this.__data__=Hr?Hr(null):{},this.size=0},Vr.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},Vr.prototype.get=function(t){var e=this.__data__;if(Hr){var n=e[t];return"__lodash_hash_undefined__"===n?void 0:n}return Fr.call(e,t)?e[t]:void 0},Vr.prototype.has=function(t){var e=this.__data__;return Hr?void 0!==e[t]:Dr.call(e,t)},Vr.prototype.set=function(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=Hr&&void 0===e?"__lodash_hash_undefined__":e,this};const Wr=Vr,qr=function(t,e){var n,r,i=t.__data__;return("string"==(r=typeof(n=e))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?i["string"==typeof e?"string":"hash"]:i.map};function Ur(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}Ur.prototype.clear=function(){this.size=0,this.__data__={hash:new Wr,map:new(Lr||fr),string:new Wr}},Ur.prototype.delete=function(t){var e=qr(this,t).delete(t);return this.size-=e?1:0,e},Ur.prototype.get=function(t){return qr(this,t).get(t)},Ur.prototype.has=function(t){return qr(this,t).has(t)},Ur.prototype.set=function(t,e){var n=qr(this,t),r=n.size;return n.set(t,e),this.size+=n.size==r?0:1,this};const $r=Ur;function zr(t){var e=this.__data__=new fr(t);this.size=e.size}zr.prototype.clear=function(){this.__data__=new fr,this.size=0},zr.prototype.delete=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n},zr.prototype.get=function(t){return this.__data__.get(t)},zr.prototype.has=function(t){return this.__data__.has(t)},zr.prototype.set=function(t,e){var n=this.__data__;if(n instanceof fr){var r=n.__data__;if(!Lr||r.length<199)return r.push([t,e]),this.size=++n.size,this;n=this.__data__=new $r(r)}return n.set(t,e),this.size=n.size,this};const Kr=zr,Qr=function(){try{var t=Pr(Object,"defineProperty");return t({},"",{}),t}catch(t){}}(),Xr=function(t,e,n){"__proto__"==e&&Qr?Qr(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n},Gr=function(t,e,n){(void 0!==n&&!sr(t[e],n)||void 0===n&&!(e in t))&&Xr(t,e,n)},Yr=function(t,e,n){for(var r=-1,i=Object(t),o=n(t),a=o.length;a--;){var s=o[++r];if(!1===e(i[s],s,i))break}return t};var Jr="object"==typeof exports&&exports&&!exports.nodeType&&exports,Zr=Jr&&"object"==typeof module&&module&&!module.nodeType&&module,ti=Zr&&Zr.exports===Jr?vr.Buffer:void 0,ei=ti?ti.allocUnsafe:void 0;const ni=vr.Uint8Array,ri=function(t,e){var n,r,i=e?(n=t.buffer,r=new n.constructor(n.byteLength),new ni(r).set(new ni(n)),r):t.buffer;return new t.constructor(i,t.byteOffset,t.length)};var ii=Object.create;const oi=function(){function t(){}return function(e){if(!Cr(e))return{};if(ii)return ii(e);t.prototype=e;var n=new t;return t.prototype=void 0,n}}(),ai=(si=Object.getPrototypeOf,ui=Object,function(t){return si(ui(t))});var si,ui,ci=Object.prototype;const li=function(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||ci)},fi=function(t){return null!=t&&"object"==typeof t},hi=function(t){return fi(t)&&"[object Arguments]"==kr(t)};var di=Object.prototype,vi=di.hasOwnProperty,pi=di.propertyIsEnumerable;const gi=hi(function(){return arguments}())?hi:function(t){return fi(t)&&vi.call(t,"callee")&&!pi.call(t,"callee")},yi=Array.isArray,mi=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991},bi=function(t){return null!=t&&mi(t.length)&&!Ar(t)};var wi="object"==typeof exports&&exports&&!exports.nodeType&&exports,Si=wi&&"object"==typeof module&&module&&!module.nodeType&&module,ki=Si&&Si.exports===wi?vr.Buffer:void 0;const Ci=(ki?ki.isBuffer:void 0)||function(){return!1};var Ai=Function.prototype,Ei=Object.prototype,Ti=Ai.toString,xi=Ei.hasOwnProperty,Oi=Ti.call(Object);var Ni={};Ni["[object Float32Array]"]=Ni["[object Float64Array]"]=Ni["[object Int8Array]"]=Ni["[object Int16Array]"]=Ni["[object Int32Array]"]=Ni["[object Uint8Array]"]=Ni["[object Uint8ClampedArray]"]=Ni["[object Uint16Array]"]=Ni["[object Uint32Array]"]=!0,Ni["[object Arguments]"]=Ni["[object Array]"]=Ni["[object ArrayBuffer]"]=Ni["[object Boolean]"]=Ni["[object DataView]"]=Ni["[object Date]"]=Ni["[object Error]"]=Ni["[object Function]"]=Ni["[object Map]"]=Ni["[object Number]"]=Ni["[object Object]"]=Ni["[object RegExp]"]=Ni["[object Set]"]=Ni["[object String]"]=Ni["[object WeakMap]"]=!1;var ji="object"==typeof exports&&exports&&!exports.nodeType&&exports,_i=ji&&"object"==typeof module&&module&&!module.nodeType&&module,Ri=_i&&_i.exports===ji&&hr.process,Bi=function(){try{return _i&&_i.require&&_i.require("util").types||Ri&&Ri.binding&&Ri.binding("util")}catch(t){}}(),Mi=Bi&&Bi.isTypedArray;const Ii=Mi?function(t){return function(e){return t(e)}}(Mi):function(t){return fi(t)&&mi(t.length)&&!!Ni[kr(t)]},Pi=function(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]};var Li=Object.prototype.hasOwnProperty;const Hi=function(t,e,n){var r=t[e];Li.call(t,e)&&sr(r,n)&&(void 0!==n||e in t)||Xr(t,e,n)};var Fi=/^(?:0|[1-9]\d*)$/;const Di=function(t,e){var n=typeof t;return!!(e=e??9007199254740991)&&("number"==n||"symbol"!=n&&Fi.test(t))&&t>-1&&t%1==0&&t<e};var Vi=Object.prototype.hasOwnProperty;const Wi=function(t,e){var n=yi(t),r=!n&&gi(t),i=!n&&!r&&Ci(t),o=!n&&!r&&!i&&Ii(t),a=n||r||i||o,s=a?function(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}(t.length,String):[],u=s.length;for(var c in t)!e&&!Vi.call(t,c)||a&&("length"==c||i&&("offset"==c||"parent"==c)||o&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||Di(c,u))||s.push(c);return s};var qi=Object.prototype.hasOwnProperty;const Ui=function(t){if(!Cr(t))return function(t){var e=[];if(null!=t)for(var n in Object(t))e.push(n);return e}(t);var e=li(t),n=[];for(var r in t)("constructor"!=r||!e&&qi.call(t,r))&&n.push(r);return n},$i=function(t){return bi(t)?Wi(t,!0):Ui(t)},zi=function(t){return function(t,e,n,r){var i=!n;n||(n={});for(var o=-1,a=e.length;++o<a;){var s=e[o],u=r?r(n[s],t[s],s,n,t):void 0;void 0===u&&(u=t[s]),i?Xr(n,s,u):Hi(n,s,u)}return n}(t,$i(t))},Ki=function(t,e,n,r,i,o,a){var s,u=Pi(t,n),c=Pi(e,n),l=a.get(c);if(l)Gr(t,n,l);else{var f=o?o(u,c,n+"",t,e,a):void 0,h=void 0===f;if(h){var d=yi(c),v=!d&&Ci(c),p=!d&&!v&&Ii(c);f=c,d||v||p?yi(u)?f=u:fi(s=u)&&bi(s)?f=function(t,e){var n=-1,r=t.length;for(e||(e=Array(r));++n<r;)e[n]=t[n];return e}(u):v?(h=!1,f=function(t,e){if(e)return t.slice();var n=t.length,r=ei?ei(n):new t.constructor(n);return t.copy(r),r}(c,!0)):p?(h=!1,f=ri(c,!0)):f=[]:function(t){if(!fi(t)||"[object Object]"!=kr(t))return!1;var e=ai(t);if(null===e)return!0;var n=xi.call(e,"constructor")&&e.constructor;return"function"==typeof n&&n instanceof n&&Ti.call(n)==Oi}(c)||gi(c)?(f=u,gi(u)?f=zi(u):Cr(u)&&!Ar(u)||(f=function(t){return"function"!=typeof t.constructor||li(t)?{}:oi(ai(t))}(c))):h=!1}h&&(a.set(c,f),i(f,c,r,o,a),a.delete(c)),Gr(t,n,f)}},Qi=function t(e,n,r,i,o){e!==n&&Yr(n,function(a,s){if(o||(o=new Kr),Cr(a))Ki(e,n,s,r,t,i,o);else{var u=i?i(Pi(e,s),a,s+"",e,n,o):void 0;void 0===u&&(u=a),Gr(e,s,u)}},$i)},Xi=function(t){return t};var Gi=Math.max;const Yi=Qr?function(t,e){return Qr(t,"toString",{configurable:!0,enumerable:!1,value:(n=e,function(){return n}),writable:!0});var n}:Xi;var Ji=Date.now;const Zi=function(t){var e=0,n=0;return function(){var r=Ji(),i=16-(r-n);if(n=r,i>0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(Yi),to=function(t,e){return Zi(function(t,e,n){return e=Gi(void 0===e?t.length-1:e,0),function(){for(var r=arguments,i=-1,o=Gi(r.length-e,0),a=Array(o);++i<o;)a[i]=r[e+i];i=-1;for(var s=Array(e+1);++i<e;)s[i]=r[i];return s[e]=n(a),function(t,e,n){switch(n.length){case 0:return t.call(e);case 1:return t.call(e,n[0]);case 2:return t.call(e,n[0],n[1]);case 3:return t.call(e,n[0],n[1],n[2])}return t.apply(e,n)}(t,this,s)}}(t,e,Xi),t+"")},eo=(no=function(t,e,n){Qi(t,e,n)},to(function(t,e){var n=-1,r=e.length,i=r>1?e[r-1]:void 0,o=r>2?e[2]:void 0;for(i=no.length>3&&"function"==typeof i?(r--,i):void 0,o&&function(t,e,n){if(!Cr(n))return!1;var r=typeof e;return!!("number"==r?bi(n)&&Di(e,n.length):"string"==r&&e in n)&&sr(n[e],t)}(e[0],e[1],o)&&(i=r<3?void 0:i,r=1),t=Object(t);++n<r;){var a=e[n];a&&no(t,a,n)}return t}));var no;function ro(t){return ro="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ro(t)}function io(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,oo(r.key),r)}}function oo(t){var e=function(t){if("object"!=ro(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=ro(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ro(e)?e:e+""}var ao=function(){return t=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.spellcheckService=e},(e=[{key:"check",value:function(t,e){if(!t)return e(null);var n=Ht(t);this.spellcheckService(n,function(t){return t&&t.length>0?e(null,t):e(null)})}}])&&io(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function so(t){return so="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},so(t)}function uo(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function co(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,lo(r.key),r)}}function lo(t){var e=function(t){if("object"!=so(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=so(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==so(e)?e:e+""}var fo={A0:"no-break space",2e3:"en quad",2001:"em quad",2002:"en space",2003:"em space",2004:"three-per-em space",2005:"four-per-em space",2006:"six-per-em space",2007:"figure space",2008:"punctuation space",2009:"thin space","200A":"hair space","202F":"narrow no-break space","205F":"medium mathematical space",3e3:"ideographic space"},ho=new RegExp("[".concat("\\u2000-\\u200A\\u202F\\u205F\\u3000","]"),"g"),vo=function(){return t=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.marker=e},(e=[{key:"findMatches",value:function(t){var e=this;if(t)return function(t){return function(t){if(Array.isArray(t))return uo(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return uo(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?uo(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(t.matchAll(ho)).map(function(t){return e.prepareMatch(t)})}},{key:"prepareMatch",value:function(t){var e,n=t.index,r=(e=t[0].charCodeAt(0),"".concat(e.toString(16).toUpperCase())),i=fo[r];return{startIndex:n,endIndex:n+t.length,match:t[0],title:"".concat(i," (\\u").concat(r,")"),marker:this.marker}}}])&&co(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function po(t){return po="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},po(t)}function go(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,yo(r.key),r)}}function yo(t){var e=function(t){if("object"!=po(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=po(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==po(e)?e:e+""}var mo=function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.matches=[]},e=[{key:"addMatches",value:function(t){null!=t&&t.length&&(this.matches=function(t,e){for(var n,r=t.length,i=e.length,o=-1,a=[],s={a1:t,i1:0,a2:e,i2:0};s.i1<r||s.i2<i;)(n=bo(s)).startIndex>=o&&a.push(n),o=n.endIndex;return a}(this.matches,t))}}],e&&go(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function bo(t){var e=t.i1,n=t.i2,r=t.a1[e],i=t.a2[n];return r&&i&&r.startIndex<i.startIndex?(t.i1=e+1,r):r&&i?(t.i2=n+1,i):r?(t.i1=e+1,r):i?(t.i2=n+1,i):void 0}function wo(t){return wo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},wo(t)}function So(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return ko(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ko(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function ko(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function Co(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Ao(r.key),r)}}function Ao(t){var e=function(t){if("object"!=wo(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=wo(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==wo(e)?e:e+""}var Eo=function(){return t=function t(e,n,r){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.editable=e,this.win=e.win,this.focusedEditableHost=void 0,this.currentlyCheckedEditableHost=void 0,this.timeout={},this.config=eo({},{checkOnInit:!1,checkOnFocus:!1,checkOnChange:!0,throttle:1e3,removeOnCorrection:!0,spellcheck:{marker:'<span class="highlight-spellcheck"></span>',throttle:1e3,spellcheckService:function(){}},whitespace:{marker:'<span class="highlight-whitespace"></span>'}},n);var i=this.config.spellcheck.spellcheckService,o=this.config.spellcheck.marker,a=this.config.whitespace.marker,s=En.createMarkerNode(a,"whitespace",this.win);this.spellcheckMarkerNode=En.createMarkerNode(o,"spellcheck",this.win),this.spellcheckService=new ao(i),this.whitespace=new vo(s),this.setupListeners()},e=[{key:"setupListeners",value:function(){var t=this;this.config.checkOnFocus&&(this.editable.on("focus",function(){return t.onFocus.apply(t,arguments)}),this.editable.on("blur",function(){return t.onBlur.apply(t,arguments)})),(this.config.checkOnChange||this.config.removeOnCorrection)&&this.editable.on("change",function(){return t.onChange.apply(t,arguments)}),this.config.checkOnInit&&this.editable.on("init",function(){return t.onInit.apply(t,arguments)})}},{key:"onInit",value:function(t){this.highlight(t)}},{key:"onFocus",value:function(t){this.focusedEditableHost!==t&&(this.focusedEditableHost=t,this.editableHasChanged(t))}},{key:"onBlur",value:function(t){this.focusedEditableHost===t&&(this.focusedEditableHost=void 0)}},{key:"onChange",value:function(t){this.config.checkOnChange&&this.editableHasChanged(t,this.config.throttle),this.config.removeOnCorrection&&this.removeHighlightsAtCursor(t)}},{key:"editableHasChanged",value:function(t,e){var n=this;this.timeout.id&&this.timeout.editableHost===t&&clearTimeout(this.timeout.id);var r=setTimeout(function(){n.highlight(t),n.timeout={}},e||0);this.timeout={id:r,editableHost:t}}},{key:"highlight",value:function(t){var e=this,n=vn.extractText(t);this.spellcheckService.check(n,function(n,r){if(!n&&t.isConnected){var i=vn.extractText(t),o=new mo,a=function(t,e,n){return yn(t,e,"word",n)}(i,r,e.spellcheckMarkerNode);o.addMatches(a),a=e.whitespace.findMatches(i),o.addMatches(a),e.safeHighlightMatches(t,o.matches)}})}},{key:"safeHighlightMatches",value:function(t,e){var n=this,r=this.editable.getSelection(t);r?r.retainVisibleSelection(function(){n.highlightMatches(t,e)}):this.highlightMatches(t,e),this.editable.dispatcher&&this.editable.dispatcher.notify("spellcheckUpdated",t)}},{key:"highlightMatches",value:function(t,e){this.removeHighlights(t),e&&e.length>0&&vn.highlightMatches(t,e)}},{key:"removeHighlights",value:function(t){t=b(t,this.win.document);var e,n=So(m('[data-highlight="spellcheck"], [data-highlight="whitespace"]',t));try{for(n.s();!(e=n.n()).done;)ce(e.value)}catch(t){n.e(t)}finally{n.f()}}},{key:"removeHighlightsAtCursor",value:function(t){t=b(t,this.win.document);var e=this.editable.getSelection(t);if(e&&e.isCursor){var n,r=e.range.startContainer;r.nodeType===h&&(r=r.parentNode);do{if(r===t)return;var i=r.getAttribute("data-highlight");if("spellcheck"===i||"whitespace"===i){n=r.getAttribute("data-word-id");break}}while(r=r.parentNode);n&&e.retainVisibleSelection(function(){var e,r=So(m('[data-word-id="'.concat(n,'"]'),t));try{for(r.s();!(e=r.n()).done;)ce(e.value)}catch(t){r.e(t)}finally{r.f()}})}}}],e&&Co(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function To(){if(!1!==i.log&&t.g.console){var e=1===arguments.length?arguments[0]:Array.from(arguments);return 1!==arguments.length&&"trace"===e[e.length-1]&&(e.pop(),console.trace&&console.trace()),console.log(e)}}function xo(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function Oo(t){return function(t){if(Array.isArray(t))return xo(t)}(e=new y(t,"getNextTextNode"))||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(e)||function(t,e){if(t){if("string"==typeof t)return xo(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?xo(t,e):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}();var e}function No(t){for(var e,n=t.textNodes,r=t.absOffset,i=0,o=0,a=0;a<n.length;a++){var s=n[a];if(r<=i+s.textContent.length){e=s,o=r-i;break}i+=s.textContent.length}return{node:e,relativeOffset:o}}function jo(t){t.rightLimit=t.currentOffset,t.currentOffset=Math.floor((t.currentOffset+t.leftLimit)/2)}function _o(t){t.leftLimit=t.currentOffset,t.currentOffset=Math.ceil((t.currentOffset+t.rightLimit)/2)}function Ro(t){var e=No({textNodes:t.textNodes,absOffset:t.offset}),n=e.node,r=e.relativeOffset,i=n.ownerDocument.createRange();return i.setStart(n,r),i.collapse(!0),i}function Bo(t){return Bo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Bo(t)}function Mo(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return Io(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Io(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function Io(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function Po(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Lo(r.key),r)}}function Lo(t){var e=function(t){if("object"!=Bo(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=Bo(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Bo(e)?e:e+""}var Ho=function(){return t=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t);var n,r={window,defaultBehavior:!0,mouseMoveSelectionChanges:!1,browserSpellcheck:!0};this.config=Object.assign(r,e),this.win=this.config.window,this.editableSelector=".".concat(i.editableClass),this.dispatcher=new ar(this),!0===this.config.defaultBehavior&&this.dispatcher.on((n=function(t){var e=t.win.document;return{focus:function(t){L(t)&&t.appendChild(e.createTextNode("\ufeff"))},blur:function(t){e.activeElement!==t&&Ft(t)},selection:function(t,e){To(e?"Default selection behavior":"Default selection empty behavior")},cursor:function(t,e){To(e?"Default cursor behavior":"Default cursor empty behavior")},newline:function(t,n){if(n.isAtTextEnd()){var r,i=e.createElement("br");n.insertBefore(i),(null===(r=i.nextSibling)||void 0===r?void 0:r.nodeType)===h&&"\ufeff"===i.nextSibling.textContent[0]||n.insertAfter(e.createTextNode("\ufeff"))}else n.insertBefore(e.createElement("br"));n.setVisibleSelection()},insert:function(t,e,n){var r=t.parentNode,i=t.cloneNode(!1);switch(i.id&&i.removeAttribute("id"),e){case"before":r.insertBefore(i,t),t.focus();break;case"after":r.insertBefore(i,t.nextSibling),i.focus()}},split:function(t,e,n,r){var i=t.cloneNode(!1);for(i.appendChild(e),t.parentNode.insertBefore(i,t);t.firstChild;)t.removeChild(t.firstChild);t.appendChild(n),Pt(i),Pt(t),t.focus()},merge:function(e,n,r){var i,o;switch(n){case"before":i=Ce(e),o=e;break;case"after":i=e,o=ke(e)}i&&o&&(r=i.childNodes.length>0?t.appendTo(i,o.innerHTML):t.prependTo(i,o.innerHTML),o.remove(),r.save(),Pt(i),r.restore(),r.setVisibleSelection())},empty:function(t){To("Default empty behavior")},switch:function(t,e,n){switch(e){case"before":var r=Ce(t);r&&(n.moveAtTextEnd(r),n.setVisibleSelection());break;case"after":var i=ke(t);i&&(n.moveAtBeginning(i),n.setVisibleSelection())}},move:function(t,e,n){To("Default move behavior")},paste:function(e,n,r){if(0!==n.length){if(r.insertBefore(n.shift()),0===n.length)return r.setVisibleSelection();var i=e.parentNode,o=e;n.forEach(function(t){var n=e.cloneNode(!1);n.id&&n.removeAttribute("id");var r=Wt(t);n.appendChild(r),i.insertBefore(n,o.nextSibling),o=n}),t.createCursorAtEnd(o).setVisibleSelection()}},clipboard:function(t,e,n){To("Default clipboard behavior")},toggleBold:function(t){t.toggleBold()},toggleEmphasis:function(t){t.toggleEmphasis()}}}(this),{focus:function(t){n.focus(t)},blur:function(t){n.blur(t)},flow:function(t,e){n.flow(t,e)},selection:function(t,e){n.selection(t,e)},cursor:function(t,e){n.cursor(t,e)},newline:function(t,e){n.newline(t,e)},split:function(t,e,r,i){n.split(t,e,r,i)},insert:function(t,e,r){n.insert(t,e,r)},merge:function(t,e,r){n.merge(t,e,r)},empty:function(t){n.empty(t)},switch:function(t,e,r){n.switch(t,e,r)},move:function(t,e,r){n.move(t,e,r)},clipboard:function(t,e,r){n.clipboard(t,e,r)},paste:function(t,e,r){n.paste(t,e,r)},toggleBold:function(t){n.toggleBold(t)},toggleEmphasis:function(t){n.toggleEmphasis(t)}}))},e=[{key:"add",value:function(t,e){return this.enable(t,e),this}},{key:"remove",value:function(t){var e=m(t,this.win.document);this.disable(e);var n,r=Mo(e);try{for(r.s();!(n=r.n()).done;)n.value.classList.remove(i.editableDisabledClass)}catch(t){r.e(t)}finally{r.f()}return this}},{key:"disable",value:function(t){var e,n=Mo(m(t||".".concat(i.editableClass),this.win.document));try{for(n.s();!(e=n.n()).done;)Ee(e.value)}catch(t){n.e(t)}finally{n.f()}return this}},{key:"enable",value:function(t,e){var n,r=null!=e?e:{},o=r.normalize,a=void 0===o?"boolean"==typeof e&&e:o,s=r.plainText,u=void 0!==s&&s,c=this.config.browserSpellcheck,l=Mo(m(t||".".concat(i.editableDisabledClass),this.win.document));try{for(l.s();!(n=l.n()).done;){var f=n.value;Ae(f,{normalize:a,plainText:u,shouldSpellcheck:c}),this.dispatcher.notify("init",f)}}catch(t){l.e(t)}finally{l.f()}return this}},{key:"suspend",value:function(t){var e,n=Mo(m(t||".".concat(i.editableClass),this.win.document));try{for(n.s();!(e=n.n()).done;)e.value.removeAttribute("contenteditable")}catch(t){n.e(t)}finally{n.f()}return this.dispatcher.suspend(),this}},{key:"continue",value:function(t){var e,n=Mo(m(t||".".concat(i.editableClass),this.win.document));try{for(n.s();!(e=n.n()).done;)e.value.setAttribute("contenteditable",!0)}catch(t){n.e(t)}finally{n.f()}return this.dispatcher.continue(),this}},{key:"createCursor",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"beginning",n=fn.findHost(t,this.editableSelector);if(n){var r=k();return"beginning"===e||"end"===e?(r.selectNodeContents(t),r.collapse("beginning"===e)):t!==n?"before"===e?(r.setStartBefore(t),r.setEndBefore(t)):"after"===e&&(r.setStartAfter(t),r.setEndAfter(t)):o("EditableJS: cannot create cursor outside of an editable block."),new fn(n,r)}}},{key:"createCursorAtCharacterOffset",value:function(t){var e=t.element,n=t.offset,r=No({textNodes:Oo(e),absOffset:n}),i=r.node,o=r.relativeOffset,a=k();a.setStart(i,o),a.collapse(!0);var s=fn.findHost(e,this.editableSelector),u=new fn(s,a);return u.setVisibleSelection(),u}},{key:"createCursorAtBeginning",value:function(t){return this.createCursor(t,"beginning")}},{key:"createCursorAtEnd",value:function(t){return this.createCursor(t,"end")}},{key:"createCursorBefore",value:function(t){return this.createCursor(t,"before")}},{key:"createCursorAfter",value:function(t){return this.createCursor(t,"after")}},{key:"getContent",value:function(t){return Dt(t)}},{key:"appendTo",value:function(t,e){var n=qt(t,this.win.document),r=this.createCursor(n,"end");return r.insertAfter("string"==typeof e?Wt(e):e),r}},{key:"prependTo",value:function(t,e){var n=qt(t,this.win.document),r=this.createCursor(n,"beginning");return r.insertBefore("string"==typeof e?Wt(e):e),r}},{key:"getSelection",value:function(t){var e=this.dispatcher.selectionWatcher.getFreshSelection();if(!t||!e)return e;var n=e.range;return null!=t&&t.isConnected&&function(t,e){var n=document.createRange();n.selectNodeContents(t);var r=e.compareBoundaryPoints(Range.START_TO_START,n),i=e.compareBoundaryPoints(Range.END_TO_END,n);return r>=0&&i<=0}(t,n)?e:void 0}},{key:"setupHighlighting",value:function(t){return this.highlighting=new Eo(this,t),this}},{key:"setupSpellcheck",value:function(t){var e,n=this;t.markerNode&&(e=t.markerNode.outerHTML),this.setupHighlighting({throttle:t.throttle,spellcheck:{marker:e,spellcheckService:t.spellcheckService}}),this.spellcheck={checkSpelling:function(t){n.highlighting.highlight(t)}}}},{key:"highlight",value:function(t){var e=t.editableHost,n=t.text,r=t.highlightId,i=t.textRange,a=t.raiseEvents,s=t.type,u=void 0===s?"comment":s;return i?"number"!=typeof i.start||"number"!=typeof i.end?(o("Error in Editable.highlight: You passed a textRange object with invalid keys. Expected shape: { start: Number, end: Number }"),-1):i.start===i.end?(o("Error in Editable.highlight: You passed a textRange object with equal start and end offsets, which is considered a cursor and therefore unfit to create a highlight."),-1):En.highlightRange(e,n,r,i.start,i.end,a?this.dispatcher:void 0,u):En.highlightText(e,n,r,u,a?this.dispatcher:void 0)}},{key:"getHighlightPositions",value:function(t){var e=t.editableHost,n=t.type;return En.extractHighlightedRanges(e,n)}},{key:"removeHighlight",value:function(t){var e=t.editableHost,n=t.highlightId,r=t.raiseEvents;En.removeHighlight(e,n,r?this.dispatcher:void 0)}},{key:"decorateHighlight",value:function(t){var e=t.editableHost,n=t.highlightId,r=t.addCssClass,i=t.removeCssClass;En.updateHighlight(e,n,r,i)}},{key:"getCssHighlightText",value:function(t){return Ct(t.editableHost).text}},{key:"setCssHighlight",value:function(t){var e=t.name,n=t.ranges;!function(t){var e,n=t.name,r=t.ranges,i=void 0===r?[]:r,o=t.win,a=void 0===o?window:o,s=new Map,u=ft(i);try{for(u.s();!(e=u.n()).done;){var c=e.value,l=c.editableHost,f=c.start,h=c.end,d=s.get(l);d?d.push({start:f,end:h}):s.set(l,[{start:f,end:h}])}}catch(t){u.e(t)}finally{u.f()}if(!s.size)return St({name:n,win:a});var v=vt.get(a);v||vt.set(a,v=new Map),v.set(n,s),kt({name:n,hosts:s,win:a})}({name:e,ranges:void 0===n?[]:n,win:this.win})}},{key:"deleteCssHighlight",value:function(t){St({name:t.name,win:this.win})}},{key:"replaceCssHighlight",value:function(t){var e=t.editableHost,n=t.start,r=t.end,i=t.text,o=wt({editableHost:e,start:n,end:r,win:this.win});return!!o&&(new In(e,o).insertCharacter(i).triggerChange(),!0)}},{key:"getCssHighlightRects",value:function(t){return function(t){var e=t.win,n=void 0===e?window:e,r=wt({editableHost:t.editableHost,start:t.start,end:t.end,win:n});if(r){var i=r.getBoundingClientRect(),o=Array.from(r.getClientRects()),a=st(n),s=a.x,u=a.y;return{bounding:Tt(i,s,u),rects:o.map(function(t){return Tt(t,s,u)})}}}({editableHost:t.editableHost,start:t.start,end:t.end,win:this.win})}},{key:"getCssHighlightCursorOffset",value:function(t){var e=t.editableHost,n=this.getSelection(e);if(null!=n&&n.isCursor){var r=n.range;return function(t){for(var e,n=t.editableHost,r=t.container,i=t.containerOffset,o=r.nodeType===f?r.childNodes[i]:void 0,a=Ct(n),s=a.text,u=a.leading,c=function(t){return Math.min(Math.max(t-u,0),s.length)},l=new y(n),d=0;e=l.getNext();){if(e===o)return c(d);if(e.nodeType!==f||"BR"!==e.nodeName){if(e.nodeType===h&&""!==e.data){if(e===r)return c(d+mt(e.data.slice(0,i)).length);d+=mt(e.data).length}}else d+=1}if(!o&&r.nodeType===f)return c(d)}({editableHost:e,container:r.startContainer,containerOffset:r.startOffset})}}},{key:"on",value:function(t,e){return this.dispatcher.on(t,e),this}},{key:"off",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return this.dispatcher.off.apply(this.dispatcher,e),this}},{key:"unload",value:function(){return this.dispatcher.unload(),this}},{key:"findClosestCursorOffset",value:function(t){var e=t.element,n=t.origCoordinates,r=t.requiredOnFirstLine,i=void 0!==r&&r,o=t.requiredOnLastLine;return function(t){var e=t.host,n=t.requiredOnFirstLine,r=t.requiredOnLastLine,i=t.positionX,o=e.ownerDocument.createRange();o.selectNodeContents(e);var a=o.getBoundingClientRect(),s=Oo(e).reduce(function(t,e){return t+e.textContent.length},0),u=Oo(e);if(0===s)return{wasFound:!1};for(var c,l={currentOffset:Math.floor(s/2),leftLimit:0,rightLimit:s},f=l.currentOffset,h=20;l.leftLimit<l.rightLimit&&h>0;){h=h-=1,f=l.currentOffset;var d=Ro({textNodes:u,offset:l.currentOffset}).getBoundingClientRect();c=Math.abs(d.left-i),n&&a.top!==d.top?jo(l):r&&a.bottom!==d.bottom?_o(l):i<d.left?jo(l):_o(l)}var v=Ro({textNodes:u,offset:l.currentOffset}).getBoundingClientRect(),p=Math.abs(v.left-i);return p<c&&(c=p,f=l.currentOffset),{distance:c,offset:f,wasFound:!0}}({host:e,requiredOnFirstLine:i,requiredOnLastLine:void 0!==o&&o,positionX:this.dispatcher.switchContext?this.dispatcher.switchContext.positionX:n.left})}}],n=[{key:"getGlobalConfig",value:function(){return i}},{key:"globalConfig",value:function(t){Object.assign(i,t),Je(i)}}],e&&Po(t.prototype,e),n&&Po(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,n}();return Ho.parser=n,Ho.content=r,["focus","blur","flow","selection","cursor","newline","insert","split","merge","empty","change","switch","move","clipboard","paste","spellcheckUpdated","selectToBoundary"].forEach(function(t){Ho.prototype[t]=function(e){return this.on(t,e)}}),e=e.Editable,e})());
2
2
  //# sourceMappingURL=editable.js.map