jQuery(document).ready((function(e){"use strict";var t=e('form[name="checkout"]').find("p.form-row input, p.form-row textarea"),i=function(e,t){e.next(".ywccp_error").length||e.after(''),e.next(".ywccp_error").html(t)};t.length&&e.each(t,(function(){var t=e(this),r=t.data("tooltip"),n=t.closest("p.form-row");t.on("blur",(function(){var r=e(this),a=r.val(),o="";ywccp_front.validation_enabled&&(!a&&n.hasClass("validate-required")?(o=ywccp_front.err_msg,i(r,o)):a&&n.hasClass("validate-vat")&&!function(t){var i=e("#billing_country");if("undefined"==typeof checkVATNumber||!i.length||!ywccp_front.vat_validation_enabled)return!0;var r=t.substr(0,2).toUpperCase(),n=i.val();return r!==n&&(t=n+t),checkVATNumber(n,t)}(a)?i(r,ywccp_front.err_msg_vat):a&&n.hasClass("validate-email")&&!/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i.test(a)?i(r,ywccp_front.err_msg_mail):t.next(".ywccp_error").remove())})),void 0!==r&&""!=r&&void 0!==e.fn.qtip&&t.qtip({content:{text:r},show:{event:"focus"},style:{classes:"ywccp_tooltip"},position:{my:"bottom center",at:"top center",viewport:e(window)}})}));var r=e(".ywccp-multiselect-type, select.select"),n=e(".ywccp-datepicker-type"),a=e(".ywccp-timepicker-type");r&&void 0!==e.fn.select2&&e.each(r,(function(){var t=e(this),i=t.attr("id");e("#s2id_"+i).length||t.select2({placeholder:t.data("placeholder")})})),void 0!==e.fn.datepicker&&n&&e.each(n,(function(){e(this).datepicker({dateFormat:e(this).data("format")||"dd-mm-yy",changeYear:ywccp_front.datepicker_change_year,changeMonth:ywccp_front.datepicker_change_month,yearRange:ywccp_front.datepicker_year_range,minDate:ywccp_front.datepicker_min_date,maxDate:ywccp_front.datepicker_max_date,beforeShow:function(){setTimeout((function(t){e("#ui-datepicker-div").wrap('
').css("z-index",99999999999999),e("#ui-datepicker-div").show()}),0)},beforeShowDay:function(e){return ywccp_front.datepicker_allowed_days.includes(e.getDay())?[!0]:[!1]},onClose:function(){e("#ui-datepicker-div").hide(),e("#ui-datepicker-div").unwrap()}})})),void 0!==e.fn.timepicki&&a&&(e.each(a,(function(){e(this).timepicki({reset:!0,disable_keyboard_mobile:!0,show_meridian:ywccp_front.time_format,max_hour_value:ywccp_front.time_format?"12":"23",min_hour_value:ywccp_front.time_format?"1":"0",overflow_minutes:!0,increase_direction:"up"})})),e(document).on("click",".reset_time",(function(e){e.preventDefault()})));var o=function(e){return jQuery.parseJSON(ywccp_front.conditions)[e]},c=function(e){var t=null;return e.each((function(i){if("radio"==e[i].type&&e[i].checked)return t=e[i].value,!1})),t},d=function(t){var i=t.input_name,r=t.type,n=(t.action,t.required,t.value),a=function(t){var i=e("*[name="+t+"]");return i.length>1?c(i):"checkbox"==i.attr("type")?i.is(":checked"):"radio"==i.attr("type")?e("#"+t+":checked").val():i.val()}(i),o=!1;switch(r){case"is-set":a&&(o=!0);break;case"is-empty":a||(o=!0);break;case"has-value":var d=n.split(",");jQuery.each(d,(function(e,t){String(a)==String(t)&&(o=!0)}));break;case"has-not-value":a!=n&&(o=!0)}return o};e("form.checkout").on("change","input, select",(function(e){s(e)})),e("form.checkout").on("submit",(function(e){s(e)})),e(document.body).on("yith_wccp_i18n_locale_done",(function(e){s(e)}));var s=function(t){e("form.checkout").find("input, textarea, select, h3[data-name]").each((function(){var i=e(this).attr("name")||e(this).attr("data-name"),r=e(this).closest(".form-row").length?e(this).closest(".form-row"):e(this),n=function(e){var t=o(e);if(void 0===t||0===t.length)return null;for(var i=t.length,r={show:null,hide:null,set_required:null},n=0;n*'))):(t.removeClass("validate-required woocommerce-validated woocommerce-invalid woocommerce-invalid-required-field"),0==t.find("label").find(".optional").length&&(t.find("label").append('(optional)'),t.find("abbr.required").remove()))};if(e("form.checkout").find("input, select").each((function(){const t=ywccp_front.field_ids_to_exclude;let i=e(this).attr("id");e.isArray(t)&&e.inArray(i,t,0)<0&&e(this).trigger("change")})),ywccp_front.ship_different_address_old_behaviour){var u=e("#ship-to-different-address-checkbox").is(":checked");e(".woocommerce-shipping-fields__field-wrapper").hide(),e(document.body).on("init_checkout",(function(){e("#ship-to-different-address-checkbox").prop("checked",u).change(),e(".woocommerce-shipping-fields__field-wrapper").toggle(!0)}))}}));