!function(h,r,c){if("undefined"==typeof yith_wccl_general)return;var p=function(t,a,e){var i=!1,o=t.data("product_variations"),r=t.find(".variations select"),c=[];h.each(r,function(){var t=h(this).data("attribute_name")||h(this).attr("name");c[t]=e==t?a:h(this).val()});for(var n=0;n'+yith_wccl_general.view_cart+""),h(c.body).trigger("wc_fragment_refresh"),h(c).trigger("wc_update_cart"),h(c.body).trigger("added_to_cart",[t.fragments,t.cart_hash,a]))}})},a=function(t,a){this.$form=t,this.$attr="undefined"!=typeof yith_wccl?JSON.parse(yith_wccl.attributes):a,this.$select=this.$form.find(".variations select"),this.$use_ajax=!1===this.$form.data("product_variations"),this.$is_loop=this.$form.hasClass("in_loop"),this.$wrapper=this.$form.closest(yith_wccl_general.wrapper_container_shop).length?this.$form.closest(yith_wccl_general.wrapper_container_shop):this.$form.closest(".product-add-to-cart"),this.$image=this.$wrapper.find(yith_wccl_general.image_selector),this.$def_image_src=this.$image.data("lazy-src")?this.$image.data("lazy-src"):this.$image.attr("src"),this.$def_image_srcset=this.$image.data("lazy-srcset")?this.$image.data("lazy-srcset"):this.$image.attr("srcset"),this.$price_html=this.$wrapper.find("span.price").clone().wrap("

").parent().html(),this.$button=this.$wrapper.find("a.product_type_variable"),this.$button_html=this.$button.html(),this.$input_qty=this.$wrapper.find("input.thumbnail-quantity"),this.$xhr=null,void 0===this.$attr&&(this.$attr=[]),t.on("yith_wccl_form_initialized",{obj:this},this.init),this.$select.each(function(){this.setAttribute("data-default_value",this.value)}),this.resetForm(this),this.$is_loop&&t.parent().on("change",function(t){t.stopPropagation()}),this.$input_qty.length&&this.$input_qty.hide(),this.$form.hasClass("inizialized")||this.$form.addClass("initialized").fadeIn().trigger("yith_wccl_form_initialized")};a.prototype.styleOption=function(t,a,e,i){"colorpicker"==e?1==(i=i.split(",")).length?a.append(h("",{class:"yith_wccl_value",css:{background:i}})):(a.append(h('')),a.find(".yith-wccl-bicolor").css({"border-bottom-color":i[0],"border-left-color":i[1]})):"image"==e?a.append(h("",{class:"yith_wccl_value",src:i})):"label"==e&&a.append(h("",{class:"yith_wccl_value",text:i}))},a.prototype.addTooltip=function(t,a,e,i,o){var r=h(''),c=yith_wccl_general.tooltip_pos+" "+yith_wccl_general.tooltip_ani;yith_wccl_general.tooltip&&void 0!==a&&a&&!e.find(".yith_wccl_tooltip").length&&("image"==i&&(a=a.replace("{show_image}",'')),r.addClass(c),e.append(r.html(""+a+"")))},a.prototype.handleSelect=function(t){var _=t.data.obj;_.$select.each(function(){var c=h(this),t=_.$attr[this.name],n=c.parent().find(".select_box"),s=[];void 0===t&&(t=_.$attr[decodeURIComponent(this.name)]),!yith_wccl_general.description||_.$is_loop||_.$wrapper.length||_.$form.find(".description_"+this.name).length||void 0===t||!t.descr||(h(this).closest("tr").length?h(this).closest("tr").after(''+t.descr+""):h(this).parent().append('

'+t.descr+"

"));var l=void 0!==t?t.type:c.data("type"),d=void 0!==t&&t.terms;(_.$is_loop||void 0!==t&&t.terms)&&void 0!==l&&l&&(c.addClass("yith_wccl_custom").hide().end().closest(".select-wrapper").addClass("yith_wccl_is_custom"),n.length&&yith_wccl_general.grey_out||(n.remove(),n=h("
",{class:"select_box_"+l+" select_box "+c.attr("name")}).insertAfter(c)),c.find("option").each(function(){var t=h(this).val();if(d&&void 0!==d[t]||h(this).data("value")){s.push(t);var o=h(this),a="select_option_"+l+" select_option",e=d&&void 0!==d[t]?d[t].value:h(this).data("value"),i=d&&void 0!==d[t]?d[t].tooltip:h(this).data("tooltip"),r=n.find('[data-value="'+t+'"]');r.length||(t!=c.val()&&t!=c.attr("data-default_value")||(a+=" selected"),(r=h("
",{class:a,"data-value":t}).appendTo(n)).off("click").on("click",function(t){var a=h(this).hasClass("inactive"),e=h(this).hasClass("selected");if(a){var i=c.data("attribute_name")||c.attr("name");p(_.$form,h(this).data("value"),i)?c.val("").change():_.resetForm(_)}e?c.val("").change():c.val(o.val()).change(),h(this).toggleClass("selected"),h(this).siblings().removeClass("selected")}),_.styleOption(_,r,l,e),_.addTooltip(_,i,r,l,e))}}),n.children().each(function(){var t=h(this).data("value")+"";"-1"==h.inArray(t,s)?h(this).addClass("inactive"):h(this).removeClass("inactive")}),_.$form.trigger("yith_wccl_select_initialized",[c,t]))})},a.prototype.setDefaultValue=function(t){var a=t.data.obj;a.$select.each(function(){h(this).val(h(this).attr("data-default_value"))}),a.$select.first().change()},a.prototype.changeLoopImage=function(t,a){if(a){var e=void 0!==a.image_src&&a.image_src?a.image_src:"",i=void 0!==a.image_srcset&&a.image_srcset?a.image_srcset:"";e&&e.length&&(t.$image.attr("src",e),t.$image.attr("data-lazy-src",e)),i&&i.length&&(t.$image.attr("srcset",i),t.$image.attr("data-lazy-srcset",i))}else t.$image.attr("src",t.$def_image_src),t.$image.attr("srcset",t.$def_image_srcset)},a.prototype.changeSingleImage=function(t,a){var e=t.$form.closest(".product").find(".images").find(".woocommerce-product-gallery__image, .woocommerce-product-gallery__image--placeholder").eq(0),i=e.find(".wp-post-image"),o=e.find("a").eq(0);i.wc_set_variation_attr("src",a.image.src),i.wc_set_variation_attr("height",a.image.src_h),i.wc_set_variation_attr("width",a.image.src_w),i.wc_set_variation_attr("srcset",a.image.srcset),i.wc_set_variation_attr("sizes",a.image.sizes),i.wc_set_variation_attr("title",a.image.title),i.wc_set_variation_attr("alt",a.image.alt),i.wc_set_variation_attr("data-src",a.image.full_src),i.wc_set_variation_attr("data-large_image",a.image.full_src),i.wc_set_variation_attr("data-large_image_width",a.image.full_src_w),i.wc_set_variation_attr("data-large_image_height",a.image.full_src_h),e.wc_set_variation_attr("data-thumb",a.image.src),o.wc_set_variation_attr("href",a.image.full_src)},a.prototype.changeImageOnHover=function(t){var i=t.data.obj;1==i.$select.length&&yith_wccl_general.image_hover&&i.$form.on("mouseenter",".select_option",function(){var t=h(this).attr("data-value"),a=i.$select.attr("name"),e=p(i.$form,t,a);h(this).hasClass("selected")||h(this).siblings().hasClass("selected")||e&&(e.image&&e.image.src||e.image_src)&&(i.$form.hasClass("in_loop")?i.changeLoopImage(i,e):i.changeSingleImage(i,e))}).on("mouseleave",".select_option",function(){h(this).hasClass("selected")||h(this).siblings().hasClass("selected")||(i.$form.hasClass("in_loop")?i.changeLoopImage(i,!1):i.$form.wc_variations_image_update(!1))})},a.prototype.handleCheckVariations=function(t,a,e){var i=t.data.obj;if(!e){if(i.$found&&(t.data.obj.$found=!1,!i.$use_ajax))return;i.$changed&&(t.data.obj.$changed=!1,i.resetLoopForm(i))}},a.prototype.handleFoundVariation=function(t,a){var e=t.data.obj;e.$use_ajax?e.handleSelect(t):e.$select.last().trigger("focusin"),e.$is_loop&&a.is_purchasable&&(e.$changed&&e.resetLoopForm(e),t.data.obj.$changed=!0,t.data.obj.$found=!0,e.changeLoopImage(e,a),a.price_html&&e.$wrapper.find("span.price").replaceWith(a.price_html),e.$input_qty.length&&e.$input_qty.show(),a.is_in_stock&&(e.$button.html(yith_wccl_general.add_cart),e.$button.off("click").on("click",{variation:a.variation_id,select:e.$select},i)),e.$wrapper.find("span.price").after(h(a.availability_html).addClass("ywccl_stock")),e.$form.data("active_variation",a.variation_id),h(c).trigger("ywccl_found_variation_in_loop",[a]))},a.prototype.handleVariationGallery=function(t,a){var e=t.data.obj;!e.$is_loop&&h(".woocommerce-product-gallery").length&&(null!==e.$xhr&&e.$xhr.abort(),id=void 0!==a?a.variation_id:e.$form.find('input[name="product_id"]').val(),e.$xhr=h.ajax({url:yith_wccl_general.ajaxurl.toString().replace("%%endpoint%%",yith_wccl_general.actionVariationGallery),data:{action:yith_wccl_general.actionVariationGallery,id:id,is_custom:h(".woocommerce-product-gallery").hasClass("custom-variation-gallery"),context:"frontend"},type:"POST",dataType:"json",beforeSend:function(){h(".woocommerce-product-gallery").addClass("loading-gallery")},success:function(t){t.html&&(h(".woocommerce-product-gallery").replaceWith(t.html),h(".woocommerce-product-gallery").wc_product_gallery(),t.default?e.$form.wc_variations_image_update(a):h(".woocommerce-product-gallery").addClass("custom-variation-gallery")),h(".woocommerce-product-gallery").removeClass("loading-gallery"),e.$xhr=null}}))},a.prototype.resetLoopForm=function(t){t.changeLoopImage(t,!1),t.$wrapper.find("span.price").replaceWith(t.$price_html),t.$wrapper.find(".ywccl_stock").remove(),t.$input_qty.length&&t.$input_qty.hide(),t.$button.html(t.$button_html).off("click",i).removeClass("added").next(".added_to_cart").remove(),t.$form.data("active_variation","")},a.prototype.resetForm=function(t){t.$form.find("div.select_option").removeClass("selected inactive"),t.$select.val("").change(),t.$form.trigger("reset_data")},a.prototype.onReset=function(t){t.data.obj.$form.find(".select_option.selected").removeClass("selected inactive")},a.prototype.init=function(t){var a=t.data.obj;a.$form.on("click.wc-variation-form",".reset_variations",{obj:a},a.onReset),a.$form.on("woocommerce_update_variation_values",{obj:a},a.handleSelect),a.$form.one("yith_wccl_select_initialized",{obj:a},a.changeImageOnHover),a.$form.on("check_variations",{obj:a},a.handleCheckVariations),a.$form.on("found_variation",{obj:a},a.handleFoundVariation),a.$form.on("found_variation",{obj:a},a.handleVariationGallery),a.$form.on("reset_image",{obj:a},a.handleVariationGallery),a.handleSelect(t),a.$select.each(function(){var t=h(this).attr("data-default_value");h(this).removeAttr("data-default_value"),h(this).val(t)})},h.yith_wccl=function(t){forms=h(".variations_form.cart:not(.initialized), .owl-item.cloned .variations_form, form.cart.ywcp_form_loaded"),void 0===t&&(t=[]),forms.each(function(){new a(h(this),t)})},h(c).on("yith-wcan-ajax-filtered yith_infs_adding_elem initialized.owl.carousel post-load ajax-tab-loaded",function(){void 0!==h.yith_wccl&&void 0!==h.fn.wc_variation_form&&(h(c).find(".variations_form:not(.initialized), .owl-item.cloned .variations_form").each(function(){h(this).wc_variation_form()}),"undefined"==typeof attr&&(attr=[]),h.yith_wccl(attr))}),h("body").on("quick-view-displayed",function(){var t=h(".pp_woocommerce_quick_view").find(".yith-wccl-data").data("attr");t&&h.yith_wccl(t)}),h(".shop-container > .products").on("append.infiniteScroll",function(){h(c).find(".variations_form:not(.initialized), .owl-item.cloned .variations_form").each(function(){h(this).wc_variation_form()}),"undefined"==typeof attr&&(attr=[]),h.yith_wccl(attr)}),h(c).on("ready",function(){h.yith_wccl()})}(jQuery,window,document);