!function(){"use strict";var t,e={n:function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,{a:r}),r},d:function(t,r){for(var i in r)e.o(r,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:r[i]})},o:function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}},r=jQuery;(t=e.n(r)())((function(){({init:function(){this.wrap=t(".rank-math-redirections-wrap"),this.addNew(),this.importExport(),this.showMore(),this.columnActions(),this.validateForm(),this.separateRedirectionTypes(),this.explodePastedContent()},addNew:function(){var e=this,r=t("html, body");this.wrap.on("click",".rank-math-add-new-redirection",(function(t){t.preventDefault();var i=e.wrap.find(".rank-math-editcreate-form");e.wrap.find(".rank-math-importexport-form").hide(),i.is(":visible")?i.hide():(i.find("#sources_repeat > .cmb-repeatable-grouping:not(:eq(0))").remove(),i.find("> form").get(0).reset(),i.show(),r.on("scroll mousedown wheel DOMMouseScroll mousewheel keyup touchmove",(function(){r.stop()})),r.animate({scrollTop:i.position().top},"slow",(function(){r.off("scroll mousedown wheel DOMMouseScroll mousewheel keyup touchmove")})))})),this.wrap.on("click",".button-link-delete",(function(e){e.preventDefault(),t(this).closest(".rank-math-editcreate-form").hide()}))},importExport:function(){var e=this;t("html, body"),this.wrap.on("click",".rank-math-redirections-import_export",(function(t){t.preventDefault();var r=e.wrap.find(".rank-math-importexport-form");e.wrap.find(".rank-math-editcreate-form").hide(),r.slideToggle(200)}))},validateForm:function(){var e=t(".rank-math-editcreate-form .button-primary");t(".rank-math-editcreate-form > .cmb-form").on("submit",(function(r){var i=t(this),n=i.find(".validation-message"),a=!1;e.prop("disabled",!0),i.find(".invalid").removeClass("invalid"),n.each((function(){t(this).prev("br").remove(),t(this).remove()})),i.find('input[type="text"]:not(.exclude)').each((function(){var e=t(this);e.val()&&e.val().trim()||(a=!0,e.addClass("invalid").after(t('<br><span class="validation-message">'+rankMath.emptyError+"</span>")))})),a&&(r.preventDefault(),e.prop("disabled",!1))}))},separateRedirectionTypes:function(){var e=this.wrap.find(".cmb2-id-header-code");if(e.length){var r=e.clone();r.find(".cmb-th label").text(rankMath.maintenanceMode),r.find(".cmb2-radio-list li:lt(3)").remove(),e.after(r),e.addClass("nob nopb"),e.find(".cmb2-radio-list li:gt(2)").remove();var i=t(".cmb2-id-url-to"),n=t("#url_to");t("[name=header_code]").on("change",(function(){var e=parseInt(t(this).val());410===e||451===e?(n.addClass("exclude"),i.addClass("hidden")):(n.removeClass("exclude"),i.removeClass("hidden"))})),t("[name=header_code]:checked").trigger("change")}},explodePastedContent:function(){var e=t("#sources_repeat");e.on("paste","input",(function(r){var i=r.originalEvent.clipboardData.getData("text");if(!/\r|\n/.exec(i))return!0;var n=t(this),a=t(".cmb-add-group-row",e),o=i.split(/\r?\n/).filter(String),s=n.closest(".cmb-field-list").find("select").val();return t.each(o,(function(r,i){if(n.val(i),n.closest(".cmb-field-list").find("select").val(s),r<o.length-1){if(rankMath.redirectionPastedContent-1<=r)return!1;a.click(),n=t(".cmb-repeatable-grouping",e).last().find("input")}else n.focus()})),!1}))},showMore:function(){this.wrap.on("click",".rank-math-showmore",(function(e){e.preventDefault();var r=t(this);r.hide(),r.next(".rank-math-more").slideDown()})),this.wrap.on("click",".rank-math-hidemore",(function(e){e.preventDefault();var r=t(this).parent();r.hide(),r.prev(".rank-math-showmore").show()}))},columnActions:function(){var e=this;this.wrap.on("click",".rank-math-redirection-action",(function(r){r.preventDefault();var i=t(this),n=i.data("action"),a=this.href.replace("admin.php","admin-ajax.php").replace("page=rank-math-redirections&","")+"&action=rank_math_redirection_"+n;t.ajax({url:a,type:"GET",success:function(r){r&&r.success&&(["delete","trash","restore"].includes(n)?i.closest("tr").fadeOut(800,(function(){t(this).remove()})):i.closest("tr").toggleClass("rank-math-redirection-activated rank-math-redirection-deactivated"),"activate"===n?(e.filterCountAdd("active"),e.filterCountSubstract("inactive")):"deactivate"===n?(e.filterCountAdd("inactive"),e.filterCountSubstract("active")):"trash"===n?(e.filterCountAdd("trashed"),e.filterCountSubstract("all"),i.closest(".rank-math-redirection-deactivated").length?e.filterCountSubstract("inactive"):e.filterCountSubstract("active")):"delete"===n?e.filterCountSubstract("trashed"):"restore"===n&&(e.filterCountAdd("active"),e.filterCountAdd("all"),e.filterCountSubstract("trashed")))}})}))},filterCountAdd:function(t){this.filterCount(t,"add")},filterCountSubstract:function(t){this.filterCount(t,"sub")},filterCount:function(t,e){var r=this.wrap.find("form > ul.subsubsub > ."+t+" .count"),i=parseInt(r.text().substr(1));i="add"===e?i+1:i-1,r.text("("+i+")")}}).init()}))}();