jQuery(document).ready(function(){if(spai_settings.webp=="1"&&self.createImageBitmap){var e=function(){var r={basic:"data:image/webp;base64,UklGRjIAAABXRUJQVlA4ICYAAACyAgCdASoCAAEALmk0mk0iIiIiIgBoSygABc6zbAAA/v56QAAAAA==",lossless:"data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA="};return function(e){var t=jQuery.Deferred();jQuery("
").on("load",function(){if(this.width===2&&this.height===1){t.resolve()}else{t.reject()}}).on("error",function(){t.reject()}).attr("src",r[e||"basic"]);return t.promise()}}();e().then(function(){ShortPixelAI.supportsWebP=true;ShortPixelAI.init()},function(){ShortPixelAI.init()})}else{ShortPixelAI.init()}});var ShortPixelAI=function(){return{init:e,handleUpdatedImageUrls:r,updateImageUrl:t,updateDivUrl:a,updateAHref:n,updateAttr:o,updateAHrefForIntegration:l,setupDOMChangeObserver:u,isExcluded:s,setupIntersectionObserverAndParse:d,elementInViewport:c,hookIntoFancybox:f,composeApiUrl:g,isPseudoSrc:p,parsePseudoSrc:v,updateSrc:x,updateSrcSet:A,removeSrcSet:I,updateInlineStyle:m,updateWpBakeryTestimonial:i,getBackgroundPseudoImage:S,urldecode:P,getSizesRecursive:y,percent2px:b,fancyboxUpdateWidth:w,fancyboxChangeId:h,xpath:_,fancyboxId:"",fancyboxHooked:"none",mutationsCount:0,mutationsList:{},timeOutHandle:false,mutationObserver:false,intersectionObserver:false,intersectionMargin:500,supportsWebP:false};function e(){if(typeof window.IntersectionObserver!=="function"){jQuery.getScript(spai_settings.plugin_url+"/js/intersection.min.js?"+spai_settings.version,ShortPixelAI.setupIntersectionObserverAndParse)}else{ShortPixelAI.setupIntersectionObserverAndParse()}}function r(e,t,r){if(e.is("img")){ShortPixelAI.updateImageUrl(e,t,r);return}jQuery("img",e).each(function(){var e=jQuery(this);ShortPixelAI.updateImageUrl(e,t,r)});if(r&&(e.is("a")||e.is("div")||e.is("li")||e.is("header"))){ShortPixelAI.updateDivUrl(e,t,r)}jQuery("a,div,li,header",e).each(function(){var e=jQuery(this);ShortPixelAI.updateDivUrl(e,t,r)});ShortPixelAI.updateAHrefForIntegration("envira",e,"a.envira-gallery-link");ShortPixelAI.updateAHrefForIntegration("modula",e,"div.modula-gallery a[data-lightbox]");ShortPixelAI.updateAHrefForIntegration("elementor-addons",e,"div.eael-filter-gallery-wrapper a.eael-magnific-link");ShortPixelAI.updateAHrefForIntegration("elementor",e,"a[data-elementor-open-lightbox]");if(spai_settings.active_integrations["wp-bakery"]){jQuery("span.dima-testimonial-image",e).each(function(){ShortPixelAI.updateWpBakeryTestimonial(jQuery(this))})}ShortPixelAI.updateAHrefForIntegration("foo",e,"div.fg-item a.fg-thumb");if(spai_settings.active_integrations.nextgen){jQuery("a.ngg-fancybox",e).each(function(){var e=jQuery(this);if(!ShortPixelAI.isPseudoSrc(e.attr("href"))){return}var t=ShortPixelAI.parsePseudoSrc(e.attr("href"));e.attr("href",g(t.src,"DEFER"));e.mousedown(function(){w(e);return true})})}}function t(e,t,r){if(typeof e.attr("data-spai-upd")!=="undefined"){return}if(!r&&!c(e[0],ShortPixelAI.intersectionMargin)){ShortPixelAI.intersectionObserver.observe(e[0]);return}var i=0,a=0;var n=ShortPixelAI.isExcluded(e);if(!n){try{var o=y(e,t);i=Math.ceil(o.width);a=Math.ceil(o.height)}catch(e){if(e=="defer"&&t){return}}}var s=x(e,"src",i,a,(spai_settings.method=="src"||spai_settings.method=="both")&&n!=2);x(e,"data-src",false,false,n!=2);x(e,"data-large_image",false,false,n!=2);if(spai_settings.active_integrations.envira){x(e,"data-envira-src",false,false,n!=2);x(e,"data-safe-src",i,a,n!=2)}if(spai_settings.active_integrations.foo){x(e,"data-src-fg",i,a,n!=2)}if(spai_settings.method=="src"){I(e)}else{A(e,i,s)}e.attr("data-spai-upd",i)}function i(e){if(1==e.attr("data-spai-upd")){return}ShortPixelAI.updateAttr(e,"data-element-bg");var t=0,r=0,i=[];var a=ShortPixelAI.isExcluded(e);if(!a){try{i=y(e,hasMutationObserver);t=Math.ceil(i.width);r=Math.ceil(i.height)}catch(e){if(e=="defer"&&hasMutationObserver){return}}}ShortPixelAI.updateInlineStyle(e,t,r,true);e.attr("data-spai-upd",1)}function a(e,t,r){if(1==e.attr("data-spai-upd")){return}if(typeof e.attr("src")==="undefined"&&typeof e.attr("data-src")==="undefined"&&typeof e.attr("data-thumb")==="undefined"&&!ShortPixelAI.getBackgroundPseudoImage(e.attr("style"))){return}if(!r&&!c(e[0],ShortPixelAI.intersectionMargin)){ShortPixelAI.intersectionObserver.observe(e[0]);return}var i=0,a=0,n=[];var o=ShortPixelAI.isExcluded(e);if(!o){try{n=y(e,t);i=Math.ceil(n.width);a=Math.ceil(n.height)}catch(e){if(e=="defer"&&t){return}}}ShortPixelAI.updateSrc(e,"src",i,a,o!=2);ShortPixelAI.updateSrc(e,"data-src",i,a,o!=2);ShortPixelAI.updateSrc(e,"data-thumb",false,false,o!=2);ShortPixelAI.updateInlineStyle(e,false,false,true);e.attr("data-spai-upd",i)}function n(e,t,r){ShortPixelAI.updateAttr(e,"href")}function o(e,t){if(1==e.attr("data-spai-upd")){return}if(typeof e.attr(t)==="undefined"){return}var r=ShortPixelAI.updateSrc(e,t,window.screen.availWidth,window.screen.availHeight,ShortPixelAI.isExcluded(e)!=2,true);e.attr("data-spai-upd",r.newWidth)}function s(e){for(var t=0;t0){r(e,true);if(t.indexOf("background")>0){m(e,false,false,true)}}delete ShortPixelAI.mutationsList[mutationTarget]}},50)}}})});var e=document.querySelector("body");var t={attributes:true,childList:true,subtree:true,characterData:true};ShortPixelAI.mutationObserver.observe(e,t)}function d(){var e={rootMargin:ShortPixelAI.intersectionMargin+"px",threshold:0};ShortPixelAI.intersectionObserver=new IntersectionObserver(function(e,r){e.forEach(function(e){if(e.isIntersecting){var t=jQuery(e.target);ShortPixelAI.handleUpdatedImageUrls(t,true,true);if(e.target.outerHTML.indexOf("background")>0){m(t,false,false,true)}r.unobserve(e.target)}})},e);jQuery("style").each(function(){var e=jQuery(this);var n=e.html();var o=false;n.replace(/(background-image|background)\s*:([^;]*[,\s]|\s*)url\(['"]?(data:image\/svg\+xml;u=[^'"\)]*?)(['"]?)\)/gm,function(e){var t=/(background-image|background)\s*:([^;]*[,\s]|\s*)url\(['"]?(data:image\/svg\+xml;u=[^'"\)]*?)(['"]?)\)/m;var r=t.exec(e);var i=ShortPixelAI.parsePseudoSrc(r[3]);var a=ShortPixelAI.composeApiUrl(i.src,i.origWidth);n=n.replace(r[3],a);o=true});if(o){e.html(n)}});ShortPixelAI.handleUpdatedImageUrls(jQuery("body"),true,false);if(typeof window.MutationObserver!=="function"){jQuery.getScript(spai_settings.plugin_url+"/js/MutationObserver.min.js?"+spai_settings.version,ShortPixelAI.setupDOMChangeObserver)}else{ShortPixelAI.setupDOMChangeObserver()}}function c(e,t){var r=e.getBoundingClientRect();return r.bottom+t>=0&&r.right+t>=0&&r.top-t<=(window.innerHeight||document.documentElement.clientHeight)&&r.left-t<=(window.innerWidth||document.documentElement.clientWidth)}function f(e){if(ShortPixelAI.fancyboxId.length==0||ShortPixelAI.fancyboxHooked!=="none"){return}console.log("HookIntoFancybox");var t=jQuery(e);var r=jQuery("a#fancybox-right",t);r.mousedown(function(e){var t=h(1);console.log("right "+t);var r=jQuery("div#"+t+" a.ngg-fancybox");if(r.length){w(r)}});var r=jQuery("a#fancybox-left",t);r.mousedown(function(e){var t=h(-1);console.log("left "+t);var r=jQuery("div#"+t+" a.ngg-fancybox");if(r.length){w(r)}});ShortPixelAI.fancyboxHooked=ShortPixelAI.fancyboxId}function h(e){var t=ShortPixelAI.fancyboxId.match(/(.*)([0-9]+)$/);return t[1]+(parseInt(t[2])+e)}function g(e,t){if(!e.match(/^http[s]{0,1}:\/\/|^\/\//)){if(e.startsWith("/")){e=spai_settings.site_url+e}else{e=window.location.href+(window.location.href.endsWith("/")?"":"/")+e}}if(t){var r=spai_settings.api_url.replace("%WIDTH%",t)}else{var r=spai_settings.api_url.replace("w_%WIDTH%"+spai_settings.sep,"");var r=spai_settings.api_url.replace("w_%WIDTH%","")}if(1==spai_settings.debug){r=r+"?url="+e+(t?"&width="+t:"")+"&height="+css_height+(ShortPixelAI.supportsWebP?"&to=webp":"")}else{r=r+(ShortPixelAI.supportsWebP?spai_settings.sep+"to_webp":"")+"/"+e}console.log(r,t);return r}function p(e){return e.indexOf("data:image/svg+xml;u=")>=0}function v(e){if(!ShortPixelAI.isPseudoSrc(e)){return false}var t=false;var r=0,i=0;var a=e.split(",");if(a.length==2){var n=a[0].split(";");if(n[1].indexOf("u=")==0){t=ShortPixelAI.urldecode(atob(n[1].substring(2)));if(t.lastIndexOf("//",0)==0){t=window.location.protocol+t}}if(n.length>=4){var o=n[2].split("=");if(o.length==2&&o[0]=="w"){r=o[1]}else{r=9999}}if(n.length>=5){var o=n[3].split("=");if(o.length==2&&o[0]=="h"){i=o[1]}else{i=9999}}}return{src:t,origWidth:r,origHeight:i}}function x(e,t,r,i,a,n){var o=e.attr(t);if(typeof o==="undefined"){return false}var s=ShortPixelAI.parsePseudoSrc(o);var l=s?s.src:false;if(!l){return false}if(typeof n==="undefined"||!n){if(i>s.origHeight*r/s.origWidth){r=Math.ceil(s.origWidth*i/s.origHeight)}}else{if(i=2){var f=ShortPixelAI.parsePseudoSrc(c[0]);d=ShortPixelAI.composeApiUrl(f.src,false)+" "+c[1];if(t==parseInt(c[1])){r=false}else if(r&&ts){l=a}else{u=n;l=Math.round(n*o)}l=l<700?Math.floor((l+49)/50)*50:Math.floor((l+99)/100)*100;var d=e.attr("href");if(d.indexOf("w_DEFER")>0){var c=d.replace("w_DEFER","w_"+l);console.log("replace DEFER: "+c);e.attr("href",c)}else{var f=d.match(/\/w_([0-9]+),._/g);if(f!==null&&f[2]1?"["+([].indexOf.call(e,t)+1)+"]":"")}}();if(!String.prototype.startsWith){String.prototype.startsWith=function(e,t){t=t||0;return this.substr(t,e.length)===e}}