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