!function(a){function e(){function r(e,o,c,t){""==e||"select"==t&&" "==e?o.hasClass("validate-required")&&c.addClass("field-required"):c.removeClass("field-required")}var e=a("form.woocommerce-checkout #customer_details"),o=e.find("input, textarea"),c=e.find("select");o.on("blur",function(){var e=a(this),o=e.attr("type"),c=e.closest("p.form-row"),t=e.val();r(t,c,e,o)}),c.on("blur",function(){var e=a(this).closest("p.form-row"),o=e.find(".select2-container--default"),c=e.find("select").val();r(c,e,o,"select")})}function o(){if("yes"==cartflows.allow_persistence&&!1!==function(){var e="test";try{return localStorage.setItem(e,e),localStorage.removeItem(e),!0}catch(e){return!1}}()){var e="form.woocommerce-checkout #customer_details",o=function(){var e=[],o=a("form.woocommerce-checkout #customer_details");localStorage.removeItem("cartflows_checkout_form"),o.find("input[type=text], select, input[type=email], input[type=tel]").each(function(){e.push({name:this.name,value:this.value})}),cartflows_checkout_form=JSON.stringify(e),localStorage.setItem("cartflows_checkout_form",cartflows_checkout_form)};(function(){if(null!=localStorage.getItem("cartflows_checkout_form")){checkout_data=JSON.parse(localStorage.getItem("cartflows_checkout_form"));for(var e=0;e<checkout_data.length;e++)a("form.woocommerce-checkout [name="+checkout_data[e].name+"]").hasClass("select2-hidden-accessible")?a("form.woocommerce-checkout [name="+checkout_data[e].name+"]").selectWoo("val",[checkout_data[e].value]):a("form.woocommerce-checkout [name="+checkout_data[e].name+"]").val(checkout_data[e].value)}})(),a(e+" input, "+e+" select").on("change",function(){o()})}}var c={init:function(){a(document.body).on("click",".wcf-submit-coupon",this.submit_coupon),a(document.body).on("click",".wcf-remove-coupon",this.remove_coupon)},submit_coupon:function(e){e.preventDefault();var o=a(".wcf-custom-coupon-field").find(".wcf-coupon-code-input"),c=o.val();if(""==c)return o.addClass("field-required"),!1;o.removeClass("field-required");var t={coupon_code:c,action:"wcf_woo_apply_coupon",security:cartflows.wcf_validate_coupon_nonce};a.ajax({type:"POST",url:cartflows.ajax_url,data:t,success:function(e){var o=a(".wcf-custom-coupon-field");o.find(".woocommerce-error, .woocommerce-message").remove();var c=JSON.parse(e);1==c.status&&a(document.body).trigger("update_checkout",{update_shipping_method:!1}),o.prepend(c.msg)}})},remove_coupon:function(e){e.preventDefault();var o={coupon_code:a(this).attr("data-coupon"),action:"wcf_woo_remove_coupon",security:cartflows.wcf_validate_remove_coupon_nonce};a.ajax({type:"POST",url:cartflows.ajax_url,data:o,success:function(e){var o=a(".wcf-custom-coupon-field");o.find(".woocommerce-error, .woocommerce-message").hide(),e&&(a(document.body).trigger("update_checkout",{update_shipping_method:!1}),o.prepend(e))}})}};a(function(){o(),e(),function(){a(".cartflows-container").find(".wcf-embed-checkout-form-two-column");var e=a(".wcf-embed-checkout-form .woocommerce-checkout").find("#billing_address_1_field"),o=a(".wcf-embed-checkout-form .woocommerce-checkout").find("#billing_address_2_field");e.hasClass("form-row-wide")&&(e.removeClass("form-row-wide"),e.addClass("form-row-first")),o.hasClass("form-row-wide")&&(o.removeClass("form-row-wide"),o.addClass("form-row-last"),o.find("label").hasClass("screen-reader-text")?o.addClass("mt20"):o.removeClass("mt20"));var c=a(".wcf-embed-checkout-form .woocommerce-checkout").find("#shipping_address_1_field"),t=a(".wcf-embed-checkout-form .woocommerce-checkout").find("#shipping_address_2_field");c.hasClass("form-row-wide")&&(c.removeClass("form-row-wide"),c.addClass("form-row-first")),t.hasClass("form-row-wide")&&(t.removeClass("form-row-wide"),t.addClass("form-row-last"),t.find("label").hasClass("screen-reader-text")?t.addClass("mt20"):t.removeClass("mt20")),a(".wcf-embed-checkout-form .woocommerce-checkout").find("#billing_country").on("change",function(e){}),a(".wcf-embed-checkout-form .woocommerce-checkout").find("#shipping_country").on("change",function(e){})}(),a(document.body).on("click","#wcf-embed-checkout-form .remove",function(e){e.preventDefault();var c=a(this).attr("data-id"),o={p_key:a(this).attr("data-item-key"),p_id:c,action:"wcf_woo_remove_cart_product",security:cartflows.wcf_validate_remove_cart_product_nonce};a.ajax({type:"POST",url:cartflows.ajax_url,data:o,success:function(e){var o=JSON.parse(e);0==o.need_shipping&&a("#wcf-embed-checkout-form").find("#ship-to-different-address-checkbox").attr("checked",!1),a("#wcf-embed-checkout-form").find(".woocommerce-notices-wrapper").first().html(o.msg),a(document).trigger("cartflows_remove_product",[c]),a("#wcf-embed-checkout-form").trigger("update_checkout")}})}),c.init()})}(jQuery);