Seditio Source
Root |
./othercms/xenForo 2.2.8/js/vendor/froala/plugins/image.min.js
/*!
 * froala_editor v4.0.7 (https://www.froala.com/wysiwyg-editor)
 * License https://froala.com/wysiwyg-editor/terms/
 * Copyright 2014-2021 Froala Labs
 */
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(require("froala-editor")):"function"==typeof define&&define.amd?define(["froala-editor"],t):t(e.FroalaEditor)}(this,function(e){"use strict";function t(e){"@babel/helpers - typeof";return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}e=e&&e.hasOwnProperty("default")?e.default:e,Object.assign(e.POPUP_TEMPLATES,{"image.insert":"[_BUTTONS_][_UPLOAD_LAYER_][_BY_URL_LAYER_][_PROGRESS_BAR_]","image.edit":"[_BUTTONS_]","image.alt":"[_BUTTONS_][_ALT_LAYER_]","image.size":"[_BUTTONS_][_SIZE_LAYER_]"}),Object.assign(e.DEFAULTS,{imageInsertButtons:["imageBack","|","imageUpload","imageByURL"],imageEditButtons:["imageReplace","imageAlign","imageCaption","imageRemove","imageLink","linkOpen","linkEdit","linkRemove","-","imageDisplay","imageStyle","imageAlt","imageSize"],imageAltButtons:["imageBack","|"],imageSizeButtons:["imageBack","|"],imageUpload:!0,imageUploadURL:null,imageCORSProxy:"https://cors-anywhere.froala.com",imageUploadRemoteUrls:!0,imageUploadParam:"file",imageUploadParams:{},imageUploadToS3:!1,imageUploadToAzure:!1,imageUploadMethod:"POST",imageMaxSize:10485760,imageAllowedTypes:["jpeg","jpg","png","gif","webp"],imageResize:!0,imageResizeWithPercent:!1,imageRoundPercent:!1,imageDefaultWidth:300,imageDefaultAlign:"center",imageDefaultDisplay:"block",imageSplitHTML:!1,imageStyles:{"fr-rounded":"Rounded","fr-bordered":"Bordered","fr-shadow":"Shadow"},imageMove:!0,imageMultipleStyles:!0,imageTextNear:!0,imagePaste:!0,imagePasteProcess:!1,imageMinWidth:16,imageOutputSize:!1,imageDefaultMargin:5,imageAddNewLine:!1}),e.PLUGINS.image=function(a){var i,n,r,o,s,l,p=a.$,g="https://i.froala.com/upload",f=!1,c=1,d=2,u=3,m=4,h=5,v=6,b={};function y(){var e=a.popups.get("image.insert").find(".fr-image-by-url-layer input");e.val(""),i&&e.val(i.attr("src")),e.trigger("change")}function w(e){return window.pageYOffset+e.get(0).getBoundingClientRect().top}function A(){var e=a.popups.get("image.edit");if(e||(e=N()),e){var t=i;a.popups.setContainer("image.edit",a.$sc),a.popups.refresh("image.edit");var n=t.offset().left+t.outerWidth()/2,r=t&&w(t),o=w(a.$wp),s=0;a.opts.iframe?((s=a.$wp.scrollTop()+e.outerHeight())<t.get(0).getBoundingClientRect().top&&(s=t.get(0).getBoundingClientRect().top),s>t.get(0).getBoundingClientRect().top+t.height()&&(s=t.get(0).getBoundingClientRect().top+t.height())):s=r>o?r:r+t.height()<o+a.$wp.height()?r+t.height():o+e.outerHeight(),i.hasClass("fr-uploading")?B():a.popups.show("image.edit",n,s,t.outerHeight(),!0)}}function C(){z()}function S(e){e.parents(".fr-img-caption").length>0&&(e=e.parents(".fr-img-caption").first()),e.hasClass("fr-dii")||e.hasClass("fr-dib")||(e.addClass("fr-fi".concat(be(e)[0])),e.addClass("fr-di".concat(ye(e)[0])),e.css("margin",""),e.css("float",""),e.css("display",""),e.css("z-index",""),e.css("position",""),e.css("overflow",""),e.css("vertical-align",""))}function E(e){e.parents(".fr-img-caption").length>0&&(e=e.parents(".fr-img-caption").first()),ve(e,e.hasClass("fr-dib")?"block":e.hasClass("fr-dii")?"inline":null,e.hasClass("fr-fil")?"left":e.hasClass("fr-fir")?"right":be(e)),e.removeClass("fr-dib fr-dii fr-fir fr-fil")}function R(){for(var e="IMG"==a.el.tagName?[a.el]:a.el.querySelectorAll("img"),t=0;t<e.length;t++){var i=p(e[t]);!a.opts.htmlUntouched&&a.opts.useClasses?((a.opts.imageDefaultAlign||a.opts.imageDefaultDisplay)&&S(i),a.opts.imageTextNear||(i.parents(".fr-img-caption").length>0?i.parents(".fr-img-caption").first().removeClass("fr-dii").addClass("fr-dib"):i.removeClass("fr-dii").addClass("fr-dib"))):a.opts.htmlUntouched||a.opts.useClasses||(a.opts.imageDefaultAlign||a.opts.imageDefaultDisplay)&&E(i),a.opts.iframe&&i.on("load",a.size.syncIframe)}}function U(e){void 0===e&&(e=!0);var t,i=Array.prototype.slice.call(a.el.querySelectorAll("img")),n=[];for(t=0;t<i.length;t++)if(n.push(i[t].getAttribute("src")),p(i[t]).toggleClass("fr-draggable",a.opts.imageMove),""===i[t].getAttribute("class")&&i[t].removeAttribute("class"),""===i[t].getAttribute("style")&&i[t].removeAttribute("style"),i[t].parentNode&&i[t].parentNode.parentNode&&a.node.hasClass(i[t].parentNode.parentNode,"fr-img-caption")){var r=i[t].parentNode.parentNode;a.browser.mozilla||r.setAttribute("contenteditable",!1),r.setAttribute("draggable",!1),r.classList.add("fr-draggable");var o=i[t].nextSibling;o&&!a.browser.mozilla&&o.setAttribute("contenteditable",!0)}if(s)for(t=0;t<s.length;t++)n.indexOf(s[t].getAttribute("src"))<0&&a.events.trigger("image.removed",[p(s[t])]);if(s&&e){var l=[];for(t=0;t<s.length;t++)l.push(s[t].getAttribute("src"));for(t=0;t<i.length;t++)l.indexOf(i[t].getAttribute("src"))<0&&a.events.trigger("image.loaded",[p(i[t])])}s=i}function x(){if(n||function(){var t;a.shared.$image_resizer?(n=a.shared.$image_resizer,o=a.shared.$img_overlay,a.events.on("destroy",function(){p("body").first().append(n.removeClass("fr-active"))},!0)):(a.shared.$image_resizer=p(document.createElement("div")).attr("class","fr-image-resizer"),n=a.shared.$image_resizer,a.events.$on(n,"mousedown",function(e){e.stopPropagation()},!0),a.opts.imageResize&&(n.append(D("nw")+D("ne")+D("sw")+D("se")),a.shared.$img_overlay=p(document.createElement("div")).attr("class","fr-image-overlay"),o=a.shared.$img_overlay,t=n.get(0).ownerDocument,p(t).find("body").first().append(o)));a.events.on("shared.destroy",function(){n.html("").removeData().remove(),n=null,a.opts.imageResize&&(o.remove(),o=null)},!0),a.helpers.isMobile()||a.events.$on(p(a.o_win),"resize",function(){i&&!i.hasClass("fr-uploading")?de(!0):i&&(x(),we(),B(!1))});if(a.opts.imageResize){t=n.get(0).ownerDocument,a.events.$on(n,a._mousedown,".fr-handler",$),a.events.$on(p(t),a._mousemove,I),a.events.$on(p(t.defaultView||t.parentWindow),a._mouseup,P),a.events.$on(o,"mouseleave",P);var r=1,s=null,l=0;a.events.on("keydown",function(t){if(i){var n=-1!=navigator.userAgent.indexOf("Mac OS X")?t.metaKey:t.ctrlKey,o=t.which;(o!==s||t.timeStamp-l>200)&&(r=1),(o==e.KEYCODE.EQUALS||a.browser.mozilla&&o==e.KEYCODE.FF_EQUALS)&&n&&!t.altKey?r=ie.call(this,t,1,1,r):(o==e.KEYCODE.HYPHEN||a.browser.mozilla&&o==e.KEYCODE.FF_HYPHEN)&&n&&!t.altKey?r=ie.call(this,t,2,-1,r):a.keys.ctrlKey(t)||o!=e.KEYCODE.ENTER||(i.before("<br>"),_(i)),s=o,l=t.timeStamp}},!0),a.events.on("keyup",function(){r=1})}}(),!i)return!1;var t=a.$wp||a.$sc;t.append(n),n.data("instance",a);var r=t.scrollTop()-("static"!=t.css("position")?t.offset().top:0),s=t.scrollLeft()-("static"!=t.css("position")?t.offset().left:0);s-=a.helpers.getPX(t.css("border-left-width")),r-=a.helpers.getPX(t.css("border-top-width")),a.$el.is("img")&&a.$sc.is("body")&&(r=0,s=0);var l=Se();Ee()&&(l=l.find(".fr-img-wrap"));var g=0,f=0;a.opts.iframe&&(g=a.helpers.getPX(a.$wp.find(".fr-iframe").css("padding-top")),f=a.helpers.getPX(a.$wp.find(".fr-iframe").css("padding-left"))),n.css("top",(a.opts.iframe?l.offset().top+g:l.offset().top+r)-1).css("left",(a.opts.iframe?l.offset().left+f:l.offset().left+s)-1).css("width",l.get(0).getBoundingClientRect().width).css("height",l.get(0).getBoundingClientRect().height).addClass("fr-active")}function D(e){return'<div class="fr-handler fr-h'.concat(e,'"></div>')}function T(e){Ee()?i.parents(".fr-img-caption").css("width",e):i.css("width",e)}function $(e){if(!a.core.sameInstance(n))return!0;if(e.preventDefault(),e.stopPropagation(),a.$el.find("img.fr-error").left)return!1;a.undo.canDo()||a.undo.saveStep();var t=e.pageX||e.originalEvent.touches[0].pageX;if("mousedown"==e.type){var s=a.$oel.get(0).ownerDocument,l=s.defaultView||s.parentWindow,g=!1;try{g=l.location!=l.parent.location&&!(l.$&&l.$.FE)}catch(e){}g&&l.frameElement&&(t+=a.helpers.getPX(p(l.frameElement).offset().left)+l.frameElement.clientLeft)}(r=p(this)).data("start-x",t),r.data("start-width",i.width()),r.data("start-height",i.height());var f=i.width();if(a.opts.imageResizeWithPercent){var c=i.parentsUntil(a.$el,a.html.blockTagsQuery()).get(0)||a.el;f=(f/p(c).outerWidth()*100).toFixed(2)+"%"}T(f),o.show(),a.popups.hideAll(),he()}function I(e){if(!a.core.sameInstance(n))return!0;var t;if(r&&i){if(e.preventDefault(),a.$el.find("img.fr-error").left)return!1;var o=e.pageX||(e.originalEvent.touches?e.originalEvent.touches[0].pageX:null);if(!o)return!1;var s=o-r.data("start-x"),l=r.data("start-width");if((r.hasClass("fr-hnw")||r.hasClass("fr-hsw"))&&(s=0-s),a.opts.imageResizeWithPercent){var g=i.parentsUntil(a.$el,a.html.blockTagsQuery()).get(0)||a.el;l=((l+s)/p(g).outerWidth()*100).toFixed(2),a.opts.imageRoundPercent&&(l=Math.round(l)),T("".concat(l,"%")),(t=Ee()?(a.helpers.getPX(i.parents(".fr-img-caption").css("width"))/p(g).outerWidth()*100).toFixed(2):(a.helpers.getPX(i.css("width"))/p(g).outerWidth()*100).toFixed(2))===l||a.opts.imageRoundPercent||T("".concat(t,"%")),i.css("height","").removeAttr("height")}else l+s>=a.opts.imageMinWidth&&(T(l+s),t=Ee()?a.helpers.getPX(i.parents(".fr-img-caption").css("width")):a.helpers.getPX(i.css("width"))),t!==l+s&&T(t),((i.attr("style")||"").match(/(^height:)|(; *height:)/)||i.attr("height"))&&(i.css("height",r.data("start-height")*i.width()/r.data("start-width")),i.removeAttr("height"));x(),a.events.trigger("image.resize",[Ce()])}}function P(e){if(!a.core.sameInstance(n))return!0;if(r&&i){if(e&&e.stopPropagation(),a.$el.find("img.fr-error").left)return!1;r=null,o.hide(),x(),A(),a.undo.saveStep(),a.events.trigger("image.resizeEnd",[Ce()])}else n.removeClass("fr-active")}function k(e,t,n){a.edit.on(),i&&i.addClass("fr-error"),b[e]?L(a.language.translate(b[e])):L(a.language.translate("Something went wrong. Please try again.")),!i&&n&&ne(n),a.events.trigger("image.error",[{code:e,message:b[e]},t,n])}function N(e){if(e)return a.$wp&&a.events.$on(a.$wp,"scroll.image-edit",function(){i&&a.popups.isVisible("image.edit")&&(a.events.disableBlur(),A())}),!0;var t="";if(a.opts.imageEditButtons.length>0){var n={buttons:t+='<div class="fr-buttons">\n        '.concat(a.button.buildList(a.opts.imageEditButtons),"\n        </div>")};return a.popups.create("image.edit",n)}return!1}function B(e){var t=a.popups.get("image.insert");if(t||(t=j()),t.find(".fr-layer.fr-active").removeClass("fr-active").addClass("fr-pactive"),t.find(".fr-image-progress-bar-layer").addClass("fr-active"),t.find(".fr-buttons").hide(),i){var n=Se();a.popups.setContainer("image.insert",a.$sc);var r=n.offset().left,o=n.offset().top+n.height();a.popups.show("image.insert",r,o,n.outerHeight())}void 0===e&&O(a.language.translate("Uploading"),0)}function z(e){var t=a.popups.get("image.insert");if(t&&(t.find(".fr-layer.fr-pactive").addClass("fr-active").removeClass("fr-pactive"),t.find(".fr-image-progress-bar-layer").removeClass("fr-active"),t.find(".fr-buttons").show(),e||a.$el.find("img.fr-error").length)){if(a.events.focus(),a.$el.find("img.fr-error").length&&(a.$el.find("img.fr-error").remove(),a.undo.saveStep(),a.undo.run(),a.undo.dropRedo()),!a.$wp&&i){var n=i;de(!0),a.selection.setAfter(n.get(0)),a.selection.restore()}a.popups.hide("image.insert")}}function O(e,t){var i=a.popups.get("image.insert");if(i){var n=i.find(".fr-image-progress-bar-layer");n.find("h3").text(e+(t?" ".concat(t,"%"):"")),n.removeClass("fr-error"),t?(n.find("div").removeClass("fr-indeterminate"),n.find("div > span").css("width","".concat(t,"%"))):n.find("div").addClass("fr-indeterminate")}}function L(e){B();var t=a.popups.get("image.insert").find(".fr-image-progress-bar-layer");t.addClass("fr-error");var i=t.find("h3");i.text(e),a.events.disableBlur(),i.focus()}function _(e){ce.call(e.get(0))}function M(){var e=p(this);a.popups.hide("image.insert"),e.removeClass("fr-uploading"),e.next().is("br")&&e.next().remove(),_(e),a.events.trigger("image.loaded",[e])}function K(e,t,i,n,r){n&&"string"==typeof n&&(n=a.$(n)),a.edit.off(),O(a.language.translate("Loading image")),t&&(e=a.helpers.sanitizeURL(e));var o=new Image;o.onload=function(){var t,o;if(n){a.undo.canDo()||n.hasClass("fr-uploading")||a.undo.saveStep();var s=n.data("fr-old-src");n.data("fr-image-pasted")&&(s=null),a.$wp?((t=n.clone().removeData("fr-old-src").removeClass("fr-uploading").removeAttr("data-fr-image-pasted")).off("load"),s&&n.attr("src",s),!a.opts.trackChangesEnabled||n[0].parentNode&&"SPAN"===n[0].parentNode.tagName&&n[0].parentNode.hasAttribute("data-tracking")||a.track_changes.replaceSpecialItem(n),n.replaceWith(t)):t=n;for(var l=t.get(0).attributes,p=0;p<l.length;p++){var g=l[p];0===g.nodeName.indexOf("data-")?t.removeAttr(g.nodeName):i&&i.hasOwnProperty(g.nodeName)&&t.removeAttr(g.nodeName)}if(void 0!==i)for(o in i)i.hasOwnProperty(o)&&"link"!=o&&t.attr("".concat(o),i[o]);t.on("load",M),t.attr("src",e),a.edit.on(),U(!1),n[0].src!=e&&a.selection.restore(),a.undo.saveStep(),a.events.disableBlur(),a.$el.blur(),a.events.trigger(s?"image.replaced":"image.inserted",[t,r])}else(t=G(e,i,M))&&(U(!1),a.undo.saveStep(),a.events.disableBlur(),a.$el.blur(),a.events.trigger("image.inserted",[t,r]))},o.onerror=function(){k(c)},B(a.language.translate("Loading image")),o.src=e}function Y(e,t,i){O(a.language.translate("Loading image"));var n=this.status,r=this.response,o=this.responseXML,s=this.responseText;try{if(a.opts.imageUploadToS3||a.opts.imageUploadToAzure)if(201==n){var l;if(a.opts.imageUploadToAzure){if(!1===a.events.trigger("image.uploadedToAzure",[this.responseURL,i,r],!0))return a.edit.on(),!1;l=t}else l=function(e){try{var t=p(e).find("Location").text(),i=p(e).find("Key").text();return!1===a.events.trigger("image.uploadedToS3",[t,i,e],!0)?(a.edit.on(),!1):t}catch(t){return k(m,e),!1}}(o);l&&K(l,!1,[],e,r||o)}else k(m,r||o,e);else if(n>=200&&n<300){var g=function(e){try{if(!1===a.events.trigger("image.uploaded",[e],!0))return a.edit.on(),!1;var t=JSON.parse(e);return t.link?t:(k(d,e),!1)}catch(t){return k(m,e),!1}}(s);g&&K(g.link,!1,g,e,r||s)}else k(u,r||s,e)}catch(t){k(m,r||s,e)}}function H(){k(m,this.response||this.responseText||this.responseXML)}function W(e){if(e.lengthComputable){var t=e.loaded/e.total*100|0;O(a.language.translate("Uploading"),t)}}function G(e,t,i){var n,r=p(document.createElement("img")).attr("src",e);if(t&&void 0!==t)for(n in t)t.hasOwnProperty(n)&&"link"!=n&&(" data-".concat(n,'="').concat(t[n],'"'),r.attr("".concat(n),t[n]));var o=a.opts.imageDefaultWidth;o&&"auto"!=o&&(o=a.opts.imageResizeWithPercent?"100%":"".concat(o,"px")),r.attr("style",o?"width: ".concat(o,";"):""),ve(r,a.opts.imageDefaultDisplay,a.opts.imageDefaultAlign),r.on("load",i),r.on("error",i),a.edit.on(),a.events.focus(!0),a.selection.restore(),a.undo.saveStep(),a.opts.imageSplitHTML?a.markers.split():a.markers.insert(),a.html.wrap();var s=a.$el.find(".fr-marker");if(s.length)(s.parent().is("hr")||s.parent().is("IMG"))&&s.parent().after(s),a.node.isLastSibling(s)&&s.parent().hasClass("fr-deletable")&&s.insertAfter(s.parent()),s.replaceWith(r);else{if(a.opts.trackChangesEnabled)return z(!0),!1;a.$el.append(r)}return a.selection.clear(),r}function V(){a.edit.on(),z(!0)}function X(e,t){if(void 0!==e&&e.length>0){if(!1===a.events.trigger("image.beforeUpload",[e,t]))return!1;var n,r=e[0];if(!(null!==a.opts.imageUploadURL&&a.opts.imageUploadURL!=g||a.opts.imageUploadToS3||a.opts.imageUploadToAzure))return function(e,t){var i=new FileReader;i.onload=function(){var n=i.result;if(i.result.indexOf("svg+xml")<0){for(var r=atob(i.result.split(",")[1]),o=[],s=0;s<r.length;s++)o.push(r.charCodeAt(s));n=window.URL.createObjectURL(new Blob([new Uint8Array(o)],{type:e.type})),t&&t.data("fr-old-src",t.attr("src")),a.image.insert(n,!1,null,t)}else a.image.insert(n,null,null,a.image.get())},B(),i.readAsDataURL(e)}(r,t||i),!1;if(r.name||(r.name=(new Date).getTime()+"."+(r.type||"image/jpeg").replace(/image\//g,"")),r.size>a.opts.imageMaxSize)return k(h),!1;if(a.opts.imageAllowedTypes.indexOf(r.type.replace(/image\//g,""))<0)return k(v),!1;if(a.drag_support.formdata&&(n=a.drag_support.formdata?new FormData:null),n){var o;if(!1!==a.opts.imageUploadToS3)for(o in n.append("key",a.opts.imageUploadToS3.keyStart+(new Date).getTime()+"-"+(r.name||"untitled")),n.append("success_action_status","201"),n.append("X-Requested-With","xhr"),n.append("Content-Type",r.type),a.opts.imageUploadToS3.params)a.opts.imageUploadToS3.params.hasOwnProperty(o)&&n.append(o,a.opts.imageUploadToS3.params[o]);for(o in a.opts.imageUploadParams)a.opts.imageUploadParams.hasOwnProperty(o)&&n.append(o,a.opts.imageUploadParams[o]);n.append(a.opts.imageUploadParam,r,r.name);var s,l,f=a.opts.imageUploadURL,c=a.opts.imageUploadMethod;a.opts.imageUploadToS3&&(f=a.opts.imageUploadToS3.uploadURL?a.opts.imageUploadToS3.uploadURL:"https://".concat(a.opts.imageUploadToS3.region,".amazonaws.com/").concat(a.opts.imageUploadToS3.bucket)),a.opts.imageUploadToAzure&&(s=f=a.opts.imageUploadToAzure.uploadURL?"".concat(a.opts.imageUploadToAzure.uploadURL,"/").concat(r.name):encodeURI("https://".concat(a.opts.imageUploadToAzure.account,".blob.core.windows.net/").concat(a.opts.imageUploadToAzure.container,"/").concat(r.name)),a.opts.imageUploadToAzure.SASToken&&(f+=a.opts.imageUploadToAzure.SASToken),c="PUT");var d=a.core.getXHR(f,c);if(a.opts.imageUploadToAzure){var u=(new Date).toUTCString();if(!a.opts.imageUploadToAzure.SASToken&&a.opts.imageUploadToAzure.accessKey){var m=a.opts.imageUploadToAzure.account,b=a.opts.imageUploadToAzure.container;if(a.opts.imageUploadToAzure.uploadURL){var y=a.opts.imageUploadToAzure.uploadURL.split("/");b=y.pop(),m=y.pop().split(".")[0]}var w="x-ms-blob-type:BlockBlob\nx-ms-date:".concat(u,"\nx-ms-version:2019-07-07"),A=encodeURI("/"+m+"/"+b+"/"+r.name),C=c+"\n\n\n"+r.size+"\n\n"+r.type+"\n\n\n\n\n\n\n"+w+"\n"+A,S=a.cryptoJSPlugin.cryptoJS.HmacSHA256(C,a.cryptoJSPlugin.cryptoJS.enc.Base64.parse(a.opts.imageUploadToAzure.accessKey)).toString(a.cryptoJSPlugin.cryptoJS.enc.Base64),E="SharedKey "+m+":"+S;l=S,d.setRequestHeader("Authorization",E)}for(o in d.setRequestHeader("x-ms-version","2019-07-07"),d.setRequestHeader("x-ms-date",u),d.setRequestHeader("Content-Type",r.type),d.setRequestHeader("x-ms-blob-type","BlockBlob"),a.opts.imageUploadParams)a.opts.imageUploadParams.hasOwnProperty(o)&&d.setRequestHeader(o,a.opts.imageUploadParams[o]);for(o in a.opts.imageUploadToAzure.params)a.opts.imageUploadToAzure.params.hasOwnProperty(o)&&d.setRequestHeader(o,a.opts.imageUploadToAzure.params[o])}!function(e,t,i,n,r,o){function s(){var s=p(this);s.off("load"),s.addClass("fr-uploading"),s.next().is("br")&&s.next().remove(),a.placeholder.refresh(),_(s),x(),B(),a.edit.off(),e.onload=function(){Y.call(e,s,r,o)},e.onerror=H,e.upload.onprogress=W,e.onabort=V,p(s.off("abortUpload")).on("abortUpload",function(){4!=e.readyState&&(e.abort(),n?(n.attr("src",n.data("fr-old-src")),n.removeClass("fr-uploading")):s.remove(),de(!0))}),e.send(a.opts.imageUploadToAzure?i:t)}var l=new FileReader;l.onload=function(){var e=l.result;if(l.result.indexOf("svg+xml")<0){for(var t=atob(l.result.split(",")[1]),i=[],r=0;r<t.length;r++)i.push(t.charCodeAt(r));e=window.URL.createObjectURL(new Blob([new Uint8Array(i)],{type:"image/jpeg"}))}n?(n.on("load",s),n.on("error",function(){s(),p(this).off("error")}),a.edit.on(),a.undo.saveStep(),n.data("fr-old-src",n.attr("src")),n.attr("src",e)):G(e,null,s)},l.readAsDataURL(i)}(d,n,r,t||i,s,l)}}}function F(e){if(e.is("img")&&e.parents(".fr-img-caption").length>0)return e.parents(".fr-img-caption")}function q(t){var i=t.originalEvent.dataTransfer;if(i&&i.files&&i.files.length){var n=i.files[0];if(n&&n.type&&-1!==n.type.indexOf("image")&&a.opts.imageAllowedTypes.indexOf(n.type.replace(/image\//g,""))>=0){if(!a.opts.imageUpload)return t.preventDefault(),t.stopPropagation(),!1;a.markers.remove(),a.markers.insertAtPoint(t.originalEvent),a.$el.find(".fr-marker").replaceWith(e.MARKERS),0===a.$el.find(".fr-marker").length&&a.selection.setAtEnd(a.el),a.popups.hideAll();var r=a.popups.get("image.insert");r||(r=j()),a.popups.setContainer("image.insert",a.$sc);var o=t.originalEvent.pageX,s=t.originalEvent.pageY;if(a.opts.iframe){var l=a.helpers.getPX(a.$wp.find(".fr-iframe").css("padding-top")),p=a.helpers.getPX(a.$wp.find(".fr-iframe").css("padding-left"));s+=a.$iframe.offset().top+l,o+=a.$iframe.offset().left+p}return a.popups.show("image.insert",o,s),B(),a.opts.imageAllowedTypes.indexOf(n.type.replace(/image\//g,""))>=0?(de(!0),X(i.files)):k(v),t.preventDefault(),t.stopPropagation(),!1}}}function j(e){if(e)return a.popups.onRefresh("image.insert",y),a.popups.onHide("image.insert",C),!0;var t,n,r="";a.opts.imageUpload||-1===a.opts.imageInsertButtons.indexOf("imageUpload")||a.opts.imageInsertButtons.splice(a.opts.imageInsertButtons.indexOf("imageUpload"),1);var o=a.button.buildList(a.opts.imageInsertButtons);""!==o&&(r='<div class="fr-buttons fr-tabs">'.concat(o,"</div>"));var s=a.opts.imageInsertButtons.indexOf("imageUpload"),l=a.opts.imageInsertButtons.indexOf("imageByURL"),g="";s>=0&&(t=" fr-active",l>=0&&s>l&&(t=""),g='<div class="fr-image-upload-layer'.concat(t,' fr-layer" id="fr-image-upload-layer-').concat(a.id,'"><strong>').concat(a.language.translate("Drop image"),"</strong><br>(").concat(a.language.translate("or click"),')<div class="fr-form"><input type="file" accept="image/').concat(a.opts.imageAllowedTypes.join(", image/").toLowerCase(),'" tabIndex="-1" aria-labelledby="fr-image-upload-layer-').concat(a.id,'" role="button"></div></div>'));var f="";l>=0&&(t=" fr-active",s>=0&&l>s&&(t=""),f='<div class="fr-image-by-url-layer'.concat(t,' fr-layer" id="fr-image-by-url-layer-').concat(a.id,'"><div class="fr-input-line"><input id="fr-image-by-url-layer-text-').concat(a.id,'" type="text" placeholder="http://" tabIndex="1" aria-required="true"></div><div class="fr-action-buttons"><button type="button" class="fr-command fr-submit" data-cmd="imageInsertByURL" tabIndex="2" role="button">').concat(a.language.translate("Insert"),"</button></div></div>"));var c={buttons:r,upload_layer:g,by_url_layer:f,progress_bar:'<div class="fr-image-progress-bar-layer fr-layer"><h3 tabIndex="-1" class="fr-message">Uploading</h3><div class="fr-loader"><span class="fr-progress"></span></div><div class="fr-action-buttons"><button type="button" class="fr-command fr-dismiss" data-cmd="imageDismissError" tabIndex="2" role="button">OK</button></div></div>'};return a.opts.imageInsertButtons.length>=1&&(n=a.popups.create("image.insert",c)),a.$wp&&a.events.$on(a.$wp,"scroll",function(){i&&a.popups.isVisible("image.insert")&&we()}),function(e){a.events.$on(e,"dragover dragenter",".fr-image-upload-layer",function(e){return p(this).addClass("fr-drop"),(a.browser.msie||a.browser.edge)&&e.preventDefault(),!1},!0),a.events.$on(e,"dragleave dragend",".fr-image-upload-layer",function(e){return p(this).removeClass("fr-drop"),(a.browser.msie||a.browser.edge)&&e.preventDefault(),!1},!0),a.events.$on(e,"drop",".fr-image-upload-layer",function(t){t.preventDefault(),t.stopPropagation(),p(this).removeClass("fr-drop");var i=t.originalEvent.dataTransfer;if(i&&i.files){var n=e.data("instance")||a;n.events.disableBlur(),n.image.upload(i.files),n.events.enableBlur()}},!0),a.helpers.isIOS()&&a.events.$on(e,"touchstart",'.fr-image-upload-layer input[type="file"]',function(){p(this).trigger("click")},!0),a.events.$on(e,"change",'.fr-image-upload-layer input[type="file"]',function(){if(this.files){var t=e.data("instance")||a;t.events.disableBlur(),e.find("input:focus").blur(),t.events.enableBlur(),t.image.upload(this.files,i)}p(this).val("")},!0)}(n),n}function J(){i&&a.popups.get("image.alt").find("input").val(i.attr("alt")||"").trigger("change")}function Q(){var e=a.popups.get("image.alt");e||(e=Z()),z(),a.popups.refresh("image.alt"),a.popups.setContainer("image.alt",a.$sc);var t=Se();Ee()&&(t=t.find(".fr-img-wrap"));var i=t.offset().left+t.outerWidth()/2,n=t.offset().top+t.outerHeight();a.popups.show("image.alt",i,n,t.outerHeight(),!0)}function Z(e){if(e)return a.popups.onRefresh("image.alt",J),!0;var t={buttons:'<div class="fr-buttons fr-tabs">'.concat(a.button.buildList(a.opts.imageAltButtons),"</div>"),alt_layer:'<div class="fr-image-alt-layer fr-layer fr-active" id="fr-image-alt-layer-'.concat(a.id,'"><div class="fr-input-line"><input id="fr-image-alt-layer-text-').concat(a.id,'" type="text" placeholder="').concat(a.language.translate("Alternative Text"),'" tabIndex="1"></div><div class="fr-action-buttons"><button type="button" class="fr-command fr-submit" data-cmd="imageSetAlt" tabIndex="2" role="button">').concat(a.language.translate("Update"),"</button></div></div>")},n=a.popups.create("image.alt",t);return a.$wp&&a.events.$on(a.$wp,"scroll.image-alt",function(){i&&a.popups.isVisible("image.alt")&&Q()}),n}function ee(){var e=a.popups.get("image.size"),t=i.get(0).style.height?i.get(0).style.height:"auto",n=i.get(0).style.width?i.get(0).style.width:"auto";if(i)if(Ee()){var r=i.parent();r.get(0).style.width||(r=i.parent().parent()),e.find('input[name="width"]').val(n).trigger("change"),e.find('input[name="height"]').val(t).trigger("change")}else e.find('input[name="width"]').val(n).trigger("change"),e.find('input[name="height"]').val(t).trigger("change")}function te(){var e=a.popups.get("image.size");e||(e=ae()),z(),a.popups.refresh("image.size"),a.popups.setContainer("image.size",a.$sc);var t=Se();Ee()&&(t=t.find(".fr-img-wrap"));var i=t.offset().left+t.outerWidth()/2,n=t.offset().top+t.outerHeight();a.popups.show("image.size",i,n,t.outerHeight(),!0)}function ae(e){if(e)return a.popups.onRefresh("image.size",ee),!0;var t={buttons:'<div class="fr-buttons fr-tabs">'.concat(a.button.buildList(a.opts.imageSizeButtons),"</div>"),size_layer:'<div class="fr-image-size-layer fr-layer fr-active" id="fr-image-size-layer-'.concat(a.id,'"><div class="fr-image-group"><div class="fr-input-line"><input id="fr-image-size-layer-width-\'').concat(a.id,'" type="text" name="width" placeholder="').concat(a.language.translate("Width"),'" tabIndex="1"></div><div class="fr-input-line"><input id="fr-image-size-layer-height').concat(a.id,'" type="text" name="height" placeholder="').concat(a.language.translate("Height"),'" tabIndex="1"></div></div><div class="fr-action-buttons"><button type="button" class="fr-command fr-submit" data-cmd="imageSetSize" tabIndex="2" role="button">').concat(a.language.translate("Update"),"</button></div></div>")},n=a.popups.create("image.size",t);return a.$wp&&a.events.$on(a.$wp,"scroll.image-size",function(){i&&a.popups.isVisible("image.size")&&te()}),n}function ie(e,t,a,i){return e.pageX=t,$.call(this,e),e.pageX=e.pageX+a*Math.floor(Math.pow(1.1,i)),I.call(this,e),P.call(this,e),++i}function ne(t){if(t=t||Se(),a.opts.trackChangesEnabled&&!a.helpers.isMobile()&&(!t[0].parentNode||"SPAN"!==t[0].parentNode.tagName||!t[0].parentNode.hasAttribute("data-tracking")))return a.track_changes.removeSpecialItem(t),a.popups.hideAll(),void de(!0);t&&!1!==a.events.trigger("image.beforeRemove",[t])&&(a.popups.hideAll(),Ae(),de(!0),a.undo.canDo()||a.undo.saveStep(),t.get(0)==a.el?t.removeAttr("src"):(t.get(0).parentNode&&"A"==t.get(0).parentNode.tagName?(a.selection.setBefore(t.get(0).parentNode)||a.selection.setAfter(t.get(0).parentNode)||t.parent().after(e.MARKERS),p(t.get(0).parentNode).remove()):(a.selection.setBefore(t.get(0))||a.selection.setAfter(t.get(0))||t.after(e.MARKERS),t.remove()),a.html.fillEmptyBlocks(),a.selection.restore()),a.undo.saveStep())}function re(t){var n=t.which;if(i&&(n==e.KEYCODE.BACKSPACE||n==e.KEYCODE.DELETE))return t.preventDefault(),t.stopPropagation(),ne(),!1;if(i&&n==e.KEYCODE.ESC){var r=i;return de(!0),a.selection.setAfter(r.get(0)),a.selection.restore(),t.preventDefault(),!1}if(i&&(n==e.KEYCODE.ARROW_LEFT||n==e.KEYCODE.ARROW_RIGHT)){var o=i.get(0);return de(!0),n==e.KEYCODE.ARROW_LEFT?a.selection.setBefore(o):a.selection.setAfter(o),a.selection.restore(),t.preventDefault(),!1}return i&&n===e.KEYCODE.TAB?(t.preventDefault(),t.stopPropagation(),de(!0),!1):i&&n!=e.KEYCODE.F10&&!a.keys.isBrowserAction(t)?(t.preventDefault(),t.stopPropagation(),!1):void 0}function oe(e){if(e&&"IMG"==e.tagName){if(a.node.hasClass(e,"fr-uploading")||a.node.hasClass(e,"fr-error")?e.parentNode.removeChild(e):a.node.hasClass(e,"fr-draggable")&&e.classList.remove("fr-draggable"),e.parentNode&&e.parentNode.parentNode&&a.node.hasClass(e.parentNode.parentNode,"fr-img-caption")){var t=e.parentNode.parentNode;t.removeAttribute("contenteditable"),t.removeAttribute("draggable"),t.classList.remove("fr-draggable");var i=e.nextSibling;i&&i.removeAttribute("contenteditable")}}else if(e&&e.nodeType==Node.ELEMENT_NODE)for(var n=e.querySelectorAll("img.fr-uploading, img.fr-error, img.fr-draggable"),r=0;r<n.length;r++)oe(n[r])}function se(e){if(!1===a.events.trigger("image.beforePasteUpload",[e]))return p(e).removeAttr("data-fr-image-pasted"),!1;i=p(e),x(),A(),we(),B(),i.on("load",function(){var e=[];x(),p(a.popups.get("image.insert").get(0)).find("div.fr-active.fr-error").length<1&&B(),p(this).data("events").filter(function(t){"load"===t[0]&&e.push(t)}),e.length<=1&&p(this).off("load")});for(var t=p(e).attr("src").split(","),n=atob(t[1]),r=[],o=0;o<n.length;o++)r.push(n.charCodeAt(o));X([a.browser.safari&&!a.opts.imageUploadURL?new Blob([new Uint8Array(r)],{type:t[0].replace(/data\:/g,"")}):new Blob([new Uint8Array(r)],{type:t[0].replace(/data\:/g,"").replace(/;base64/g,"")})],i)}function le(){a.opts.imagePaste?a.$el.find("img[data-fr-image-pasted]").each(function(e,t){if(a.opts.imagePasteProcess){var i=a.opts.imageDefaultWidth;i&&"auto"!=i&&(i+=a.opts.imageResizeWithPercent?"%":"px"),p(t).css("width",i).removeClass("fr-dii fr-dib fr-fir fr-fil"),ve(p(t),a.opts.imageDefaultDisplay,a.opts.imageDefaultAlign)}if(0===t.src.indexOf("data:"))se(t);else if(0===t.src.indexOf("blob:")||0===t.src.indexOf("http")&&a.opts.imageUploadRemoteUrls&&a.opts.imageCORSProxy){var n=new Image;n.crossOrigin="Anonymous",n.onload=function(){var e,i=a.o_doc.createElement("CANVAS"),n=i.getContext("2d");i.height=this.naturalHeight,i.width=this.naturalWidth,n.drawImage(this,0,0),setTimeout(function(){se(t)},0),e=this.naturalWidth>2e3||this.naturalHeight>1500?"jpeg":"png",t.src=i.toDataURL("image/".concat(e))},n.src=(0===t.src.indexOf("blob:")?"":"".concat(a.opts.imageCORSProxy,"/"))+t.src,0!==t.src.indexOf("blob:")&&a.undo.saveStep()}else 0!==t.src.indexOf("http")||0===t.src.indexOf("https://mail.google.com/mail")?(a.selection.save(),p(t).remove(),a.selection.restore()):p(t).removeAttr("data-fr-image-pasted")}):a.$el.find("img[data-fr-image-pasted]").remove()}function pe(e){var t=e.target.result,i=a.opts.imageDefaultWidth;i&&"auto"!=i&&(i+=a.opts.imageResizeWithPercent?"%":"px"),a.undo.saveStep(),a.html.insert('<img data-fr-image-pasted="true" src="'.concat(t,'"').concat(i?' style="width: '.concat(i,';"'):"",">"));var n=a.$el.find('img[data-fr-image-pasted="true"]');n&&ve(n,a.opts.imageDefaultDisplay,a.opts.imageDefaultAlign),a.events.trigger("paste.after")}function ge(e){if(e&&e.clipboardData&&e.clipboardData.items){var t=null;if(e.clipboardData.types&&-1!=[].indexOf.call(e.clipboardData.types,"text/rtf")||e.clipboardData.getData("text/rtf"))t=e.clipboardData.items[0].getAsFile();else for(var a=0;a<e.clipboardData.items.length&&!(t=e.clipboardData.items[a].getAsFile());a++);if(t)return function(e){var t=new FileReader;t.onload=pe,t.readAsDataURL(e)}(t),!1}}function fe(e){return e=e.replace(/<img /gi,'<img data-fr-image-pasted="true" ')}function ce(t){if("false"==p(this).parents("[contenteditable]").not(".fr-element").not(".fr-img-caption").not("body").first().attr("contenteditable"))return!0;if(t&&"touchend"==t.type&&l)return!0;if(t&&a.edit.isDisabled())return t.stopPropagation(),t.preventDefault(),!1;for(var n=0;n<e.INSTANCES.length;n++)e.INSTANCES[n]!=a&&e.INSTANCES[n].events.trigger("image.hideResizer");a.toolbar.disable(),t&&(t.stopPropagation(),t.preventDefault()),a.helpers.isMobile()&&(a.events.disableBlur(),a.$el.blur(),a.events.enableBlur()),a.opts.iframe&&a.size.syncIframe(),i=p(this),Ae(),x(),A(),a.browser.msie?(a.popups.areVisible()&&a.events.disableBlur(),a.win.getSelection&&(a.win.getSelection().removeAllRanges(),a.win.getSelection().addRange(a.doc.createRange()))):a.selection.clear(),a.helpers.isIOS()&&(a.events.disableBlur(),a.$el.blur()),a.button.bulkRefresh(),a.events.trigger("video.hideResizer")}function de(e){i&&(ue||!0===e)&&(a.toolbar.enable(),n.removeClass("fr-active"),a.popups.hideAll(),i=null,he(),r=null,o&&o.hide())}b[c]="Image cannot be loaded from the passed link.",b[d]="No link in upload response.",b[u]="Error during file upload.",b[m]="Parsing response failed.",b[h]="File is too large.",b[v]="Image file type is invalid.",b[7]="Files can be uploaded only to same domain in IE 8 and IE 9.",b[8]="Image file is corrupted.";var ue=!1;function me(){ue=!0}function he(){ue=!1}function ve(e,t,i){!a.opts.htmlUntouched&&a.opts.useClasses?(e.removeClass("fr-fil fr-fir fr-dib fr-dii"),i&&e.addClass("fr-fi".concat(i[0])),t&&e.addClass("fr-di".concat(t[0]))):"inline"==t?(e.css({display:"inline-block",verticalAlign:"bottom",margin:a.opts.imageDefaultMargin}),"center"==i?e.css({float:"none",marginBottom:"",marginTop:"",maxWidth:"calc(100% - ".concat(2*a.opts.imageDefaultMargin,"px)"),textAlign:"center"}):"left"==i?e.css({float:"left",marginLeft:0,maxWidth:"calc(100% - ".concat(a.opts.imageDefaultMargin,"px)"),textAlign:"left"}):e.css({float:"right",marginRight:0,maxWidth:"calc(100% - ".concat(a.opts.imageDefaultMargin,"px)"),textAlign:"right"})):"block"==t&&(e.css({display:"block",float:"none",verticalAlign:"top",margin:"".concat(a.opts.imageDefaultMargin,"px auto"),textAlign:"center"}),"left"==i?e.css({marginLeft:0,textAlign:"left"}):"right"==i&&e.css({marginRight:0,textAlign:"right"}))}function be(e){if(void 0===e&&(e=Se()),e){if(e.hasClass("fr-fil"))return"left";if(e.hasClass("fr-fir"))return"right";if(e.hasClass("fr-dib")||e.hasClass("fr-dii"))return"center";var t=e.css("float");if(e.css("float","none"),"block"==e.css("display")){if(e.css("float",""),e.css("float")!=t&&e.css("float",t),0===parseInt(e.css("margin-left"),10))return"left";if(0===parseInt(e.css("margin-right"),10))return"right"}else{if(e.css("float",""),e.css("float")!=t&&e.css("float",t),"left"==e.css("float"))return"left";if("right"==e.css("float"))return"right"}}return"center"}function ye(e){void 0===e&&(e=Se());var t=e.css("float");return e.css("float","none"),"block"==e.css("display")?(e.css("float",""),e.css("float")!=t&&e.css("float",t),"block"):(e.css("float",""),e.css("float")!=t&&e.css("float",t),"inline")}function we(){var e=a.popups.get("image.insert");e||(e=j()),a.popups.isVisible("image.insert")||(z(),a.popups.refresh("image.insert"),a.popups.setContainer("image.insert",a.$sc));var t=Se();Ee()&&(t=t.find(".fr-img-wrap"));var i=t.offset().left+t.outerWidth()/2,n=t.offset().top+t.outerHeight();a.popups.show("image.insert",i,n,t.outerHeight(!0),!0)}function Ae(){if(i){a.events.disableBlur(),a.selection.clear();var e=a.doc.createRange();e.selectNode(i.get(0)),a.browser.msie&&e.collapse(!0),a.selection.get().addRange(e),a.events.enableBlur()}}function Ce(){return i}function Se(){return Ee()?i.parents(".fr-img-caption").first():i}function Ee(){return!!i&&i.parents(".fr-img-caption").length>0}function Re(e){for(var t=document.createDocumentFragment();e.firstChild;){var a=e.removeChild(e.firstChild);t.appendChild(a)}e.parentNode.replaceChild(t,e)}return{_init:function(){var t;a.events.$on(a.$el,a._mousedown,"IMG"==a.el.tagName?null:'img:not([contenteditable="false"])',function(e){if("false"==p(this).parents("contenteditable").not(".fr-element").not(".fr-img-caption").not("body").first().attr("contenteditable"))return!0;a.helpers.isMobile()||a.selection.clear(),f=!0,a.popups.areVisible()&&a.events.disableBlur(),a.browser.msie&&(a.events.disableBlur(),a.$el.attr("contenteditable",!1)),a.draggable||"touchstart"==e.type||e.preventDefault(),e.stopPropagation()}),a.events.$on(a.$el,a._mousedown,".fr-img-caption .fr-inner",function(e){a.core.hasFocus()||a.events.focus(),e.stopPropagation()}),a.events.$on(a.$el,"paste",".fr-img-caption .fr-inner",function(e){!0===a.opts.toolbarInline&&(a.toolbar.hide(),e.stopPropagation())}),a.events.$on(a.$el,a._mouseup,"IMG"==a.el.tagName?null:'img:not([contenteditable="false"])',function(e){if("false"==p(this).parents("contenteditable").not(".fr-element").not(".fr-img-caption").not("body").first().attr("contenteditable"))return!0;f&&(f=!1,e.stopPropagation(),a.browser.msie&&(a.$el.attr("contenteditable",!0),a.events.enableBlur()))}),a.events.on("keyup",function(e){if(e.shiftKey&&""===a.selection.text().replace(/\n/g,"")&&a.keys.isArrow(e.which)){var t=a.selection.element(),i=a.selection.endElement();t&&"IMG"==t.tagName?_(p(t)):i&&"IMG"==i.tagName&&_(p(i))}},!0),a.events.on("drop",q),a.events.on("element.beforeDrop",F),a.events.on("mousedown window.mousedown",me),a.events.on("window.touchmove",he),a.events.on("mouseup window.mouseup",function(){if(i&&!a.helpers.isMobile())return de(),!1;he()}),a.events.on("commands.mousedown",function(e){e.parents(".fr-toolbar").length>0&&de()}),a.events.on("image.resizeEnd",function(){a.opts.iframe&&a.size.syncIframe()}),a.events.on("blur image.hideResizer commands.undo commands.redo element.dropped",function(){f=!1,de(!0)}),a.events.on("modals.hide",function(){i&&(Ae(),a.selection.clear())}),a.events.on("image.resizeEnd",function(){a.win.getSelection&&_(i)}),a.opts.imageAddNewLine&&a.events.on("image.inserted",function(t){var i=t.get(0);for(i.nextSibling&&"BR"===i.nextSibling.tagName&&(i=i.nextSibling);i&&!a.node.isElement(i);)i=a.node.isLastSibling(i)?i.parentNode:null;a.node.isElement(i)&&(a.opts.enter===e.ENTER_BR?t.after("<br>"):p(a.node.blockParent(t.get(0))).after("<".concat(a.html.defaultTag(),"><br></").concat(a.html.defaultTag(),">")))}),"IMG"==a.el.tagName&&a.$el.addClass("fr-view"),a.events.$on(a.$el,a.helpers.isMobile()&&!a.helpers.isWindowsPhone()?"touchend":"click","IMG"==a.el.tagName?null:'img:not([contenteditable="false"])',ce),a.helpers.isMobile()&&(a.events.$on(a.$el,"touchstart","IMG"==a.el.tagName?null:'img:not([contenteditable="false"])',function(){l=!1}),a.events.$on(a.$el,"touchmove",function(){l=!0})),a.$wp?(a.events.on("window.keydown keydown",re,!0),a.events.on("keyup",function(t){if(i&&t.which==e.KEYCODE.ENTER)return!1},!0),a.events.$on(a.$el,"keydown",function(){var t=a.selection.element();(t.nodeType===Node.TEXT_NODE||"BR"==t.tagName&&a.node.isLastSibling(t))&&(t=t.parentNode),a.node.hasClass(t,"fr-inner")||(a.node.hasClass(t,"fr-img-caption")||(t=p(t).parents(".fr-img-caption").get(0)),a.node.hasClass(t,"fr-img-caption")&&(a.opts.trackChangesEnabled||p(t).after(e.INVISIBLE_SPACE+e.MARKERS),a.selection.restore()))})):a.events.$on(a.$win,"keydown",re),a.events.on("toolbar.esc",function(){if(i){if(a.$wp)a.events.disableBlur(),a.events.focus();else{var e=i;de(!0),a.selection.setAfter(e.get(0)),a.selection.restore()}return!1}},!0),a.events.on("toolbar.focusEditor",function(){if(i)return!1},!0),a.events.on("window.cut window.copy",function(t){if(i&&a.popups.isVisible("image.edit")&&!a.popups.get("image.edit").find(":focus").length){var n=Se();Ee()?(n.before(e.START_MARKER),n.after(e.END_MARKER),a.selection.restore(),a.paste.saveCopiedText(n.get(0).outerHTML,n.text())):(Ae(),a.paste.saveCopiedText(i.get(0).outerHTML,i.attr("alt"))),"copy"==t.type?setTimeout(function(){_(i)}):(de(!0),a.undo.saveStep(),setTimeout(function(){a.undo.saveStep()},0))}},!0),a.browser.msie&&a.events.on("keydown",function(t){if(!a.selection.isCollapsed()||!i)return!0;var n=t.which;n==e.KEYCODE.C&&a.keys.ctrlKey(t)?a.events.trigger("window.copy"):n==e.KEYCODE.X&&a.keys.ctrlKey(t)&&a.events.trigger("window.cut")}),a.events.$on(p(a.o_win),"keydown",function(t){var a=t.which;if(i&&a==e.KEYCODE.BACKSPACE)return t.preventDefault(),!1}),a.events.$on(a.$win,"keydown",function(t){var a=t.which;i&&i.hasClass("fr-uploading")&&a==e.KEYCODE.ESC&&i.trigger("abortUpload")}),a.events.on("destroy",function(){i&&i.hasClass("fr-uploading")&&i.trigger("abortUpload")}),a.events.on("paste.before",ge),a.events.on("paste.beforeCleanup",fe),a.events.on("paste.after",le),a.events.on("html.set",R),a.events.on("html.inserted",R),R(),a.events.on("destroy",function(){s=[]}),a.events.on("html.processGet",oe),a.opts.imageOutputSize&&a.events.on("html.beforeGet",function(){t=a.el.querySelectorAll("img");for(var e=0;e<t.length;e++){var i=t[e].style.width||p(t[e]).width(),n=t[e].style.height||p(t[e]).height();i&&t[e].setAttribute("width","".concat(i).replace(/px/,"")),n&&t[e].setAttribute("height","".concat(n).replace(/px/,""))}}),a.opts.iframe&&a.events.on("image.loaded",a.size.syncIframe),a.$wp&&(U(),a.events.on("contentChanged",U)),a.events.$on(p(a.o_win),"orientationchange.image",function(){setTimeout(function(){i&&_(i)},100)}),N(!0),j(!0),ae(!0),Z(!0),a.events.on("node.remove",function(e){if("IMG"==e.get(0).tagName)return ne(e),!1})},showInsertPopup:function(){var e=a.$tb.find('.fr-command[data-cmd="insertImage"]'),t=a.popups.get("image.insert");if(t||(t=j()),z(),!t.hasClass("fr-active"))if(a.popups.refresh("image.insert"),a.popups.setContainer("image.insert",a.$tb),e.isVisible()){var i=a.button.getPosition(e),n=i.left,r=i.top;a.popups.show("image.insert",n,r,e.outerHeight())}else a.position.forSelection(t),a.popups.show("image.insert")},showLayer:function(e){var t,n,r=a.popups.get("image.insert");if(i||a.opts.toolbarInline){if(i){var o=Se();Ee()&&(o=o.find(".fr-img-wrap")),n=o.offset().top+o.outerHeight(),t=o.offset().left}}else{var s=a.$tb.find('.fr-command[data-cmd="insertImage"]');t=s.offset().left,n=s.offset().top+(a.opts.toolbarBottom?10:s.outerHeight()-10)}!i&&a.opts.toolbarInline&&(n=r.offset().top-a.helpers.getPX(r.css("margin-top")),r.hasClass("fr-above")&&(n+=r.outerHeight())),r.find(".fr-layer").removeClass("fr-active"),r.find(".fr-".concat(e,"-layer")).addClass("fr-active"),a.popups.show("image.insert",t,n,i?i.outerHeight():0),a.accessibility.focusPopup(r)},refreshUploadButton:function(e){var t=a.popups.get("image.insert");t&&t.find(".fr-image-upload-layer").hasClass("fr-active")&&e.addClass("fr-active").attr("aria-pressed",!0)},refreshByURLButton:function(e){var t=a.popups.get("image.insert");t&&t.find(".fr-image-by-url-layer").hasClass("fr-active")&&e.addClass("fr-active").attr("aria-pressed",!0)},upload:X,insertByURL:function(){var e=a.popups.get("image.insert").find(".fr-image-by-url-layer input");if(e.val().length>0){B(),O(a.language.translate("Loading image"));var t=e.val().trim();if(a.opts.imageUploadRemoteUrls&&a.opts.imageCORSProxy&&a.opts.imageUpload){var n=new XMLHttpRequest;n.onload=function(){200==this.status?X([new Blob([this.response],{type:this.response.type||"image/png"})],i):k(c)},n.onerror=function(){K(t,!0,[],i)},n.open("GET","".concat(a.opts.imageCORSProxy,"/").concat(t),!0),n.responseType="blob",n.send()}else K(t,!0,[],i);e.val(""),e.blur()}},align:function(e){var t=Se();t.removeClass("fr-fir fr-fil"),!a.opts.htmlUntouched&&a.opts.useClasses?"left"==e?t.addClass("fr-fil"):"right"==e&&t.addClass("fr-fir"):ve(t,ye(),e),Ae(),x(),A(),a.selection.clear()},refreshAlign:function(e){i&&e.find("> *").first().replaceWith(a.icon.create("image-align-".concat(be())))},refreshAlignOnShow:function(e,t){i&&t.find('.fr-command[data-param1="'.concat(be(),'"]')).addClass("fr-active").attr("aria-selected",!0)},display:function(e){var t=Se();t.removeClass("fr-dii fr-dib"),!a.opts.htmlUntouched&&a.opts.useClasses?"inline"==e?t.addClass("fr-dii"):"block"==e&&t.addClass("fr-dib"):ve(t,e,be()),Ae(),x(),A(),a.selection.clear()},refreshDisplayOnShow:function(e,t){i&&t.find('.fr-command[data-param1="'.concat(ye(),'"]')).addClass("fr-active").attr("aria-selected",!0)},replace:we,back:function(){i?(a.events.disableBlur(),p(".fr-popup input:focus").blur(),_(i)):(a.events.disableBlur(),a.selection.restore(),a.events.enableBlur(),a.popups.hide("image.insert"),a.toolbar.showInline())},get:Ce,getEl:Se,insert:K,showProgressBar:B,remove:ne,hideProgressBar:z,applyStyle:function(e,n,r){if(void 0===n&&(n=a.opts.imageStyles),void 0===r&&(r=a.opts.imageMultipleStyles),!i)return!1;var o=Se();if(!r){var s=Object.keys(n);s.splice(s.indexOf(e),1),o.removeClass(s.join(" "))}"object"==t(n[e])?(o.removeAttr("style"),o.css(n[e].style)):o.toggleClass(e),_(i)},showAltPopup:Q,showSizePopup:te,setAlt:function(e){if(i){var t=a.popups.get("image.alt");i.attr("alt",e||t.find("input").val()||""),t.find("input:focus").blur(),_(i)}},setSize:function(e,t){if(i){var n=a.popups.get("image.size");e=e||n.find('input[name="width"]').val()||"",t=t||n.find('input[name="height"]').val()||"";var r=/^[\d]+((px)|%)*$/g;i.removeAttr("width").removeAttr("height"),e.match(r)?i.css("width",e):i.css("width",""),t.match(r)?i.css("height",t):i.css("height",""),Ee()&&(i.parents(".fr-img-caption").removeAttr("width").removeAttr("height"),e.match(r)?i.parents(".fr-img-caption").css("width",e):i.parents(".fr-img-caption").css("width",""),t.match(r)?i.parents(".fr-img-caption").css("height",t):i.parents(".fr-img-caption").css("height","")),n&&n.find("input:focus").blur(),_(i)}},toggleCaption:function(){var t;if(i&&!Ee()){t=i,i.parent().is("a")&&(t=i.parent());var n,r,o=i.parents("ul")&&i.parents("ul").length>0?i.parents("ul"):i.parents("ol")&&i.parents("ol").length>0?i.parents("ol"):[];if(o.length>0){var s=o.find("li").length,l=i.parents("li"),p=document.createElement("li");s-1===l.index()&&(o.append(p),p.innerHTML="&nbsp;")}t.attr("style")?r=(n=t.attr("style").split(":")).indexOf("width")>-1?n[n.indexOf("width")+1].replace(";",""):"":t.attr("width")&&(r=t.attr("width"));var g=a.opts.imageResizeWithPercent?(r.indexOf("px")>-1?null:r)||"100%":i.width()+"px";t.wrap('<div class="fr-img-space-wrap"><span '+(a.browser.mozilla?"":'contenteditable="false"')+'class="fr-img-caption '+i.attr("class")+'" style="'+(a.opts.useClasses?"":t.attr("style"))+'" draggable="false"></span></div>'),t.wrap('<span class="fr-img-wrap"></span>'),i.after('<span class="fr-inner"'.concat(a.browser.mozilla?"":' contenteditable="true"',">").concat(e.START_MARKER).concat(a.language.translate("Image Caption")).concat(e.END_MARKER,"</span>")),i.parents(".fr-img-caption").css("width",g);var f=i.parents(".fr-img-space-wrap").length;1==f?Re(document.querySelector(".fr-img-space-wrap")):f>1&&(Re(document.querySelector(".fr-img-space-wrap")),Re(document.querySelector(".fr-img-space-wrap2"))),de(!0),a.selection.restore()}else{if(t=Se(),i.insertBefore(t),null!==t[0].querySelector("a")){for(var c,d=t[0].querySelector("a"),u=document.createElement("a"),m=0,h=d.attributes,v=h.length;m<v;m++)c=h[m],u.setAttribute(c.nodeName,c.nodeValue);i.wrap(u)}i.attr("class",t.attr("class").replace("fr-img-caption","")).attr("style",t.attr("style")),t.remove();var b=i.parents(".fr-img-space-wrap").length;1==b?Re(document.querySelector(".fr-img-space-wrap")):b>1&&(Re(document.querySelector(".fr-img-space-wrap")),Re(document.querySelector(".fr-img-space-wrap2"))),_(i)}},hasCaption:Ee,exitEdit:de,edit:_}},e.DefineIcon("insertImage",{NAME:"image",SVG_KEY:"insertImage"}),e.RegisterShortcut(e.KEYCODE.P,"insertImage",null,"P"),e.RegisterCommand("insertImage",{title:"Insert Image",undo:!1,focus:!0,refreshAfterCallback:!1,popup:!0,callback:function(){this.popups.isVisible("image.insert")?(this.$el.find(".fr-marker").length&&(this.events.disableBlur(),this.selection.restore()),this.popups.hide("image.insert")):this.image.showInsertPopup()},plugin:"image"}),e.DefineIcon("imageUpload",{NAME:"upload",SVG_KEY:"upload"}),e.RegisterCommand("imageUpload",{title:"Upload Image",undo:!1,focus:!1,toggle:!0,callback:function(){this.image.showLayer("image-upload")},refresh:function(e){this.image.refreshUploadButton(e)}}),e.DefineIcon("imageByURL",{NAME:"link",SVG_KEY:"insertLink"}),e.RegisterCommand("imageByURL",{title:"By URL",undo:!1,focus:!1,toggle:!0,callback:function(){this.image.showLayer("image-by-url")},refresh:function(e){this.image.refreshByURLButton(e)}}),e.RegisterCommand("imageInsertByURL",{title:"Insert Image",undo:!0,refreshAfterCallback:!1,callback:function(){this.image.insertByURL()},refresh:function(e){this.image.get()?e.text(this.language.translate("Replace")):e.text(this.language.translate("Insert"))}}),e.DefineIcon("imageDisplay",{NAME:"star",SVG_KEY:"imageDisplay"}),e.RegisterCommand("imageDisplay",{title:"Display",type:"dropdown",options:{inline:"Inline",block:"Break Text"},callback:function(e,t){this.image.display(t)},refresh:function(e){this.opts.imageTextNear||e.addClass("fr-hidden")},refreshOnShow:function(e,t){this.image.refreshDisplayOnShow(e,t)}}),e.DefineIcon("image-align",{NAME:"align-left",SVG_KEY:"alignLeft"}),e.DefineIcon("image-align-left",{NAME:"align-left",SVG_KEY:"alignLeft"}),e.DefineIcon("image-align-right",{NAME:"align-right",SVG_KEY:"alignRight"}),e.DefineIcon("image-align-center",{NAME:"align-justify",SVG_KEY:"alignCenter"}),e.DefineIcon("imageAlign",{NAME:"align-justify",SVG_KEY:"alignJustify"}),e.RegisterCommand("imageAlign",{type:"dropdown",title:"Align",options:{left:"Align Left",center:"None",right:"Align Right"},html:function(){var t='<ul class="fr-dropdown-list" role="presentation">',a=e.COMMANDS.imageAlign.options;for(var i in a)a.hasOwnProperty(i)&&(t+='<li role="presentation"><a class="fr-command fr-title" tabIndex="-1" role="option" data-cmd="imageAlign" data-param1="'.concat(i,'" title="').concat(this.language.translate(a[i]),'">').concat(this.icon.create("image-align-".concat(i)),'<span class="fr-sr-only">').concat(this.language.translate(a[i]),"</span></a></li>"));return t+="</ul>"},callback:function(e,t){this.image.align(t)},refresh:function(e){this.image.refreshAlign(e)},refreshOnShow:function(e,t){this.image.refreshAlignOnShow(e,t)}}),e.DefineIcon("imageReplace",{NAME:"exchange",FA5NAME:"exchange-alt",SVG_KEY:"replaceImage"}),e.RegisterCommand("imageReplace",{title:"Replace",undo:!1,focus:!1,popup:!0,refreshAfterCallback:!1,callback:function(){this.image.replace()}}),e.DefineIcon("imageRemove",{NAME:"trash",SVG_KEY:"remove"}),e.RegisterCommand("imageRemove",{title:"Remove",callback:function(){this.image.remove()}}),e.DefineIcon("imageBack",{NAME:"arrow-left",SVG_KEY:"back"}),e.RegisterCommand("imageBack",{title:"Back",undo:!1,focus:!1,back:!0,callback:function(){this.image.back()},refresh:function(e){this.$;this.image.get()||this.opts.toolbarInline?(e.removeClass("fr-hidden"),e.next(".fr-separator").removeClass("fr-hidden")):(e.addClass("fr-hidden"),e.next(".fr-separator").addClass("fr-hidden"))}}),e.RegisterCommand("imageDismissError",{title:"OK",undo:!1,callback:function(){this.image.hideProgressBar(!0)}}),e.DefineIcon("imageStyle",{NAME:"magic",SVG_KEY:"imageClass"}),e.RegisterCommand("imageStyle",{title:"Style",type:"dropdown",html:function(){var e='<ul class="fr-dropdown-list" role="presentation">',a=this.opts.imageStyles;for(var i in a)if(a.hasOwnProperty(i)){var n=a[i];"object"==t(n)&&(n=n.title),e+='<li role="presentation"><a class="fr-command" tabIndex="-1" role="option" data-cmd="imageStyle" data-param1="'.concat(i,'">').concat(this.language.translate(n),"</a></li>")}return e+="</ul>"},callback:function(e,t){this.image.applyStyle(t)},refreshOnShow:function(e,t){var a=this.$,i=this.image.getEl();i&&t.find(".fr-command").each(function(){var e=a(this).data("param1"),t=i.hasClass(e);a(this).toggleClass("fr-active",t).attr("aria-selected",t)})}}),e.DefineIcon("imageAlt",{NAME:"info",SVG_KEY:"imageAltText"}),e.RegisterCommand("imageAlt",{undo:!1,focus:!1,popup:!0,title:"Alternative Text",callback:function(){this.image.showAltPopup()}}),e.RegisterCommand("imageSetAlt",{undo:!0,focus:!1,title:"Update",refreshAfterCallback:!1,callback:function(){this.image.setAlt()}}),e.DefineIcon("imageSize",{NAME:"arrows-alt",SVG_KEY:"imageSize"}),e.RegisterCommand("imageSize",{undo:!1,focus:!1,popup:!0,title:"Change Size",callback:function(){this.image.showSizePopup()}}),e.RegisterCommand("imageSetSize",{undo:!0,focus:!1,title:"Update",refreshAfterCallback:!1,callback:function(){this.image.setSize()}}),e.DefineIcon("imageCaption",{NAME:"commenting",FA5NAME:"comment-alt",SVG_KEY:"imageCaption"}),e.RegisterCommand("imageCaption",{undo:!0,focus:!1,title:"Image Caption",refreshAfterCallback:!0,callback:function(){this.image.toggleCaption()},refresh:function(e){this.image.get()&&e.toggleClass("fr-active",this.image.hasCaption())}})});