"use strict";var WPFormsStripeElements=window.WPFormsStripeElements||function(n,t,o){const l={stripe:null,lockedPageToSwitch:0,init:function(){l.stripe=Stripe(wpforms_stripe.publishable_key,{locale:wpforms_stripe.data.element_locale}),o(n).on("wpformsReady",function(){o(".wpforms-stripe form").filter((e,t)=>"number"==typeof o(t).data("formid")).each(l.setupStripeForm)}),o(n).on("wpformsBeforePageChange",l.pageChange)},setupStripeForm:function(){var e=o(this);l.updateFormSubmitHandler(e),e.on("wpformsAjaxSubmitActionRequired",l.handleCardActionCallback),l.updateCardElementStylesModern(e)},setupCardElement:function(r,i){const s=r.find(".wpforms-stripe-credit-card-hidden-input");if(s&&0!==s.length){var t=s.data("stripe-element");if(!t){let e=wpforms_stripe.data.element_style;o.isEmptyObject(e)&&(e=l.getElementStyleDefault(s));var a={classes:wpforms_stripe.data.element_classes,hidePostalCode:!0,style:e};(t=l.stripe.elements().create("card",a)).mount(r.find(".wpforms-field-stripe-credit-card-cardnumber").get(0)),t.on("change",function(t){if(t.error){let e=t.error.message;"incomplete_number"!==t.error.code&&"invalid_number"!==t.error.code||(e=wpforms_settings.val_creditcard),l.displayStripeError(r,e)}else i.hideThese(i.errorsFor(s.get(0)))}),t.on("focus",function(){o(n).trigger("wpformsStripePaymentElementFocus",[r])}),s.data("stripe-element",t)}return t}},getElementStyleDefault:function(t){if(t&&0!==t.length){var r=t.css("color"),i=t.css("font-size"),i={base:{fontSize:i,color:r,"::placeholder":{color:r,fontSize:i}},invalid:{color:r}};let e=t.css("font-family");r=/[“”<>!@$%^&*=~`|{}[\]]/;return!r.test(e)&&-1===e.indexOf("MS Shell Dlg")||(e=o("p").css("font-family")),r.test(e)||(i.base.fontFamily=e,i.base["::placeholder"].fontFamily=e),i}},updateFormSubmitHandler:function(a){let e=a.validate(),n=e.settings.submitHandler,o=l.setupCardElement(a,e),d=a.find(".wpforms-field-stripe-credit-card-cardnumber");e.settings.submitHandler=function(){let e=a.validate().form(),t=d.hasClass(wpforms_stripe.data.element_classes.empty),r=d.data("required"),i=d.closest(".wpforms-field-stripe-credit-card").hasClass("wpforms-conditional-hide"),s=i?!1:r||!t&&!r;if(e&&s)a.find(".wpforms-submit").prop("disabled",!0),l.createPaymentMethod(a,o,r,n);else{if(e)return a.find(".wpforms-submit").prop("disabled",!1),n(a);a.find(".wpforms-submit").prop("disabled",!1),a.validate().cancelSubmit=!0}}},createPaymentMethod:function(t,e,r,i){l.stripe.createPaymentMethod("card",e,{billing_details:{name:t.find(".wpforms-field-stripe-credit-card-cardname").val()}}).then(function(e){e.error&&r?(t.find(".wpforms-submit").prop("disabled",!1),l.displayStripeError(t,e.error.message),t.validate().cancelSubmit=!0):(e.error||(t.find(".wpforms-stripe-payment-method-id").remove(),e.paymentMethod&&t.append('')),i(t))})},handleCardActionCallback:function(e,t){const r=o(this);t.success&&t.data.action_required&&l.stripe.handleCardPayment(t.data.payment_intent_client_secret,{payment_method:t.data.payment_method_id}).then(function(e){l.handleCardPaymentCallback(r,e)})},handleCardPaymentCallback:function(e,t){t.error?(l.formAjaxUnblock(e),e.find(".wpforms-field-stripe-credit-card-cardnumber").addClass(wpforms_stripe.data.element_classes.invalid),l.displayStripeError(e,t.error.message)):t.paymentIntent&&"succeeded"===t.paymentIntent.status?(e.find(".wpforms-stripe-payment-method-id").remove(),e.find(".wpforms-stripe-payment-intent-id").remove(),e.append(''),wpforms.formSubmitAjax(e)):l.formAjaxUnblock(e)},displayStripeError:function(e,t){var r=e.find(".wpforms-stripe-credit-card-hidden-input").attr("name"),i=e.find(".wpforms-field-stripe-credit-card-cardnumber"),s={};s[r]=t,wpforms.displayFormAjaxFieldErrors(e,s),!i.is(":visible")&&0