jQuery(function(e){"use strict";if("undefined"==typeof wpdInvoicesCheckout)return;const i=wpdInvoicesCheckout.wantInvoiceKey,n=wpdInvoicesCheckout.billingTaxIdKey,d=wpdInvoicesCheckout.shippingTaxIdKey,o=wpdInvoicesCheckout.fieldBehavior||"ask_user";function s(){const s=e("#"+i+', input[name="'+i+'"]'),t=e("#"+n+"_field"),r=e("#"+d+"_field"),a=e("#ship-to-different-address-checkbox");let u=!1;u="ask_user"!==o||s.is(":checked");const h=!!a.length&&a.is(":checked");u?(t.show(),h?r.show():r.hide()):(t.hide(),r.hide()),c(t,u),c(r,u&&h)}function c(e,i){if(!e.hasClass("wpd-invoices-required-with-invoice"))return;const n=e.find("label").first();if(i)return n.find("span.optional").hide(),n.find("span.required").length||n.append('<span class="required" aria-hidden="true">*</span>'),void e.addClass("validate-required");n.find("span.optional").show(),n.find(".required").remove(),e.removeClass("validate-required woocommerce-invalid woocommerce-invalid-required-field")}e(document).on("change","#"+i+', input[name="'+i+'"], #ship-to-different-address-checkbox',s),e(document.body).on("updated_checkout",s),s()})