!function(r,e,o){var t=function(r){type=r.closest(".ag-user-role-wrapper").attr("data-type"),rules=r.find(".ag-user-role-condition"),show_close=!1,rules.length>1&&(show_close=!0),rules.each(function(){show_close?jQuery(this).find(".user_role-condition-delete").removeClass("ag-hidden"):jQuery(this).find(".user_role-condition-delete").addClass("ag-hidden")})};r(document).ready(function(r){jQuery(".ag-user-role-selector-wrapper").each(function(){t(jQuery(this))}),jQuery(".ag-user-role-selector-wrapper").on("click",".user_role-add-rule-wrap a",function(r){r.preventDefault(),r.stopPropagation();var e=jQuery(this),o=parseInt(e.attr("data-rule-id"))+1,a=e.closest(".ag-user-role-selector-wrapper").find(".user_role-builder-wrap"),l=wp.template("ag-user-role-condition"),n=e.closest(".ag-user-role-wrapper");a.append(l({id:o})),e.attr("data-rule-id",o),t(n)}),jQuery(".ag-user-role-selector-wrapper").on("click",".user_role-condition-delete",function(r){var e=jQuery(this),o=e.closest(".ag-user-role-condition"),a=e.closest(".ag-user-role-wrapper");cnt=0,data_type=a.attr("data-type"),optionVal=e.siblings(".user_role-condition-wrap").children(".user_role-condition").val(),o.remove(),a.find(".ag-user-role-condition").each(function(r){var e=jQuery(this),o=e.attr("data-rule"),t=e.find(".user_role-condition"),a=t.attr("name");e.attr("data-rule",r),t.attr("name",a.replace("["+o+"]","["+r+"]")),e.removeClass("ag-user-role-"+o).addClass("ag-user-role-"+r),cnt=r}),a.find(".user_role-add-rule-wrap a").attr("data-rule-id",cnt),t(a)})})}(jQuery,window);