!function(){"use strict";jQuery(e=>{const t=wp.i18n.__,a=document.querySelector("#rollback-plugin"),r=e(a).find("button"),s=()=>{"true"===r.attr("aria-busy")&&r.text(r.data("text")).data("text","").attr("aria-busy",!1).prop("disabled",!1).removeClass("is-busy")},o=e=>{s(),GLSR.notices.error(e.error??GLSR.text.rollback_error),console.error(e)},i=e=>{let a;_.isObject(e)&&!_.isFunction(e.always)?a=e.errorMessage:_.isString(e)&&"-1"===e?a=t("An error has occurred. Please reload the page and try again."):_.isString(e)?a=e:void 0!==e.readyState&&0===e.readyState?a=t("Connection lost or the server is busy. Please try again later."):_.isString(e.responseText)&&""!==e.responseText?a=e.responseText:_.isString(e.statusText)&&(a=e.statusText),a=a.replace(/<[\/a-z][^<>]*>/gi,""),GLSR.notices.error((e.error??GLSR.text.rollback_error)+": "+a)},n=e=>{wp.ajax.send({data:e.data,error:i,success:()=>window.location=e.url}).always(e=>{s(),void 0!==e.debug&&_.map(e.debug,e=>console.info(e))})};e(a).on("submit",e=>{e.preventDefault();let t={_ajax_request:!0,action:GLSR.action},s={_action:a.action.value,_nonce:a._wpnonce.value,version:a.version.value};t[GLSR.nameprefix]=s,(()=>{if(["false",void 0].includes(r.attr("aria-busy"))){let e=(r.data("loading")||r.data("text")).replace("%s","v"+a.version.value);r.addClass("is-busy").prop("disabled",!0).attr("aria-busy",!0).data("text",r.text()).text(e)}})(),wp.ajax.send({data:t,error:o,success:n})})})}();
