var wpforms=window.wpforms||function(s,p,d){const l={cache:{},isUpdatingToken:!1,init(){d(l.ready),d(p).on("load",function(){"function"==typeof d.ready.then?d.ready.then(l.load):l.load()}),l.bindUIActions(),l.bindOptinMonster()},ready(){l.clearUrlQuery(),l.setUserIdentifier(),l.loadValidation(),l.loadHoneypot(),l.loadDatePicker(),l.loadTimePicker(),l.loadInputMask(),l.loadSmartPhoneField(),l.loadPayments(),l.loadMailcheck(),l.loadChoicesJS(),l.initTokenUpdater(),l.restoreSubmitButtonOnEventPersisted(),l.bindSmartPhoneField(),l.bindChoicesJS(),d(".wpforms-randomize").each(function(){for(var e=d(this),t=e.children();t.length;)e.append(t.splice(Math.floor(Math.random()*t.length),1)[0])}),d(".wpforms-page-button").prop("disabled",!1),l.initFormsStartTime(),d(s).trigger("wpformsReady"),d(".wpforms-smart-phone-field").each(function(){l.repairSmartPhoneHiddenField(d(this))})},load(){},clearUrlQuery(){var e=p.location;let t=e.search;-1!==t.indexOf("wpforms_form_id=")&&(t=t.replace(/([&?]wpforms_form_id=[0-9]*$|wpforms_form_id=[0-9]*&|[?&]wpforms_form_id=[0-9]*(?=#))/,""),history.replaceState({},null,e.origin+e.pathname+t))},loadHoneypot(){d(".wpforms-form").each(function(){const e=d(this),t=e.data("formid"),r=[],a=[];var i,o,s,n;void 0!==wpforms_settings.hn_data[t]&&(d(`#wpforms-form-${t} .wpforms-field`).each(function(){var e=d(this);r.push(e.data("field-id")),a.push(e.find(".wpforms-field-label").text())}),i=l.getHoneypotRandomLabel(a.join(" ").split(" ")),o=l.getHoneypotFieldId(r),n=r[Math.floor(Math.random()*r.length)],s=`wpforms-${t}-field_`+o,d(`#wpforms-${t}-field_${n}-container`,e).before(`
`),(n=d(`#wpforms-${t}-field_${wpforms_settings.hn_data[t]}-container`,e)).find("input").attr({tabindex:"-1","aria-hidden":"true"}),n.find("label").attr("aria-hidden","true"))})},getHoneypotRandomLabel(t){let r="";for(let e=0;e<3;e++)r+=t[Math.floor(Math.random()*t.length)]+" ";return r.trim()},getHoneypotFieldId(t){var r=Math.max(...t);let a=0;for(let e=1;ea)return!1;return!0},wpforms_settings.val_filesize),d.validator.addMethod("step",function(e,t,r){o=r;const a=Math.floor(o)!==o&&o.toString().split(".")[1].length||0;function i(e){return Math.round(e*Math.pow(10,a))}var o=i(d(t).attr("min"));return e=i(e)-o,this.optional(t)||i(e)%i(r)==0}),d.validator.methods.email=function(e,t){return this.optional(t)||function(e){if("string"!=typeof e)return!1;var t=e.indexOf("@",1);if(e.length<6||254=Number(r.data("password-strength-level"))},wpforms_settings.val_password_strength),d(".wpforms-validate").each(function(){var e=d(this),t=e.data("formid");let r;r=void 0!==p["wpforms_"+t]&&p["wpforms_"+t].hasOwnProperty("validate")?p["wpforms_"+t].validate:"undefined"!=typeof wpforms_validate?wpforms_validate:{errorElement:l.isModernMarkupEnabled()?"em":"label",errorClass:"wpforms-error",validClass:"wpforms-valid",ignore:":hidden:not(textarea.wp-editor-area), .wpforms-conditional-hide textarea.wp-editor-area",ignoreTitle:!0,errorPlacement(e,t){l.isLikertScaleField(t)?(t.closest("table").hasClass("single-row")?t.closest(".wpforms-field"):t.closest("tr").find("th")).append(e):l.isWrappedField(t)?t.closest(".wpforms-field").append(e):l.isDateTimeField(t)?l.dateTimeErrorPlacement(t,e):l.isFieldInColumn(t)||l.isFieldHasHint(t)?t.parent().append(e):l.isLeadFormsSelect(t)?t.parent().parent().append(e):t.hasClass("wp-editor-area")?t.parent().parent().parent().append(e):e.insertAfter(t),l.isModernMarkupEnabled()&&e.attr({role:"alert","aria-label":wpforms_settings.errorMessagePrefix,for:""})},highlight(e,t,r){var a=d(e),i=a.closest(".wpforms-field"),o=a.attr("name");("radio"===a.attr("type")||"checkbox"===a.attr("type")?i.find('input[name="'+o+'"]'):a).addClass(t).removeClass(r),"password"===a.attr("type")&&""===a.val().trim()&&p.WPFormsPasswordField&&a.data("rule-password-strength")&&a.hasClass("wpforms-field-required")&&WPFormsPasswordField.passwordStrength("",e),i.addClass("wpforms-has-error")},unhighlight(e,t,r){var e=d(e),a=e.closest(".wpforms-field"),i=e.attr("name");("radio"===e.attr("type")||"checkbox"===e.attr("type")?a.find('input[name="'+i+'"]'):e).addClass(r).removeClass(t),a.find(":input.wpforms-error,[data-dz-errormessage]:not(:empty)").length||a.removeClass("wpforms-has-error"),l.isModernMarkupEnabled()&&e.parent().find("em.wpforms-error").remove()},submitHandler(s){function n(e,t){let r="label",a="";l.isModernMarkupEnabled()&&(r="em",a='role="alert"');var i=`<${r} id="wpforms-field_recaptcha-error" class="wpforms-error" ${a}> ${wpforms_settings.val_recaptcha_fail_msg}${r}>`;e.find(".wpforms-recaptcha-container").append(i),l.restoreSubmitButton(e,t)}function e(){const e=d(s),t=e.closest(".wpforms-container"),r=e.find(".wpforms-submit"),a=r.data("captchaInvalid"),i=r.data("alt-text"),o=r.get(0).recaptchaID;return e.data("token")&&0===d(".wpforms-token",e).length&&d('').val(e.data("token")).appendTo(e),e.find("#wpforms-field_recaptcha-error").remove(),r.prop("disabled",!0),WPFormsUtils.triggerEvent(e,"wpformsFormSubmitButtonDisable",[e,r]),i&&r.text(i),a?n(e,t):l.empty(o)&&0!==o?(d(".wpforms-input-temp-name").removeAttr("name"),void l.formSubmit(e)):(grecaptcha.execute(o).then(null,function(){grecaptcha.getResponse()||n(e,t)}),!1)}return"function"==typeof wpformsRecaptchaV3Execute?wpformsRecaptchaV3Execute(e):e()},invalidHandler(e,t){void 0!==t.errorList[0]&&l.scrollToError(d(t.errorList[0].element))},onkeyup:WPFormsUtils.debounce(function(e,t){d(e).hasClass("wpforms-novalidate-onkeyup")||9===t.which&&""===this.elementValue(e)||-1!==d.inArray(t.keyCode,[16,17,18,20,35,36,37,38,39,40,45,144,225])||(e.name in this.submitted||e.name in this.invalid)&&this.element(e)},1e3),onfocusout:function(e){let t=!1;d(e).hasClass("wpforms-novalidate-onkeyup")&&!e.value&&(t=!0),this.checkable(e)||!(e.name in this.submitted)&&this.optional(e)||(t=!0),(t=d(e).data("server-error")?!1:t)&&this.element(e)},onclick(e){let t=!1;var r=(e||{}).type;let a=d(e);-1<["checkbox","radio"].indexOf(r)&&((a=a.hasClass("wpforms-likert-scale-option")?a.closest("tr"):a.closest(".wpforms-field")).find("label.wpforms-error, em.wpforms-error").remove(),t=!0),t&&this.element(e)}},e.validate(r)}))},restrictedEmailRequest(r,a){var e=d(r),t=e.closest("form");const i=t.data("validator"),o=t.data("formid");t=e.closest(".wpforms-field").data("field-id");l.cache[o]=l.cache[o]||{},i.startRequest(r),d.post({url:wpforms_settings.ajaxurl,type:"post",data:{action:"wpforms_restricted_email",form_id:o,field_id:t,email:a},dataType:"json",success(e){var t={},e=e.success&&e.data;e||(t[r.name]=wpforms_settings.val_email_restricted,i.showErrors(t)),l.cache[o].restrictedEmailValidation=l.cache[o].restrictedEmailValidation||[],Object.prototype.hasOwnProperty.call(l.cache[o].restrictedEmailValidation,a)||(l.cache[o].restrictedEmailValidation[a]=e),i.stopRequest(r,e)}})},isFieldInColumn(e){return e.parent().hasClass("wpforms-one-half")||e.parent().hasClass("wpforms-two-fifths")||e.parent().hasClass("wpforms-one-fifth")},isFieldHasHint(e){return 0e.toLowerCase()),e.preferredCountries=e.preferredCountries.map(e=>e.toLowerCase()),p.intlTelInput(t[0],e),t.siblings('input[type="hidden"]').each(function(){var e=d(this);e.attr("name",e.attr("name").replace("wpf-temp-",""))}))})},repairSmartPhoneHiddenField(r){var a=r.closest(".wpforms-field-phone").data("field-id");if(!d('[name="wpforms[fields]['+a+']"]').length){a=r.data("plugin_intlTelInput");let e=r.val(),t={};a&&(t=a.d||a.options||{},e=a.getNumber(),a.destroy()),r.removeData("plugin_intlTelInput"),r.val(e),l.initSmartPhoneField(r,t)}},getDefaultSmartPhoneFieldOptions(){var e,t={countrySearch:!1,fixDropdownWidth:!1,preferredCountries:["us","gb"],countryListAriaLabel:wpforms_settings.country_list_label};wpforms_settings.gdpr||(t.geoIpLookup=l.currentIpToCountry);let r;if(wpforms_settings.gdpr&&(e=l.mapLanguageToIso(this.getFirstBrowserLanguage()),r=-1'"()/\\|:;=@%&\s]/gi,"").substr(0,64),a=decodeURI(t.domain).replaceAll(/[<>'"()/\\|:;=@%&+_\s]/gi,"");t=''+r+"@"+a+"",t=wpforms_settings.val_email_suggestion.replace("{suggestion}",t),e.closest(".wpforms-field").find("#"+i+"_suggestion").remove(),e.parent().append('")},empty(){d("#"+i+"_suggestion").remove()}})}),d(s).on("click",".wpforms-field-email .mailcheck-suggestion",function(e){var t=d(this),r=t.closest(".wpforms-field"),a=t.data("id");e.preventDefault(),r.find("#"+a).val(t.text()),t.parent().remove()}))},loadChoicesJS(o){"function"==typeof p.Choices&&(o=o?.length?o:d(s)).find(".wpforms-field-select-style-modern .choicesjs-select, .wpforms-field-payment-select .choicesjs-select").each(function(e,t){var r,a,i;d(t).data("choicesjs")||WPFormsUtils.triggerEvent(o,"wpformsBeforeLoadElementChoices",[t]).isDefaultPrevented()||(r=p.wpforms_choicesjs_config||{},a=d(t).data("search-enabled"),i=d(t).data("remove-items-enabled"),r.searchEnabled=void 0===a||a,r.removeItems=void 0===i||i,r.removeItemButton=r.removeItems,r.searchEnabled=void 0===a||a,r.allowHTML=!0,r.callbackOnInit=function(){const t=this,r=d(t.passedElement.element),a=d(t.input.element),e=r.data("size-class");r.removeAttr("hidden").addClass(t.config.classNames.input+"--hidden"),e&&d(t.containerOuter.element).addClass(e),r.prop("multiple")&&(a.data("placeholder",a.attr("placeholder")).css("width","auto"),t.getValue(!0).length&&a.removeAttr("placeholder"),a.css("width","1ch")),r.on("change",function(){r.prop("multiple")&&(t.getValue(!0).length?a.removeAttr("placeholder"):a.attr("placeholder",a.data("placeholder")).css("width","auto"));var e=r.closest("form").data("validator");e&&e.element(r)})},r.callbackOnCreateTemplates=function(){const r=d(this.passedElement.element);return{option(e){var t=Choices.defaults.templates.option.call(this,e);return void 0!==e.placeholder&&!0===e.placeholder&&t.classList.add("placeholder"),r.hasClass("wpforms-payment-price")&&void 0!==e.customProperties&&null!==e.customProperties&&(t.dataset.amount=e.customProperties),t}}},d(t).data("choicesjs",new Choices(t,r)))})},bindChoicesJS(){d(s).on("click",".choices",function(e){var t=d(this),r=t.find("select").data("choicesjs");r&&t.hasClass("is-open")&&(e.target.classList.contains("choices__inner")||e.target.classList.contains("choices__arrow"))&&r.hideDropdown()})},bindUIActions(){var e=d(s);e.on("click",".wpforms-page-button",function(e){e.preventDefault(),l.pagebreakNav(this)}),e.on("change input",".wpforms-payment-price",function(){l.amountTotal(this,!0)}),e.on("change input","select.wpforms-payment-quantity",function(){l.amountTotal(this,!0),l.updateOrderSummaryItemQuantity(d(this))}),e.on("input",".wpforms-payment-user-input",function(){var e=d(this),t=e.val();e.val(t.replace(/[^0-9.,]/g,""))}),e.on("focusout",".wpforms-payment-user-input",function(){var e=d(this),t=e.val();if(!t)return t;t=l.amountSanitize(t),t=l.amountFormat(t);e.val(t)}),e.on("wpformsProcessConditionals",function(e,t){l.amountTotal(t,!0)}),e.on("mouseenter",".wpforms-field-rating-item",function(){d(this).parent().find(".wpforms-field-rating-item").removeClass("selected hover"),d(this).prevAll().addBack().addClass("hover")}).on("mouseleave",".wpforms-field-rating-item",function(){d(this).parent().find(".wpforms-field-rating-item").removeClass("selected hover"),d(this).parent().find("input:checked").parent().prevAll().addBack().addClass("selected")}),d(s).on("change",".wpforms-field-rating-item input",function(){var e=d(this),t=e.closest(".wpforms-field-rating-items").find(".wpforms-field-rating-item");e.focus(),t.removeClass("hover selected"),e.parent().prevAll().addBack().addClass("selected")}),d(function(){d(".wpforms-field-rating-item input:checked").trigger("change")}),e.on("keydown",".wpforms-image-choices-item label",function(e){var t=d(this);if(t.closest(".wpforms-field").hasClass("wpforms-conditional-hide"))return e.preventDefault(),!1;32===e.keyCode&&(t.find("input").trigger("click"),e.preventDefault())}),p.document.documentMode&&e.on("click",".wpforms-image-choices-item img",function(){d(this).closest("label").find("input").trigger("click")}),e.on("change",".wpforms-field-checkbox input, .wpforms-field-radio input, .wpforms-field-payment-multiple input, .wpforms-field-payment-checkbox input, .wpforms-field-gdpr-checkbox input",function(e){var t=d(this);if(t.closest(".wpforms-field").hasClass("wpforms-conditional-hide"))return e.preventDefault(),!1;switch(t.attr("type")){case"radio":t.closest("ul").find("li").removeClass("wpforms-selected").find("input[type=radio]").removeProp("checked"),t.prop("checked",!0).closest("li").addClass("wpforms-selected");break;case"checkbox":t.is(":checked")?(t.closest("li").addClass("wpforms-selected"),t.prop("checked",!0)):(t.closest("li").removeClass("wpforms-selected"),t.prop("checked",!1))}}),e.on("input",".wpforms-field-file-upload",function(){var e=d(this),t=e.closest("form.wpforms-form").find('.wpforms-field-file-upload input:not(".dropzone-input")');let a=0,r=Number(wpforms_settings.post_max_size),i=''+wpforms_settings.val_post_max_size+"
";e=e.closest("form.wpforms-form").find(".wpforms-submit-container");let o=e.find("button.wpforms-submit"),s=e.prev();var n=o.closest("form"),l=n.find(".wpforms-page-next:visible");0!==n.find(".wpforms-page-indicator").length&&0!==l.length&&(o=l),t.each(function(){var e=d(this);let t=0;for(var r=e[0].files.length;t{errorMsg}'.replace(/{errorMsg}/,i)),s=e.prev()),o.prop("disabled",!0),WPFormsUtils.triggerEvent(n,"wpformsFormSubmitButtonDisable",[n,o]),WPFormsUtils.triggerEvent(n,"wpformsCombinedUploadsSizeError",[n,s]))}),e.on("change input",".wpforms-field-number-slider input[type=range]",function(e){var t=d(e.target).siblings(".wpforms-field-number-slider-hint");t.html(t.data("hint").replaceAll("{value}",""+e.target.value+""))}),e.on("keydown",".wpforms-form input",function(e){var t,r;13!==e.keyCode||0===(r=(t=d(this)).closest(".wpforms-page")).length||["text","tel","number","email","url","radio","checkbox"].indexOf(t.attr("type"))<0||(t.hasClass("wpforms-datepicker")&&t.flatpickr("close"),e.preventDefault(),(r.hasClass("last")?r.closest(".wpforms-form").find(".wpforms-submit"):r.find(".wpforms-page-next")).trigger("click"))}),e.on("keypress",".wpforms-field-number input",function(e){return/^[-0-9.]+$/.test(String.fromCharCode(e.keyCode||e.which))}),e.one("input",".wpforms-field input, .wpforms-field textarea, .wpforms-field select",l.formChanged).one("change",".wpforms-field-select-style-modern, .wpforms-timepicker",l.formChanged).one("focus",".dropzone-input",l.formChanged).one("click touchstart",".wpforms-signature-canvas",l.formChanged).one("wpformsRichTextContentChange",l.richTextContentChanged),d("form.wpforms-form").on("wpformsBeforePageChange",l.skipEmptyPages)},skipEmptyPages(e,t,r,a){var i=l.findNonEmptyPage(t,r,a);i!==t&&(e.preventDefault(),1===i&&"prev"===a?(e=r.find(".wpforms-page-2"),a=r.find(".wpforms-page-"+t),t=(e.find(".wpforms-page-prev").length?e:a).find(".wpforms-page-prev"),wpforms.navigateToPage(t,"prev",2,r,e)):(t=r.find(".wpforms-page-"+(a=i-1)),wpforms.navigateToPage(t.find(".wpforms-page-next"),"next",a,r,t)))},findNonEmptyPage(e,t,r){let a=e;for(;l.isEmptyPage(t,a);)"prev"===r?a--:a++;return a},isEmptyPage(e,t){return 1!==t&&!(e=e.find(".wpforms-page-"+t)).hasClass("last")&&(t=e.find(".wpforms-field:not(.wpforms-field-pagebreak):not(.wpforms-field-hidden)"),e.find(".wpforms-conditional-hide").length===t.length)},formChanged(e){var t=d(this).closest(".wpforms-form");l.maybeSetStartTime(t)},richTextContentChanged(e,t,r){r=r.getContainer(),r=d(r).closest(".wpforms-form");l.maybeSetStartTime(r)},initFormsStartTime(){d(".wpforms-form").each(function(){l.maybeSetStartTime(d(this))})},maybeSetStartTime(e){e.data("start_timestamp")||e.data("start_timestamp",Date.now())},entryPreviewFieldPageChange(e,t,r){console.warn("WARNING! Obsolete function called. Function wpforms.entryPreviewFieldPageChange has been deprecated, please use the WPFormsEntryPreview.pageChange function instead!"),WPFormsEntryPreview.pageChange(e,t,r)},entryPreviewFieldUpdate(e,t){console.warn("WARNING! Obsolete function called. Function wpforms.entryPreviewFieldUpdate has been deprecated, please use the WPFormsEntryPreview.update function instead!"),WPFormsEntryPreview.update(e,t)},scrollToError(e){if(0!==e.length){let t=e.find(".wpforms-field.wpforms-has-error");0!==(t=0===t.length?e.closest(".wpforms-field"):t).length&&void 0!==(e=t.offset())&&l.animateScrollTop(e.top-75,750).done(function(){var e=t.find(".wpforms-error").first();"function"==typeof e.focus&&e.trigger("focus")})}},pagebreakNav(e){const t=d(e),r=t.data("action"),a=t.data("page"),i=t.closest(".wpforms-form"),o=i.find(".wpforms-page-"+a);l.saveTinyMCE(),"next"===r&&void 0!==d.fn.validate?l.checkForInvalidFields(i,o,function(){l.navigateToPage(t,r,a,i,o)}):"prev"!==r&&"next"!==r||l.navigateToPage(t,r,a,i,o)},checkForInvalidFields(e,t,r){var a=e.data("validator");if(a)if(0'),o.render(i,{sitekey:a,callback(){wpformsRecaptchaCallback(d("#"+i))}})}},amountTotal(e,t){t=t||!1;const r=d(e),a=r.closest(".wpforms-form"),i=l.amountTotalCalc(a);if(l.allowAmountTotalCalc(a,r,i)){const o=l.amountFormatSymbol(i);a.find(".wpforms-payment-total").each(function(){"hidden"===d(this).attr("type")||"text"===d(this).attr("type")?(d(this).val(o),"text"===d(this).attr("type")&&t&&a.data("validator")&&d(this).valid()):d(this).text(o)}),l.updateOrderSummaryItems(a,r,o)}},allowAmountTotalCalc(e,t,r){var e=e.data("formid");return l.getCache(e,"amountTotal")!==r?(l.updateCache(e,"amountTotal",r),!0):"radio"===(e=t.prop("type"))||"select-one"===e},updateOrderSummaryItems(t,e,r){t.find(".wpforms-order-summary-preview").each(function(){const e=d(this);""!==r&&e.find(".wpforms-order-summary-preview-total .wpforms-order-summary-item-price").text(r),t.find(".wpforms-payment-price").each(function(){l.updateOrderSummaryItem(d(this),e)})})},updateCache(e,t,r){l.cache[e]=l.cache[e]||{},l.cache[e][t]=r},getCache(e,t){return!(!Object.prototype.hasOwnProperty.call(l.cache,e)||!Object.prototype.hasOwnProperty.call(l.cache[e],t))&&l.cache[e][t]},updateOrderSummaryItem(e,t){if(e.hasClass("wpforms-payment-price")){const i=e.closest(".wpforms-field"),o=i.data("field-id"),s=e.prop("type"),n="block"===i.css("display");var r,a;"checkbox"===s||"radio"===s||"select-one"===s?t.find(`tr[data-field="${o}"]`).each(function(){var e=d(this).data("choice"),e="select-one"===s?e===parseInt(i.find("select").val(),10):i.find(`input[value="${e}"]`).is(":checked");d(this).toggle(n&&e)}):(r=t.find(`tr[data-field="${o}"]`),a=e.val(),r.find(".wpforms-order-summary-item-price").text(l.amountFormatSymbol(l.amountSanitize(a))),r.toggle(n)),i.hasClass("wpforms-payment-quantities-enabled")?l.updateOrderSummaryItemQuantity(e):(l.updateSummaryPriceWidth(t),l.toggleSummaryPlaceholder(t))}},updateOrderSummaryItemQuantity(e){const t=e.closest(".wpforms-field"),a=t.find("input.wpforms-payment-price, select.wpforms-payment-price"),r=e.closest(".wpforms-form"),i=t.data("field-id"),o=l.getPaymentFieldQuantity(a),s=l.getPaymentFieldAmount(a),n=a.prop("type");r.find(".wpforms-order-summary-preview").each(function(){var e,t=d(this);let r;(r="checkbox"===n||"radio"===n||"select-one"===n?(e=a.val(),t.find(`tr[data-field="${i}"][data-choice="${e}"]`)):t.find(`tr[data-field="${i}"]`)).toggle(0'),e.append(''),e.get(0).submit())},formHasCaptcha(e){return!(!e||!e.length||"undefined"==typeof hcaptcha&&"undefined"==typeof grecaptcha&&"undefined"==typeof turnstile)&&(e=e.find(".wpforms-recaptcha-container"),Boolean(e.length))},resetFormRecaptcha(r){if(l.formHasCaptcha(r)){var a=r.find(".wpforms-recaptcha-container");let e,t;e=a.hasClass("wpforms-is-hcaptcha")?hcaptcha:a.hasClass("wpforms-is-turnstile")?turnstile:grecaptcha,t=r.find(".wpforms-submit").get(0).recaptchaID,l.empty(t)&&0!==t&&(t=r.find(".g-recaptcha").data("recaptcha-id")),l.empty(t)&&0!==t||e.reset(t)}},consoleLogAjaxError(e){e?console.error("WPForms AJAX submit error:\n%s",e):console.error("WPForms AJAX submit error")},displayFormAjaxErrors(e,t){"string"==typeof t?l.displayFormAjaxGeneralErrors(e,t):(t=t&&"errors"in t?t.errors:null,l.empty(t)||l.empty(t.general)&&l.empty(t.field)?l.consoleLogAjaxError():(l.empty(t.general)||l.displayFormAjaxGeneralErrors(e,t.general),l.empty(t.field)||l.displayFormAjaxFieldErrors(e,t.field)))},displayFormAjaxGeneralErrors(e,t){var r,a;e&&e.length&&(l.empty(t)||(l.isModernMarkupEnabled()&&e.attr({"aria-invalid":"true","aria-errormessage":""}),"string"==typeof t?(a=l.isModernMarkupEnabled()?' role="alert"':"",r=l.isModernMarkupEnabled()?`${wpforms_settings.formErrorMessagePrefix}`:"",e.find(".wpforms-submit-container").before(`${r}${t}
`),l.setCurrentPage(e,{})):(a=e.data("formid"),l.printGeneralErrors(e,t,a))))},printGeneralErrors(i,e,o){d.each(e,function(e,t){switch(e){case"header":case"header_styled":i.prepend(t);break;case"footer":case"footer_styled":r=t,0===i.find(".wpforms-page-indicator").length?i.find(".wpforms-submit-container").before(r):i.find(".wpforms-page-1").append(r);break;case"recaptcha":r=t,i.find(".wpforms-recaptcha-container").append(r)}var r,a;l.isModernMarkupEnabled()&&(a=i.attr("aria-errormessage")||"",i.attr("aria-errormessage",a+` wpforms-${o}-${e}-error`))}),i.find(".wpforms-error-container").length&&l.animateScrollTop(i.find(".wpforms-error-container").first().offset().top-100)},clearFormAjaxGeneralErrors(e){e.find(".wpforms-error-container").remove(),e.find("#wpforms-field_recaptcha-error").remove(),l.isModernMarkupEnabled()&&e.attr({"aria-invalid":"false","aria-errormessage":""})},displayFormAjaxFieldErrors(r,e){var t;r&&r.length&&(l.empty(e)||(t=r.data("validator"))&&(e=l.splitFieldErrors(e),d.each(e,function(e,t){d('[name="'+e+'"]',r).attr("data-server-error",t)}),t.showErrors(e),l.formHasCaptcha(r)||t.focusInvalid()))},splitFieldErrors:o=>(d.each(o,function(i,e){"string"!=typeof e&&d.each(e,function(e,t){var r=i.split("[").pop().replace("]",""),a=i.replace("["+r+"]","");r===e?o[i]=t:"string"==typeof e&&isNaN(e)&&(o[a+"["+e+"]"]=t)})}),o),formSubmitAjax:a=>{if(!a.length)return d.Deferred().reject();const r=a.closest(".wpforms-container"),e=a.find(".wpforms-submit-spinner");let i;r.css("opacity",.6),e.show(),l.clearFormAjaxGeneralErrors(a);var t=new FormData(a.get(0)),t=(t.append("action","wpforms_submit"),t.append("start_timestamp",a.data("start_timestamp")),t.append("end_timestamp",Date.now()),{type:"post",dataType:"json",url:wpforms_settings.ajaxurl,data:t,cache:!1,contentType:!1,processData:!1});return t.success=function(e){var t;if(e)if(e.data&&e.data.action_required)a.trigger("wpformsAjaxSubmitActionRequired",e);else if(e.success){if(a.trigger("wpformsAjaxSubmitSuccess",e),e.data)return e.data.redirect_url?(t=e.data.new_tab||!1,a.trigger("wpformsAjaxSubmitBeforeRedirect",e),t?(p.open(e.data.redirect_url,"_blank"),void location.reload()):void(p.location=e.data.redirect_url)):void(e.data.confirmation&&(r.html(e.data.confirmation),i=r.find("div.wpforms-confirmation-scroll"),r.trigger("wpformsAjaxSubmitSuccessConfirmation",e),i.length)&&l.animateScrollTop(i.offset().top-100))}else l.resetFormRecaptcha(a),l.displayFormAjaxErrors(a,e.data),a.trigger("wpformsAjaxSubmitFailed",e),l.setCurrentPage(a,e.data);else l.consoleLogAjaxError()},t.error=function(e,t,r){l.consoleLogAjaxError(r),a.trigger("wpformsAjaxSubmitError",[e,t,r])},t.complete=function(e,t){e.responseJSON&&e.responseJSON.data&&(e.responseJSON.data.action_required||"success"===t&&e.responseJSON.data.redirect_url)||(l.restoreSubmitButton(a,r),a.trigger("wpformsAjaxSubmitCompleted",[e,t]))},WPFormsUtils.triggerEvent(a,"wpformsAjaxBeforeSubmit",[a]).isDefaultPrevented()?(l.restoreSubmitButton(a,r),d.Deferred().reject()):d.ajax(t)},setCurrentPage(r,a){if(0!==r.find(".wpforms-page-indicator").length){const o=[];if(r.find(".wpforms-page").each(function(e,t){if(1<=d(t).find(".wpforms-has-error").length)return o.push(d(t))}),0!==o.length||void 0===a.errors||void 0===a.errors.general||void 0!==a.errors.general.footer||void 0===a.errors.general.recaptcha){var i=0=1e3*wpforms_settings.token_cache_lifetime&&!this.isUpdatingToken},updateToken(t,r,a){var e=r.data("formid");const i=r.find(".wpforms-submit");this.isUpdatingToken=!0,i.prop("disabled",!0),d.post(wpforms_settings.ajaxurl,{action:"wpforms_get_token",formId:e}).done(function(e){e.success?(r.attr("data-token-time",t),r.attr("data-token",e.data.token),i.prop("disabled",!1),a.target===i[0]&&i.trigger("click")):console.error("Failed to update token: ",e)}).fail(function(e,t,r){console.error("AJAX request failed: ",t,r)}).always(function(){this.isUpdatingToken=!1,i.prop("disabled",!1)}.bind(this))},restoreSubmitButtonOnEventPersisted(){p.onpageshow=function(e){e.persisted&&d(".wpforms-form").each(function(){var e=d(this);l.restoreSubmitButton(e,e.closest(".wpforms-container"))})}}};return l}(document,window,jQuery);wpforms.init();