window.seraph_accel||(window.seraph_accel={});
(function(){seraph_accel.PluginAdmin={AdvertProductsContentInit:function(a,c,b,d,f,g){function l(h,m){var k="";if(Array.isArray(h)&&h.length){k+=seraph_accel.Ui.TagOpen("tr");for(var e=0;e<h.length;e++){var n=h[e];0<e&&0==e%f&&(k+=seraph_accel.Ui.TagClose("tr")+seraph_accel.Ui.TagOpen("tr"));var x=seraph_accel.Ui,C=x.Tag,y=seraph_accel.Ui,D=y.Tag,z=m,r="";var q=n.images;var u=z;if(Array.isArray(q)){for(var v=-1,A=2147483647,w=-1,B=2147483647,t=0;t<q.length;t++){var p=q[t];if(u==p.width){v=t;break}u<
p.width?(p=p.width-u,p<A&&(v=t,A=p)):(p=u-p.width,p<B&&(w=t,B=p))}q=-1!=v?q[v].url:-1!=w?q[w].url:null}else q=null;q&&(r+=seraph_accel.Ui.Tag("td",seraph_accel.Ui.Link(seraph_accel.Ui.Tag("img",null,{"class":"ctlSpaceAfter",width:z,src:q},!0),n.urlInfo,!0),{style:{width:"1px"}}));r+=seraph_accel.Ui.TagOpen("td");r+=seraph_accel.Ui.Tag("h3",n.title,{"class":"ctlSpaceVAfter",style:{"margin-top":0}});r+=seraph_accel.Ui.Tag("div",n.descr);n.urlInfo&&(r+=seraph_accel.Ui.Button(d,!0,null,"ctlSpaceVBefore",
"button",{onclick:"window.open( '"+n.urlInfo+"', '_blank' )"}));r+=seraph_accel.Ui.TagClose("td");n=seraph_accel.Ui.Tag("table",seraph_accel.Ui.Tag("tbody",seraph_accel.Ui.Tag("row",r)));k+=C.call(x,"td",D.call(y,"div",n,{style:{margin:"1em 1em 2em 1em"}}),{"class":"cx-lg-6 cx-xs-12",style:{"vertical-align":"top"}})}for(;e%f;e++)k+=seraph_accel.Ui.Tag("td",null,{"class":"cx-lg-6 cx-xs-12"});k+=seraph_accel.Ui.TagClose("tr");k=seraph_accel.Ui.Tag("table",seraph_accel.Ui.Tag("tbody",k))}jQuery(a).html(k)}
jQuery.ajax({url:seraph_accel.Net.UpdateQueryArgs(c+"/v1/advert_products",{slug:"accelerator",locale:b}),type:"GET",dataType:"json"}).then(function(h){l(h,g)},function(h){l(null,0)})},SwitchTo:function(a,c,b,d,f,g,l){function h(e,n){e?m.find(".operateblock").hide():m.find(".operateblock").find("*").prop("disabled",!1);k.removeClass("notice-warning updating-message");k.addClass(e?"notice-success updated-message":"notice-error");k.find("p").text(n);e&&m.find(".refresh_after").prop("checked")&&setTimeout(function(){location.reload()},
0)}var m=jQuery(".seraph_accel_switchto"),k=m.find(".update-message");k.removeClass("notice-success notice-error updated-message");k.addClass("notice-warning updating-message");k.find("p").text(c);m.find(".operateblock").find("*").prop("disabled",!0);k.show();jQuery.ajax({url:d,type:"POST",data:""}).then(function(e){return jQuery.ajax({url:f,type:"POST",data:{action:"update-plugin",plugin:g,slug:"seraphinite-accelerator",_ajax_nonce:l,seraph_accel_switchto:a},dataType:"json"})}).then(function(e){e.success?
h(!0,b):h(!1,e.data.errorMessage)},function(e){h(!1,"OK"===e.statusText?"PHP error: "+e.responseText:"Backend error: "+e.status+" "+e.statusText)})},RateItCont_Set:function(a,c,b){var d=jQuery("#"+a),f=d.find(".actions"),g=d.find(".seraph_accel_spinner");f.hide();g.show();jQuery.ajax({url:b+"="+(c?"rateItPostpone":"rateItDisable"),type:"POST",data:""}).then(function(l){d.hide()},function(l){f.show();g.hide()})},RateIt_Set:function(a,c){jQuery("#seraph_accel_RateIt_Message .actions").hide();jQuery("#seraph_accel_RateIt_Message .seraph_accel_spinner").show();
jQuery.ajax({url:c+"="+(a?"rateItPostpone":"rateItDisable"),type:"POST",data:""}).then(function(b){seraph_accel.Ui.BannerMsgClose(jQuery("#seraph_accel_RateIt_Message"))},function(b){jQuery("#seraph_accel_RateIt_Message .actions").show();jQuery("#seraph_accel_RateIt_Message .spinner").hide()})},ChangeVersion_Confirm:function(a){jQuery("#seraph_accel_ChangeVersion_Msg .actions").hide();jQuery("#seraph_accel_ChangeVersion_Msg .seraph_accel_spinner").show();jQuery.ajax({url:a+"=changeVersionConfirm",
type:"POST",data:""}).then(function(c){seraph_accel.Ui.BannerMsgClose(jQuery("#seraph_accel_ChangeVersion_Msg"))},function(c){jQuery("#seraph_accel_ChangeVersion_Msg .actions").show();jQuery("#seraph_accel_ChangeVersion_Msg .spinner").hide()})},SettImport:function(a,c,b,d){function f(){l.prop("disabled",!1);g.hide()}if(b){a=jQuery(a.parentNode);var g=a.find(".seraph_accel_spinner"),l=a.find("input.button");l.prop("disabled",!0);g.show();a=new FileReader;a.onabort=function(h){f()};a.onerror=function(h){f()};
a.onload=function(h){jQuery.ajax({url:c+"=settImport&_wpnonce="+d+"&redir="+encodeURIComponent(location.href),type:"POST",contentType:"application/json",data:h.target.result}).then(function(m){m?location=m:location.reload()},function(m){f()})};a.readAsText(b)}},SettExport:function(a,c,b){function d(l){l&&window.saveAs(new Blob([l],{type:"text/json"}),"seraphinite-accelerator-settings.json");g.prop("disabled",!1);f.hide()}a=jQuery(a.parentNode);var f=a.find(".seraph_accel_spinner"),g=a.find("input.button");
g.prop("disabled",!0);f.show();jQuery.ajax({url:c+"=settExport&_wpnonce="+b,type:"POST",data:""}).then(function(l){seraph_accel.Ui.ScriptLoad(document,"https://cdn.jsdelivr.net/npm/file-saver@2.0.5/dist/FileSaver.min.js","file-saver").then(function(){d(l)},function(h){d()})},function(l){d()})},OnSettWizNext:function(a,c){var b=jQuery(a).closest("form");a=jQuery(a.parentNode);var d=b.find(".wizPages");b=d.find(">.active").first();b.get(0)?(c=c?b.next():b.prev(),c.get(0)&&(b.removeClass("active"),b=
c)):b=d.children().first();b.addClass("active");c=!!b.next().get(0);b=!!b.prev().get(0);a.find("input.wizNext").prop("disabled",!c);a.find("input.wizPrev").prop("disabled",!b);c?a.find("input.wizFinish").hide():a.find("input.wizFinish").show()},_int:{StrItem_OnAdd:function(a){function c(g){(g=g.trim())&&seraph_accel.Ui.TokensList.AddItem(f[0],g)}var b=1<arguments.length&&void 0!==arguments[1]?arguments[1]:",",d=jQuery(a.parentNode).closest(".blck").first(),f=d.find(".vals");d=d.find(".val");b?d.val().split(b).forEach(c):
c(d.val());d.val("")},StrItem_OnCopyAll:function(a){seraph_accel.Ui.TokensList.CopyAllItems(jQuery(a.parentNode).closest(".blck").first().find(".vals")[0])},StrItem_OnDelAll:function(a){seraph_accel.Ui.TokensList.DelAllItems(jQuery(a.parentNode).closest(".blck").first().find(".vals")[0])}}}})();
