Файловый менеджер - Редактировать - /home/pimjdymy/public_html/revisionroad/themes/ee/asset/javascript/compressed/fields/rte/redactorx/redactor.min.js
Назад
var CodeMirror;!function(){function o(t,e){return this.parse(t,e)}function t(t,e){return i=e,h.dom(t).each(function(t){(s=t.dataget(h.namespace))||(s=new p(t,i,r),t.dataset(h.namespace,s),h.instances[r]=s,r++)}),s;var i,s}var i={settings:{},post:function(t){return new s("post",t)},get:function(t){return new s("get",t)},request:function(t,e){return new s(t,e)}},s=function(t,e){this.p=this.extend({method:t,url:"",before:function(){},success:function(){},error:function(){},data:!1,async:!0,headers:{}},e),this.p=this.extend(this.p,i.settings),this.p.method=this.p.method.toUpperCase(),this.prepareData(),this.xhr=new XMLHttpRequest,this.xhr.open(this.p.method,this.p.url,this.p.async),this.setHeaders(),!1!==("function"!=typeof this.p.before||this.p.before(this.xhr))&&this.send()},a=(s.prototype={extend:function(e,i){return i&&Object.keys(i).forEach(function(t){e[t]=i[t]}),e},prepareData:function(){var t;-1===["POST","PUT"].indexOf(this.p.method)||this.isFormData()||(this.p.headers["Content-Type"]="application/x-www-form-urlencoded"),"object"!=typeof this.p.data||this.isFormData()||(this.p.data=this.toParams(this.p.data)),"GET"===this.p.method&&(t=-1!==this.p.url.search(/\?/)?"&":"?",this.p.url=this.p.data?this.p.url+t+this.p.data:this.p.url)},setHeaders:function(){this.xhr.setRequestHeader("X-Requested-With",this.p.headers["X-Requested-With"]||"XMLHttpRequest"),Object.keys(this.p.headers).forEach(function(t){this.xhr.setRequestHeader(t,this.p.headers[t])}.bind(this))},isFormData:function(){return void 0!==window.FormData&&this.p.data instanceof window.FormData},isComplete:function(){return!(this.xhr.status<200||300<=this.xhr.status&&304!==this.xhr.status)},send:function(){this.p.async?(this.xhr.onload=this.loaded.bind(this),this.xhr.send(this.p.data)):(this.xhr.send(this.p.data),this.loaded.call(this))},loaded:function(){var t;this.isComplete()?(t=this.parseResponse(),"function"==typeof this.p.success&&this.p.success(t,this.xhr)):(t=this.parseResponse(),"function"==typeof this.p.error&&this.p.error(t,this.xhr,this.xhr.status))},parseResponse:function(){var t=this.xhr.response,e=this.parseJson(t);return e||t},parseJson:function(t){try{var e=JSON.parse(t);if(e&&"object"==typeof e)return e}catch(t){}return!1},toParams:function(e){return Object.keys(e).map(function(t){return encodeURIComponent(t)+"="+encodeURIComponent(e[t])}).join("&")}},[0]),n="data"+(new Date).getTime(),r=(o.ready=function(t){document.addEventListener("DOMContentLoaded",t)},o.prototype={get length(){return this.nodes.length},parse:function(t,e){var i;if(t){if(t instanceof o)return this.nodes=t.nodes,t;i=/^\s*<(\w+|!)[^>]*>/.test(t)?this.create(t):"string"!=typeof t?t.nodeType&&11===t.nodeType?t.childNodes:t.nodeType||this._isWindowNode(t)?[t]:t:this._query(t,e)}else i=[];this.nodes=this._slice(i)},create:function(t){if(/^<(\w+)\s*\/?>(?:<\/\1>|)$/.test(t))return[document.createElement(RegExp.$1)];var e=[],i=document.createElement("div");i.innerHTML=t;for(var s=0,a=i.childNodes.length;s<a;s++)e.push(i.childNodes[s]);return e},dataset:function(e,i){return this.each(function(t){a[this.dataindex(t.get())][e]=i})},dataget:function(t){return a[this.dataindex(this.get())][t]},dataindex:function(t){var e=t[n],i=a.length;return e||(e=i,t&&(t[n]=i),a[e]={}),e},add:function(t){return this.nodes=this.nodes.concat(this._array(t)),this},get:function(t){return this.nodes[t||0]||!1},getAll:function(){return this.nodes},eq:function(t){return new o(this.nodes[t])},first:function(){return new o(this.nodes[0])},last:function(){return new o(this.nodes[this.nodes.length-1])},contents:function(){return this.get().childNodes},each:function(t){for(var e=this.nodes.length,i=0;i<e;i++)t.call(this,new o(this.nodes[i]),i);return this},is:function(t){return 0<this.filter(t).length},filter:function(e){return void 0===e?this:new o(this.nodes.filter.call(this.nodes,"function"==typeof e?function(t){return e(new o(t))}:function(t){return e&&e.nodeType||e instanceof Node?e===t:(t.matches=t.matches||t.msMatchesSelector||t.webkitMatchesSelector,1===t.nodeType&&t.matches(e||"*"))}))},not:function(e){return this.filter(function(t){return!new o(t).is(e||!0)})},find:function(s){var a=[];return this.each(function(t){for(var t=t.get(),e=this._query(s,t),i=0;i<e.length;i++)a.push(e[i])}),new o(a)},children:function(t){var s=[];return this.each(function(t){t=t.get();if(t.children)for(var e=t.children,i=0;i<e.length;i++)s.push(e[i])}),new o(s).filter(t)},parent:function(t){var e=this.get(),e=e.parentNode||!1;return e?new o(e).filter(t):new o},parents:function(i,s){s=this._context(s);var a=[];return this.each(function(t){for(var e=t.get().parentNode;e&&e!==s;)i&&!new o(e).is(i)||a.push(e),e=e.parentNode}),new o(a)},closest:function(i,s){s=this._context(s);var a=[],n=i&&i.nodeType;return this.each(function(t){var e=t.get();do{if(e&&(n&&e===i||new o(e).is(i)))return a.push(e)}while((e=e.parentNode)&&e!==s)}),new o(a)},next:function(t){return this._sibling(t,"nextSibling")},nextElement:function(t){return this._sibling(t,"nextElementSibling")},prev:function(t){return this._sibling(t,"previousSibling")},prevElement:function(t){return this._sibling(t,"previousElementSibling")},css:function(a,n){var t;return void 0===n&&"object"!=typeof a?(t=this.get(),"width"===a||"height"===a?t.style?this._getHeightOrWidth(a)+"px":void 0:t.style?getComputedStyle(t,null)[a]:void 0):this.each(function(t){var e,i=t.get(),s={};for(e in"object"==typeof a?s=a:s[a]=n,s)i.style&&(i.style[e]=s[e])})},attr:function(a,n,o){var t;return o=o?"data-":"",void 0===n&&"object"!=typeof a?(t=this.get())&&3!==t.nodeType?"checked"===a?t.checked:this._boolean(t.getAttribute(o+a)):void 0:this.each(function(t){var e,i=t.get(),s={};for(e in"object"==typeof a?s=a:s[a]=n,s)3!==i.nodeType&&("checked"===e?i.checked=s[e]:i.setAttribute(o+e,s[e]))})},data:function(t,e){if(void 0!==t&&!0!==t)return this.attr(t,e,!0);function i(t){return t[1].toUpperCase()}var s,a,n,o=/^data-(.+)$/,r=this.get().attributes,p={};for(s in r)r[s]&&o.test(r[s].nodeName)&&(a=r[s].nodeName.match(o)[1],n=r[s].value,!0!==t&&(a=a.replace(/-([a-z])/g,i)),n=-1!==n.search(/^{/)?this._object(n):this._number(n)?parseFloat(n):this._boolean(n),p[a]=n);return p},val:function(e){var t;return void 0===e?(t=this.get()).type&&"checkbox"===t.type?t.checked:t.value:this.each(function(t){t=t.get();t.type&&"checkbox"===t.type?t.checked=e:t.value=e})},removeAttr:function(i){return this.each(function(t){var e=t.get();i.split(" ").forEach(function(t){3!==e.nodeType&&e.removeAttribute(t)})})},addClass:function(t){return this._eachClass(t,"add")},removeClass:function(t){return this._eachClass(t,"remove")},toggleClass:function(t){return this._eachClass(t,"toggle")},hasClass:function(t){var e=this.get();return!!t&&(t=t.split(" "),!!e.classList)&&e.matches("."+t.join("."))},empty:function(){return this.each(function(t){t.get().innerHTML=""})},html:function(t){return void 0===t?this.get().innerHTML||"":this.empty().append(t)},text:function(e){return void 0===e?this.get().textContent||"":this.each(function(t){t.get().textContent=e})},after:function(t){return this._inject(t,function(t,e){if("string"==typeof t)e.insertAdjacentHTML("afterend",t);else if(null!==e.parentNode)for(var i=t instanceof Node?[t]:this._array(t).reverse(),s=0;s<i.length;s++)e.parentNode.insertBefore(i[s],e.nextSibling);return e})},before:function(t){return this._inject(t,function(t,e){if("string"==typeof t)e.insertAdjacentHTML("beforebegin",t);else for(var i=t instanceof Node?[t]:this._array(t),s=0;s<i.length;s++)e.parentNode.insertBefore(i[s],e);return e})},append:function(t){return this._inject(t,function(t,e){if("string"==typeof t||"number"==typeof t)e.insertAdjacentHTML("beforeend",t);else for(var i=t instanceof Node?[t]:this._array(t),s=0;s<i.length;s++)e.appendChild(i[s]);return e})},prepend:function(t){return this._inject(t,function(t,e){if("string"==typeof t||"number"==typeof t)e.insertAdjacentHTML("afterbegin",t);else for(var i=t instanceof Node?[t]:this._array(t).reverse(),s=0;s<i.length;s++)e.insertBefore(i[s],e.firstChild);return e})},wrap:function(t){return this._inject(t,function(t,e){t="string"==typeof t||"number"==typeof t?this.create(t)[0]:t instanceof Node?t:this._array(t)[0];return e.parentNode&&e.parentNode.insertBefore(t,e),t.appendChild(e),t})},unwrap:function(){return this.each(function(t){for(var e=t.get(),i=document.createDocumentFragment();e.firstChild;){var s=e.removeChild(e.firstChild);i.appendChild(s)}e.parentNode.replaceChild(i,e)})},replaceWith:function(t){return this._inject(t,function(t,e){for(var i=document.createDocumentFragment(),s="string"==typeof t||"number"==typeof t?this.create(t):t instanceof Node?[t]:this._array(t),a=0;a<s.length;a++)i.appendChild(s[a]);t=i.childNodes[0];return e.parentNode&&e.parentNode.replaceChild(i,e),t})},remove:function(){return this.each(function(t){t=t.get();t.parentNode&&t.parentNode.removeChild(t)})},clone:function(i){var s=[];return this.each(function(t){var t=t.get(),e=this._clone(t);i&&(e=this._cloneEvents(t,e)),s.push(e)}),new o(s)},show:function(){return this.each(function(t){var e,t=t.get();t.style&&this._hasDisplayNone(t)&&(e=t.getAttribute("domTargetShow"),t.style.display=e||"block",t.removeAttribute("domTargetShow"))}.bind(this))},hide:function(){return this.each(function(t){var e,t=t.get();t.style&&!this._hasDisplayNone(t)&&("block"!==(e=t.style.display)&&t.setAttribute("domTargetShow",e),t.style.display="none")})},scrollTop:function(t){var e=this.get(),i=this._isWindowNode(e),s=9===e.nodeType?e.scrollingElement||e.body.parentNode||e.body||e.documentElement:e;if(void 0===t)return i?e.pageYOffset:s.scrollTop;t=parseInt(t),i?e.scrollTo(0,t):s.scrollTop=t},offset:function(){return this._getPos("offset")},position:function(){return this._getPos("position")},width:function(t){return void 0!==t?this.css("width",parseInt(t)+"px"):this._getSize("width","Width")},height:function(t){return void 0!==t?this.css("height",parseInt(t)+"px"):this._getSize("height","Height")},outerWidth:function(){return this._getSize("width","Width","outer")},outerHeight:function(){return this._getSize("height","Height","outer")},innerWidth:function(){return this._getSize("width","Width","inner")},innerHeight:function(){return this._getSize("height","Height","inner")},click:function(){return this._trigger("click")},focus:function(){return this._trigger("focus")},blur:function(){return this._trigger("blur")},on:function(o,r,p){return this.each(function(t){for(var e=t.get(),i=o.split(" "),s=0;s<i.length;s++){var a=this._getEventName(i[s]),n=this._getEventNamespace(i[s]);r=p?this._getOneHandler(r,o):r,e.addEventListener(a,r),e._e=e._e||{},e._e[n]=e._e[n]||{},e._e[n][a]=e._e[n][a]||[],e._e[n][a].push(r)}})},one:function(t,e){return this.on(t,e,!0)},off:function(o,r){function p(t,e,i){return t===i}function l(t,e,i,s){return e===s}function h(t,e,i,s){return t===i&&e===s}function e(){return!0}return void 0===o?this.each(function(t){this._offEvent(t.get(),!1,!1,r,e)}):this.each(function(t){for(var e=t.get(),i=o.split(" "),s=0;s<i.length;s++){var a=this._getEventName(i[s]),n=this._getEventNamespace(i[s]);"_events"===n?this._offEvent(e,a,n,r,p):a||"_events"===n?this._offEvent(e,a,n,r,h):this._offEvent(e,a,n,r,l)}})},serialize:function(t){for(var e={},i=this.get().elements,s=0;s<i.length;s++){var a=i[s];if((!/(checkbox|radio)/.test(a.type)||a.checked)&&(a.name&&!a.disabled&&"file"!==a.type)){if("select-multiple"===a.type)for(var n=0;n<a.options.length;n++){var o=a.options[n];o.selected&&(e[a.name]=o.value)}e[a.name]=this._number(a.value)?parseFloat(a.value):this._boolean(a.value)}}return t?e:this._params(e)},scroll:function(){this.get().scrollIntoView({behavior:"smooth"})},fadeIn:function(t,e){var i=this._anim(t,e,500);return this.each(function(t){t.css({display:"block",opacity:0,animation:"fadeIn "+i.speed+"s ease-in-out"}).removeClass("hidden"),t.one("animationend",function(){t.css({opacity:"",animation:""}),i.fn&&i.fn(t)})})},fadeOut:function(t,e){var i=this._anim(t,e,300);return this.each(function(t){t.css({opacity:1,animation:"fadeOut "+i.speed+"s ease-in-out"}),t.one("animationend",function(){t.css({display:"none",opacity:"",animation:""}),i.fn&&i.fn(t)})})},slideUp:function(t,e){var i=this._anim(t,e,300);return this.each(function(t){t.height(t.height()),t.css({overflow:"hidden",animation:"slideUp "+i.speed+"s ease-out"}),t.one("animationend",function(){t.css({display:"none",height:"",animation:""}),i.fn&&i.fn(t)})})},slideDown:function(t,e){var i=this._anim(t,e,400);return this.each(function(t){t.height(t.height()),t.css({display:"block",overflow:"hidden",animation:"slideDown "+i.speed+"s ease-in-out"}).removeClass("hidden"),t.one("animationend",function(){t.css({overflow:"",height:"",animation:""}),i.fn&&i.fn(t)})})},_queryContext:function(t,e){return 3!==(e=this._context(e)).nodeType&&"function"==typeof e.querySelectorAll?e.querySelectorAll(t):[]},_query:function(t,e){var i=document;return e?this._queryContext(t,e):/^[.#]?[\w-]*$/.test(t)?"#"===t[0]?(e=i.getElementById(t.slice(1)))?[e]:[]:"."===t[0]?i.getElementsByClassName(t.slice(1)):i.getElementsByTagName(t):i.querySelectorAll(t)},_context:function(t){return t?"string"==typeof t?document.querySelector(t):t:document},_sibling:function(i,s){var a,n=i&&i.nodeType;return this.each(function(t){var e=t.get();do{if((e=e[s])&&(n&&e===i||new o(e).is(i)))return void(a=e)}while(e)}),new o(a)},_slice:function(t){return t&&0!==t.length?t.length?[].slice.call(t.nodes||t):[t]:[]},_array:function(t){if(void 0===t)return[];if(t instanceof NodeList){for(var e=[],i=0;i<t.length;i++)e[i]=t[i];return e}return t instanceof o?t.nodes:t},_object:function(t){t=t.replace(/(\w+:)|(\w+ :)/g,function(t){return'"'+t.substring(0,t.length-1)+'":'});return JSON.parse(t)},_params:function(e){var i="";return Object.keys(e).forEach(function(t){i+="&"+this._encodeUri(t)+"="+this._encodeUri(e[t])}.bind(this)),i.replace(/^&/,"")},_boolean:function(t){return"true"===t||"false"!==t&&t},_number:function(t){return!isNaN(t)&&!isNaN(parseFloat(t))},_inject:function(t,e){for(var i=this.nodes.length,s=[];i--;){var a="function"==typeof t?t.call(this,this.nodes[i]):t,a=0===i?a:this._clone(a),a=e.call(this,a,this.nodes[i]);a&&(a.dom?s.push(a.get()):s.push(a))}return new o(s)},_clone:function(t){if(void 0!==t)return"string"==typeof t?t:t instanceof Node||t.nodeType?t.cloneNode(!0):"length"in t?[].map.call(this._array(t),function(t){return t.cloneNode(!0)}):void 0},_cloneEvents:function(t,e){var i=t._e;if(i)for(var s in(e._e=i)._events)if(i._events.hasOwnProperty(s))for(var a=0;a<i._events[s].length;a++)e.addEventListener(s,i._events[s][a]);return e},_trigger:function(t){var e=this.get();return e&&3!==e.nodeType&&e[t](),this},_encodeUri:function(t){return encodeURIComponent(t).replace(/!/g,"%21").replace(/'/g,"%27").replace(/\(/g,"%28").replace(/\)/g,"%29").replace(/\*/g,"%2A").replace(/%20/g,"+")},_getSize:function(t,e){var i=this.get(),s=0,s=3===i.nodeType?0:9===i.nodeType?this._getDocSize(i,e):this._isWindowNode(i)?window["inner"+e]:this._getHeightOrWidth(t);return Math.round(s)},_getDocSize:function(t,e){var i=t.body,t=t.documentElement;return Math.max(i["scroll"+e],i["offset"+e],t["client"+e],t["scroll"+e],t["offset"+e])},_getPos:function(t){var e,i=this.get(),s={top:0,left:0};return 3===i.nodeType||this._isWindowNode(i)||9===i.nodeType?s:"position"===t?{top:i.offsetTop,left:i.offsetLeft}:"offset"===t?(t=i.getBoundingClientRect(),e=(i=i.ownerDocument).documentElement,i=i.defaultView,{top:t.top+i.pageYOffset-e.clientTop,left:t.left+i.pageXOffset-e.clientLeft}):s},_getHeightOrWidth:function(t,e){var i,s,t=t.charAt(0).toUpperCase()+t.slice(1),e=e||"offset",a=0,n=this.get(),o=getComputedStyle(n,null),r=this.parents().filter(function(t){t=t.get();return 1===t.nodeType&&"none"===getComputedStyle(t,null).display&&t});return"none"===o.display&&r.add(n),0!==r.length?(i="visibility: hidden !important; display: block !important;",s=[],r.each(function(t){var e=t.attr("style");null!==e&&s.push(e),t.attr("style",null!==e?e+";"+i:i)}),a=n[e+t],r.each(function(t,e){void 0===s[e]?t.removeAttr("style"):t.attr("style",s[e])})):a=n[e+t],a},_eachClass:function(i,s){return this.each(function(t){var e;i&&(e=t.get(),i.split(" ").forEach(function(t){e.classList&&e.classList[s](t)}))})},_getOneHandler:function(t,e){var i=this;return function(){t.apply(this,arguments),i.off(e)}},_getEventNamespace:function(t){var t=t.split("."),e=t[1]||"_events";return t[2]?e+t[2]:e},_getEventName:function(t){return t.split(".")[0]},_offEvent:function(t,e,i,s,a){for(var n in t._e)if(t._e.hasOwnProperty(n))for(var o in t._e[n])if(a(o,n,e,i))for(var r=t._e[n][o],p=0;p<r.length;p++)void 0!==s&&r[p].toString()!==s.toString()||(t.removeEventListener(o,r[p]),t._e[n][o].splice(p,1),0===t._e[n][o].length&&delete t._e[n][o],0===Object.keys(t._e[n]).length&&delete t._e[n])},_hasDisplayNone:function(t){return"none"===t.style.display||"none"===(t.currentStyle||getComputedStyle(t,null)).display},_anim:function(t,e,i){return t="function"==typeof t?(e=t,i):t||i,{fn:e,speed:t/1e3}},_isWindowNode:function(t){return t===window||t.parent&&t.parent===window}},0),h=t,p=(h.dom=function(t,e){return new o(t,e)},h.ajax=i,h.instances=[],h.namespace="redactorx",h.prefix="rx",h.version="1.4.6",h.settings={},h.lang={},h._mixins={},h._repository={},h._subscribe={},h.keycodes={BACKSPACE:8,DELETE:46,UP:38,DOWN:40,ENTER:13,SPACE:32,ESC:27,TAB:9,CTRL:17,META:91,SHIFT:16,ALT:18,RIGHT:39,LEFT:37},h.add=function(t,e,i){var s;if(i.translations&&(h.lang=h.extend(!0,h.lang,i.translations)),i.defaults&&((s={})[e]=i.defaults,h.opts=h.extend(!0,h.opts,s)),"mixin"===t)h._mixins[e]=i;else{if(i.subscribe)for(var a in i.subscribe)if(i.subscribe.hasOwnProperty(a))for(var n=a.split(","),o=0;o<n.length;o++){var r=n[o].trim();void 0===h._subscribe[r]&&(h._subscribe[r]=[]),h._subscribe[r].push({module:e,func:i.subscribe[a]})}function p(){}if((p.prototype=i).mixins)for(var l=0;l<i.mixins.length;l++)h.inherit(p,h._mixins[i.mixins[l]]);h._repository[e]={type:t,proto:p,obj:i}}},h.extend=function(){var t={},e=!1,i=0,s=arguments.length;for("[object Boolean]"===Object.prototype.toString.call(arguments[0])&&(e=arguments[0],i++);i<s;i++){a=void 0;var a,n=arguments[i];for(a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e&&"[object Object]"===Object.prototype.toString.call(n[a])?t[a]=h.extend(!0,t[a],n[a]):t[a]=n[a])}return t},h.error=function(t){throw t},h.inherit=function(t,e){function i(){}i.prototype=e;var s,a=new i;for(s in t.prototype)t.prototype.__lookupGetter__(s)?a.__defineGetter__(s,t.prototype.__lookupGetter__(s)):a[s]=t.prototype[s];return t.prototype=a,t.prototype.super=e,t},h.addLang=function(t,e){void 0===h.lang[t]&&(h.lang[t]={}),h.lang[t]=h.extend(!0,h.lang[t],e)},t.opts={plugins:[],content:!1,placeholder:!1,classes:!1,draggable:!1,editor:{classname:"content",focus:!1,sync:!0,drop:!0,lang:"en",add:"top",https:!1,enterKey:!0,scrollTarget:window,direction:"ltr",spellcheck:!0,grammarly:!1,notranslate:!1,reloadmarker:!0,minHeight:"40px",maxHeight:!1},codemirrorSrc:!1,codemirror:!1,source:!0,autosave:{url:!1,name:!1,data:!1,method:"post"},state:{limit:100},clean:{comments:!1,enter:!0,enterinline:!1},tab:{key:!0,spaces:!1},link:{size:30,nofollow:!1,target:!1},tooltip:{context:!0},topbar:!0,context:!1,control:!1,reorder:!1,buttons:{addbar:["paragraph","image","embed","table","quote","pre","line"],context:["bold","italic","deleted","code","link"],topbar:["shortcut"],editor:["add","html","format","bold","italic","deleted","link"],toolbar:!1,tags:{b:["bold"],strong:["bold"],i:["italic"],em:["italic"],del:["deleted"],u:["underline"],a:["link"]},types:!1,icons:!1,hidden:{}},addbar:{add:{},hide:[]},toolbar:{hide:[],sticky:!0,stickyMinHeight:200,stickyTopOffset:0},paste:{clean:!0,autoparse:!0,paragraphize:!0,plaintext:!1,linkTarget:!1,images:!0,links:!0,keepClass:[],keepStyle:[],keepAttrs:["td","th"],formTags:["form","input","button","select","textarea","legend","fieldset"],blockTags:["pre","h1","h2","h3","h4","h5","h6","table","tbody","thead","tfoot","th","tr","td","ul","ol","li","blockquote","p","hr","figure","iframe","figcaption","address"],inlineTags:["a","svg","img","br","strong","ins","code","del","span","samp","kbd","sup","sub","mark","var","cite","small","b","u","em","i","abbr"]},image:{states:!0,upload:!1,url:!0,select:!1,selectMethod:"get",name:"file",data:!1,drop:!0,multiple:!0,clipboard:!0,types:["image/*"],tag:"figure",newtab:!1,link:!0,width:!1},noneditable:{classname:"noneditable"},embed:{responsive:"embed-responsive",script:!0,checkbox:!0},pre:{template:"<pre></pre>",spaces:4},line:!0,table:{template:"<table><tr><td></td><td></td></tr><tr><td></td><td></td></tr></table>",nowrap:"nowrap"},quote:{template:"<blockquote><p>Quote...</p><p><cite>Author Attribution</cite></p></blockquote>"},format:["p","h1","h2","h3","ul","ol"],formatAdd:!1,shortcutsRemove:!1,shortcutsBase:{"meta+z":"## shortcuts.meta-z ##","meta+shift+z":"## shortcuts.meta-shift-z ##","meta+a":"## shortcuts.meta-a ##"},shortcuts:{"ctrl+shift+o, meta+shift+o":{title:"## shortcuts.meta-shift-o ##",name:"meta+shift+o",command:"addbar.popup"},"ctrl+shift+d, meta+shift+d":{title:"## shortcuts.meta-shift-d ##",name:"meta+shift+d",command:"block.duplicate"},"ctrl+shift+up, meta+shift+up":{title:"## shortcuts.meta-shift-up ##",name:"meta+shift+↑",command:"block.moveUp"},"ctrl+shift+down, meta+shift+down":{title:"## shortcuts.meta-shift-down ##",name:"meta+shift+↓",command:"block.moveDown"},"ctrl+shift+m, meta+shift+m":{title:"## shortcuts.meta-shift-m ##",name:"meta+shift+m",command:"inline.removeFormat"},"ctrl+b, meta+b":{title:"## shortcuts.meta-b ##",name:"meta+b",command:"inline.set",params:{tag:"b"}},"ctrl+i, meta+i":{title:"## shortcuts.meta-i ##",name:"meta+i",command:"inline.set",params:{tag:"i"}},"ctrl+u, meta+u":{title:"## shortcuts.meta-u ##",name:"meta+u",command:"inline.set",params:{tag:"u"}},"ctrl+h, meta+h":{title:"## shortcuts.meta-h ##",name:"meta+h",command:"inline.set",params:{tag:"sup"}},"ctrl+l, meta+l":{title:"## shortcuts.meta-l ##",name:"meta+l",command:"inline.set",params:{tag:"sub"}},"ctrl+alt+0, meta+alt+0":{title:"## shortcuts.meta-alt-0 ##",name:"meta+alt+0",command:"block.format",params:{tag:"p"}},"ctrl+alt+1, meta+alt+1":{title:"## shortcuts.meta-alt-1 ##",name:"meta+alt+1",command:"block.format",params:{tag:"h1"}},"ctrl+alt+2, meta+alt+2":{title:"## shortcuts.meta-alt-2 ##",name:"meta+alt+2",command:"block.format",params:{tag:"h2"}},"ctrl+alt+3, meta+alt+3":{title:"## shortcuts.meta-alt-3 ##",name:"meta+alt+3",command:"block.format",params:{tag:"h3"}},"ctrl+alt+4, meta+alt+4":{title:"## shortcuts.meta-alt-4 ##",name:"meta+alt+4",command:"block.format",params:{tag:"h4"}},"ctrl+alt+5, meta+alt+5":{title:"## shortcuts.meta-alt-5 ##",name:"meta+alt+5",command:"block.format",params:{tag:"h5"}},"ctrl+alt+6, meta+alt+6":{title:"## shortcuts.meta-alt-6 ##",name:"meta+alt+6",command:"block.format",params:{tag:"h6"}},"ctrl+shift+7, meta+shift+7":{title:"## shortcuts.meta-shift-7 ##",name:"meta+shift+7",command:"block.format",params:{tag:"ol"}},"ctrl+shift+8, meta+shift+8":{title:"## shortcuts.meta-shift-8 ##",name:"meta+shift+8",command:"block.format",params:{tag:"ul"}},"ctrl+], meta+]":{title:"## shortcuts.meta-indent ##",name:"meta+]",command:"list.indent"},"ctrl+[, meta+[":{title:"## shortcuts.meta-outdent ##",name:"meta+[",command:"list.outdent"},"ctrl+k, meta+k":{title:"## shortcuts.meta-k ##",name:"meta+k",command:"link.format"}},paddingControl:"24px 26px",paddingNormal:"20px",buttonsObj:{add:{title:"## buttons.add ##",command:"addbar.popup"},html:{title:"## buttons.html ##",command:"source.toggle"},format:{title:"## buttons.format ##",command:"format.popup"},duplicate:{title:"## buttons.duplicate ##",command:"block.duplicate"},trash:{title:"## buttons.delete ##",command:"block.remove"},undo:{title:"## buttons.undo ##",command:"state.undo"},redo:{title:"## buttons.redo ##",command:"state.redo"},shortcut:{title:"## buttons.shortcuts ##",command:"shortcut.popup"},bold:{title:"## buttons.bold ##",command:"inline.set",params:{tag:"b"}},italic:{title:"## buttons.italic ##",command:"inline.set",params:{tag:"i"}},deleted:{title:"## buttons.deleted ##",command:"inline.set",params:{tag:"del"}},code:{title:"## buttons.code ##",command:"inline.set",params:{tag:"code"}},link:{title:"## buttons.link ##",command:"link.popup"},mark:{title:"## buttons.mark ##",command:"inline.set",params:{tag:"mark"}},sub:{title:"## buttons.subscript ##",command:"inline.set",params:{tag:"sub"}},sup:{title:"## buttons.superscript ##",command:"inline.set",params:{tag:"sup"}},kbd:{title:"## buttons.shortcut ##",command:"inline.set",params:{tag:"kbd"}},paragraph:{title:"## blocks.paragraph ##",command:"block.add",params:{name:"paragraph"}},image:{title:"## blocks.image ##",command:"image.popup",observer:"image.observe"},embed:{title:"## blocks.embed ##",command:"embed.popup",observer:"embed.observe"},"table-tune":{title:"## buttons.column-settings ##",command:"table.cellSetting",icon:"tune"},indent:{title:"## buttons.indent ##",command:"list.indent"},outdent:{title:"## buttons.outdent ##",command:"list.outdent"},line:{title:"## blocks.line ##",command:"block.add",observer:"block.observe",params:{name:"line"}},table:{title:"## blocks.table ##",command:"table.add",observer:"table.observe",params:{name:"table"}},quote:{title:"## blocks.quote ##",command:"block.add",observer:"block.observe",params:{name:"quote"}},pre:{title:"## blocks.pre ##",command:"block.add",observer:"block.observe",params:{name:"pre"}}},formatObj:{p:{title:"## format.p ##",type:"paragraph",shortcut:"Ctrl+Alt+0"},h1:{title:'<span style="font-size: 20px; font-weight: bold;">## format.h1 ##</span>',type:"heading",shortcut:"Ctrl+Alt+1"},h2:{title:'<span style="font-size: 16px; font-weight: bold;">## format.h2 ##</span>',type:"heading",shortcut:"Ctrl+Alt+2"},h3:{title:'<span style="font-weight: bold;">## format.h3 ##</span>',type:"heading",shortcut:"Ctrl+Alt+3"},h4:{title:'<span style="font-weight: bold;">## format.h4 ##</span>',type:"heading",shortcut:"Ctrl+Alt+4"},h5:{title:'<span style="font-weight: bold;">## format.h5 ##</span>',type:"heading",shortcut:"Ctrl+Alt+5"},h6:{title:'<span style="font-weight: bold;">## format.h6 ##</span>',type:"heading",shortcut:"Ctrl+Alt+6"},ol:{title:"1. ## format.ol ##",type:"list",shortcut:"Ctrl+Shift+7"},ul:{title:"• ## format.ul ##",type:"list",shortcut:"Ctrl+Shift+8"},address:{title:"<em>## format.address ##</em>",type:"address"},dl:{title:"## format.dl ##",type:"dlist"}},markerChar:"\ufeff",containers:{main:["toolbar","editor","source","statusbar"]},tags:{denied:["font","html","head","link","title","body","meta","applet","marquee"],incode:["!DOCTYPE","!doctype","html","head","link","title","body","meta","textarea","style"],form:["form","input","button","select","textarea","legend","fieldset"],inline:["a","svg","span","strong","strike","b","u","em","i","code","del","ins","samp","kbd","sup","sub","mark","var","cite","small","abbr"],block:["pre","hr","ul","ol","li","p","h1","h2","h3","h4","h5","h6","dl","dt","dd","div","table","tbody","thead","tfoot","tr","th","td","blockquote","output","figcaption","figure","address","main","section","header","footer","aside","article","iframe"],parser:["pre","hr","ul","ol","p","h1","h2","h3","h4","h5","h6","table","address","blockquote","figure","iframe","form","dl","div","section","header","footer","article","main","aside"]},bsmodal:!1,regex:{youtube:/^https?\:\/\/(?:www\.youtube(?:\-nocookie)?\.com\/|m\.youtube\.com\/|youtube\.com\/)?(?:ytscreeningroom\?vi?=|youtu\.be\/|vi?\/|user\/.+\/u\/\w{1,2}\/|embed\/|watch\?(?:.*\&)?vi?=|\&vi?=|\?(?:.*\&)?vi?=)([^#\&\?\n\/<>"']*)/gi,vimeo:/(http|https)?:\/\/(?:www.|player.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/(?:[^/]*)\/videos\/|album\/(?:\d+)\/video\/|video\/|)(\d+)(?:\/[a-zA-Z0-9_-]+)?/gi,imageurl:/((https?|www)[^\s]+\.)(jpe?g|png|gif)(\?[^\s-]+)?/gi,url:/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z\u00F0-\u02AF0-9()!@:%_+.~#?&//=]*)/gi,aurl1:/(\b(https?|ftp):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gim,aurl2:/(^|[^\/])(www\.[\S]+(\b|$))/gim}},t.lang.en={accessibility:{"help-label":"Rich text editor"},placeholders:{figcaption:"Type caption (optional)"},popup:{back:"Back",link:"Link",add:"Add",image:"Image","add-image":"Add Image"},shortcuts:{"meta-a":"Select all","meta-z":"Undo","meta-shift-z":"Redo","meta-shift-m":"Remove inline format","meta-b":"Bold","meta-i":"Italic","meta-u":"Underline","meta-h":"Superscript","meta-l":"Subscript","meta-k":"Link","meta-alt-0":"Normal text","meta-alt-1":"Heading 1","meta-alt-2":"Heading 2","meta-alt-3":"Heading 3","meta-alt-4":"Heading 4","meta-alt-5":"Heading 5","meta-alt-6":"Heading 6","meta-shift-7":"Ordered List","meta-shift-8":"Unordered List","meta-indent":"Indent","meta-outdent":"Outdent","meta-shift-backspace":"Delete","meta-shift-o":"Add","meta-shift-d":"Duplicate","meta-shift-up":"Move up","meta-shift-down":"Move down"},buttons:{add:"Add",html:"HTML",format:"Format",bold:"Bold",italic:"Italic",deleted:"Deleted",link:"Link",list:"List",image:"Image",indent:"Indent",outdent:"Outdent",embed:"Embed",table:"Table",insert:"Insert",save:"Save",cancel:"Cancel",delete:"Delete",duplicate:"Duplicate",shortcut:"Shortcuts",underline:"Underline",undo:"Undo",redo:"Redo",code:"Code",mark:"Mark",subscript:"Subscript",superscript:"Superscript",kbd:"Shortcut","column-settings":"Column settings"},blocks:{text:"Text",paragraph:"Paragraph",image:"Image",embed:"Embed",line:"Line",table:"Table",quote:"Quote",pre:"Code",address:"Address"},format:{p:"Normal Text",h1:"Heading 1",h2:"Heading 2",h3:"Heading 3",h4:"Heading 4",h5:"Heading 5",h6:"Heading 6",address:"Address",ul:"Unordered List",ol:"Ordered List",dl:"Definition List"},embed:{embed:"Embed",caption:"Caption",description:"Paste any embed/html code or enter the url (vimeo or youtube video only)","responsive-video":"Responsive video"},image:{or:"or","alt-text":"Alt Text",link:"Link",width:"Width",caption:"Caption","link-in-new-tab":"Open link in new tab","url-placeholder":"Paste url of image...","upload-new-placeholder":"Drag to upload a new image<br>or click to select"},link:{link:"Link","edit-link":"Edit Link",unlink:"Unlink","link-in-new-tab":"Open link in new tab",text:"Text",url:"URL"},table:{width:"Width",nowrap:"Nowrap",column:"Column","add-head":"Add head","remove-head":"Remove head","add-row-below":"Add row below","add-row-above":"Add row above","remove-row":"Remove row","add-column-after":"Add column after","add-column-before":"Add column before","remove-column":"Remove column","delete-table":"Delete table"}},function(t,e,i){for(var s=["keycodes","prefix","dom","ajax","_repository","_subscribe"],a=0;a<s.length;a++)this[s[a]]=h[s[a]];this.uuid=i,this.$win=this.dom(window),this.$doc=this.dom(document),this.$body=this.dom("body"),this.$element=t,(this.app=this).initialSettings=e,this._initer=["setting","lang"],this._priority=["container","editor","state","accessibility"],this._plugins=[],this.started=!1,this.start()});p.prototype={start:function(t){!this.isTextarea()||this.isStarted()||(t&&(this.initialSettings=t),this._initCore(),this._plugins=this.setting.get("plugins"),this.broadcast("app.before.start"),this._initModules(),this._initPlugins(),this._startPriority(),this._startModules(),this._startPlugins(),this.started=!0,this.broadcast("app.start"),this._loadModulesAndPlugins())},isStarted:function(){return this.started},isTextarea:function(){return"TEXTAREA"===this.$element.get().tagName},stop:function(){this.isStopped()||(this.broadcast("app.before.stop"),this._stopPlugins(),this._stopPriority(),this._stopModules(),this.started=!1,this.broadcast("app.stop"))},isStopped:function(){return!this.started},destroy:function(){clearTimeout(this.app.sync.typingTimer),this.stop(),this.broadcast("app.destroy"),this.$element.dataset(h.namespace,!1);var t=h.instances.indexOf(this.uuid);-1<t&&h.instances.splice(t,1)},broadcast:function(t,e){var i=e instanceof p.Event?e:new p.Event(t,e);if(void 0!==this._subscribe[t])for(var s=this._subscribe[t],a=0;a<s.length;a++){var n=this[s[a].module];n&&s[a].func.call(n,i)}e=this.setting.has("subscribe")?this.setting.get("subscribe"):{};return"function"==typeof e[t]&&e[t].call(this,i),i},broadcastParams:function(t,e){return this.broadcast(t,e).getAll()},broadcastHtml:function(t,e){return this.broadcast(t,{html:e}).get("html")},create:function(t){void 0===this._repository[t]&&h.error('The class "'+t+'" does not exist.');for(var e,i=[].slice.call(arguments,1),s=new this._repository[t].proto,a=(s._name=t,s.app=this,["uuid","prefix","dom","ajax"]),n=0;n<a.length;n++)s[a[n]]=this[a[n]];return this.lang&&(s.lang=this.lang),this.opts&&(s.opts=this.opts),(e=s.init?s.init.apply(s,i):e)||s},api:function(t){for(var e=[].slice.call(arguments,1),i=t.split("."),s=i.pop(),a=this,n=0;n<i.length;n++)a=a[i[n]];if(a&&"function"==typeof a[s])return a[s].apply(a,e)},_initCore:function(){for(var t=0;t<this._initer.length;t++)this[this._initer[t]]=this.create(this._initer[t]);this.setting&&(this.opts=this.setting.dump())},_initModules:function(){for(var t in this._repository)"module"===this._repository[t].type&&-1===this._initer.indexOf(t)&&(this[t]=this.create(t))},_initPlugins:function(){var t,e=this.setting.get("plugins");for(t in this._repository)"plugin"===this._repository[t].type&&-1!==e.indexOf(t)&&(this[t]=this.create(t))},_startPriority:function(){for(var t=0;t<this._priority.length;t++)this._call(this[this._priority[t]],"start")},_startModules:function(){this._iterate("module","start")},_startPlugins:function(){this._iterate("plugin","start")},_stopPriority:function(){for(var t=this._priority.slice().reverse(),e=0;e<t.length;e++)this._call(this[t[e]],"stop")},_stopModules:function(){this._iterate("module","stop")},_stopPlugins:function(){this._iterate("plugin","stop")},_loadModulesAndPlugins:function(){this._iterate("module","load"),this._iterate("plugin","load")},_iterate:function(t,e){for(var i in this._repository){var s;this._repository.hasOwnProperty(i)&&(s="module"===t?"load"===e||-1===this._priority.indexOf(i):-1!==this._plugins.indexOf(i),this._repository[i].type===t)&&s&&this._call(this[i],e)}},_call:function(t,e){"function"==typeof t[e]&&t[e].apply(t)}},p.Event=function(t,e){this.name=t,this.params=void 0===e?{}:e,this.stopped=!1},p.Event.prototype={is:function(t){if(!Array.isArray(t))return this.get(t);for(var e=0;e<t.length;e++)if(this.params[t[e]])return!0},has:function(t){return void 0!==this.params[t]},getAll:function(){return this.params},get:function(t){return this.params[t]},set:function(t,e){this.params[t]=e},stop:function(){this.stopped=!0},isStopped:function(){return this.stopped}},t.add("mixin","block",{defaults:{id:{getter:"getId",setter:"setId"},html:{getter:"getHtml",setter:"setHtml"}},init:function(t,e){this.$block=t?this.dom(t):this.create(e),this._build(e),this._buildData(),this._render()},isType:function(t){return-1!==(Array.isArray(t)?t:[t]).indexOf(this.type)},isBlock:function(){return!0},isEditable:function(){return void 0!==this.editable&&!0===this.editable},isFigcaption:function(){return"figcaption"===this.type},isSecondLevel:function(){return-1!==["quoteitem","row","cell"].indexOf(this.type)},isNested:function(){return-1!==["quote","table"].indexOf(this.type)},isFirstLevel:function(){return this.$block.attr("data-"+this.prefix+"-first-level")},isAllSelected:function(){return!this.isEditable()||this.app.selection.isAll(this.$block)},isEmpty:function(t){var e=this.$block.text(),e=this._cleanEmpty(e);return""===(e=t?e.trim():e)},isCaretStart:function(){var t;return"pre"===this.getType()?this.app.caret.is(this.$block,"start",!1,!1):"list"===this.getType()?(t=this.app.selection.getCurrent(),0===this.dom(t).closest("li").prev().length&&this.app.caret.is(this.$block,"start")):!this.isEditable()||this.app.caret.is(this.$block,"start")},isCaretEnd:function(){return"pre"===this.getType()?this.app.caret.is(this.$block,"end",!1,!1):"address"===this.getType()?this.app.caret.is(this.$block,"end",!1,!0,!1):!this.isEditable()||this.app.caret.is(this.$block,"end")},isAllowedButton:function(t,e){var i=this.getType();if(void 0!==this.opts.buttons.hidden[i]){var s=this.opts.buttons.hidden[i];if(Array.isArray(s)&&-1!==s.indexOf(t))return!1}if(void 0===e.blocks)return!0;s=e.blocks;if(s.except&&-1!==s.except.indexOf(i))return!1;if(s.all){if(!0===s.all||"all"===s.all)return!0;if("editable"===s.all&&-1!==["heading","paragraph","list","address","quote","table"].indexOf(i))return!0;if("first-level"===s.all&&this.isFirstLevel())return!0;if("noneditable"===s.all&&-1!==["image","embed","layer","line"].indexOf(i))return!0}return!(!Array.isArray(s.types)||-1===s.types.indexOf(i))},getData:function(t){var e={};return Object.keys(this.data).forEach(function(t){e[t]=this[this.data[t].getter].apply(this)}.bind(this)),t?e[t]:e},getOffset:function(){return this.$block.offset()},getType:function(){return this.type},getTag:function(){return!!this.$block&&this.$block.get().tagName.toLowerCase()},getBlock:function(){return this.$block},getHtml:function(){return this.$block.html()},getPlainText:function(){var t=this.$block.html();return this.app.content.getTextFromHtml(t,{nl:!0})},getOuterHtml:function(){return this.$block.get().outerHTML},getFirstLevel:function(){var t=this.$block.closest("[data-"+this.prefix+"-first-level]");return 0!==t.length&&t.dataget("instance")},getParent:function(t){t=t?"="+t:"";t=this.$block.parent().closest("[data-"+this.prefix+"-type"+t+"]");return 0!==t.length&&t.dataget("instance")},getNext:function(t){t=t?"="+t:"";var e=this.$block.nextElement();return!(0===e.length||!e.is("[data-"+this.prefix+"-type"+t+"]"))&&e.dataget("instance")},getPrev:function(t){t=t?"="+t:"";var e=this.$block.prevElement();return!(0===e.length||!e.is("[data-"+this.prefix+"-type"+t+"]"))&&e.dataget("instance")},getChildFirst:function(t){t=this.$block.find("[data-"+this.prefix+"-type"+(t=t?"="+t:"")+"]").first();return 0!==t.length&&t.dataget("instance")},getChildLast:function(t){t=this.$block.find("[data-"+this.prefix+"-type"+(t=t?"="+t:"")+"]").last();return 0!==t.length&&t.dataget("instance")},getId:function(){return this.$block.attr("id")},getCaption:function(){var t=this.$block.find("figcaption");return 0!==t.length?t.html().trim():""},setData:function(t){for(var e in t)this.data[e]&&this[this.data[e].setter].call(this,t[e])},setEmpty:function(){this.$block.html("")},setSelectAll:function(){this.isEditable()&&this.app.selection.select(this.$block)},setHtml:function(t){this.$block.html(t)},setId:function(t){""===t?this.$block.removeAttr("id"):this.$block.attr("id",t)},setCaption:function(t){var e;""===t?this.$block.find("figcaption").remove():(0===(e=this.$block.find("figcaption")).length&&((e=this.dom("<figcaption>")).attr("data-placeholder",this.lang.get("placeholders.figcaption")),this.$block.append(e),this.app.create("block.figcaption",e)),e.html(t))},setClassFromObj:function(t,e){this._removeObjClasses(t);t=t[e];"none"===t&&!1===t||this.$block.addClass(t)},setCaret:function(t){this.app.caret.set(this.$block,t)},moveUp:function(){var t=this.getPrev();t&&this._move(t,"before")},moveDown:function(){var t=this.getNext();t&&this._move(t,"after")},remove:function(t){var e=this.getType();this.$block.remove(),t&&this.app.broadcast("block.remove",{type:e})},appendNext:function(){var t,e,i,s,a,n=this.getNext();n.isEmpty()?n.remove():this.isEmpty()?(this.remove(),this.app.block.set(n,"start")):(t=n.getHtml(),a=this.getType(),i=n.getType(),s=e=!0,"pre"===a&&"pre"!==i&&(t=n.getPlainText()),"list"===i&&(s="list"===a?(i=n.getBlock().children(),this.$block.append(i),!(e=!1)):(t=this._appendListHtml(n.getBlock(),t),n.isEmpty())),e&&((a=this.app.selection.getTopInline())&&this.app.caret.set(a,"after"),this.app.insertion.insertHtml(t,"start")),s&&n.remove())},appendToPrev:function(){var t,e,i,s,a,n=this.getPrev();this.isEmpty()?(this.remove(),this.app.block.set(n,"end")):n.isEmpty()?n.remove():(a=n.getType(),t=this.getHtml(),s=e=!0,"pre"!==(i=this.getType())&&"pre"===a&&(t=this.getPlainText()),"list"===i&&(s="list"===a?(i=this.getBlock().children(),this.app.block.set(n,"end"),n.getBlock().append(i),!(e=!1)):(t=this._appendListHtml(this.getBlock(),t),this.isEmpty())),e&&(this.app.block.set(n,"end"),(a=this.app.selection.getTopInline())&&this.app.caret.set(a,"after"),this.app.insertion.insertHtml(t,"start")),s&&this.remove())},insertEmpty:function(t){return(t=t||{}).instance=this.app.block.create(),this.insert(t)},insert:function(t){var t=h.extend({},{instance:!1,position:"after",caret:!1,remove:!0,type:"input"},t),e=t.instance.getBlock();return"list"===t.instance.getType()&&"list"===this.getType()?this.app.insertion.insertListToList(e,this.$block,t.caret):("split"===t.position?this.app.element.split(this.$block).before(e):this.$block[t.position](e),t.remove&&this.isEditable()&&this.isEmpty()&&this.remove()),this.app.editor.build(),t.caret&&this.app.block.set(t.instance,t.caret),this.app.toolbar.observe(),this.app.context.observe(),this.app.broadcast("block.add",{instance:t.instance,type:t.type}),t.instance},change:function(t,e){var i=t.getBlock();this.$block.after(i),this.$block.remove(),this.app.editor.build(),this.app.block.set(t),!1!==e&&this.app.broadcast("block.change",{instance:t})},duplicate:function(t){var e=this.getType(),i=this.$block.clone();return i.removeClass(this.prefix+"-block-focus"),t&&i.html(""),this.app.create("block."+e,i)},duplicateEmpty:function(){return this.duplicate(!0)},_build:function(t){this.build&&this.build(t)},_buildData:function(){this.data||(this.data={}),this.data=h.extend({},!0,this.defaults,this.data)},_buildItems:function(t,e){t=this.$block.find(t);0!==t.length&&t.each(function(t){this.app.create("block."+e,t)}.bind(this))},_buildCaption:function(){"figure"===this.getTag()&&this.$block.find("figcaption").attr("data-placeholder",this.lang.get("placeholders.figcaption"))},_render:function(){this._renderEdit()},_renderEdit:function(){this.$block.dataset("instance",this),this.$block.attr("data-"+this.prefix+"-type",this.getType()),void 0!==this.editable&&!1===this.editable?this.$block.attr("contenteditable",!1):"figcaption"===this.type&&this.$block.attr("contenteditable",!0)},_cleanEmpty:function(t){return t=(t=-1!==(t=this.app.utils.removeInvisibleChars(t)).search(/^<br\s?\/?>$/)?"":t).replace(/\n/g,"")},_appendListHtml:function(t,e){t=t.find("li").first();return e=(e=(e=t.html().trim()).replace(/<\/li>/gi,"</li><br>")).replace(/<(ul|ol)/gi,"<br><$1"),e=(e=(e=this.app.content.removeTags(e,["ul","ol","li"])).trim()).replace(/<br\s?\/?>$/gi,""),t.remove(),e},_move:function(t,e){var i=this;i.isNested()&&(i=i.getFirst()),(this.isEditable()||this.isNested())&&this.app.selection.save(i.getBlock()),t.getBlock()[e](this.$block),this.app.block.set(i,!1,!0),(this.isEditable()||this.isNested())&&this.app.selection.restore(!1)},_removeObjClasses:function(t){t=this._buildObjClasses(t);this.$block.removeClass(t.join(" ")),this.app.element.removeEmptyAttrs(this.$block,["class"])},_buildObjClasses:function(t){var e,i=[];for(e in t)t[e]&&i.push(t[e]);return i}}),t.add("mixin","tool",{init:function(t,e,i,s){this.name=t,this.setter=i.get("setter"),this.popup=i,this.data=s,this.obj=this._observe(e),this.obj&&this._build()},getElement:function(){return this.$tool},getInput:function(){return this.$input},getValue:function(){return this.$input.val().trim()},setValue:function(t){this.$input.val(t)},setFocus:function(){this.$input.focus()},trigger:function(t){this.setValue(t),this.setter&&this.app.api(this.setter,this.popup)},_build:function(){this._buildTool(),this._buildLabel(),this._buildInputElement(),this._buildInput(),this._buildEvent(),this._has("placeholder")&&this.$input.attr("placeholder",this.lang.parse(this.obj.placeholder)),this._has("width")&&this.$input.css("width",this.obj.width),this._has("classname")&&this.$input.addClass(this.obj.classname)},_buildInputElement:function(){this.$input=this.dom("<"+this._getInputParam("tag")+">").addClass(this.prefix+this._getInputParam("classname")),this.$input.attr({name:this.name,type:this._getInputParam("type"),"data-type":this.type}),this.$input.dataset("instance",this)},_buildInput:function(){},_buildEvent:function(){var t;-1===["segment"].indexOf(this.type)&&this.setter&&(t="checkbox"===this.type||"select"===this.type?"change":"keydown blur",t="number"===this.type?t+" change":t,this.$input.on(t,this._catchSetter.bind(this)))},_buildTool:function(){this.$tool=this.dom("<div>").addClass(this.prefix+"-form-item").dataset("instance",this)},_buildLabel:function(){"checkbox"!==this.type&&this._has("label")&&(this.$label=this.dom("<label>").addClass(this.prefix+"-form-label").html(this.lang.parse(this.obj.label)),this.$tool.append(this.$label))},_getInputParam:function(t){return this.input&&void 0!==this.input[t]?this.input[t]:""},_get:function(t){return this.obj[t]},_has:function(t){return Object.prototype.hasOwnProperty.call(this.obj,t)},_observe:function(t){return t=Object.prototype.hasOwnProperty.call(t,"observer")?this.app.api(t.observer,t,this.name):t},_catchSetter:function(t){"keydown"===t.type&&13!==t.which||("keydown"===t.type&&t.preventDefault(),this.app.api(this.setter,this.popup))}}),t.add("module","accessibility",{start:function(){this._buildRole(),this._buildLabel()},_buildRole:function(){this.app.editor.getEditor().attr({"aria-labelledby":this.prefix+"-voice",role:"presentation"})},_buildLabel:function(){var t=this.lang.get("accessibility.help-label"),t=this._createLabel(t);this.app.container.get("main").prepend(t)},_createLabel:function(t){var e=this.dom("<span />").addClass(this.prefix+"-voice-label");return e.attr({id:this.prefix+"-voice-"+this.uuid,"aria-hidden":!1}),e.html(t),e}}),t.add("module","lang",{init:function(){this.langKey=this.app.setting.get("editor.lang"),this.vars=this._build()},get:function(t){var e=this._get(t,this.vars);return void 0===(e=void 0===e&&"en"!==this.langKey?this._get(t,h.lang.en):e)?"":e},parse:function(t){if("string"==typeof t){var e=t.match(/## (.*?) ##/g);if(e)for(var i=0;i<e.length;i++){var s=e[i].replace(/^##\s/g,"").replace(/\s##$/g,"");t=t.replace(e[i],this.get(s))}}return t},_get:function(t,e){var i=t.split("."),t=1===i.length?e[t]:void 0!==e[i[0]]?e[i[0]][i[1]]:void 0;return t},_build:function(){var t=h.lang.en;return t="en"!==this.langKey?"undefined"!==h.lang[this.langKey]?h.lang[this.langKey]:t:t}}),t.add("module","setting",{init:function(){this.opts=this._build()},dump:function(){return this.opts},has:function(t){var e=t.split("."),t=1===e.length?void 0!==this.opts[t]:void 0!==this.opts[e[0]]&&void 0!==this.opts[e[1]];return t},set:function(t,e,i){void 0===this.opts[t]&&(this.opts[t]={}),void 0===i?this.opts[t]=e:this.opts[t][e]=i},get:function(t){var e=t.split("."),t=1===e.length?this.opts[t]:void 0!==this.opts[e[0]]?this.opts[e[0]][e[1]]:void 0;return t},_build:function(){var t=h.extend(!0,{},h.opts,this.app.initialSettings);return h.extend(!0,t,h.settings)}}),t.add("module","element",{is:function(t,e,i){var s=!1,t="text"===e?t:this._getNode(t);return"inline"===e?s=this._isElement(t)&&this._isInlineTag(t.tagName,i):"blocks"===e?s=this._isElement(t)&&t.hasAttribute("data-"+this.prefix+"-type"):"blocks-first"===e?s=this._isElement(t)&&t.hasAttribute("data-"+this.prefix+"-first-level"):"block"===e?s=this._isElement(t)&&this._isBlockTag(t.tagName,i):"element"===e?s=this._isElement(t):"text"===e?s="string"==typeof t&&!/^\s*<(\w+|!)[^>]*>/.test(t)||this.isTextNode(t):"list"===e?s=this._isElement(t)&&-1!==["ul","ol"].indexOf(t.tagName.toLowerCase()):"heading"===e&&(s=this._isElement(t)&&-1!==["h1","h2","h3","h4","h5","h6"].indexOf(t.tagName.toLowerCase())),s},isEmptyOrImageInline:function(t){var e,i,s,t=this.dom(t).get();return!!(t&&3!==t.nodeType&&(e=t.tagName.toLowerCase(),i="false"===t.getAttribute("contenteditable"),(s=this.is(t,"inline"))&&this.isEmpty(t)||s&&i||-1!==["svg","img"].indexOf(e)))},isEmpty:function(t){t=this._getNode(t);return!!t&&(3===t.nodeType?""===t.textContent.trim().replace(/\n/,""):""===t.innerHTML)},isTag:function(t,e){return this._getNode(t).tagName.toLowerCase()===e},isTextNode:function(t){t=this._getNode(t);return t&&t.nodeType&&3===t.nodeType},isVisible:function(t){t=this._getNode(t);return!!(t.offsetWidth||t.offsetHeight||t.getClientRects().length)},isScrollVisible:function(t){var e=this.app.scroll.getTarget(),t=this.dom(t),e=e.scrollTop()+e.height();return t.offset().top<=e},getFirstLevel:function(t){return this.dom(t).closest("[data-"+this.prefix+"-first-level]")},getDataBlock:function(t){return this.dom(t).closest("[data-"+this.prefix+"-type]")},getType:function(t){return this.dom(t).attr("data-"+this.prefix+"-type")},getAllInlines:function(t){for(var e=[],i=t;i;)this.is(i,"inline")&&e.push(i),i=i.parentNode;return e},getClosest:function(t,e){return this.dom(t).closest(this.getTypesSelector(e))},getParents:function(t,e){return this.dom(t).parents(this.getTypesSelector(e))},getChildren:function(t,e){return this.dom(t).find(this.getTypesSelector(e))},getTypesSelector:function(t){return"[data-"+this.prefix+"-type="+t.join("],[data-"+this.prefix+"-type=")+"]"},hasClass:function(t,e){e="string"==typeof e?[e]:e;for(var i=this.dom(t),s=e.length,a=0,n=0;n<s;n++)i.hasClass(e[n])&&a++;return s===a},scrollTo:function(t,e){var i,s;this.isScrollVisible(t)||(e=e||60,t=t.offset(),i=this.app.scroll.getTarget(),s=t.top-e,i.scrollTop(s),setTimeout(function(){i.scrollTop(s)},1))},replaceToTag:function(t,a,n){return this.dom(t).replaceWith(function(t){var e=this.dom("<"+a+">");if(n||e.append(t.innerHTML),t.attributes)for(var i=t.attributes,s=0;s<i.length;s++)e.attr(i[s].nodeName,i[s].value);if(n)for(;0<t.childNodes.length;)e.append(this.dom(t.firstChild));return e}.bind(this))},compareStyle:function(t,e){let i=Object.keys(e).length,s=this.dom(t),a=this.app.utils.cssToObject(s.attr("style")),n=Object.keys(a).length,o=0;if(n!==i)return!1;for(var[r,p]of Object.entries(a)){var l;e[r]&&(l=e[r],(l=this._normalizeValue(r,l))===(p=this._normalizeValue(r,p)))&&o++}return n===o},hasAttrs:function(t,e){let i=Object.keys(e).length,s=this.dom(t),a=0;for(var[n,o]of Object.entries(e))s.attr(n)===o&&a++;return i===a},hasStyle:function(t,e){if(!e)return!1;let i=this.dom(t),s=Object.keys(e).length,a=0;for(var[n,o]of Object.entries(e)){var r=i.css(n);this._normalizeValue(n,r)===(o=this._normalizeValue(n,o))&&a++}return s===a},split:function(t){var e=this.dom(t),i=(t=e.get()).tagName.toLowerCase(),s=this.app.content.extractHtmlFromCaret(t),i=(s.nodeType&&11===s.nodeType&&(s=this.dom(s.childNodes)),this.dom("<"+i+" />")),t=((i=this.cloneAttrs(t,i)).append(s),e.after(i),e.children().last()),s=(this.is(t,"inline")&&(s=t.html(),""===(s=this.app.utils.removeInvisibleChars(s)))&&t.remove(),this.getType(i));return s&&this.app.create("block."+s,i,!0),""===e.html()&&e.remove(),i},cloneEmpty:function(t){t=this.dom(t).get().tagName.toLowerCase();return this.dom("<"+t+">")},cloneAttrs:function(t,e){for(var i=this.dom(e),s=this._getNode(t).attributes,a=s.length;a--;){var n=s[a];i.attr(n.name,n.value)}return i},getAttrs:function(t){var e=this._getNode(t),i={};if(null!=e.attributes&&e.attributes.length)for(var s=0;s<e.attributes.length;s++){var a=e.attributes[s].nodeValue,a=this._isNumber(a)?parseFloat(a):this._getBooleanFromStr(a);i[e.attributes[s].nodeName]=a}return i},removeEmptyAttrs:function(t,e){var t=this.dom(t),e=e.join(" "),i=!1;return void 0===t.attr(e)||null===t.attr(e)?i=!0:""===t.attr(e)&&(t.removeAttr(e),i=!0),i},getBlocks:function(t,e,i){var s=this._getNode(t).childNodes,a=[],n=e||this.opts.tags.parser;i&&(n=this.app.utils.extendArray(n,i));for(var o=0;o<s.length;o++)1===s[o].nodeType&&-1!==n.indexOf(s[o].tagName.toLowerCase())&&a.push(s[o]);return a},hasBlocks:function(t){return 0!==this.getBlocks(t).length},hasTextSiblings:function(t){var t=this._getNode(t),e=t.previousSibling&&3===t.previousSibling.nodeType&&!this.isEmpty(t.previousSibling),t=t.nextSibling&&3===t.nextSibling.nodeType&&!this.isEmpty(t.nextSibling);return e||t},_getNode:function(t){return this.dom(t).get()},_getBooleanFromStr:function(t){return"true"===t||"false"!==t&&t},_isBlockTag:function(t,e){return-1!==this.app.utils.extendArray(this.opts.tags.block,e).indexOf(t.toLowerCase())},_isInlineTag:function(t,e){return-1!==this.app.utils.extendArray(this.opts.tags.inline,e).indexOf(t.toLowerCase())},_isElement:function(t){return t&&t.nodeType&&1===t.nodeType},_isTag:function(t){return void 0!==t&&t},_isNumber:function(t){return!isNaN(t)&&!isNaN(parseFloat(t))},_normalizeValue:function(t,e){return e=(e="string"==typeof e?e.replace(/'/g,'"'):e).trim().replace(/;$/,""),-1!==t.search(/color|background/)&&(e=(e=this.app.utils.convertRgb2hex(e)).toLowerCase()),e=-1!==t.search(/family/)?e.replace(/"/g,""):e}}),t.add("module","paragraphizer",{init:function(){this.remStart="#####replace",this.remEnd="#####";this.tags=this.opts.tags.parser.concat(["form","audio","figcaption","object","style","script","iframe","select","input","textarea","button","option","map","area","math","fieldset","legend","hgroup","nav","details","menu","summary"])},paragraphize:function(t){for(var e=[],i=[],s=(t=this._storeTags(t,e),t=(t=this.app.content.storeComments(t,i)).trim(),""),a=(t=(t=(t=(t=(t=(t=this._trimLinks(t)).replace(/xparagraphmarkerz(?:\r\n|\r|\n)$/g,"")).replace(/xparagraphmarkerz$/g,"")).replace(/xparagraphmarkerz(?:\r\n|\r|\n)/g,"\n")).replace(/xparagraphmarkerz/g,"\n")).replace(/[\n]+/g,"\n")).split("\n"),n=0;n<a.length;n++)s+="<p>"+a[n].trim()+"</p>\n";return t=(t=(t=(t=s.replace(/\n$/,"")).replace(new RegExp("<p>\\s+#####","gi"),"#####")).replace(new RegExp("<p>#####","gi"),"#####")).replace(new RegExp("#####</p>","gi"),"#####"),t=this._restoreTags(t,e),t=(t=(t=(t=(t=(t=this.app.content.restoreComments(t,i)).replace(/<(p|h1|h2|h3|h4|h5|h6|li|td|th)(.*?)>[\s\n]*<\/\1>/gi,"<$1$2></$1>")).replace(/<p(.*?)><\/?br\s?\/?><\/p>/gi,"<p$1></p>")).replace(/<div(.*?)><\/?br\s?\/?><\/div>/gi,"<div$1></div>")).replace(/<\/?br\s?\/?><\/div>/gi,"</div>")).replace(/<\/?br\s?\/?><\/li>/gi,"</li>")},_storeTags:function(t,i){return this.app.utils.wrap(t,function(t){t.find(this.tags.join(", ")).each(function(t,e){this._replaceTag(t,e,i)}.bind(this))}.bind(this))},_restoreTags:function(t,e){for(var i=0;i<e.length;i++){var s=e[i].replace(/\$/gi,"$");t=t.replace(this.remStart+i+this.remEnd,s)}return t},_replaceTag:function(t,e,i){t=t.get(),e=document.createTextNode(this.remStart+e+this.remEnd+"xparagraphmarkerz");i.push(t.outerHTML),t.parentNode.replaceChild(e,t)},_trimLinks:function(t){return this.app.utils.wrap(t,function(t){t.find("a").each(this._trimLink.bind(this))}.bind(this))},_trimLink:function(t){t.html(t.html().trim())}}),t.add("module","utils",{isMobile:function(){return"ontouchstart"in document.documentElement},createInvisibleChar:function(){return document.createTextNode(this.opts.markerChar)},searchInvisibleChars:function(t){return t.search(/^\uFEFF$/g)},removeInvisibleChars:function(t){return t.replace(/\uFEFF/g,"")},wrap:function(t,e){var i=this.dom("<div>").html(t);return e(i),t=i.html(),i.remove(),t},extendArray:function(t,e){if(t=t.concat(t),e)for(var i=0;i<e.length;i++)t.push(e[i]);return t},removeFromArrayByValue:function(t,e){var i;e=Array.isArray(e)?e:[e];for(var s=0;s<e.length;s++)-1<(i=t.indexOf(e[s]))&&t.splice(i,1);return t},sumOfArray:function(t){return t.reduce(function(t,e){return parseInt(t)+parseInt(e)},0)},getObjectIndex:function(t,e){return Object.keys(t).indexOf(e)},insertToObject:function(s,a,n,o){return Object.keys(n).reduce(function(t,e,i){return i===o&&(t[s]=a),t[e]=n[e],t},{})},getRandomId:function(){for(var t="",e="abcdefghijklmnopqrstuvwxyz0123456789",i=0;i<12;i++)t+=e.charAt(Math.floor(Math.random()*e.length));return t},escapeRegExp:function(t){return t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")},capitalize:function(t){return(t=t.toLowerCase()).charAt(0).toUpperCase()+t.slice(1)},extendData:function(t,e){for(var i in e)t="elements"===i?this._extendDataElements(t,e[i]):this._setData(t,i,e[i]);return t},_extendDataElements:function(s,t){return this.dom(t).each(function(t){var e,i;"FORM"===t.get().tagName?(e=t.serialize(!0),Object.keys(e).forEach(function(t){s=this._setData(s,t,e[t])}.bind(this))):(i=t.attr("name")?t.attr("name"):t.attr("id"),s=this._setData(s,i,t.val()))}.bind(this)),s},_setData:function(t,e,i){return t instanceof FormData?t.append(e,i):t[e]=i,t},cssToObject:function(t){for(var e,i=/([\w-]*)\s*:\s*([^;]*)/g,s={};null!=(e=i.exec(t))&&(s[e[1]]=this._normalizeValue(e[1],e[2].trim())),e;);return s},_normalizeValue:function(t,e){return e=(e="string"==typeof e?e.replace(/'/g,'"'):e).trim().replace(/;$/,""),-1!==t.search(/color|background/)&&(e=(e=this.convertRgb2hex(e)).toLowerCase()),e=-1!==t.search(/family/)?e.replace(/"/g,""):e},getInvertedColor:function(t){return t=this.normalizeColor(t=""===t||null==t?"#ffffff":t),t=this._removeHexDiese(t),186<.299*parseInt(t.slice(0,2),16)+.587*parseInt(t.slice(2,4),16)+.114*parseInt(t.slice(4,6),16)?"black":"white"},normalizeColor:function(t){return t=(t=t&&this.convertRgb2hex(t))&&this.convertShorthex2long(t)},convertRgb2hex:function(t){return-1===t.search(/^rgb/i)?t:(t=t.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i))&&4===t.length?"#"+("0"+parseInt(t[1],10).toString(16)).slice(-2)+("0"+parseInt(t[2],10).toString(16)).slice(-2)+("0"+parseInt(t[3],10).toString(16)).slice(-2):""},convertShorthex2long:function(t){return 3===(t=this._removeHexDiese(t)).length?"#"+t[0]+t[0]+t[1]+t[1]+t[2]+t[2]:"#"+t},replaceRgbToHex:function(t){return t.replace(/rgb\((.*?)\)/g,function(t,e){return"#"+e.split(",").map(function(t){return 1===(t=parseInt(t).toString(16)).length?"0"+t:t}).join("")})}}),t.add("module","scroll",{init:function(){this.scrolltop=!1},save:function(){this.scrolltop=this.getTarget().scrollTop()},restore:function(){!1!==this.scrolltop&&(this.getTarget().scrollTop(this.scrolltop),this.scrolltop=!1)},isTarget:function(){return this.opts.editor.scrollTarget!==window},getTarget:function(){return this.dom(this.opts.editor.scrollTarget)}}),t.add("module","autosave",{send:function(){this.opts.autosave.url&&this._sending()},_getName:function(){var t=this.opts.autosave.name||(t=this.app.$element.attr("name"))||"content"+this.uuid;return t},_sending:function(){var e=this._getName(),i={};i[e]=this.app.$element.val(),i=this.app.utils.extendData(i,this.opts.autosave.data),this.ajax.request(this.opts.autosave.method,{url:this.opts.autosave.url,data:i,before:function(t){if(this.app.broadcast("autosave.before.send",{xhr:t,name:e,data:i}).isStopped())return!1}.bind(this),success:function(t){this._complete(t,e,i)}.bind(this)})},_complete:function(t,e,i){var s=t&&t.error?"autosave.error":"autosave.send";this.app.broadcast(s,{name:e,data:i,response:t})}}),t.add("module","progress",{stop:function(){this.hide()},show:function(){this.hide(),this.$progress=this.dom("<div>").addClass(this.prefix+"-editor-progress"),this.$progress.attr("id",this.prefix+"-progress"),this.$progressBar=this.dom("<span>"),this.$progress.append(this.$progressBar),this.app.$body.append(this.$progress)},hide:function(){this.app.$body.find("#"+this.prefix+"-progress").remove()}}),t.add("module","clipboard",{getContent:function(t){var e=this.isPlainText(t)?"text/plain":"text/html",t=t.getData(e);return"text/plain"==e?this.app.content.escapeHtml(t):t},setContent:function(t,e,i){t=t.clipboardData;e=this.app.parser.unparse(e),e='<meta type="'+this.prefix+'-editor"/>'+e,i=i||this.app.content.getTextFromHtml(e,{nl:!0}),t.setData("text/html",e),t.setData("text/plain",i)},isPlainText:function(t){var e=t.getData("text/plain"),t=t.getData("text/html");return(!t||""===t.trim())&&null!==e}}),t.add("module","fragment",{build:function(t){return this.is(t)?t:this.create(t)},insert:function(t){var e,i=this.app.selection.get();i.range&&(i.collapsed?3!==(e=i.range.startContainer).nodeType&&"BR"===e.tagName&&e.parentNode.removeChild(e):i.range.deleteContents(),t.frag?i.range.insertNode(t.frag):i.range.insertNode(t))},createContainer:function(t){var e=this.dom("<div>");return"string"==typeof t?e.html(t):e.append(this.dom(t).clone(!0)),e.get()},create:function(t){for(var e,i,s="string"==typeof t?this.createContainer(t):t,a=document.createDocumentFragment(),n=[],o=0;r=s.firstChild;){o++;var r=a.appendChild(r);1===o&&(e=r),n.push(r),i=r}return{frag:a,first:e,last:i,nodes:n}},is:function(t){return"object"==typeof t&&t.frag}}),t.add("module","button",{init:function(t,e,i,s){"object"==typeof t?(this.name=t.name,this.obj=e,this._buildFromElement(t.element)):t&&(this.type=s||!1,this.name=t,s=this._observe(e),this.obj=void 0===s?e:s,this.obj)&&this._build(t,i)},setColor:function(t,e){t=t.getName();"background"!==t&&"text-color"!==t||this.setBackground(e["background"===t?"background-color":"color"])},isButton:function(){return!0},isAddbar:function(){return this._has("addbar")},isControl:function(){return this._has("control")},getName:function(){return this.name},getTitle:function(){return this.title},getParams:function(){return!!this._has("params")&&this.obj.params},getOffset:function(){return this.$button.offset()},getDimension:function(){return{width:this.$button.width(),height:this.$button.height()}},getElement:function(){return this.$button},setBackground:function(t){this._background("add",t)},resetBackground:function(){this._background("remove","")},_has:function(t){return Object.prototype.hasOwnProperty.call(this.obj,t)},_observe:function(t){return t=Object.prototype.hasOwnProperty.call(t,"observer")?this.app.api(t.observer,t,this.name):t},_background:function(t,e){this.$icon["remove"===t?"removeClass":"addClass"](this.prefix+"-button-icon-color").css({"background-color":e,color:""!==e?this.app.color.invert(e):""})},_buildFromElement:function(t){this.$button=this.dom(t),this.$button.addClass(this.prefix+"-button-target"),this._buildData()},_build:function(t,e){this._buildTitle(),this._buildElement(),this._buildIcon(),this._buildData(e)},_buildData:function(t){this.$button.attr({"data-name":this.name,"data-command":this.obj.command||!1}),this.$button.dataset("instance",this);var e=this._has("command")?"_catch":"_stop";this.$button.on("click."+this.prefix+"-button",this[e].bind(this)),this.$button.on("dragstart."+this.prefix+"-button",function(t){t.preventDefault()}),t&&(this._buildTooltip(),this._buildBackground(),this._buildPosition(t))},_buildTitle:function(){this.title=void 0!==this.obj.title?this.lang.parse(this.obj.title):""},_buildElement:function(){this.$button=this.dom('<a href="#"></a>'),this.$button.addClass(this.prefix+"-button "+this.prefix+"-button-target"),this.type&&this.$button.addClass(this.prefix+"-button-"+this.type),this._has("classname")&&this.$button.addClass(this.obj.classname)},_buildIcon:function(){var t=this._has("icon"),e='<span class="'+this.prefix+"-icon-"+this.name+'"></span>';this.$icon=this._buildIconElement(),t&&!0!==this.obj.icon&&(e=-1!==this.obj.icon.search(/</)?this.obj.icon:'<span class="'+this.prefix+"-icon-"+this.obj.icon+'"></span>'),this.opts.buttons.icons&&void 0!==this.opts.buttons.icons[this.name]&&(e=this.opts.buttons.icons[this.name]),this.$icon.append(e),this.$button.append(this.$icon)},_buildIconElement:function(){return this.dom("<span>").addClass(this.prefix+"-button-icon")},_buildTooltip:function(){("toolbar"===this.type||"context"===this.type&&this.opts.tooltip.context)&&this.app.tooltip.build(this.$button,this.title)},_buildBackground:function(){this._has("background")&&this.setBackground(this.obj.background)},_buildPosition:function(t){var e,i;this._has("position")?"first"===(e=this.obj.position)?t.prepend(this.$button):"object"==typeof e&&(i=e[e=Object.prototype.hasOwnProperty.call(e,"after")?"after":"before"],(i=this._findPositionElement(i,t))?i[e](this.$button):t.append(this.$button)):t.append(this.$button)},_findPositionElement:function(t,e){var i;if(Array.isArray(t))for(var s=0;s<t.length&&0===(i=e.find("[data-name="+t[s]+"]")).length;s++);else i=e.find("[data-name="+t+"]");return 0!==i.length?i:0},_stop:function(t){t.preventDefault(),t.stopPropagation()},_catch:function(t){t.preventDefault(),t.stopPropagation();var e,i,s=this.dom(t.target).closest("."+this.prefix+"-button-target");s.hasClass("disable")||(this.app.editor.setFocus(),e=s.attr("data-command"),i=s.attr("data-name"),s=s.dataget("instance"),this.app.api(e,this.getParams(),s,i,t),this.app.tooltip.close())}}),t.add("module","tooltip",{init:function(){this.classname=this.prefix+"-tooltip",this.eventname=this.prefix+"-button-"+this.uuid},stop:function(){this.close()},build:function(t,e){(e=this._cleanTitle(e))&&(t.attr("data-tooltip",e),t.on("mouseover."+this.eventname,this.open.bind(this)),t.on("mouseout."+this.eventname,this.close.bind(this)))},open:function(t){t=this._getButton(t);this.app.popup.isOpen()||t.hasClass("disable")||(this.$tooltip=this._create(t),this._setPosition(t),this._fixBSModal(),this.app.$body.append(this.$tooltip))},close:function(){this.app.$body.find("."+this.classname).remove()},_create:function(t){return this.dom("<span>").addClass(this.classname).html(t.attr("data-tooltip"))},_cleanTitle:function(t){return!!t&&t.replace(/(<([^>]+)>)/gi,"")},_setPosition:function(t){var e=t.offset(),t=t.height();this.$tooltip.css({top:e.top+t+"px",left:e.left+"px"})},_fixBSModal:function(){this.opts.bsmodal&&this.$tooltip.css("z-index",1060)},_getButton:function(t){return this.dom(t.target).closest("."+this.prefix+"-button-target")}}),t.add("module","codemirror",{init:function(){this.cm=!1},create:function(t){var e,i;if(this.is())return e="object"==typeof this.opts.codemirror?this.opts.codemirror:{},i=this.opts.codemirrorSrc||CodeMirror,this.cm=i.fromTextArea(this.dom(t.el).get(),e),t.height&&this.cm.setSize(null,t.height),t.focus&&this.cm.focus(),this.cm},destroy:function(){this.cm&&(this.cm.toTextArea(),this.cm=!1)},is:function(){return this.opts.codemirror},val:function(t){return t=this.is()&&this.cm?this.cm.getValue():t}}),t.add("class","upload",{defaults:{type:"image",box:!1,url:!1,cover:!0,name:"file",data:!1,multiple:!0,placeholder:!1,hidden:!0,target:!1,success:!1,error:!1,remove:!1,trigger:!1,input:!1},init:function(t,e,i){this.eventname=this.prefix+"-upload",t&&this._build(t,e,i)},send:function(t,e,i,s){this.p=this._buildParams(i,s),this._send(t,e)},complete:function(t,e){this._complete(t,e)},setImage:function(t){this.p.input||(this.$image&&this.$image.remove(),this.$remove&&this.$remove.remove(),""===t?this.$placeholder.show():(this.$placeholder.hide(),this._buildImage(t),this.p.remove&&this._buildRemove()))},_build:function(t,e,i){this.p=this._buildParams(e,i),this.$element=this.dom(t),"INPUT"===this.$element.get().tagName?this._buildByInput():this._buildByBox()},_buildImage:function(t){this.$image=this.dom("<img>"),this.$image.attr("src",t),this.$box.append(this.$image),!1===this.p.input&&(this.$box.off("click."+this.eventname),this.$image.on("click."+this.eventname,this._click.bind(this)))},_buildRemove:function(){this.$remove=this.dom("<span>"),this.$remove.addClass(this.prefix+"-upload-remove"),this.$remove.on("click",this._removeImage.bind(this)),this.$box.append(this.$remove)},_buildParams:function(t,e){return t=h.extend(!0,this.defaults,t),e&&(t.trigger=e),t},_buildByInput:function(){this.$input=this.$element,this.p.box?(this._buildBox(),this._buildPlaceholder()):this.p.input=!0,this._buildAccept(),this._buildMultiple(),this._buildEvents()},_buildByBox:function(){this._buildInput(),this._buildAccept(),this._buildMultiple(),this._buildBox(),this._buildPlaceholder(),this._buildEvents()},_buildBox:function(){this.$box=this.dom("<div>").addClass(this.prefix+"-form-upload-box"),this.$element.before(this.$box),!1===this.p.cover&&this.$box.addClass(this.prefix+"-form-upload-cover-off"),this.p.hidden&&this.$element.hide()},_buildPlaceholder:function(){this.p.placeholder&&(this.$placeholder=this.dom("<span>").addClass(this.prefix+"-form-upload-placeholder"),this.$placeholder.html(this.p.placeholder),this.$box.append(this.$placeholder))},_buildInput:function(){this.$input=this.dom("<input>"),this.$input.attr("type","file"),this.$input.attr("name",this._getUploadParam()),this.$input.hide(),this.$element.before(this.$input)},_buildAccept:function(){var t;"image"===this.p.type&&(t=this.opts.image.types.join(","),this.$input.attr("accept",t))},_buildMultiple:function(){"image"===this.p.type&&(this.p.multiple?this.$input.attr("multiple","multiple"):this.$input.removeAttr("multiple"))},_buildEvents:function(){this.$input.on("change."+this.eventname+"-"+this.uuid,this._change.bind(this)),!1===this.p.input&&(this.$box.on("click."+this.eventname,this._click.bind(this)),this.$box.on("drop."+this.eventname,this._drop.bind(this)),this.$box.on("dragover."+this.eventname,this._dragover.bind(this)),this.$box.on("dragleave."+this.eventname,this._dragleave.bind(this)))},_buildData:function(t,e,i){if("single"===this.p.multiple)i.append(t,e[0]);else if(this.p.multiple)for(var s=0;s<e.length;s++)i.append(t+"[]",e[s]);else i.append(t+"[]",e[0]);return i},_removeImage:function(t){t&&(t.preventDefault(),t.stopPropagation()),this.$image&&this.$image.remove(),this.$remove&&this.$remove.remove(),this.$placeholder.show(),!1===this.p.input&&this.$box.on("click."+this.eventname,this._click.bind(this)),t&&this.app.api(this.p.remove,t)},_getUploadParam:function(){return this.p.name},_click:function(t){t.preventDefault(),this.$input.click()},_change:function(t){this._send(t,this.$input.get().files)},_drop:function(t){t.preventDefault(),this._send(t)},_dragover:function(t){return t.preventDefault(),this._setStatus("hover"),!1},_dragleave:function(t){return t.preventDefault(),this._removeStatus(),!1},_setStatus:function(t){!this.p.input&&this.p.box&&(this._removeStatus(),this.$box.addClass(this.prefix+"-form-upload-"+t))},_removeStatus:function(){if(!this.p.input&&this.p.box)for(var t=["hover","error"],e=0;e<t.length;e++)this.$box.removeClass(this.prefix+"-form-upload-"+t[e])},_send:function(t,e){e=e||t.dataTransfer.files;var i=new FormData,s=this._getUploadParam(),i=this._buildData(s,e,i);i=this.app.utils.extendData(i,this.p.data),this._sendData(t,e,i)},_sendData:function(e,i,s){"function"==typeof this.p.url?this.p.url.call(this.app,this,{data:s,files:i,e:e}):(this.app.progress.show(),this.ajax.post({url:this.p.url,data:s,before:function(t){if(this.app.broadcast("upload.before.send",{xhr:t,data:s,files:i,e:e}).isStopped())return this.app.progress.hide(),!1}.bind(this),success:function(t){this._complete(t,e)}.bind(this),error:function(t){this._complete(t,e)}.bind(this)}))},_complete:function(t,e){t&&t.error?(this._setStatus("error"),this.p.error&&(this.app.broadcast("upload.error",{response:t}),this.app.api(this.p.error,t,e))):(this._removeStatus(),this._trigger(t),this.p.success&&(this.app.broadcast("upload.complete",{response:t}),this.app.api(this.p.success,t,e))),setTimeout(function(){this.app.progress.hide()}.bind(this),500)},_trigger:function(t){var e;this.p.trigger&&t&&t.url&&(e=this.p.trigger.instance)[this.p.trigger.method].call(e,t.url)}}),t.add("module","statusbar",{init:function(){this.classname=this.prefix+"-statusbar"},start:function(){this._build()},add:function(t,e){return this.update(t,e)},update:function(t,e){var i=this.get(t);return(i=0===i.length?this._buildItem(t):i).html(e)},get:function(t){return this.$statusbar.find(t?"[data-name="+t+"]":"[data-name]")},remove:function(t){this.get(t).remove()},clear:function(){this.$statusbar.html("")},_build:function(){this.$statusbar=this.dom("<div>").attr("dir",this.opts.editor.direction),this.$statusbar.addClass(this.classname+" "+this.classname+"-"+this.uuid),this.app.container.get("statusbar").append(this.$statusbar)},_buildItem:function(t){var e=this.dom("<span>").addClass(this.classname+"-item");return e.attr("data-name",t),this.$statusbar.append(e),e}}),t.add("module","container",{init:function(){this.blurclass=this.prefix+"-in-blur",this.focusclass=this.prefix+"-in-focus"},start:function(){this._buildMain(),this._buildContainers(this.$main,this.opts.containers.main),this._buildBSModal()},stop:function(){this.$main.remove()},get:function(t){return this["$"+t]},setFocus:function(){this.$main.removeClass(this.blurclass).addClass(this.focusclass)},setBlur:function(){this.$main.removeClass(this.focusclass).addClass(this.blurclass)},isFocus:function(){return this.$main.hasClass(this.focusclass)},_buildMain:function(){this.$main=this.dom("<div>").attr(this.prefix+"-uuid",this.uuid),this.$main.addClass(this.prefix+"-container "+this.prefix+"-container-"+this.uuid),this.app.$element.after(this.$main)},_buildContainers:function(t,e){for(var i=0;i<e.length;i++){var s=e[i],a="$"+s;this[a]=this._createContainer(s),void 0!==this.opts.containers[s]&&this._buildContainers(this[a],this.opts.containers[s]),t.append(this[a])}},_buildBSModal:function(){this.opts.bsmodal=0!==this.$main.closest(".modal-dialog").length},_createContainer:function(t){return this.dom("<div>").addClass(this.prefix+"-"+t+"-container")}}),t.add("module","shortcut",{init:function(){if(this.opts.shortcutsRemove)for(var t=this.opts.shortcutsRemove,e=0;e<t.length;e++)this.remove(t[e]);this.shortcuts=this.opts.shortcuts,this.hotkeys={8:"backspace",9:"tab",10:"return",13:"return",16:"shift",17:"ctrl",18:"alt",19:"pause",20:"capslock",27:"esc",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"insert",46:"del",59:";",61:"=",96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8",105:"9",106:"*",107:"+",109:"-",110:".",111:"/",112:"f1",113:"f2",114:"f3",115:"f4",116:"f5",117:"f6",118:"f7",119:"f8",120:"f9",121:"f10",122:"f11",123:"f12",144:"numlock",145:"scroll",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},this.hotkeysShiftNums={"`":"~",1:"!",2:"@",3:"#",4:"$",5:"%",6:"^",7:"&",8:"*",9:"(",0:")","-":"_","=":"+",";":": ","'":'"',",":"<",".":">","/":"?","\\":"|"}},add:function(t,e){this.shortcuts[t]=e},remove:function(t){this.opts.shortcutsBase=this._remove(t,this.opts.shortcutsBase),this.opts.shortcuts=this._remove(t,this.opts.shortcuts)},popup:function(t,e){var i=/(Mac|iPhone|iPod|iPad)/i.test(navigator.platform)?"<b>⌘</b>":"ctrl",s={},a=this._buildPopupItems(s,0,this.opts.shortcutsBase,i,"base");this._buildPopupItems(s,a,this.opts.shortcuts,i),this.app.popup.create("shortcuts",{width:"360px",items:s}),this.app.popup.open({button:e})},handle:function(t){if((this.triggered=!1)===this.shortcuts)return!t.ctrlKey&&!t.metaKey||66!==t.which&&73!==t.which||t.preventDefault(),!0;if(t.ctrlKey||t.metaKey||t.shoftKey||t.altKey)for(var e in this.shortcuts)this.shortcuts.hasOwnProperty(e)&&this._build(t,e,this.shortcuts[e]);return this.triggered},_buildPopupItems:function(t,e,i,s,a){for(var n in i)if(i.hasOwnProperty(n)){for(var o=this.dom("<div>").addClass(this.prefix+"-popup-shortcut-item"),r="base"===a?i[n]:i[n].title,r=this.dom("<span>").addClass(this.prefix+"-popup-shortcut-title").html(this.lang.parse(r)),p=this.dom("<span>").addClass(this.prefix+"-popup-shortcut-kbd"),l=("base"===a?n:i[n].name).replace("meta",s).split("+"),h=0;h<l.length;h++)l[h]="<span>"+l[h]+"</span>";p.html(l.join("+")),o.append(r),o.append(p),t[e]={html:o},e++}return e},_build:function(t,e,i){for(var s=e.split(","),a=s.length,n=0;n<a;n++)"string"!=typeof s[n]||Object.prototype.hasOwnProperty.call(i,"trigger")||this._handler(t,s[n].trim(),i)},_handler:function(t,e,i){e=e.toLowerCase().split(" ");for(var s=this.hotkeys[t.keyCode],a=91!==t.which&&String.fromCharCode(t.which).toLowerCase(),n="",o={},r=["meta","ctrl","alt","shift"],p=0;p<r.length;p++){var l=r[p];t[l+"Key"]&&s!==l&&(n+=l+"+")}93===t.keyCode&&(n+="meta+"),s&&(o[n+s]=!0),a&&(o[n+a]=!0,o[n+this.hotkeysShiftNums[a]]=!0,"shift+"===n)&&(o[this.hotkeysShiftNums[a]]=!0);for(var h=e.length,c=0;c<h;c++)if(o[e[c]])return t.preventDefault(),this.triggered=!0,void this.app.api(i.command,i.params,t)},_remove:function(i,s){return Object.keys(s).reduce(function(t,e){return e!==i&&(t[e]=s[e]),t},{})}}),t.add("module","offset",{get:function(t){t=this._getEl(t);var e,i=this.app.editor.getWinNode().getSelection(),s=!1;return i&&0<i.rangeCount&&(e=i.getRangeAt(0),t.contains(i.anchorNode))&&((i=e.cloneRange()).selectNodeContents(t),i.setEnd(e.startContainer,e.startOffset),s={start:t=i.toString().length,end:t+e.toString().length}),s},set:function(t,e){!1===e&&(e={start:0,end:0}),t=this._getEl(t);var i,s=0,a=this.app.editor.getDocNode().createRange(),n=[t],o=!1,r=!1;for(a.setStart(t,0),a.collapse(!0);!r&&(i=n.pop());)if(3===i.nodeType){var p=s+i.length;!o&&e.start>=s&&e.start<=p&&(a.setStart(i,e.start-s),o=!0),o&&e.end>=s&&e.end<=p&&(a.setEnd(i,e.end-s),r=!0),s=p}else for(var l=i.childNodes.length;l--;)n.push(i.childNodes[l]);this.app.selection.setRange(a)},_getEl:function(t){return(t?this.dom(t):this.app.editor.getLayout()).get()}}),t.add("module","marker",{build:function(t){t=this.dom("<span>").attr("id","selection-marker-"+t);return t.addClass(this.prefix+"-selection-marker"),t.html(this.opts.markerChar),t.get()},insert:function(){this.remove();var t,e,i,s=this.app.selection.get(),a=!s.collapsed;s.range&&(t=this.build("start"),e=this.build("end"),i=s.range.cloneRange(),a&&(i.collapse(!1),i.insertNode(e)),i.setStart(s.range.startContainer,s.range.startOffset),i.collapse(!0),i.insertNode(t),s.range.setStartAfter(t),a&&s.range.setEndBefore(e),this.app.selection.setRange(s.range))},restore:function(){var t,e,i=this.find("start"),s=this.find("end"),a=this.app.selection.get(),a=a.range||this.app.editor.getDocNode().createRange();i&&(t=!!s&&s.previousSibling,e=(!(e=i.nextSibling)||3!==e.nodeType||""!==e.textContent.replace(/[\n\t]/g,""))&&e,s?e&&"selection-marker-end"===e.id?this._restoreInject(a,i):t&&e?(a.selectNodeContents(t),a.collapse(!1),a.setStart(e,0)):t&&!e?(a.selectNodeContents(t),a.collapse(!1),a.setStartAfter(i)):(a.setStartAfter(i),a.setEndBefore(s)):e?(a.selectNodeContents(e),a.collapse(!0)):this._restoreInject(a,i),this.app.selection.setRange(a),t=i&&s?2:1,e={start:(e=this.app.offset.get()).start-t,end:e.end-t},i&&i.parentNode.removeChild(i),s&&s.parentNode.removeChild(s),this.app.editor.setWinFocus(),this.app.offset.set(!1,e))},find:function(t){t=this.app.editor.getLayout().find("#selection-marker-"+t);return 0!==t.length&&t.get()},remove:function(){var t=this.find("start"),e=this.find("end");t&&t.parentNode.removeChild(t),e&&e.parentNode.removeChild(e)},_restoreInject:function(t,e){var i=this.app.utils.createInvisibleChar();this.dom(e).after(i),t.selectNodeContents(i),t.collapse(!1)}}),t.add("module","state",{init:function(){this.started=!1,this.storage=!1,this.state=!1,this.passed=!0,this.undoStorage=[],this.redoStorage=[]},load:function(){this.clear(),this.trigger(!0)},stop:function(){this.clear()},clear:function(){this.storage=!1,this.state=!1,this.passed=!0,this.undoStorage=[],this.redoStorage=[]},get:function(){return this.undoStorage},add:function(t){t&&(t.ctrlKey||t.metaKey||this._isUndo(t)||this._isRedo(t))||!this.app.observer.trigger||(this.state=this._createState(),!1===this.started&&(this._setState(this.state,0),this.started=!0))},trigger:function(t){var e;this.passed&&(e=this._createState(),this.state?e=this.state:this.state||t||(e=this.storage,this.started=!0),this._addState(e),this.storage=this._createState(),this.state=!1)},listen:function(t){return this._isUndo(t)?(t.preventDefault(),this.undo(),!0):this._isRedo(t)?(t.preventDefault(),this.redo(),!0):void(this.passed=!0)},undo:function(){var t,e;this._hasUndo()&&(this.passed=!1,t=this._getUndo(),this._setRedo(),e=this.app.parser.parse(t[0]),this.app.editor.getLayout().html(e.children()),this._rebuild(t,"undo"),e=!(!(e=this.app.block.get())||!e.isEditable())&&e.getBlock(),this.app.offset.set(e,t[1]))},redo:function(){var t,e;this._hasRedo()&&(this.passed=!1,t=this.redoStorage.pop(),this._addState({html:t[0],offset:t[1]}),e=this.app.parser.parse(t[0]),this.app.editor.getLayout().html(e.children()),this._rebuild(t,"redo"),e=!(!(e=this.app.block.get())||!e.isEditable())&&e.getBlock(),this.app.offset.set(e,t[1]))},_rebuild:function(t,e){this.app.editor.build(),this.app.editor.getLayout().find("."+this.prefix+"-block-state").each(function(t){this.app.block.set(t)}.bind(this)),this.app.broadcast("state."+e,{html:t[0],offset:t[1]})},_isUndo:function(t){var e=t.which;return(t.ctrlKey||t.metaKey)&&90===e&&!t.shiftKey&&!t.altKey},_isRedo:function(t){var e=t.which;return(t.ctrlKey||t.metaKey)&&(90===e&&t.shiftKey||89===e&&!t.shiftKey)&&!t.altKey},_hasUndo:function(){return 0!==this.undoStorage.length},_hasRedo:function(){return 0!==this.redoStorage.length},_getUndo:function(){return 1===this.undoStorage.length?this.undoStorage[0]:this.undoStorage.pop()},_createState:function(){var t=this.app.editor.getLayout().html(),t=this.app.utils.wrap(t,function(t){t.find("."+this.prefix+"-block-focus").addClass(this.prefix+"-block-state")}.bind(this)),e=this.app.block.get(),e=!(!e||!e.isEditable())&&e.getBlock();return{html:this.app.parser.unparse(t,!0),offset:this.app.offset.get(e)}},_setState:function(t,e){this.undoStorage[e]=[t.html,t.offset]},_addState:function(t){var e=this.undoStorage[this.undoStorage.length-1];void 0===e||e[0]!==t.html?(this.undoStorage.push([t.html,t.offset]),this._removeOverStorage()):e[1]=t.offset},_setRedo:function(){var t=this._createState();this.redoStorage.push([t.html,t.offset]),this.redoStorage=this.redoStorage.slice(0,this.opts.state.limit)},_removeOverStorage:function(){this.undoStorage.length>this.opts.state.limit&&(this.undoStorage=this.undoStorage.slice(0,this.undoStorage.length-this.opts.state.limit))}}),t.add("module","sync",{build:function(){this.syncedHtml=this.app.$element.val()},trigger:function(){this.opts.editor.sync&&(this.typingTimer&&clearTimeout(this.typingTimer),this.typingTimer=setTimeout(function(){var t=this._getHtml();this.is(t)&&this._sync(t)}.bind(this),300))},invoke:function(){var t=this._getHtml();this.syncedHtml=t,this._sync(t)},is:function(t){var e=!1;return this.syncedHtml!==t&&(this.syncedHtml=t,e=!0),e},_getHtml:function(){var t=this.app.editor.getLayout().html();return this.app.parser.unparse(t)},_sync:function(t){t=this.app.broadcast("editor.before.change",{html:t});t.isStopped()||(this.app.$element.val(t.get("html")),this.app.autosave.send(),this.app.state.trigger(),this.app.broadcast("editor.change",t))}}),t.add("module","placeholder",{start:function(){this.placeholder=!1,this.$layout=this.app.editor.getLayout(),this._build()},handleClick:function(t){this.dom(t.target).hasClass(this.prefix+"-placeholder")&&(t.preventDefault(),t.stopPropagation(),this.app.editor.setFocus("start"))},trigger:function(){this.placeholder&&this.app.editor.isEmpty(!0)?this.show():this.hide()},toggle:function(){this.observerTimer&&clearTimeout(this.observerTimer),this.observerTimer=setTimeout(this.trigger.bind(this),10)},show:function(){this.$layout.addClass(this.prefix+"-placeholder")},hide:function(){this.$layout.removeClass(this.prefix+"-placeholder")},change:function(t){this.opts.placeholder=t,this._rebuild(),this.app.editor.isEmpty(!0)&&this.app.editor.setEmpty()},_build:function(){this._rebuild(),this.toggle()},_rebuild:function(){var t=this.opts.placeholder,e=this.app.$element.attr("placeholder");!1===t&&!e||(this.$layout.attr("placeholder",!1!==t?t:e),this.placeholder=!0)}}),t.add("module","list",{indent:function(){var t=this.app.selection.get(),e=this.app.selection.getBlock(),i=this.dom(e),s=i.prevElement(),a=s.get(),t=t.collapsed&&e&&a&&"LI"===a.tagName;return t&&(this.app.selection.save(e),e=(s=this.dom(a)).children("ul, ol"),a=i.closest("ul, ol"),0!==e.length?e.append(i):(e=a.get().tagName.toLowerCase(),(a=this.dom("<"+e+">")).append(i),s.append(a)),this.app.selection.restore()),t},outdent:function(){var t=this.app.selection.get(),e=this.app.selection.getBlock(),i=this.dom(e),s=!1;if(t.collapsed&&e){var t=i.parent(),a=t.closest("li"),n=i.prevElement(),o=i.nextElement(),n=n.get(),o=o.get(),r=!1===n,n=!1!==n&&!1!==o;if(this.app.selection.save(e),0!==a.length){if(n){for(var p=this._getAllNext(i.get()),l=this.dom("<"+t.get().tagName.toLowerCase()+">"),h=0;h<p.length;h++)l.append(p[h]);a.after(i),i.append(l)}else a.after(i),0===t.children().length?t.remove():r&&i.append(t);s=!0}this.app.selection.restore()}return s},_getAllNext:function(t){for(var e=[];t;){if(!(t=this.dom(t).nextElement().get()))return e;e.push(t)}return e}}),t.add("module","cleaner",{cleanHtml:function(t){t=this.app.broadcastHtml("editor.before.clean",t);var e,i,s={},a=this.opts.paste.blockTags.concat(this.opts.paste.inlineTags).concat(this.opts.paste.formTags),n=this._isPages(t),o=this._isHtmlMsWord(t),r=this._isEditor(t),a=(t=this.app.content.store(t,"embed",s,0),t=this.app.content.removeDoctype(t),t=(t=this.app.content.removeTags(t,this.opts.tags.denied)).trim(),t=this.app.content.removeComments(t),t=this.app.content.removeTagsWithContent(t,["script","style"]),t=n?this._cleanPages(t):t,t=o?t:this._cleanGDocs(t),t=this._encodePhp(t),t=this.app.content.removeTagsExcept(t,a),t=o?this._cleanMsWord(t):t,!1);return!r&&this.app.event.pasteEvent&&(t=this.app.content.restore(t,"embed",s),a=!0),r||(e=0!==this.opts.paste.keepClass.length?this.opts.paste.keepClass.join(","):"",i=0!==this.opts.paste.keepAttrs.length?this.opts.paste.keepAttrs.join(","):"",t=this.app.utils.wrap(t,function(t){t=t.find("*");t.not(e).removeAttr("class"),t.not(i).each(function(t){for(var e=t.get(),i=e.attributes,s=i.length-1;0<=s;s--){var a=i[s].name;"class"!==a&&"dir"!==a&&-1===a.search(/^data-/)&&("IMG"!==e.tagName||"src"!==a&&"alt"!==a)&&("A"!==e.tagName||"href"!==a&&"target"!==a)&&e.removeAttribute(a)}})})),a||(t=this.app.content.restore(t,"embed",s)),t=r?this.app.content.cacheStyle(t):this.app.content.removeStyleAttr(t),t=(t=(t=(t=(t=(t=this.app.content.removeEmptyInlines(t)).replace(/<figure[^>]*><\/figure>/gi,"")).replace(/<p> <\/p>/gi,"<p></p>")).replace(/<p><br\s?\/?><\/p>/gi,"<p></p>")).replace(/^<li/gi,"<ul><li")).replace(/<\/li>$/gi,"</li></ul>"),(o||n)&&(t=(t=t.replace(/<p><\/p>/gi,"")).replace(/<p>\s<\/p>/gi,"")),t=this.app.utils.wrap(t,function(t){t.find(".Apple-converted-space").unwrap(),t.find("ul, ol").each(this._placeListToItem.bind(this)),t.find("li p").unwrap()}.bind(this)),this.app.broadcastHtml("editor.clean",t)},_encodePhp:function(t){return t=(t=(t=t.replace("<?php","<?php")).replace("<?","<?")).replace("?>","?>")},_isEditor:function(t){return t.match(new RegExp('meta\\stype="'+this.prefix+'-editor"',"i"))},_isHtmlMsWord:function(t){return t.match(/class="?Mso|style="[^"]*\bmso-|style='[^'']*\bmso-|w:WordDocument/i)},_isPages:function(t){return t.match(/name="Generator"\scontent="Cocoa\sHTML\sWriter"/i)},_placeListToItem:function(t){var t=t.get(),e=t.previousSibling;e&&"LI"===e.tagName&&((e=this.dom(e)).find("p").unwrap(),e.append(t))},_cleanPages:function(t){return t=(t=t.replace(/\sclass="s[0-9]"/gi,"")).replace(/\sclass="p[0-9]"/gi,"")},_cleanGDocs:function(t){return t=(t=(t=(t=(t=(t=-1!==t.search(/docs-internal-guid/i)?(t=this.app.utils.wrap(t,function(t){t.find("h1, h2, h3, h4, h5, h6").each(function(t){t.find("span").unwrap()})})).replace(/ dir="[^>]*"/gi,""):t).replace(/<b\sid="internal-source-marker(.*?)">([\w\W]*?)<\/b>/gi,"$2")).replace(/<b(.*?)id="docs-internal-guid(.*?)">([\w\W]*?)<\/b>/gi,"$3")).replace(/<span[^>]*(font-style:\s?italic;\s?font-weight:\s?(bold|600|700)|font-weight:\s?(bold|600|700);\s?font-style:\s?italic)[^>]*>([\w\W]*?)<\/span>/gi,"<b><i>$4</i></b>")).replace(/<span[^>]*font-style:\s?italic[^>]*>([\w\W]*?)<\/span>/gi,"<i>$1</i>")).replace(/<span[^>]*font-weight:\s?(bold|600|700)[^>]*>([\w\W]*?)<\/span>/gi,"<b>$2</b>")},_cleanMsWord:function(t){t=(t=(t=(t=(t=(t=t.replace(/<!--[\s\S]+?-->/gi,"")).trim()).replace(/<(!|script[^>]*>.*?<\/script(?=[>\s])|\/?(\?xml(:\w+)?|meta|link|style|\w:\w+)(?=[\s/>]))[^>]*>/gi,"")).replace(/<(\/?)s>/gi,"<$1strike>")).replace(/ /gi," ")).replace(/<span\s+style\s*=\s*"\s*mso-spacerun\s*:\s*yes\s*;?\s*"\s*>([\s\u00a0]*)<\/span>/gi,function(t,e){return 0<e.length?e.replace(/./," ").slice(Math.floor(e.length/2)).split("").join(" "):""});for(var e="",i=(t=(t=(t=(t=(t=(t=this.app.utils.wrap(t,function(t){t.find("p").each(function(t){var e=/mso-list:\w+ \w+([0-9]+)/.exec(t.attr("style"));e&&t.attr("data-listLevel",parseInt(e[1],10))}),this._parseWordLists(t),t.find("[align]").removeAttr("align"),t.find("[name]").removeAttr("name"),t.find("span").each(function(t){var e=t.attr("style");/mso-list:Ignore/.exec(e)?t.remove():t.unwrap()}),t.find("[style]").removeAttr("style"),t.find("[class^='Mso']").removeAttr("class"),t.find("a").filter(function(t){return!t.attr("href")}).unwrap()}.bind(this))).replace(/<p><img(.*?)>/gi,"<p><img$1></p><p>")).replace(/<p[^>]*><\/p>/gi,"")).replace(/<li>·/gi,"<li>")).trim()).replace(/\/(p|ul|ol|h1|h2|h3|h4|h5|h6|blockquote)>\s+<(p|ul|ol|h1|h2|h3|h4|h5|h6|blockquote)/gi,"/$1>\n<$2")).split(/\n/),s=0;s<i.length;s++){var a=""!==i[s]&&-1===i[s].search(/>$/)?" ":"\n";e+=i[s]+a}return e=e.trim()},_parseWordLists:function(t){var n,o=0,r=null,p=null;t.find("p").each(function(t){var e=t.attr("data-listLevel");if(null!==(e=null===e&&t.hasClass("MsoListParagraphCxSpMiddle")?1:e)){var i=t.text(),i=/^\s*\w+\./.test(i)?"<ol></ol>":"<ul></ul>";if(t.hasClass("MsoListParagraphCxSpFirst")||t.hasClass("MsoNormal")?(p=this.dom(i),t.before(p)):o<e&&0!==o&&(n=this.dom(i),r.append(n),p=n),e<o)for(var s=o-e+1,a=0;a<s;a++)p=p.parent();t.find("span").first().unwrap(),r=this.dom("<li>"+t.html().trim()+"</li>"),null===p&&(t.before(i),p=t.prev()),p.append(r),t.remove(),o=e}else p=null,o=0}.bind(this))}}),t.add("module","tidy",{init:function(){},parse:function(t){t=this.app.content.encodeAttrSings(t);var e,i=["li"],s=["li"],a=(this.lineBefore=new RegExp("^<(/?"+i.join("|/?")+"|"+s.join("|")+")[ >]"),this.lineAfter=new RegExp("^<(/?"+i.join("|/?")+"|/"+s.join("|/")+")[ >]"),this.newLevel=new RegExp("^</?("+["p","ul","ol","li","div","h1","h2","h3","h4","h5","h6","blockquote","figure","figcaption","table","thead","tbody","tfoot","tr","td","th","dl","dt","dd"].join("|")+")[ >]"),0),n=t.length,o=0,r="",p="",l="";for(this.cleanlevel=0;a<n;a++){if(o=a,-1===t.substr(a).indexOf("<"))return p+=t.substr(a),this.finish(p);for(;o<n&&"<"!==t.charAt(o);)o++;for(a===o||(l=t.substr(a,o-a)).match(/^\s{2,}$/g)||("\n"===p.charAt(p.length-1)?p+=this.getTabs():"\n"===l.charAt(0)&&(p+="\n"+this.getTabs(),l=l.replace(/^\s+/,"")),p+=l),e=o;o<n&&">"!==t.charAt(o);)o++;var h,a=o;if("!--"===(r=t.substr(e,o-e)).substr(1,3)){if(!r.match(/--$/)){for(;"--\x3e"!==t.substr(o,3);)o++;o+=2,r=t.substr(e,o-e),a=o}"\n"!==p.charAt(p.length-1)&&(p+="\n"),p=p+this.getTabs()+(r+">\n")}else"!"===r[1]?p=this.placeTag(r+">",p):"?"===r[1]?p+=r+">\n":h===r.match(/^<(script|style|pre)/i)?(h[1]=h[1].toLowerCase(),r=this.cleanTag(r),p=this.placeTag(r,p),(e=String(t.substr(a+1)).toLowerCase().indexOf("</"+h[1]))&&(l=t.substr(a+1,e),a+=e,p+=l)):(r=this.cleanTag(r),p=this.placeTag(r,p))}return this.finish(p)},getTabs:function(){for(var t="",e=0;e<this.cleanlevel;e++)t+=" ";return t},finish:function(t){return t=(t=(t=(t=(t=(t=(t=t.replace(/\n\s*\n/g,"\n")).replace(/^[\s\n]*/,"")).replace(/[\s\n]*$/,"")).replace(/<li(.*?)>[\s\n]*/gi,"<li$1>")).replace(/<(p|h1|h2|h3|h4|h5|h6|li|td|th)(.*?)>[\s\n]*<\/\1>/gi,"<$1$2></$1>")).replace(/[\s\n]*<\/li>/gi,"</li>")).replace(/<script(.*?)>\n<\/script>/gi,"<script$1><\/script>"),t=this.app.content.decodeAttrSings(t),this.cleanlevel=0,t},cleanTag:function(t){var e,i="",s="";for((t=(t=(t=t.replace(/\n/g," ")).replace(/\s{2,}/g," ")).replace(/^\s+|\s+$/g," ")).match(/\/$/)&&(s="/",t=t.replace(/\/+$/,""));e=/\s*([^= ]+)(?:=((['"']).*?\3|[^ ]+))?/.exec(t);)e[2]?i+=e[1].toLowerCase()+"="+e[2]:e[1]&&(i+=e[1].toLowerCase()),i+=" ",t=t.substr(e[0].length);return i.replace(/\s*$/,"")+s+">"},placeTag:function(t,e){var i=t.match(this.newLevel);return(t.match(this.lineBefore)||i)&&(e=e.replace(/\s*$/,""),e+="\n"),i&&"/"===t.charAt(1)&&this.cleanlevel--,"\n"===e.charAt(e.length-1)&&(e+=this.getTabs()),i&&"/"!==t.charAt(1)&&this.cleanlevel++,e+=t,(t.match(this.lineAfter)||t.match(this.newLevel))&&(e=e.replace(/ *$/,""),e+="\n"),e}}),t.add("module","source",{start:function(){this.eventname=this.prefix+"-source-events",this._build()},toggle:function(){this.is()?this.close():this.open()},is:function(){return"none"!==this.app.container.get("source").css("display")},open:function(){this.app.broadcast("source.before.open");var t=this.app.editor.getContent(),t=this.app.tidy.parse(t),e=this.app.container.get("editor").height(),t=(this.$source.height(e),this.$source.val(t),this.$source.on("focus."+this.eventname,this._handleFocus.bind(this)),this.$source.on("input."+this.eventname,this._handleChanges.bind(this)),this.$source.on("keydown."+this.eventname,this.app.input.handleTextareaTab.bind(this)),this.app.editor.unselectAll(),this.app.container.get("editor").hide(),this.app.container.get("source").show(),this.app.codemirror.create({el:this.$source,height:e,focus:!0}));t&&(t.on("change",this._handleChanges.bind(this)),t.on("focus",this._handleFocus.bind(this))),this.app.editor.disableUI(),this.app.toolbar.setToggled("html"),this.app.broadcast("source.open")},close:function(){this.app.broadcast("source.before.close");var t=this.getContent();this.app.codemirror.destroy(),this.$source.off("."+this.eventname),this.app.container.get("source").hide(),this.app.container.get("editor").show(),this.app.editor.setContent({html:t,caret:"start"}),this.app.editor.enableUI(),this.app.toolbar.unsetToggled("html"),this.app.broadcast("source.close")},update:function(t){var e=this.app.editor.isTextarea()?"val":"html";this.app.$element[e](t)},getContent:function(){var t=this.$source.val();return this.app.codemirror.val(t)},_build:function(){this.opts.source&&(this.$source=this.dom("<textarea>").addClass(this.prefix+"-source"),this.$source.attr("data-gramm_editor",!1),this.app.container.get("source").append(this.$source))},_handleFocus:function(){this.app.editor.setFocus()},_handleChanges:function(t){var e=this.getContent();this.update(e),this.app.broadcast("source.change",{e:t})}}),t.add("module","content",{init:function(){this._selectors={code:["pre","code"],embed:["figure"],noneditable:["."+this.opts.noneditable.classname],images:["img"],links:["a"]}},paragraphize:function(t){return this.app.paragraphizer.paragraphize(t)},encodeEntities:function(t){return this.decodeEntities(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")},encodeCode:function(t){return t=(t=(t=(t=(t=(t=(t=(t=this.encodeAttrSings(t)).replace(/<\s/gi,"< ")).replace(/<([^>]+)</gi,"<$1<")).replace(/<(.*?)>/gi,"xtagstartz$1xtagendz")).replace(/xtagstartzpre(.*?)xtagendz/g,"<pre$1>")).replace(/xtagstartzcode(.*?)xtagendz/g,"<code$1>")).replace(/xtagstartz\/codextagendz/g,"</code>")).replace(/xtagstartz\/prextagendz/g,"</pre>"),t=(t=(t=this._encodeCode(t)).replace(/xtagstartz([\w\W]*?)xtagendz/g,"<$1>")).replace(/xtagstartz\/(.*?)xtagendz/g,"</$1>"),t=this.decodeAttrSings(t)},encodeAttrSings:function(t){var e=t.match(/="(.*?)"/g);if(null!==e)for(var i,s=0;s<e.length;s++)-1===e[s].search(/^"</)&&-1===e[s].search(/>"$/)&&(i=(i=e[s].replace(/>/g,"xmoresignz")).replace(/</g,"xlesssignz"),t=t.replace(e[s],i));return t},decodeAttrSings:function(t){return t=(t=t.replace(/xmoresignz/gi,">")).replace(/xlesssignz/gi,"<")},decodeEntities:function(t){return String(t).replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/&/g,"&")},decodeHref:function(t){var e=t.match(new RegExp('(href=".*?)(&)(.*?">)',"g"));if(null!==e)for(var i=0;i<e.length;i++)t=t.replace(e[i],e[i].replace(/&/g,"&"));return t},sanitize:function(t){return t=this.app.utils.wrap(t,function(t){t.find("[src]").each(this._sanitizeSrc),t.find("a").each(this._sanitizeHref),t.find("a,b,i,strong,em,svg,img,details,audio").each(this._sanitizeEvents)}.bind(this))},escapeHtml:function(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")},store:function(t,e,i,s){for(var a=this._selectors[e],n=0;n<a.length;n++){var o=this._getElementsFromHtml(t,a[n]);t=this._store(t,e,o,i,s)}return t},restore:function(t,e,i){if(void 0!==i[e])for(var s=0;s<i[e].length;s++)t=t.replace("####_"+e+s+"_####",i[e][s]);return t},storeComments:function(t,e){var i=t.match(new RegExp("\x3c!--([\\w\\W]*?)--\x3e","gi"));if(null!==i)for(var s=0;s<i.length;s++)t=t.replace(i[s],"#####xstarthtmlcommentzz"+s+"xendhtmlcommentzz#####"),e.push(i[s]);return t},restoreComments:function(t,e){for(var i=0;i<e.length;i++){var s=e[i].replace(/\$/gi,"$");t=t.replace("#####xstarthtmlcommentzz"+i+"xendhtmlcommentzz#####",s)}return t},cacheStyle:function(t){var e=this.opts.tags.block.join(",")+",img,"+this.opts.tags.inline.join(",");return this.app.utils.wrap(t,function(t){t.find(e).each(this._cacheStyle.bind(this))}.bind(this))},recacheStyle:function(t){return this.app.utils.wrap(t,function(t){t.find("[data-"+this.prefix+"-style-cache]").each(this._recacheStyle.bind(this))}.bind(this))},cacheElementStyle:function(t){let e="data-"+this.prefix+"-style-cache",i=t.attr("style");i?(i=i.replace(/"/g,""),t.attr(e,i)):i&&""!==i||t.removeAttr(e)},recacheElementStyle:function(t){var e="data-"+this.prefix+"-style-cache",i=t.attr(e);t.attr("style",i).removeAttr(e)},fixListMargin:function(t){var e,i=parseInt(t.css("margin-left"));0!==i&&(e=parseInt(t.css("padding-left")),t.css({"margin-left":0,"padding-left":e+i+"px"}),t.attr(this.prefix+"-list-left",i))},unfixListMargin:function(t){t.attr(this.prefix+"-list-left")&&(t.css({"padding-left":"","margin-left":""}),t.removeAttr(this.prefix+"-list-left"))},addNofollow:function(t){return this.opts.link.nofollow?this.app.utils.wrap(t,function(t){t.find("a").attr("rel","nofollow")}):t},addHttps:function(t){return t=this.opts.editor.https?(t=(t=t.replace('href="http://','href="https://')).replace('src="http://','src="https://')).replace('srcset="http://','srcset="https://'):t},addSpaceToBlocks:function(t){return t.replace(/<\/(div|li|dt|dd|td|p|H[1-6])>\n?/gi,"</$1> ")},addBrToBlocks:function(t){return t.replace(/<\/(div|li|dt|dd|td|p|H[1-6])>\n?/gi,"</$1><br>")},addPredefinedTagClass:function(t){var e=t.get().tagName.toLowerCase(),i=void 0!==this.opts.classes.tags?this.opts.classes.tags:this.opts.classes;void 0!==i[e]&&t.addClass(i[e])},addPredefinedBlockClass:function(t){var e=t.attr("data-"+this.prefix+"-type"),i=this.opts.classes.blocks;void 0!==i[e]&&t.addClass(i[e])},getPredefinedBlocks:function(){var e=[];return Object.keys(this.opts.classes.blocks).forEach(function(t){e.push(t)}),e},getPredefinedTags:function(){var e=[],t=void 0!==this.opts.classes.tags?this.opts.classes.tags:this.opts.classes;return Object.keys(t).forEach(function(t){e.push(t)}),e},getText:function(t){var e="";if(3===t.nodeType)e=t.nodeValue;else{for(var i=0;i<t.childNodes.length;i++)e+=this.getText(t.childNodes[i]);var s=1===t.nodeType?getComputedStyle(t).getPropertyValue("display"):"";(s.match(/^block/)||s.match(/list/)||"BR"===t.tagName||"HR"===t.tagName)&&(e+="\n")}return e},getTextFromHtml:function(t,e){var i={},s=(e=h.extend({},{br:!1,nl:!1,trimlines:!0,images:!1,links:!1},e),t=this.store(t,"code",i,0),t=e.links?this.store(t,"links",i,0):t,t=(t=(t=(t=(t=(t=(t=(t=(t=e.images?this.store(t,"images",i,0):t).replace(/<(ul|ol)>\s+<li>/gi,"<$1><li>")).replace(/<li[^>]*>\n/gi,"<li$1>")).replace(/<p[^>]*>(\s+|)<\/p>/gi,"xemptyz")).replace(/<!--[\s\S]*?-->/gi,"")).replace(/<style[\s\S]*?style>/gi,"")).replace(/<script[\s\S]*?script>/gi,"")).replace(/<\/(div|li|dt|dd|td|p|H[1-6])>\n?/gi,"</$1>\n")).replace(/&(lt|gt);/gi,"x$1z"),this.dom("<div>").html(t));if(t=this.getText(s.get()),e.trimlines){for(var a="",n=t.split("\n"),o=0;o<n.length;o++)a+=n[o].trim()+"\n";t=a}return t=(t=(t=t.replace(/[\n]+/g,"\n")).replace("xemptyz","\n")).replace(/x(lt|gt)z/gi,"&$1;"),t=e.br?(t=t.replace(/\n/g,"<br>\n")).replace(/<br\s?\/?>\n?$/gi,""):e.nl?t:t.replace(/\n/gi," "),t=this.restore(t,"code",i),t=e.links?this.restore(t,"links",i):t,t=(t=(t=(t=(t=e.images?this.restore(t,"images",i):t).replace(/<pre[^>]*>/g,"")).replace(/<code[^>]*>/g,"")).replace(/<\/pre>\n?/g,"")).replace(/<\/code>/g,""),(t=e.images?t:(t=t.replace(/<img[\s\S]*?>/gi,"")).replace(/<a[^>]*>(\s+|)<\/a>/gi,"")).trim()},extractHtmlFromCaret:function(t){var e,t=this.dom(t).get(),i=this.app.selection.getRange();if(i)return(e=i.cloneRange()).selectNodeContents(t),e.setStart(i.endContainer,i.endOffset),e.extractContents()},isEmptyHtml:function(t,e){return t=t.trim(),t=(t=(t=(t=(t=(t=(t=(t=(t=this.app.utils.removeInvisibleChars(t)).replace(/^ $/gi,"1")).replace(/ /gi,"")).replace(/<\/?br\s?\/?>/g,"")).replace(/\s/g,"")).replace(/^<p>\s\S<\/p>$/i,"")).replace(/<hr(.*?[^>])>$/i,"hr")).replace(/<iframe(.*?[^>])>$/i,"iframe")).replace(/<source(.*?[^>])>$/i,"source"),t=this.removeComments(t),""===(t=(t=(t=(t=e?t.replace(/<p[^>]*><\/p>/gi,""):t).replace(/<[^/>]><\/[^>]+>/gi,"")).replace(/<[^/>]><\/[^>]+>/gi,"")).trim())},isLine:function(t){var e=document.createElement("div");return e.innerHTML=t,0===this.dom(e).find(this.opts.tags.block.join(",")+",img").length},removeDoctype:function(t){return t.replace(new RegExp("<!doctype[^>]*>","gi"),"")},removeComments:function(t){return t.replace(/<!--[\s\S]*?-->\n?/g,"")},removeTags:function(t,i){return t.replace(i?/<\/?([a-z][a-z0-9]*)\b[^>]*>/gi:/(<([^>]+)>)/gi,i?function(t,e){return-1===i.indexOf(e.toLowerCase())?t:""}:"")},removeTagsExcept:function(t,i){return void 0===i?t.replace(/(<([^>]+)>)/gi,""):t.replace(/<\/?([a-z][a-z0-9]*)\b[^>]*>/gi,function(t,e){return-1===i.indexOf(e.toLowerCase())?"":t})},removeTagsWithContent:function(t,e){return this.app.utils.wrap(t,function(t){t.find(e.join(",")).remove()})},removeMarkers:function(t){return this.app.utils.wrap(t,function(t){t.find("."+this.prefix+"-plus-button").remove(),t.find("."+this.prefix+"pastemarker").removeClass(this.prefix+"pastemarker"),t.find("."+this.prefix+"pasteitems").removeClass(this.prefix+"pasteitems"),t.find("."+this.prefix+"-selection-marker").remove()}.bind(this))},removeEmptySpans:function(t){return this.app.utils.wrap(t,function(t){t.find("span").each(this._removeEmptySpan.bind(this))}.bind(this))},removeEmptyInlines:function(t){return this.app.utils.wrap(t,function(t){t.find(this.opts.tags.inline.join(",")).each(this._removeEmptyTag.bind(this))}.bind(this))},removeEmptyAttrs:function(t,i){return this.app.utils.wrap(t,function(t){for(var e=0;e<i.length;e++)t.find("["+i[e]+'=""]').removeAttr(i[e])})},removeBlockTags:function(t,e,i){var s=this.opts.tags.block.concat();return i&&(s=this.app.utils.removeFromArrayByValue(s,i)),e=e&&(e?this.app.utils.extendArray(s,e):s),this.removeTags(t,e)},removeBlockTagsInside:function(t,e){return this.blockListTags=this.app.utils.removeFromArrayByValue(this.opts.tags.block.concat(),["ul","ol","li"]),this.app.utils.wrap(t,function(t){t.find(e.join(",")).each(this._removeBlockTagsInside.bind(this))}.bind(this))},removeInlineStyles:function(t){var e=this.app.utils.removeFromArrayByValue(this.opts.tags.inline,"a");return this.app.utils.wrap(t,function(t){t.find(e.join(",")).removeAttr("style")})},removeStyleAttr:function(t,e){return e=e||"",this.app.utils.wrap(t,function(t){t.find("*").not("[data-"+this.prefix+"-style-cache]"+e).removeAttr("style")}.bind(this))},_cacheStyle:function(t){var e="data-"+this.prefix+"-style-cache",i=t.attr("style");i?(i=i.replace(/"/g,""),t.attr(e,i)):t.removeAttr(e)},_recacheStyle:function(t){var e="data-"+this.prefix+"-style-cache",i=t.attr(e);t.attr("style",i).removeAttr(e)},_cleanEmpty:function(t){return t=t.trim(),t=(t=(t=this.app.utils.removeInvisibleChars(t)).replace(/<\/?br\s?\/?>/g,"")).replace(/\s/g,"")},_removeEmptySpan:function(t){0===t.get().attributes.length&&t.unwrap()},_removeEmptyTag:function(t){var e=t.html().trim();0===t.get().attributes.length&&""===e&&t.unwrap()},_removeBlockTagsInside:function(t){var e="LI"===t.get().tagName?this.blockListTags:this.opts.tags.block;t.find(e.join(",")).append("<br>").unwrap()},_store:function(t,e,i,s,a){if(i){void 0===s[e]&&(s[e]=[]);for(var n=0;n<i.length;n++)s[e][a]=i[n],t=t.replace(i[n],"####_"+e+a+"_####"),a++}return t},_getElementsFromHtml:function(t,e){var i=[];return this.dom("<div>").html(t).find(e).each(function(t){i.push(t.get().outerHTML)}),i},_sanitizeSrc:function(t){var t=t.get(),e=t.getAttribute("src");(-1!==e.search(/^javascript:/i)||"IMG"!==t.tagName&&-1!==e.search(/^data:/i))&&t.setAttribute("src","")},_sanitizeHref:function(t){var t=t.get(),e=t.getAttribute("href");e&&-1!==e.search(/^javascript:/i)&&t.setAttribute("href","")},_sanitizeEvents:function(t){t.removeAttr("onload onerror ontoggle onwheel onmouseover oncopy")},_encodeCode:function(t){return this.app.utils.wrap(t,function(t){t.find("pre code, pre, code").each(this._encodeNode.bind(this))}.bind(this))},_encodeNode:function(t){var t=t.get(),e=t.firstChild,i=t.innerHTML;"PRE"===t.tagName&&e&&"CODE"===e.tagName||(i=(i=i.replace(/xtagstartz/g,"<")).replace(/xtagendz/g,">"),e=this.decodeEntities(i),t.textContent=this._encodeNodeHtml(e))},_encodeNodeHtml:function(t){return t=t.replace(/ /g," ").replace(/<br\s?\/?>/g,"\n"),t=this.opts.code.spaces?t.replace(/\t/g,new Array(this.opts.code.spaces+1).join(" ")):t}}),t.add("module","autoparse",{parse:function(t){if(this.opts.paste.autoparse){var e=this.app.block.get(),i=[],s=(t=this.app.content.storeComments(t,i),t=this.app.content.removeDoctype(t),["figure","html","form","pre","div","span","video","object","iframe","code","a","img","link","script"]),a=["div","img","html","span"],n=[],o=0;for(c=0;c<s.length;c++){var r=-1!==a.indexOf(s[c])?"<"+s[c]+"[^>]*>":"<"+s[c]+"[^>]*>([\\w\\W]*?)</"+s[c]+">",p=t.match(new RegExp(r,"gi"));if(null!==p)for(var l=0;l<p.length;l++)t=t.replace(p[l],"#####replaceparse"+o+"#####"),n.push(p[l]),o++}if((t=!(t=t.replace("&","&")).match(this.opts.regex.aurl1)&&!t.match(this.opts.regex.aurl2)||t.match(this.opts.regex.imageurl)?t:this._formatLinks(t)).match(this.opts.regex.imageurl))for(var h=t.match(this.opts.regex.imageurl),c=0;c<h.length;c++)t=t.replace(h[c],this._splitBlock(e,'<img src="'+h[c]+'">'));t=this._restoreReplaced(n,t),t=this.app.content.restoreComments(t,i),t=this._restoreReplaced(n,t)}return t},_splitBlock:function(t,e){return t?"\n"+e+"\n":e},_formatLinks:function(t){var s=!1!==this.opts.paste.linkTarget?' target="'+this.opts.paste.linkTarget+'"':"",a=this.opts.editor.https?"https":"http",n=this;return t=(t=t.replace(this.opts.regex.aurl1,function(t){return'<a href="'+t+'"'+s+">"+n._subLinkText(t)+"</a>"})).replace(this.opts.regex.aurl2,function(t,e,i){return e+'<a href="'+a+"://"+i+'"'+s+">"+n._subLinkText(i)+"</a>"})},_subLinkText:function(t){return t=-1===(t=t.length>this.opts.link.size?t.substring(0,this.opts.link.size)+"...":t).search("%")?decodeURIComponent(t):t},_restoreReplaced:function(t,e){for(var i=0;i<t.length;i++)e=e.replace("#####replaceparse"+i+"#####",t[i]);return e}}),t.add("module","caret",{set:function(t,e){var t=this.dom(t).get(),i=this.app.editor.getDocNode().createRange();t&&this._isInPage(t)&&(this.app.editor.setWinFocus(),this._isInline(t)&&this._isNon(t)&&("start"===e?e="before":"end"===e&&(e="after")),this[{start:"_setStart",end:"_setEnd",before:"_setBefore",after:"_setAfter"}[e]](i,t),this.app.selection.setRange(i))},is:function(t,e,i,s,a){var t=this.dom(t).get(),n=this.app.editor.getWinNode().getSelection(),o=!1;return t&&n.isCollapsed&&(n=this._getPosition(t,s,a),a=this._getSize(t,i,s),"end"===e?o=n===a:"start"===e&&(o=0===n)),o},_setStart:function(t,e){t.setStart(e,0),t.collapse(!0);var i=this._getInlineInside(e);i&&(t=this._setStartInline(t,i)),this._isInline(e)&&this._insertInvisibleNode(t)},_setStartInline:function(t,e){e=this.app.element.getAllInlines(e)[0];t.selectNodeContents(e),t.collapse(!0)},_setEnd:function(t,e){var i=1===e.nodeType&&e.lastChild,s=i&&this._isInline(i);t.selectNodeContents(e=s?i:e),t.collapse(!1)},_setBefore:function(t,e){t.setStartBefore(e),t.collapse(!0),this._isInline(e)&&this._insertInvisibleNode(t,e)},_setAfter:function(t,e){t.setStartAfter(e),t.collapse(!0);var i=3!==e.nodeType&&e.tagName.toLowerCase();!this._isInline(e)&&"br"!==i&&"svg"!==i||this._insertInvisibleNode(t)},_insertInvisibleNode:function(t,e){var i=this.app.utils.createInvisibleChar();return e?e.parentNode.insertBefore(i,e):t.insertNode(i),t.selectNodeContents(i),t.collapse(!1),i},_getInlineInside:function(t){t=t.firstChild;if(this._isInline(t)){for(var e=t.firstChild;e;){if(this._isInline(e))return e;e=e.firstChild}return t}},_getSize:function(t,e,i){var s,a=3===t.nodeType,n=e&&0!==e.length?((s=this.dom(t).clone()).find(e.join(",")).remove(),s.html().trim()):(n=a?t.textContent:t.innerHTML,a||!1===i?n:n.trim());return this._trimmed(n,a,i).length},_getPosition:function(t,e,i){var s=this.app.editor.getWinNode().getSelection().getRangeAt(0),a=s.cloneRange(),n=document.createElement("div"),o=3===t.nodeType,t=(a.selectNodeContents(t),a.setEnd(s.endContainer,s.endOffset),n.appendChild(a.cloneContents()),o||!1===e?n.innerHTML:n.innerHTML.trim()),s=-1!==t.search(/<\/?br\s?\/?>$/g)?1:0;return!1===i&&(s=0),(t=this._trimmed(t,o,e)).length+s},_trimmed:function(t,e,i){return!1===i?t.replace(/\n$/g,""):""===(t=(t=(t=this.app.utils.removeInvisibleChars(t)).replace(/<\/?([a-z][a-z0-9]*)\b[^>]*>/gi,"")).replace(/\s+/g," "))||e?t:t.replace(/\s$/,"")},_isInline:function(t){return this.app.element.is(t,"inline")},_isInPage:function(t){var e=!1,i=this.app.editor.getDocNode();return e=t&&t.nodeType?t!==i.body&&i.body.contains(t):e},_isNon:function(t){return"false"===t.getAttribute("contenteditable")}}),t.add("module","selection",{init:function(){this.savedSelection=!1,this.savedMarker=!1,this.savedPosition=!1,this.savedRange=!1},get:function(){var t=this._getSelection(),e=this._getRange(t),i=this._getCurrent(t);return{selection:t,range:e,collapsed:this._getCollapsed(t,e),current:i,parent:this._getParent(i)}},getRange:function(){return this._getRange(this.get().selection)},getNodes:function(t){var e=this.get(),i=t&&(t.type&&"inline"===t.type||t.tags&&-1!==t.tags.indexOf("a")),s=i?"_getAllRangeNodes":"_getRangeNodes",a=[];return 0<(a=this.app.editor.isAllSelected()?this.app.editor.getLayout().children().getAll():e.selection&&e.range?this[s](e.range):a).length?this._filterNodes(a,e.range,i,t):a},getCurrent:function(){var t=this._getSelection();return this._getCurrent(t)},getParent:function(){var t=this.getCurrent();return this._getParent(t)},getElement:function(t){return this._getElement(t,"element")},getInline:function(t){return this._getElement(t,"inline")},getTopInline:function(t){for(var e=t?this.dom(t).get():this.getCurrent(),i=[];e&&this._getElement(e,"inline");)i.push(e),e=e.parentNode;return i[i.length-1]},getDataBlock:function(t){var e=this._getSelection(),i=t||this._getCurrent(e);if(i)for(i=this.dom(i).get();i;){if(1===i.nodeType&&i.getAttribute("data-"+this.prefix+"-type"))return this.dom(i);i=i.parentNode}return this.dom()},getBlock:function(t){return this._getElement(t,"block")},getText:function(t,e){var i,s,a=this.get(),n=!1;return!!a.selection&&(t&&a.range?(e=void 0===e?1:e,i=this.app.editor.getLayout().get(),s=a.range.cloneRange(),"before"===t?(s.collapse(!0),s.setStart(i,0),n=s.toString().slice(-e)):"after"===t&&(s.selectNodeContents(i),s.setStart(a.range.endContainer,a.range.endOffset),n=s.toString().slice(0,e))):n=a.selection?a.selection.toString():"",n)},getHtml:function(){var t,e="",i=this.get();return i.selection&&(i=i.range.cloneContents(),(t=document.createElement("div")).appendChild(i),e=(e=t.innerHTML).replace(/<p><\/p>$/i,"")),e},getPosition:function(t){var e=this.getRange(),i={top:0,left:0,width:0,height:0};return this.app.editor.getWinNode().getSelection&&e.getBoundingClientRect&&(e=e.cloneRange(),"end"==t?e.setStart(e.endContainer,e.endOffset):(t=e.startOffset-1,e.setStart(e.startContainer,t<0?0:t)),i={top:(t=e.getBoundingClientRect()).top,bottom:t.bottom,left:t.left,width:t.right-t.left,height:t.bottom-t.top}),i},set:function(t,e){t&&(t.removeAllRanges(),t.addRange(e))},setRange:function(t){this.set(this.app.editor.getWinNode().getSelection(),t)},is:function(t){if(void 0===t)return this.get().selection;for(var e=this.dom(t).get(),i=this.getNodes(),s=0;s<i.length;s++)if(i[s]===e)return!0;return!1},isCollapsed:function(){var t=this.get();return this._getCollapsed(t.selection,t.range)},isIn:function(t){var t=this.dom(t).get(),e=this.getCurrent();return!(!e||!t)&&t.contains(e)},isAll:function(t){var e=!t,t=(t?this.dom(t):this.app.editor.getLayout()).get(),i=this.app.editor.getWinNode().getSelection(),s=this._getRange(i),e=e||this.is(t);return!i.isCollapsed&&!!e&&void 0!==t.textContent&&t.textContent.trim().length===s.toString().trim().length},select:function(t){var t=(t?this.dom(t):this.app.editor.getLayout()).get(),e=this.app.editor.getDocNode().createRange();e.selectNodeContents(t),this.setRange(e)},removeAllRanges:function(){var t=this._getSelection();t&&t.removeAllRanges()},deleteContents:function(){var t=this.getRange();!this.isCollapsed()&&t&&t.deleteContents()},collapse:function(t){t=t||"start";var e=this.get();e.selection&&!e.collapsed&&("start"===t?e.selection.collapseToStart():e.selection.collapseToEnd())},save:function(t){var e;t||(t=(e=this.app.block.get())?e.getBlock():this.app.editor.getLayout()),this.savedSelection={el:t,offset:this.app.offset.get(t)}},restore:function(t){var e;this.savedMarker||this.savedSelection&&(this.app.editor.setWinFocus(),e=this.savedSelection.el,this.dom(e).dataget("instance")&&!1!==t&&this.app.block.set(e),e&&(e.focus(),this.app.offset.set(e,this.savedSelection.offset)),this.savedSelection=!1)},saveMarker:function(){this.savedMarker=!0,this.app.marker.insert()},restoreMarker:function(){this.app.marker.restore(),this.savedMarker=!1,this.savedSelection=!1},_getSelection:function(){return this.app.editor.getSelection()},_getRange:function(t){return!!t&&0<t.rangeCount&&t.getRangeAt(0)},_getCurrent:function(t){return!!t&&t.anchorNode},_getParent:function(t){return!!t&&t.parentNode},_getElement:function(t,e){var i=this._getSelection();if(i)for(var s=t||this._getCurrent(i),s=this.dom(s).get();s;){if(this.app.element.is(s,e))return s;s=s.parentNode}return!1},_getCollapsed:function(t,e){var i=!1;return i=t&&t.isCollapsed||e&&0===e.toString().length?!0:i},_getNextNode:function(t){if(t.firstChild)return t.firstChild;for(;t;){if(t.nextSibling)return t.nextSibling;t=t.parentNode}},_getRangeNodes:function(t,e){var i,s=t.startContainer.childNodes[t.startOffset]||t.startContainer,a=t.endContainer.childNodes[t.endOffset]||t.endContainer,n=t.commonAncestorContainer,o=[];if(e){for(this.app.editor.isLayout(s)||o.push(s),i=s.parentNode;i&&!this.app.editor.isLayout(i)&&(o.push(i),i!==n);i=i.parentNode);for(o.reverse(),i=s;i&&(3===i.nodeType||0!==this.dom(i.parentNode).closest(n).length)&&(o.push(i),i!==a);i=this._getNextNode(i));}else for(3===s.nodeType&&o.push(this.getBlock(s)),i=s;i&&i!==n&&(3===i.nodeType||0!==this.dom(i.parentNode).closest(n).length)&&(o.push(i),i!==a);i=this._getNextNode(i));return o},_getAllRangeNodes:function(t){return this._getRangeNodes(t,!0)},_filterNodes:function(t,e,i,s){for(var a=(a=this.getText())?a.replace(/[-[\]/{}()*+?.\\^$|]/g,"\\$&"):"",n=[],o=0;o<t.length;o++){var r=!0;this.app.editor.isLayout(t[o])&&(r=!1),s&&(r=s.types?this._filterByTypes(r,s,t[o]):r,r=s.selected?this._filterBySelected(r,s,t[o],e,a):r,r=s.type?this._filterByType(r,s,t[o],i):r,r=s.tags?this._filterByTags(r,s,t[o]):r),r&&n.push(t[o])}var p=[];if(s&&("blocks"===s.type||"blocks-first"===s.type)){for(var l,h=0;h<n.length;h++)"blocks-first"===s.type?l=this.app.element.is(n[h],"blocks-first")?n[h]:this.app.element.getFirstLevel(n[h]).get():"blocks"===s.type&&(l=this.app.element.is(n[h],"blocks")?n[h]:this.app.element.getDataBlock(n[h]).get()),this._isInNodesArray(p,l)||p.push(l);n=p}return n},_filterByTypes:function(t,e,i){var s;return!0===e.types?(s=this.app.element.getType(i))||(t=!1):(s=this.app.element.getType(i),-1===e.types.indexOf(s)&&(t=!1)),t},_filterByType:function(t,e,i,s){var a=e.type;return"blocks"!==a&&"blocks-first"!==a||(a="block"),!s||e.links?this.app.element.is(i,a)||(t=!1):(1!==i.nodeType||"A"!==i.tagName)&&this.app.element.is(i,a)||(t=!1),t},_filterByTags:function(t,e,i){var s=void 0!==i.tagName;return t=s&&-1!==e.tags.indexOf(i.tagName.toLowerCase())?t:!1},_filterBySelected:function(t,e,i,s,a){return!0!==e.selected||this._containsNodeText(s,i)?"inside"===e.selected&&(1===i.nodeType&&"A"===i.tagName?t=!0:this._isTextSelected(i,a)||(t=!1)):t=!1,t},_isTextSelected:function(t,e){t=9!==t.nodeType?this.app.utils.removeInvisibleChars(t.textContent):"";return e===t||-1!==t.search(e)||-1!==e.search(new RegExp("^"+this.app.utils.escapeRegExp(t)+"$"))},_isBackwards:function(){var t,e=!1,i=this.get();return i&&!i.collapsed&&((t=this.app.editor.getDocNode().createRange()).setStart(i.selection.anchorNode,i.selection.anchorOffset),t.setEnd(i.selection.focusNode,i.selection.focusOffset),e=t.collapsed,t.detach()),e},_containsNodeText:function(t,e){for(var i,s,a,n=this.app.editor.getDocNode().createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode:function(t){return NodeFilter.FILTER_ACCEPT}},!1);a=n.nextNode();)i=i||a,s=a;var o=t.cloneRange();return i?(o.setStart(i,0),o.setEnd(s,s.length)):o.selectNodeContents(e),t.compareBoundaryPoints(Range.START_TO_START,o)<1&&-1<t.compareBoundaryPoints(Range.END_TO_END,o)},_isInNodesArray:function(t,e){return-1!==t.indexOf(e)}}),t.add("module","inline",{set(t){let e=this.dom([]);if(this.app.popup.close(),this.params=t||{},this.params.style){var i,s,a={};for([i,s]of Object.entries(this.params.style)){let t=i.replace(/([A-Z])/g," $1");a[t=t.split(" ").join("-").toLowerCase()]=s}this.params.style=a}if(this.app.selection.getRange())return e=this.app.selection.isCollapsed()?this._formatCollapsed():this._formatUncollapsed(),this.app.broadcast("inline.set",{$nodes:e}),this.app.sync.trigger(),this.app.editor.observeUI(),this.app.context&&this.app.context.updatePosition(),e},remove(e){var t,i=this.app.selection.getNodes({type:"inline"}),s=this.app.selection.getTopInline();if(this.app.selection.isCollapsed()&&s)t=s.tagName.toLowerCase(),s=this._insertSplit(s,t),this.app.caret.set(s,"before");else{if(this.app.selection.save(),e.style){var a=Array.isArray(e.style)?e.style:[e.style];for(let t=0;t<i.length;t++){var n=this.dom(i[t]);n.removeAttr("data-"+this.prefix+"-style-cache");for(let t=0;t<a.length;t++)n.css(a[t],"");""===n.attr("style")&&n.removeAttr("style"),this.app.content.cacheElementStyle(n)}}else if(e.classname)for(let t=0;t<i.length;t++){var o=this.dom(i[t]);o.removeClass(e.classname),""===o.attr("class")&&o.removeAttr("class")}this.app.selection.restore(),this.app.context&&this.app.context.updatePosition()}},removeFormat(){this.app.popup.close();let t=this.app.block.get(),e,i,s=0,a;if(t){for(e=t.getBlock(),this.app.selection.save(e),i=this.app.selection.getNodes({type:"inline"}),s;s<i.length;s++)(a=this.dom(i[s])).attr("data"+this.prefix+"-type")||a.unwrap();this.app.selection.restore(),this.app.editor.observeUI(),this.app.context&&this.app.context.updatePosition()}},_formatCollapsed(){let t,e=this.app.selection.getInline(),i=this.dom(e),s=this._getTags(),a=this._isSameTag(e,s),n=!(!this.params||!this.params.caret)&&this.params.caret;return this.app.selection.save(),e?this.app.utils.isEmptyHtml(e.innerHTML)?a?!this._isParams()||this._hasAllSameParams(e)?(this.app.caret.set(e,n||"after"),i.remove()):t=this._hasSameClassname(e)?(this.app.selection.restore(),this._setStyle(e)):this._hasSameStyle(e)?(this.app.selection.restore(),this._setClassname(e)):(this.app.selection.restore(),this._setParams(e)):(t=this._insertInline(this.params.tag,n),t=this._setParams(t)):e&&(a?!this._isParams()||this._hasAllSameParams(e)?this._makeSplit(e,n):t=this._hasSameClassname(e)?(t=this._insertInline(this.params.tag,n),this._setStyle(t)):this._hasSameStyle(e)?(t=this._insertInline(this.params.tag,n),this._setClassname(t)):(t=this._insertInline(this.params.tag,n),this._setParams(t)):(t=this._insertInline(this.params.tag,n),t=this._setParams(t))):(t=this._insertInline(this.params.tag,n),t=this._setParams(t)),this.dom(t)},_formatUncollapsed(){var t=!1,e=this.app.editor.isAllSelected(),i=this.dom(this.app.selection.getNodes({type:"blocks",partial:!0})),s=this.app.selection.getNodes({type:"inline"});return this.app.selection.save(),this._convertTags(i,s),this.app.selection.restore(),this.app.selection.save(),this._convertToStrike(s),this.app.selection.restore(),this.app.editor.getDocNode().execCommand("strikethrough"),this.app.selection.save(),t=this._revertToInlines(i),this.app.selection.restore(),this._clearEmptyStyle(),this.app.selection.save(),t.each(this._applyParams.bind(this)),this.app.selection.restore(),i.each(function(t){t.get().normalize()}),this.app.selection.save(),this._revertTags(i),this.app.selection.restore(),this.params.caret&&(s=t.last(),this.app.caret.set(s,this.params.caret)),e&&this.app.editor.selectAll(),t},_isParams(){return this.params.style||this.params.classname},_applyParams(a){var n=a.get().tagName.toLowerCase(),t=this._getTags(),o=a.parent(),t=0!==o.length&&this._isSameTag(o.get(),t);if(t&&o.text()===a.text()&&this.params.style){let t=this.params.style,e=this.app.utils.cssToObject(o.attr("style")),i=Object.keys(t).length,s=0;for(var r of Object.keys(t))e[r]&&s++;s===i?o.unwrap():(a.unwrap(),this._applyParamsToNode(o,n))}this._applyParamsToNode(a,n)},_applyParamsToNode(t,e){t.removeAttr("data-"+this.prefix+"-style-cache"),""===t.attr("class")&&t.removeAttr("class"),0===t.get().attributes.length?this._isParams()&&"span"===this.params.tag?(this._setParams(t),this._clearSpanInside(t)):"span"===e&&t.unwrap():this._isParams()&&(this._setParams(t),this._clearSpanInside(t))},_setParams(t){return t=this._setClassname(t),t=this._setStyle(t)},_setClassname(t){var e,t=this.dom(t);return this.params.classname&&(this.params.group?(e="inlineGroups."+this.params.group,(e=!!this.opts.is(e)&&this.opts.get(e))&&t.removeClass(e.join(" "))):t.removeAttr("class"),t.addClass(this.params.classname)),t.get()},_setStyle(t){t=this.dom(t);return this.params.style&&(t.css(this.params.style),this.app.content.cacheElementStyle(t)),t.get()},_hasAllSameParams(t){return this._hasSameClassname(t)&&this._hasSameStyle(t)},_hasSameClassname(t){t=this.dom(t);return!this.params.classname||t.hasClass(this.params.classname)},_hasSameStyle(t){t=this.dom(t);return!this.params.style||this.app.element.compareStyle(t,this.params.style)},_makeSplit(t,e){let i=this.app.create("caret"),s=i.is(t,"end"),a=t;s?e="after":a=this._insertSplit(t),i.set(a,e||"before")},_insertSplit(t,e){var i=this.dom(t),s=this.app.content.extractHtmlFromCaret(t),e=this.dom("<"+(e||this.params.tag)+" />"),a=document.createElement("div");return a.appendChild(s),(e=this.app.element.cloneAttrs(t,e)).append(a.innerHTML),i.after(e),e},_insertInline(t,e){return this.app.create("insertion").insertNode(document.createElement(t),e||"start")},_isSameTag(t,e){return t&&-1!==e.indexOf(t.tagName.toLowerCase())},_getTags(){let t=[this.params.tag];return"b"===this.params.tag||"strong"===this.params.tag?t=["b","strong"]:"i"!==this.params.tag&&"em"!==this.params.tag||(t=["i","em"]),t},_convertToStrike(e){let i=this.app.selection.getText().replace(/[-[\]/{}()*+?.\\^$|]/g,"\\$&"),s=this._getTags(),a,n,o,r,p=!1;for(let t=0;t<e.length;t++)a=e[t],n=this.dom(a),o=e[t].tagName.toLowerCase(),r=this._hasAllSameParams(a),-1!==s.indexOf(o)&&("span"===this.params.tag&&this._isFullySelected(a,i)?(n.addClass("rx-inline-convertable"),n.removeAttr("data-"+this.prefix+"-style-cache")):r&&"a"!==this.params.tag?this._replaceToStrike(n):"span"===this.params.tag?(this.params.style&&this._hasSameStyle(n)&&(p=!0),(p=this.params.classname&&this._hasSameClassname(n)?!0:p)?(n.addClass("rx-inline-convertable"),n.removeAttr("data-"+this.prefix+"-style-cache")):n.addClass("rx-inline-unconvertable")):r||(n.addClass("rx-inline-convertable"),n.removeAttr("data-"+this.prefix+"-style-cache")))},_convertInlineBlocks(t){t.find("[data-"+this.prefix+"-inline]").each(function(t){!0===t.attr("contenteditable")&&t.addClass("rx-inlineblock-editable").attr("contenteditable",!1)})},_convertTag(e,t){this.params.tag!==e?t.find(e).each(function(t){this.app.element.replaceToTag(t,"span").addClass("rx-convertable-"+e)}.bind(this)):"del"===this.params.tag&&t.find(e).each(function(t){this.app.element.replaceToTag(t,"strike")}.bind(this))},_convertTags(t,e){this._convertTag("del",t),this._convertTag("u",t),this._convertInlineBlocks(t)},_replaceToStrike(t){t.replaceWith(function(){return this.dom("<strike>").append(t.contents())}.bind(this))},_revertInlineBlocks(t){t.find(".rx-inlineblock-editable").removeClass("rx-inlineblock-editable").attr("contenteditable",!0)},_revertTag(e,t){t.find("span.rx-convertable-"+e).each(function(t){this.app.element.replaceToTag(t,e).removeAttr("class")}.bind(this))},_revertTags(t){this._revertTag("u",t),this._revertTag("del",t),this._revertInlineBlocks(t)},_revertToInlines(t){let i=this.dom([]);return"u"!==this.params.tag&&t.find("u").unwrap(),t.each(function(t){t.find("*").each(function(t){t.get().style.textDecorationLine&&(t.css("text-decoration-line",""),t.wrap("<u>"),""===t.attr("style"))&&t.removeAttr("style")})}),t.find(".rx-inline-convertable").each(function(e){e.find("strike").each(function(t){e.text()===t.text()&&t.unwrap()}),e.removeClass("rx-inline-convertable"),this.app.element.removeEmptyAttrs(e,["class"]),this._hasAllSameParams(e)?e.unwrap():i.add(e)}.bind(this)),t.find("span.rx-inline-unconvertable").each(function(t){t.removeClass("rx-inline-unconvertable"),this.app.element.removeEmptyAttrs(t,["class"])}.bind(this)),t.find("strike").each(function(t){t=this.app.element.replaceToTag(t,this.params.tag),i.add(t)}.bind(this)),i},_clearEmptyStyle(){let t=this.app.selection.getNodes({type:"inline"}),e=0,i=t.length,s,a=0;for(e;e<i;e++)if(this._clearEmptyStyleAttr(t[e]),s=t[e].childNodes)for(a;a<s.length;a++)this._clearEmptyStyleAttr(s[a])},_clearEmptyStyleAttr(t){3!==t.nodeType&&""===t.getAttribute("style")&&t.removeAttribute("style")},_clearSpanInside(t){t.find("span").each(function(t){if(this.params.classname&&t.removeAttr("class"),this.params.styles)for(var e of Object.keys(this.params.styles))t.css(e,"");""===t.attr("class")&&t.removeAttr("class"),""===t.attr("style")&&t.removeAttr("style"),0===t.get().attributes.length&&t.unwrap()}.bind(this))},_isFullySelected(t,e){t=this.app.utils.removeInvisibleChars(t.textContent);return e===t||-1!==e.search(new RegExp("^"+this.app.utils.escapeRegExp(t)+"$"))}}),t.add("module","popup",{init:function(){this.stack=!1,this.stacks=[],this.name=!1,this.supername=!1,this.autoclose=!0,this.control=!1,this.saved=!1},start:function(){this._build(),this._buildDepth()},stop:function(){this._stopEvents(),this._stop()},stopStack:function(){this._stopEvents(),this.app.toolbar.unsetToggled(),this.$popup.removeAttr("data-"+this.prefix+"-popup-name"),this.$popup.removeClass("open")},isOpen:function(t){var e=this.$popup.hasClass("open");return(!t||this._getName()===t)&&e},create:function(t,e){return this.isOpen(t)||(this._reset(),this.name=t,this.supername=t,this.stack=this._createStack(t,e)),this.stack},add:function(t,e){return this._createStack(t,e,!0)},setStack:function(t){this.stack=t,this.name=t.getName()},setData:function(t){this.stack.setData(t)},setFocus:function(t){this.stack.setFocus(t)},setWidth:function(t){this.stack.setWidth(t)},getName:function(){return this.name},getElement:function(){return this.$popup},getButton:function(){return this.button},getStack:function(t){return t?this.stacks[t]:this.stack},getBody:function(){return this.stack.getBody()},getItems:function(){return this.stack.getItems()},getFooter:function(){return this.stack.getFooter()},getFooterPrimary:function(){return this.stack.getFooterPrimary()},getTool:function(t){return this.stack.getTool(t)},getInput:function(t){return this.stack.getInput(t)},getFormItem:function(t){return this.stack.getFormItem(t)},getData:function(t){return this.stack.getData(t)},open:function(t){this.isOpen()?this.isOpen(this.supername)?(this.saved=!0,this.close(!1)):(this.saved=!0,this.close(!1),this._open(t,!1)):(this.saved=!1,this._open(t))},openStack:function(t){var t=this.getStack(t),e={};this.stack&&this.stack.isCollapsed()&&(e={collapse:!0},this.removeStack(this.stack)),t.open(e)},close:function(t,e){!1===this.autoclose&&!0!==t&&!e||!this.isOpen()||t&&this._isPopupTarget(t)||(this._stopEvents(),this._resetToolbarToggledButton(),!1!==t&&!1===this.saved&&(this.app.scroll.save(),this.app.selection.restore(),this.app.scroll.restore()),this.$popup.hide(),this._closed())},closeStacks:function(){for(var t in this.stacks)"object"==typeof this.stacks[t]&&this.stacks[t].close()},removeStack:function(t){t=t.getName();delete this.stacks[t],this.$popup.find("[data-"+this.prefix+"-stack-name="+t+"]").remove()},updatePosition:function(t){this._buildPosition(t),this._buildHeight()},resize:function(){var t=this.$popup.attr("data-width"),e=this.app.editor.getWidth();if("100%"!==t&&parseInt(t)<e)return;this.$popup.css("width",e+"px")},_build:function(){this.$popup=this.dom("<div>").addClass(this.prefix+"-popup "+this.prefix+"-popup-"+this.uuid),this.$popup.hide(),this.$popup.attr("dir",this.opts.editor.direction),this.app.$body.append(this.$popup)},_buildDepth:function(){this.opts.bsmodal&&this.$popup.css("z-index",1061)},_buildButton:function(t){t&&(this.button=!!Object.prototype.hasOwnProperty.call(t,"button")&&t.button)},_buildControl:function(t){t&&(this.control=!!Object.prototype.hasOwnProperty.call(t,"control")&&t.control)},_buildName:function(){this.$popup.attr("data-"+this.prefix+"-popup-name",this.name),this.$popup.addClass(this.prefix+"-popup-"+this.name)},_buildHeader:function(){this.header=this.app.create("popup.header",this)},_buildHeight:function(){var t,e=this.app.scroll.getTarget(),i=this.$popup.offset(),i=this.app.scroll.isTarget()?(t=i.top-e.offset().top,e.height()-parseInt(e.css("border-bottom-width"))):(t=i.top-e.scrollTop(),e.height());this.$popup.css("max-height",i-t-10+"px")},_buildPosition:function(){var t=this._isButton()&&this.button.isControl()||this._isControl()?this._buildPositionControl():this._isButton()?this._buildPositionButton():this._buildPositionModal();this.$popup.css({top:t.top-1+"px",left:t.left+"px"})},_buildPositionButton:function(){var t=this.app.editor.getRect(),e=this.button.getOffset(),i=this.button.getDimension(),s=this.$popup.width(),a={};return this._isToolbarButton()||this._isTopbarButton()?(a={top:e.top+i.height,left:e.left}).left+s>t.right&&(a.left=e.left+i.width-s):(a={top:e.top+t.top+i.height,left:e.left+t.left+i.width/2-s/2}).left+s>t.right&&(a.left=t.left+t.width-s),(a.left<t.left||a.left<0)&&(a.left=t.left),a},_buildPositionControl:function(){var t=this.app.block.get(),t=(t=t.isSecondLevel()?t.getFirstLevel():t).getBlock().offset();return{top:t.top,left:t.left}},_buildPositionModal:function(){var t,e;return e=(t=this.opts.toolbar?(t=(e=this.app.container.get("toolbar")).height(),(e=e.offset()).top+t):(e=(t=(t=this.app.block.get()).isSecondLevel()?t.getFirstLevel():t).getBlock().offset()).top,e.left),{top:t,left:e}},_getName:function(){return this.$popup.attr("data-"+this.prefix+"-popup-name")},_setToolbarToggledButton:function(){var t;this.app.toolbar.unsetToggled(),this._isToolbarButton()&&(t=this.button.getName(),this.app.toolbar.setToggled(t))},_createStack:function(t,e,i){Object.prototype.hasOwnProperty.call(e,"collapse")&&!1===e.collapse&&(i=!1),Object.prototype.hasOwnProperty.call(e,"autoclose")&&(this.autoclose=e.autoclose);e=this.app.create("popup.stack",t,e,i,this);return this.stacks[t]=e},_open:function(t,e){this._buildButton(t),this._buildControl(t),this._buildName(),this._buildHeader(),this.app.broadcast("popup.before.open").isStopped()?this.stopStack():(this._setToolbarToggledButton(),this._startEvents(),!1!==e&&this.app.editor.isPopupSelection()&&this.app.selection.save(),this.stack=this._findActiveStack(),this.stack.open(t,!1,!1),this._buildPosition(),!1===e?(this.$popup.show(),this._opened()):this.$popup.fadeIn(100,this._opened.bind(this)))},_opened:function(){this._buildHeight(),this.$popup.addClass("open"),this.app.broadcast("popup.open"),this.stack.renderFocus()},_closed:function(){var t="data-"+this.prefix+"-popup-name",e=this.$popup.attr(t);this.$popup.removeAttr(t),this.$popup.removeClass("open "+this.prefix+"-popup-"+e),this.saved=!1,this.app.broadcast("popup.close")},_isPopupTarget:function(t){return 0!==this.dom(t.target).closest("."+this.prefix+"-popup").length},_isButton:function(){return this.button},_isControl:function(){return this.control},_isToolbarButton:function(){return this.button&&("toolbar"===this.button.type||"context"===this.button.type)},_isTopbarButton:function(){return this.button&&"topbar"===this.button.type},_findActiveStack:function(){for(var t in this.stacks)"object"==typeof this.stacks[t]&&this.stacks[t].isActive()&&(this.stack=this.stacks[t]);return this.stack},_reset:function(){this.button=!1,this.control=!1,this.autoclose=!0,this.stack=!1,this.stacks=[],this.$popup.html(""),this.$popup.removeClass("has-footer has-items has-form")},_resetToolbarToggledButton:function(){var t;this.button&&(t=this.button.getName(),this.app.toolbar.unsetToggled(t))},_startEvents:function(){var t=this.prefix+"-popup";this.app.scroll.getTarget().on("resize."+t+" scroll."+t,this.updatePosition.bind(this))},_stopEvents:function(){this.app.scroll.getTarget().off("."+this.prefix+"-popup")},_stop:function(){this.$popup&&this.$popup.remove()}}),t.add("class","popup.item",{defaults:{container:!1,title:!1,html:!1,toggle:!0,active:!1,divider:!1,remover:!1,classname:!1,params:!1,instance:!1,observer:!1,command:!1},init:function(t,e,i){this.popup=t,this.name=e,this.params=this._buildParams(i),this._build(),this._buildContainer(),this._buildIcon(),this._buildTitle(),this._buildImage(),this._buildShortcut(),this._buildActive(),this._buildHidden(),this._buildDivider(),this._buildCommand(),this._buildRemover()},getPopup:function(){return this.popup},getName:function(){return this.name},getParams:function(){return this.params.params},getElement:function(){return this.$item},getInstance:function(){return this.params.instance},isControl:function(){return this.params.control},_build:function(){this.$item=this.params.html?this.dom(this.params.html):this.dom("<div>"),this.$item.addClass(this.prefix+"-popup-item "+this.prefix+"-popup-stack-item"),this.$item.attr({"data-name":this.name})},_buildContainer:function(){this.params.container&&this.$item.addClass(this.prefix+"-popup-item-container")},_buildTitle:function(){this.params.title&&(this.$title=this.dom("<span>").addClass(this.prefix+"-popup-item-title"),this.$title.html(this.lang.parse(this.params.title)),this.$item.append(this.$title))},_buildImage:function(){this.params.image&&(this.$image=this.dom("<span>").addClass(this.prefix+"-popup-item-image"),this.$image.html(this.params.image),this.$item.append(this.$image))},_buildIcon:function(){this.params.icon&&(this.$icon=this.dom("<span>").addClass(this.prefix+"-popup-item-icon"),this.opts.buttons.icons&&void 0!==this.opts.buttons.icons[this.name]?this.$icon.html(this.opts.buttons.icons[this.name]):!0===this.params.icon?this.$icon.addClass(this.prefix+"-icon-"+this.name):-1!==this.params.icon.search(/</)?this.$icon.html(this.params.icon):this.$icon.addClass(this.prefix+"-icon-"+this.params.icon),this.$item.append(this.$icon))},_buildShortcut:function(){var t;this.params.shortcut&&(t=/(Mac|iPhone|iPod|iPad)/i.test(navigator.platform)?"<b>⌘</b>":"ctrl",t=this.params.shortcut.replace("Ctrl",t),this.$shortcut=this.dom("<span>").addClass(this.prefix+"-popup-item-shortcut"),this.$shortcut.html(t),this.$item.append(this.$shortcut))},_buildParams:function(t){return h.extend({},!0,this.defaults,t)},_buildActive:function(){this.params.active&&this.$item.addClass("active")},_buildHidden:function(){this.params.hidden&&this.$item.addClass(this.prefix+"-popup-item-hidden")},_buildDivider:function(){this.params.divider&&this.$item.addClass(this.prefix+"-popup-item-divider-"+this.params.divider)},_buildCommand:function(){this.params.command&&(this.$item.on("click."+this.prefix+"-popup-item-"+this.uuid,this._catch.bind(this)),this.$item.attr("data-command",this.params.command))},_buildRemover:function(){var t;this.params.title&&this.params.remover&&((t=this.dom("<span>").addClass(this.prefix+"-popup-item-trash "+this.prefix+"-icon-trash")).attr("data-command",this.params.remover),t.on("click."+this.prefix+"-popup-item-"+this.uuid,this._catchRemover.bind(this)),this.$item.append(t))},_catchRemover:function(t){t.preventDefault(),t.stopPropagation();var e=this.dom(t.target).closest("."+this.prefix+"-popup-stack-item"),t=this.dom(t.target).closest("."+this.prefix+"-popup-item-trash").attr("data-command"),i=e.attr("data-name");this.app.api(t,this,i),e.fadeOut(200,function(t){t.remove()})},_catch:function(t){t.preventDefault(),t.stopPropagation();var e=this.dom(t.target).closest("."+this.prefix+"-popup-stack-item"),i=e.attr("data-name"),s=e.attr("data-command");this.popup.$items.find("."+this.prefix+"-popup-stack-item").removeClass("active"),this.params.toggle&&e.addClass("active"),this.app.api(s,this.getParams(),this,i,t)}}),t.add("class","popup.stack",{defaults:{active:!1,title:!1,type:!1,width:!1,setter:!1,getter:!1,builder:!1,observer:!1,instance:!1,collapse:!1,form:!1,items:!1,html:!1,focus:!1,footer:!1},init:function(t,e,i,s){this.defaultWidth="240px",this.popup=s,this.name=t,this.tools={},this.data=!1,this.items=!1,this.formitems=!1,this.params=h.extend({},!0,this.defaults,e),i&&(this.params.collapse=!0),this._build(),this._observe()},set:function(t,e){this.params[t]=e},setData:function(t){this.data=t},setFocus:function(t){void 0!==this.tools[t]&&this.tools[t].setFocus()},setWidth:function(t){var e=this.app.popup.getElement();e.attr("data-width",t),"100%"===t&&(t=this.app.editor.getWidth()+"px"),e.css("width",t),this.app.$win.on("resize."+this.prefix+"-popup-"+this.uuid,this.popup.resize.bind(this.popup)),this.popup.resize()},setItemsData:function(t){this.items=t},get:function(t){return this.params[t]},getElement:function(){return this.$stack},getName:function(){return this.name},getBody:function(){return this.$body},getInstance:function(){return this.get("instance")},getItemsData:function(){return this.items},getItems:function(){return this.$items},getFooter:function(){return this.$footer},getFooterPrimary:function(){return this.$footer.find("."+this.prefix+"-form-button-primary")},getTool:function(t){return void 0!==this.tools[t]&&this.tools[t]},getInput:function(t){t=this.getTool(t);return t?t.getInput():this.dom()},getFormItem:function(t){t=this.getTool(t);return t?t.getInput().closest("."+this.prefix+"-form-item"):this.dom()},getData:function(t){var e;return t?void 0!==this.tools[t]&&(e=this.tools[t].getValue()):(e={},Object.keys(this.tools).forEach(function(t){e[t]=this.tools[t].getValue()}.bind(this))),e},hasForm:function(){return this.formitems},hasFooter:function(){return 0!==this.footerbuttons},hasItems:function(){return!1!==this.items},isCollapsed:function(){return this.get("collapse")},isActive:function(){return this.get("active")},open:function(t,e,i){if((t&&t.focus&&this.set("focus",t.focus),this.popup.closeStacks(),this.app.popup.setStack(this),!1!==i)&&this.app.broadcast("popup.before.open").isStopped())return void this.popup.stopStack();t&&t.collapse?(this._buildItems(),this._renderItems()):this.render(),this.popup.header.render(this.popup.stacks),this.popup.header.setActive(this),this.$stack.show(),this._renderWidth(),!1!==e&&this.renderFocus(),!1!==i&&this.app.broadcast("popup.open")},close:function(){this.$stack.hide()},collapse:function(){var t=this._getPrev();this.isCollapsed()&&this.popup.removeStack(this),t.open({collapse:!0})},render:function(){this._renderType(),this.params.html?this._renderHtml():this._renderItems(),this._renderForm(),this._renderFooter(),this._renderEnv()},renderFocus:function(){this.get("focus")&&this.setFocus(this.get("focus"))},_observe:function(){this.params.observer&&this.app.api(this.params.observer,this)},_getPrev:function(){var t,e;for(e in this.popup.stacks)if(this.popup.stacks.hasOwnProperty(e)){if(e===this.name)return t;t=this.popup.stacks[e]}},_build:function(){this._buildElement(),this._buildBody(),this._buildFooter(),this._buildParams()},_buildElement:function(){this.$stack=this.dom("<div>").addClass(this.prefix+"-popup-stack "+this.prefix+"-popup-stack-"+this.name),this.$stack.hide(),this.$stack.attr("data-"+this.prefix+"-stack-name",this.name),this.popup.getElement().append(this.$stack)},_buildBody:function(){this.$body=this.dom("<div>").addClass(this.prefix+"-popup-body"),this.$stack.append(this.$body)},_buildFooter:function(){this.$footer=this.dom("<div>").addClass(this.prefix+"-popup-footer"),this.$stack.append(this.$footer)},_buildParams:function(){this.params.width=this.params.width||this.defaultWidth,this.params.setter=this.params.setter||!1,this.params.getter=this.params.getter||!1,this.data=!!this.params.getter&&this.app.api(this.params.getter,this),this._buildItems()},_buildItems:function(){this.params.builder?this.items=this.app.api(this.params.builder,this):this.params.items&&(this.items=this.params.items)},_renderWidth:function(){this.setWidth(this.get("width"))},_renderType:function(){this.$stack.removeClass(this.prefix+"-popup-type-grid");var t=this.get("type");t&&this.$stack.addClass(this.prefix+"-popup-type-"+t)},_renderHtml:function(){this.$items?this.$items.html(""):(this.$items=this.dom("<div>").addClass(this.prefix+"-popup-html"),this.$body.append(this.$items)),this.$items.append(this.params.html)},_renderItems:function(){if(this.items)for(var t in this.$items?this.$items.html(""):(this.$items=this.dom("<div>").addClass(this.prefix+"-popup-items"),this.$body.append(this.$items)),this.items){var e;this.items.hasOwnProperty(t)&&(Object.prototype.hasOwnProperty.call(this.items[t],"observer")&&this.items[t].observer&&void 0!==(e=this.app.api(this.items[t].observer,this.items[t],t,this))&&(this.items[t]=e),!1!==this.items[t])&&(e=this.app.create("popup.item",this,t,this.items[t]).getElement(),this._renderItemPosition(this.$items,e,this.items[t]))}},_renderItemPosition:function(t,e,i){var s;i.position?"first"===(i=i.position)?t.prepend(e):"object"==typeof i&&(s=i[i=Object.prototype.hasOwnProperty.call(i,"after")?"after":"before"],(s=this._findPositionElement(s,t))?s[i](e):t.append(e)):t.append(e)},_renderEnv:function(){var t=this.popup.getElement();t.removeClass("has-footer has-items has-form"),this.hasForm()&&t.addClass("has-form"),this.hasFooter()&&t.addClass("has-footer"),this.hasItems()&&t.addClass("has-items")},_renderForm:function(){this.formitems=this.get("form"),this.formitems&&(this.$form?this.$form.html(""):(this.$form=this.dom("<form>").addClass(this.prefix+"-popup-form"),this.$body.append(this.$form)),this._renderTools(),this._renderData(),this.$form.find("input[type=text],input[type=url],input[type=email]").on("keydown."+this.prefix+"-popup",function(t){if(13===t.which)return t.preventDefault(),!1}.bind(this)))},_renderTools:function(){Object.keys(this.formitems).forEach(function(t){this._renderTool(t,this.formitems[t])}.bind(this))},_renderTool:function(t,e){var e=this.app.create("tool."+e.type,t,e,this,this.data),i=e.getElement();i&&(this.tools[t]=e,this.$form.append(i))},_renderData:function(){if(this.data)for(var t in this.data)void 0!==this.tools[t]&&this.tools[t].setValue(this.data[t])},_renderFooter:function(){this.footerbuttons=0;var t=this.get("footer");if(t)for(var e in this.$footer.html(""),t)t.hasOwnProperty(e)&&!1!==t[e]&&(e=this.app.create("popup.button",e,this,t[e]),this.$footer.append(e.getElement()),this.footerbuttons++)},_findPositionElement:function(t,e){var i;if(Array.isArray(t))for(var s=0;s<t.length&&0===(i=e.find("[data-name="+t[s]+"]")).length;s++);else i=e.find("[data-name="+t+"]");return 0!==i.length?i:0}}),t.add("class","popup.button",{init:function(t,e,i){this.name=t,this.obj=i,this.popup=e,this.$button=this.dom("<button>").addClass(this.prefix+"-form-button"),this.$button.attr("data-name",this.name),this.$button.html(this.lang.parse(this.obj.title)),this.$button.dataset("instance",this),this._has("type")&&this.$button.addClass(this.prefix+"-form-button-"+this.obj.type),this._has("classname")&&this.$button.addClass(this.obj.classname),this._has("fullwidth")&&this.$button.addClass(this.prefix+"-form-button-fullwidth"),this._has("right")&&this.$button.addClass(this.prefix+"-form-button-push-right"),this.$button.on("click."+this.prefix+"-popup-button"+this.uuid,this._catch.bind(this))},getName:function(){return this.name},getElement:function(){return this.$button},invokeCommand:function(){this._invoke()},_has:function(t){return Object.prototype.hasOwnProperty.call(this.obj,t)},_catch:function(t){t.preventDefault(),t.stopPropagation(),this._has("command")?this._invoke(t):this._has("close")&&this.app.popup.close()},_invoke:function(t){this.app.api(this.obj.command,this.popup,this.name,t)}}),t.add("class","popup.header",{init:function(t){this.popup=t,this._build()},setActive:function(t){this.$headerbox.find("."+this.prefix+"-popup-header-item").removeClass("active"),this.$headerbox.find("[data-"+this.prefix+"-name="+t.getName()+"]").addClass("active")},render:function(t){this._reset(),0<this._buildItems(t)&&this._buildClose()},_build:function(){this.$header=this.dom("<div>").addClass(this.prefix+"-popup-header"),this.$headerbox=this.dom("<div>").addClass(this.prefix+"-popup-header-box"),this.$header.append(this.$headerbox),this.popup.getElement().prepend(this.$header)},_buildClose:function(){var t=this.dom("<span>").addClass(this.prefix+"-popup-close");t.one("click",this._catchClose.bind(this)),this.$header.append(t)},_buildItems:function(t){var e,i,s=Object.keys(t).length,a=0,n=0;for(e in t)t.hasOwnProperty(e)&&"object"==typeof t[e]&&(n++,(i=t[e].get("title"))?(a++,this._buildItem(t[e],i,s)):1===n&&1<s&&(a++,this._buildItem(t[e],"## popup.back ##",s)));return a},_buildItem:function(t,e,i){var i=1<i,s=i?this.dom("<a>").attr("href","#"):this.dom("<span>");i&&(s.dataset("stack",t),s.addClass(this.prefix+"-popup-header-item-link"),s.on("click",this._catchStack.bind(this))),s.attr("data-"+this.prefix+"-name",t.getName()),s.addClass(this.prefix+"-popup-header-item"),s.html(this.lang.parse(e)),this.$headerbox.append(s)},_reset:function(){this.$headerbox.html(""),this.$header.find("."+this.prefix+"-popup-close").remove()},_catchStack:function(t){t.preventDefault(),t.stopPropagation();var t=this.dom(t.target).dataget("stack"),e=this.app.popup.getStack();e.isCollapsed()&&this.app.popup.removeStack(e),t.open()},_catchClose:function(t){t.preventDefault(),t.stopPropagation(),this.popup.close()}}),t.add("module","editor",{start:function(){this._buildEditor(),this._buildBlurClass(),this._buildOptions(),this._buildContent()},stop:function(){this.app.$element.show()},load:function(){this._setFocusOnStart()},build:function(){this.app.blocks.build(),this.app.embed.build(),this.app.image.observeStates(),this.app.parser.buildPredefinedClasses(),this.app.broadcast("editor.build")},isEditor:function(t){return this.dom(t).get()===this.$editor.get()},isLayout:function(t){return this.isEditor(t)},isTextarea:function(){return!1===this.opts.content},isFocus:function(){return this.app.container.isFocus()},isAllSelected:function(){return this._classSelect("has")},isEmpty:function(t){return!(1<this.app.blocks.getFirstLevel().length)&&this.app.content.isEmptyHtml(this.$editor.html(),t)},isPopupSelection:function(){return!this.app.blocks.isMeta()},isBlocksSelection:function(){return this.app.blocks.isMeta()||this.app.blocks.is()||this.app.editor.isAllSelected()},addButton:function(t,e){this.opts.buttonsObj[t]=e,this.opts.buttons.editor.push(t)},selectAll:function(){var t,e;this.isAllSelected()||(this._classSelect("add"),this.app.block.unset(),this.app.blocks.unset(),this.app.toolbar.build(),this.app.control.close(),this.app.context.close(),e=this.app.blocks.getLast(),t=!1,e&&"layer"===e.getType()&&(t=e.getBlock()).attr("contenteditable",!0),1===(e=this.app.blocks.getFirstLevel()).length?(this.app.editor.setFocus("start"),this.app.selection.select(e.first().get())):this.app.selection.select(),this.app.broadcast("editor.select"),t&&setTimeout(function(){t.attr("contenteditable",!1)},0))},unselectAll:function(){this.isAllSelected()&&(this.unsetSelectAll(),this.app.block.unset(),this.app.blocks.unset(),this.app.broadcast("editor.unselect"))},unsetSelectAll:function(){this._classSelect("remove")},observeBlocks:function(t){this.blocks=[];var e,i,t=this.app.blocks.getSelectedBlock(t),s=(this.app.editor.setFocus(),this.app.blocks.getSelectedBlocks());1===s.length?this.app.block.set(t):this.app.selection.isAll()?(e=this.app.blocks.getBlocks(),i=this.app.selection.getNodes({type:"blocks-first"}),e.length===i.length?this.app.editor.selectAll():this.blocksSelection(s)):1<s.length?this.blocksSelection(s):this.app.block.set(t)},blocksSelection:function(t){this.app.block.unset(),this.app.blocks.set(t),this.app.toolbar.build()},insertContent:function(t){this.app.insertion.insertContent(t)},setContent:function(t){this.app.insertion.setContent(t)},setEmpty:function(){this.app.insertion.setContent({html:""})},setWinFocus:function(){},setFocus:function(t){if(t){var t=!0===t?"start":t,e="start"===t?this.app.blocks.getFirst():this.app.blocks.getLast();this.app.block.set(e,t)}else if(!this.isFocus()){for(var i=0;i<h.instances.length;i++)h.instances[i]!==this.app&&h.instances[i].editor.setBlur();this.app.container.setFocus(),this.app.broadcast("editor.focus")}},setBlur:function(t){this.isFocus()&&this.$editor.get&&(this.app.broadcast("editor.before.blur",{e:t}).isStopped()?t&&t.preventDefault():(this.app.container.setBlur(),this.app.selection.removeAllRanges(),this.app.source.is()||(this.app.block.unset(),this.app.blocks.unset(),this.app.popup.close(!1),this.app.context.close(),this.app.control.close(),this.app.toolbar.build()),this.app.broadcast("editor.blur",{e:t})))},getContent:function(t){var e="",e=this.app.source.is()?this.app.source.getContent():(e=this._getContent(),t?this.app.tidy.parse(e):e);return e=this.app.content.decodeHref(e)},getSelection:function(){var t,e=this.getWinNode().getSelection();return 0<e.rangeCount&&(t=e.anchorNode,0!==this.dom(t).closest("."+this.prefix+"-container-"+this.uuid).length)&&e},getWinNode:function(){return this.app.$win.get()},getDocNode:function(){return this.app.$doc.get()},getEditor:function(){return this.$editor},getLayout:function(){return this.getEditor()},getWidth:function(){var t=this.getEditor(),e=parseInt(t.css("padding-left")),i=parseInt(t.css("padding-right"));return t.width()-e-i},getRect:function(){var t=this.$editor.offset(),e=this.$editor.width(),i=this.$editor.height(),s=Math.round(t.top),t=Math.round(t.left);return{top:s,left:t,bottom:s+i,right:t+e,width:e,height:i}},getButtonsFromArr:function(t){var e={};if(!Array.isArray(t)&&"object"==typeof t)return t;if(t)for(var i=h.extend(!0,{},this.opts.buttonsObj),s=0;s<t.length;s++){var a=t[s];void 0!==i[a]&&(e[a]=i[a])}return e},observeUI:function(){this.app.toolbar.observe(),this.app.context.observe()},enableUI:function(){this.app.toolbar.enable(),this.app.toolbar.enableSticky()},disableUI:function(){this.app.popup.close(),this.app.control.close(),this.app.context.close(),this.app.toolbar.disable(),this.app.toolbar.disableSticky()},_buildEditor:function(){this.app.$element.hide(),this.$editor=this.dom("<div>"),this.$editor.addClass(this.prefix+"-editor "+this.prefix+"-reset "+this.prefix+"-"+this.opts.editor.classname),this.$editor.attr("contenteditable",!0);var t=this.opts.paddingNormal;(this.opts.control||this.opts.reorder)&&(t=this.opts.paddingControl),this.$editor.css("padding",t),this.app.container.get("editor").append(this.$editor)},_buildBlurClass:function(){this.app.container.setBlur()},_buildOptions:function(){var t=this.$editor,e=this.opts.editor;this.opts.code=this.opts.pre,t.attr("dir",e.direction),e.minHeight&&t.css("min-height",e.minHeight),e.maxHeight&&t.css({"max-height":e.maxHeight,overflow:"auto"}),e.notranslate&&t.addClass("notranslate"),e.spellcheck||t.attr("spellcheck",!1),e.grammarly||t.attr("data-gramm_editor",!1)},_buildContent:function(){var t=this._getContentValue(),t=this.app.broadcastHtml("editor.before.load",t),t=this.app.parser.parse(t,!0,!0),t=(this.$editor.html(t.get().childNodes),this.app.parser.unparse(this.$editor.html()));this.app.$element.val(t),this._load()},_buildDraggable:function(){this.app.$body.find("[data-"+this.prefix+"-drop-id]").each(function(t){t.attr("draggable",!0),t.on("dragstart",function(t){var e=this.dom(t.target).attr("data-"+this.prefix+"-drop-id");t.dataTransfer.setData("item",e)}.bind(this))}.bind(this))},_load:function(){this.app.blocks.build(),this.app.event.build(),this.app.observer.build(),this.app.embed.build(),this.app.sync.build(),this.app.image.observeStates(),this._buildDraggable(),this.app.broadcast("editor.load")},_getContent:function(){var t=this.$editor.html();return this.app.parser.unparse(t)},_getContentValue:function(){return this.opts.content||this.app.$element.val()},_setFocusOnStart:function(){this.opts.editor.focus&&(this.setFocus(),this.setFocus(this.opts.editor.focus))},_classSelect:function(t){return this.$editor[t+"Class"](this.prefix+"-select-all")}}),t.add("module","parser",{build:function(t){return this.$layout=this.dom("<div>"),this.$layout.html(t),this.$layout.find("[data-"+this.prefix+"-type]").each(this._build.bind(this)),this.$layout},buildPredefinedClasses:function(t){var e,i,s;this.opts.classes&&(t=t||this.app.editor.getEditor(),e=this.app.content,i=!(s=!0),(s=void 0!==this.opts.classes.blocks&&(i=!0,void 0===this.opts.classes.tags)?!1:s)&&t.find(e.getPredefinedTags().join(",")).each(e.addPredefinedTagClass.bind(this)),i)&&(s=e.getPredefinedBlocks(),s="["+(i="data-"+this.prefix+"-type")+"="+s.join("],["+i+"=")+"]",t.find(s).each(e.addPredefinedBlockClass.bind(this)))},parse:function(t,e,i){return t=t.trim(),t=this.app.broadcastHtml("editor.before.parse",t),t=this.app.content.isEmptyHtml(t)?this.app.block.createHtml():(t=this._clean(t,i),this._parse(t)),t=this.app.broadcastHtml("editor.parse",t),!1!==e?this.build(t):t},parseLine:function(t,e){return t=" "===t?" ":(t=(t=this.app.broadcastHtml("editor.before.parse",t)).replace(/\r?\n/g,"<br>"),t=this.app.content.encodeCode(t),t=this.app.content.sanitize(t),t=this.app.content.removeEmptySpans(t),t=this.app.content.addHttps(t),this.app.broadcastHtml("editor.parse",t)),!1!==e?this.build(t):t},unparse:function(t,e){var i={},s=this.app.content;return t=t.trim(),t=this.app.broadcastHtml("editor.before.unparse",t),s.isEmptyHtml(t)?"":(t=this._revertForms(t),t=this._revertFrames(t),t=s.store(t,"embed",i,0),t=s.addNofollow(t),t=s.removeMarkers(t),t=this.app.utils.removeInvisibleChars(t),t=s.recacheStyle(t),t=s.restore(t,"embed",i),t=s.removeEmptyAttrs(t,["style","class","rel","alt","title"]),t=this._unparseAllTags(t),t=this._unparseDataType(t,e),t=(t=s.removeEmptyAttrs(t,["style","class","rel","alt","title"])).replace(/"(.*?)"/gi,"'$1'"),t=this.app.utils.replaceRgbToHex(t),this.opts.classes&&(t=this.app.utils.wrap(t,this.buildPredefinedClasses.bind(this))),this.app.broadcastHtml("editor.unparse",t="<p></p>"===t?"":t))},_build:function(t){var e=t.attr("data-"+this.prefix+"-type");this.app.create("block."+e,t)},_clean:function(t,e){var i={},s=[],a=this.app.content;return t=(t=a.storeComments(t,s)).replace(/¤t/gi,"¤t"),e&&this.app.editor.isTextarea()&&(t=a.encodeCode(t)),t=a.sanitize(t),t=this._convertForms(t),t=this._convertFrames(t),t=a.store(t,"embed",i,0),t=a.removeTags(t,this.opts.tags.denied),t=a.removeDoctype(t),t=a.removeTagsWithContent(t,["script","style"]),t=a.removeEmptySpans(t),t=a.addHttps(t),t=a.removeBlockTagsInside(t,["th","td","li","dt","dd","address"]),t=a.cacheStyle(t),t=a.restore(t,"embed",i),t=a.restoreComments(t,s),this.opts.clean.comments&&(t=a.removeComments(t)),t=a.isEmptyHtml(t)?this.app.block.createHtml():a.paragraphize(t)},_parse:function(t){return this.app.utils.wrap(t,function(t){for(var e=this.app.element.getBlocks(t),i=0;i<e.length;i++)this._parseHtml(e[i]);this.buildPredefinedClasses(t)}.bind(this))},_parseHtml:function(t){var e=t.tagName.toLowerCase(),t=this.dom(t),i=this._parseType(t,e);i&&(t.attr("data-"+this.prefix+"-type",i),"image"===i&&e!==this.opts.image.tag&&(t=this.app.element.replaceToTag(t,this.opts.image.tag,!0)),"layer"===i)&&this._parseNested(t)},_parseNested:function(t){for(var e=this.app.element.getBlocks(t),i=0;i<e.length;i++)this._parseHtml(e[i])},_parseType:function(t,e){t=t.attr("data-"+this.prefix+"-type")?t.attr("data-"+this.prefix+"-type"):this._parseTypeByTag(t,e);return t},_parseTypeByTag:function(t,e){var i;switch(e){case"p":i="paragraph",this._isImageBlock(t,"p")&&(i="image");break;case"figure":i="embed",this._isImageBlock(t,"figure")?i="image":this._hasChild(t,"pre")?i="pre":this._hasChild(t,"blockquote")&&(i="quote");break;case"div":i="layer",this._isImageBlock(t,"div")&&(i="image");break;case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":i="heading";break;case"blockquote":i="quote";break;case"table":i="table";break;case"pre":i="pre";break;case"hr":i="line";break;case"dl":i="dlist";break;case"address":i="address";break;case"ul":case"ol":i="list";break;default:i="layer"}return i},_isImageBlock:function(t,e){var i=t.find("img");if(0!==i.length&&("div"!==e||0===i.closest("figure").length)){var s=i,i=i.parent(),a=0!==i.length&&i.get().tagName;if(!a||"A"!==a&&"SPAN"!==a){if(a&&i.get()!==t.get())return}else s=i;if(0===s.prevElement().length&&("figure"===e||0===s.nextElement().length))return!0}},_hasChild:function(t,e){if("pre"===e){if(0!==t.find("pre").length)return!0}else if("blockquote"===e){e=t.find("blockquote");if(0===t.find("script").length&&0!==e.length)return!0}},_unparseAllTags:function(t){return this.app.utils.wrap(t,function(t){t.find("*").removeAttr("contenteditable data-gramm_editor"),this.opts.image.states||t.find("img").removeAttr("data-image")}.bind(this))},_unparseDataType:function(t,i){return this.app.utils.wrap(t,function(t){var e=t.find("[data-"+this.prefix+"-type]");!0!==i&&e.removeClass(this.prefix+"-block-state"),e.removeAttr("tabindex data-"+this.prefix+"-parsed data-"+this.prefix+"-first-level"),e.removeClass(this.prefix+"-block-focus "+this.prefix+"-block-multiple-focus "+this.prefix+"-block-multiple-hover "+this.prefix+"-editable-pause"),e.removeClass(this.prefix+"-nowrap"),e.each(this._unparseByType.bind(this)),e.removeAttr("data-"+this.prefix+"-type"),t.find("figcaption").removeAttr("data-"+this.prefix+"-type data-placeholder").each(this.app.content._removeEmptyTag.bind(this))}.bind(this))},_unparseByType:function(t){var e=t.attr("data-"+this.prefix+"-type");"embed"===e?this._unparseEmbed(t):"list"===e&&this._unparseList(t)},_unparseEmbed:function(t){var e,i=decodeURI(t.attr("data-embed-code")),s=t.find("."+this.opts.embed.responsive.replace(/ +/g,".")),a=t.find("figcaption");0!==a.length&&(e=a.clone(),a.remove()),(0===s.length?t:s).html(i),e&&t.append(e),t.removeAttr("data-embed-code data-arx-type"),0===t.get().attributes.length&&0===t.find("figcaption").length&&0===t.find("div").length&&t.unwrap()},_unparseList:function(t){this.app.content.unfixListMargin(t)},_convertFrames:function(t){return this.app.utils.wrap(t,function(t){t.find("iframe").each(this._convertFrame.bind(this))}.bind(this))},_convertFrame:function(t){0===t.closest("figure").length&&(t.wrap("<figure>"),t.parent().addClass(this.prefix+"-figure-iframe"))},_convertForms:function(t){return this.app.utils.wrap(t,function(t){t.find("form").each(this._convertForm.bind(this))}.bind(this))},_convertForm:function(t){this.app.element.replaceToTag(t,"div").addClass(this.prefix+"-div-form")},_revertFrames:function(t){return this.app.utils.wrap(t,function(t){t.find("."+this.prefix+"-figure-iframe").each(this._revertFrame.bind(this))}.bind(this))},_revertFrame:function(t){0!==t.find("figcaption").length?t.removeClass(this.prefix+"-figure-iframe"):t.unwrap()},_revertForms:function(t){return this.app.utils.wrap(t,function(t){t.find("."+this.prefix+"-div-form").each(this._revertForm.bind(this))}.bind(this))},_revertForm:function(t){this.app.element.replaceToTag(t,"form").removeClass(this.prefix+"-div-form")}}),t.add("module","blocks",{init:function(){this.selected=[],this.focusclass=this.prefix+"-block-meta-focus"},start:function(){this.$editor=this.app.editor.getEditor()},build:function(){this._buildFirstLevel()},is:function(){return 0<this.selected.length},isMeta:function(){return 0<this.getSelected().length},set:function(t){this.selected=t},setMeta:function(t){t=t.closest("[data-"+this.prefix+"-first-level]"),this.app.block.unset(),this._classFocus(t,"add"),this.app.toolbar.build(),setTimeout(function(){this.app.selection.removeAllRanges()}.bind(this),0)},unset:function(){this._classFocus(this.getFirstLevel(),"remove"),this.selected=[]},getBlocks:function(){return this.$editor.find("[data-"+this.prefix+"-type]")},getFirstLevel:function(){return this.$editor.find("[data-"+this.prefix+"-first-level]")},getFirst:function(){return this.getBlocks().first().dataget("instance")},getLast:function(){return this.getBlocks().last().dataget("instance")},getFirstSelected:function(){return this.getSelected().first().dataget("instance")},getLastSelected:function(){return this.getSelected().last().dataget("instance")},getSelected:function(){return this.$editor.find("."+this.focusclass)},getSelectedBlocks:function(t){var e=this.app.selection.getNodes({type:"blocks"});if("editable"===t){for(var i=[],s=0;s<e.length;s++){var a=this.dom(e[s]).dataget("instance").getType();-1!==["paragraph","heading","list","address"].indexOf(a)&&i.push(e[s])}e=i}return e},getSelectedBlock:function(t){var e=this.app.selection.getDataBlock();return e=t&&0===e.length?this.app.element.getDataBlock(t.target):e},getFirstSelectedBlock:function(){return 0<this.selected.length&&this.selected[0]},getLastSelectedBlock:function(){return 0<this.selected.length&&this.selected[this.selected.length-1]},removeSelected:function(t){var e,i=this.getLastSelected();!1!==t&&i&&(e=i.getNext()),this.getSelected().each(this._removeSelectedBlock.bind(this)),e&&this.app.block.set(e,"start")},_buildFirstLevel:function(){var t="data-"+this.prefix+"-first-level",e=this.app.editor.getEditor();e.find("["+t+"]").removeAttr(t),e.children("[data-"+this.prefix+"-type]").attr(t,!0)},_removeSelectedBlock:function(t){t.dataget("instance").remove({traverse:!1})},_classFocus:function(t,e){return t[e+"Class"](this.focusclass)}}),t.add("module","event",{init:function(){this.trigger=!0,this.imageDrag=!1,this.dragoverEvent=!1,this.isPopupMouseUp=!1,this.isEditorMouseUp=!1,this.isBlockMouseUp=!1,this.pasteEvent=!1,this.events={editor:["click","touchstart","mouseover","mouseup","mousedown","keyup","drop","dragstart","dragover","dragleave"],doc:["keydown","mousedown","mouseup","click","paste","cut","copy"],win:["focus"]}},build:function(){this.$editor=this.app.editor.getEditor(),this._buildPreventLinks(),this._buildEvents()},run:function(){this._buildEvents()},pause:function(){this._pauseEvents()},stop:function(){this._pauseEvents()},onmouseover:function(t){this.app.broadcast("editor.mouseover",{e:t})},ontouchstart:function(t){this.app.state.add(t)},onclick:function(t){this.app.broadcast("editor.click",{e:t}),this._isEditorClick(t)&&!this.isBlockMouseUp&&this._setByClick(t),3===t.detail&&setTimeout(function(){this._setBlockFocus(t,!0)}.bind(this),0)},onmouseup:function(t){!this.trigger||!this.isEditorMouseUp&&this._isEditorClick(t)||setTimeout(function(){this._observeBlockFocus(t),this.isEditorMouseUp=!1,this.app.broadcast("editor.mouseup",{e:t})}.bind(this),0)},onmousedown:function(t){this.app.placeholder.handleClick(t),this._isEditorClick(t)?this.isBlockMouseUp=!1:(this.isBlockMouseUp=!0,this._setCaretInline(t),this.isEditorMouseUp=!0,this.app.state.add(t),this.app.broadcast("editor.mousedown",{e:t}))},onkeyup:function(t){if(this.app.broadcast("editor.keyup",this._buildEventKeysObj(t)).isStopped())return t.preventDefault();var e,i=t.which;i!==this.app.keycodes.DOWN&&i!==this.app.keycodes.UP||0===(e=this.app.selection.getDataBlock()).length||this.app.block.is(e)||this.app.block.set(e),i===this.app.keycodes.BACKSPACE&&this.app.editor.isEmpty()&&this.app.editor.setEmpty(),i!==this.app.keycodes.TAB||this.app.block.is()||this._setBlock(t)},ondrop:function(t){var e,i,s;return!this.opts.editor.drop||this.app.broadcast("editor.drop",{e:t}).isStopped()?t.preventDefault():(""!==(s=(e=t.dataTransfer).getData("item"))?(t.preventDefault(),(i=this.opts.draggable&&void 0!==this.opts.draggable[s]?this.opts.draggable[s]:(i=this.dom("[data-"+this.prefix+"-drop-item="+s+"]").html()).trim())&&this._drop(t,i,"after",!1)):this.opts.image&&this.opts.image.upload&&null!==e.files&&0<e.files.length?(t.preventDefault(),this.app.image.drop(t,e)):(i=""===(i=e.getData("text/html")).trim()?e.getData("Text"):i,s=this._drop(t,i),this.imageDrag&&0!==s.instances.length&&s.instances[0].change(this.imageDrag,!1)),this._removeDragPlaceholder(),this.imageDrag=!1,void(this.app.observer.trigger=!0))},ondragstart:function(t){var e=this._getBlock(t.target);0!==e.length&&"image"===this.app.element.getType(e)&&(this.imageDrag=e.dataget("instance")),this.app.broadcast("editor.dragstart",{e:t})},ondragover:function(t){var e,i;t.preventDefault(),this.dragoverEvent=!0,this.app.observer.trigger=!1,this._removeDragPlaceholder(),-1!==t.dataTransfer.types.indexOf("item")&&0!==(e=this._getBlockFirst(t.target)).length&&(i=this.dom("<div>").addClass(this.prefix+"-draggable-placeholder"),e.after(i)),this.app.broadcast("editor.dragover",{e:t})},ondragleave:function(t){t.preventDefault(),this.dragoverEvent=!0,this.app.observer.trigger=!0,this._removeDragPlaceholder(),this.app.broadcast("editor.dragleave",{e:t})},onwinfocus:function(){var t=this.app.block.get();t&&!t.isEditable()&&setTimeout(function(){this.app.selection.removeAllRanges()}.bind(this),0)},ondocpaste:function(t){this._isFocusEditor()&&this._paste(t)},ondoccopy:function(t){this._isFocusEditor()&&this._copy(t)},ondoccut:function(t){this._isFocusEditor()&&this._cut(t)},ondockeydown:function(t){if(this.app.popup.isOpen()){if(this._isEnter(t)){var e=this.app.popup.getStack();if(!1!==e.hasForm()&&"TEXTAREA"!==t.target.tagName)return t.preventDefault(),void e.getFooterPrimary().dataget("instance").invokeCommand()}this._isEsc(t)&&this.app.popup.close(!1)}if(!this._isOutsideEditor(t)&&this.app.editor.isFocus()&&!this.app.popup.isOpen()&&!this.app.source.is()){e=this.app.broadcast("editor.keydown",this._buildEventKeysObj(t));if(e.isStopped())return t.preventDefault();!1===this.opts.editor.enterKey&&13===t.which?t.preventDefault():this.app.state.listen(t)||(this._isEsc(t)&&(this.app.block.unset(),this.app.selection.removeAllRanges()),this.app.shortcut.handle(t))||this.app.input.handle(e)}},ondocmousedown:function(t){this.isPopupMouseUp=0!==this.dom(t.target).closest("."+this.prefix+"-popup-"+this.uuid).length,this.app.broadcast("editor.docmousedown",{e:t})},ondocmouseup:function(t){this.app.selection.is()&&!this.app.editor.isFocus()&&this._observeBlockFocus(t),this.app.broadcast("editor.docmouseup",{e:t})},ondocclick:function(t){if(!this.app.popup.isOpen()||!this._isEditorContainer(t))return!this._isOutsideEditor(t)||!1===this.trigger||void(this.isEditorMouseUp?this.isEditorMouseUp=!1:(this.app.popup.isOpen()?!1===this.isPopupMouseUp&&this.app.popup.close(!1):this.app.editor.setBlur(t),this.app.broadcast("editor.docclick",{e:t})));this.app.popup.close(!1)},_buildPreventLinks:function(){var t=this.prefix+"-prevent-events";this.$editor.on("click."+t+" dblclick."+t,this._preventLinks.bind(this))},_buildEventKeysObj:function(t){var e=t.which,i=[this.app.keycodes.UP,this.app.keycodes.DOWN,this.app.keycodes.LEFT,this.app.keycodes.RIGHT],s=!t.ctrlKey&&!t.metaKey&&(48<=e&&e<=57||65<=e&&e<=90),a=this.app.keycodes;return{e:t,key:e,ctrl:t.ctrlKey||t.metaKey,shift:t.shiftKey,alt:t.altKey,select:(t.ctrlKey||t.metaKey)&&!t.altKey&&65===e,enter:e===a.ENTER,space:e===a.SPACE,esc:e===a.ESC,tab:!(e!==a.TAB||t.shiftKey||t.altKey||t.ctrlKey||t.metaKey),delete:e===a.DELETE,backspace:e===a.BACKSPACE,alpha:s,arrow:-1!==i.indexOf(e),left:e===a.LEFT,right:e===a.RIGHT,up:e===a.UP,down:e===a.DOWN,"left-right":e===a.LEFT||e===a.RIGHT,"up-left":e===a.UP||e===a.LEFT,"down-right":e===a.DOWN||e===a.RIGHT}},_buildEvents:function(){var t=this.prefix+"-events";this._buildTargetEvents(this.$editor,this.events.editor,t,""),this._buildTargetEvents(this.app.$doc,this.events.doc,t,"doc"),this._buildTargetEvents(this.app.$win,this.events.win,t,"win")},_buildTargetEvents:function(t,e,i,s){for(var a=0;a<e.length;a++)t.on(e[a]+"."+i,this["on"+s+e[a]].bind(this))},_pauseEvents:function(){var t=this.prefix+"-events";this.$editor.off("."+t),this.app.$doc.off("."+t),this.app.$win.off("."+t)},_preventLinks:function(t){0!==this.dom(t.target).closest("a").length&&t.preventDefault()},_isEditorClick:function(t){if(this.app.editor.isEditor(t.target))return t.preventDefault(),!0},_isEsc:function(t){return t.which===this.app.keycodes.ESC},_isEnter:function(t){return t.which===this.app.keycodes.ENTER},_isEditorContainer:function(t){return 0!==this.dom(t.target).closest("."+this.prefix+"-container-"+this.uuid).length},_isOutsideEditor:function(t){return 0===this.dom(t.target).closest("."+this.prefix+["-container-","-popup-","-toolbar-","-control-"].join(this.uuid+",."+this.prefix)+this.uuid).length},_isFocusEditor:function(){return!this.app.popup.isOpen()&&!this.app.source.is()&&(this.app.block.is()||this.app.blocks.is()||this.app.blocks.isMeta()||this.app.editor.isAllSelected())},_removeDragPlaceholder:function(){this.app.editor.getEditor().find("."+this.prefix+"-draggable-placeholder").remove()},_getBlock:function(t){return this.dom(t).closest("[data-"+this.prefix+"-type]")},_getBlockFirst:function(t){return this.dom(t).closest("[data-"+this.prefix+"-first-level]")},_observeBlockFocus:function(t){this.app.selection.isCollapsed()?this._setBlockFocus(t):this.app.editor.observeBlocks(t),this.app.toolbar.observe(),this.app.state.add(t)},_setByClick:function(a){var t=this.app.blocks.getFirstLevel(),e=[],n=(t.each(function(t){t=t.get().getBoundingClientRect();e.push([t.x,t.y,t.y+t.height])}),[]),o=!1,i=(e.forEach(function(t,e){var i=parseInt(a.clientY),s=parseInt(a.clientX);t[1]<i&&i<t[2]?o=e:(e=Math.hypot(t[0]-s,t[1]-i),n.push(parseInt(e)))}),!1!==o?o:n.indexOf(Math.min.apply(Math,n))),t=t.eq(i);this.app.block.set(t.dataget("instance"),"start"),this.app.editor.setFocus()},_setBlock:function(t){this.app.editor.setFocus();var t=t?this._getBlock(t.target):this.app.selection.getDataBlock(),e=!1;0===t.length&&(t=this.app.blocks.getFirst(),e="start"),this.app.block.set(t,e)},_setBlockFocus:function(t,e){t=this._getBlock(t.target);0!==t.length&&(this.app.editor.setFocus(),e&&this.app.selection.select(t),this.app.block.set(t))},_setCaretInline:function(e){var t=this.app.block.get(),i=!1;t&&t.isEditable()&&(this.app.element.isEmptyOrImageInline(e.target)?this.app.caret.set(e.target,"after"):this.app.selection.isCollapsed()&&"CODE"===e.target.tagName&&(i=!0,setTimeout(function(){var t=this.app.selection.getElement();t&&i&&"CODE"!==t.tagName&&(this.app.caret.set(e.target,"start"),i=!1)}.bind(this),1)))},_drop:function(t,e,i,s){var a=0===(a=this.app.element["after"===i?"getFirstLevel":"getDataBlock"](t.target)).length?this.app.blocks.getFirst():a,a=(this.app.block.set(a),i||this.app.insertion.insertPoint(t),!0),t=!0,n=this.app.block.get(),o=this.app.editor.isAllSelected();if(n&&"pre"===n.getType()&&!o&&(e=this.app.content.getTextFromHtml(e,{nl:!(t=a=!1),trimlines:!1})),!1===s&&(a=!1,e=this.app.autoparse.parse(e)),""!==e)return e=a?this.app.autoparse.parse(e):e,this.app.insertion.insertContent({html:e,clean:a,parse:t,position:i})},_paste:function(t){t.preventDefault();var e,i,s,a,n=t.clipboardData;this.opts.image&&this.opts.image.upload&&this.app.image.insertFromClipboard(n)||(e=n.getData("URL"),a=this.app.clipboard.getContent(n),this.pasteEvent=!0,(t=this.app.broadcast("editor.before.paste",{e:t,html:a})).isStopped()||(a=t.get("html"),a=e&&""!==e?e:a,t=this.app.block.get(),i=e=!0,s=this.app.editor.isAllSelected(),this.opts.paste.plaintext?a=this.app.content.getTextFromHtml(a,{br:!(i=e=!1)}):t&&"pre"===t.getType()&&!s?a=this.app.content.getTextFromHtml(a,{nl:!(i=e=!1),trimlines:!1}):this.opts.paste.clean||(e=!1),a=this.opts.paste.links?a:this.app.content.removeTags(a,["a"]),""!==(a=this.opts.paste.images?a:this.app.content.removeTags(a,["img"]))&&((t=n.getData("text/rtf"))&&(s=this._findLocalImages(a),a=this._replaceLocalImages(a,s,this._extractImagesFromRtf(t))),a=e?this.app.autoparse.parse(a):a,n=this.app.insertion.insertContent({html:a,clean:e,parse:i}),this.opts.image.upload&&this.app.image.parseInserted(n),this.app.placeholder.toggle(),this.app.broadcast("editor.paste",n))),this.pasteEvent=!1)},_copy:function(t){this._action(t,"copy")},_cut:function(t){this._action(t,"cut")},_action:function(t,e){var i={},s=this.app.block.get();s&&s.isEditable()&&this.app.selection.isCollapsed()||(this.app.blocks.isMeta()&&(s=this.app.blocks.getLastSelected()),t.preventDefault(),this.app.editor.isAllSelected()?i={html:this.app.editor.getLayout().html(),remove:"all"}:this.app.blocks.is()?i={html:this.app.selection.getHtml(),remove:"content"}:s&&s.isEditable()?i=this._copyFromEditable(e,s):s&&(i=this._copyFromNonEditable(e,s)),(s=this.app.broadcast("editor.before."+e,{e:t,html:i.html})).isStopped())||("cut"===e&&this._cutDeleteContent(i),i=s.get("html"),i=this.app.clipboard.setContent(t,i),this.app.broadcastHtml("editor."+e,i))},_cutDeleteContent:function(t){"instance"===t.remove?(t.instance.remove(!0),this.app.control.close()):"all"===t.remove?this.app.editor.setEmpty():!1!==t.remove&&this.app.selection.deleteContents()},_copyFromEditable:function(t,e){var i=e.getType(),s=this.app.selection.getHtml(),a="content";return"figcaption"===i||"cell"===i||"paragraph"===i?a="content":e.isAllSelected()?(s=e.getOuterHtml(),a="instance"):"list"===i&&(i=e.getTag(),-1!==(s=this.app.selection.getHtml()).search(/<li/gi))&&(s="<"+i+">"+(s=-1===s.search(/^<li/g)?"<li>"+s+"</li>":s)+"</"+i+">"),{html:s,remove:a,instance:e}},_copyFromNonEditable:function(t,e){var i=!1;return{html:e.getOuterHtml(),remove:i="cut"!==t||e.isSecondLevel()?i:"instance",instance:e}},_findLocalImages:function(t){var e=[];return this.app.utils.wrap(t,function(t){t.find("img").each(function(t){-1!==t.attr("src").search(/^file:\/\//)&&e.push(t.attr("src"))})}),e},_extractImagesFromRtf:function(t){if(!t)return[];var e=/{\\pict[\s\S]+?\\bliptag-?\d+(\\blipupi-?\d+)?({\\\*\\blipuid\s?[\da-fA-F]+)?[\s}]*?/,i=new RegExp("(?:("+e.source+"))([\\da-fA-F\\s]+)\\}","g"),s=t.match(i);if(!s)return[];for(var a=[],n=0;n<s.length;n++){var o=!1;-1!==s[n].indexOf("\\pngblip")?o="image/png":-1!==s[n].indexOf("\\jpegblip")&&(o="image/jpeg"),o&&a.push({hex:s[n].replace(e,"").replace(/[^\da-fA-F]/g,""),type:o})}return a},_convertHexToBase64:function(t){return btoa(t.match(/\w{2}/g).map(function(t){return String.fromCharCode(parseInt(t,16))}).join(""))},_replaceLocalImages:function(t,e,i){if(e.length===i.length)for(var s=0;s<e.length;s++){var a="data:"+i[s].type+";base64,"+this._convertHexToBase64(i[s].hex);t=t.replace(new RegExp('src="'+e[s]+'"',"g"),'src="'+a+'"')}return t}}),t.add("module","block",{init:function(){this.instance=!1,this.$block=!1},create:function(t){var e=this.app.create("block.paragraph");return t&&e.getBlock().html(t),e},createHtml:function(t){return this.create(t).getOuterHtml()},is:function(t){return t?this._isBlockActive(t):this.get()},isType:function(t){if(this.is())return this.get().isType(t)},get:function(){return this.instance},set:function(t,e,i){t&&(t.isBlock&&(t=(t.isNested()?e&&"end"===e?t.getLast():t.getFirst():t).getBlock()),this.app.blocks.unset(),this.app.editor.unsetSelectAll(),!0!==i&&this._isBlockActive(t)||(this.unset(),this.instance=this._getInstance(t),this.$block=this.instance.getBlock(),this.$block.addClass(this.prefix+"-block-focus"),this._setCaret(e),this.app.toolbar.build(),this.app.control.build(),this.app.broadcast("block.set")))},unset:function(){this.instance&&(this.$block.removeClass(this.prefix+"-block-focus"),this.instance=!1,this.$block=!1,this.app.popup.close(),this.app.control.close(),this.app.context.close(),this.app.broadcast("block.unset"))},observe:function(t,e){if(-1!==["line","quote","pre"].indexOf(e)&&!this.opts[e])return!1},format:function(t){this.app.format.set(t)},add:function(t){this.app.popup.close();var e,i,s,a=this.get(),n=(this.app.blocks.isMeta()&&(a=this.app.blocks.getLastSelected()),t.type&&"image"===t.type&&a&&"cell"===a.getType()&&(a=a.getParent("table")),"after");if(!t||!t.template)return e=t.instance||this.app.create("block."+t.name,t.source),a?(a=a.isSecondLevel()?a.getFirstLevel():a).isEditable()&&(n=t&&t.position?t.position:this.app.insertion.detectPosition(a.getBlock(),!1)):n="top"===this.opts.editor.add?(a=this.app.blocks.getFirst(),"before"):(a=this.app.blocks.getLast(),"after"),i=!0,a&&(s=a.getType(),"paragraph"===t.name)&&-1!==["paragraph","heading"].indexOf(s)&&(i=!1),a.insert({instance:e,caret:t.caret||"end",position:n,remove:i,type:"add"}),e;a||(n=this.opts.editor.add),this.app.insertion.insertContent({html:t.template,position:n})},change:function(t){var e=this._getCurrentInstance();e&&e.change(t)},duplicate:function(){var t,e;if(this.app.popup.close(),this.is())return t=(e=(e=this.get()).isSecondLevel()?e.getFirstLevel():e).duplicate(),e=e.insert({instance:t,caret:"start",type:"duplicate"}),this.app.broadcast("block.duplicate",{instance:e}),e},remove:function(t){this.app.popup.close();var e,i,s,a,n=this.get();n&&("image"===(i=(n=n.isSecondLevel()?n.getFirstLevel():n).getType())&&(e={url:n.getSrc(),id:n.getId()}),!t||void 0===t.tarverse||!1!==t.tarverse?(t=n.getNext(),s=n.getPrev(),a=n.getParent("layer"),n.remove(),a&&a.isEmpty(!0)&&(t=a.getNext(),s=a.getPrev(),a.remove()),t?this.app.block.set(t,"start"):s?this.app.block.set(s,"end"):this.unset()):(this.unset(),n.remove()),"image"===i&&this.app.broadcast("image.remove",e),this.app.broadcast("block.remove",{type:i}),this.app.editor.isEmpty())&&this.app.editor.setEmpty()},moveUp:function(){var t=this._getCurrentInstance();t&&(t=t.isSecondLevel()?t.getFirstLevel():t).moveUp()},moveDown:function(){var t=this._getCurrentInstance();t&&(t=t.isSecondLevel()?t.getFirstLevel():t).moveDown()},getData:function(){if(this.is())return this.get().getData()},setData:function(t){this.is()&&(t=t.getData(),this.get().setData(t))},_isBlockActive:function(t){return this.instance&&this.dom(t).get()===this.$block.get()},_getCurrentInstance:function(){var t;return this.app.blocks.isMeta()?t=this.app.blocks.getLastSelected():this.is()&&(t=this.get()),t},_getInstance:function(t){return this.dom(t).dataget("instance")},_setCaret:function(t){var e=this.instance.getType(),i=this.get();-1!==["embed","image","line","layer"].indexOf(e)?(this.app.scroll.save(),this.$block.attr("tabindex","-1"),this.$block.focus(),setTimeout(function(){this.app.selection.removeAllRanges()}.bind(this),1),this.app.scroll.restore()):i.isEditable()&&t&&this.instance.setCaret(t)}}),t.add("module","observer",{init:function(){this.observer=!1,this.trigger=!0},build:function(){var t;window.MutationObserver&&(t=this.app.editor.getEditor().get(),this.observer=this._build(t),this.observer.observe(t,{attributes:!0,subtree:!0,childList:!0,characterData:!0,characterDataOldValue:!0}))},stop:function(){this.observer&&this.observer.disconnect(),this.trigger=!0},isButtons:function(){return!(this.app.blocks.isMeta()||this.app.editor.isAllSelected()||!this.opts.buttons.tags&&!this.opts.buttons.types)},buildButtons:function(t,e){for(var i,s=this.app.block.get(),a=!!s&&s.getType(),s=!!s&&s.getTag(),n=this.app.selection.getNodes({type:"inline",selected:"inside",links:!0}),o=this._getObservedTags(s,n),r=[],p=0;p<o.length;p++)(i=t[o[p]])&&(r=r.concat(i));return r=a&&(i=e[a])?r.concat(i):r},buildActiveButtons:function(t){var e,i,s={};for(e in s.tags=this.opts.buttons.tags||{},s.types=this.opts.buttons.types||{},t)t.hasOwnProperty(e)&&(i=t[e].active)&&(this._buildActiveButton(e,i.tags,s.tags),this._buildActiveButton(e,i.types,s.types));return s},_build:function(e){var i=this;return new MutationObserver(function(t){i._observe(t[t.length-1],e)})},_observe:function(t,e){"attributes"===t.type&&t.target===e||this.trigger&&(this.app.broadcast("observer.change"),this.app.placeholder.toggle(),this.app.sync.trigger())},_buildActiveButton:function(t,e,i){if(e){for(var s=0;s<e.length;s++){var a=e[s];i[a]?i[a].push(t):i[a]=[t]}return i}},_getObservedTags:function(t,e){var i=[];if(t&&i.push(t),0<e.length)for(var s=0;s<e.length;s++)i.push(e[s].tagName.toLowerCase());return i}}),t.add("module","input",{handle:function(t){var e=t.get("e"),i=t.get("key");this._doSelectAll(e,t)||(t.is("enter")&&t.is("shift")?this.handleShiftEnter(e,i,t):t.is("enter")?this.handleEnter(e,i,t):t.is("space")&&t.is("shift")?this.handleShiftSpace(e,i,t):t.is("space")?this.handleSpace(e,i,t):t.is("tab")&&this.opts.tab.key?this.handleTab(e,i,t):t.is("arrow")?t.is("ctrl")&&t.is("up")?this.handleArrowCtrl(e,i,t):t.is(["shift","alt","ctrl"])||this.handleArrow(e,i,t):t.is(["delete","backspace"])&&this.handleDelete(e,i,t))},handleDelete:function(t,e,i){var s,a,n=this.app.block.get(),o=i.is("backspace"),r=i.is("delete");this.app.editor.isEmpty(!0)?t.preventDefault():this.app.blocks.isMeta()?(t.preventDefault(),this.app.blocks.removeSelected()):this.app.blocks.is()?(t.preventDefault(),a=this.app.blocks.getFirstSelectedBlock(),a=this.dom(a),this.app.selection.deleteContents(),this.app.block.set(a,"end"),this.app.block.get().appendNext()):this._deleteInsideSelection(t)||(n?n&&n.isEditable()&&this._trimInvisibleChar(t,i.is("backspace")?"left":"right",r)||((a=this.app.selection.getInline())&&1===a.innerHTML.length?(t.preventDefault(),a.innerHTML=""):n.handleDelete&&n.handleDelete(t,e,i)||(a=n.getNext(),e=n.getPrev(),n.isEditable()?n.isEditable()&&(n.isAllSelected()?(t.preventDefault(),n.setEmpty(),this.app.caret.set(n.getBlock(),"start"),this.app.toolbar.observe()):n.isSecondLevel()||n.isFigcaption()?r&&n.isCaretEnd()&&t.preventDefault():r&&a&&n.isCaretEnd()?(t.preventDefault(),a.isEditable()?"pre"===a.getType()?(this.app.blocks.setMeta(a.getBlock()),n.isEmpty()&&n.remove(!0)):n.appendNext():(a.isNested()?this.app.blocks.setMeta(a.getBlock()):this.app.block.set(a),n.isEmpty()&&n.remove(!0))):o&&e&&n.isCaretStart()?(t.preventDefault(),e.isEditable()?"pre"===e.getType()?(this.app.blocks.setMeta(e.getBlock()),n.isEmpty()&&n.remove(!0)):(n.appendToPrev(),this.app.control.updatePosition()):(e.isNested()?this.app.blocks.setMeta(e.getBlock()):this.app.block.set(e),n.isEmpty()&&n.remove(!0))):this.app.selection.isCollapsed()||(t.preventDefault(),this.app.selection.deleteContents())):(t.preventDefault(),"image"===n.getType()&&(s={url:n.getSrc(),id:n.getId()}),n.remove(!0),"image"===n.getType()&&this.app.broadcast("image.remove",s),a?this.app.block.set(a,"start"):e?this.app.block.set(e,"end"):this.app.editor.isEmpty()?this.app.editor.setEmpty():this.app.block.unset()))):(t.preventDefault(),this.app.selection.deleteContents()))},handleArrowCtrl:function(t,e,i){this.app.editor.unselectAll(),this.app.selection.removeAllRanges(),this.app.editor.setFocus("start")},handleArrow:function(t,e,i){var s=this.app.block.get();if(this.app.editor.isAllSelected())t.preventDefault(),a=i.is("down-right")?this.app.blocks.getLast():this.app.blocks.getFirst(),n=i.is("down-right")?"end":"start",this.app.editor.unselectAll(),this.app.selection.removeAllRanges(),this.app.block.set(a,n);else if(!this.app.blocks.is())if(this.app.blocks.isMeta())s=this.app.blocks.getLastSelected(),this._doArrow(t,i,s);else{if(s.isEditable()){var a=this.app.selection.getTopInline();if(i.is("right")&&a&&"CODE"===a.tagName){var n=this.app.caret.is(a,"end"),o=this.app.caret.is(s.getBlock(),"end");if(n&&o)return t.preventDefault(),void this.app.caret.set(a,"after")}}s.isEditable()&&this._trimInvisibleChar(t,i.is("left")?"left":"right")||s.handleArrow&&s.handleArrow(t,e,i)||this._doArrow(t,i,s)}},handleTab:function(t,e,i){var s,a,n=this.app.block.get();this.app.blocks.isMeta()?(t.preventDefault(),(s=(n=this.app.blocks.getLastSelected()).getNext())&&this.app.block.set(s,"start")):(n=this.app.blocks.is()&&(a=this.app.blocks.getLastSelectedBlock(),(n=this.dom(a).dataget("instance")).isSecondLevel())?n.getFirstLevel():n).handleTab&&n.handleTab(t,e,i)||(this.opts.tab.spaces&&n.isEditable()?(t.preventDefault(),a=this.opts.tab.spaces,e=document.createTextNode(Array(a+1).join(" ")),this.app.insertion.insertNode(e,"end")):(t.preventDefault(),(s=n.getNext())&&this.app.block.set(s,"start")))},handleShiftSpace:function(t){var e,i=this.app.block.get();this.app.blocks.isMeta()?t.preventDefault():this.app.blocks.is()?(t.preventDefault(),e=this.app.blocks.getFirstSelectedBlock(),e=this.dom(e),this.app.selection.deleteContents(),this.app.caret.set(e,"end"),this.app.insertion.insertHtml(" ","end")):i.isEditable()&&(i.isAllSelected()?(t.preventDefault(),i.setEmpty()):"pre"!==i.getType()&&(t.preventDefault(),this.app.insertion.insertHtml(" ","end")))},handleSpace:function(t,e,i){var s,a=this.app.block.get();this.app.blocks.isMeta()?(t.preventDefault(),this.app.blocks.getLastSelected().insertEmpty({position:"after",caret:"start"}),this.app.blocks.removeSelected(!1)):this.app.blocks.is()?(s=this.app.blocks.getFirstSelectedBlock(),s=this.dom(s),this.app.selection.deleteContents(),this.app.caret.set(s,"end")):a.handleSpace&&a.handleSpace(t,e,i)||(a.isEditable()&&a.isAllSelected()?(t.preventDefault(),a.setEmpty()):a.isEditable()||(t.preventDefault(),a.insertEmpty({position:"after",caret:"start"}),a.remove(!0)))},handleShiftEnter:function(t){var e;this.app.blocks.isMeta()?t.preventDefault():this.app.blocks.is()?(t.preventDefault(),e=this.app.blocks.getFirstSelectedBlock(),e=this.dom(e),this.app.selection.deleteContents(),this.app.caret.set(e,"end"),this.app.insertion.insertBreakline()):this._deleteInsideSelection(t)||((e=this.app.block.get()).isEditable()?(t.preventDefault(),this.app.insertion.insertBreakline()):(t.preventDefault(),e.insertEmpty({position:"after",caret:"start"})))},handleEnter:function(t,e,i){if(this.app.blocks.isMeta())t.preventDefault(),this.app.blocks.getLastSelected().insertEmpty({position:"after",caret:"start"});else if(this.app.blocks.is())t.preventDefault(),this.app.selection.deleteContents();else if(!this._deleteInsideSelection(t)){var s=this.app.block.get();if(s.isEditable()){if(s.isAllSelected())return t.preventDefault(),void s.setEmpty();if(!this.app.selection.isCollapsed())return t.preventDefault(),void("pre"===s.getType()?this.app.insertion.insertNewline():this.app.insertion.insertBreakline())}s.isEditable()||(t.preventDefault(),s.insertEmpty({position:"after",caret:"start"})),s.handleEnter&&s.handleEnter(t,e,i)}},handleTextareaTab:function(t){if(9!==t.keyCode)return!0;t.preventDefault();var t=t.target,e=t.value,i=t.selectionStart;t.value=e.substring(0,i)+" "+e.substring(t.selectionEnd),t.selectionStart=t.selectionEnd=i+4},_deleteInsideSelection:function(t){if(!this.app.selection.isCollapsed()){var e=this.app.selection.getNodes({type:"blocks"});if(1<e.length)return t.preventDefault(),this.app.selection.deleteContents(),this.app.caret.set(e[0],"end"),!0}return!1},_doSelectAll:function(t,e){return this._isAllSelected(e)?(this._setEditorEmpty(t,e),!0):e.is("select")?(t.preventDefault(),this.app.editor.selectAll(),!0):void 0},_doArrow:function(t,e,i){var s,a,n=i.getParent("layer"),o=i.getType(),r=["pre","line","image","embed","layer"];if(e.is("right")&&"layer"===o){var p=i.getChildFirst();if(p.isEditable())return this.app.block.set(p),void setTimeout(function(){this.app.offset.set(p.getBlock(),{start:0})}.bind(this),0)}else if(e.is("up-left")&&i.isCaretStart()){if(a="end",s=(n||i).getPrev(),n&&!s)return void this.app.block.set(n);if(!s&&-1!==r.indexOf(o))return void this.app.insertion.insertEmptyBlock({position:"before",caret:"start"})}else if(e.is("down-right")&&i.isCaretEnd()){if(a="start",s=(n||i).getNext(),n&&!s)return void this.app.block.set(n);if(!s&&-1!==r.indexOf(o))return void this.app.insertion.insertEmptyBlock({position:"after",caret:"start"})}s&&(t.preventDefault(),this.app.block.set(s,a))},_isAllSelected:function(t){return this.app.editor.isAllSelected()&&t.is(["enter","delete","backspace","alpha","space"])},_setEditorEmpty:function(t,e){e.is(["alpha","space"])||t.preventDefault(),this.app.editor.setEmpty()},_trimInvisibleChar:function(t,e,i){var s,a="left"===e?"before":"after",n=this.app.selection.get(),a=this._isInvisibleChar(a);if(a&&"left"===e)s=n.current,this.dom(s).replaceWith(s.textContent.replace(/\uFEFF/g,""));else if(a&&i&&n.current&&n.current.nextSibling)s=n.current.nextSibling,this.dom(s).replaceWith(s.textContent.replace(/\uFEFF/g,""));else if(a&&"right"===e)return t.preventDefault(),i=this.app.offset.get(),this.app.offset.set(!1,{start:i.start+1,end:i.end+1}),!0},_isInvisibleChar:function(t){var e=this.app.selection.get(),t=this.app.selection.getText(t);return e.current&&3===e.current.nodeType&&0===this.app.utils.searchInvisibleChars(t)}}),t.add("module","insertion",{init:function(){this._clear()},start:function(){this.win=this.app.$win.get(),this.doc=this.app.$doc.get()},getFirstInserted:function(){return this.inserted.instances[0]},getLastInserted:function(){var t=this.inserted.instances.length,t=this.inserted.instances[t-1];return t=t&&t.isFigcaption()?t.getFigure():t},getInserted:function(){return this.inserted},setContent:function(t){this._insert(t,"set");t=this.getInserted();return this.inserted=!1,t},insertContent:function(t){this._insert(t,"insert");t=this.getInserted();return this.inserted=!1,t},insertEmptyBlock:function(t){(t=t||{}).html=this.app.block.createHtml(),this._insert(t,"insert");t=this.getInserted();return this.inserted=!1,this.app.broadcast("block.add",{instance:t.instances[0],type:"input"}),t},insertNewline:function(t,e){return this._insertFragment({node:document.createTextNode(e?"\n\n":"\n")},t||"after")},insertPoint:function(t){var e,i,s=this.app.utils.createInvisibleChar(),a=t.clientX,t=t.clientY;this.doc.caretPositionFromPoint?(e=this.doc.caretPositionFromPoint(a,t),(i=this.doc.getSelection().getRangeAt(0)).setStart(e.offsetNode,e.offset),i.collapse(!0),i.insertNode(s)):this.doc.caretRangeFromPoint&&(i=this.doc.caretRangeFromPoint(a,t)).insertNode(s),this.app.caret.set(s,"after")},insertBreakline:function(t){var e=this.app.selection.getNodes({type:"inline"});return this.app.selection.isCollapsed()&&0!==e.length?this._splitInline(e,document.createElement("br")):this._insertFragment({node:document.createElement("br")},t||"after")},insertNode:function(t,e,i){if(i){i=this.app.selection.getNodes({type:"inline"});if(0!==i.length)return this._splitInline(i,t)}return this._insertFragment({node:this.dom(t).get()},e)},insertHtml:function(t,e){return this._insertFragment({html:t},e)},insertText:function(t,e){var i,s=this.app.block.get();if(!(s&&!s.isEditable()||this.app.blocks.isMeta()))return(s=this.win.getSelection()).getRangeAt&&s.rangeCount&&(t=this.app.content.getTextFromHtml(t,{nl:!0}),i=document.createTextNode(t),(s=s.getRangeAt(0)).deleteContents(),s.insertNode(i),this.app.caret.set(i,e=e||"end")),i;this.insertContent({html:t,caret:e})},insertListToList:function(t,e,i){var s=t.find("li"),a=s.last(),s=(s.addClass(this.prefix+"-pasteitems"),a.addClass(this.prefix+"-pastemarker"),t.children()),t=this.dom(this.app.selection.getBlock()),n=this.app.caret.is(e,"start"),o=this.app.caret.is(e,"end"),r=this.app.caret.is(t,"start"),p=this.app.caret.is(t,"end",["ul","ol"]),l=this.app.content.isEmptyHtml(t.html()),o=(n?(l&&t.remove(),e.prepend(s)):o?(l&&t.remove(),e.append(s)):l?(t.after(s),t.remove()):r?t.before(s):p?0!==(n=t.find("ul, ol")).length?n.prepend(s):t.after(s):this.app.element.split(t).before(s),this.prefix+"-pastemarker"),e=this.prefix+"-pasteitems";return i&&(a=this.app.editor.getEditor().find("."+o).removeClass(o),this.app.caret.set(a,"end")),this.app.editor.getEditor().find("."+e).removeClass(e)},detectPosition:function(t,e){var i;return e||(i=this.app.caret.is(t,"start"),e=this.app.caret.is(t,"end")?"after":i?"before":"split"),e},_insert:function(t,e){this.html=t.html,this.html=this.app.broadcastHtml("editor.before.insert",this.html),this.isParse=void 0===t.parse||t.parse,this.isClean=void 0!==t.clean&&t.clean,this.isCaret=void 0===t.caret||t.caret,this.isPosition=void 0!==t.position&&t.position,this.isCurrent=void 0!==t.current&&t.current,"set"===e||this.app.editor.isAllSelected()?this._setContent():this._insertContent(),this.app.broadcast("editor.insert",this.inserted)},_insertContent:function(){var t=this.isCurrent||this.app.block.get(),e=!1,i=!1;if(this._checkEmpty(),this._checkLine(),this.app.blocks.isMeta()||this.app.blocks.is()){if(this.isEmpty)return;if(this.isLine&&(this.html=this.app.block.createHtml(this.html)),this._clean(),this._parse(),this._parseBuild(),a=this._buildParsedNodes(),this.app.blocks.is()){if(!(n=this.app.blocks.getLastSelectedBlock()))return;t=(s=this.dom(n)).dataget("instance"),this.app.selection.deleteContents(),this._insertToEditable(t,s,a)}else(n=this.app.blocks.getLastSelected()).getBlock().after(a),this.app.blocks.removeSelected(!1)}else if(!t||this.isPosition){if(this.isEmpty)return;this.isLine&&(this.html=this.app.block.createHtml(this.html)),this._clean(),this._parse(),this._parseBuild();var s,a=this._buildParsedNodes(),e="top"===this.isPosition||!this.isPosition&&"top"===this.opts.editor.add?(t=this.app.blocks.getFirst(),"before"):t&&-1!==["after","before","append"].indexOf(this.isPosition)?this.isPosition:(t=this.app.blocks.getLast(),"after");(s=t.getBlock())[e](a)}else if(this._isListToList(t)){this.app.selection.deleteContents(),this._clean(),this._parse(),this._parseBuild(),s=t.getBlock();var n=this.$parsed.children().first();this.$nodes=this.insertListToList(n,s,"end"),this.isCaret=!1}else{if(!t)return;if(t.isEditable()){if(this.isEmpty)return;this._clean(),this._cleanSpecial(t),this.isLine?this._parseLine():this._parse(),this._parseBuild(),t.isEmpty()?(i=!0,e="after"):this.app.selection.deleteContents(),a=this._buildParsedNodes(),s=t.getBlock(),this._insertToEditable(t,s,a,e,i)}else{if(e="after",this.isEmpty)return;this.isLine&&(this.html=this.app.block.createHtml(this.html)),this._clean(),this.isLine?this._parseLine():this._parse(),this._parseBuild(),a=this._buildParsedNodes(),(s=t.getBlock())[e](a)}}this._buildInserted(),this._buildEditor(),this._buildCaret()},_insertToEditable:function(t,e,i,s,a){this.isLine?(this.$nodes=this._insertFragment({fragment:this.$parsed.get()},"end"),this.isCaret=!1):(this.app.content.isEmptyHtml(e.html())?(s="after",a=!0):s=this.detectPosition(e,s),"split"===s?this.app.element.split(e).before(i):e[s](i),a&&t.remove())},_insertFragment:function(t,e){var i,s;return t.html||t.fragment?(i=this.app.fragment.build(t.html||t.fragment),this.app.fragment.insert(i)):this.app.fragment.insert(t.node),e&&(s=t.node||("start"===e?i.first:i.last),this.app.caret.set(s,e)),t.node?this.dom(t.node):this.dom(i.nodes)},_setContent:function(){this._checkEmpty(),this._checkLine(),this.isEmpty?this.html=this.app.block.createHtml():this.isLine&&(this.html=this.app.block.createHtml(this.html)),this._clean(),this._parse(),this._parseBuild();var t=this._buildParsedNodes();this.app.editor.unsetSelectAll(),this.app.editor.getEditor().html("").append(t),this.isEmpty&&this.app.broadcast("editor.empty"),this._buildInserted(),this._buildEditor(),this._buildCaret(),this.app.broadcast("editor.set",this.inserted)},_splitInline:function(t,e){t=this.app.element.split(t[0]);return t.before(e),""===t.html()&&t.remove(),this.dom(e)},_buildEditor:function(){this.app.placeholder.trigger(),this.app.editor.build(),this.app.editor.setFocus(),this.app.toolbar.observe(),this.app.context.observe()},_buildCaret:function(){var t,e;this.isCaret&&(e="end","start"===this.isCaret?(t=this.getFirstInserted(),e="start"):t=this.getLastInserted(),t)&&this.app.block.set(t,e)},_buildInserted:function(){this.inserted={$nodes:this.$nodes,instances:[]},this.inserted.$nodes.each(this._buildInstance.bind(this))},_buildInstance:function(t){t=t.dataget("instance");t&&this.inserted.instances.push(t)},_buildParsedNodes:function(){return this.$parsed.get().childNodes},_clear:function(){this.html=!1,this.isLine=!1,this.isEmpty=!1,this.isSplit=!1,this.isClean=!1,this.isParse=!0,this.isCaret=!0,this.isCurrent=!1,this.isPosition=!1},_clean:function(){this.isClean&&(this.html=this.app.cleaner.cleanHtml(this.html))},_cleanSpecial:function(t){var e,i,t=t.getType();-1!==["cell","address","figcaption","quoteitem"].indexOf(t)?e=!0:"list"===t&&(e=!0,i=["ul","ol","li"]),e&&(this.isLine=!0,this.html=this.app.content.addBrToBlocks(this.html),this.html=this.app.content.removeBlockTags(this.html,void 0,i),this.html=this.html.replace(/<br\s?\/?>\n?$/gi,""))},_parse:function(){this.isParse&&(this.html=this.app.parser.parse(this.html,!1))},_parseLine:function(){this.isParse&&(this.html=this.app.parser.parseLine(this.html,!1))},_parseBuild:function(){this.$parsed=this.app.parser.build(this.html),this.$nodes=this.$parsed.children()},_checkEmpty:function(){this.isEmpty=this.app.content.isEmptyHtml(this.html)},_checkLine:function(){this.isLine=this.app.content.isLine(this.html)},_isListToList:function(t){var t=t.getBlock().attr("data-"+this.prefix+"-type"),e=this.dom("<div>").html(this.html);return e.find("meta").remove(),e.find("b").unwrap(),e=e.children().first(),"list"===t&&0!==e.length&&-1!==["ul","ol"].indexOf(e.get().tagName.toLowerCase())}}),t.add("module","toolbar",{init:function(){this.eventname=this.prefix+"-toolbar",this.activeClass="active",this.toggledClass="toggled",this.disableClass="disable",this.customButtons={},this.aTags={},this.aTypes={}},start:function(){this.$container=this.app.container.get("toolbar"),this.opts.toolbar&&(this._build(),this._buildSticky())},load:function(){this.opts.toolbar&&(this._buildActiveButtons(),this.app.block.get()||(this.$toolbar.html(""),this._buildButtons()))},stop:function(){this.opts.toolbar&&(this.$toolbar.remove(),this.customButtons={},this.editorButtons={})},build:function(){var t,e;this.opts.toolbar&&((t=this.app.block.get())&&t.isSecondLevel()&&(t=t.getFirstLevel()),e=this.app.editor.getButtonsFromArr(this.opts.buttons.editor),t&&t.toolbar&&(e=this.app.editor.getButtonsFromArr(t.toolbar)),this.$toolbar.html(""),e=this._createButtons(e,t),t||this._checkIntialToolbar(e))},observe:function(){var t;this.opts.toolbar&&(this.unsetActive(),this.app.observer.isButtons())&&(t=this.app.observer.buildButtons(this.aTags,this.aTypes),this._setActiveKeys(t))},getElement:function(){return this.$toolbar},get:function(t){return this._findButton(t)},add:function(t,e){this.customButtons[t]=e},setActive:function(t){this.opts.toolbar&&(this._findButtons().removeClass(this.activeClass),this._findButton(t).removeClass(this.disableClass).addClass(this.activeClass))},setToggled:function(t){this.opts.toolbar&&(this._findButtons().removeClass(this.toggledClass),this._findButton(t).removeClass(this.disableClass).addClass(this.toggledClass))},unsetActive:function(t){this.opts.toolbar&&(t?this._findButton(t):this._findButtons()).removeClass(this.activeClass)},unsetToggled:function(t){this.opts.toolbar&&(t?this._findButton(t):this._findButtons()).removeClass(this.toggledClass)},enable:function(){this.opts.toolbar&&this._findButtons().removeClass(this.disableClass)},disable:function(){this.opts.toolbar&&this._findButtons().removeClass(this.toggledClass).removeClass(this.activeClass).addClass(this.disableClass)},disableSticky:function(){var t=this.app.container.get("toolbar");t.removeClass(this.prefix+"-toolbar-sticky"),t.css("top","")},enableSticky:function(){var t;this.opts.toolbar.sticky&&((t=this.app.container.get("toolbar")).addClass(this.prefix+"-toolbar-sticky"),t.css("top",this.opts.toolbar.stickyTopOffset+"px"))},isSticky:function(){var t=this.app.container.get("toolbar"),e=this.app.container.get("main"),e=e.offset().top+parseInt(e.css("border-top-width")),t=t.offset().top;return e<t||t<e},_build:function(){this.$toolbar=this.dom("<div>").addClass(this.prefix+"-toolbar"),this.$container.append(this.$toolbar),this.$container.addClass("is-"+this.prefix+"-toolbar")},_buildSticky:function(){this.opts.toolbar.sticky&&(this._toggleSticky("add",this.opts.toolbar.stickyTopOffset+"px"),this._startEvent())},_buildButtons:function(){var t=this.app.editor.getButtonsFromArr(this.opts.buttons.editor),t=this._createButtons(t);this._checkIntialToolbar(t)},_buildActiveButtons:function(){var t=this.app.observer.buildActiveButtons(this.customButtons);this.aTags=t.tags,this.aTypes=t.types},_checkIntialToolbar:function(t){var e;0!==t||this.opts.topbar||(t=this.app.blocks.getFirst(),e=this.app.editor.getButtonsFromArr(t.toolbar),this.$toolbar.html(""),this._createButtons(e,t),this.disable())},_findButtons:function(){return this.$toolbar.find("."+this.prefix+"-button-toolbar")},_findButton:function(t){return this.$toolbar.find("[data-name="+t+"]")},_createButtons:function(t,e){var i,s=t,a=0;for(i in s=e?h.extend(!0,{},t,this.customButtons):s)!s.hasOwnProperty(i)||"add"===i&&!this.opts.addbar||"html"===i&&!this.opts.source||"format"===i&&!this.opts.format||e&&!e.isAllowedButton(i,s[i])||this._isHidden(i)||(this.app.create("button",i,s[i],this.$toolbar,"toolbar"),a++);return a},_isHidden:function(t){return-1!==this.opts.toolbar.hide.indexOf(t)},_setActiveKeys:function(t){for(var e=0;e<t.length;e++)this._findButton(t[e]).addClass(this.activeClass)},_getObservedTags:function(t,e){var i=[];if(t&&i.push(t),0<e.length)for(var s=0;s<e.length;s++)i.push(e[s].tagName.toLowerCase());return i},_toggleSticky:function(t,e){this.$container["remove"===t?"removeClass":"addClass"](this.prefix+"-toolbar-sticky"),this.$container.css("top",e)},_startEvent:function(){this.app.scroll.getTarget().on("scroll."+this.eventname,this._observeSticky.bind(this))},_stopEvent:function(){this.app.scroll.getTarget().off("."+this.eventname)},_observeSticky:function(){var t;this.app.source.is()?this.$container.css("top",0):(t=this.app.scroll.getTarget(),t=this.app.scroll.isTarget()?parseInt(t.css("padding-top")):0,this.$container.css("top",0-t+this.opts.toolbar.stickyTopOffset+"px"),this.isSticky()?this.app.broadcast("toolbar.sticky"):this.app.broadcast("toolbar.static"))}}),t.add("module","addbar",{init:function(){this.custom={}},popup:function(t,e){this.opts.addbar&&(this.app.popup.create("addbar",{width:"380px",items:this.buildItems()}),e=e.isButton||e.isControl?{button:e}:{},this.app.popup.open(e))},add:function(t,e){this.custom[t]=e,this.custom[t].container=!0,this.custom[t].addbar=!0,this.custom[t].command=e.command||"block.add",e.template&&(this.custom[t].params={template:e.template})},buildItems:function(){for(var t,e={},i=this.opts.buttons.addbar,s=h.extend(!0,{},this.opts.buttonsObj),a=0;a<i.length;a++){var n=i[a];this._isHidden(n)||(e[n]=s[n],e[n].container=!0,e[n].addbar=!0,e[n].icon=!0)}for(t in this.opts.addbar.add)!this.opts.addbar.add.hasOwnProperty(t)||this._isHidden(t)||(e[t]=this.opts.addbar.add[t],e[t].container=!0,e[t].addbar=!0,e[t].command="block.add",e[t].params={template:this.opts.addbar.add[t].template});return e=h.extend(!0,{},e,this.custom)},_isHidden:function(t){return-1!==this.opts.addbar.hide.indexOf(t)}}),t.add("module","format",{popup:function(t,e){for(var i,s=this.app.block.get(),a=!!s&&s.getBlock(),s=!!s&&s.getTag(),n=this.opts.format,o={},r=0;r<n.length;r++){var p=n[r];o[p]={title:this.opts.formatObj[p].title,params:{tag:p},command:"block.format",shortcut:this.opts.formatObj[p].shortcut}}this.opts.formatAdd&&(i=this.opts.formatAdd,Object.keys(i).forEach(function(t){o[t]={title:i[t].title,params:i[t].params,command:"block.format"}}));a=this._isActiveFormat(a,s,o);a&&(o[a].active=!0),this.app.popup.create("format",{width:"300px",items:o}),this.app.popup.open({button:e})},set:function(t){var e,i,s;this.app.popup.close(),this.app.blocks.isMeta()||(e={type:this.opts.formatObj[t.tag].type,tag:t.tag,classname:t.classname||!1},i=this.app.blocks.getSelectedBlocks("editable"),(s=this.app.block.get())?this.setSingle(s,e,t):0!==i.length&&this.setMultiple(i,e,t))},setSingle:function(t,e){var i,s=t.isEmpty(),a=!!s&&"start";this.tag=t.getTag(),this.type=t.getType(),this.$block=t.getBlock(),s||this.app.selection.saveMarker(),(e=this._isSameTag(e)?this._checkSameFormat(this.$block,e):e)&&(this._isListToText(e,"list")?i=this._formatListToText(e):this._isListToText(e,"dlist")?i=this._formatListToText(e,!0):this._isTextToList(e,"list")?this._formatTextToList(e,!1,a):this._isTextToList(e,"dlist")?this._formatTextToList(e,!0,a):this._replaceTo(t,e,a)),s||this.app.selection.restoreMarker(),i&&this.app.block.unset(),t=this.app.block.get(),this.app.editor.build(),this.app.broadcast("block.format",{instance:t})},setMultiple:function(t,i){var e,s;this.app.selection.saveMarker(),this._isListTag(i.tag)&&this._isMultipleParagraphs()&&(s=(e=this.app.create("block."+i.type,!1,{tag:i.tag})).getBlock(),this.dom(t[0]).before(s));for(var a,n,o,r,p=0;p<t.length;p++)(r=t[p].tagName.toLowerCase())!==i.tag&&(s?(a=this.dom("<li>").html(t[p].innerHTML),s.append(a),this.dom(t[p]).remove(),this._setStyleAndClass(s,i)):!this._isListTag(r)&&this._isListTag(i.tag)?(o=(e=this.app.create("block."+i.type,!1,{tag:i.tag})).getBlock(),a=this.dom("<li>").html(t[p].innerHTML),o.append(a),(n=this.dom(t[p])).after(o),n.remove(),this._setStyleAndClass(o,i)):this._isListTag(r)&&!this._isListTag(i.tag)?((o=(n=this.dom(t[p])).find("li")).find("ul, ol").each(function(t){t.parent().after(t)}),o.find("ul, ol").unwrap(),o.each(function(t){var e=this.dom("<"+i.tag+">");e.html(t.html()),t.remove(),this.app.create("block."+i.type,e),n.before(e),this._setStyleAndClass(e,i)}.bind(this)),n.remove()):e=this._replaceToBlock(t[p],i));this.app.selection.restoreMarker(),s&&this.app.block.set(s),this.app.editor.build(),this.app.editor.unsetSelectAll(),this.app.broadcast("block.format",{instance:e})},_isListTag:function(t){return-1!==["ul","ol"].indexOf(t)},_isSameTag:function(t){return this.tag===t.tag&&this.type===t.type},_isMultipleParagraphs:function(){var t=this.app.blocks.getSelectedBlocks(),e=["P","ADDRESS","H1","H2","H3","H4","H5","H6"];if(1<t.length){for(var i=0,s=0;s<t.length;s++)-1===e.indexOf(t[s].tagName)&&i++;if(0===i)return!0}return!1},_checkSameFormat:function(t,e){t=this.app.element.hasClass(t,e.classname);return!e.classname||t?this._buildDefaultFormat():e},_buildDefaultFormat:function(){return{type:"paragraph",tag:"p",classname:!1}},_formatListToText:function(t,e){e=e?this._getDlistItems():this._getListItems();return this._createItems(e,t),this.$block.remove(),e},_formatTextToList:function(t,e,i){var s,a=this.app.create("block."+t.type,"<"+t.tag+">").getBlock();e&&"list"===this.type?(s=0,this._getListItems().each(function(t){var e=0===s?"dt":"dd",t=this.dom("<"+e+">").html(t.html());s="dt"==e?1:0,a.append(t)}.bind(this))):e||"dlist"!==this.type?(e=this.dom(e?"<dt>":"<li>").html(this.$block.html()),a.append(e)):this._getDlistItems().each(function(t){t=this.dom("<li>").html(t.html());a.append(t)}.bind(this)),this.app.create("block."+t.type,a),this.$block.after(a),this.$block.remove(),this._setStyleAndClass(a,t),this.app.block.set(a,i)},_replaceTo:function(t,e,i){var s=t.getBlock(),s=(t=this._replaceToBlock(s,e)).getBlock();this.app.block.set(s,i)},_replaceToBlock:function(t,e){t=this.app.element.replaceToTag(t,e.tag);return this._setStyleAndClass(t,e),this.app.create("block."+e.type,t)},_createItems:function(t,i){t.each(function(t){var e=this.dom("<"+i.tag+">");e.html(t.html()),t.remove(),this.app.create("block."+i.type,e),this.$block.before(e),this._setStyleAndClass(e,i)}.bind(this))},_isListToText:function(t,e){return this.type===e&&-1!==["heading","address","paragraph"].indexOf(t.type)},_isTextToList:function(t,e){var i="list"===e?"dlist":"list";return t.type===e&&-1!==["heading","address","paragraph",i].indexOf(this.type)},_isActiveFormat:function(t,e,i){if(t){var s,a,n;for(a in i)i.hasOwnProperty(a)&&(n=i[a].params.classname||!1,e!==i[a].params.tag||n&&!this.app.element.hasClass(t,n)||(s=a));return s}},_setStyleAndClass:function(t,e){t.removeAttr("style class data-"+this.prefix+"-style-cache"),e.classname&&t.addClass(e.classname)},_getListItems:function(){var t=this.$block.find("li");return t.find("ul, ol").each(function(t){t.parent().after(t)}),t.find("ul, ol").unwrap(),t},_getDlistItems:function(){return this.$block.find("dt, dd")}}),t.add("module","embed",{popups:{add:{title:"## embed.embed ##",width:"100%",form:{embed:{type:"textarea",label:"## embed.description ##",rows:6},caption:{type:"input",label:"## embed.caption ##"},responsive:{type:"checkbox",text:"## embed.responsive-video ##"}},footer:{insert:{title:"## buttons.insert ##",command:"embed.insert",type:"primary"},cancel:{title:"## buttons.cancel ##",command:"popup.close"}}},edit:{title:"## embed.embed ##",width:"100%",form:{embed:{type:"textarea",label:"## embed.description ##",rows:6},caption:{type:"input",label:"## embed.caption ##"},responsive:{type:"checkbox",text:"## embed.responsive-video ##"}},footer:{save:{title:"## buttons.save ##",command:"embed.save",type:"primary"},remove:{title:"## buttons.delete ##",command:"embed.remove",type:"danger",right:!0},cancel:{title:"## buttons.cancel ##",command:"popup.close"}}}},build:function(t){t?this._callScripts(t):this._findScripts()},observe:function(t,e,i){var s;return!!this.opts.embed&&(s=this.app.block.get(),i&&"addbar"===i.getName()?t.command="embed.popup":s&&"embed"===s.getType()&&(t.command="embed.edit"),t)},popup:function(){this.app.popup.create("embed",this.popups.add),this.app.popup.open({focus:"embed"}),this.opts.embed.checkbox&&this.app.popup.getInput("responsive").attr("checked",!0),this._buildCodemirror()},edit:function(t){var e=this.app.block.get(),e={embed:e.getEmbedCode(),caption:e.getCaption(),responsive:e.isResponsive()};this.app.popup.create("embed",this.popups.edit),this.app.popup.setData(e),this.app.popup.open({focus:"embed"}),this._buildCodemirror()},insert:function(){this.app.popup.close();var t=this.app.popup.getData(),e=this._getEmbedCode(t);""!==e&&(t=this._createInstance(t,e),this.app.block.add({instance:t}))},save:function(){this.app.popup.close();var t=this.app.block.get(),e=this.app.popup.getData(),i=this._getEmbedCode(e);""===i?this.app.block.remove():(i=this._createInstance(e,i,t),this._isNeedToChange(e,i,t)&&this.app.block.change(i))},remove:function(){this.app.popup.close(),this.app.block.remove()},_buildCodemirror:function(){var t=this.app.popup.getInput("embed");this.app.codemirror.create({el:t,height:"200px",focus:!0}),this.app.popup.updatePosition()},_findScripts:function(){var t=this.app.editor.getEditor().find("[data-"+this.prefix+"-type=embed]").find("script").getAll();this.build.call(this,t)},_callScripts:function(e){for(var i,t,s,a=0;a<e.length;a++)""!==e[a].src&&(i=e[a].src,this.app.$doc.find('head script[src="'+i+'"]').remove(),(t=this.dom("<script>").attr({src:i,async:!0,defer:"true"})).on("load",function(){var t;-1!==i.search("instagram")&&(t=this.app.$win.get()).instgrm&&t.instgrm.Embeds.process(),this.build(e.slice(a+1))}.bind(this)),s=this.app.$doc.get().getElementsByTagName("head")[0])&&s.appendChild(t.get())},_getEmbedCode:function(t){t=t.embed.trim(),t=this.app.codemirror.val(t);return t=this._removeScript(t),t=this.app.content.sanitize(t),this._isHtmlString(t)||""===t?t:this._parseUrl(t)},_removeScript:function(t){return t=this.opts.embed.script?t:this.app.content.removeTagsWithContent(t,["script"])},_createInstance:function(t,e,i){i?(s=i.duplicate().getBlock()).html(e):s=this._isFigure(e)?e:"<figure>"+e+"</figure>";var s,i=this.app.create("block.embed",s);return i.setCaption(t.caption),t.responsive&&i.addResponsive(),i},_parseUrl:function(t){var e,i='<iframe width="560" height="315" src="',s='" frameborder="0" allowfullscreen></iframe>';return t.match(this.opts.regex.youtube)?(e="//www.youtube.com",-1!==t.search("youtube-nocookie.com")&&(e="//www.youtube-nocookie.com"),i+t.replace(this.opts.regex.youtube,e+"/embed/$1")+s):t.match(this.opts.regex.vimeo)?i+t.replace(this.opts.regex.vimeo,"//player.vimeo.com/video/$2")+s:t},_isNeedToChange:function(t,e,i){return i.getEmbedCode()!==e.getEmbedCode()||t.responsive!==i.isResponsive()||t.caption!==i.getCaption()||void 0},_isHtmlString:function(t){return/^\s*<(\w+|!)[^>]*>/.test(t)},_isFigure:function(t){return/^<figure/.test(t)}}),t.add("module","image",{popups:{add:{title:"## popup.add-image ##",width:"100%"},edit:{title:"## popup.image ##",width:"100%",getter:"block.getData",form:{width:{type:"input",width:"100px",label:"## image.width ##",observer:"image.observeImageWidth"},alt:{type:"input",label:"## image.alt-text ##"},caption:{type:"input",label:"## image.caption ##",observer:"image.observeImageCaption"},link:{type:"input",label:"## image.link ##",observer:"image.observeImageLink"},target:{type:"checkbox",text:"## image.link-in-new-tab ##",observer:"image.observeImageLink"}},footer:{save:{title:"## buttons.save ##",command:"image.save",type:"primary"},remove:{title:"## buttons.delete ##",command:"image.remove",type:"danger",right:!0},cancel:{title:"## buttons.cancel ##",command:"popup.close"}}}},init:function(){this.dataStates=[]},popup:function(){this.app.popup.create("image",this.popups.add);var t=this.app.popup.getBody();this._createImageByUrl(t),this._createOrSection(t),this._createUploadBox(t),this._createSelectBox(t),this.app.popup.open()},edit:function(t){this.app.popup.create("image-edit",this.popups.edit),this._buildEditUpload(),this.app.popup.open()},observe:function(t,e,i){var s;return!!this.isImagePopup()&&(s=this.app.block.get(),i&&"addbar"===i.getName()?t.command="image.popup":s&&"image"===s.getType()&&(t.command="image.edit"),t)},observeStates:function(){this._findImages().each(this._addImageState.bind(this))},observeImageLink:function(t){return!!this.opts.image.link&&t},observeImageCaption:function(t){var e=this.app.block.get();return!(!e||"figure"!==e.getTag())&&t},observeImageWidth:function(t){return!!this.opts.image.width&&t},isImagePopup:function(){return!1!==this.opts.image},paste:function(t,e){var i={url:this.opts.image.upload,name:this.opts.image.name,data:this.opts.image.data,multiple:this.opts.image.multiple,success:"image.insertFromBlob",error:"image.error"};this.app.create("upload").send(e,[t],i)},parseInserted:function(t){for(var e,i=[],s={url:this.opts.image.upload,name:this.opts.image.name,data:this.opts.image.data,multiple:!0,success:"image.insertFromInserted",error:"image.error"},a=(this.pasteInsertedImages=[],this.resolved=[],0),n=0;n<t.instances.length;n++){var o,r,p,l=t.instances[n];"image"===l.getType()&&(-1!==(o=l.getSrc()).search(/^data:/i)?(r=this._dataURLtoFile(o,"image"+n),i.push(r),this.pasteInsertedImages.push(l)):-1!==o.search(/^blob:/i)&&(a++,this.pasteInsertedImages.push(l),p=this,function(t,i){var s=new XMLHttpRequest;s.open("GET",t,!0),s.responseType="blob",s.onload=function(t){var e;200==s.status&&(e=s.response,e=new File([e],"image"+i,{type:"image/png"}),p.resolved.push(e))},s.send()}(o,n)))}0!==a&&(e=setInterval(function(){this.resolved.length===a&&(clearInterval(e),this.app.create("upload").send(!1,this.resolved,s))}.bind(this),100)),0!==i.length&&this.app.create("upload").send(!1,i,s)},drop:function(t,e){for(var i=[],s=0;s<e.files.length;s++){var a=e.files[s]||e.items[s].getAsFile();a&&i.push(a)}var n,o={url:this.opts.image.upload,name:this.opts.image.name,data:this.opts.image.data,multiple:this.opts.image.multiple,success:"image.insertByDrop",error:"image.error"};0<i.length&&(0!==(n=this.dom(t.target).closest("[data-"+this.prefix+"-type]")).length&&this.app.block.set(n),this.app.create("upload").send(t,i,o))},insertFromClipboard:function(t){var e=(e=t.getData("text/plain")||t.getData("text/html")).trim();if(""===e){for(var i=t.items,s=null,a=0;a<i.length;a++)0===i[a].type.indexOf("image")&&(s=i[a].getAsFile());return null!==s?(this.paste(s),!0):void 0}},insertFromBlob:function(t){this.insert(t)},insertByDrop:function(t,e){if(this.app.block.is()){var i=this.app.block.get(),s=e.target,a=i.getType();if("card"===a&&s&&"IMG"===s.tagName&&i.hasImage()||"image"===a)return void this.change(t);e&&"card"!==a&&i.isEditable()&&this.app.insertion.insertPoint(e)}this.insert(t)},insertByUpload:function(t){this.insert(t)},insertByUrl:function(t){t.preventDefault();var t=this.$urlinput.val();""!==t.trim()&&(t={file:{url:t,id:this.app.utils.getRandomId()}},this.insert(t))},insertFromSelect:function(t){t.preventDefault();for(var e=this.dom(t.target),i={url:e.attr("data-url")},s=["id","alt","caption","link","width","height"],a=0;a<s.length;a++){var n=e.attr("data-"+s[a]);null!==n&&(i[s[a]]=n)}this.insert({file:i},!0)},insertFromInserted:function(t){var e,i=0;for(e in t)t.hasOwnProperty(e)&&(this.pasteInsertedImages[i].setImage(t[e]),i++)},changeClone:function(t){for(var e in t)if(t.hasOwnProperty(e)){this.$imageclone.attr("src",t[e].url);break}this.change(t,!1)},change:function(t,e){!1!==e&&this.app.popup.close();var i,s=this.app.block.get();for(i in t)if(t.hasOwnProperty(i))return s.setImage(t[i]),this.app.broadcast("image.change",t[i]),void this.app.broadcast("image.upload",{instance:s,data:t[i]});this.app.parser.buildPredefinedClasses()},save:function(t){this.app.popup.close(),this.app.block.setData(t)},insert:function(t,e){this.app.popup.close(),this.imageslen=0,this.imagescount=0;var i,s,a,n=this.opts.image.tag;for(i in t)t.hasOwnProperty(i)&&(a=this.dom("<"+n+">"),s=this._createImageFromResponseItem(t[i]),a.append(s),s=this.app.create("block.image",a),this.app.block.add({instance:s,type:"image"}),Object.prototype.hasOwnProperty.call(t[i],"caption")&&(a=this.dom("<figcaption>").html(t[i].caption),s.$block.append(a),this.app.create("block.figcaption",a)),this.app.broadcast("image."+(e?"select":"upload"),{instance:s,data:t[i]}),this.$last=s.getBlock(),this.imageslen++)},remove:function(){this.app.popup.close(),this.app.block.remove()},error:function(t){this.app.broadcast("image.upload.error",{response:t})},getStates:function(){var t,e,i,s=this._findImages();for(t in this.dataStates)this.dataStates.hasOwnProperty(t)&&(e=this.dataStates[t],i=s.is('[data-image="'+e.id+'"]'),this._setImageState(e.id,i));return this.dataStates},createUploadBox:function(t,e){if(t)return t=this.dom("<div>"),e.append(t),t},createSelectBox:function(t,e,i){t&&(this.$selectbox=this._createImagesBox(e),"object"==typeof t?this._parseList(t,i):(e=this.opts.editor.reloadmarker?{d:(new Date).getTime()}:{},this.ajax.request(this.opts.image.selectMethod,{url:t,data:e,success:function(t){this._parseList(t,i)}.bind(this)})))},_findImages:function(){return this.app.editor.getEditor().find("[data-image]")},_addImageState:function(t){var e=t.attr("data-image");this.dataStates[e]={type:"image",status:!0,url:t.attr("src"),$img:t,id:e}},_setImageState:function(t,e){this.dataStates[t].status=e},_checkImageLoad:function(){this.imagescount++,this.imagescount===this.imageslen&&(this.app.block.unset(),this.app.block.set(this.$last))},_buildEditUpload:function(){var t,e,i;this.opts.image.upload&&(i=this.app.block.get(),t=this.app.popup.getBody(),(e=this._createFormItem()).addClass(this.prefix+"-form-item-edit-image-box"),this.$imageclone=i.getImage().clone(),this.$imageclone.removeAttr("width height style"),(i=this.dom("<div>").addClass(this.prefix+"-form-item-image")).append(this.$imageclone),e.append(i),this.$upload=this.dom("<div>"),e.append(this.$upload),t.prepend(e),this._buildUpload(this.$upload,"image.changeClone"))},_buildUpload:function(t,e){this.opts.image.upload&&(e={box:!0,placeholder:this.lang.get("image.upload-new-placeholder"),url:this.opts.image.upload,name:this.opts.image.name,data:this.opts.image.data,multiple:this.opts.image.multiple,success:e,error:"image.error"},this.app.create("upload",t,e))},_createSelectBox:function(t){this.createSelectBox(this.opts.image.select,t,"image.insertFromSelect")},_createUploadBox:function(t){this.$upload=this.createUploadBox(this.opts.image.upload,t),this._buildUpload(this.$upload,"image.insertByUpload")},_createImageFromResponseItem:function(t){for(var e,i=this.dom("<img>").attr("src",t.url).one("load",this._checkImageLoad.bind(this)),s=i,a=["id","alt","width","height"],n=0;n<a.length;n++)Object.prototype.hasOwnProperty.call(t,a[n])&&s.attr(a[n],t[a[n]]);return Object.prototype.hasOwnProperty.call(t,"id")&&s.attr("data-image",t.id),Object.prototype.hasOwnProperty.call(t,"2x")&&s.attr("srcset",t["2x"]+" 2x"),Object.prototype.hasOwnProperty.call(t,"link")&&((e=this.dom("<a>")).attr("href",t.link),i.wrap(e),s=e),s},_createImagesBox:function(t){var e=this.dom("<div>").addClass(this.prefix+"-popup-images-box");return t.append(e),e},_createOrSection:function(t){var e;this.opts.image.url&&(this.opts.image.upload||this.opts.image.select)&&((e=this.dom("<div>").addClass(this.prefix+"-popup-image-section-or")).html(this.lang.get("image.or")),t.append(e))},_createImageByUrl:function(t){var e;this.opts.image.url&&(e=this._createFormItem(),this.$urlinput=this._createUrlInput(),this.$urlbutton=this._createUrlButton(),e.append(this.$urlinput),e.append(this.$urlbutton),t.append(e),this.$urlinput.focus())},_createFormItem:function(){return this.dom("<div>").addClass(this.prefix+"-form-container-flex")},_createUrlInput:function(){var t=this.dom("<input>").addClass(this.prefix+"-form-input");return t.attr("placeholder",this.lang.get("image.url-placeholder")),t},_createUrlButton:function(){var t=this.dom("<button>").addClass(this.prefix+"-form-button "+this.prefix+"-form-button-primary");return t.html(this.lang.get("buttons.insert")),t.one("click",this.insertByUrl.bind(this)),t},_parseList:function(t,e){for(var i in t)if(t.hasOwnProperty(i)){var s=t[i];if("object"==typeof s){for(var a=this.dom("<img>"),i=s.thumb||s.url,n=(a.addClass(this.prefix+"-popup-event"),a.attr("src",i),a.attr("data-url",s.url),a.attr("data-callback",e),["id","alt","caption","link","width","height"]),o=0;o<n.length;o++)Object.prototype.hasOwnProperty.call(s,n[o])&&a.attr("data-"+n[o],s[n[o]]);a.on("click."+this.prefix+"-popup-event-"+this.uuid,function(t){var e=this.dom(t.target).attr("data-callback");this.app.api(e,t)}.bind(this)),this.$selectbox.append(a)}}},_dataURLtoFile:function(t,e){for(var t=t.split(","),i=t[0].match(/:(.*?);/)[1],s=atob(t[1]),a=s.length,n=new Uint8Array(a);a--;)n[a]=s.charCodeAt(a);return new File([n],e,{type:i})}}),t.add("module","link",{popups:{format:{items:{format:{title:"## link.link ##",command:"link.format",shortcut:"Ctrl+k"},unlink:{title:"## link.unlink ##",command:"link.unlink"}}},change:{items:{edit:{title:"## link.edit-link ##",command:"link.format",shortcut:"Ctrl+k"},unlink:{title:"## link.unlink ##",command:"link.unlink"}}},create:{title:"## popup.link ##",width:"600px",form:{text:{type:"input",label:"## link.text ##"},url:{type:"input",label:"## link.url ##"},target:{type:"checkbox",text:"## link.link-in-new-tab ##"}},footer:{insert:{title:"## buttons.insert ##",command:"link.insert",type:"primary"},cancel:{title:"## buttons.cancel ##",command:"popup.close"}}},edit:{title:"## popup.link ##",width:"600px",form:{text:{type:"input",label:"## link.text ##"},url:{type:"input",label:"## link.url ##"},target:{type:"checkbox",text:"## link.link-in-new-tab ##"}},footer:{save:{title:"## buttons.save ##",command:"link.save",type:"primary"},cancel:{title:"## buttons.cancel ##",command:"popup.close"}}}},popup:function(t,e){var i=0===this.getLink().length?"format":"change";this.app.popup.create("link-items",this.popups[i]),this.app.popup.open({button:e})},format:function(t){this.app.selection.restore();var e=this.getLink(),i=0!==e.length,s=this.app.selection.getText(),a=(this.app.selection.save(),i?"edit":"create"),a=(this.app.popup.create("link",this.popups[a]),{}),a=i?(a={text:e.text(),url:e.attr("href"),target:e.attr("target")||this.opts.link.target},this._encodeUrl(a)):{text:s,target:this.opts.link.target};this.app.popup.setData(a),this.app.popup.open(i?{focus:"url"}:{focus:s?"url":"text"})},insert:function(){this.app.popup.close();var t=this.app.inline.set({tag:"a",caret:"after"}),t=this.dom(t);this._save(t,"add")},save:function(){this.app.popup.close();var t=this.getLink();this._save(t,"change")},unlink:function(){this.app.popup.close();var t=this.app.selection.getNodes({tags:["a"]});if(0!==t.length){for(var e=0;e<t.length;e++){var i=this.dom(t[e]);this.app.broadcast("link.remove",{url:i.attr("href"),text:i.text()}),i.unwrap()}this.app.toolbar.observe(),this.app.context.observe()}},getLink:function(){var t=this.app.selection.getNodes({tags:["a"]});return 0!==t.length?this.dom(t[0]):this.dom()},_save:function(t,e){var i=this.app.popup.getData(),i=this._cleanUrl(i);""===(i=this._encodeUrl(i)).url?t.unwrap():(i=this._setUrl(t,i),1===t.length&&(i=this._setText(t,i)),(i=this._setTarget(t,i)).element=t,this.app.broadcast("link."+e,i))},_cleanUrl:function(t){return t.url=this.app.content.escapeHtml(t.url),t.url=-1!==t.url.search(/^javascript:/i)?"":t.url,t},_encodeUrl:function(t){return t.url=t.url?t.url.replace(/&/g,"&"):"",t},_setUrl:function(t,e){return t.attr("href",e.url),e},_setText:function(t,e){return e.text=""===e.text?e.url:e.text,t.text(e.text),e},_setTarget:function(t,e){return e.target?t.attr("target","_blank"):t.removeAttr("target"),e}}),t.add("module","table",{popups:{cell:{title:"## table.column ##",width:"300px",form:{width:{type:"input",label:"## table.width ##"},nowrap:{type:"checkbox",text:"## table.nowrap ##"}},footer:{insert:{title:"## buttons.save ##",command:"table.save",type:"primary"},cancel:{title:"## buttons.cancel ##",command:"popup.close"}}}},items:{addhead:{title:"## table.add-head ##",command:"table.addHead"},addcolumnafter:{title:"## table.add-column-after ##",command:"table.addColumnAfter"},addcolumnbefore:{title:"## table.add-column-before ##",command:"table.addColumnBefore"},addrowbelow:{title:"## table.add-row-below ##",command:"table.addRowBelow"},addrowabove:{title:"## table.add-row-above ##",command:"table.addRowAbove"},removehead:{title:"## table.remove-head ##",command:"table.removeHead",divider:"top"},removecolumn:{title:"## table.remove-column ##",command:"table.removeColumn"},removerow:{title:"## table.remove-row ##",command:"table.removeRow"},removetable:{title:"## table.delete-table ##",command:"table.removeTable",divider:"top"}},add:function(){var t=this.app.block.add({name:"table",source:this.opts.table.template,caret:"start"}).getFirstCell();t&&this.app.caret.set(t.getBlock(),"start")},observe:function(t,e,i){var s;return!!this.opts.table&&(s=this.app.block.get(),i&&"addbar"===i.getName()?t.command="table.add":s&&s.isType(["table","cell"])&&(t.command="table.popup"),t)},popup:function(t,e){this.app.popup.create("table",{items:this.items}),this.app.popup.open({button:e})},addHead:function(){var t=this.app.block.get().getTable().getBlock(),e=(this.removeHead(),t.find("tr").first().children("td, th").length),i=this.dom("<thead>"),e=this._buildRow(!1,e,"<th>");i.append(e),t.prepend(i),this.app.block.set(e.children("td, th").first(),"start")},addRowBelow:function(){this._addRow("below")},addRowAbove:function(){this._addRow("above")},addColumnBefore:function(){this._addColumn("before")},addColumnAfter:function(){this._addColumn("after")},removeTable:function(){this.app.popup.close(),this.app.block.remove()},removeHead:function(){this.app.popup.close();var t=this.app.block.get().getTable(),e=t.getBlock().find("thead");0!==e.length&&e.remove(),t.getFirst().setCaret("start")},removeRow:function(){this.app.popup.close(),this.app.control.close();var t=this.app.block.get(),e=t.getTable(),t=t.getRow(),i=t.getBlock().closest("thead");0!==i.length?(i.remove(),e.getFirst().setCaret("start")):t.remove()},removeColumn:function(){this.app.popup.close(),this.app.control.close();var i=this.app.block.get().getBlock(),t=i.closest("table"),e=i.closest("tr"),s=0;e.find("td, th").each(function(t,e){t.get()===i.get()&&(s=e)}),t.find("tr").each(function(t){t=t.find("td, th").get(s);this.dom(t).remove()}.bind(this))},cellSetting:function(t,e){var i=this.app.block.get();this.app.popup.create("cell",this.popups.cell).setData({width:i.getWidth(),nowrap:i.getNowrap()}),this.app.popup.open({button:e,focus:"width"})},save:function(t){this.app.popup.close();var t=t.getData(),e=this.app.block.get();""!==t.width&&e.setWidth(t.width),e.setNowrap(t.nowrap)},_addColumn:function(s){this.app.popup.close();var a,i=this.app.block.get().getBlock(),t=i.closest("table"),n=i.closest("tr"),o=0,r=(n.find("td, th").each(function(t,e){t.get()===i.get()&&(o=e)}),0);t.find("tr").each(function(t,e){t.get()===n.get()&&(r=e)}),t.find("tr").each(function(t,e){var t=t.find("td, th").get(o),t=this.dom(t),i=t.clone();i.html(""),this.app.create("block.cell",i),r===e&&(a=i),t[s](i)}.bind(this)),a&&this.app.block.set(a,"start")},_addRow:function(t){this.app.popup.close();var t="below"===t?"after":"before",e=this.app.block.get().getBlock(),i=e.closest("tr"),e=e.closest("thead"),s=i.children("td, th").length,s=this._buildRow(i,s,"<td>");0!==e.length?e.after(s):i[t](s),this.app.block.set(s.find("td, th").first(),"start")},_buildRow:function(t,e,i){if(!1===t){t=this.dom("<tr>");for(var s=0;s<e;s++){var a=this.dom(i);this.app.create("block.cell",a),t.append(a)}}else(t=t.clone()).find("td, th").html("");return this.app.create("block.row",t),t.find("td, th").each(function(t){this.app.create("block.cell",t)}.bind(this)),t}}),t.add("module","context",{init:function(){this.customButtons={},this.activeClass="active",this.eventname="."+this.prefix+"-context",this.aTags={},this.aTypes={},this.clickOffset=!1},start:function(){this.opts.context&&this._build()},stop:function(){this.app.scroll.isTarget()&&this.app.scroll.getTarget().off(this.eventname),this.opts.context&&this.$context.remove()},isOpen:function(){this.$context.hasClass("open")},close:function(){this.opts.context&&this._close()},add:function(t,e){this.customButtons[t]=e},observe:function(){this.opts.context&&this._observe()},updatePosition:function(){this.opts.context&&this._buildPosition(!1)},_doOpen:function(t){!1===this.opts.context||this.app.utils.isMobile()||setTimeout(function(){this._isSelection()?this._open(t):this._isInstance()&&this.clickOffset&&this.clickOffset.x===t.pageX&&this.clickOffset.y===t.pageY?(this.clickOffset=!1,this._open(t)):(this._close(),this.clickOffset={x:t.pageX,y:t.pageY})}.bind(this),0)},_open:function(t){this.$context.html(""),this._buildButtons(),this._buildCustomButtons(),this._buildActiveButtons(),this._buildPosition(t),this._buildEvents(),this._observe()},_close:function(){this.$context.removeClass("open"),this.$context.hide(),this.app.editor.getEditor().off(this.eventname),this.app.scroll.isTarget()&&this.app.scroll.getTarget().off(this.eventname)},_isSelection:function(){return!this.app.blocks.is()&&this._isInstance()&&this.app.selection.is()&&!this.app.selection.isCollapsed()},_isInstance:function(){var t=this.app.block.get(),e=t&&t.isEditable(),t=t&&"pre"!==t.getType();return e&&t},_scroll:function(){var t,e,i=this.app.selection.getPosition().bottom+this.app.$doc.scrollTop();this.$context.css("top",i+2+"px"),this.app.scroll.isTarget()&&(t=(e=this.app.scroll.getTarget()).offset().top+e.height(),e=e.offset().top,t<i+this.$context.height()||i<e?this.$context.hide():this.$context.show())},_build:function(){this.$context=this.dom("<div>").addClass(this.prefix+"-context "+this.prefix+"-context-"+this.uuid).hide(),this.app.$body.append(this.$context),this.app.editor.getEditor().on("mouseup."+this.prefix+"-context-up",this._doOpen.bind(this))},_buildButtons:function(){for(var t=this.opts.buttons.context,e=h.extend(!0,{},this.opts.buttonsObj),i=0;i<t.length;i++){var s=t[i],a=e[s];this.app.create("button",s,a,this.$context,"context")}},_buildCustomButtons:function(){var t,e=this.customButtons;for(t in e)e.hasOwnProperty(t)&&this.app.create("button",t,e[t],this.$context,"context")},_buildPosition:function(t){var e=this.$context.width(),i=this.app.editor.getRect(),s=this.app.selection.getPosition(),a=this.app.selection.getPosition("end"),t=(t?t.pageX:a.left)-e/2,a=s.bottom+this.app.$doc.scrollTop();(t=t<i.left?i.left+4:t)+e>i.right&&(t=i.right-e-4),this.$context.css({left:t+"px",top:a+2+"px"}),this.$context.addClass("open"),this.$context.show()},_buildEvents:function(){var t=this.app.editor.getEditor();t.on("mousedown"+this.eventname,this._close.bind(this)),t.on("keydown"+this.eventname,this._close.bind(this)),this.app.scroll.isTarget()&&this.app.scroll.getTarget().on("scroll"+this.eventname,this._scroll.bind(this))},_buildActiveButtons:function(){var t=this.app.observer.buildActiveButtons(this.customButtons);this.aTags=t.tags,this.aTypes=t.types},_observe:function(){var t;this._unsetActive(),this.app.observer.isButtons()&&(t=this.app.observer.buildButtons(this.aTags,this.aTypes),this._setActiveKeys(t))},_setActiveKeys:function(t){for(var e=0;e<t.length;e++)this._findButton(t[e]).addClass(this.activeClass)},_unsetActive:function(){this._findButtons().removeClass(this.activeClass)},_findButtons:function(){return this.$context.find("."+this.prefix+"-button-context")},_findButton:function(t){return this.$context.find("[data-name="+t+"]")}}),t.add("module","topbar",{init:function(){this.activeClass="active",this.toggledClass="disable",this.disableClass="disable",this.customButtons={}},start:function(){this._isTopbar()&&this._build()},load:function(){this._buildButtons()},get:function(t){return this._findButton(t)},add:function(t,e){this.customButtons[t]=e},setToggled:function(t){this._isTopbar()&&(this._findButtons().removeClass(this.toggledClass),this._findButton(t).addClass(this.toggledClass))},unsetToggled:function(t){this._isTopbar()&&(t?this._findButton(t):this._findButtons()).removeClass(this.toggledClass)},enable:function(){this._isTopbar()&&this._findButtons().removeClass(this.disableClass)},disable:function(){this._isTopbar()&&this._findButtons().removeClass(this.toggledClass).removeClass(this.activeClass).addClass(this.disableClass)},_isTopbar:function(){return this.opts.topbar},_build:function(){this.$topbar=this.dom("<div>").addClass(this.prefix+"-topbar"),this.app.container.get("toolbar").append(this.$topbar)},_buildButtons:function(){var t,e=this.app.editor.getButtonsFromArr(this.opts.buttons.topbar),e=h.extend(!0,{},e,this.customButtons);for(t in e=this.opts.topbar.add?h.extend(!0,{},e,this.opts.topbar.add):e)!e.hasOwnProperty(t)||this.opts.topbar.hide&&-1!==this.opts.topbar.hide.indexOf(t)||this.app.create("button",t,e[t],this.$topbar,"topbar")},_findButtons:function(){return this.$topbar.find("."+this.prefix+"-button-topbar")},_findButton:function(t){return this.$topbar.find("[data-name="+t+"]")}}),t.add("module","control",{init:function(){this.instance=!1,this.customItems={},this.eventName=this.prefix+"-control"},start:function(){this._build()},stop:function(){this._isControl()&&this.$control.remove(),this.instance=!1},getElement:function(){return this.$control},add:function(t,e){this.customItems[t]=e},build:function(){var t;!this._isControl()||(t=this.app.block.get()).isFigcaption()||((t=t.isSecondLevel()?t.getFirstLevel():t)?this.open(t):this.close())},open:function(t){this._isControl()&&(this.instance=t,this.instance?(this.$control.show(),this.updatePosition(),(t=this.app.scroll.getTarget()).on("resize."+this.eventName,this.updatePosition.bind(this)),t.on("scroll."+this.eventName,this.updatePosition.bind(this)),this.$button.off("."+this.prefix+"-control-button"),this.app.$win.off("."+this.prefix+"-control-button"),this.opts.control&&this.$button.on("click."+this.prefix+"-control-button",this._click.bind(this)),this.opts.reorder&&this.$button.on("mousedown."+this.prefix+"-control-button touchstart."+this.prefix+"-control-button",this._press.bind(this))):this.close())},close:function(){var t;this._isControl()&&(this.$control.hide(),this.instance&&(t=this.instance.getBlock(),this.app.content.unfixListMargin(t)),this.app.scroll.getTarget().off("."+this.eventName),this.instance=!1)},updatePosition:function(){var t,e,i,s;this._isControl()&&(this.instance?("list"===this.instance.getType()&&(t=this.instance.getBlock(),this.app.content.fixListMargin(t)),t=this.instance.isEditable(),e=this.instance.getOffset(),s=this.$control.width(),t=e.top-(t?-3:4),e=e.left-s-4,this.$control.show(),this.app.scroll.isTarget()&&(i=(s=this.app.scroll.getTarget()).offset().top+s.height(),s=s.offset().top,i<t+this.$control.height()||t<s)&&this.$control.hide(),this.$control.css({top:t+"px",left:e+"px"})):this.close())},_isControl:function(){return this.opts.control||this.opts.reorder},_click:function(t){t.preventDefault(),t.stopPropagation();var e,i={},s=this.app.editor.getButtonsFromArr(this.instance.control);for(e in s=h.extend(!0,{},s,this.customItems))this.instance.isAllowedButton(e,s[e])&&(i[e]=s[e],i[e].icon=s[e].icon||!0,i[e].control=!0);this.app.popup.create("control",{items:i}),this.app.context.close(),this.app.popup.open({control:this.$button})},_press:function(t){t.preventDefault(),t.stopPropagation(),setTimeout(function(){this.app.$win.on("mouseup."+this.prefix+"-control-button touchend."+this.prefix+"-control-button",this._release.bind(this)),this.app.$win.on("mousemove."+this.prefix+"-control-button touchmove."+this.prefix+"-control-button",this._move.bind(this))}.bind(this),0)},_release:function(t){this.$button.removeClass(this.prefix+"-handle"),this.app.$win.off("."+this.prefix+"-control-button"),this.app.observer.trigger=!0,this.app.event.trigger=!1,this.oldY=0,this.dragging=!1,this._trashDragItem(),this.updatePosition(),this.$control.show(),setTimeout(function(){this.app.block.set(this.instance,"start",!0),this.app.event.trigger=!0}.bind(this),2)},_move:function(t){t.preventDefault(),this.$button.hasClass(this.prefix+"-handle")||(s=this.instance.getBlock().get(),this.$button.addClass(this.prefix+"-handle"),this.dragging=!0,this.$dragItem=this._makeDragItem(s,t.target),this.$control.hide());for(var e,i,s=!1,a=0===this.oldY?0:this.oldY-t.pageY,a=(0<a?s="up":a<0&&(s="down"),this._moveItem(this.$dragItem,a),this.oldY=t.pageY,t.pageY),t=this.app.editor.getRect(),n=this.app.$doc.scrollTop(),o=n>t.top?n+40:t.top+40,r=this.app.$win.height()+n-40,p=t.top,l=t.top+this.app.editor.getEditor().height(),h=(this.app.scroll.isTarget()&&(p=(i=(e=this.app.scroll.getTarget()).offset()).top,o=n>t.top?i.top+40:o,r=(l=i.top+e.height())-40),"up"===s&&a<o&&p<a?this._scroll(-10):"down"===s&&r<a&&a<l&&this._scroll(10),this.app.editor.getEditor().children()),c=h.length,d=0;d<c;d++){var u=h.eq(d).get();u!==this.$clickItem.get()&&this._isOver(this.dom(u))&&this._swapItems(u)}},_build:function(){this.$control=this.dom("<div>").addClass(this.prefix+"-control "+this.prefix+"-control-"+this.uuid).hide(),this.$button=this.dom("<span>").addClass(this.prefix+"-icon-sort "+this.prefix+"-button "+this.prefix+"-button-control"),this.$control.append(this.$button),this.opts.bsmodal&&this.$control.css("z-index",1060),this.app.$body.append(this.$control)},_isOver:function(t){var e=this.$dragItem.offset().top,i=t.offset(),t=t.height();return e>i.top&&e<i.top+t},_scroll:function(t){var e=this.app.scroll.isTarget()?this.app.scroll.getTarget():this.app.$win,i=e.scrollTop();e.scrollTop(i+t)},_swapItems:function(t){var e=this.$dragItem.offset().top,i=this.$clickItem,t=this.dom(t),s=t.offset(),a=t.height()/2;t[a+s.top>e?"before":"after"](i)},_moveItem:function(t,e){var i=t.offset().top;t.css("top",(i-=e)+"px"),this.$control.css("top",i+"px")},_makeDragItem:function(t){this._trashDragItem();var t=this.dom(t),e=t.offset(),i=(this.$clickItem=t,this.$clickItem.addClass(this.prefix+"-drag-active"),t.clone()),s=(i.removeClass(this.prefix+"-drag-active "+this.prefix+"-element-active"),i.css({"font-family":t.css("font-family"),"font-size":t.css("font-size"),"line-height":t.css("line-height"),margin:0,padding:0}),this.dom("<div>").addClass(this.prefix+"-dragging"));return s.append(i),s.css({opacity:.95,position:"absolute","z-index":999,left:e.left+"px",top:e.top+"px",width:t.width()+"px"}),this.app.$body.append(s),s},_trashDragItem:function(){this.$dragItem&&this.$clickItem&&(this.$clickItem.removeClass(this.prefix+"-drag-active"),this.$clickItem=null,this.$dragItem.remove(),this.$dragItem=null)}}),t.add("class","tool.checkbox",{mixins:["tool"],type:"checkbox",input:{tag:"input",type:"checkbox",classname:"-form-checkbox"},getValue:function(){return this.$input.val()},_buildInput:function(){var t;this.$box=this.dom("<label>").addClass(this.prefix+"-form-checkbox-item"),this.$box.append(this.$input),this._has("text")&&(t=this.dom("<span>").html(this.lang.parse(this.obj.text)),this.$box.append(t)),this.$tool.append(this.$box)}}),t.add("class","tool.input",{mixins:["tool"],type:"input",input:{tag:"input",type:"text",classname:"-form-input"},_buildInput:function(){this.$tool.append(this.$input)}}),t.add("class","tool.number",{mixins:["tool"],type:"number",input:{tag:"input",type:"number",classname:"-form-input"},_buildInput:function(){this.$input.attr("min",0).css("max-width","65px"),this.$tool.append(this.$input)}}),t.add("class","tool.segment",{mixins:["tool"],type:"segment",input:{tag:"input",type:"hidden",classname:"-form-input"},setValue:function(t){this.$segment.find("."+this.prefix+"-form-segment-item").removeClass("active"),this.$segment.find("[data-segment="+t+"]").addClass("active"),this.$input.val(t)},_buildInput:function(){this.$segment=this.dom("<div>").addClass(this.prefix+"-form-segment");var t,e,i=this.obj.segments;for(t in i)i.hasOwnProperty(t)&&((e=this.dom("<span>").addClass(this.prefix+"-form-segment-item")).attr("data-segment",t).on("click",this._catchSegment.bind(this)),Object.prototype.hasOwnProperty.call(i[t],"icon")?e.html(i[t].icon):e.addClass(this.prefix+"-icon-"+i[t].prefix+"-"+t),this.$segment.append(e));this.$segment.append(this.$input),this.$tool.append(this.$segment)},_catchSegment:function(t){t.preventDefault(),t.stopPropagation();var t=this.dom(t.target).closest("."+this.prefix+"-form-segment-item"),e=t.attr("data-segment");this.$segment.find("."+this.prefix+"-form-segment-item").removeClass("active"),t.addClass("active"),this.$input.val(e),this.app.api(this.setter,this.popup)}}),t.add("class","tool.select",{mixins:["tool"],type:"select",input:{tag:"select",classname:"-form-select"},_buildInput:function(){for(var t in this.obj.options){var e;this.obj.options.hasOwnProperty(t)&&((e=this.dom("<option>")).val(t),e.html(this.lang.parse(this.obj.options[t])),this.$input.append(e))}this.$tool.append(this.$input)}}),t.add("class","tool.textarea",{mixins:["tool"],type:"textarea",input:{tag:"textarea",classname:"-form-textarea"},setFocus:function(){this.$input.focus(),this.$input.get().setSelectionRange(0,0),this.$input.scrollTop(0)},_buildInput:function(){this._has("rows")&&this.$input.attr("rows",this._get("rows")),this.$input.attr("data-gramm_editor",!1),this.$tool.append(this.$input)}}),t.add("class","tool.upload",{mixins:["tool"],type:"upload",input:{tag:"input",type:"hidden",classname:"-form-input"},setValue:function(t){t=t||"",this.upload&&this.upload.setImage(t),this.$input.val(t)},_buildInput:function(){this.$tool.append(this.$input),this._buildUpload()},_buildUpload:function(){this.$upload=this.dom("<input>").attr("type","file"),this.$tool.append(this.$upload);var t={};this._has("trigger")&&this._get("trigger")&&(t={instance:this,method:"trigger"}),this.upload=this.app.create("upload",this.$upload,this.obj.upload,t)}}),t.add("block","block.address",{mixins:["block"],type:"address",editable:!0,toolbar:{add:{title:"## buttons.add ##",command:"addbar.popup"},html:{title:"## buttons.html ##",command:"source.toggle"},format:{title:"## buttons.format ##",command:"format.popup"},bold:{title:"## buttons.bold ##",command:"inline.set",params:{tag:"b"}},italic:{title:"## buttons.italic ##",command:"inline.set",params:{tag:"i"}},deleted:{title:"## buttons.deleted ##",command:"inline.set",params:{tag:"del"}},link:{title:"## buttons.link ##",command:"link.popup"}},control:{add:{title:"## buttons.add ##",command:"addbar.popup"},format:{title:"## buttons.format ##",command:"format.popup"},duplicate:{title:"## buttons.duplicate ##",command:"block.duplicate"},trash:{title:"## buttons.delete ##",command:"block.remove"}},create:function(){return this.dom("<address>")},handleEnter:function(t){if(t.preventDefault(),this.isEmpty()||this.isCaretEnd()){var t=this.getBlock(),e=t.children(),i=e.length,s=e.eq(i-1),e=e.eq(i-2),i=t.html().trim();if(-1!==(i=this.app.utils.removeInvisibleChars(i)).search(/<br\s?\/?>$/))return e.remove(),s.remove(),void this.insertEmpty({position:"after",caret:"start"})}return this.app.insertion.insertBreakline(),!0}}),t.add("block","block.cell",{mixins:["block"],type:"cell",editable:!0,create:function(){return this.dom("<td>")},getTable:function(){return this.getParent("table")},getRow:function(){return this.getParent("row")},getNextCell:function(){var t,e=this.getNext();return e||(t=this.getParent("row"))&&(t=t.getNextRow())&&(e=t.getChildFirst("cell")),e},getPrevCell:function(){var t,e=this.getPrev();return e||(t=this.getParent("row"))&&(t=t.getPrevRow())&&(e=t.getChildLast("cell")),e},getWidth:function(){var t=this.$block.attr("width");return t||""},getNowrap:function(){return this.$block.hasClass(this.prefix+"-nowrap")},setWidth:function(e){this._eachCell(function(t){""===e?t.removeAttr("width"):(e=-1!==e.search("%")?e:e.replace("px",""),t.attr("width",e))})},setNowrap:function(i){this._eachCell(function(t){var e=this.opts.table.nowrap+" "+this.prefix+"-nowrap";i?t.addClass(e):t.removeClass(e)}.bind(this))},handleArrow:function(t,e,i){var s,a,n=this.getTable(),o=n.getBlock(),r=this.app.caret.is(o,"start"),o=this.app.caret.is(o,"end");return i.is("up-left")&&r?(t.preventDefault(),(s=n.getPrev())?this.app.block.set(s,"end"):this.app.insertion.insertEmptyBlock({current:n,position:"before",caret:"start"}),!0):i.is("down-right")&&o?(t.preventDefault(),(a=n.getNext())?this.app.block.set(a,"start"):this.app.insertion.insertEmptyBlock({current:n,position:"after",caret:"start"}),!0):i.is("up-left")&&this.isCaretStart()?(t.preventDefault(),(s=(s=this.getPrevCell())||this.getFirstLevel().getPrev())&&this.app.block.set(s,"end"),!0):i.is("down-right")&&this.isCaretEnd()?(t.preventDefault(),(a=(a=this.getNextCell())||this.getFirstLevel().getNext())&&this.app.block.set(a,"start"),!0):void 0},handleTab:function(t){t.preventDefault();t=this.getNextCell();return(t=t||this.getFirstLevel().getNext())&&this.app.block.set(t,"start"),!0},handleEnter:function(t){return t.preventDefault(),this.app.insertion.insertBreakline(),!0},_eachCell:function(e){var i=0,t=this.$block.closest("table");this.$block.closest("tr").find("td, th").each(function(t,e){t.get()===this.$block.get()&&(i=e)}.bind(this)),t.find("tr").each(function(t){t=t.find("td, th").get(i),t=this.dom(t);e(t)}.bind(this))}}),t.add("block","block.pre",{mixins:["block"],type:"pre",editable:!0,toolbar:{add:{title:"## buttons.add ##",command:"addbar.popup"},html:{title:"## buttons.html ##",command:"source.toggle"}},control:{add:{title:"## buttons.add ##",command:"addbar.popup"},duplicate:{title:"## buttons.duplicate ##",command:"block.duplicate"},trash:{title:"## buttons.delete ##",command:"block.remove"}},create:function(){return this.dom(this.opts.pre.template)},build:function(){this._buildCaption(),this._buildItems("figcaption","figcaption")},handleTab:function(t){t.preventDefault();t=this.opts.pre.spaces,t=document.createTextNode(Array(t+1).join(" "));return this.app.insertion.insertNode(t,"end"),!0},handleEnter:function(t){t.preventDefault();t=this.$block.html().search(/\n$/);return this.isCaretEnd()&&-1===t?this.app.insertion.insertNewline("after",!0):this.app.insertion.insertNewline(),!0}}),t.add("block","block.embed",{mixins:["block"],type:"embed",editable:!1,toolbar:{add:{title:"## buttons.add ##",command:"addbar.popup"},html:{title:"## buttons.html ##",command:"source.toggle"},embed:{title:"## blocks.embed ##",command:"embed.popup",observer:"embed.observe"}},control:{add:{title:"## buttons.add ##",command:"addbar.popup"},duplicate:{title:"## buttons.duplicate ##",command:"block.duplicate"},trash:{title:"## buttons.delete ##",command:"block.remove"}},create:function(){return this.dom("<figure>")},build:function(){this._buildCaption(),this._buildItems("figcaption","figcaption"),this._buildEmbedCode()},addResponsive:function(){var t=this.dom("<div>").addClass(this.opts.embed.responsive),e=this.$block.find("figcaption"),i=e.clone(),s=this.getEmbedCode();e.remove(),t.html(s),this.$block.html("").append(t),0!==i.length&&(this.app.create("block.figcaption",i),this.$block.append(i)),this._buildEmbedCode()},removeResponsive:function(){this.$block.find(this._getEmbedClass()).unwrap()},getEmbedCode:function(){return decodeURI(this.$block.attr("data-embed-code"))},isResponsive:function(){return 0!==this.$block.find(this._getEmbedClass()).length},_buildEmbedCode:function(){var t=this.$block.clone(),t=(t.find(this._getEmbedClass()).unwrap(),t.find("figcaption").remove(),t.html().trim());this.$block.attr("data-embed-code",encodeURI(t))},_getEmbedClass:function(){return"."+this.opts.embed.responsive.replace(/ +/g,".")}}),t.add("block","block.figcaption",{mixins:["block"],type:"figcaption",editable:!0,toolbar:{bold:{title:"## buttons.bold ##",command:"inline.set",params:{tag:"b"}},italic:{title:"## buttons.italic ##",command:"inline.set",params:{tag:"i"}},deleted:{title:"## buttons.deleted ##",command:"inline.set",params:{tag:"del"}},link:{title:"## buttons.link ##",command:"link.popup"}},create:function(){return this.dom("<figcaption>")},getFigure:function(){return this.$block.closest("figure").dataget("instance")},handleArrow:function(t,e,i){if(i.is("up-left")&&this.isCaretStart()||i.is("down-right")&&this.isCaretEnd())return t.preventDefault(),i=this.getFigure(),this.app.block.set(i),!0},handleTab:function(t){t.preventDefault();t=this.getFigure();return this.app.block.set(t),!0},handleEnter:function(t){return t.preventDefault(),this.isEmpty()||this.isCaretEnd()||this.isCaretStart()||this.app.insertion.insertBreakline(),!0}}),t.add("block","block.heading",{mixins:["block"],type:"heading",editable:!0,toolbar:{add:{title:"## buttons.add ##",command:"addbar.popup"},html:{title:"## buttons.html ##",command:"source.toggle"},format:{title:"## buttons.format ##",command:"format.popup"},bold:{title:"## buttons.bold ##",command:"inline.set",params:{tag:"b"}},italic:{title:"## buttons.italic ##",command:"inline.set",params:{tag:"i"}},deleted:{title:"## buttons.deleted ##",command:"inline.set",params:{tag:"del"}},link:{title:"## buttons.link ##",command:"link.popup"}},control:{add:{title:"## buttons.add ##",command:"addbar.popup"},format:{title:"## buttons.format ##",command:"format.popup"},duplicate:{title:"## buttons.duplicate ##",command:"block.duplicate"},trash:{title:"## buttons.delete ##",command:"block.remove"}},create:function(){return this.dom("<h2>")},getTitle:function(){var t=this.lang.get("headings"),e=this.getTag(),i=this.$block.attr("data-title");return void 0!==t[e]?t[e]:i},handleEnter:function(t){return t.preventDefault(),this.isEmpty()||this.isCaretEnd()?this.insertEmpty({position:"after",caret:"start",remove:!1}):this.isCaretStart()?this.insert({instance:this.duplicateEmpty(),position:"before"}):(t=this.getBlock(),t=this.app.element.split(t),this.app.block.set(t,"start")),!0}}),t.add("block","block.image",{mixins:["block"],type:"image",editable:!1,toolbar:{add:{title:"## buttons.add ##",command:"addbar.popup"},html:{title:"## buttons.html ##",command:"source.toggle"},image:{title:"## blocks.image ##",command:"image.popup",observer:"image.observe"}},control:{add:{title:"## buttons.add ##",command:"addbar.popup"},duplicate:{title:"## buttons.duplicate ##",command:"block.duplicate"},trash:{title:"## buttons.delete ##",command:"block.remove"}},create:function(){return this.dom("<"+this.opts.image.tag+">")},build:function(){this._buildCaption(),this._buildItems("figcaption","figcaption"),this.data={alt:{getter:"getAlt",setter:"setAlt"},width:{getter:"getWidth",setter:"setWidth"},link:{getter:"getLinkUrl",setter:"setLinkUrl"},target:{getter:"getTarget",setter:"setTarget"},caption:{getter:"getCaption",setter:"setCaption"}}},getImage:function(){return this.$block.find("img").eq(0)},getSrc:function(){return this.getImage().attr("src")},getId:function(){return this.getImage().attr("data-image")},getLink:function(){var t=this.getImage().parent();return t="A"===t.get().tagName&&t},getWidth:function(){var t=this.getImage(),e=t.css("width"),t=t.attr("width");return e=t&&-1!==t.search(/%/)?t:e},getAlt:function(){var t=this.getImage().attr("alt");return t||""},getLinkUrl:function(){var t=this.getLink();return t?t.attr("href"):""},getTarget:function(){var t=this.getLink();return t?t.attr("target"):this.opts.image.newtab},setWidth:function(t){var e,i,s,a=this.getImage();""===(t=t.trim())?a.removeAttr("width"):(e=(s=-1!==t.search(/%/))?t:parseInt(t),i=a.width()/a.height(),s?(a.removeAttr("height"),a.attr({width:e})):(s=Math.round(e/i),a.attr({width:e,height:s}))),a.css({width:t,"max-width":t}),this.app.broadcast("image.width",{image:a,width:t})},setAlt:function(t){var e=this.getImage();t=t.replace(/"/g,"'"),e.attr("alt",t)},setTarget:function(t){var e=this.getLink();e&&(t?e.attr("target","_blank"):e.removeAttr("target"))},setLinkUrl:function(t){if(i=this.getLink()){if(""===t)return this.removeLink(),void this.app.broadcast("image.unlink",{instance:this});i.attr("href",t)}else if(!i){if(""===t)return;var e=this.getImage(),i=this.dom("<a>");e.wrap(i),i.attr("href",t)}this.app.broadcast("image.link",{instance:this,link:i})},setImage:function(t){var e=this.getImage();e.attr("src",t.url),Object.prototype.hasOwnProperty.call(t,"id")&&e.attr("data-image",t.id),Object.prototype.hasOwnProperty.call(t,"2x")&&e.attr("srcset",t["2x"]+" 2x")},removeLink:function(){var t=this.getLink();t&&t.unwrap()}}),t.add("block","block.line",{mixins:["block"],type:"line",editable:!1,toolbar:{add:{title:"## buttons.add ##",command:"addbar.popup"},html:{title:"## buttons.html ##",command:"source.toggle"}},control:{add:{title:"## buttons.add ##",command:"addbar.popup"},format:{title:"## buttons.format ##",command:"format.popup"},duplicate:{title:"## buttons.duplicate ##",command:"block.duplicate"},trash:{title:"## buttons.delete ##",command:"block.remove"}},create:function(){return this.dom("<hr>")}}),t.add("block","block.list",{mixins:["block"],type:"list",editable:!0,toolbar:{add:{title:"## buttons.add ##",command:"addbar.popup"},html:{title:"## buttons.html ##",command:"source.toggle"},format:{title:"## buttons.format ##",command:"format.popup"},bold:{title:"## buttons.bold ##",command:"inline.set",params:{tag:"b"}},italic:{title:"## buttons.italic ##",command:"inline.set",params:{tag:"i"}},deleted:{title:"## buttons.deleted ##",command:"inline.set",params:{tag:"del"}},indent:{title:"## buttons.indent ##",command:"list.indent"},outdent:{title:"## buttons.outdent ##",command:"list.outdent"},link:{title:"## buttons.link ##",command:"link.popup"}},control:{add:{title:"## buttons.add ##",command:"addbar.popup"},format:{title:"## buttons.format ##",command:"format.popup"},duplicate:{title:"## buttons.duplicate ##",command:"block.duplicate"},trash:{title:"## buttons.delete ##",command:"block.remove"}},create:function(t){return t&&t.tag?this.dom("<"+t.tag+">"):this.dom("<ul>")},setCaret:function(t){var e=this.$block;"start"===t?e=this.$block.find("li").first():"end"===t&&(e=this.$block.find("li").last()),this.app.caret.set(e,t)},setEmpty:function(){this.$block.html("");var t=this.dom("<li>");this.$block.append(t),this.app.caret.set(t,"start")},isEmpty:function(){var t=this.$block.html(),t=this._cleanEmpty(t),e=this.$block.find("li");return 0===e.length?""===(t=t.trim()):1===e.length&&(t=e.eq(0).html(),""===(t=this._cleanEmpty(t)))},handleTab:function(t){var e=this.app.selection.getBlock(),i=this.app.caret.is(e,"start"),e=this.app.element.isEmpty(e);if(e&&(t.preventDefault(),this.app.list.indent()))return!0;if(this.isCaretStart()||this.isCaretEnd()){e=this.getNext();if(e)return t.preventDefault(),this.app.block.set(e,"start"),!0}else if(!this.opts.tab.spaces||i)return t.preventDefault(),this.app.list.indent(),!0},handleEnter:function(t){if(t.preventDefault(),this.isEmpty()||this.isCaretEnd()){if(s=this.app.selection.getBlock(),a=this.dom(s),n=this.app.content.isEmptyHtml(s.innerHTML))return a.remove(),this.insertEmpty({position:"after",caret:"start"}),!0;i=this.dom("<li>"),this.app.element.cloneAttrs(s,i),this.dom(s).after(i),this.app.caret.set(i,"start"),this.app.broadcast("list.item",{element:i})}else if(this.isCaretStart())i=this.dom("<li>"),s=this.app.selection.getBlock(),this.app.element.cloneAttrs(s,i),this.dom(s).before(i);else{var e,i,s=this.app.selection.getBlock(),a=this.dom(s),n=this.app.content.isEmptyHtml(s.innerHTML),o=this.app.caret.is(s,"start"),r=this.app.caret.is(s,"end",["ul","ol"]);if(i=this.dom("<li>"),this.app.element.cloneAttrs(s,i),n){if(a.after(i),this.app.caret.set(i,"start"),n=i.prevElement(),this.app.content.isEmptyHtml(n.html()))return t.preventDefault(),e=this.app.element.split(this.$block),t=this.app.block.create(),this.insert({instance:t,caret:"start"}),i.remove(),n.remove(),void e.find("li").first().remove()}else o?a.before(i):r?(0!==(t=a.find("ul, ol").first()).length&&(i.append(this.app.utils.createInvisibleChar()),i.append(t)),a.after(i),this.app.caret.set(i,"start")):(i=e=this.app.element.split(s),this.app.caret.set(e,"start"));this.app.broadcast("list.item",{element:i})}return!0}}),t.add("block","block.paragraph",{mixins:["block"],type:"paragraph",editable:!0,toolbar:{add:{title:"## buttons.add ##",command:"addbar.popup"},html:{title:"## buttons.html ##",command:"source.toggle"},format:{title:"## buttons.format ##",command:"format.popup"},bold:{title:"## buttons.bold ##",command:"inline.set",params:{tag:"b"}},italic:{title:"## buttons.italic ##",command:"inline.set",params:{tag:"i"}},deleted:{title:"## buttons.deleted ##",command:"inline.set",params:{tag:"del"}},link:{title:"## buttons.link ##",command:"link.popup"}},control:{add:{title:"## buttons.add ##",command:"addbar.popup"},format:{title:"## buttons.format ##",command:"format.popup"},duplicate:{title:"## buttons.duplicate ##",command:"block.duplicate"},trash:{title:"## buttons.delete ##",command:"block.remove"}},create:function(){return this.dom("<p>")},handleEnter:function(t){var e;if(t.preventDefault(),this.isEmpty()||this.isCaretEnd()){if(e=this.app.block.create(),this.opts.clean.enter||(e=this.duplicateEmpty()).getBlock().removeAttr("id"),!this.opts.clean.enterinline){var t=this.app.selection.getInline();if(t){for(var i,s,a=this.app.element.getAllInlines(t),n=0;n<a.length;n++)"A"!==a[n].tagName&&(0===n?((i=a[n].cloneNode()).removeAttribute("id"),i.innerHTML=""):((s=a[n].cloneNode()).removeAttribute("id"),s.innerHTML="",i.appendChild(s)));i&&(e=this.app.block.create(i.outerHTML))}}this.insert({instance:e,position:"after",caret:"start",remove:!1})}else this.isCaretStart()?((e=this.duplicate()).getBlock().html(""),this.insert({instance:e,position:"before"})):(t=this.getBlock(),e=this.app.element.split(t),this.app.block.set(e,"start"));return!0}}),t.add("block","block.quote",{mixins:["block"],type:"quote",toolbar:{add:{title:"## buttons.add ##",command:"addbar.popup"},html:{title:"## buttons.html ##",command:"source.toggle"},bold:{title:"## buttons.bold ##",command:"inline.set",params:{tag:"b"}},italic:{title:"## buttons.italic ##",command:"inline.set",params:{tag:"i"}},deleted:{title:"## buttons.deleted ##",command:"inline.set",params:{tag:"del"}},link:{title:"## buttons.link ##",command:"link.popup"}},control:{add:{title:"## buttons.add ##",command:"addbar.popup"},duplicate:{title:"## buttons.duplicate ##",command:"block.duplicate"},trash:{title:"## buttons.delete ##",command:"block.remove"}},create:function(){return this.dom(this.opts.quote.template)},build:function(){this._buildCaption(),this._buildItems("p","quoteitem"),this._buildItems("figcaption","figcaption")},getLast:function(){return this._getLast()},getFirst:function(){return this._getFirst()},getFirstElement:function(){return this._getFirst().getBlock()},_getFirst:function(){return this.$block.find("p").first().dataget("instance")},_getLast:function(){return this.$block.find("p").last().dataget("instance")}}),t.add("block","block.quoteitem",{mixins:["block"],type:"quoteitem",editable:!0,create:function(){return this.dom("<p>")},getBlockquote:function(){return this.$block.closest("blockquote").dataget("instance")},handleArrow:function(t,e,i){var s,a=this.getBlockquote(),n=a.getBlock();if(0!==n.length)return s=this.app.caret.is(n,"start"),n=this.app.caret.is(n,"end"),i.is("up-left")&&s?(t.preventDefault(),(s=this.getFirstLevel().getPrev())?this.app.block.set(s,"end"):this.app.insertion.insertEmptyBlock({current:a,position:"before",caret:"start"}),!0):i.is("down-right")&&n?(t.preventDefault(),(s=this.getFirstLevel().getNext())?this.app.block.set(s,"start"):this.app.insertion.insertEmptyBlock({current:a,position:"after",caret:"start"}),!0):void 0},handleTab:function(t){t.preventDefault();t=this.getNext();return(t=t||this.getFirstLevel().getNext())&&this.app.block.set(t,"start"),!0},handleEnter:function(t){t.preventDefault();var t=this.app.create("block.quoteitem");return this.isEmpty()||this.isCaretEnd()?this.insert({instance:t,position:"after",caret:"start"}):this.isCaretStart()?this.insert({instance:t,position:"before"}):(t=this.getBlock(),t=this.app.element.split(t),this.app.block.set(t,"start")),!0}}),t.add("block","block.row",{mixins:["block"],type:"row",create:function(){return this.dom("<tr>")},getNextRow:function(){var t=this.getNext(),e=this.$block.parent();return t=t||"TABLE"===e.get().tagName?t:e.nextElement().find("tr").first().dataget("instance")},getPrevRow:function(){var t=this.getPrev(),e=this.$block.parent();return t=t||"TABLE"===e.get().tagName?t:e.prevElement().find("tr").last().dataget("instance")}}),t.add("block","block.table",{mixins:["block"],type:"table",toolbar:{add:{title:"## buttons.add ##",command:"addbar.popup"},html:{title:"## buttons.html ##",command:"source.toggle"},table:{title:"## blocks.table ##",command:"table.add",observer:"table.observe",params:{name:"table"}},bold:{title:"## buttons.bold ##",command:"inline.set",params:{tag:"b"}},italic:{title:"## buttons.italic ##",command:"inline.set",params:{tag:"i"}},deleted:{title:"## buttons.deleted ##",command:"inline.set",params:{tag:"del"}},link:{title:"## buttons.link ##",command:"link.popup"},tune:{title:"## buttons.column-settings ##",command:"table.cellSetting"}},control:{add:{title:"## buttons.add ##",command:"addbar.popup"},table:{title:"## blocks.table ##",command:"table.add",observer:"table.observe",params:{name:"table"}},tune:{title:"## buttons.column-settings ##",command:"table.cellSetting",icon:"tune"},duplicate:{title:"## buttons.duplicate ##",command:"block.duplicate"},trash:{title:"## buttons.delete ##",command:"block.remove"}},create:function(){return this.dom(this.opts.table.template)},build:function(){this._buildItems("tr","row"),this._buildItems("td, th","cell"),this._buildNowrap()},getLast:function(){return this.getLastCell()},getFirst:function(){return this.getFirstCell()},getFirstElement:function(){return this.getFirstCell().getBlock()},getFirstCell:function(){var t=this.$block.find("th, td").first();if(0!==t.length)return t.dataget("instance")},getLastCell:function(){var t=this.$block.find("th, td").last();if(0!==t.length)return t.dataget("instance")},_buildNowrap:function(){this.$block.find("th, td").each(function(t){t.hasClass(this.opts.table.nowrap)&&t.addClass(this.prefix+"-nowrap")}.bind(this))}}),t.add("block","block.layer",{mixins:["block"],type:"layer",nested:!0,toolbar:{add:{title:"## buttons.add ##",command:"addbar.popup"},html:{title:"## buttons.html ##",command:"source.toggle"}},control:{add:{title:"## buttons.add ##",command:"addbar.popup"},duplicate:{title:"## buttons.duplicate ##",command:"block.duplicate"},trash:{title:"## buttons.delete ##",command:"block.remove"}}}),t.add("block","block.dlist",{mixins:["block"],type:"dlist",editable:!0,toolbar:{add:{title:"## buttons.add ##",command:"addbar.popup"},html:{title:"## buttons.html ##",command:"source.toggle"},format:{title:"## buttons.format ##",command:"format.popup"},bold:{title:"## buttons.bold ##",command:"inline.set",params:{tag:"b"}},italic:{title:"## buttons.italic ##",command:"inline.set",params:{tag:"i"}},deleted:{title:"## buttons.deleted ##",command:"inline.set",params:{tag:"del"}},link:{title:"## buttons.link ##",command:"link.popup"}},control:{add:{title:"## buttons.add ##",command:"addbar.popup"},format:{title:"## buttons.format ##",command:"format.popup"},duplicate:{title:"## buttons.duplicate ##",command:"block.duplicate"},trash:{title:"## buttons.delete ##",command:"block.remove"}},create:function(){return this.dom("<dl>")},getPlainText:function(i){var s="",t=this.$block.find("dt, dd"),a=t.length;return t.each(function(t,e){e=e!==a&&i?"<br>":"";s+=t.html()+e}),s},setEmpty:function(){this.$block.html("");var t=this.dom("<dt>");this.$block.append(t),this.app.caret.set(t,"start")},isEmpty:function(){var t=this.$block.html(),t=this._cleanEmpty(t),e=this.$block.find("dt, dd");return 0===e.length?""===(t=t.trim()):1===e.length&&(t=e.eq(0).html(),""===(t=this._cleanEmpty(t)))},handleEnter:function(t,e,i){if(t.preventDefault(),this.isEmpty()||this.isCaretEnd()){var t=this.app.selection.getBlock(),s=this.dom(t),a=t.tagName.toLowerCase(),n=this.app.content.isEmptyHtml(t.innerHTML);if("dt"===a&&n)return s.remove(),this.insertEmpty({position:"after",caret:"start"}),!0;n="dt"===a?this.dom("<dd>"):this.dom("<dt>"),this.dom(t).after(n),this.app.caret.set(n,"start")}else{if(this.isCaretStart())return!0;this.app.insertion.insertBreakline()}return!0}}),window.RedactorX=t,window.addEventListener("load",function(){t("[data-redactorx]")}),"object"==typeof module&&module.exports&&(module.exports=t,module.exports.RedactorX=t)}(),RedactorX.add("plugin","alignment",{translations:{en:{alignment:{alignment:"Alignment"}}},defaults:{align:{left:"align-left",center:"align-center",right:"align-right",justify:"align-justify"}},start:function(){this.app.toolbar.add("alignment",{title:"## alignment.alignment ##",command:"alignment.popup",position:{after:"format"},blocks:{all:"editable"}})},popup:function(t,e){var i,s={},a=this.opts.alignment.align;for(i in a)a[i]&&(s[i]={name:a[i],prefix:"align"});this.app.popup.create("alignment",{setter:"alignment.setAlign",getter:"alignment.getAlign",form:{align:{type:"segment",label:"## alignment.alignment ##",segments:s}}}),this.app.popup.open({button:e})},getAlign:function(){var t=this.opts.alignment.align;if(!t)return!1;var e,i=this.app.block.get().getBlock(),s="left";for(e in t)i.hasClass(t[e])&&(s=e);return{align:s}},setAlign:function(t){this.app.popup.close();t=t.getData();this.app.block.get().setClassFromObj(this.opts.alignment.align,t.align)}}),RedactorX.add("plugin","alignment",{translations:{en:{alignment:{alignment:"Alignment"}}},defaults:{align:{left:"align-left",center:"align-center",right:"align-right",justify:"align-justify"}},start:function(){this.app.toolbar.add("alignment",{title:"## alignment.alignment ##",command:"alignment.popup",position:{after:"format"},blocks:{all:"editable"}})},popup:function(t,e){var i,s={},a=this.opts.alignment.align;for(i in a)a[i]&&(s[i]={name:a[i],prefix:"align"});this.app.popup.create("alignment",{setter:"alignment.setAlign",getter:"alignment.getAlign",form:{align:{type:"segment",label:"## alignment.alignment ##",segments:s}}}),this.app.popup.open({button:e})},getAlign:function(){var t=this.opts.alignment.align;if(!t)return!1;var e,i=this.app.block.get().getBlock(),s="left";for(e in t)i.hasClass(t[e])&&(s=e);return{align:s}},setAlign:function(t){this.app.popup.close(),t=t.getData(),this.app.block.get().setClassFromObj(this.opts.alignment.align,t.align)}}),RedactorX.add("plugin","beyondgrammar",{subscribe:{"editor.docmousedown":function(t){t=t.get("e");t&&this._isPwa(t)&&t.preventDefault()},"editor.before.blur":function(t){var e,i=t.get("e");i&&this._isPwa(i)&&(e=this.app.offset.get(),setTimeout(function(){this.app.offset.set(e)}.bind(this),10),t.stop())},"editor.unparse":function(t){var e=t.get("html"),e=this.app.utils.wrap(e,function(t){t.find(".pwa-mark").unwrap()});t.set("html",e)}},start:function(){this.GrammarChecker=this._getGrammarChecker(),this.opts.beyondgrammar&&this.GrammarChecker&&this._activate()},_isPwa:function(t){return this.dom(t.target).hasClass("pwa-suggest")},_activate:function(){this.$editor=this.app.editor.getEditor(),this.$editor.attr("spellcheck",!1);var t=new this.GrammarChecker(this.$editor.get(),this.opts.beyondgrammar.service,this.opts.beyondgrammar.grammar);t.init().then(function(){t.activate()})},_getGrammarChecker:function(){return void 0!==window.BeyondGrammar&&window.BeyondGrammar.GrammarChecker}}),RedactorX.add("plugin","beyondgrammar",{subscribe:{"editor.docmousedown":function(t){(t=t.get("e"))&&this._isPwa(t)&&t.preventDefault()},"editor.before.blur":function(t){var e,i=t.get("e");i&&this._isPwa(i)&&(e=this.app.offset.get(),setTimeout(function(){this.app.offset.set(e)}.bind(this),10),t.stop())},"editor.unparse":function(t){var e=t.get("html"),e=this.app.utils.wrap(e,function(t){t.find(".pwa-mark").unwrap()});t.set("html",e)}},start:function(){this.GrammarChecker=this._getGrammarChecker(),this.opts.beyondgrammar&&this.GrammarChecker&&this._activate()},_isPwa:function(t){return this.dom(t.target).hasClass("pwa-suggest")},_activate:function(){this.$editor=this.app.editor.getEditor(),this.$editor.attr("spellcheck",!1);var t=new this.GrammarChecker(this.$editor.get(),this.opts.beyondgrammar.service,this.opts.beyondgrammar.grammar);t.init().then(function(){t.activate()})},_getGrammarChecker:function(){return void 0!==window.BeyondGrammar&&window.BeyondGrammar.GrammarChecker}}),RedactorX.add("plugin","blockcode",{translations:{en:{blockcode:{save:"Save",cancel:"Cancel","edit-code":"Edit Code"}}},defaults:{icon:'<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m10.6128994 3.20970461.0942074.08318861 4 4c.3604839.36048396.3882135.92771502.0831886 1.32000622l-.0831886.09420734-4 4.00000002c-.3905243.3905243-1.02368929.3905243-1.41421358 0-.36048396-.360484-.3882135-.927715-.08318861-1.3200062l.08318861-.0942074 3.29210678-3.2928932-3.29210678-3.29289322c-.36048396-.36048396-.3882135-.92771502-.08318861-1.32000622l.08318861-.09420734c.36048396-.36048396.92771498-.3882135 1.32000618-.08318861zm-3.90579262.08318861c.36048396.36048396.3882135.92771502.08318861 1.32000622l-.08318861.09420734-3.29210678 3.29289322 3.29210678 3.2928932c.36048396.360484.3882135.927715.08318861 1.3200062l-.08318861.0942074c-.36048396.3604839-.92771502.3882135-1.32000622.0831886l-.09420734-.0831886-4-4.00000002c-.36048396-.36048396-.3882135-.92771502-.08318861-1.32000622l.08318861-.09420734 4-4c.39052429-.39052429 1.02368927-.39052429 1.41421356 0z"/></svg>',popup:{width:"100%",title:"## blockcode.edit-code ##",form:{code:{type:"textarea",rows:"8"}},footer:{save:{title:"## blockcode.save ##",command:"blockcode.save",type:"primary"},cancel:{title:"## blockcode.cancel ##",close:!0}}}},init:function(){this.offset=!1},start:function(){this.app.control.add("blockcode",{icon:this.opts.blockcode.icon,command:"blockcode.edit",title:"## blockcode.edit-code ##",position:{before:"duplicate"}})},edit:function(){var t=this._getCurrent(),e=t.getOuterHtml(),e=this.app.parser.unparse(e);t.isEditable()&&(this.offset=this.app.offset.get(t.getBlock())),this.app.popup.create("code",this.opts.blockcode.popup),this.app.popup.setData({code:e}),this.app.popup.open({focus:"code"}),this._buildInputHandle(),this._buildCodemirror()},save:function(){this.app.popup.close();var t=this._getCurrent(),e=this._getCode();""!==e&&(e=this.app.parser.parse(e,!1),e=this.dom(e),e=this.app.create("block."+t.getType(),e),t.change(e),this.offset&&e.isEditable()&&this.app.offset.set(e.getBlock(),this.offset),this.offset=!1)},_getCurrent:function(){var t=this.app.block.get();return t=t.isSecondLevel()?t.getFirstLevel():t},_getCode:function(){var t=this.app.popup.getData().code.trim();return this.app.codemirror.val(t)},_buildInputHandle:function(){this.app.popup.getInput("code").on("keydown",this.app.input.handleTextareaTab.bind(this))},_buildCodemirror:function(){var t=this.app.popup.getInput("code");this.app.codemirror.create({el:t,height:"200px",focus:!0}),this.app.popup.updatePosition()}}),RedactorX.add("plugin","blockcode",{translations:{en:{blockcode:{save:"Save",cancel:"Cancel","edit-code":"Edit Code"}}},defaults:{icon:'<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m10.6128994 3.20970461.0942074.08318861 4 4c.3604839.36048396.3882135.92771502.0831886 1.32000622l-.0831886.09420734-4 4.00000002c-.3905243.3905243-1.02368929.3905243-1.41421358 0-.36048396-.360484-.3882135-.927715-.08318861-1.3200062l.08318861-.0942074 3.29210678-3.2928932-3.29210678-3.29289322c-.36048396-.36048396-.3882135-.92771502-.08318861-1.32000622l.08318861-.09420734c.36048396-.36048396.92771498-.3882135 1.32000618-.08318861zm-3.90579262.08318861c.36048396.36048396.3882135.92771502.08318861 1.32000622l-.08318861.09420734-3.29210678 3.29289322 3.29210678 3.2928932c.36048396.360484.3882135.927715.08318861 1.3200062l-.08318861.0942074c-.36048396.3604839-.92771502.3882135-1.32000622.0831886l-.09420734-.0831886-4-4.00000002c-.36048396-.36048396-.3882135-.92771502-.08318861-1.32000622l.08318861-.09420734 4-4c.39052429-.39052429 1.02368927-.39052429 1.41421356 0z"/></svg>',popup:{width:"100%",title:"## blockcode.edit-code ##",form:{code:{type:"textarea",rows:"8"}},footer:{save:{title:"## blockcode.save ##",command:"blockcode.save",type:"primary"},cancel:{title:"## blockcode.cancel ##",close:!0}}}},init:function(){this.offset=!1},start:function(){this.app.control.add("blockcode",{icon:this.opts.blockcode.icon,command:"blockcode.edit",title:"## blockcode.edit-code ##",position:{before:"duplicate"}})},edit:function(){var t=this._getCurrent(),e=t.getOuterHtml(),e=this.app.parser.unparse(e);t.isEditable()&&(this.offset=this.app.offset.get(t.getBlock())),this.app.popup.create("code",this.opts.blockcode.popup),this.app.popup.setData({code:e}),this.app.popup.open({focus:"code"}),this._buildInputHandle(),this._buildCodemirror()},save:function(){this.app.popup.close();var t=this._getCurrent(),e=this._getCode();""!==e&&(e=this.app.parser.parse(e,!1),e=this.dom(e),e=this.app.create("block."+t.getType(),e),t.change(e),this.offset&&e.isEditable()&&this.app.offset.set(e.getBlock(),this.offset),this.offset=!1)},_getCurrent:function(){var t=this.app.block.get();return t.isSecondLevel()?t.getFirstLevel():t},_getCode:function(){var t=this.app.popup.getData().code.trim();return this.app.codemirror.val(t)},_buildInputHandle:function(){this.app.popup.getInput("code").on("keydown",this.app.input.handleTextareaTab.bind(this))},_buildCodemirror:function(){var t=this.app.popup.getInput("code");this.app.codemirror.create({el:t,height:"200px",focus:!0}),this.app.popup.updatePosition()}}),RedactorX.add("plugin","clips",{translations:{en:{clips:{clips:"Clips"}}},defaults:{icon:'<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m12.1666667 1c1.0193924 0 1.8333333.83777495 1.8333333 1.85714286v10.28571424c0 1.0193679-.8139409 1.8571429-1.8333333 1.8571429h-8.33333337c-1.01868744 0-1.83333333-.8379215-1.83333333-1.8571429v-10.28571424c0-1.01922137.81464589-1.85714286 1.83333333-1.85714286zm-.1666667 2h-8v10h8zm-2 7c.5522847 0 1 .4477153 1 1 0 .5128358-.3860402.9355072-.8833789.9932723l-.1166211.0067277h-4c-.55228475 0-1-.4477153-1-1 0-.5128358.38604019-.9355072.88337887-.9932723l.11662113-.0067277zm0-3c.5522847 0 1 .44771525 1 1 0 .51283584-.3860402.93550716-.8833789.99327227l-.1166211.00672773h-4c-.55228475 0-1-.44771525-1-1 0-.51283584.38604019-.93550716.88337887-.99327227l.11662113-.00672773zm0-3c.5522847 0 1 .44771525 1 1 0 .51283584-.3860402.93550716-.8833789.99327227l-.1166211.00672773h-4c-.55228475 0-1-.44771525-1-1 0-.51283584.38604019-.93550716.88337887-.99327227l.11662113-.00672773z"/></svg>',items:!1},start:function(){this.opts.clips.items&&this.app.toolbar.add("clips",{title:"## clips.clips ##",icon:this.opts.clips.icon,command:"clips.popup",blocks:{all:"editable"}})},popup:function(t,e){var i,s={};for(i in this.opts.clips.items)s[i]={title:this.opts.clips.items[i].title,command:"clips.insert"};this.app.popup.create("clips",{items:s}),this.app.popup.open({button:e})},insert:function(t,e,i){this.app.popup.close();i=this.opts.clips.items[i].html;this.app.editor.insertContent({html:i})}}),RedactorX.add("plugin","clips",{translations:{en:{clips:{clips:"Clips"}}},defaults:{icon:'<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m12.1666667 1c1.0193924 0 1.8333333.83777495 1.8333333 1.85714286v10.28571424c0 1.0193679-.8139409 1.8571429-1.8333333 1.8571429h-8.33333337c-1.01868744 0-1.83333333-.8379215-1.83333333-1.8571429v-10.28571424c0-1.01922137.81464589-1.85714286 1.83333333-1.85714286zm-.1666667 2h-8v10h8zm-2 7c.5522847 0 1 .4477153 1 1 0 .5128358-.3860402.9355072-.8833789.9932723l-.1166211.0067277h-4c-.55228475 0-1-.4477153-1-1 0-.5128358.38604019-.9355072.88337887-.9932723l.11662113-.0067277zm0-3c.5522847 0 1 .44771525 1 1 0 .51283584-.3860402.93550716-.8833789.99327227l-.1166211.00672773h-4c-.55228475 0-1-.44771525-1-1 0-.51283584.38604019-.93550716.88337887-.99327227l.11662113-.00672773zm0-3c.5522847 0 1 .44771525 1 1 0 .51283584-.3860402.93550716-.8833789.99327227l-.1166211.00672773h-4c-.55228475 0-1-.44771525-1-1 0-.51283584.38604019-.93550716.88337887-.99327227l.11662113-.00672773z"/></svg>',items:!1},start:function(){this.opts.clips.items&&this.app.toolbar.add("clips",{title:"## clips.clips ##",icon:this.opts.clips.icon,command:"clips.popup",blocks:{all:"editable"}})},popup:function(t,e){var i,s={};for(i in this.opts.clips.items)s[i]={title:this.opts.clips.items[i].title,command:"clips.insert"};this.app.popup.create("clips",{items:s}),this.app.popup.open({button:e})},insert:function(t,e,i){this.app.popup.close(),i=this.opts.clips.items[i].html,this.app.editor.insertContent({html:i})}}),RedactorX.add("plugin","counter",{translations:{en:{counter:{words:"words",chars:"chars"}}},subscribe:{"editor.insert, editor.set, editor.empty":function(){this.count()}},start:function(){this.$editor=this.app.editor.getEditor(),this.$editor.on("keyup."+this.prefix+"-plugin-counter paste."+this.prefix+"-plugin-counter",this.count.bind(this)),this.count()},stop:function(){this.$editor.off("."+this.prefix+"-plugin-counter"),this.app.statusbar.remove("words"),this.app.statusbar.remove("chars")},count:function(){var t,e=0,i=0,s=0,a=this.$editor.html(),n=(""!==(a=this._clean(a))&&(n=a.split(/\s+/),t=a.match(/\s/g),e=n?n.length:0,s=t?t.length:0,i=a.length),{words:e,characters:i,spaces:s});this.app.broadcast("counter",n),this.app.statusbar.add("words",this.lang.get("counter.words")+": "+n.words),this.app.statusbar.add("chars",this.lang.get("counter.chars")+": "+n.characters)},_clean:function(t){return t=(t=(t=(t=(t=(t=(t=t.replace(/<\/(.*?)>/gi," ")).replace(/<(.*?)>/gi,"")).replace(/\t/gi,"")).replace(/\n/gi," ")).replace(/\r/gi," ")).replace(/ /g,"1")).trim(),t=this.app.utils.removeInvisibleChars(t)}}),RedactorX.add("plugin","counter",{translations:{en:{counter:{words:"words",chars:"chars"}}},subscribe:{"editor.insert, editor.set, editor.empty":function(){this.count()}},start:function(){this.$editor=this.app.editor.getEditor(),this.$editor.on("keyup."+this.prefix+"-plugin-counter paste."+this.prefix+"-plugin-counter",this.count.bind(this)),this.count()},stop:function(){this.$editor.off("."+this.prefix+"-plugin-counter"),this.app.statusbar.remove("words"),this.app.statusbar.remove("chars")},count:function(){var t,e=0,i=0,s=0,a=this.$editor.html(),n=(""!==(a=this._clean(a))&&(n=a.split(/\s+/),t=a.match(/\s/g),e=n?n.length:0,s=t?t.length:0,i=a.length),{words:e,characters:i,spaces:s});this.app.broadcast("counter",n),this.app.statusbar.add("words",this.lang.get("counter.words")+": "+n.words),this.app.statusbar.add("chars",this.lang.get("counter.chars")+": "+n.characters)},_clean:function(t){return t=(t=(t=(t=(t=(t=(t=t.replace(/<\/(.*?)>/gi," ")).replace(/<(.*?)>/gi,"")).replace(/\t/gi,"")).replace(/\n/gi," ")).replace(/\r/gi," ")).replace(/ /g,"1")).trim(),this.app.utils.removeInvisibleChars(t)}}),RedactorX.add("plugin","definedlinks",{defaults:{items:!1},subscribe:{"popup.open":function(){!1!==this.opts.definedlinks.items&&"link"===this.app.popup.getName()&&this._build()}},_build:function(){var t=this.app.popup.getFormItem("text"),e=this.dom("<div>").addClass(this.prefix+"-form-item");this.$select=this._create(),e.append(this.$select),t.before(e)},_change:function(t){var t=this.dom(t.target).val(),t=this.opts.definedlinks.items[t],e=this.app.popup.getInput("text"),i=this.app.popup.getInput("url"),s=t.name,a=t.url;!1===t.url&&(s=a=""),""===e.val()&&e.val(s),i.val(a)},_create:function(){var t=this.opts.definedlinks.items,e=this.dom("<select>").addClass(this.prefix+"-form-select");e.on("change",this._change.bind(this));for(var i=0;i<t.length;i++){var s=t[i],a=this.dom("<option>");a.val(i),a.html(s.name),e.append(a)}return e}}),RedactorX.add("plugin","definedlinks",{defaults:{items:!1},subscribe:{"popup.open":function(){!1!==this.opts.definedlinks.items&&"link"===this.app.popup.getName()&&this._build()}},_build:function(){var t=this.app.popup.getFormItem("text"),e=this.dom("<div>").addClass(this.prefix+"-form-item");this.$select=this._create(),e.append(this.$select),t.before(e)},_change:function(t){var t=this.dom(t.target).val(),t=this.opts.definedlinks.items[t],e=this.app.popup.getInput("text"),i=this.app.popup.getInput("url"),s=t.name,a=t.url;!1===t.url&&(s=a=""),""===e.val()&&e.val(s),i.val(a)},_create:function(){var t=this.opts.definedlinks.items,e=this.dom("<select>").addClass(this.prefix+"-form-select");e.on("change",this._change.bind(this));for(var i=0;i<t.length;i++){var s=t[i],a=this.dom("<option>");a.val(i),a.html(s.name),e.append(a)}return e}}),RedactorX.add("plugin","filebrowser",{start:function(){this.app.toolbar.add("filebrowser",{title:this.app.lang.get("popup.image"),icon:'<span class="rx-icon-image"></span>',command:"filebrowser.open",blocks:{all:"editable",except:["image"]}}),this.app.addbar.add("filebrowser",{title:this.app.lang.get("popup.image"),icon:'<span class="rx-icon-image"></span>',command:"filebrowser.open"})},open:function(){var a;void 0!==this.app.addbar&&this.app.popup.close(),window.document.addEventListener("filepicker:pick",((a=this).app.selection.save(),function t(e){a.app.selection.restore(),window.document.removeEventListener("filepicker:pick",t);var i,s,e=e.detail;"[object String]"===Object.prototype.toString.call(e)?a.app.image.insert(e):e.file_id&&(i=EE.Rte.filedirUrls[e.upload_location_id]+e.file_name,e.isImage||e.isSVG?a.app.image.insert({file:{url:e.path,alt:e.title}}):((s=document.createElement("a")).setAttribute("href",i),s.innerText=e.title,a.app.insertion.insertNode(s)))})),window.Rte_browseImages(this.app.insertion,{})}}),RedactorX.add("plugin","filelink",{translations:{en:{filelink:{file:"File",upload:"Upload",title:"Title",choose:"Choose",placeholder:"Drag to upload a file<br>or click to select"}}},defaults:{states:!0,classname:!1,upload:!1,select:!1,name:"file",data:!1,icon:'<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m14 9c.5128358 0 .9355072.38604019.9932723.88337887l.0067277.11662113v3.2c0 .9600523-.7638671 1.7205052-1.7068479 1.7941504l-.150295.0058496h-10.28571424c-.96021508 0-1.77209294-.7124503-1.85088019-1.6501425l-.00626267-.1498575v-3.2c0-.55228475.44771525-1 1-1 .51283584 0 .93550716.38604019.99327227.88337887l.00672773.11662113v3h10v-3c0-.51283584.3860402-.93550716.8833789-.99327227zm-6-8c.51283584 0 .93550716.38604019.99327227.88337887l.00672773.11662113v6h1.5c.1573787 0 .3055728.07409708.4.2.1656854.2209139.1209139.53431458-.1.7l-2.5 1.875c-.17777778.1333333-.42222222.1333333-.6 0l-2.5-1.875c-.12590292-.09442719-.2-.24262135-.2-.4 0-.27614237.22385763-.5.5-.5h1.5v-6c0-.55228475.44771525-1 1-1z"/></svg>'},subscribe:{"editor.load, editor.build":function(){this.observeStates()}},popups:{create:{title:"## filelink.upload ##",width:"400px",form:{title:{type:"input",label:"## filelink.title ##"},file:{}}},choose:{collapse:!1,title:"## filelink.choose ##",width:"400px"}},init:function(){this.dataStates=[]},start:function(){this._is()&&this.app.toolbar.add("file",{title:"## filelink.file ##",icon:this.opts.filelink.icon,command:"filelink.popup",blocks:{all:"editable",except:["code"]},position:{after:"link"}})},popup:function(t,e){var i,s="create";this.opts.filelink.upload&&(s="add",i=this.app.selection.getText(),this.app.popup.create("file",this._buildPopupUpload(this.popups.create)).setData({title:i})),this.opts.filelink.select&&(i=this.app.popup[s]("file-select",this.popups.choose),this.$sbox=i.getBody(),"string"==typeof this.opts.filelink.select?this.ajax.get({url:this.opts.filelink.select,success:this._parseList.bind(this)}):this._parseList.apply(this,[this.opts.filelink.select])),this.app.popup.open({button:e})},insertByUpload:function(t){this.app.popup.close();var e=this.app.popup.getData();this._insert(t,e.title)},insertBySelect:function(t){t.preventDefault(),this.app.popup.close();var e=this.app.selection.getText(),t=this.dom(t.target).closest("."+this.prefix+"-popup-list-item"),t=JSON.parse(decodeURI(t.attr("data-params")));this._insert({file:t},e,!0)},error:function(t){this.app.broadcast("file.upload.error",{response:t})},observeStates:function(){this._findFiles().each(this._addFileState.bind(this))},getStates:function(){var t,e=this._findFiles();for(t in this.dataStates){var i=this.dataStates[t],s=e.is('[data-file="'+i.id+'"]');this._setFileState(i.id,s)}return this.dataStates},_is:function(){return this.opts.filelink.upload||this.opts.filelink.select},_insert:function(t,e,i){for(var s in t){s=this._createFileAndStore(t[s],e);this.app.broadcast("file."+(i?"select":"upload"),{response:t,$el:s});break}},_buildPopupUpload:function(t){return t.form.file={type:"upload",upload:{type:"file",box:!0,placeholder:this.lang.get("filelink.placeholder"),url:this.opts.filelink.upload,name:this.opts.filelink.name,data:this.opts.filelink.data,success:"filelink.insertByUpload",error:"filelink.error"}},t},_findFiles:function(){return this.app.editor.getLayout().find("[data-file]")},_addFileState:function(t){var e=t.attr("data-file");this.dataStates[e]={type:"file",status:!0,url:t.attr("src"),$el:t,id:e}},_setFileState:function(t,e){this.dataStates[t].status=e},_parseList:function(t){var e,i=this.dom("<ul>");for(e in i.addClass(this.prefix+"-popup-list"),t){var s,a,n=t[e];"object"==typeof n&&(s=this.dom("<li>"),a=this.dom("<span>"),s.append(a),a.addClass(this.prefix+"-popup-list-item"),a.attr("data-params",encodeURI(JSON.stringify(n))),a.text(n.title||n.name),(a=this.dom("<span>")).addClass(this.prefix+"-popup-list-aside"),a.text(n.name),s.append(a),(a=this.dom("<span>")).addClass(this.prefix+"-popup-list-aside"),a.text("("+n.size+")"),s.append(a),s.on("click",this.insertBySelect.bind(this)),i.append(s))}this.$sbox.append(i)},_createFileAndStore:function(t,e){var i=this.app.inline.set({tag:"a",caret:"after"}),i=this.dom(i);return i.attr("href",t.url),i.attr("data-file",t.id||this.app.utils.getRandomId()),i.attr("data-name",t.name),this.opts.filelink.classname&&i.addClass(this.opts.filelink.classname),e=e&&""!==e?e:this._truncateUrl(t.name),i.html(e),i},_truncateUrl:function(t){return-1!==t.search(/^http/)&&20<t.length?t.substring(0,20)+"...":t}}),RedactorX.add("plugin","filelink",{translations:{en:{filelink:{file:"File",upload:"Upload",title:"Title",choose:"Choose",placeholder:"Drag to upload a file<br>or click to select"}}},defaults:{states:!0,classname:!1,upload:!1,select:!1,name:"file",data:!1,icon:'<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m14 9c.5128358 0 .9355072.38604019.9932723.88337887l.0067277.11662113v3.2c0 .9600523-.7638671 1.7205052-1.7068479 1.7941504l-.150295.0058496h-10.28571424c-.96021508 0-1.77209294-.7124503-1.85088019-1.6501425l-.00626267-.1498575v-3.2c0-.55228475.44771525-1 1-1 .51283584 0 .93550716.38604019.99327227.88337887l.00672773.11662113v3h10v-3c0-.51283584.3860402-.93550716.8833789-.99327227zm-6-8c.51283584 0 .93550716.38604019.99327227.88337887l.00672773.11662113v6h1.5c.1573787 0 .3055728.07409708.4.2.1656854.2209139.1209139.53431458-.1.7l-2.5 1.875c-.17777778.1333333-.42222222.1333333-.6 0l-2.5-1.875c-.12590292-.09442719-.2-.24262135-.2-.4 0-.27614237.22385763-.5.5-.5h1.5v-6c0-.55228475.44771525-1 1-1z"/></svg>'},subscribe:{"editor.load, editor.build":function(){this.observeStates()}},popups:{create:{title:"## filelink.upload ##",width:"400px",form:{title:{type:"input",label:"## filelink.title ##"},file:{}}},choose:{collapse:!1,title:"## filelink.choose ##",width:"400px"}},init:function(){this.dataStates=[]},start:function(){this._is()&&this.app.toolbar.add("file",{title:"## filelink.file ##",icon:this.opts.filelink.icon,command:"filelink.popup",blocks:{all:"editable",except:["code"]},position:{after:"link"}})},popup:function(t,e){var i,s="create";this.opts.filelink.upload&&(s="add",i=this.app.selection.getText(),this.app.popup.create("file",this._buildPopupUpload(this.popups.create)).setData({title:i})),this.opts.filelink.select&&(i=this.app.popup[s]("file-select",this.popups.choose),this.$sbox=i.getBody(),"string"==typeof this.opts.filelink.select?this.ajax.get({url:this.opts.filelink.select,success:this._parseList.bind(this)}):this._parseList.apply(this,[this.opts.filelink.select])),this.app.popup.open({button:e})},insertByUpload:function(t){this.app.popup.close();var e=this.app.popup.getData();this._insert(t,e.title)},insertBySelect:function(t){t.preventDefault(),this.app.popup.close();var e=this.app.selection.getText(),t=this.dom(t.target).closest("."+this.prefix+"-popup-list-item"),t=JSON.parse(decodeURI(t.attr("data-params")));this._insert({file:t},e,!0)},error:function(t){this.app.broadcast("file.upload.error",{response:t})},observeStates:function(){this._findFiles().each(this._addFileState.bind(this))},getStates:function(){var t,e=this._findFiles();for(t in this.dataStates){var i=this.dataStates[t],s=e.is('[data-file="'+i.id+'"]');this._setFileState(i.id,s)}return this.dataStates},_is:function(){return this.opts.filelink.upload||this.opts.filelink.select},_insert:function(t,e,i){for(var s in t){s=this._createFileAndStore(t[s],e),this.app.broadcast("file."+(i?"select":"upload"),{response:t,$el:s});break}},_buildPopupUpload:function(t){return t.form.file={type:"upload",upload:{type:"file",box:!0,placeholder:this.lang.get("filelink.placeholder"),url:this.opts.filelink.upload,name:this.opts.filelink.name,data:this.opts.filelink.data,success:"filelink.insertByUpload",error:"filelink.error"}},t},_findFiles:function(){return this.app.editor.getLayout().find("[data-file]")},_addFileState:function(t){var e=t.attr("data-file");this.dataStates[e]={type:"file",status:!0,url:t.attr("src"),$el:t,id:e}},_setFileState:function(t,e){this.dataStates[t].status=e},_parseList:function(t){var e,i=this.dom("<ul>");for(e in i.addClass(this.prefix+"-popup-list"),t){var s,a,n=t[e];"object"==typeof n&&(s=this.dom("<li>"),a=this.dom("<span>"),s.append(a),a.addClass(this.prefix+"-popup-list-item"),a.attr("data-params",encodeURI(JSON.stringify(n))),a.text(n.title||n.name),(a=this.dom("<span>")).addClass(this.prefix+"-popup-list-aside"),a.text(n.name),s.append(a),(a=this.dom("<span>")).addClass(this.prefix+"-popup-list-aside"),a.text("("+n.size+")"),s.append(a),s.on("click",this.insertBySelect.bind(this)),i.append(s))}this.$sbox.append(i)},_createFileAndStore:function(t,e){var i=this.app.inline.set({tag:"a",caret:"after"});return(i=this.dom(i)).attr("href",t.url),i.attr("data-file",t.id||this.app.utils.getRandomId()),i.attr("data-name",t.name),this.opts.filelink.classname&&i.addClass(this.opts.filelink.classname),e=e&&""!==e?e:this._truncateUrl(t.name),i.html(e),i},_truncateUrl:function(t){return-1!==t.search(/^http/)&&20<t.length?t.substring(0,20)+"...":t}}),RedactorX.add("plugin","fontcolor",{translations:{en:{fontcolor:{title:"Text color",remove:"Remove color",text:"Text",background:"Background"}}},init(){this.colors=this.opts.fontcolor||{gray:["#212529","#343a40","#495057","#868e96","#adb5bd","#ced4da","#dee2e6","#e9ecef","#f1f3f5","#f8f9fa"],red:["#c92a2a","#e03131","#f03e3e","#fa5252","#ff6b6b","#ff8787","#ffa8a8","#ffc9c9","#ffe3e3","#fff5f5"],pink:["#a61e4d","#c2255c","#d6336c","#e64980","#f06595","#f783ac","#faa2c1","#fcc2d7","#ffdeeb","#fff0f6"],grape:["#862e9c","#9c36b5","#ae3ec9","#be4bdb","#cc5de8","#da77f2","#e599f7","#eebefa","#f3d9fa","#f8f0fc"],violet:["#5f3dc4","#6741d9","#7048e8","#7950f2","#845ef7","#9775fa","#b197fc","#d0bfff","#e5dbff","#f3f0ff"],indigo:["#364fc7","#3b5bdb","#4263eb","#4c6ef5","#5c7cfa","#748ffc","#91a7ff","#bac8ff","#dbe4ff","#edf2ff"],blue:["#1864ab","#1971c2","#1c7ed6","#228be6","#339af0","#4dabf7","#74c0fc","#a5d8ff","#d0ebff","#e7f5ff"],cyan:["#0b7285","#0c8599","#1098ad","#15aabf","#22b8cf","#3bc9db","#66d9e8","#99e9f2","#c5f6fa","#e3fafc"],teal:["#087f5b","#099268","#0ca678","#12b886","#20c997","#38d9a9","#63e6be","#96f2d7","#c3fae8","#e6fcf5"],green:["#2b8a3e","#2f9e44","#37b24d","#40c057","#51cf66","#69db7c","#8ce99a","#b2f2bb","#d3f9d8","#ebfbee"],lime:["#5c940d","#66a80f","#74b816","#82c91e","#94d82d","#a9e34b","#c0eb75","#d8f5a2","#e9fac8","#f4fce3"],yellow:["#e67700","#f08c00","#f59f00","#fab005","#fcc419","#ffd43b","#ffe066","#ffec99","#fff3bf","#fff9db"],orange:["#d9480f","#e8590c","#f76707","#fd7e14","#ff922b","#ffa94d","#ffc078","#ffd8a8","#ffe8cc","#fff4e6"]}},start(){this.app.toolbar.add("fontcolor",{title:"## fontcolor.title ##",color:!0,icon:'<svg width="17" height="16" viewBox="0 0 17 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M8.50002 4.16336C8.18972 4.16336 7.89213 4.28662 7.67271 4.50604C7.45329 4.72546 7.33002 5.02305 7.33002 5.33336V6.50336H9.67002V5.33336C9.67002 5.02305 9.54676 4.72546 9.32734 4.50604C9.10792 4.28662 8.81033 4.16336 8.50002 4.16336ZM11.33 5.33336C11.33 4.58279 11.0319 3.86297 10.5011 3.33224C9.97041 2.80152 9.25059 2.50336 8.50002 2.50336C7.74946 2.50336 7.02964 2.80152 6.49891 3.33224C5.96818 3.86297 5.67002 4.58279 5.67002 5.33336V10C5.67002 10.4584 6.04163 10.83 6.50002 10.83C6.95842 10.83 7.33002 10.4584 7.33002 10V8.16336H9.67002V10C9.67002 10.4584 10.0416 10.83 10.5 10.83C10.9584 10.83 11.33 10.4584 11.33 10V5.33336ZM3.00336 12.6667C3.00336 12.2083 3.37496 11.8367 3.83336 11.8367H13.1667C13.6251 11.8367 13.9967 12.2083 13.9967 12.6667C13.9967 13.1251 13.6251 13.4967 13.1667 13.4967H3.83336C3.37496 13.4967 3.00336 13.1251 3.00336 12.6667Z"/></svg>',blocks:{all:"editable",except:["code"]},command:"fontcolor.popup"})},popup(t,e){var i=this.app.selection.getNodes({type:"inline"}),i=(this.currentColor=!1,this.currentBackgroundColor=!1,i&&(i=this.dom(i[0]),i=this.app.utils.cssToObject(i.attr("style")),this.currentColor=i.color||this.currentColor,this.currentBackgroundColor=i.background||this.currentBackgroundColor),this.dom('<div class="'+this.prefix+'-dropdown-cells">'));this.$selector=this._buildSelector(),this.$selectorText=this._buildSelectorItem("text",this.lang.get("fontcolor.text")),this.$selectorText.addClass("active"),this.$selectorBack=this._buildSelectorItem("back",this.lang.get("fontcolor.background")),this.$selector.append(this.$selectorText),this.$selector.append(this.$selectorBack),this.$pickerText=this._buildPicker("textcolor"),this.$pickerBack=this._buildPicker("backcolor"),i.append(this.$selector),i.append(this.$pickerText),i.append(this.$pickerBack),this._buildSelectorEvents(),this.app.popup.create("fontcolor",{html:i}),this.app.popup.open({button:e})},_remove(t){this.app.popup.close(),this.app.inline.remove("color"===t?{style:"color"}:{style:"background"})},_buildSelector(){var t=this.dom("<div>");return t.addClass(this.prefix+"-dropdown-selector"),t},_buildSelectorItem(t,e){var i=this.dom("<span>");return i.attr("rel",t).html(e),i.addClass(this.prefix+"-dropdown-not-close"),i},_buildSelectorEvents(){this.$selectorText.on("click",function(t){t.preventDefault(),this.$selector.find("span").removeClass("active"),this.$pickerBack.hide(),this.$pickerText.show(),this.$selectorText.addClass("active")}.bind(this)),this.$selectorBack.on("click",function(t){t.preventDefault(),this.$selector.find("span").removeClass("active"),this.$pickerText.hide(),this.$pickerBack.show(),this.$selectorBack.addClass("active")}.bind(this))},_buildPicker(t){var e,i,s=this.dom('<div class="'+this.prefix+"-dropdown-box-"+t+'">'),a=this.dom('<div class="'+this.prefix+'-form-colors-box">'),n="backcolor"==t?"background":"color",o=(this.colors.length,this);for([e,i]of Object.entries(this.colors)){for(var r=this.dom('<div class="'+this.prefix+'-form-colors">'),p=0;p<i.length;p++){var l=i[p],h=this.dom('<a href="#">');h.attr({rel:l,"data-rule":n}),h.css({"background-color":l,"font-size":0,width:"20px",height:"20px"}),h.on("click",function(t){t.preventDefault(),t.stopPropagation();var t=this.dom(t.target),e=t.attr("rel"),t={tag:"span",style:"color"===t.data("rule")?{color:e}:{background:e}};this.app.event.trigger=!1,this.app.inline.set(t),setTimeout(function(){this.app.event.trigger=!0}.bind(this),100)}.bind(this)),"color"==n&&this.currentColor===l&&h.addClass("active"),"background"==n&&this.currentBackgroundColor===l&&h.addClass("active"),r.append(h)}a.append(r)}s.append(a);var c=this.dom("<div>").addClass(this.prefix+"-dropdown-remove-item"),d=this.dom("<a>");return d.attr({href:"#"}),d.html(this.lang.get("fontcolor.remove")),d.on("click",function(t){t.preventDefault(),o._remove(n)}),c.append(d),s.append(c),"backcolor"==t&&s.hide(),s}}),RedactorX.add("plugin","fontcolor",{translations:{en:{fontcolor:{title:"Text color",remove:"Remove color",text:"Text",background:"Background"}}},init(){this.colors=this.opts.fontcolor||{gray:["#212529","#343a40","#495057","#868e96","#adb5bd","#ced4da","#dee2e6","#e9ecef","#f1f3f5","#f8f9fa"],red:["#c92a2a","#e03131","#f03e3e","#fa5252","#ff6b6b","#ff8787","#ffa8a8","#ffc9c9","#ffe3e3","#fff5f5"],pink:["#a61e4d","#c2255c","#d6336c","#e64980","#f06595","#f783ac","#faa2c1","#fcc2d7","#ffdeeb","#fff0f6"],grape:["#862e9c","#9c36b5","#ae3ec9","#be4bdb","#cc5de8","#da77f2","#e599f7","#eebefa","#f3d9fa","#f8f0fc"],violet:["#5f3dc4","#6741d9","#7048e8","#7950f2","#845ef7","#9775fa","#b197fc","#d0bfff","#e5dbff","#f3f0ff"],indigo:["#364fc7","#3b5bdb","#4263eb","#4c6ef5","#5c7cfa","#748ffc","#91a7ff","#bac8ff","#dbe4ff","#edf2ff"],blue:["#1864ab","#1971c2","#1c7ed6","#228be6","#339af0","#4dabf7","#74c0fc","#a5d8ff","#d0ebff","#e7f5ff"],cyan:["#0b7285","#0c8599","#1098ad","#15aabf","#22b8cf","#3bc9db","#66d9e8","#99e9f2","#c5f6fa","#e3fafc"],teal:["#087f5b","#099268","#0ca678","#12b886","#20c997","#38d9a9","#63e6be","#96f2d7","#c3fae8","#e6fcf5"],green:["#2b8a3e","#2f9e44","#37b24d","#40c057","#51cf66","#69db7c","#8ce99a","#b2f2bb","#d3f9d8","#ebfbee"],lime:["#5c940d","#66a80f","#74b816","#82c91e","#94d82d","#a9e34b","#c0eb75","#d8f5a2","#e9fac8","#f4fce3"],yellow:["#e67700","#f08c00","#f59f00","#fab005","#fcc419","#ffd43b","#ffe066","#ffec99","#fff3bf","#fff9db"],orange:["#d9480f","#e8590c","#f76707","#fd7e14","#ff922b","#ffa94d","#ffc078","#ffd8a8","#ffe8cc","#fff4e6"]}},start(){this.app.toolbar.add("fontcolor",{title:"## fontcolor.title ##",color:!0,icon:'<svg width="17" height="16" viewBox="0 0 17 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M8.50002 4.16336C8.18972 4.16336 7.89213 4.28662 7.67271 4.50604C7.45329 4.72546 7.33002 5.02305 7.33002 5.33336V6.50336H9.67002V5.33336C9.67002 5.02305 9.54676 4.72546 9.32734 4.50604C9.10792 4.28662 8.81033 4.16336 8.50002 4.16336ZM11.33 5.33336C11.33 4.58279 11.0319 3.86297 10.5011 3.33224C9.97041 2.80152 9.25059 2.50336 8.50002 2.50336C7.74946 2.50336 7.02964 2.80152 6.49891 3.33224C5.96818 3.86297 5.67002 4.58279 5.67002 5.33336V10C5.67002 10.4584 6.04163 10.83 6.50002 10.83C6.95842 10.83 7.33002 10.4584 7.33002 10V8.16336H9.67002V10C9.67002 10.4584 10.0416 10.83 10.5 10.83C10.9584 10.83 11.33 10.4584 11.33 10V5.33336ZM3.00336 12.6667C3.00336 12.2083 3.37496 11.8367 3.83336 11.8367H13.1667C13.6251 11.8367 13.9967 12.2083 13.9967 12.6667C13.9967 13.1251 13.6251 13.4967 13.1667 13.4967H3.83336C3.37496 13.4967 3.00336 13.1251 3.00336 12.6667Z"/></svg>',blocks:{all:"editable",except:["code"]},command:"fontcolor.popup"})},popup(t,e){var i=this.app.selection.getNodes({type:"inline"}),i=(this.currentColor=!1,this.currentBackgroundColor=!1,i&&(i=this.dom(i[0]),i=this.app.utils.cssToObject(i.attr("style")),this.currentColor=i.color||this.currentColor,this.currentBackgroundColor=i.background||this.currentBackgroundColor),this.dom('<div class="'+this.prefix+'-dropdown-cells">'));this.$selector=this._buildSelector(),this.$selectorText=this._buildSelectorItem("text",this.lang.get("fontcolor.text")),this.$selectorText.addClass("active"),this.$selectorBack=this._buildSelectorItem("back",this.lang.get("fontcolor.background")),this.$selector.append(this.$selectorText),this.$selector.append(this.$selectorBack),this.$pickerText=this._buildPicker("textcolor"),this.$pickerBack=this._buildPicker("backcolor"),i.append(this.$selector),i.append(this.$pickerText),i.append(this.$pickerBack),this._buildSelectorEvents(),this.app.popup.create("fontcolor",{html:i}),this.app.popup.open({button:e})},_remove(t){this.app.popup.close(),this.app.inline.remove("color"===t?{style:"color"}:{style:"background"})},_buildSelector(){var t=this.dom("<div>");return t.addClass(this.prefix+"-dropdown-selector"),t},_buildSelectorItem(t,e){var i=this.dom("<span>");return i.attr("rel",t).html(e),i.addClass(this.prefix+"-dropdown-not-close"),i},_buildSelectorEvents(){this.$selectorText.on("click",function(t){t.preventDefault(),this.$selector.find("span").removeClass("active"),this.$pickerBack.hide(),this.$pickerText.show(),this.$selectorText.addClass("active")}.bind(this)),this.$selectorBack.on("click",function(t){t.preventDefault(),this.$selector.find("span").removeClass("active"),this.$pickerText.hide(),this.$pickerBack.show(),this.$selectorBack.addClass("active")}.bind(this))},_buildPicker(t){var e,i,s=this.dom('<div class="'+this.prefix+"-dropdown-box-"+t+'">'),a=this.dom('<div class="'+this.prefix+'-form-colors-box">'),n="backcolor"==t?"background":"color",o=(this.colors.length,this);for([e,i]of Object.entries(this.colors)){for(var r=this.dom('<div class="'+this.prefix+'-form-colors">'),p=0;p<i.length;p++){var l=i[p],h=this.dom('<a href="#">');h.attr({rel:l,"data-rule":n}),h.css({"background-color":l,"font-size":0,width:"20px",height:"20px"}),h.on("click",function(t){t.preventDefault(),t.stopPropagation();var e=(t=this.dom(t.target)).attr("rel"),t={tag:"span",style:"color"===t.data("rule")?{color:e}:{background:e}};this.app.event.trigger=!1,this.app.inline.set(t),setTimeout(function(){this.app.event.trigger=!0}.bind(this),100)}.bind(this)),"color"==n&&this.currentColor===l&&h.addClass("active"),"background"==n&&this.currentBackgroundColor===l&&h.addClass("active"),r.append(h)}a.append(r)}s.append(a);var c=this.dom("<div>").addClass(this.prefix+"-dropdown-remove-item"),d=this.dom("<a>");return d.attr({href:"#"}),d.html(this.lang.get("fontcolor.remove")),d.on("click",function(t){t.preventDefault(),o._remove(n)}),c.append(d),s.append(c),"backcolor"==t&&s.hide(),s}}),RedactorX.add("plugin","fontfamily",{translations:{en:{fontfamily:{title:"Font",remove:"Remove font family"}}},init(){this.fonts=this.opts.fontfamily||["Arial","Helvetica","Georgia","Times New Roman","Monospace"]},start(){this.app.toolbar.add("fontfamily",{title:"## fontfamily.title ##",icon:'<svg width="17" height="16" viewBox="0 0 17 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M7.05618 2.37524C7.17767 2.05129 7.48736 1.83667 7.83334 1.83667H9.16667C9.49643 1.83667 9.79491 2.03188 9.92708 2.33399L14.3762 12.5033H14.5C14.9584 12.5033 15.33 12.8749 15.33 13.3333C15.33 13.7917 14.9584 14.1633 14.5 14.1633H13.8524C13.8399 14.1636 13.8275 14.1636 13.8152 14.1633H11.1855C11.1732 14.1636 11.1609 14.1636 11.1486 14.1633H9.83334C9.37494 14.1633 9.00334 13.7917 9.00334 13.3333C9.00334 12.8749 9.37494 12.5033 9.83334 12.5033H9.91398L9.20556 10.83H5.65853L5.03103 12.5033H5.16667C5.62507 12.5033 5.99667 12.8749 5.99667 13.3333C5.99667 13.7917 5.62507 14.1633 5.16667 14.1633H3.85246C3.83966 14.1636 3.82682 14.1636 3.81397 14.1633H3.16667C2.70827 14.1633 2.33667 13.7917 2.33667 13.3333C2.33667 12.8749 2.70827 12.5033 3.16667 12.5033H3.25815L7.05618 2.37524ZM6.28103 9.17H8.50278L7.32462 6.38709L6.28103 9.17ZM8.17134 4.12916L11.7166 12.5033H12.5643L8.62384 3.49667H8.40853L8.17134 4.12916Z"/></svg>',blocks:{all:"editable",except:["code"]},command:"fontfamily.popup"})},popup(t,e){var i={};for(let t=0;t<this.fonts.length;t++){var s=this.fonts[t],s={title:s.replace(/'/g,""),command:"inline.set",params:{tag:"span",style:{"font-family":s}}};i[t]=s}i.remove={title:"## fontfamily.remove ##",divider:"top",command:"fontfamily.remove"},this.app.popup.create("fontfamily",{items:i}),this.app.popup.open({button:e})},remove(){this.app.popup.close(),this.app.inline.remove({style:"font-family"})}}),RedactorX.add("plugin","fontfamily",{translations:{en:{fontfamily:{title:"Font",remove:"Remove font family"}}},init(){this.fonts=this.opts.fontfamily||["Arial","Helvetica","Georgia","Times New Roman","Monospace"]},start(){this.app.toolbar.add("fontfamily",{title:"## fontfamily.title ##",icon:'<svg width="17" height="16" viewBox="0 0 17 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M7.05618 2.37524C7.17767 2.05129 7.48736 1.83667 7.83334 1.83667H9.16667C9.49643 1.83667 9.79491 2.03188 9.92708 2.33399L14.3762 12.5033H14.5C14.9584 12.5033 15.33 12.8749 15.33 13.3333C15.33 13.7917 14.9584 14.1633 14.5 14.1633H13.8524C13.8399 14.1636 13.8275 14.1636 13.8152 14.1633H11.1855C11.1732 14.1636 11.1609 14.1636 11.1486 14.1633H9.83334C9.37494 14.1633 9.00334 13.7917 9.00334 13.3333C9.00334 12.8749 9.37494 12.5033 9.83334 12.5033H9.91398L9.20556 10.83H5.65853L5.03103 12.5033H5.16667C5.62507 12.5033 5.99667 12.8749 5.99667 13.3333C5.99667 13.7917 5.62507 14.1633 5.16667 14.1633H3.85246C3.83966 14.1636 3.82682 14.1636 3.81397 14.1633H3.16667C2.70827 14.1633 2.33667 13.7917 2.33667 13.3333C2.33667 12.8749 2.70827 12.5033 3.16667 12.5033H3.25815L7.05618 2.37524ZM6.28103 9.17H8.50278L7.32462 6.38709L6.28103 9.17ZM8.17134 4.12916L11.7166 12.5033H12.5643L8.62384 3.49667H8.40853L8.17134 4.12916Z"/></svg>',blocks:{all:"editable",except:["code"]},command:"fontfamily.popup"})},popup(t,e){var i={};for(let t=0;t<this.fonts.length;t++){var s={title:(s=this.fonts[t]).replace(/'/g,""),command:"inline.set",params:{tag:"span",style:{"font-family":s}}};i[t]=s}i.remove={title:"## fontfamily.remove ##",divider:"top",command:"fontfamily.remove"},this.app.popup.create("fontfamily",{items:i}),this.app.popup.open({button:e})},remove(){this.app.popup.close(),this.app.inline.remove({style:"font-family"})}}),RedactorX.add("plugin","handle",{translations:{en:{handle:{handle:"Handle"}}},defaults:{url:!1,start:1,trigger:"@"},subscribe:{"editor.keydown":function(t){this._listen(t)},"editor.keyup":function(t){!1!==this.opts.handle.url&&this._handle(t)}},start:function(){this.handleLen=this.opts.handle.start},stop:function(){this._hide()},_handle:function(t){var t=t.get("e"),e=t.which,t=t.ctrlKey||t.metaKey,i=this.app.keycodes;e===i.ESC?this.app.selection.restore():e===i.DELETE||e===i.SPACE||e===i.SHIFT||t||-1!==[37,38,39,40].indexOf(e)||(e===i.BACKSPACE&&(this.handleLen=this.handleLen-2,this.handleLen<=this.opts.handle.start)&&this._hide(),this._emit())},_listen:function(t){var e,i=t.get("e"),s=i.which,a=this.app.keycodes;if(this._isShown()&&s===a.ENTER)return 0===(e=this._getActiveItem()).length?void this._hideForce():(i.preventDefault(),t.stop(),void this._replace(i,e));!this._isShown()||40!==s&&38!==s||(i.preventDefault(),t.stop(),0===(e=this._getActiveItem()).length?(a=this._getFirstItem(),this._setActive(a)):40===s?this._setNextActive(e):38===s&&this._setPrevActive(e))},_getItems:function(){return this.$panel.find("."+this.prefix+"-panel-item")},_getActiveItem:function(){return this._getItems().filter(function(t){return t.hasClass("active")})},_getFirstItem:function(){return this._getItems().first()},_getLastItem:function(){return this._getItems().last()},_setActive:function(t){this._getItems().removeClass("active"),t.addClass("active");var e=t.outerHeight(),t=t.position().top,i=this.$panel.scrollTop(),s=t+2*e,a=this.$panel.outerHeight();this.$panel.scrollTop(i+a<s?s-a:t-e<i?t-e:i)},_setNextActive:function(t){var t=t.next();0!==t.length?this._setActive(t):(t=this._getFirstItem(),this._setActive(t))},_setPrevActive:function(t){var t=t.prev();0!==t.length?this._setActive(t):(t=this._getLastItem(),this._setActive(t))},_emit:function(){var t=new RegExp("^"+this.opts.handle.trigger);this.handleStr=this.app.selection.getText("before",this.handleLen),this.handleStr2=this.app.selection.getText("before",this.handleLen+1),t.test(this.handleStr)&&(this.handleStr2&&" "===this.handleStr2[0]||""===this.handleStr2[0])&&(this.handleStr=this.handleStr.replace(this.opts.handle.trigger,""),this.handleLen++,this.handleLen-1>this.opts.handle.start)&&this._load()},_isShown:function(){return this.$panel&&this.$panel.hasClass("open")},_load:function(){this.ajax.post({url:this.opts.handle.url,data:"handle="+this.handleStr,success:this._parse.bind(this)})},_parse:function(t){""===t||Array.isArray(t)&&0===t.length?this.$panel&&this.$panel.remove():(t="object"==typeof t?t:JSON.parse(t),this._build(t))},_build:function(t){for(var e in this.data=t,this.$panel=this.app.$body.find("."+this.prefix+"-panel"),0===this.$panel.length?(this.$panel=this.dom("<div>").addClass(this.prefix+"-panel"),this.app.$body.append(this.$panel)):this.$panel.html(""),this._stopEvents(),this._startEvents(),t){var i=this.dom("<div>").addClass(this.prefix+"-panel-item"),s=this.dom("<a>").attr("href","#");s.html(t[e].item),s.attr("data-key",e),s.on("click",this._replace.bind(this)),i.append(s),this.$panel.append(i)}var a=this.app.$doc.scrollTop(),n=this.app.selection.getPosition();this.$panel.addClass("open"),this.$panel.css({top:n.bottom+a+"px",left:n.left+"px"}),this.app.selection.save()},_replace:function(t,e){t.preventDefault(),t.stopPropagation();var i,s,a,e=(e?e.find("a"):this.dom(t.target)).attr("data-key"),t=this.data[e].replacement,e=(this.app.marker.insert("start"),this.app.marker.find("start"));!1!==e&&(i=this.dom(e),a=(e=e.previousSibling).textContent,s=new RegExp(this.opts.handle.trigger+this.handleStr+"$"),a=a.replace(s,""),e.textContent=a,i.before(t),this.app.selection.restoreMarker(),this._hide())},_reset:function(){this.handleStr=!1,this.handleLen=this.opts.handle.start,this.$panel=!1},_hide:function(t){var e=!1,i=t&&t.which,s=this.app.keycodes;(e=t&&"click"!==t.type&&i!==s.ESC&&i!==s.SPACE?e:!0)&&this._hideForce()},_hideForce:function(){this.$panel&&this.$panel.remove(),this._reset(),this._stopEvents()},_startEvents:function(){var t="click."+this.prefix+"-plugin-handle keydown."+this.prefix+"-plugin-handle";this.app.$doc.on(t,this._hide.bind(this)),this.app.editor.getEditor().on(t,this._hide.bind(this))},_stopEvents:function(){var t="."+this.prefix+"-plugin-handle";this.app.$doc.off(t),this.app.editor.getEditor().off(t)}}),RedactorX.add("plugin","handle",{translations:{en:{handle:{handle:"Handle"}}},defaults:{url:!1,start:1,trigger:"@"},subscribe:{"editor.keydown":function(t){this._listen(t)},"editor.keyup":function(t){!1!==this.opts.handle.url&&this._handle(t)}},start:function(){this.handleLen=this.opts.handle.start},stop:function(){this._hide()},_handle:function(t){var e=(t=t.get("e")).which,t=t.ctrlKey||t.metaKey,i=this.app.keycodes;e===i.ESC?this.app.selection.restore():e===i.DELETE||e===i.SPACE||e===i.SHIFT||t||-1!==[37,38,39,40].indexOf(e)||(e===i.BACKSPACE&&(this.handleLen=this.handleLen-2,this.handleLen<=this.opts.handle.start)&&this._hide(),this._emit())},_listen:function(t){var e,i=t.get("e"),s=i.which,a=this.app.keycodes;if(this._isShown()&&s===a.ENTER)return 0===(e=this._getActiveItem()).length?void this._hideForce():(i.preventDefault(),t.stop(),void this._replace(i,e));!this._isShown()||40!==s&&38!==s||(i.preventDefault(),t.stop(),0===(e=this._getActiveItem()).length?(a=this._getFirstItem(),this._setActive(a)):40===s?this._setNextActive(e):38===s&&this._setPrevActive(e))},_getItems:function(){return this.$panel.find("."+this.prefix+"-panel-item")},_getActiveItem:function(){return this._getItems().filter(function(t){return t.hasClass("active")})},_getFirstItem:function(){return this._getItems().first()},_getLastItem:function(){return this._getItems().last()},_setActive:function(t){this._getItems().removeClass("active"),t.addClass("active");var e=t.outerHeight(),t=t.position().top,i=this.$panel.scrollTop(),s=t+2*e,a=this.$panel.outerHeight();this.$panel.scrollTop(i+a<s?s-a:t-e<i?t-e:i)},_setNextActive:function(t){0===(t=t.next()).length&&(t=this._getFirstItem()),this._setActive(t)},_setPrevActive:function(t){0===(t=t.prev()).length&&(t=this._getLastItem()),this._setActive(t)},_emit:function(){var t=new RegExp("^"+this.opts.handle.trigger);this.handleStr=this.app.selection.getText("before",this.handleLen),this.handleStr2=this.app.selection.getText("before",this.handleLen+1),t.test(this.handleStr)&&(this.handleStr2&&" "===this.handleStr2[0]||""===this.handleStr2[0])&&(this.handleStr=this.handleStr.replace(this.opts.handle.trigger,""),this.handleLen++,this.handleLen-1>this.opts.handle.start)&&this._load()},_isShown:function(){return this.$panel&&this.$panel.hasClass("open")},_load:function(){this.ajax.post({url:this.opts.handle.url,data:"handle="+this.handleStr,success:this._parse.bind(this)})},_parse:function(t){""===t||Array.isArray(t)&&0===t.length?this.$panel&&this.$panel.remove():(t="object"==typeof t?t:JSON.parse(t),this._build(t))},_build:function(t){for(var e in this.data=t,this.$panel=this.app.$body.find("."+this.prefix+"-panel"),0===this.$panel.length?(this.$panel=this.dom("<div>").addClass(this.prefix+"-panel"),this.app.$body.append(this.$panel)):this.$panel.html(""),this._stopEvents(),this._startEvents(),t){var i=this.dom("<div>").addClass(this.prefix+"-panel-item"),s=this.dom("<a>").attr("href","#");s.html(t[e].item),s.attr("data-key",e),s.on("click",this._replace.bind(this)),i.append(s),this.$panel.append(i)}var a=this.app.$doc.scrollTop(),n=this.app.selection.getPosition();this.$panel.addClass("open"),this.$panel.css({top:n.bottom+a+"px",left:n.left+"px"}),this.app.selection.save()},_replace:function(t,e){t.preventDefault(),t.stopPropagation();var i,s,a,e=(e?e.find("a"):this.dom(t.target)).attr("data-key"),t=this.data[e].replacement;this.app.marker.insert("start"),!1!==(e=this.app.marker.find("start"))&&(i=this.dom(e),a=(e=e.previousSibling).textContent,s=new RegExp(this.opts.handle.trigger+this.handleStr+"$"),a=a.replace(s,""),e.textContent=a,i.before(t),this.app.selection.restoreMarker(),this._hide())},_reset:function(){this.handleStr=!1,this.handleLen=this.opts.handle.start,this.$panel=!1},_hide:function(t){var e=t&&t.which,i=this.app.keycodes;t&&"click"!==t.type&&e!==i.ESC&&e!==i.SPACE||this._hideForce()},_hideForce:function(){this.$panel&&this.$panel.remove(),this._reset(),this._stopEvents()},_startEvents:function(){var t="click."+this.prefix+"-plugin-handle keydown."+this.prefix+"-plugin-handle";this.app.$doc.on(t,this._hide.bind(this)),this.app.editor.getEditor().on(t,this._hide.bind(this))},_stopEvents:function(){var t="."+this.prefix+"-plugin-handle";this.app.$doc.off(t),this.app.editor.getEditor().off(t)}}),RedactorX.add("plugin","icons",{translations:{en:{icons:{icons:"Icons"}}},defaults:{icon:'<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m4.83610557 5.032-3.97464639.56135882-.11503066.02273502c-.74344369.19074743-1.01211485 1.14559722-.43257233 1.69388798l2.85824938 2.70401818-.67299733 3.8119764-.01354998.1096265c-.05329246.7582459.7508858 1.3132977 1.45280081.9551391l3.5617465-1.818742 3.56345043 1.8187308.1008624.0450315c.7094575.2728097 1.4755032-.3337453 1.3384209-1.1097256l-.6737337-3.8120367 2.8592493-2.70401818.0806168-.08514687c.4956567-.58602276.1617639-1.52007291-.6282281-1.63147731l-3.976638-.56135764-1.7716142-3.48521534c-.37065902-.72902616-1.41208515-.72905169-1.78277991-.0000437zm2.664-.826 1.11796025 2.19736628.06151847.10474119c.15723483.23391009.4074375.39236473.69024457.43224609l2.43527674.34264644-1.741257 1.6488901-.08529699.09144393c-.18419657.22405591-.26337869.51926707-.2122058.80894091l.41775979 2.36372506-2.22848404-1.1365651-.1252676-.0535184c-.25574273-.0891979-.53905484-.0713624-.78377298.0535073l-2.22947541 1.1365762.4187491-2.36366475.01403221-.12426844c.0144621-.28970819-.09782698-.57400297-.31152431-.77617671l-1.742257-1.6488901 2.43601084-.34264762c.3231876-.04557858.60379519-.24600908.75173246-.53694239z"/></svg>',items:['<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><g fill="#000" fill-rule="nonzero"><path d="m8 14c3.3137085 0 6-2.6862915 6-6s-2.6862915-6-6-6-6 2.6862915-6 6 2.6862915 6 6 6zm0 2c-4.418278 0-8-3.581722-8-8s3.581722-8 8-8 8 3.581722 8 8-3.581722 8-8 8z"/><path d="m5.5 7.98901099c0-1.34799209.21516178-2.34981357.6454918-3.00549451.43033002-.65568093 1.04849324-.98351648 1.8545082-.98351648.86066004 0 1.49248432.32417258 1.8954918.97252747.4030075.64835489.6045082 1.65383934.6045082 3.01648352 0 1.35531813-.2168694 2.36263411-.65061475 3.02197801-.43374534.659344-1.05361619.989011-1.85963115.989011-.85382941 0-1.48223842-.3461504-1.8852459-1.0384615-.40300748-.6923112-.6045082-1.68314377-.6045082-2.97252751zm1.33196721 0c0 .89377736.09050456 1.58424665.2715164 2.07142861.18101183.4871819.47984764.7307692.89651639.7307692.40300748 0 .69842802-.223441.88627049-.6703297.18784247-.44688866.2817623-1.15750426.2817623-2.13186811 0-.88645132-.08879693-1.57142615-.26639345-2.05494506-.17759651-.4835189-.48155522-.72527472-.91188524-.72527472-.40983812 0-.70525866.22710395-.88627049.68131868-.18101184.45421473-.2715164 1.15384143-.2715164 2.0989011z"/></g></svg>','<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><g fill="#000" fill-rule="nonzero"><path d="m8 14c3.3137085 0 6-2.6862915 6-6s-2.6862915-6-6-6-6 2.6862915-6 6 2.6862915 6 6 6zm0 2c-4.418278 0-8-3.581722-8-8s3.581722-8 8-8 8 3.581722 8 8-3.581722 8-8 8z"/><path d="m5.93478261 10.7640449h1.59038901v-4.4382022l.17162472-.76404495-.54919909.66292135-1.01830663.68539326-.62929062-.84269663 2.60869565-2.06741573h.83524028v6.7640449h1.55606407v1.2359551h-4.56521739z"/></g></svg>','<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><g fill="#000" fill-rule="nonzero"><path d="m8 14c3.3137085 0 6-2.6862915 6-6s-2.6862915-6-6-6-6 2.6862915-6 6 2.6862915 6 6 6zm0 2c-4.418278 0-8-3.581722-8-8s3.581722-8 8-8 8 3.581722 8 8-3.581722 8-8 8z"/><path d="m10.3218527 6.07282913c0 .38095429-.0732376.76563765-.2197149 1.15406163-.14647741.38842397-.33254047.76937255-.55819481 1.14285714-.22565433.37348459-.47505801.73389182-.74821852 1.08123249-.27316052.34734067-.54037875.66666521-.80166271.95798321l-.62945368.4593837v.0560224l.85510688-.1568627h2.28028504v1.232493h-5v-.7507003c.1900247-.1867423.40379929-.4052275.64133017-.6554622.23753088-.2502346.47703759-.5154047.71852731-.79551817.24148973-.28011345.47703765-.56955967.70665083-.86834734.22961319-.29878768.43547019-.59943826.6175772-.90196079.18210701-.30252252.32660279-.59570352.43349169-.87955182.10688889-.28384829.16033254-.55275316.16033254-.80672269 0-.30625736-.09303153-.55835568-.27909739-.75630252-.18606585-.19794683-.4809956-.29691876-.8847981-.29691876-.25336627 0-.51266692.05041966-.77790974.1512605-.26524281.10084084-.48891437.22969109-.67102137.38655462l-.6175772-1.03081232c.30879014-.23903014.65914293-.43137182 1.05106888-.57703082.39192595-.14565899.85312482-.21848739 1.38361045-.21848739.34046093 0 .65320523.04481748.93824228.13445378.28503706.0896363.53048195.22035395.73634205.39215686.20586009.17180292.3681704.38655334.4869359.64425771.1187654.25770437.1781472.55835496.1781472.90196078z"/></g></svg>','<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><g fill="#000" fill-rule="nonzero"><path d="m8 14c3.3137085 0 6-2.6862915 6-6s-2.6862915-6-6-6-6 2.6862915-6 6 2.6862915 6 6 6zm0 2c-4.418278 0-8-3.581722-8-8s3.581722-8 8-8 8 3.581722 8 8-3.581722 8-8 8z"/><path d="m7.44047619 10.767507c.49206595 0 .8670622-.1232481 1.125-.3697479s.38690476-.54528302.38690476-.89635854c0-.42577244-.13491928-.73949479-.4047619-.94117647s-.69444155-.30252101-1.27380953-.30252101h-.85714285v-.77310924l1.44047619-1.8487395.67857143-.50420168-.94047619.10084034h-2v-1.232493h4.547619v.79551821l-1.67857139 2.11764706-.52380952.302521v.05602241l.5-.06722689c.27777917.02240908.54166542.08216572.79166667.17927171.25000125.097106.46825303.23716062.6547619.42016807.18650884.18300745.33531694.40896224.44642854.67787115.1111117.2689089.1666667.57889647.1666667.92997199 0 .44071182-.0773802.82166039-.2321429 1.14285709-.1547626.3211968-.36904621.5901017-.6428571.8067227-.27381089.2166211-.59325214.3772171-.95833333.4817928-.36508119.1045756-.75793441.1568627-1.17857143.1568627-.3492081 0-.7103156-.0298783-1.08333334-.0896359-.37301773-.0597575-.67460202-.1456577-.9047619-.257703l.41666667-1.2100841c.20635023.097106.43452256.1755366.68452381.2352941.25000125.0597576.52976035.0896359.83928571.0896359z"/></g></svg>','<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><g fill="#000" fill-rule="nonzero"><path d="m8 14c3.3137085 0 6-2.6862915 6-6s-2.6862915-6-6-6-6 2.6862915-6 6 2.6862915 6 6 6zm0 2c-4.418278 0-8-3.581722-8-8s3.581722-8 8-8 8 3.581722 8 8-3.581722 8-8 8z"/><path d="m10.5 9.78723404h-1.23595506v2.21276596h-1.35955056v-2.21276596h-3.40449438v-.83971631l3.56179775-4.94751773h1.20224719v4.6070922h1.23595506zm-2.59550562-2.91631205.1011236-.95319149h-.04494382l-.38202247.81702127-1.16853933 1.5319149-.56179775.43120567.71910112-.09078014h1.33707865z"/></g></svg>','<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><g fill="#000" fill-rule="nonzero"><path d="m8 14c3.3137085 0 6-2.6862915 6-6s-2.6862915-6-6-6-6 2.6862915-6 6 2.6862915 6 6 6zm0 2c-4.418278 0-8-3.581722-8-8s3.581722-8 8-8 8 3.581722 8 8-3.581722 8-8 8z"/><path d="m7.31818182 10.7114846c.52631842 0 .92902572-.1195133 1.20813397-.3585434.27910825-.2390302.41866029-.56769168.41866029-.98599442 0-.44818151-.16347524-.77684303-.49043063-.9859944-.32695538-.20915137-.79345789-.31372549-1.39952153-.31372549l-.94497607.03361345v-4.10084034h4.11483255v1.36694678h-2.77511963v1.51260504l.49043062-.04481793c.39075155.01493939.74361884.08216561 1.05861244.20168068s.58412966.28571322.80741627.49859944c.2232866.21288621.3947362.47058672.5143541.77310924.1196178.30252252.1794258.64052101.1794258 1.0140056 0 .44071182-.079744.82912995-.2392344 1.16526615-.1594905.3361361-.38078013.6162453-.66387565.8403361-.28309551.2240907-.61602679.3921563-.99880383.5042017-.38277703.1120454-.80143313.1680672-1.25598086.1680672-.35885347 0-.69975915-.0280109-1.02272727-.0840336s-.59609139-.1325859-.81937799-.2296919l.41866029-1.210084c.18341399.0746969.38476764.1325861.60406698.1736694s.48444821.0616247.79545455.0616247z"/></g></svg>','<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><g fill="#000" fill-rule="nonzero"><path d="m8 14c3.3137085 0 6-2.6862915 6-6s-2.6862915-6-6-6-6 2.6862915-6 6 2.6862915 6 6 6zm0 2c-4.418278 0-8-3.581722-8-8s3.581722-8 8-8 8 3.581722 8 8-3.581722 8-8 8z"/><path d="m10.5 9.46153846c0 .35897616-.0587601.69230614-.1762821 1.00000004-.1175219.3076938-.2831185.5750904-.49679482.8021978-.21367629.2271073-.47186459.4065927-.77457265.5384615-.30270807.1318688-.63568195.1978022-.99893163.1978022-.37037222 0-.71046853-.060439-1.02029914-.1813187s-.57870257-.3021966-.80662393-.543956c-.22792137-.2417595-.40598227-.5457857-.53418804-.9120879-.12820577-.36630224-.19230769-.79120641-.19230769-1.27472531 0-.72527835.10149471-1.38094945.30448718-1.96703297s.47720625-1.09706742.82264957-1.53296703c.34544332-.43589962.74786095-.78754445 1.20726496-1.05494506.45940401-.2674006.94551026-.4450545 1.45833333-.53296703l.30982906 1.13186813c-.35612713.05860835-.68375919.17216033-.98290598.34065934-.2991468.16849901-.56445753.3699622-.79594017.60439561-.23148264.2344334-.42734963.49633555-.58760684.78571428-.16025721.28937874-.27243558.58791055-.33653846.8956044.14245085-.1831511.32763419-.3388272.55555556-.46703297.22792136-.12820577.5128188-.19230769.85470085-.19230769.32051442 0 .61609551.05128154.88675214.15384615.27065662.10256462.50213579.25457775.69444444.45604396.19230866.20146621.34187976.44871648.44871796.74175824.1068381.29304176.1602564.63003473.1602564 1.01098901zm-1.34615385.07692308c0-.82051692-.39173397-1.23076923-1.17521367-1.23076923-.28490171 0-.52528392.0659334-.72115385.1978022-.19586992.13186879-.33297681.2857134-.41132478.46153846-.01424509.08058648-.02136753.15018285-.02136753.20879121v.17582417c0 .17582506.02492853.34981599.07478633.52197802s.12286277.32600663.21901709.46153843c.09615433.1355318.21901635.2454209.36858975.3296704.14957339.0842495.32763429.1263736.53418803.1263736.33475951 0 .60719268-.117215.81730769-.3516484s.31517094-.53479666.31517094-.90109886z"/></g></svg>','<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><g fill="#000" fill-rule="nonzero"><path d="m8 14c3.3137085 0 6-2.6862915 6-6s-2.6862915-6-6-6-6 2.6862915-6 6 2.6862915 6 6 6zm0 2c-4.418278 0-8-3.581722-8-8s3.581722-8 8-8 8 3.581722 8 8-3.581722 8-8 8z"/><path d="m5.98780488 12 2.53880266-6.16.48780488-.56-.66518847.11428571h-2.84922395v-1.39428571h5v.43428571l-3.10421286 7.56571429z"/></g></svg>','<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><g fill="#000" fill-rule="nonzero"><path d="m8 14c3.3137085 0 6-2.6862915 6-6s-2.6862915-6-6-6-6 2.6862915-6 6 2.6862915 6 6 6zm0 2c-4.418278 0-8-3.581722-8-8s3.581722-8 8-8 8 3.581722 8 8-3.581722 8-8 8z"/><path d="m5.5 9.96703297c0-.25641154.03363195-.48534698.10089686-.68681319s.16255544-.38461456.28587444-.54945055.26905746-.31318615.43721973-.44505494c.16816228-.1318688.34940112-.25274671.54372197-.36263737-.36622006-.22710736-.65396009-.4890095-.8632287-.78571428-.2092686-.29670478-.31390134-.66483297-.31390134-1.10439561 0-.28571571.05418481-.5531123.16255605-.8021978.10837125-.24908549.26532035-.46520055.47085202-.64835165s.45403442-.32600681.7455157-.42857143c.29148127-.10256461.62032701-.15384615.98654708-.15384615.33632455 0 .64274899.0439556.91928251.13186813s.51382562.21245341.71188341.37362638c.19805779.16117296.35126997.3571417.45964127.58791208.1083712.23077039.162556.4853466.162556.76373627 0 .43223659-.0990274.79853329-.2970852 1.0989011-.19805775.3003678-.48766622.57509033-.86883404.82417582.44843273.25641154.78662068.53846 1.01457394.84615385.2279534.30769384.3419283.70329428.3419283 1.18681318 0 .32967199-.0616586.62820379-.1849776.89560439s-.2970841.4963361-.52130043.6868132c-.22421636.1904771-.49327197.3388273-.80717488.4450549-.31390292.1062277-.65769619.1593407-1.03139014.1593407s-.71188189-.0494501-1.01457399-.1483516c-.3026921-.0989016-.56053705-.2362629-.7735426-.412088-.21300555-.175825-.37742842-.3882771-.49327354-.6373626-.11584513-.2490855-.17376682-.527471-.17376682-.83516483zm3.60986547-.14285715c0-.16849901-.04110572-.32234362-.12331838-.46153846-.08221267-.13919483-.18871385-.2655672-.31950673-.37912088s-.27653134-.21794824-.43721973-.31318681c-.1606884-.09523857-.32324283-.18681275-.48766816-.27472527-.35127231.19780318-.59230129.41208675-.72309417.64285714-.13079289.23077038-.19618834.45970582-.19618834.68681319 0 .29304177.10276429.54395497.30829596.75274727.20553167.2087922.49140325.3131868.85762332.3131868.33632455 0 .6072486-.0805853.81278027-.2417583.20553167-.1611729.30829596-.4029287.30829596-.72527468zm-2.02914798-3.76923077c0 .17582506.03363195.32966968.10089686.46153847s.15881855.24725225.27466368.34615384c.11584512.0989016.24663604.19047577.39237668.27472528.14574064.0842495.29708442.16300329.45403587.23626373.44843274-.37362824.67264574-.78388055.67264574-1.23076923 0-.30769384-.09155364-.54029225-.27466367-.69780219-.18311004-.15750995-.4054546-.23626374-.66704036-.23626374-.32885068 0-.56987966.08424824-.72309417.25274725-.15321452.16849901-.22982063.36629923-.22982063.59340659z"/></g></svg>','<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><g fill="#000" fill-rule="nonzero"><path d="m8 14c3.3137085 0 6-2.6862915 6-6s-2.6862915-6-6-6-6 2.6862915-6 6 2.6862915 6 6 6zm0 2c-4.418278 0-8-3.581722-8-8s3.581722-8 8-8 8 3.581722 8 8-3.581722 8-8 8z"/><path d="m5.5 6.56043956c0-.37362824.05473109-.71794714.16419492-1.03296703.10946382-.31501989.26836054-.58424797.47669491-.80769231.20833438-.22344434.46256912-.39926676.76271186-.52747253.30014275-.12820577.64441897-.19230769 1.03283899-.19230769.79802659 0 1.42478586.24725027 1.88029661.74175824.45551071.49450797.68326271 1.21428099.68326271 2.15934066 0 .8498211-.1041656 1.58424599-.3125 2.2032967-.20833437.61905072-.48728639 1.1355291-.83686441 1.5494506-.34957802.4139214-.75388188.7307681-1.21292373.9505494-.45904184.2197813-.94279406.3516481-1.45127118.3956044l-.29661017-1.1208791c.38842002-.0512823.73446176-.1501824 1.03813559-.2967033.30367384-.1465209.56497066-.3278378.78389831-.5439561.21892765-.21611826.39724507-.46153705.53495762-.7362637.13771256-.27472665.23481611-.56959549.29131356-.88461538-.16949237.19047714-.35134083.32234395-.54555084.39560439s-.45374132.10989011-.7786017.10989011c-.26836292 0-.5349563-.04761857-.79978813-.14285714-.26483184-.09523857-.50141139-.23992577-.70974577-.43406593-.20833437-.19414017-.3778242-.43955896-.50847457-.73626374s-.19597458-.64651813-.19597458-1.04945055zm1.33474576-.07692308c0 .41758451.11299322.73259967.33898305.94505495.22598983.21245527.50847288.31868132.84745763.31868132.28954947 0 .52612903-.04761857.70974576-.14285715.18361674-.09523857.32485827-.21245351.42372882-.35164835.02118654-.15384692.03177966-.3003656.03177966-.43956044 0-.20512923-.02471727-.40659241-.07415254-.6043956-.04943528-.19780319-.1253526-.37362561-.22775424-.52747253s-.23305005-.27655632-.39194915-.36813187-.34780964-.13736263-.56673729-.13736263c-.34604693 0-.61440583.11538346-.80508475.34615384-.19067892.23077039-.28601695.55128-.28601695.96153846z"/></g></svg>','<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m8 16c-4.418278 0-8-3.581722-8-8s3.581722-8 8-8 8 3.581722 8 8-3.581722 8-8 8zm-2.5-8.01098901c0 1.28938374.20150072 2.28021631.6045082 2.97252751.40300748.6923111 1.03141649 1.0384615 1.8852459 1.0384615.80601496 0 1.42588581-.329667 1.85963115-.989011.43374535-.6593439.65061475-1.66665988.65061475-3.02197801 0-1.36264418-.2015007-2.36812863-.6045082-3.01648352-.40300748-.64835489-1.03483176-.97252747-1.8954918-.97252747-.80601496 0-1.42417818.32783555-1.8545082.98351648-.43033002.65568094-.6454918 1.65750242-.6454918 3.00549451zm1.33196721 0c0-.94505967.09050456-1.64468637.2715164-2.0989011.18101183-.45421473.47643237-.68131868.88627049-.68131868.43033002 0 .73428873.24175582.91188524.72527472.17759652.48351891.26639345 1.16849374.26639345 2.05494506 0 .97436385-.09391983 1.68497945-.2817623 2.13186811-.18784247.4468887-.48326301.6703297-.88627049.6703297-.41666875 0-.71550456-.2435873-.89651639-.7307692-.18101184-.48718196-.2715164-1.17765125-.2715164-2.07142861z"/></svg>','<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m8 16c-4.418278 0-8-3.581722-8-8s3.581722-8 8-8 8 3.581722 8 8-3.581722 8-8 8zm-2.06521739-5.2359551v1.2359551h4.56521739v-1.2359551h-1.55606407v-6.7640449h-.83524028l-2.60869565 2.06741573.62929062.84269663 1.01830663-.68539326.54919909-.66292135-.17162472.76404495v4.4382022z"/></svg>','<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m8 16c-4.418278 0-8-3.581722-8-8s3.581722-8 8-8 8 3.581722 8 8-3.581722 8-8 8zm2.3218527-9.92717087c0-.34360582-.0593818-.64425641-.1781472-.90196078-.1187655-.25770437-.28107581-.47245479-.4869359-.64425771-.2058601-.17180291-.45130499-.30252056-.73634205-.39215686-.28503705-.0896363-.59778135-.13445378-.93824228-.13445378-.53048563 0-.9916845.0728284-1.38361045.21848739-.39192595.145659-.74227874.33800068-1.05106888.57703082l.6175772 1.03081232c.182107-.15686353.40577856-.28571378.67102137-.38655462.26524282-.10084084.52454347-.1512605.77790974-.1512605.4038025 0 .69873225.09897193.8847981.29691876.18606586.19794684.27909739.45004516.27909739.75630252 0 .25396953-.05344365.5228744-.16033254.80672269-.1068889.2838483-.25138468.5770293-.43349169.87955182-.18210701.30252253-.38796401.60317311-.6175772.90196079-.22961318.29878767-.4651611.58823389-.70665083.86834734-.24148972.28011347-.48099643.54528357-.71852731.79551817-.23753088.2502347-.45130547.4687199-.64133017.6554622v.7507003h5v-1.232493h-2.28028504l-.85510688.1568627v-.0560224l.62945368-.4593837c.26128396-.291318.52850219-.61064254.80166271-.95798321.27316051-.34734067.52256419-.7077479.74821852-1.08123249.22565434-.37348459.4117174-.75443317.55819481-1.14285714.1464773-.38842398.2197149-.77310734.2197149-1.15406163z"/></svg>','<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m8 16c-4.418278 0-8-3.581722-8-8s3.581722-8 8-8 8 3.581722 8 8-3.581722 8-8 8zm-.55952381-5.232493c-.30952536 0-.58928446-.0298783-.83928571-.0896359-.25000125-.0597575-.47817358-.1381881-.68452381-.2352941l-.41666667 1.2100841c.23015988.1120453.53174417.1979455.9047619.257703.37301774.0597576.73412524.0896359 1.08333334.0896359.42063702 0 .81349024-.0522871 1.17857143-.1568627.36508119-.1045757.68452244-.2651717.95833333-.4817928.27381089-.216621.4880945-.4855259.6428571-.8067227.1547627-.3211967.2321429-.70214527.2321429-1.14285709 0-.35107552-.055555-.66106309-.1666667-.92997199-.1111116-.26890891-.2599197-.4948637-.44642854-.67787115-.18650887-.18300745-.40476065-.32306207-.6547619-.42016807-.25000125-.09710599-.5138875-.15686263-.79166667-.17927171l-.5.06722689v-.05602241l.52380952-.302521 1.67857139-2.11764706v-.79551821h-4.547619v1.232493h2l.94047619-.10084034-.67857143.50420168-1.44047619 1.8487395v.77310924h.85714285c.57936798 0 1.00396691.10083933 1.27380953.30252101s.4047619.51540403.4047619.94117647c0 .35107552-.12896696.64985874-.38690476.89635854s-.63293405.3697479-1.125.3697479z"/></svg>','<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m8 16c-4.418278 0-8-3.581722-8-8s3.581722-8 8-8 8 3.581722 8 8-3.581722 8-8 8zm2.5-6.21276596v-1.18014184h-1.23595506v-4.6070922h-1.20224719l-3.56179775 4.94751773v.83971631h3.40449438v2.21276596h1.35955056v-2.21276596zm-2.59550562-2.91631205v1.73617021h-1.33707865l-.71910112.09078014.56179775-.43120567 1.16853933-1.5319149.38202247-.81702127h.04494382z"/></svg>','<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m8 16c-4.418278 0-8-3.581722-8-8s3.581722-8 8-8 8 3.581722 8 8-3.581722 8-8 8zm-.68181818-5.2885154c-.31100634 0-.57615521-.0205414-.79545455-.0616247s-.42065299-.0989725-.60406698-.1736694l-.41866029 1.210084c.2232866.097106.49640987.1736692.81937799.2296919s.6638738.0840336 1.02272727.0840336c.45454773 0 .87320383-.0560218 1.25598086-.1680672.38277704-.1120454.71570832-.280111.99880383-.5042017.28309552-.2240908.50438515-.5042.66387565-.8403361.1594904-.3361362.2392344-.72455433.2392344-1.16526615 0-.37348459-.059808-.71148308-.1794258-1.0140056-.1196179-.30252252-.2910675-.56022303-.5143541-.77310924-.22328661-.21288622-.49242267-.37908437-.80741627-.49859944s-.66786089-.18674129-1.05861244-.20168068l-.49043062.04481793v-1.51260504h2.77511963v-1.36694678h-4.11483255v4.10084034l.94497607-.03361345c.60606364 0 1.07256615.10457412 1.39952153.31372549.32695539.20915137.49043063.53781289.49043063.9859944 0 .41830274-.13955204.74696422-.41866029.98599442-.27910825.2390301-.68181555.3585434-1.20813397.3585434z"/></svg>','<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m8 16c-4.418278 0-8-3.581722-8-8s3.581722-8 8-8 8 3.581722 8 8-3.581722 8-8 8zm2.5-6.53846154c0-.38095428-.0534183-.71794725-.1602564-1.01098901-.1068382-.29304176-.2564093-.54029203-.44871796-.74175824-.19230865-.20146621-.42378782-.35347934-.69444444-.45604396-.27065663-.10256461-.56623772-.15384615-.88675214-.15384615-.34188205 0-.62677949.06410192-.85470085.19230769-.22792137.12820577-.41310471.28388187-.55555556.46703297.06410288-.30769385.17628125-.60622566.33653846-.8956044.16025721-.28937873.3561242-.55128088.58760684-.78571428.23148264-.23443341.49679337-.4358966.79594017-.60439561.29914679-.16849901.62677885-.28205099.98290598-.34065934l-.30982906-1.13186813c-.51282307.08791253-.99892932.26556643-1.45833333.53296703-.45940401.26740061-.86182164.61904544-1.20726496 1.05494506-.34544332.43589961-.6196571.94688351-.82264957 1.53296703s-.30448718 1.24175462-.30448718 1.96703297c0 .4835189.06410192.90842307.19230769 1.27472531.12820577.3663022.30626667.6703284.53418804.9120879.22792136.2417594.49679332.4230763.80662393.543956s.64992692.1813187 1.02029914.1813187c.36324968 0 .69622356-.0659334.99893163-.1978022.30270806-.1318688.56089636-.3113542.77457265-.5384615.21367632-.2271074.37927292-.494504.49679482-.8021978.117522-.3076939.1762821-.64102388.1762821-1.00000004zm-1.34615385.07692308c0 .3663022-.10505593.66666546-.31517094.90109886s-.48254818.3516484-.81730769.3516484c-.20655374 0-.38461464-.0421241-.53418803-.1263736-.1495734-.0842495-.27243542-.1941386-.36858975-.3296704-.09615432-.1355318-.16915929-.2893764-.21901709-.46153843s-.07478633-.34615296-.07478633-.52197802c0-.05860835 0-.11721582 0-.17582417 0-.05860836.00712244-.12820473.02136753-.20879121.07834797-.17582506.21545486-.32966967.41132478-.46153846.19586993-.1318688.43625214-.1978022.72115385-.1978022.7834797 0 1.17521367.41025231 1.17521367 1.23076923z"/></svg>','<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m8 16c-4.418278 0-8-3.581722-8-8s3.581722-8 8-8 8 3.581722 8 8-3.581722 8-8 8zm-2.01219512-4h1.40798226l3.10421286-7.56571429v-.43428571h-5v1.39428571h2.84922395l.66518847-.11428571-.48780488.56z"/></svg>','<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m8 16c-4.418278 0-8-3.581722-8-8s3.581722-8 8-8 8 3.581722 8 8-3.581722 8-8 8zm-2.5-6.03296703c0 .30769383.05792169.58607933.17376682.83516483.11584512.2490855.28026799.4615376.49327354.6373626.21300555.1758251.4708505.3131864.7735426.412088.3026921.0989015.64088004.1483516 1.01457399.1483516s.71748722-.053113 1.03139014-.1593407c.31390291-.1062276.58295852-.2545778.80717488-.4450549.22421633-.1904771.39798143-.4194126.52130043-.6868132s.1849776-.5659324.1849776-.89560439c0-.4835189-.1139749-.87911934-.3419283-1.18681318-.22795326-.30769385-.56614121-.58974231-1.01457394-.84615385.38116782-.24908549.67077629-.52380802.86883404-.82417582.1980578-.30036781.2970852-.66666451.2970852-1.0989011 0-.27838967-.0541848-.53296588-.162556-.76373627-.1083713-.23077038-.26158348-.42673912-.45964127-.58791208-.19805779-.16117297-.43534989-.28571385-.71188341-.37362638s-.58295796-.13186813-.91928251-.13186813c-.36622007 0-.69506581.05128154-.98654708.15384615-.29148128.10256462-.53998403.24542033-.7455157.42857143s-.36248077.39926616-.47085202.64835165c-.10837124.2490855-.16255605.51648209-.16255605.8021978 0 .43956264.10463274.80769083.31390134 1.10439561.20926861.29670478.49700864.55860692.8632287.78571428-.19432085.10989066-.37555969.23076857-.54372197.36263737-.16816227.13186879-.31390073.28021895-.43721973.44505494s-.21860953.34798434-.28587444.54945055-.10089686.43040165-.10089686.68681319zm3.60986547-.14285715c0 .32234598-.10276429.56410178-.30829596.72527468-.20553167.161173-.47645572.2417583-.81278027.2417583-.36622007 0-.65209165-.1043946-.85762332-.3131868-.20553167-.2087923-.30829596-.4597055-.30829596-.75274727 0-.22710737.06539545-.45604281.19618834-.68681319.13079288-.23077039.37182186-.44505396.72309417-.64285714.16442533.08791252.32697976.1794867.48766816.27472527.16068839.09523857.30642685.19963313.43721973.31318681s.23729406.23992605.31950673.37912088c.08221266.13919484.12331838.29303945.12331838.46153846zm-2.02914798-3.76923077c0-.22710736.07660611-.42490758.22982063-.59340659.15321451-.16849901.39424349-.25274725.72309417-.25274725.26158576 0 .48393032.07875379.66704036.23626374.18311003.15750994.27466367.39010835.27466367.69780219 0 .44688868-.224213.85714099-.67264574 1.23076923-.15695145-.07326044-.30829523-.15201423-.45403587-.23626373-.14574064-.08424951-.27653156-.17582368-.39237668-.27472528-.11584513-.09890159-.20739877-.21428505-.27466368-.34615384s-.10089686-.28571341-.10089686-.46153847z"/></svg>','<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m8 16c-4.418278 0-8-3.581722-8-8s3.581722-8 8-8 8 3.581722 8 8-3.581722 8-8 8zm-2.5-9.43956044c0 .40293242.06532421.75274577.19597458 1.04945055s.3001402.54212357.50847457.73626374c.20833438.19414016.44491393.33882736.70974577.43406593.26483183.09523857.53142521.14285714.79978813.14285714.32486038 0 .58439169-.03662967.7786017-.10989011s.37605847-.20512725.54555084-.39560439c-.05649745.31501989-.153601.60988873-.29131356.88461538-.13771255.27472665-.31602997.52014544-.53495762.7362637-.21892765.2161183-.48022447.3974352-.78389831.5439561-.30367383.1465209-.64971557.245421-1.03813559.2967033l.29661017 1.1208791c.50847712-.0439563.99222934-.1758231 1.45127118-.3956044.45904185-.2197813.86334571-.536628 1.21292373-.9505494.34957802-.4139215.62853004-.93039988.83686441-1.5494506.2083344-.61905071.3125-1.3534756.3125-2.2032967 0-.94505967-.227752-1.66483269-.68326271-2.15934066-.45551075-.49450797-1.08227002-.74175824-1.88029661-.74175824-.38842002 0-.73269624.06410192-1.03283899.19230769-.30014274.12820577-.55437748.30402819-.76271186.52747253-.20833437.22344434-.36723109.49267242-.47669491.80769231-.10946383.31501989-.16419492.65933879-.16419492 1.03296703zm1.33474576-.07692308c0-.41025846.09533803-.73076807.28601695-.96153846.19067892-.23077038.45903782-.34615384.80508475-.34615384.21892765 0 .40783819.04578708.56673729.13736263s.28954751.21428495.39194915.36813187.17831896.32966934.22775424.52747253c.04943527.19780319.07415254.39926637.07415254.6043956 0 .13919484-.01059312.28571352-.03177966.43956044-.09887055.13919484-.24011208.25640978-.42372882.35164835-.18361673.09523858-.42019629.14285715-.70974576.14285715-.33898475 0-.6214678-.10622605-.84745763-.31868132-.22598983-.21245528-.33898305-.52747044-.33898305-.94505495z"/></svg>']},start:function(){var t={title:"## icons.icons ##",icon:this.opts.icons.icon,command:"icons.popup",blocks:{all:"editable"}};this.app.toolbar.add("icons",t)},popup:function(t,e){for(var i={},s=this.opts.icons.items,a=0;a<s.length;a++)i[a]={html:this.dom("<div>").addClass(this.prefix+"-popup-item").html(s[a]),command:"icons.insert",params:{icon:s[a]}};this.app.popup.create("icons",{type:"grid",width:"160px",items:i}),this.app.popup.open({button:e})},insert:function(t){this.app.popup.close(),this.app.insertion.insertHtml(t.icon,"after")}}),RedactorX.add("plugin","icons",{translations:{en:{icons:{icons:"Icons"}}},defaults:{icon:'<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m4.83610557 5.032-3.97464639.56135882-.11503066.02273502c-.74344369.19074743-1.01211485 1.14559722-.43257233 1.69388798l2.85824938 2.70401818-.67299733 3.8119764-.01354998.1096265c-.05329246.7582459.7508858 1.3132977 1.45280081.9551391l3.5617465-1.818742 3.56345043 1.8187308.1008624.0450315c.7094575.2728097 1.4755032-.3337453 1.3384209-1.1097256l-.6737337-3.8120367 2.8592493-2.70401818.0806168-.08514687c.4956567-.58602276.1617639-1.52007291-.6282281-1.63147731l-3.976638-.56135764-1.7716142-3.48521534c-.37065902-.72902616-1.41208515-.72905169-1.78277991-.0000437zm2.664-.826 1.11796025 2.19736628.06151847.10474119c.15723483.23391009.4074375.39236473.69024457.43224609l2.43527674.34264644-1.741257 1.6488901-.08529699.09144393c-.18419657.22405591-.26337869.51926707-.2122058.80894091l.41775979 2.36372506-2.22848404-1.1365651-.1252676-.0535184c-.25574273-.0891979-.53905484-.0713624-.78377298.0535073l-2.22947541 1.1365762.4187491-2.36366475.01403221-.12426844c.0144621-.28970819-.09782698-.57400297-.31152431-.77617671l-1.742257-1.6488901 2.43601084-.34264762c.3231876-.04557858.60379519-.24600908.75173246-.53694239z"/></svg>',items:['<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><g fill="#000" fill-rule="nonzero"><path d="m8 14c3.3137085 0 6-2.6862915 6-6s-2.6862915-6-6-6-6 2.6862915-6 6 2.6862915 6 6 6zm0 2c-4.418278 0-8-3.581722-8-8s3.581722-8 8-8 8 3.581722 8 8-3.581722 8-8 8z"/><path d="m5.5 7.98901099c0-1.34799209.21516178-2.34981357.6454918-3.00549451.43033002-.65568093 1.04849324-.98351648 1.8545082-.98351648.86066004 0 1.49248432.32417258 1.8954918.97252747.4030075.64835489.6045082 1.65383934.6045082 3.01648352 0 1.35531813-.2168694 2.36263411-.65061475 3.02197801-.43374534.659344-1.05361619.989011-1.85963115.989011-.85382941 0-1.48223842-.3461504-1.8852459-1.0384615-.40300748-.6923112-.6045082-1.68314377-.6045082-2.97252751zm1.33196721 0c0 .89377736.09050456 1.58424665.2715164 2.07142861.18101183.4871819.47984764.7307692.89651639.7307692.40300748 0 .69842802-.223441.88627049-.6703297.18784247-.44688866.2817623-1.15750426.2817623-2.13186811 0-.88645132-.08879693-1.57142615-.26639345-2.05494506-.17759651-.4835189-.48155522-.72527472-.91188524-.72527472-.40983812 0-.70525866.22710395-.88627049.68131868-.18101184.45421473-.2715164 1.15384143-.2715164 2.0989011z"/></g></svg>','<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><g fill="#000" fill-rule="nonzero"><path d="m8 14c3.3137085 0 6-2.6862915 6-6s-2.6862915-6-6-6-6 2.6862915-6 6 2.6862915 6 6 6zm0 2c-4.418278 0-8-3.581722-8-8s3.581722-8 8-8 8 3.581722 8 8-3.581722 8-8 8z"/><path d="m5.93478261 10.7640449h1.59038901v-4.4382022l.17162472-.76404495-.54919909.66292135-1.01830663.68539326-.62929062-.84269663 2.60869565-2.06741573h.83524028v6.7640449h1.55606407v1.2359551h-4.56521739z"/></g></svg>','<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><g fill="#000" fill-rule="nonzero"><path d="m8 14c3.3137085 0 6-2.6862915 6-6s-2.6862915-6-6-6-6 2.6862915-6 6 2.6862915 6 6 6zm0 2c-4.418278 0-8-3.581722-8-8s3.581722-8 8-8 8 3.581722 8 8-3.581722 8-8 8z"/><path d="m10.3218527 6.07282913c0 .38095429-.0732376.76563765-.2197149 1.15406163-.14647741.38842397-.33254047.76937255-.55819481 1.14285714-.22565433.37348459-.47505801.73389182-.74821852 1.08123249-.27316052.34734067-.54037875.66666521-.80166271.95798321l-.62945368.4593837v.0560224l.85510688-.1568627h2.28028504v1.232493h-5v-.7507003c.1900247-.1867423.40379929-.4052275.64133017-.6554622.23753088-.2502346.47703759-.5154047.71852731-.79551817.24148973-.28011345.47703765-.56955967.70665083-.86834734.22961319-.29878768.43547019-.59943826.6175772-.90196079.18210701-.30252252.32660279-.59570352.43349169-.87955182.10688889-.28384829.16033254-.55275316.16033254-.80672269 0-.30625736-.09303153-.55835568-.27909739-.75630252-.18606585-.19794683-.4809956-.29691876-.8847981-.29691876-.25336627 0-.51266692.05041966-.77790974.1512605-.26524281.10084084-.48891437.22969109-.67102137.38655462l-.6175772-1.03081232c.30879014-.23903014.65914293-.43137182 1.05106888-.57703082.39192595-.14565899.85312482-.21848739 1.38361045-.21848739.34046093 0 .65320523.04481748.93824228.13445378.28503706.0896363.53048195.22035395.73634205.39215686.20586009.17180292.3681704.38655334.4869359.64425771.1187654.25770437.1781472.55835496.1781472.90196078z"/></g></svg>','<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><g fill="#000" fill-rule="nonzero"><path d="m8 14c3.3137085 0 6-2.6862915 6-6s-2.6862915-6-6-6-6 2.6862915-6 6 2.6862915 6 6 6zm0 2c-4.418278 0-8-3.581722-8-8s3.581722-8 8-8 8 3.581722 8 8-3.581722 8-8 8z"/><path d="m7.44047619 10.767507c.49206595 0 .8670622-.1232481 1.125-.3697479s.38690476-.54528302.38690476-.89635854c0-.42577244-.13491928-.73949479-.4047619-.94117647s-.69444155-.30252101-1.27380953-.30252101h-.85714285v-.77310924l1.44047619-1.8487395.67857143-.50420168-.94047619.10084034h-2v-1.232493h4.547619v.79551821l-1.67857139 2.11764706-.52380952.302521v.05602241l.5-.06722689c.27777917.02240908.54166542.08216572.79166667.17927171.25000125.097106.46825303.23716062.6547619.42016807.18650884.18300745.33531694.40896224.44642854.67787115.1111117.2689089.1666667.57889647.1666667.92997199 0 .44071182-.0773802.82166039-.2321429 1.14285709-.1547626.3211968-.36904621.5901017-.6428571.8067227-.27381089.2166211-.59325214.3772171-.95833333.4817928-.36508119.1045756-.75793441.1568627-1.17857143.1568627-.3492081 0-.7103156-.0298783-1.08333334-.0896359-.37301773-.0597575-.67460202-.1456577-.9047619-.257703l.41666667-1.2100841c.20635023.097106.43452256.1755366.68452381.2352941.25000125.0597576.52976035.0896359.83928571.0896359z"/></g></svg>','<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><g fill="#000" fill-rule="nonzero"><path d="m8 14c3.3137085 0 6-2.6862915 6-6s-2.6862915-6-6-6-6 2.6862915-6 6 2.6862915 6 6 6zm0 2c-4.418278 0-8-3.581722-8-8s3.581722-8 8-8 8 3.581722 8 8-3.581722 8-8 8z"/><path d="m10.5 9.78723404h-1.23595506v2.21276596h-1.35955056v-2.21276596h-3.40449438v-.83971631l3.56179775-4.94751773h1.20224719v4.6070922h1.23595506zm-2.59550562-2.91631205.1011236-.95319149h-.04494382l-.38202247.81702127-1.16853933 1.5319149-.56179775.43120567.71910112-.09078014h1.33707865z"/></g></svg>','<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><g fill="#000" fill-rule="nonzero"><path d="m8 14c3.3137085 0 6-2.6862915 6-6s-2.6862915-6-6-6-6 2.6862915-6 6 2.6862915 6 6 6zm0 2c-4.418278 0-8-3.581722-8-8s3.581722-8 8-8 8 3.581722 8 8-3.581722 8-8 8z"/><path d="m7.31818182 10.7114846c.52631842 0 .92902572-.1195133 1.20813397-.3585434.27910825-.2390302.41866029-.56769168.41866029-.98599442 0-.44818151-.16347524-.77684303-.49043063-.9859944-.32695538-.20915137-.79345789-.31372549-1.39952153-.31372549l-.94497607.03361345v-4.10084034h4.11483255v1.36694678h-2.77511963v1.51260504l.49043062-.04481793c.39075155.01493939.74361884.08216561 1.05861244.20168068s.58412966.28571322.80741627.49859944c.2232866.21288621.3947362.47058672.5143541.77310924.1196178.30252252.1794258.64052101.1794258 1.0140056 0 .44071182-.079744.82912995-.2392344 1.16526615-.1594905.3361361-.38078013.6162453-.66387565.8403361-.28309551.2240907-.61602679.3921563-.99880383.5042017-.38277703.1120454-.80143313.1680672-1.25598086.1680672-.35885347 0-.69975915-.0280109-1.02272727-.0840336s-.59609139-.1325859-.81937799-.2296919l.41866029-1.210084c.18341399.0746969.38476764.1325861.60406698.1736694s.48444821.0616247.79545455.0616247z"/></g></svg>','<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><g fill="#000" fill-rule="nonzero"><path d="m8 14c3.3137085 0 6-2.6862915 6-6s-2.6862915-6-6-6-6 2.6862915-6 6 2.6862915 6 6 6zm0 2c-4.418278 0-8-3.581722-8-8s3.581722-8 8-8 8 3.581722 8 8-3.581722 8-8 8z"/><path d="m10.5 9.46153846c0 .35897616-.0587601.69230614-.1762821 1.00000004-.1175219.3076938-.2831185.5750904-.49679482.8021978-.21367629.2271073-.47186459.4065927-.77457265.5384615-.30270807.1318688-.63568195.1978022-.99893163.1978022-.37037222 0-.71046853-.060439-1.02029914-.1813187s-.57870257-.3021966-.80662393-.543956c-.22792137-.2417595-.40598227-.5457857-.53418804-.9120879-.12820577-.36630224-.19230769-.79120641-.19230769-1.27472531 0-.72527835.10149471-1.38094945.30448718-1.96703297s.47720625-1.09706742.82264957-1.53296703c.34544332-.43589962.74786095-.78754445 1.20726496-1.05494506.45940401-.2674006.94551026-.4450545 1.45833333-.53296703l.30982906 1.13186813c-.35612713.05860835-.68375919.17216033-.98290598.34065934-.2991468.16849901-.56445753.3699622-.79594017.60439561-.23148264.2344334-.42734963.49633555-.58760684.78571428-.16025721.28937874-.27243558.58791055-.33653846.8956044.14245085-.1831511.32763419-.3388272.55555556-.46703297.22792136-.12820577.5128188-.19230769.85470085-.19230769.32051442 0 .61609551.05128154.88675214.15384615.27065662.10256462.50213579.25457775.69444444.45604396.19230866.20146621.34187976.44871648.44871796.74175824.1068381.29304176.1602564.63003473.1602564 1.01098901zm-1.34615385.07692308c0-.82051692-.39173397-1.23076923-1.17521367-1.23076923-.28490171 0-.52528392.0659334-.72115385.1978022-.19586992.13186879-.33297681.2857134-.41132478.46153846-.01424509.08058648-.02136753.15018285-.02136753.20879121v.17582417c0 .17582506.02492853.34981599.07478633.52197802s.12286277.32600663.21901709.46153843c.09615433.1355318.21901635.2454209.36858975.3296704.14957339.0842495.32763429.1263736.53418803.1263736.33475951 0 .60719268-.117215.81730769-.3516484s.31517094-.53479666.31517094-.90109886z"/></g></svg>','<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><g fill="#000" fill-rule="nonzero"><path d="m8 14c3.3137085 0 6-2.6862915 6-6s-2.6862915-6-6-6-6 2.6862915-6 6 2.6862915 6 6 6zm0 2c-4.418278 0-8-3.581722-8-8s3.581722-8 8-8 8 3.581722 8 8-3.581722 8-8 8z"/><path d="m5.98780488 12 2.53880266-6.16.48780488-.56-.66518847.11428571h-2.84922395v-1.39428571h5v.43428571l-3.10421286 7.56571429z"/></g></svg>','<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><g fill="#000" fill-rule="nonzero"><path d="m8 14c3.3137085 0 6-2.6862915 6-6s-2.6862915-6-6-6-6 2.6862915-6 6 2.6862915 6 6 6zm0 2c-4.418278 0-8-3.581722-8-8s3.581722-8 8-8 8 3.581722 8 8-3.581722 8-8 8z"/><path d="m5.5 9.96703297c0-.25641154.03363195-.48534698.10089686-.68681319s.16255544-.38461456.28587444-.54945055.26905746-.31318615.43721973-.44505494c.16816228-.1318688.34940112-.25274671.54372197-.36263737-.36622006-.22710736-.65396009-.4890095-.8632287-.78571428-.2092686-.29670478-.31390134-.66483297-.31390134-1.10439561 0-.28571571.05418481-.5531123.16255605-.8021978.10837125-.24908549.26532035-.46520055.47085202-.64835165s.45403442-.32600681.7455157-.42857143c.29148127-.10256461.62032701-.15384615.98654708-.15384615.33632455 0 .64274899.0439556.91928251.13186813s.51382562.21245341.71188341.37362638c.19805779.16117296.35126997.3571417.45964127.58791208.1083712.23077039.162556.4853466.162556.76373627 0 .43223659-.0990274.79853329-.2970852 1.0989011-.19805775.3003678-.48766622.57509033-.86883404.82417582.44843273.25641154.78662068.53846 1.01457394.84615385.2279534.30769384.3419283.70329428.3419283 1.18681318 0 .32967199-.0616586.62820379-.1849776.89560439s-.2970841.4963361-.52130043.6868132c-.22421636.1904771-.49327197.3388273-.80717488.4450549-.31390292.1062277-.65769619.1593407-1.03139014.1593407s-.71188189-.0494501-1.01457399-.1483516c-.3026921-.0989016-.56053705-.2362629-.7735426-.412088-.21300555-.175825-.37742842-.3882771-.49327354-.6373626-.11584513-.2490855-.17376682-.527471-.17376682-.83516483zm3.60986547-.14285715c0-.16849901-.04110572-.32234362-.12331838-.46153846-.08221267-.13919483-.18871385-.2655672-.31950673-.37912088s-.27653134-.21794824-.43721973-.31318681c-.1606884-.09523857-.32324283-.18681275-.48766816-.27472527-.35127231.19780318-.59230129.41208675-.72309417.64285714-.13079289.23077038-.19618834.45970582-.19618834.68681319 0 .29304177.10276429.54395497.30829596.75274727.20553167.2087922.49140325.3131868.85762332.3131868.33632455 0 .6072486-.0805853.81278027-.2417583.20553167-.1611729.30829596-.4029287.30829596-.72527468zm-2.02914798-3.76923077c0 .17582506.03363195.32966968.10089686.46153847s.15881855.24725225.27466368.34615384c.11584512.0989016.24663604.19047577.39237668.27472528.14574064.0842495.29708442.16300329.45403587.23626373.44843274-.37362824.67264574-.78388055.67264574-1.23076923 0-.30769384-.09155364-.54029225-.27466367-.69780219-.18311004-.15750995-.4054546-.23626374-.66704036-.23626374-.32885068 0-.56987966.08424824-.72309417.25274725-.15321452.16849901-.22982063.36629923-.22982063.59340659z"/></g></svg>','<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><g fill="#000" fill-rule="nonzero"><path d="m8 14c3.3137085 0 6-2.6862915 6-6s-2.6862915-6-6-6-6 2.6862915-6 6 2.6862915 6 6 6zm0 2c-4.418278 0-8-3.581722-8-8s3.581722-8 8-8 8 3.581722 8 8-3.581722 8-8 8z"/><path d="m5.5 6.56043956c0-.37362824.05473109-.71794714.16419492-1.03296703.10946382-.31501989.26836054-.58424797.47669491-.80769231.20833438-.22344434.46256912-.39926676.76271186-.52747253.30014275-.12820577.64441897-.19230769 1.03283899-.19230769.79802659 0 1.42478586.24725027 1.88029661.74175824.45551071.49450797.68326271 1.21428099.68326271 2.15934066 0 .8498211-.1041656 1.58424599-.3125 2.2032967-.20833437.61905072-.48728639 1.1355291-.83686441 1.5494506-.34957802.4139214-.75388188.7307681-1.21292373.9505494-.45904184.2197813-.94279406.3516481-1.45127118.3956044l-.29661017-1.1208791c.38842002-.0512823.73446176-.1501824 1.03813559-.2967033.30367384-.1465209.56497066-.3278378.78389831-.5439561.21892765-.21611826.39724507-.46153705.53495762-.7362637.13771256-.27472665.23481611-.56959549.29131356-.88461538-.16949237.19047714-.35134083.32234395-.54555084.39560439s-.45374132.10989011-.7786017.10989011c-.26836292 0-.5349563-.04761857-.79978813-.14285714-.26483184-.09523857-.50141139-.23992577-.70974577-.43406593-.20833437-.19414017-.3778242-.43955896-.50847457-.73626374s-.19597458-.64651813-.19597458-1.04945055zm1.33474576-.07692308c0 .41758451.11299322.73259967.33898305.94505495.22598983.21245527.50847288.31868132.84745763.31868132.28954947 0 .52612903-.04761857.70974576-.14285715.18361674-.09523857.32485827-.21245351.42372882-.35164835.02118654-.15384692.03177966-.3003656.03177966-.43956044 0-.20512923-.02471727-.40659241-.07415254-.6043956-.04943528-.19780319-.1253526-.37362561-.22775424-.52747253s-.23305005-.27655632-.39194915-.36813187-.34780964-.13736263-.56673729-.13736263c-.34604693 0-.61440583.11538346-.80508475.34615384-.19067892.23077039-.28601695.55128-.28601695.96153846z"/></g></svg>','<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m8 16c-4.418278 0-8-3.581722-8-8s3.581722-8 8-8 8 3.581722 8 8-3.581722 8-8 8zm-2.5-8.01098901c0 1.28938374.20150072 2.28021631.6045082 2.97252751.40300748.6923111 1.03141649 1.0384615 1.8852459 1.0384615.80601496 0 1.42588581-.329667 1.85963115-.989011.43374535-.6593439.65061475-1.66665988.65061475-3.02197801 0-1.36264418-.2015007-2.36812863-.6045082-3.01648352-.40300748-.64835489-1.03483176-.97252747-1.8954918-.97252747-.80601496 0-1.42417818.32783555-1.8545082.98351648-.43033002.65568094-.6454918 1.65750242-.6454918 3.00549451zm1.33196721 0c0-.94505967.09050456-1.64468637.2715164-2.0989011.18101183-.45421473.47643237-.68131868.88627049-.68131868.43033002 0 .73428873.24175582.91188524.72527472.17759652.48351891.26639345 1.16849374.26639345 2.05494506 0 .97436385-.09391983 1.68497945-.2817623 2.13186811-.18784247.4468887-.48326301.6703297-.88627049.6703297-.41666875 0-.71550456-.2435873-.89651639-.7307692-.18101184-.48718196-.2715164-1.17765125-.2715164-2.07142861z"/></svg>','<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m8 16c-4.418278 0-8-3.581722-8-8s3.581722-8 8-8 8 3.581722 8 8-3.581722 8-8 8zm-2.06521739-5.2359551v1.2359551h4.56521739v-1.2359551h-1.55606407v-6.7640449h-.83524028l-2.60869565 2.06741573.62929062.84269663 1.01830663-.68539326.54919909-.66292135-.17162472.76404495v4.4382022z"/></svg>','<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m8 16c-4.418278 0-8-3.581722-8-8s3.581722-8 8-8 8 3.581722 8 8-3.581722 8-8 8zm2.3218527-9.92717087c0-.34360582-.0593818-.64425641-.1781472-.90196078-.1187655-.25770437-.28107581-.47245479-.4869359-.64425771-.2058601-.17180291-.45130499-.30252056-.73634205-.39215686-.28503705-.0896363-.59778135-.13445378-.93824228-.13445378-.53048563 0-.9916845.0728284-1.38361045.21848739-.39192595.145659-.74227874.33800068-1.05106888.57703082l.6175772 1.03081232c.182107-.15686353.40577856-.28571378.67102137-.38655462.26524282-.10084084.52454347-.1512605.77790974-.1512605.4038025 0 .69873225.09897193.8847981.29691876.18606586.19794684.27909739.45004516.27909739.75630252 0 .25396953-.05344365.5228744-.16033254.80672269-.1068889.2838483-.25138468.5770293-.43349169.87955182-.18210701.30252253-.38796401.60317311-.6175772.90196079-.22961318.29878767-.4651611.58823389-.70665083.86834734-.24148972.28011347-.48099643.54528357-.71852731.79551817-.23753088.2502347-.45130547.4687199-.64133017.6554622v.7507003h5v-1.232493h-2.28028504l-.85510688.1568627v-.0560224l.62945368-.4593837c.26128396-.291318.52850219-.61064254.80166271-.95798321.27316051-.34734067.52256419-.7077479.74821852-1.08123249.22565434-.37348459.4117174-.75443317.55819481-1.14285714.1464773-.38842398.2197149-.77310734.2197149-1.15406163z"/></svg>','<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m8 16c-4.418278 0-8-3.581722-8-8s3.581722-8 8-8 8 3.581722 8 8-3.581722 8-8 8zm-.55952381-5.232493c-.30952536 0-.58928446-.0298783-.83928571-.0896359-.25000125-.0597575-.47817358-.1381881-.68452381-.2352941l-.41666667 1.2100841c.23015988.1120453.53174417.1979455.9047619.257703.37301774.0597576.73412524.0896359 1.08333334.0896359.42063702 0 .81349024-.0522871 1.17857143-.1568627.36508119-.1045757.68452244-.2651717.95833333-.4817928.27381089-.216621.4880945-.4855259.6428571-.8067227.1547627-.3211967.2321429-.70214527.2321429-1.14285709 0-.35107552-.055555-.66106309-.1666667-.92997199-.1111116-.26890891-.2599197-.4948637-.44642854-.67787115-.18650887-.18300745-.40476065-.32306207-.6547619-.42016807-.25000125-.09710599-.5138875-.15686263-.79166667-.17927171l-.5.06722689v-.05602241l.52380952-.302521 1.67857139-2.11764706v-.79551821h-4.547619v1.232493h2l.94047619-.10084034-.67857143.50420168-1.44047619 1.8487395v.77310924h.85714285c.57936798 0 1.00396691.10083933 1.27380953.30252101s.4047619.51540403.4047619.94117647c0 .35107552-.12896696.64985874-.38690476.89635854s-.63293405.3697479-1.125.3697479z"/></svg>','<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m8 16c-4.418278 0-8-3.581722-8-8s3.581722-8 8-8 8 3.581722 8 8-3.581722 8-8 8zm2.5-6.21276596v-1.18014184h-1.23595506v-4.6070922h-1.20224719l-3.56179775 4.94751773v.83971631h3.40449438v2.21276596h1.35955056v-2.21276596zm-2.59550562-2.91631205v1.73617021h-1.33707865l-.71910112.09078014.56179775-.43120567 1.16853933-1.5319149.38202247-.81702127h.04494382z"/></svg>','<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m8 16c-4.418278 0-8-3.581722-8-8s3.581722-8 8-8 8 3.581722 8 8-3.581722 8-8 8zm-.68181818-5.2885154c-.31100634 0-.57615521-.0205414-.79545455-.0616247s-.42065299-.0989725-.60406698-.1736694l-.41866029 1.210084c.2232866.097106.49640987.1736692.81937799.2296919s.6638738.0840336 1.02272727.0840336c.45454773 0 .87320383-.0560218 1.25598086-.1680672.38277704-.1120454.71570832-.280111.99880383-.5042017.28309552-.2240908.50438515-.5042.66387565-.8403361.1594904-.3361362.2392344-.72455433.2392344-1.16526615 0-.37348459-.059808-.71148308-.1794258-1.0140056-.1196179-.30252252-.2910675-.56022303-.5143541-.77310924-.22328661-.21288622-.49242267-.37908437-.80741627-.49859944s-.66786089-.18674129-1.05861244-.20168068l-.49043062.04481793v-1.51260504h2.77511963v-1.36694678h-4.11483255v4.10084034l.94497607-.03361345c.60606364 0 1.07256615.10457412 1.39952153.31372549.32695539.20915137.49043063.53781289.49043063.9859944 0 .41830274-.13955204.74696422-.41866029.98599442-.27910825.2390301-.68181555.3585434-1.20813397.3585434z"/></svg>','<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m8 16c-4.418278 0-8-3.581722-8-8s3.581722-8 8-8 8 3.581722 8 8-3.581722 8-8 8zm2.5-6.53846154c0-.38095428-.0534183-.71794725-.1602564-1.01098901-.1068382-.29304176-.2564093-.54029203-.44871796-.74175824-.19230865-.20146621-.42378782-.35347934-.69444444-.45604396-.27065663-.10256461-.56623772-.15384615-.88675214-.15384615-.34188205 0-.62677949.06410192-.85470085.19230769-.22792137.12820577-.41310471.28388187-.55555556.46703297.06410288-.30769385.17628125-.60622566.33653846-.8956044.16025721-.28937873.3561242-.55128088.58760684-.78571428.23148264-.23443341.49679337-.4358966.79594017-.60439561.29914679-.16849901.62677885-.28205099.98290598-.34065934l-.30982906-1.13186813c-.51282307.08791253-.99892932.26556643-1.45833333.53296703-.45940401.26740061-.86182164.61904544-1.20726496 1.05494506-.34544332.43589961-.6196571.94688351-.82264957 1.53296703s-.30448718 1.24175462-.30448718 1.96703297c0 .4835189.06410192.90842307.19230769 1.27472531.12820577.3663022.30626667.6703284.53418804.9120879.22792136.2417594.49679332.4230763.80662393.543956s.64992692.1813187 1.02029914.1813187c.36324968 0 .69622356-.0659334.99893163-.1978022.30270806-.1318688.56089636-.3113542.77457265-.5384615.21367632-.2271074.37927292-.494504.49679482-.8021978.117522-.3076939.1762821-.64102388.1762821-1.00000004zm-1.34615385.07692308c0 .3663022-.10505593.66666546-.31517094.90109886s-.48254818.3516484-.81730769.3516484c-.20655374 0-.38461464-.0421241-.53418803-.1263736-.1495734-.0842495-.27243542-.1941386-.36858975-.3296704-.09615432-.1355318-.16915929-.2893764-.21901709-.46153843s-.07478633-.34615296-.07478633-.52197802c0-.05860835 0-.11721582 0-.17582417 0-.05860836.00712244-.12820473.02136753-.20879121.07834797-.17582506.21545486-.32966967.41132478-.46153846.19586993-.1318688.43625214-.1978022.72115385-.1978022.7834797 0 1.17521367.41025231 1.17521367 1.23076923z"/></svg>','<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m8 16c-4.418278 0-8-3.581722-8-8s3.581722-8 8-8 8 3.581722 8 8-3.581722 8-8 8zm-2.01219512-4h1.40798226l3.10421286-7.56571429v-.43428571h-5v1.39428571h2.84922395l.66518847-.11428571-.48780488.56z"/></svg>','<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m8 16c-4.418278 0-8-3.581722-8-8s3.581722-8 8-8 8 3.581722 8 8-3.581722 8-8 8zm-2.5-6.03296703c0 .30769383.05792169.58607933.17376682.83516483.11584512.2490855.28026799.4615376.49327354.6373626.21300555.1758251.4708505.3131864.7735426.412088.3026921.0989015.64088004.1483516 1.01457399.1483516s.71748722-.053113 1.03139014-.1593407c.31390291-.1062276.58295852-.2545778.80717488-.4450549.22421633-.1904771.39798143-.4194126.52130043-.6868132s.1849776-.5659324.1849776-.89560439c0-.4835189-.1139749-.87911934-.3419283-1.18681318-.22795326-.30769385-.56614121-.58974231-1.01457394-.84615385.38116782-.24908549.67077629-.52380802.86883404-.82417582.1980578-.30036781.2970852-.66666451.2970852-1.0989011 0-.27838967-.0541848-.53296588-.162556-.76373627-.1083713-.23077038-.26158348-.42673912-.45964127-.58791208-.19805779-.16117297-.43534989-.28571385-.71188341-.37362638s-.58295796-.13186813-.91928251-.13186813c-.36622007 0-.69506581.05128154-.98654708.15384615-.29148128.10256462-.53998403.24542033-.7455157.42857143s-.36248077.39926616-.47085202.64835165c-.10837124.2490855-.16255605.51648209-.16255605.8021978 0 .43956264.10463274.80769083.31390134 1.10439561.20926861.29670478.49700864.55860692.8632287.78571428-.19432085.10989066-.37555969.23076857-.54372197.36263737-.16816227.13186879-.31390073.28021895-.43721973.44505494s-.21860953.34798434-.28587444.54945055-.10089686.43040165-.10089686.68681319zm3.60986547-.14285715c0 .32234598-.10276429.56410178-.30829596.72527468-.20553167.161173-.47645572.2417583-.81278027.2417583-.36622007 0-.65209165-.1043946-.85762332-.3131868-.20553167-.2087923-.30829596-.4597055-.30829596-.75274727 0-.22710737.06539545-.45604281.19618834-.68681319.13079288-.23077039.37182186-.44505396.72309417-.64285714.16442533.08791252.32697976.1794867.48766816.27472527.16068839.09523857.30642685.19963313.43721973.31318681s.23729406.23992605.31950673.37912088c.08221266.13919484.12331838.29303945.12331838.46153846zm-2.02914798-3.76923077c0-.22710736.07660611-.42490758.22982063-.59340659.15321451-.16849901.39424349-.25274725.72309417-.25274725.26158576 0 .48393032.07875379.66704036.23626374.18311003.15750994.27466367.39010835.27466367.69780219 0 .44688868-.224213.85714099-.67264574 1.23076923-.15695145-.07326044-.30829523-.15201423-.45403587-.23626373-.14574064-.08424951-.27653156-.17582368-.39237668-.27472528-.11584513-.09890159-.20739877-.21428505-.27466368-.34615384s-.10089686-.28571341-.10089686-.46153847z"/></svg>','<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m8 16c-4.418278 0-8-3.581722-8-8s3.581722-8 8-8 8 3.581722 8 8-3.581722 8-8 8zm-2.5-9.43956044c0 .40293242.06532421.75274577.19597458 1.04945055s.3001402.54212357.50847457.73626374c.20833438.19414016.44491393.33882736.70974577.43406593.26483183.09523857.53142521.14285714.79978813.14285714.32486038 0 .58439169-.03662967.7786017-.10989011s.37605847-.20512725.54555084-.39560439c-.05649745.31501989-.153601.60988873-.29131356.88461538-.13771255.27472665-.31602997.52014544-.53495762.7362637-.21892765.2161183-.48022447.3974352-.78389831.5439561-.30367383.1465209-.64971557.245421-1.03813559.2967033l.29661017 1.1208791c.50847712-.0439563.99222934-.1758231 1.45127118-.3956044.45904185-.2197813.86334571-.536628 1.21292373-.9505494.34957802-.4139215.62853004-.93039988.83686441-1.5494506.2083344-.61905071.3125-1.3534756.3125-2.2032967 0-.94505967-.227752-1.66483269-.68326271-2.15934066-.45551075-.49450797-1.08227002-.74175824-1.88029661-.74175824-.38842002 0-.73269624.06410192-1.03283899.19230769-.30014274.12820577-.55437748.30402819-.76271186.52747253-.20833437.22344434-.36723109.49267242-.47669491.80769231-.10946383.31501989-.16419492.65933879-.16419492 1.03296703zm1.33474576-.07692308c0-.41025846.09533803-.73076807.28601695-.96153846.19067892-.23077038.45903782-.34615384.80508475-.34615384.21892765 0 .40783819.04578708.56673729.13736263s.28954751.21428495.39194915.36813187.17831896.32966934.22775424.52747253c.04943527.19780319.07415254.39926637.07415254.6043956 0 .13919484-.01059312.28571352-.03177966.43956044-.09887055.13919484-.24011208.25640978-.42372882.35164835-.18361673.09523858-.42019629.14285715-.70974576.14285715-.33898475 0-.6214678-.10622605-.84745763-.31868132-.22598983-.21245528-.33898305-.52747044-.33898305-.94505495z"/></svg>']},start:function(){var t={title:"## icons.icons ##",icon:this.opts.icons.icon,command:"icons.popup",blocks:{all:"editable"}};this.app.toolbar.add("icons",t)},popup:function(t,e){for(var i={},s=this.opts.icons.items,a=0;a<s.length;a++)i[a]={html:this.dom("<div>").addClass(this.prefix+"-popup-item").html(s[a]),command:"icons.insert",params:{icon:s[a]}};this.app.popup.create("icons",{type:"grid",width:"160px",items:i}),this.app.popup.open({button:e})},insert:function(t){this.app.popup.close(),this.app.insertion.insertHtml(t.icon,"after")}}),RedactorX.add("plugin","fontsize",{translations:{en:{fontsize:{title:"Text size",remove:"Remove text size"}}},init(){this.sizes=this.opts.fontsize||["10px","11px","12px","14px","16px","18px","20px","24px","28px","30px"]},start(){this.app.toolbar.add("fontsize",{title:"## fontsize.title ##",icon:'<svg width="17" height="16" viewBox="0 0 17 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M1.33667 3.33336C1.33667 2.87496 1.70827 2.50336 2.16667 2.50336H10.8333C11.2917 2.50336 11.6633 2.87496 11.6633 3.33336V4.66669C11.6633 5.12509 11.2917 5.49669 10.8333 5.49669C10.3749 5.49669 10.0033 5.12509 10.0033 4.66669V4.16336H7.66334V11.8367H8.16667C8.62507 11.8367 8.99667 12.2083 8.99667 12.6667C8.99667 13.1251 8.62507 13.4967 8.16667 13.4967H5.5C5.04161 13.4967 4.67 13.1251 4.67 12.6667C4.67 12.2083 5.04161 11.8367 5.5 11.8367H6.00334V4.16336H2.99667V4.66669C2.99667 5.12509 2.62507 5.49669 2.16667 5.49669C1.70827 5.49669 1.33667 5.12509 1.33667 4.66669V3.33336ZM9.33667 8.00002C9.33667 7.54163 9.70827 7.17002 10.1667 7.17002H14.1667C14.6251 7.17002 14.9967 7.54163 14.9967 8.00002V8.66669C14.9967 9.12509 14.6251 9.49669 14.1667 9.49669C13.7642 9.49669 13.4286 9.2102 13.3527 8.83002H12.9967V11.8528C13.3768 11.9286 13.6633 12.2642 13.6633 12.6667C13.6633 13.1251 13.2917 13.4967 12.8333 13.4967H11.5C11.0416 13.4967 10.67 13.1251 10.67 12.6667C10.67 12.2642 10.9565 11.9286 11.3367 11.8528V8.83002H10.9806C10.9047 9.2102 10.5692 9.49669 10.1667 9.49669C9.70827 9.49669 9.33667 9.12509 9.33667 8.66669V8.00002Z"/></svg>',blocks:{all:"editable",except:["code"]},command:"fontsize.popup"})},popup(t,e){var i={};for(let t=0;t<this.sizes.length;t++){var s=this.sizes[t];i[t]={title:s,command:"inline.set",params:{tag:"span",style:{"font-size":s}}}}i.remove={title:"## fontsize.remove ##",divider:"top",command:"fontsize.remove"},this.app.popup.create("fontsize",{items:i}),this.app.popup.open({button:e})},remove(){this.app.popup.close();this.app.inline.remove({style:"font-size"})}}),RedactorX.add("plugin","fontsize",{translations:{en:{fontsize:{title:"Text size",remove:"Remove text size"}}},init(){this.sizes=this.opts.fontsize||["10px","11px","12px","14px","16px","18px","20px","24px","28px","30px"]},start(){this.app.toolbar.add("fontsize",{title:"## fontsize.title ##",icon:'<svg width="17" height="16" viewBox="0 0 17 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M1.33667 3.33336C1.33667 2.87496 1.70827 2.50336 2.16667 2.50336H10.8333C11.2917 2.50336 11.6633 2.87496 11.6633 3.33336V4.66669C11.6633 5.12509 11.2917 5.49669 10.8333 5.49669C10.3749 5.49669 10.0033 5.12509 10.0033 4.66669V4.16336H7.66334V11.8367H8.16667C8.62507 11.8367 8.99667 12.2083 8.99667 12.6667C8.99667 13.1251 8.62507 13.4967 8.16667 13.4967H5.5C5.04161 13.4967 4.67 13.1251 4.67 12.6667C4.67 12.2083 5.04161 11.8367 5.5 11.8367H6.00334V4.16336H2.99667V4.66669C2.99667 5.12509 2.62507 5.49669 2.16667 5.49669C1.70827 5.49669 1.33667 5.12509 1.33667 4.66669V3.33336ZM9.33667 8.00002C9.33667 7.54163 9.70827 7.17002 10.1667 7.17002H14.1667C14.6251 7.17002 14.9967 7.54163 14.9967 8.00002V8.66669C14.9967 9.12509 14.6251 9.49669 14.1667 9.49669C13.7642 9.49669 13.4286 9.2102 13.3527 8.83002H12.9967V11.8528C13.3768 11.9286 13.6633 12.2642 13.6633 12.6667C13.6633 13.1251 13.2917 13.4967 12.8333 13.4967H11.5C11.0416 13.4967 10.67 13.1251 10.67 12.6667C10.67 12.2642 10.9565 11.9286 11.3367 11.8528V8.83002H10.9806C10.9047 9.2102 10.5692 9.49669 10.1667 9.49669C9.70827 9.49669 9.33667 9.12509 9.33667 8.66669V8.00002Z"/></svg>',blocks:{all:"editable",except:["code"]},command:"fontsize.popup"})},popup(t,e){var i={};for(let t=0;t<this.sizes.length;t++){var s=this.sizes[t];i[t]={title:s,command:"inline.set",params:{tag:"span",style:{"font-size":s}}}}i.remove={title:"## fontsize.remove ##",divider:"top",command:"fontsize.remove"},this.app.popup.create("fontsize",{items:i}),this.app.popup.open({button:e})},remove(){this.app.popup.close(),this.app.inline.remove({style:"font-size"})}}),RedactorX.add("plugin","imageposition",{translations:{en:{imageposition:{"image-position":"Image position"}}},defaults:{icon:'<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m15 13c.5522847 0 1 .4477153 1 1s-.4477153 1-1 1h-13c-.55228475 0-1-.4477153-1-1s.44771525-1 1-1zm-5-12c.5522847 0 1 .44771525 1 1v8c0 .5522847-.4477153 1-1 1h-8c-.55228475 0-1-.4477153-1-1v-8c0-.55228475.44771525-1 1-1zm5 8c.5522847 0 1 .44771525 1 1 0 .5522847-.4477153 1-1 1h-2c-.5522847 0-1-.4477153-1-1 0-.55228475.4477153-1 1-1zm-10-1-1 1h2zm4-5h-6v5l2-2 3 3h1zm6 2c.5522847 0 1 .44771525 1 1s-.4477153 1-1 1h-2c-.5522847 0-1-.44771525-1-1s.4477153-1 1-1zm-8-1c.55228475 0 1 .44771525 1 1s-.44771525 1-1 1-1-.44771525-1-1 .44771525-1 1-1zm8-3c.5522847 0 1 .44771525 1 1s-.4477153 1-1 1h-2c-.5522847 0-1-.44771525-1-1s.4477153-1 1-1z"/></svg>',items:{none:"none",left:"float-left",center:"align-center",right:"float-right"},icons:{none:'<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m12 3c.5522847 0 1 .44771525 1 1v8c0 .5522847-.4477153 1-1 1h-8c-.55228475 0-1-.4477153-1-1v-8c0-.55228475.44771525-1 1-1zm-5 7-1 1h2zm4-5h-6v5l2-2 3 3h1zm-2 1c.55228475 0 1 .44771525 1 1s-.44771525 1-1 1-1-.44771525-1-1 .44771525-1 1-1z"/></svg>',left:'<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m10 3c.5522847 0 1 .44771525 1 1v8c0 .5522847-.4477153 1-1 1h-8c-.55228475 0-1-.4477153-1-1v-8c0-.55228475.44771525-1 1-1zm5 8c.5522847 0 1 .4477153 1 1s-.4477153 1-1 1h-2c-.5522847 0-1-.4477153-1-1s.4477153-1 1-1zm-10-1-1 1h2zm4-5h-6v5l2-2 3 3h1zm6 2c.5522847 0 1 .44771525 1 1s-.4477153 1-1 1h-2c-.5522847 0-1-.44771525-1-1s.4477153-1 1-1zm-8-1c.55228475 0 1 .44771525 1 1s-.44771525 1-1 1-1-.44771525-1-1 .44771525-1 1-1zm8-3c.5522847 0 1 .44771525 1 1s-.4477153 1-1 1h-2c-.5522847 0-1-.44771525-1-1s.4477153-1 1-1z"/></svg>',center:'<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m12 3c.5522847 0 1 .44771525 1 1v8c0 .5522847-.4477153 1-1 1h-8c-.55228475 0-1-.4477153-1-1v-8c0-.55228475.44771525-1 1-1zm3 8c.5522847 0 1 .4477153 1 1s-.4477153 1-1 1-1-.4477153-1-1 .4477153-1 1-1zm-14 0c.55228475 0 1 .4477153 1 1s-.44771525 1-1 1-1-.4477153-1-1 .44771525-1 1-1zm6-1-1 1h2zm4-5h-6v5l2-2 3 3h1zm4 2c.5522847 0 1 .44771525 1 1s-.4477153 1-1 1-1-.44771525-1-1 .4477153-1 1-1zm-14 0c.55228475 0 1 .44771525 1 1s-.44771525 1-1 1-1-.44771525-1-1 .44771525-1 1-1zm8-1c.55228475 0 1 .44771525 1 1s-.44771525 1-1 1-1-.44771525-1-1 .44771525-1 1-1zm6-3c.5522847 0 1 .44771525 1 1s-.4477153 1-1 1-1-.44771525-1-1 .4477153-1 1-1zm-14 0c.55228475 0 1 .44771525 1 1s-.44771525 1-1 1-1-.44771525-1-1 .44771525-1 1-1z"/></svg>',right:'<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m14 3c.5522847 0 1 .44771525 1 1v8c0 .5522847-.4477153 1-1 1h-8c-.55228475 0-1-.4477153-1-1v-8c0-.55228475.44771525-1 1-1zm-11 8c.55228475 0 1 .4477153 1 1s-.44771525 1-1 1h-2c-.55228475 0-1-.4477153-1-1s.44771525-1 1-1zm6-1-1 1h2zm4-5h-6v5l2-2 3 3h1zm-10 2c.55228475 0 1 .44771525 1 1s-.44771525 1-1 1h-2c-.55228475 0-1-.44771525-1-1s.44771525-1 1-1zm8-1c.5522847 0 1 .44771525 1 1s-.4477153 1-1 1-1-.44771525-1-1 .4477153-1 1-1zm-8-3c.55228475 0 1 .44771525 1 1s-.44771525 1-1 1h-2c-.55228475 0-1-.44771525-1-1s.44771525-1 1-1z"/></svg>'}},start:function(){this.app.toolbar.add("imageposition",{title:"## imageposition.image-position ##",command:"imageposition.popup",icon:this.opts.imageposition.icon,position:{after:"image"},blocks:{types:["image"]}})},popup:function(t,e){var i,s={},a=this.opts.imageposition.items;for(i in a)a[i]&&(s[i]={name:a[i],icon:this.opts.imageposition.icons[i]});this.app.popup.create("imageposition",{setter:"imageposition.setFloat",getter:"imageposition.getFloat",form:{ifloat:{type:"segment",label:"## imageposition.image-position ##",segments:s}}}),this.app.popup.open({button:e})},getFloat:function(){var t=this.opts.imageposition.items;if(!t)return!1;var e,i=this.app.block.get().getBlock(),s="none";for(e in t)i.hasClass(t[e])&&(s=e);return{ifloat:s}},setFloat:function(t){this.app.popup.close();var t=t.getData(),e=this.app.block.get();e.setClassFromObj(this.opts.imageposition.items,t.ifloat),this.app.broadcast("image.position",{image:e.getImage(),position:t.ifloat})}}),RedactorX.add("plugin","imageposition",{translations:{en:{imageposition:{"image-position":"Image position"}}},defaults:{icon:'<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m15 13c.5522847 0 1 .4477153 1 1s-.4477153 1-1 1h-13c-.55228475 0-1-.4477153-1-1s.44771525-1 1-1zm-5-12c.5522847 0 1 .44771525 1 1v8c0 .5522847-.4477153 1-1 1h-8c-.55228475 0-1-.4477153-1-1v-8c0-.55228475.44771525-1 1-1zm5 8c.5522847 0 1 .44771525 1 1 0 .5522847-.4477153 1-1 1h-2c-.5522847 0-1-.4477153-1-1 0-.55228475.4477153-1 1-1zm-10-1-1 1h2zm4-5h-6v5l2-2 3 3h1zm6 2c.5522847 0 1 .44771525 1 1s-.4477153 1-1 1h-2c-.5522847 0-1-.44771525-1-1s.4477153-1 1-1zm-8-1c.55228475 0 1 .44771525 1 1s-.44771525 1-1 1-1-.44771525-1-1 .44771525-1 1-1zm8-3c.5522847 0 1 .44771525 1 1s-.4477153 1-1 1h-2c-.5522847 0-1-.44771525-1-1s.4477153-1 1-1z"/></svg>',items:{none:"none",left:"float-left",center:"align-center",right:"float-right"},icons:{none:'<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m12 3c.5522847 0 1 .44771525 1 1v8c0 .5522847-.4477153 1-1 1h-8c-.55228475 0-1-.4477153-1-1v-8c0-.55228475.44771525-1 1-1zm-5 7-1 1h2zm4-5h-6v5l2-2 3 3h1zm-2 1c.55228475 0 1 .44771525 1 1s-.44771525 1-1 1-1-.44771525-1-1 .44771525-1 1-1z"/></svg>',left:'<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m10 3c.5522847 0 1 .44771525 1 1v8c0 .5522847-.4477153 1-1 1h-8c-.55228475 0-1-.4477153-1-1v-8c0-.55228475.44771525-1 1-1zm5 8c.5522847 0 1 .4477153 1 1s-.4477153 1-1 1h-2c-.5522847 0-1-.4477153-1-1s.4477153-1 1-1zm-10-1-1 1h2zm4-5h-6v5l2-2 3 3h1zm6 2c.5522847 0 1 .44771525 1 1s-.4477153 1-1 1h-2c-.5522847 0-1-.44771525-1-1s.4477153-1 1-1zm-8-1c.55228475 0 1 .44771525 1 1s-.44771525 1-1 1-1-.44771525-1-1 .44771525-1 1-1zm8-3c.5522847 0 1 .44771525 1 1s-.4477153 1-1 1h-2c-.5522847 0-1-.44771525-1-1s.4477153-1 1-1z"/></svg>',center:'<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m12 3c.5522847 0 1 .44771525 1 1v8c0 .5522847-.4477153 1-1 1h-8c-.55228475 0-1-.4477153-1-1v-8c0-.55228475.44771525-1 1-1zm3 8c.5522847 0 1 .4477153 1 1s-.4477153 1-1 1-1-.4477153-1-1 .4477153-1 1-1zm-14 0c.55228475 0 1 .4477153 1 1s-.44771525 1-1 1-1-.4477153-1-1 .44771525-1 1-1zm6-1-1 1h2zm4-5h-6v5l2-2 3 3h1zm4 2c.5522847 0 1 .44771525 1 1s-.4477153 1-1 1-1-.44771525-1-1 .4477153-1 1-1zm-14 0c.55228475 0 1 .44771525 1 1s-.44771525 1-1 1-1-.44771525-1-1 .44771525-1 1-1zm8-1c.55228475 0 1 .44771525 1 1s-.44771525 1-1 1-1-.44771525-1-1 .44771525-1 1-1zm6-3c.5522847 0 1 .44771525 1 1s-.4477153 1-1 1-1-.44771525-1-1 .4477153-1 1-1zm-14 0c.55228475 0 1 .44771525 1 1s-.44771525 1-1 1-1-.44771525-1-1 .44771525-1 1-1z"/></svg>',right:'<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m14 3c.5522847 0 1 .44771525 1 1v8c0 .5522847-.4477153 1-1 1h-8c-.55228475 0-1-.4477153-1-1v-8c0-.55228475.44771525-1 1-1zm-11 8c.55228475 0 1 .4477153 1 1s-.44771525 1-1 1h-2c-.55228475 0-1-.4477153-1-1s.44771525-1 1-1zm6-1-1 1h2zm4-5h-6v5l2-2 3 3h1zm-10 2c.55228475 0 1 .44771525 1 1s-.44771525 1-1 1h-2c-.55228475 0-1-.44771525-1-1s.44771525-1 1-1zm8-1c.5522847 0 1 .44771525 1 1s-.4477153 1-1 1-1-.44771525-1-1 .4477153-1 1-1zm-8-3c.55228475 0 1 .44771525 1 1s-.44771525 1-1 1h-2c-.55228475 0-1-.44771525-1-1s.44771525-1 1-1z"/></svg>'}},start:function(){this.app.toolbar.add("imageposition",{title:"## imageposition.image-position ##",command:"imageposition.popup",icon:this.opts.imageposition.icon,position:{after:"image"},blocks:{types:["image"]}})},popup:function(t,e){var i,s={},a=this.opts.imageposition.items;for(i in a)a[i]&&(s[i]={name:a[i],icon:this.opts.imageposition.icons[i]});this.app.popup.create("imageposition",{setter:"imageposition.setFloat",getter:"imageposition.getFloat",form:{ifloat:{type:"segment",label:"## imageposition.image-position ##",segments:s}}}),this.app.popup.open({button:e})},getFloat:function(){var t=this.opts.imageposition.items;if(!t)return!1;var e,i=this.app.block.get().getBlock(),s="none";for(e in t)i.hasClass(t[e])&&(s=e);return{ifloat:s}},setFloat:function(t){this.app.popup.close();var t=t.getData(),e=this.app.block.get();e.setClassFromObj(this.opts.imageposition.items,t.ifloat),this.app.broadcast("image.position",{image:e.getImage(),position:t.ifloat})}}),RedactorX.add("plugin","imageresize",{translations:{en:{imageresize:{"image-resize":"Image resize"}}},defaults:{minHeight:20,minWidth:100,zIndex:97},subscribe:{"editor.blur, editor.select":function(){this.stop()},"image.position":function(){this._setResizerPosition()},"editor.unparse, editor.before.cut, editor.before.copy":function(t){this._unparse(t)},"block.set":function(t){this._load()}},stop:function(){this._remove(),this._stopEvents()},_load:function(){var t=this.app.block.get();this._remove(),t.isType("image")&&this._build(t)},_build:function(t){this.$block=t.getBlock(),this.$image=t.getImage(),this.$resizer=this.dom("<span>"),this.$resizer.attr("id",this.prefix+"-image-resizer"),this.$resizer.css({position:"absolute","z-index":this.opts.imageresize.zIndex,"background-color":"#007dff",width:"15px",height:"15px","border-radius":"8px","font-size":"0",border:"2px solid #fff",cursor:"ew-resize"}),this.$image.after(this.$resizer),this._setResizerPosition(),setTimeout(this._setResizerPosition.bind(this),30),this.$resizer.on("mousedown touchstart",this._press.bind(this))},_setResizerPosition:function(){var t=this.$image.position(),e=this.$image.width(),i=this.$image.height(),s=this.$resizer.width(),a=this.$resizer.height();this.$resizer.css({top:Math.round(t.top+i/2-a+9)+"px",left:Math.round(t.left+e-s+9)+"px"})},_press:function(t){t.preventDefault();var e=this.$image.height(),i=this.$image.width();this.resizeHandle={x:t.pageX,y:t.pageY,el:this.$image,$figure:this.$image.closest("figure"),ratio:i/e,h:e,w:i},this.app.event.pause(),this.app.$doc.on("mousemove."+this.prefix+".image-resize touchmove."+this.prefix+".image-resize",this._move.bind(this)),this.app.$doc.on("mouseup."+this.prefix+".image-resize touchend."+this.prefix+".image-resize",this._release.bind(this)),this.app.broadcast("image.resize.start",{e:t,block:this.$block,image:this.$image})},_move:function(t){t.preventDefault();var e=(a=this._getWidth(t))/this.resizeHandle.ratio,i=this.resizeHandle.el,s=this.opts.imageresize,e=Math.round(e),a=Math.round(a);e<s.minHeight||a<s.minWidth||this._getResizableBoxWidth()<=a||(0!==this.resizeHandle.$figure.length&&""!==this.resizeHandle.$figure.css("max-width")&&this.resizeHandle.$figure.css("max-width",a+"px"),i.attr({width:a,height:e}),this._setResizerPosition(),this.app.broadcast("image.resize.move",{e:t,block:this.$block,image:this.$image}))},_release:function(t){this._stopEvents(),this.app.event.run(),this.app.broadcast("image.resize.stop",{e:t,block:this.$block,image:this.$image})},_stopEvents:function(){this.app.$doc.off("."+this.prefix+".image-resize")},_remove:function(){this.app.editor.getLayout().find("#"+this.prefix+"-image-resizer").remove()},_getWidth:function(t){var e=this.resizeHandle.w;return t.targetTouches?e+=t.targetTouches[0].pageX-this.resizeHandle.x:e+=t.pageX-this.resizeHandle.x,e},_getResizableBoxWidth:function(){var t=this.app.editor.getLayout();return t.width()-parseInt(t.css("padding-left"))-parseInt(t.css("padding-right"))},_unparse:function(t){var e=t.get("html"),e=this.app.utils.wrap(e,function(t){t.find("#"+this.prefix+"-image-resizer").remove()}.bind(this));t.set("html",e)}}),RedactorX.add("plugin","imageresize",{translations:{en:{imageresize:{"image-resize":"Image resize"}}},defaults:{minHeight:20,minWidth:100,zIndex:97},subscribe:{"editor.blur, editor.select":function(){this.stop()},"image.position":function(){this._setResizerPosition()},"editor.unparse, editor.before.cut, editor.before.copy":function(t){this._unparse(t)},"block.set":function(t){this._load()}},stop:function(){this._remove(),this._stopEvents()},_load:function(){var t=this.app.block.get();this._remove(),t.isType("image")&&this._build(t)},_build:function(t){this.$block=t.getBlock(),this.$image=t.getImage(),this.$resizer=this.dom("<span>"),this.$resizer.attr("id",this.prefix+"-image-resizer"),this.$resizer.css({position:"absolute","z-index":this.opts.imageresize.zIndex,"background-color":"#007dff",width:"15px",height:"15px","border-radius":"8px","font-size":"0",border:"2px solid #fff",cursor:"ew-resize"}),this.$image.after(this.$resizer),this._setResizerPosition(),setTimeout(this._setResizerPosition.bind(this),30),this.$resizer.on("mousedown touchstart",this._press.bind(this))},_setResizerPosition:function(){var t=this.$image.position(),e=this.$image.width(),i=this.$image.height(),s=this.$resizer.width(),a=this.$resizer.height();this.$resizer.css({top:Math.round(t.top+i/2-a+9)+"px",left:Math.round(t.left+e-s+9)+"px"})},_press:function(t){t.preventDefault();var e=this.$image.height(),i=this.$image.width();this.resizeHandle={x:t.pageX,y:t.pageY,el:this.$image,$figure:this.$image.closest("figure"),ratio:i/e,h:e,w:i},this.app.event.pause(),this.app.$doc.on("mousemove."+this.prefix+".image-resize touchmove."+this.prefix+".image-resize",this._move.bind(this)),this.app.$doc.on("mouseup."+this.prefix+".image-resize touchend."+this.prefix+".image-resize",this._release.bind(this)),this.app.broadcast("image.resize.start",{e:t,block:this.$block,image:this.$image})},_move:function(t){t.preventDefault();var e=(a=this._getWidth(t))/this.resizeHandle.ratio,i=this.resizeHandle.el,s=this.opts.imageresize,e=Math.round(e),a=Math.round(a);e<s.minHeight||a<s.minWidth||this._getResizableBoxWidth()<=a||(0!==this.resizeHandle.$figure.length&&""!==this.resizeHandle.$figure.css("max-width")&&this.resizeHandle.$figure.css("max-width",a+"px"),i.attr({width:a,height:e}),this._setResizerPosition(),this.app.broadcast("image.resize.move",{e:t,block:this.$block,image:this.$image}))},_release:function(t){this._stopEvents(),this.app.event.run(),this.app.broadcast("image.resize.stop",{e:t,block:this.$block,image:this.$image})},_stopEvents:function(){this.app.$doc.off("."+this.prefix+".image-resize")},_remove:function(){this.app.editor.getLayout().find("#"+this.prefix+"-image-resizer").remove()},_getWidth:function(t){var e=this.resizeHandle.w;return t.targetTouches?e+=t.targetTouches[0].pageX-this.resizeHandle.x:e+=t.pageX-this.resizeHandle.x,e},_getResizableBoxWidth:function(){var t=this.app.editor.getLayout();return t.width()-parseInt(t.css("padding-left"))-parseInt(t.css("padding-right"))},_unparse:function(t){var e=t.get("html"),e=this.app.utils.wrap(e,function(t){t.find("#"+this.prefix+"-image-resizer").remove()}.bind(this));t.set("html",e)}}),RedactorX.add("plugin","inlineformat",{translations:{en:{inlineformat:{"inline-format":"Inline Format",underline:"Underline",superscript:"Superscript",subscript:"Subscript",mark:"Mark",code:"Code",shortcut:"Shortcut","remove-format":"Remove Format"}}},defaults:{icon:'<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m7.39849577 1.20113038c-3.5610278 2.68125517-5.39849577 5.14152807-5.39849577 7.49360646 0 3.50902886 2.59345039 6.30526316 6 6.30526316 3.4065496 0 6-2.7962343 6-6.30526316 0-2.35207839-1.837468-4.81235129-5.39849577-7.49360646-.35616697-.26817384-.84684149-.26817384-1.20300846 0zm.60150423 2.06186962.28200813.22720401c2.50634097 2.04313256 3.71799187 3.80538426 3.71799187 5.20453283 0 2.43669386-1.73306 4.30526316-4 4.30526316-2.26694005 0-4-1.8685693-4-4.30526316 0-1.39914857 1.21165095-3.16140027 3.71799187-5.20453283z"/></svg>',items:["u","sup","sub","mark","code","kbd"],itemsObj:{u:{title:'<span style="text-decoration: underline;">## inlineformat.underline ##</span>',params:{tag:"u"},shortcut:"Ctrl+u"},sup:{title:"## inlineformat.superscript ##<sup>x</sup>",params:{tag:"sup"},shortcut:"Ctrl+h"},sub:{title:"## inlineformat.subscript ##<sub>x</sub>",params:{tag:"sub"},shortcut:"Ctrl+l"},mark:{title:'<span style="background: yellow;">## inlineformat.mark ##</span>',params:{tag:"mark"}},code:{title:'<span style="font-family: monospace; background: #f0f1f2; padding: 4px;">## inlineformat.code ##</span>',params:{tag:"code"}},kbd:{title:"## inlineformat.shortcut ##",params:{tag:"kbd"}}}},start:function(){this.app.toolbar.add("inlineformat",{title:"## inlineformat.inline-format ##",icon:this.opts.inlineformat.icon,command:"inlineformat.popup",position:{after:"deleted"},blocks:{all:"editable"}})},popup:function(t,e){for(var i=this.opts.inlineformat.items,s=this.app.selection.getNodes({type:"inline"}),a={},n=0;n<i.length;n++){var o=i[n];a[o]=this.opts.inlineformat.itemsObj[o],a[o].command="inline.set"}0!==s.length&&(a.remove={title:"## inlineformat.remove-format ##",divider:"top",command:"inline.removeFormat"}),this.app.popup.create("inlineformat",{width:"300px",items:a}),this.app.popup.open({button:e})}}),RedactorX.add("plugin","inlineformat",{translations:{en:{inlineformat:{"inline-format":"Inline Format",underline:"Underline",superscript:"Superscript",subscript:"Subscript",mark:"Mark",code:"Code",shortcut:"Shortcut","remove-format":"Remove Format"}}},defaults:{icon:'<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m7.39849577 1.20113038c-3.5610278 2.68125517-5.39849577 5.14152807-5.39849577 7.49360646 0 3.50902886 2.59345039 6.30526316 6 6.30526316 3.4065496 0 6-2.7962343 6-6.30526316 0-2.35207839-1.837468-4.81235129-5.39849577-7.49360646-.35616697-.26817384-.84684149-.26817384-1.20300846 0zm.60150423 2.06186962.28200813.22720401c2.50634097 2.04313256 3.71799187 3.80538426 3.71799187 5.20453283 0 2.43669386-1.73306 4.30526316-4 4.30526316-2.26694005 0-4-1.8685693-4-4.30526316 0-1.39914857 1.21165095-3.16140027 3.71799187-5.20453283z"/></svg>',items:["u","sup","sub","mark","code","kbd"],itemsObj:{u:{title:'<span style="text-decoration: underline;">## inlineformat.underline ##</span>',params:{tag:"u"},shortcut:"Ctrl+u"},sup:{title:"## inlineformat.superscript ##<sup>x</sup>",params:{tag:"sup"},shortcut:"Ctrl+h"},sub:{title:"## inlineformat.subscript ##<sub>x</sub>",params:{tag:"sub"},shortcut:"Ctrl+l"},mark:{title:'<span style="background: yellow;">## inlineformat.mark ##</span>',params:{tag:"mark"}},code:{title:'<span style="font-family: monospace; background: #f0f1f2; padding: 4px;">## inlineformat.code ##</span>',params:{tag:"code"}},kbd:{title:"## inlineformat.shortcut ##",params:{tag:"kbd"}}}},start:function(){this.app.toolbar.add("inlineformat",{title:"## inlineformat.inline-format ##",icon:this.opts.inlineformat.icon,command:"inlineformat.popup",position:{after:"deleted"},blocks:{all:"editable"}})},popup:function(t,e){for(var i=this.opts.inlineformat.items,s=this.app.selection.getNodes({type:"inline"}),a={},n=0;n<i.length;n++){var o=i[n];a[o]=this.opts.inlineformat.itemsObj[o],a[o].command="inline.set"}0!==s.length&&(a.remove={title:"## inlineformat.remove-format ##",divider:"top",command:"inline.removeFormat"}),this.app.popup.create("inlineformat",{width:"300px",items:a}),this.app.popup.open({button:e})}}),RedactorX.add("plugin","pages",{translations:{en:{pages:{pages:"Pages"}}},defaults:{url:!1,start:3,trigger:"@"},subscribe:{"editor.keydown":function(t){this._listen(t)},"editor.keyup":function(t){void 0!==this.opts.handle&&this._handle(t)}},start:function(){this.handleLen=this.opts.pages.start},stop:function(){this._hide()},_handle:function(t){var t=t.get("e"),e=t.which,t=t.ctrlKey||t.metaKey,i=this.app.keycodes;e===i.ESC?this.app.selection.restore():e===i.DELETE||e===i.SPACE||e===i.SHIFT||t||-1!==[37,38,39,40].indexOf(e)||(e===i.BACKSPACE&&(this.handleLen=this.handleLen-2,this.handleLen<=this.opts.pages.start)&&this._hide(),this._emit())},_listen:function(t){var e,i=t.get("e"),s=i.which,a=this.app.keycodes;if(this._isShown()&&s===a.ENTER)return 0===(e=this._getActiveItem()).length?void this._hideForce():(i.preventDefault(),t.stop(),void this._replace(i,e));!this._isShown()||40!==s&&38!==s||(i.preventDefault(),t.stop(),0===(e=this._getActiveItem()).length?(a=this._getFirstItem(),this._setActive(a)):40===s?this._setNextActive(e):38===s&&this._setPrevActive(e))},_getItems:function(){return this.$panel.find("."+this.prefix+"-panel-item")},_getActiveItem:function(){return this._getItems().filter(function(t){return t.hasClass("active")})},_getFirstItem:function(){return this._getItems().first()},_getLastItem:function(){return this._getItems().last()},_setActive:function(t){this._getItems().removeClass("active"),t.addClass("active");var e=t.outerHeight(),t=t.position().top,i=this.$panel.scrollTop(),s=t+2*e,a=this.$panel.outerHeight();this.$panel.scrollTop(i+a<s?s-a:t-e<i?t-e:i)},_setNextActive:function(t){var t=t.next();0!==t.length?this._setActive(t):(t=this._getFirstItem(),this._setActive(t))},_setPrevActive:function(t){var t=t.prev();0!==t.length?this._setActive(t):(t=this._getLastItem(),this._setActive(t))},_emit:function(){var t=new RegExp("^"+this.opts.pages.trigger);this.handleStr=this.app.selection.getText("before",this.handleLen),this.handleStr2=this.app.selection.getText("before",this.handleLen+1),t.test(this.handleStr)&&(this.handleStr2&&" "===this.handleStr2[0]||""===this.handleStr2[0])&&(this.handleStr=this.handleStr.replace(this.opts.pages.trigger,""),this.handleLen++,this.handleLen-1>this.opts.pages.start)&&this._load()},_isShown:function(){return this.$panel&&this.$panel.hasClass("open")},_load:function(){this.ajax.get({url:this.opts.handle+"&search="+this.handleStr,success:this._parse.bind(this)})},_parse:function(t){""===t||Array.isArray(t)&&0===t.length?this.$panel&&this.$panel.remove():(t="object"==typeof t?t:JSON.parse(t),this._build(t))},_build:function(t){for(var e in this.data=t,this.$panel=this.app.$body.find("."+this.prefix+"-panel"),0===this.$panel.length?(this.$panel=this.dom("<div>").addClass(this.prefix+"-panel"),this.app.$body.append(this.$panel)):this.$panel.html(""),this._stopEvents(),this._startEvents(),t){var i=this.dom("<div>").addClass(this.prefix+"-panel-item"),s=this.dom("<a>").attr("href","#");s.html(this.data[e].text),s.attr("data-href",this.data[e].href),s.attr("data-text",this.data[e].text),s.on("click",this._replace.bind(this)),i.append(s),this.$panel.append(i)}var t=this.app.$doc.scrollTop(),a=this.app.selection.getPosition();this.$panel.addClass("open"),this.$panel.css({top:a.bottom+t+"px",left:a.left+"px"}),this.app.selection.save()},_replace:function(t,e){t.preventDefault(),t.stopPropagation(),e=e?e.find("a"):this.dom(t.target);var i,s,a,t=document.createElement("a"),e=(t.setAttribute("href",e.attr("data-href")),t.innerHTML=e.attr("data-text"),this.app.marker.insert("start"),this.app.marker.find("start"));!1!==e&&(i=this.dom(e),a=(e=e.previousSibling).textContent,s=new RegExp(this.opts.pages.trigger+this.handleStr+"$"),a=a.replace(s,""),e.textContent=a,i.before(t),this.app.selection.restoreMarker(),this._hide())},_reset:function(){this.handleStr=!1,this.handleLen=this.opts.pages.start,this.$panel=!1},_hide:function(t){var e=!1,i=t&&t.which,s=this.app.keycodes;(e=t&&"click"!==t.type&&i!==s.ESC&&i!==s.SPACE?e:!0)&&this._hideForce()},_hideForce:function(){this.$panel&&this.$panel.remove(),this._reset(),this._stopEvents()},_startEvents:function(){var t="click."+this.prefix+"-plugin-handle keydown."+this.prefix+"-plugin-handle";this.app.$doc.on(t,this._hide.bind(this)),this.app.editor.getEditor().on(t,this._hide.bind(this))},_stopEvents:function(){var t="."+this.prefix+"-plugin-handle";this.app.$doc.off(t),this.app.editor.getEditor().off(t)}}),RedactorX.add("plugin","readmore",{translations:{en:{readmore:"Read more"}},start:function(){this.app.toolbar.add("readmore",{title:this.lang.get("readmore"),icon:'<i class="re-icon-readmore"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" width="18" height="18"><path d="M3.598.687h1.5v5h-1.5zm14.5 0h1.5v5h-1.5z"></path><path d="M19.598 4.187v1.5h-16v-1.5zm-16 14.569h1.5v-5h-1.5zm14.5 0h1.5v-5h-1.5z"></path><path d="M19.598 15.256v-1.5h-16v1.5zM5.081 9h6v2h-6zm8 0h6v2h-6zm-9.483 1L0 12.5v-5z"></path></svg></i>',command:"readmore.open"})},open:function(){var t='<div class="readmore"><span class="readmore__label">'+this.lang.get("readmore")+"</span></div>";this.app.editor.insertContent({html:t})}}),RedactorX.add("plugin","removeformat",{translations:{en:{removeformat:{removeformat:"Remove Format"}}},defaults:{icon:'<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m8 11c.51283584 0 .93550716.3860402.99327227.8833789l.00672773.1166211v1c0 .5522847-.44771525 1-1 1-.51283584 0-.93550716-.3860402-.99327227-.8833789l-.00672773-.1166211v-1c0-.5522847.44771525-1 1-1zm-4.60436072-5.91850958.10436072.05248418 9.5262794 5.5c.4782927.2761424.6421678.8877328.3660254 1.3660254-.2564179.4441289-.8020741.6171529-1.2616646.4185096l-.1043608-.0524842-9.5262794-5.5c-.47829262-.27614237-.64216778-.88773278-.3660254-1.3660254.25641792-.44412886.80207419-.61715287 1.26166468-.41850958zm9.60436072-3.08149042c.5522847 0 1 .44771525 1 1 0 .51283584-.3860402.93550716-.8833789.99327227l-.1166211.00672773h-4.00016698l.00016698 2c0 .55228475-.44771525 1-1 1-.51283584 0-.93550716-.38604019-.99327227-.88337887l-.00672773-.11662113-.00016698-2h-3.99983302c-.55228475 0-1-.44771525-1-1 0-.51283584.38604019-.93550716.88337887-.99327227l.11662113-.00672773z"/></svg>'},start:function(){var t={title:"## removeformat.removeformat ##",icon:this.opts.removeformat.icon,command:"inline.removeFormat",position:{after:["deleted","italic"]},blocks:{all:"editable"}};this.app.toolbar.add("removeformat",t),this.app.context.add("removeformat",t)}}),RedactorX.add("plugin","removeformat",{translations:{en:{removeformat:{removeformat:"Remove Format"}}},defaults:{icon:'<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m8 11c.51283584 0 .93550716.3860402.99327227.8833789l.00672773.1166211v1c0 .5522847-.44771525 1-1 1-.51283584 0-.93550716-.3860402-.99327227-.8833789l-.00672773-.1166211v-1c0-.5522847.44771525-1 1-1zm-4.60436072-5.91850958.10436072.05248418 9.5262794 5.5c.4782927.2761424.6421678.8877328.3660254 1.3660254-.2564179.4441289-.8020741.6171529-1.2616646.4185096l-.1043608-.0524842-9.5262794-5.5c-.47829262-.27614237-.64216778-.88773278-.3660254-1.3660254.25641792-.44412886.80207419-.61715287 1.26166468-.41850958zm9.60436072-3.08149042c.5522847 0 1 .44771525 1 1 0 .51283584-.3860402.93550716-.8833789.99327227l-.1166211.00672773h-4.00016698l.00016698 2c0 .55228475-.44771525 1-1 1-.51283584 0-.93550716-.38604019-.99327227-.88337887l-.00672773-.11662113-.00016698-2h-3.99983302c-.55228475 0-1-.44771525-1-1 0-.51283584.38604019-.93550716.88337887-.99327227l.11662113-.00672773z"/></svg>'},start:function(){var t={title:"## removeformat.removeformat ##",icon:this.opts.removeformat.icon,command:"inline.removeFormat",position:{after:["deleted","italic"]},blocks:{all:"editable"}};this.app.toolbar.add("removeformat",t),this.app.context.add("removeformat",t)}}),RedactorX.add("plugin","rte_definedlinks",{defaults:{items:null},init:function(){this.items=null},subscribe:{"popup.open":function(){var t=this.app.popup.getName();"link"!==t&&"image-edit"!==t||(null===this.items?this._load():0!==this.items.length&&this._build())}},_load:function(){null!==this.items&&0<this.items.length||this.ajax.get({url:this.opts.definedlinks,success:function(t){this.items=t,0!==this.items.length&&this._build()}.bind(this)})},_build:function(){var t=this.app.popup.getFormItem("link").find("input"),e=(0==t.nodes.length&&(t=this.app.popup.getFormItem("url").find("input")),this.dom("<div>").addClass(this.prefix+"-form-item").css("padding","0px 0px 16px 0px"));this.$select=this._create(),e.append(this.$select),t.before(e),"BASE"in window.EE&&Dropdown.renderFields()},_create:function(){var t=this.dom("<div>").addClass(this.prefix+"-form-div"),i={},e=($.each(this.items,function(t,e){e.label=e.text,e.value=e.href,i[t]=e}),{name:this.prefix+"-form-dropdown-react",items:i,initialItems:i,disabled:!1,tooMany:8,limit:100,emptyText:"Select a Page",conditionalRule:"rx-redactor-dropdown"}),e=btoa(JSON.stringify(e));return t.attr("data-input-value",this.prefix+"-form-dropdown-react"),t.attr("data-dropdown-react",e),t}}),RedactorX.add("plugin","selector",{translations:{en:{selector:{"class-id":"Class & ID"}}},defaults:{icon:'<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m10.6663083 2.14369002c.5071647.07664087.8669828.53941479.8491564 1.06286535l-.0109223.12172524-.2435424 1.67154209 1.239.0001773c.5522847 0 1 .44771525 1 1 0 .51283584-.3860402.93550716-.8833789.99327227l-.1166211.00672773-1.531-.0001773-.291 2 1.322.0001773c.5522847 0 1 .44771525 1 1 0 .5128358-.3860402.9355072-.8833789.9932723l-.1166211.0067277-1.613-.0001773-.3121956 2.1487091c-.08323349.571695-.59347185.9682364-1.13964926.8857001-.50716474-.0766409-.86698283-.5394148-.84915642-1.0628653l.01092235-.1217253.26807893-1.8498186h-1.978l-.31219557 2.1487091c-.08323352.571695-.59347188.9682364-1.13964929.8857001-.50716474-.0766409-.86698283-.5394148-.84915642-1.0628653l.01092235-.1217253.26807893-1.8498186-1.365.0001773c-.55228475 0-1-.4477153-1-1 0-.51283584.38604019-.93550716.88337887-.99327227l.11662113-.00672773 1.656-.0001773.292-2-1.448.0001773c-.55228475 0-1-.44771525-1-1 0-.51283584.38604019-.93550716.88337887-.99327227l.11662113-.00672773 1.739-.0001773.28765901-1.97043255c.08323352-.571695.59347189-.96823646 1.1396493-.88570013.50716473.07664087.86698282.53941479.84915642 1.06286535l-.01092236.12172524-.24354237 1.67154209h1.978l.28765901-1.97043255c.08323352-.571695.59347189-.96823646 1.13964929-.88570013zm-2.0103083 6.85613268.292-2h-1.979l-.291 2z"/></svg>'},popups:{base:{title:"## selector.class-id ##",width:"100%",form:{classname:{type:"input",label:"Class"},id:{type:"input",label:"ID"}},footer:{insert:{title:"## buttons.save ##",command:"selector.save",type:"primary"},cancel:{title:"## buttons.cancel ##",command:"popup.close"}}}},init:function(){this.editorClasses=[]},start:function(){var t={title:"## selector.class-id ##",icon:this.opts.selector.icon,command:"selector.popup",blocks:{all:"all"}};this.app.toolbar.add("selector",t),t.position={before:"duplicate"},this.app.control.add("selector",t)},popup:function(t,e){this.app.popup.create("selector",this.popups.base);for(var i=this.app.block.get().getBlock(),s=i.attr("class"),i=i.attr("id"),a=s.split(" "),s="",n=0;n<a.length;n++)-1===a[n].search(this.prefix+"-")?s+=a[n]+" ":this.editorClasses.push(a[n]);this.app.popup.setData({id:i,classname:s.trim()}),this.app.popup.open({button:e,focus:"classname"})},save:function(){this.app.popup.close();var t=this.app.block.get().getBlock(),e=this.app.popup.getData();""===e.id?t.removeAttr("id"):t.attr("id",e.id),0<this.editorClasses.length&&(e.classname=e.classname+" "+this.editorClasses.join(" ")),t.attr("class",e.classname),this.editorClasses=[]}}),RedactorX.add("plugin","selector",{translations:{en:{selector:{"class-id":"Class & ID"}}},defaults:{icon:'<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m10.6663083 2.14369002c.5071647.07664087.8669828.53941479.8491564 1.06286535l-.0109223.12172524-.2435424 1.67154209 1.239.0001773c.5522847 0 1 .44771525 1 1 0 .51283584-.3860402.93550716-.8833789.99327227l-.1166211.00672773-1.531-.0001773-.291 2 1.322.0001773c.5522847 0 1 .44771525 1 1 0 .5128358-.3860402.9355072-.8833789.9932723l-.1166211.0067277-1.613-.0001773-.3121956 2.1487091c-.08323349.571695-.59347185.9682364-1.13964926.8857001-.50716474-.0766409-.86698283-.5394148-.84915642-1.0628653l.01092235-.1217253.26807893-1.8498186h-1.978l-.31219557 2.1487091c-.08323352.571695-.59347188.9682364-1.13964929.8857001-.50716474-.0766409-.86698283-.5394148-.84915642-1.0628653l.01092235-.1217253.26807893-1.8498186-1.365.0001773c-.55228475 0-1-.4477153-1-1 0-.51283584.38604019-.93550716.88337887-.99327227l.11662113-.00672773 1.656-.0001773.292-2-1.448.0001773c-.55228475 0-1-.44771525-1-1 0-.51283584.38604019-.93550716.88337887-.99327227l.11662113-.00672773 1.739-.0001773.28765901-1.97043255c.08323352-.571695.59347189-.96823646 1.1396493-.88570013.50716473.07664087.86698282.53941479.84915642 1.06286535l-.01092236.12172524-.24354237 1.67154209h1.978l.28765901-1.97043255c.08323352-.571695.59347189-.96823646 1.13964929-.88570013zm-2.0103083 6.85613268.292-2h-1.979l-.291 2z"/></svg>'},popups:{base:{title:"## selector.class-id ##",width:"100%",form:{classname:{type:"input",label:"Class"},id:{type:"input",label:"ID"}},footer:{insert:{title:"## buttons.save ##",command:"selector.save",type:"primary"},cancel:{title:"## buttons.cancel ##",command:"popup.close"}}}},init:function(){this.editorClasses=[]},start:function(){var t={title:"## selector.class-id ##",icon:this.opts.selector.icon,command:"selector.popup",blocks:{all:"all"}};this.app.toolbar.add("selector",t),t.position={before:"duplicate"},this.app.control.add("selector",t)},popup:function(t,e){this.app.popup.create("selector",this.popups.base);for(var i=(s=this.app.block.get().getBlock()).attr("class"),s=s.attr("id"),a=i.split(" "),i="",n=0;n<a.length;n++)-1===a[n].search(this.prefix+"-")?i+=a[n]+" ":this.editorClasses.push(a[n]);this.app.popup.setData({id:s,classname:i.trim()}),this.app.popup.open({button:e,focus:"classname"})},save:function(){this.app.popup.close();var t=this.app.block.get().getBlock(),e=this.app.popup.getData();""===e.id?t.removeAttr("id"):t.attr("id",e.id),0<this.editorClasses.length&&(e.classname=e.classname+" "+this.editorClasses.join(" ")),t.attr("class",e.classname),this.editorClasses=[]}}),RedactorX.add("plugin","specialchars",{translations:{en:{specialchars:{"special-chars":"Special Characters"}}},defaults:{icon:'<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m2 14v-1.8348348h2.38016529v-.0780781c-.99173554-.975976-2.10247934-2.67417419-2.10247934-4.99699701 0-3.57207207 2.28099174-6.09009009 5.73223141-6.09009009 3.43140494 0 5.71239664 2.51801802 5.71239664 6.09009009 0 2.32282282-1.1107438 4.02102101-2.1024793 4.99699701v.0780781h2.3801653v1.8348348h-4.95867769v-1.6396396c1.40826449-1.1906907 2.32066119-2.75225229 2.32066119-5.07507511 0-2.4984985-1.2495868-4.31381382-3.35206614-4.31381382s-3.37190083 1.81531532-3.37190083 4.31381382c0 2.32282282.91239669 3.88438441 2.32066116 5.07507511v1.6396396z"/></svg>',items:["‘","’","“","”","–","—","÷","…","™","•","→","≈","$","€","¢","£","¥","¡","¤","¦","§","¨","©","ª","«","»","¬","®","¯","°","¹","²","³","´","µ","¶","·","¸","º","¼","½","¾","¿","À","Á","Â","Ã","Ä","Å","Æ","Ç","È","É","Ê","Ë","Ì","Í","Î","Ï","Ð","Ñ","Ò","Ó","Ô","Õ","Ö","×","Ø","Ù","Ú","Û","Ü","Ý","Þ","ß","à","á","â","ã","ä","å","æ","ç","è","é","ê","ë","ì","í","î","ï","ð","ñ","ò","ó","ô","õ","ö","ø","ù","ú","û","ü","ý","þ","ÿ","Œ","œ","Ŵ","Ŷ","ŵ","ŷ"]},start:function(){var t={title:"## specialchars.special-chars ##",icon:this.opts.specialchars.icon,command:"specialchars.popup",blocks:{all:"editable"}};this.app.toolbar.add("specialchars",t)},popup:function(t,e){for(var i={},s=this.opts.specialchars.items,a=0;a<s.length;a++)i[a]={html:this.dom("<div>").addClass(this.prefix+"-popup-item").html(s[a]),command:"specialchars.insert",params:{character:s[a]}};this.app.popup.create("specialchars",{type:"grid",width:"352px",items:i}),this.app.popup.open({button:e})},insert:function(t){this.app.popup.close(),this.app.insertion.insertHtml(t.character,"after")}}),RedactorX.add("plugin","specialchars",{translations:{en:{specialchars:{"special-chars":"Special Characters"}}},defaults:{icon:'<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m2 14v-1.8348348h2.38016529v-.0780781c-.99173554-.975976-2.10247934-2.67417419-2.10247934-4.99699701 0-3.57207207 2.28099174-6.09009009 5.73223141-6.09009009 3.43140494 0 5.71239664 2.51801802 5.71239664 6.09009009 0 2.32282282-1.1107438 4.02102101-2.1024793 4.99699701v.0780781h2.3801653v1.8348348h-4.95867769v-1.6396396c1.40826449-1.1906907 2.32066119-2.75225229 2.32066119-5.07507511 0-2.4984985-1.2495868-4.31381382-3.35206614-4.31381382s-3.37190083 1.81531532-3.37190083 4.31381382c0 2.32282282.91239669 3.88438441 2.32066116 5.07507511v1.6396396z"/></svg>',items:["‘","’","“","”","–","—","÷","…","™","•","→","≈","$","€","¢","£","¥","¡","¤","¦","§","¨","©","ª","«","»","¬","®","¯","°","¹","²","³","´","µ","¶","·","¸","º","¼","½","¾","¿","À","Á","Â","Ã","Ä","Å","Æ","Ç","È","É","Ê","Ë","Ì","Í","Î","Ï","Ð","Ñ","Ò","Ó","Ô","Õ","Ö","×","Ø","Ù","Ú","Û","Ü","Ý","Þ","ß","à","á","â","ã","ä","å","æ","ç","è","é","ê","ë","ì","í","î","ï","ð","ñ","ò","ó","ô","õ","ö","ø","ù","ú","û","ü","ý","þ","ÿ","Œ","œ","Ŵ","Ŷ","ŵ","ŷ"]},start:function(){var t={title:"## specialchars.special-chars ##",icon:this.opts.specialchars.icon,command:"specialchars.popup",blocks:{all:"editable"}};this.app.toolbar.add("specialchars",t)},popup:function(t,e){for(var i={},s=this.opts.specialchars.items,a=0;a<s.length;a++)i[a]={html:this.dom("<div>").addClass(this.prefix+"-popup-item").html(s[a]),command:"specialchars.insert",params:{character:s[a]}};this.app.popup.create("specialchars",{type:"grid",width:"352px",items:i}),this.app.popup.open({button:e})},insert:function(t){this.app.popup.close(),this.app.insertion.insertHtml(t.character,"after")}}),RedactorX.add("plugin","textdirection",{translations:{en:{textdirection:{title:"RTL-LTR",ltr:"Left to Right",rtl:"Right to Left"}}},defaults:{icon:'<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m3.8 8.10002943c.12590292.09442719.2.24262134.2.4v1.49999997h9c.5522847 0 1 .4477153 1 1 0 .5128359-.3860402.9355072-.8833789.9932723l-.1166211.0067277h-9v1.5c0 .2761424-.22385763.5-.5.5-.15737865 0-.30557281-.0740971-.4-.2l-1.875-2.5c-.13333333-.1777778-.13333333-.4222222 0-.6l1.875-2.49999997c.16568542-.2209139.4790861-.26568543.7-.1zm7.4-6c.2209139-.16568543.5343146-.1209139.7.1l1.875 2.5c.1333333.17777777.1333333.42222222 0 .6l-1.875 2.5c-.0944272.12590292-.2426213.2-.4.2-.2761424 0-.5-.22385763-.5-.5v-1.5h-9c-.55228475 0-1-.44771525-1-1 0-.51283584.38604019-.93550716.88337887-.99327227l.11662113-.00672773 8.999-.00002943.001-1.49997057c0-.12590293.0474221-.24592777.1308533-.33724831z"/></svg>'},start:function(){this.app.toolbar.add("textdirection",{title:"## textdirection.title ##",icon:this.opts.textdirection.icon,command:"textdirection.toggle",blocks:{all:"editable",types:["pre"]}})},toggle:function(t,e){var i=this.app.block.get().getBlock().attr("dir"),s={ltr:{title:"## textdirection.ltr ##",command:"textdirection.set"},rtl:{title:"## textdirection.rtl ##",command:"textdirection.set"}};s[i||this.opts.editor.direction].active=!0,this.app.popup.create("textdirection",{items:s}),this.app.popup.open({button:e})},set:function(t,e,i){this.app.popup.close();var s=this.app.block.get().getBlock();this.opts.editor.direction===i?s.removeAttr("dir"):s.attr("dir",i)}}),RedactorX.add("plugin","textdirection",{translations:{en:{textdirection:{title:"RTL-LTR",ltr:"Left to Right",rtl:"Right to Left"}}},defaults:{icon:'<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m3.8 8.10002943c.12590292.09442719.2.24262134.2.4v1.49999997h9c.5522847 0 1 .4477153 1 1 0 .5128359-.3860402.9355072-.8833789.9932723l-.1166211.0067277h-9v1.5c0 .2761424-.22385763.5-.5.5-.15737865 0-.30557281-.0740971-.4-.2l-1.875-2.5c-.13333333-.1777778-.13333333-.4222222 0-.6l1.875-2.49999997c.16568542-.2209139.4790861-.26568543.7-.1zm7.4-6c.2209139-.16568543.5343146-.1209139.7.1l1.875 2.5c.1333333.17777777.1333333.42222222 0 .6l-1.875 2.5c-.0944272.12590292-.2426213.2-.4.2-.2761424 0-.5-.22385763-.5-.5v-1.5h-9c-.55228475 0-1-.44771525-1-1 0-.51283584.38604019-.93550716.88337887-.99327227l.11662113-.00672773 8.999-.00002943.001-1.49997057c0-.12590293.0474221-.24592777.1308533-.33724831z"/></svg>'},start:function(){this.app.toolbar.add("textdirection",{title:"## textdirection.title ##",icon:this.opts.textdirection.icon,command:"textdirection.toggle",blocks:{all:"editable",types:["pre"]}})},toggle:function(t,e){var i={ltr:{title:"## textdirection.ltr ##",command:"textdirection.set"},rtl:{title:"## textdirection.rtl ##",command:"textdirection.set"}};i[this.app.block.get().getBlock().attr("dir")||this.opts.editor.direction].active=!0,this.app.popup.create("textdirection",{items:i}),this.app.popup.open({button:e})},set:function(t,e,i){this.app.popup.close();var s=this.app.block.get().getBlock();this.opts.editor.direction===i?s.removeAttr("dir"):s.attr("dir",i)}}),RedactorX.add("plugin","textexpander",{defaults:{items:!1},start:function(){this.opts.textexpander.items&&(this.$editor=this.app.editor.getEditor(),this.$editor.on("keyup."+this.prefix+"-plugin-textexpander",this._expand.bind(this)))},stop:function(){this.$editor.off("."+this.prefix+"-plugin-textexpander")},_expand:function(t){var e=t.which;if(e===this.app.keycodes.SPACE){var i=this.opts.textexpander.items;for(e in i){var s=i[e],a=new RegExp(this.app.utils.escapeRegExp(e)+"\\s$"),n=e.length+1;if(e===this.app.selection.getText("before",n).trim())return this._replaceSelection(a,s)}}},_replaceSelection:function(t,e){this.app.marker.insert();var i=this.app.marker.find("start").previousSibling,s=i.textContent;s=(s=s.replace(/ /," ")).replace(t,e),i.textContent=s,this.app.marker.remove()}}),RedactorX.add("plugin","textexpander",{defaults:{items:!1},start:function(){this.opts.textexpander.items&&(this.$editor=this.app.editor.getEditor(),this.$editor.on("keyup."+this.prefix+"-plugin-textexpander",this._expand.bind(this)))},stop:function(){this.$editor.off("."+this.prefix+"-plugin-textexpander")},_expand:function(t){var e=t.which;if(e===this.app.keycodes.SPACE){var i=this.opts.textexpander.items;for(e in i){var s=i[e],a=new RegExp(this.app.utils.escapeRegExp(e)+"\\s$"),n=e.length+1;if(e===this.app.selection.getText("before",n).trim())return this._replaceSelection(a,s)}}},_replaceSelection:function(t,e){this.app.marker.insert();var i=this.app.marker.find("start").previousSibling,s=(s=(s=i.textContent).replace(/ /," ")).replace(t,e);i.textContent=s,this.app.marker.remove()}}),RedactorX.add("plugin","underline",{defaults:{icon:'<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m12.2307692 12c.5522848 0 1 .4477153 1 1 0 .5128358-.3860402.9355072-.8833788.9932723l-.1166212.0067277h-8.2307692c-.55228475 0-1-.4477153-1-1 0-.5128358.38604019-.9355072.88337887-.9932723l.11662113-.0067277zm-1.2307692-10c.5128358 0 .9355072.43429521.9932723.99380123l.0067277.13119877v3.51108871c0 2.42071645-1.7998593 4.36391129-4 4.36391129-2.13138633 0-3.8871179-1.82364282-3.99476969-4.13841284l-.00523031-.22549845v-3.51108871c0-.62132034.44771525-1.125 1-1.125.51283584 0 .93550716.43429521.99327227.99380123l.00672773.13119877v3.51108871c0 1.15688618.88643222 2.11391129 2 2.11391129 1.06054074 0 1.91506284-.86804999 1.99404104-1.95008319l.00595896-.1638281v-3.51108871c0-.62132034.4477153-1.125 1-1.125z"/></svg>'},start:function(){var t={title:"## buttons.underline ##",icon:this.opts.underline.icon,command:"inline.set",position:{after:"italic"},active:{tags:["u"]},params:{tag:"u"},blocks:{all:"editable"}};this.app.toolbar.add("underline",t),this.app.context.add("underline",t)}}),RedactorX.add("plugin","underline",{defaults:{icon:'<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m12.2307692 12c.5522848 0 1 .4477153 1 1 0 .5128358-.3860402.9355072-.8833788.9932723l-.1166212.0067277h-8.2307692c-.55228475 0-1-.4477153-1-1 0-.5128358.38604019-.9355072.88337887-.9932723l.11662113-.0067277zm-1.2307692-10c.5128358 0 .9355072.43429521.9932723.99380123l.0067277.13119877v3.51108871c0 2.42071645-1.7998593 4.36391129-4 4.36391129-2.13138633 0-3.8871179-1.82364282-3.99476969-4.13841284l-.00523031-.22549845v-3.51108871c0-.62132034.44771525-1.125 1-1.125.51283584 0 .93550716.43429521.99327227.99380123l.00672773.13119877v3.51108871c0 1.15688618.88643222 2.11391129 2 2.11391129 1.06054074 0 1.91506284-.86804999 1.99404104-1.95008319l.00595896-.1638281v-3.51108871c0-.62132034.4477153-1.125 1-1.125z"/></svg>'},start:function(){var t={title:"## buttons.underline ##",icon:this.opts.underline.icon,command:"inline.set",position:{after:"italic"},active:{tags:["u"]},params:{tag:"u"},blocks:{all:"editable"}};this.app.toolbar.add("underline",t),this.app.context.add("underline",t)}});
| ver. 1.4 |
Github
|
.
| PHP 8.2.30 | Генерация страницы: 0.02 |
proxy
|
phpinfo
|
Настройка