(()=>{var e={1669:e=>{"use strict";e.exports=jQuery}},t={},a=function a(d){var n=t[d];if(void 0!==n)return n.exports;var r=t[d]={exports:{}};return e[d](r,r.exports,a),r.exports}(1669);!function(e,t){"use strict";const a=edd_global_vars.edd_eu_countries;function d(){const e=t("#edd-card-vat-wrap");e.length&&(t("#billing_country").on("change",d),a.includes(t("#billing_country").val())?e.show():(e.hide(),o()))}t(e.body).on("edd_gateway_loaded",(function(e,t){d()}));const n=edd_global_vars.checkout_updated_cart_selector,r=edd_global_vars.checkout_form_selector;function o(){t("#edd-vat-check-result").remove()}function c(e,t){e.append('<div id="edd-vat-check-result" class="edd_errors edd-alert edd-alert-error"><p class="edd_error">'+t+"</p></div>")}const s=function(a){const d=t("#edd-card-vat-wrap"),s=t("#billing_country").val(),l=t("#edd-vat-number"),i=l.val(),u=t("#edd-vat-check-button");if(!d.length)return!1;if(d.data("check"))return!1;if(o(),!i)return c(d,edd_global_vars.messages.vat_number_missing),!1;if(!s)return c(d,edd_global_vars.messages.country_missing),!1;l.prop("disabled",!0),u.prop("disabled",!0);const _=e.createElement("span");_.classList.add("edd-loading","edd-loading-ajax"),u.before(_);const v={action:"edd_vat_check",billing_country:s,vat_number:i,nonce:t("#edd-checkout-address-fields-nonce").val(),current_page:edd_global_vars.current_page};return d.data("check",!0),t(e.body).trigger("edd_eu_vat:before_vat_check",v),t.ajax({type:"POST",data:v,dataType:"json",url:edd_global_vars.ajaxurl,xhrFields:{withCredentials:!0}}).done((function(a,o,s){if(200==s.status&&void 0!==a.html){let o=t(t.parseHTML(a.html.trim())).filter(n);o.length&&t(r).replaceWith(o),t(".edd_cart_amount").html(a.total),d.append(a.vat_check_result);const c={postdata:v,response:a};t(e.body).trigger("edd_taxes_recalculated",c).trigger("edd_eu_vat:vat_check",a)}else c(d,edd_global_vars.messages.ajax_error)})).fail((function(e,t,a){c(d,edd_global_vars.messages.ajax_error)})).always((function(){u.prop("disabled",!1),l.prop("disabled",!1),d.data("check",!1),_.remove(),t(e.body).trigger("edd_eu_vat:vat_check_complete")})),!1};function l(){const e=t("#edd-vat-number");if(!e.length)return;const a=t("#edd-vat-check-button"),d=e.val().trim().length>0;a.prop("disabled",!d)}t((function(){t("#edd_purchase_form").on("click","#edd-vat-check-button",s).on("change","#billing_country",(function(e){const a=t("#edd-vat-check-result").data();a?.valid&&a?.country!==t(this).val()&&(t("#edd-vat-number").val(""),o()),d()})).on("change","#edd-stripe-update-billing-address",(function(e){d()})).on("change","#edd-vat-show-fields",(function(e){const a=t(this).is(":checked"),d=t("#edd-vat-fields-wrap"),n=t("#edd-vat-number");a?d.slideDown(200):(d.slideUp(200),n.val(""),o()),l()})).on("input","#edd-vat-number",(function(e){l()})),l()})),t((function(){t("#edd_purchase_form").on("change","#billing_country",(function(e){t("#edd-purchase-button, #billing_country").prop("disabled",!0)}))})),t(e.body).on("edd_taxes_recalculated",(function(e,a){const d=t(".edd_cart_amount"),n=a?.response?.total_raw;void 0!==n&&d.attr("data-total",n),t("#edd-purchase-button, #billing_country").prop("disabled",!1),function(e){e.postdata.current_tax_amount!==e.response.tax_raw&&(t("#edd-recurring-sl-auto-renew").each((function(){t(this).remove()})),t("#edd-recurring-sl-cancel-replace").each((function(){t(this).remove()})))}(a)}))}(document,a)})();