window.seraph_accel||(window.seraph_accel={});
(function(){seraph_accel.PluginAdmin={AdvertProductsContentInit:function(a,c,b,f,k,g){function m(h,l){var e="";if(Array.isArray(h)&&h.length){e+=seraph_accel.Ui.TagOpen("tr");for(var d=0;d<h.length;d++){var n=h[d];0<d&&0==d%k&&(e+=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=l,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(f,!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)));e+=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(;d%k;d++)e+=seraph_accel.Ui.Tag("td",null,{"class":"cx-lg-6 cx-xs-12"});e+=seraph_accel.Ui.TagClose("tr");e=seraph_accel.Ui.Tag("table",seraph_accel.Ui.Tag("tbody",e))}jQuery(a).html(e)}
jQuery.ajax({url:seraph_accel.Net.UpdateQueryArgs(c+"/v1/advert_products",{slug:"accelerator",locale:b}),type:"GET",dataType:"json"}).then(function(h){m(h,g)},function(h){m(null,0)})},SwitchTo:function(a,c,b,f,k,g,m){function h(d,n){d?l.find(".operateblock").hide():l.find(".operateblock").find("*").prop("disabled",!1);e.removeClass("notice-warning updating-message");e.addClass(d?"notice-success updated-message":"notice-error");e.find("p").text(n);d&&l.find(".refresh_after").prop("checked")&&setTimeout(function(){location.reload()},
0)}var l=jQuery(".seraph_accel_switchto"),e=l.find(".update-message");e.removeClass("notice-success notice-error updated-message");e.addClass("notice-warning updating-message");e.find("p").text(c);l.find(".operateblock").find("*").prop("disabled",!0);e.show();jQuery.ajax({url:f,type:"POST",data:""}).then(function(d){return jQuery.ajax({url:k,type:"POST",data:{action:"update-plugin",plugin:g,slug:"seraphinite-accelerator",_ajax_nonce:m,seraph_accel_switchto:a},dataType:"json"})}).then(function(d){d.success?
h(!0,b):h(!1,d.data.errorMessage)},function(d){h(!1,"OK"===d.statusText?"PHP error: "+d.responseText:"Backend error: "+d.status+" "+d.statusText)})},RateItCont_Set:function(a,c,b){var f=jQuery("#"+a),k=f.find(".actions"),g=f.find(".seraph_accel_spinner");k.hide();g.show();jQuery.ajax({url:b+"="+(c?"rateItPostpone":"rateItDisable"),type:"POST",data:""}).then(function(m){f.hide()},function(m){k.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,f){function k(){m.prop("disabled",!1);g.hide()}if(b){a=jQuery(a.parentNode);var g=a.find(".seraph_accel_spinner"),m=a.find("input.button");m.prop("disabled",!0);g.show();a=new FileReader;a.onabort=function(h){k()};a.onerror=function(h){k()};
a.onload=function(h){jQuery.ajax({url:c+"=settImport&_wpnonce="+f+"&redir="+encodeURIComponent(location.href),type:"POST",contentType:"application/json",data:h.target.result}).then(function(l){l?location=l:location.reload()},function(l){k()})};a.readAsText(b)}},SettExport:function(a,c){function b(g){g&&window.saveAs(new Blob([g],{type:"text/json"}),"seraphinite-accelerator-settings.json");k.prop("disabled",!1);f.hide()}a=jQuery(a.parentNode);var f=a.find(".seraph_accel_spinner"),k=a.find("input.button");
k.prop("disabled",!0);f.show();jQuery.ajax({url:c+"=settExport",type:"POST",data:""}).then(function(g){seraph_accel.Ui.ScriptLoad(document,"https://cdn.jsdelivr.net/npm/file-saver@2.0.5/dist/FileSaver.min.js","file-saver").then(function(){b(g)},function(m){b()})},function(g){b()})},OnSettWizNext:function(a,c){var b=jQuery(a).closest("form");a=jQuery(a.parentNode);var f=b.find(".wizPages");b=f.find(">.active").first();b.get(0)?(c=c?b.next():b.prev(),c.get(0)&&(b.removeClass("active"),b=c)):b=f.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()}}})();
