jQuery(function(a){if("undefined"==typeof kadence_blocks_form_params)return!1;var b={init:function(){a("form.kb-form").on("submit",this.submit)},submit:function(c){c.preventDefault(),a("body").trigger("kb-form-start-submit",a(this));var d=a(this),e=d.find("input[type=submit]");form_data=b.validateForm(d),form_data&&(d.parent(".wp-block-kadence-form").find(".kadence-blocks-form-message").slideUp("fast",function(){a(this).remove()}),d.append("<div class=\"kb-form-loading\"><div class=\"kb-form-loading-spin\"><div></div><div></div><div></div><div></div></div></div>"),e.attr("disabled","disabled").addClass("button-primary-disabled"),a.post(kadence_blocks_form_params.ajaxurl,form_data,function(c){c.success?(a("body").trigger("kb-form-success",c),c.redirect?window.location=c.redirect:(d.after(c.html),0<d.find(".g-recaptcha").length&&grecaptcha.reset(),b.clearForm(d))):(0<d.find(".g-recaptcha").length&&grecaptcha.reset(),d.after(c.data.html),c.data.required&&0<d.find("#"+c.data.required).length&&b.markError(d.find("#"+c.data.required),"required"),console.log(c.data.console),e.removeAttr("disabled")),e.removeClass("button-primary-disabled"),d.find(".kb-form-loading").remove()}))},removeErrors:function(b){a(b).parents(".kb-form").removeClass("kb-form-has-error"),a(b).find(".has-error").removeClass("has-error"),a(".kb-form-error-msg").remove()},isValidEmail:function(a){var b=new RegExp(/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i);return b.test(a)},removeErrorNotice:function(b){a(b).find(".kb-form-errors").remove()},markError:function(b,c){var d="";a(b).parents(".kb-form").addClass("kb-form-has-error"),a(b).addClass("has-error");c&&(d=a(b).data("label"),(""===d||void 0===d)&&(d=kadence_blocks_form_params.item),"required"===c?d=d+" "+kadence_blocks_form_params[c]:"mismatch"===c?d=d+" "+kadence_blocks_form_params[c]:"validation"===c?d=d+" "+kadence_blocks_form_params[c]:void 0,a(b).siblings(".kb-form-error-msg").remove(),a(b).hasClass("kb-checkbox-style")?a(b).parent(".kadence-blocks-form-field").append("<div class=\"kb-form-error-msg kadence-blocks-form-warning\" role=\"alert\">"+d+"</div>"):a(b).after("<div class=\"kb-form-error-msg kadence-blocks-form-warning\">"+d+"</div>"));a(b).focus()},clearForm:function(b){a(b)[0].reset()},addErrorNotice:function(b){a(b).after("<div class=\"kadence-blocks-form-message kadence-blocks-form-warning\">"+kadence_blocks_form_params.error_message+"</div>")},isValidURL:function(a){return /^(http:\/\/www.|https:\/\/www.|ftp:\/\/www.|www.|http:\/\/|https:\/\/){1}([0-9A-Za-z]+.)/.test(a)},isValidTel:function(a){return /\/^[+]?[(]?[0-9]{3}[)]?[-s.]?[0-9]{3}[-s.]?[0-9]{4,6}$\/im/.test(a)},validateForm:function(c){var d=!1;error_type="",b.removeErrors(c),b.removeErrorNotice(c);var e=c.find("[data-required=\"yes\"]:visible");if(e.each(function(c,e){var f=a(e).data("type");switch(h="",f){case"textarea":case"text":h=a.trim(a(e).val()),""===h&&(d=!0,error_type="required",b.markError(e,error_type));break;case"tel":h=a.trim(a(e).val()),""===h&&(d=!0,error_type="required",b.markError(e,error_type));break;case"accept":!1==a(e).prop("checked")&&(d=!0,error_type="required",b.markError(e,error_type));break;case"select":h=a(e).val(),a(e).prop("multiple")?(null===h||0===h.length)&&(d=!0,error_type="required",b.markError(e,error_type)):(!h||"-1"===h)&&(d=!0,error_type="required",b.markError(e,error_type));break;case"radio":var g=a(e).find("input:checked").length;g||(d=!0,error_type="required",b.markError(e,error_type));break;case"checkbox":var g=a(e).find("input:checked").length;g||(d=!0,error_type="required",b.markError(e,error_type));break;case"email":var h=a(e).val();""===h?""===h&&(d=!0,error_type="required",b.markError(e,error_type)):!b.isValidEmail(h)&&(d=!0,error_type="validation",b.markError(e,error_type));break;case"url":var h=a(e).val();""===h||b.isValidURL(h)||(d=!0,error_type="validation",b.markError(e,error_type));}}),d)return b.addErrorNotice(c),!1;var f=c.serialize();return f=f+"&_kb_form_verify="+kadence_blocks_form_params.nonce,f}};b.init()});