/*! WP User Manager - v2.9.9 * https://wpusermanager.com * Copyright (c) 2024; * Licensed GPLv2+ */ jQuery(function(a){function b(){a(".wpum-multiselect:not(.wpum-clone-field)").each(function(){c(a(this))}),a(".wpum-datepicker:not([readonly]):not(.wpum-clone-field)").flatpickr({altFormat:wpumFrontend.dateFormat,altInput:!0,dateFormat:"Y-m-d"})}function c(a){var b={theme:"default"},c=a.attr("placeholder");c&&(b.placeholder=c),a.select2(b)}var d={form:a("form"),repeaters:{},init:function(){var b=this;a(".add-repeater-row").each(function(){var c=a(this).parents("fieldset");if(c.find(".fieldset-wpum_field_group").not(".fieldset-wpum_field_group-clone").length){var d=c.get(0).classList[0];b.increaseInstance(d),b.validateMaxRows(d)}}),a(".fieldset-wpum_field_group-clone :input").not(":button, :submit, :reset").each(function(){a(this).addClass("wpum-clone-field"),a(this).attr("data-clone",a(this).attr("id")),a(this).attr("data-name",a(this).attr("name")),a(this).attr("id",""),a(this).attr("name",""),a(this).removeAttr("required")}),b.form.on("click",".add-repeater-row",function(){var c=a(this).parents("fieldset");b.addNewInstance(c.get(0).classList[0]),b.form.wpumConditionalFields({})}),b.form.on("click",".remove-repeater-row",function(c){c.preventDefault();var d=a(this).parents("fieldset");a(this).parents(".fieldset-wpum_field_group").remove(),b.setupInstances(d.get(0).classList[0])})},increaseInstance:function(a){this.repeaters[a]||this.resetInstance(a),this.repeaters[a]++},addNewInstance:function(a){this.addNewRepeaterRow(a),this.setupInstances(a),b()},resetInstance:function(a){this.repeaters[a]=0},addNewRepeaterRow:function(b){var c=a("."+b).find(".fieldset-wpum_field_group-clone").last();if(c.length&&this.validateMaxRows(b)){var d=c.clone();d.removeClass("fieldset-wpum_field_group-clone"),d.find(":input").not(":button, :submit, :reset").val("").prop("checked",!1).prop("selected",!1).removeClass("wpum-clone-field").trigger("change"),d.insertBefore(c)}},setupInstances:function(b){var c=a("."+b).find(".fieldset-wpum_field_group").not(".fieldset-wpum_field_group-clone"),d=this;c.length&&(d.resetInstance(b),c.each(function(c){a(this).find("fieldset").attr("data-index",c),a(this).find(":input").each(function(){var b="";if(b=a(this).attr("data-name")?a(this).attr("data-name"):a(this).prop("name"),a(this).attr("name",b.replace(new RegExp(/\[(.*?)\]/),function(){return"["+c+"]"})),c>0){var d="";d=a(this).attr("data-clone")?a(this).attr("data-clone"):a(this).prop("id");var e=d+"_"+c;a(this).attr("id",e),a(this).closest("fieldset").find("label").attr("for",e)}}),d.increaseInstance(b)}))},validateMaxRows:function(b){var c=a("."+b),d=c.find(".fieldset-wpum_field_group").not(".fieldset-wpum_field_group-clone"),e=c.find(".add-repeater-row"),f=e.data("max-row");return!f||parseInt(f)<1||(d.length-1},this.valueEquals=function(b){var c=this.getValue(b);return a.isArray(c)?c.includes(b.value):c&&c.toLowerCase()===b.value.toLowerCase()},this.valueNotEquals=function(b){var c=this.getValue(b);return a.isArray(c)?!c.includes(b.value):c&&c.toLowerCase()!==b.value.toLowerCase()},this.valueGreater=function(a){var b=this.getValue(a);return parseFloat(b)>parseFloat(a.value)},this.valueLess=function(a){var b=this.getValue(a);return parseFloat(b)