!function(e){var t={};function n(s){if(t[s])return t[s].exports;var i=t[s]={i:s,l:!1,exports:{}};return e[s].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=e,n.c=t,n.d=function(e,t,s){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:s})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var s=Object.create(null);if(n.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(s,i,function(t){return e[t]}.bind(null,i));return s},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=50)}({0:function(e,t){e.exports=jQuery},50:function(e,t,n){"use strict";n.r(t);class s{constructor(){this.element=document.createElement("div"),this.element.classList.add("notice"),this.dismissible=!1}setMessage(e){return this.message=e,this}renderDismiss(){const e=document.createElement("button");e.classList.add("notice-dismiss"),e.setAttribute("type","button"),e.insertAdjacentHTML("beforeend",'<span class="screen-reader-text">Dismiss this notice.</span>'),e.addEventListener("click",e=>{e.preventDefault(),this.element.remove()}),this.element.classList.add("is-dismissible"),this.element.insertAdjacentElement("beforeend",e)}renderContent(){this.element.insertAdjacentHTML("afterbegin",this.message)}makeDismissable(){return this.dismissible=!0,this}addClass(e){return this.element.classList.add(e),this}render(){return this.element.innerHTML="",this.renderContent(),this.dismissible&&this.renderDismiss(),this.element}}var i=n(0),r=n.n(i);class a{constructor(e,t){this.element=e,this.slug=t,this.loadingState=!1,this.initEvents()}getDownloadButton(){return this.element.querySelector("[data-install]")}setLoadingState(){const e=this.getDownloadButton();e&&(e.insertAdjacentHTML("afterend",'<span class="spinner" style="visibility: visible;"></span>'),e.classList.add("button-disabled")),this.loadingState=!0}removeLoadingState(){const e=this.getDownloadButton(),t=this.element.querySelector(".spinner");t&&t.remove(),e&&e.classList.remove("button-disabled"),this.loadingState=!1}initEvents(){const e=this.getDownloadButton();e&&e.addEventListener("click",e=>{e.preventDefault(),this.loadingState||(this.setLoadingState(),this.download())})}success(e){const t=this.getDownloadButton(),n=this.element.querySelector("h3"),i=new s;i.setMessage(`<p>The Add-on <strong>${n.innerHTML}</strong> is installed.</p>`).makeDismissable().addClass("updated"),document.querySelector(".ac-addons").insertAdjacentElement("beforebegin",i.render()),t&&(t.insertAdjacentHTML("beforebegin",`<span class="active">${e}</span>`),t.remove())}static scrollToTop(e){r()("html, body").animate({scrollTop:0},e)}failure(e){const t=this.element.querySelector("h3"),n=new s;n.setMessage(`<p><strong>${t.innerHTML}</strong>: ${e}</p>`).makeDismissable().addClass("notice-error"),document.querySelector(".ac-addons").insertAdjacentElement("beforebegin",n.render()),a.scrollToTop(200)}download(){this.request().done(e=>{this.removeLoadingState(),e.success?this.success(e.data.status):this.failure(e.data)})}request(){let e={action:"acp-install-addon",plugin_name:this.slug,network_wide:AC.is_network_admin,_ajax_nonce:AC._ajax_nonce};return r.a.ajax({url:ajaxurl,method:"post",data:e})}}document.addEventListener("DOMContentLoaded",(function(){document.querySelectorAll(".ac-addon").forEach(e=>{new a(e,e.dataset.slug)})}))}});