!function(g){woodmartThemeModule.$document.on("wdQuickShopSuccess wdQuickViewOpen wdUpdateWishlist",function(){woodmartThemeModule.swatchesVariations()}),g.each(["frontend/element_ready/wd_single_product_add_to_cart.default"],function(a,e){woodmartThemeModule.wdElementorAddAction(e,function(a){a.find(".variations_form").each(function(){g(this).wc_variation_form()}),woodmartThemeModule.swatchesVariations()})}),woodmartThemeModule.swatchesVariations=function(){woodmartThemeModule.setupMainCarouselArg();var a=g(".variations_form"),d=!1,n=!1,t=!1===a.data("product_variations"),r=(g(".variations_form .label").on("click",function(a){g(this).siblings(".value").hasClass("with-swatches")&&a.preventDefault()}),a.each(function(){var s=g(this);s.data("swatches")||(s.data("swatches",!0),s.data("product_variations")||s.find(".swatches-select").find("> div").addClass("swatch-enabled"),g(".swatches-select > div").hasClass("active-swatch")&&s.addClass("variation-swatch-selected"),s.on("click",".swatches-select > div",function(){var a=g(this),e=a.data("value"),t=a.parent().data("id"),o=a.data("title");r(s),a.hasClass("active-swatch")||a.hasClass("swatch-disabled")||(s.find("select#"+t).val(e).trigger("change"),a.parent().find(".active-swatch").removeClass("active-swatch"),a.addClass("active-swatch"),r(s),("yes"===woodmart_settings.swatches_labels_name&&769<=woodmartThemeModule.$window.width()||woodmartThemeModule.$window.width()<=768)&&(a.parents("tr").find(" > th .wd-attr-selected").remove(),a.parents("tr").find(" > th").append(''+o+"")))}).on("woocommerce_update_variation_values",function(){r(s)}).on("click",".reset_variations",function(){s.find(".active-swatch").removeClass("active-swatch"),("yes"===woodmart_settings.swatches_labels_name&&769<=woodmartThemeModule.$window.width()||woodmartThemeModule.$window.width()<=768)&&s.find(".wd-attr-selected").html("")}).on("reset_data",function(){var a=g(this),e=!0,t=(s.find(".variations select").each(function(){0===(a.val()||"").length&&(e=!1)}),e&&a.parent().find(".active-swatch").removeClass("active-swatch"),s.removeClass("variation-swatch-selected"),g(".woocommerce-product-gallery__wrapper.owl-carousel")),o=g(".woocommerce-product-gallery");r(s),w("default",s),t.hasClass("owl-carousel")&&("yes"===woodmart_settings.product_slider_auto_height?(!l()&&u("default",s)&&d&&t.trigger("destroy.owl.carousel"),g(".product-images").imagesLoaded(function(){(t=t.owlCarousel(woodmartThemeModule.mainCarouselArg)).trigger("refresh.owl.carousel")})):(t=t.owlCarousel(woodmartThemeModule.mainCarouselArg)).trigger("refresh.owl.carousel"),o=o.hasClass("thumbs-position-centered")?woodmart_settings.centered_gallery_start:0,l()&&(o=0),t.trigger("to.owl.carousel",o),woodmartThemeModule.$document.trigger("wdResetVariation"))}).on("found_variation",function(a,e){t&&w(e.variation_id,s,e)}).on("reset_image",function(){var a=g(".thumbnails .product-image-thumbnail img").first();l()||c(s)||a.wc_reset_variation_attr("src")}).on("show_variation",function(a,e){var t,o,r,i;("yes"===woodmart_settings.swatches_labels_name&&769<=woodmartThemeModule.$window.width()||woodmartThemeModule.$window.width()<=768)&&!n&&(s.find(".active-swatch").each(function(){var a=g(this),e=a.data("title");a.parents("tr").find(".wd-attr-selected").html(e)}),n=!0),e.image.src&&(i=0 a").first().data("o_href"),i&&t.wc_reset_variation_attr("src"),c(s)||w(e.variation_id,s)||(t.attr("src")!==e.image.thumb_src&&t.wc_set_variation_attr("src",e.image.src),woodmartThemeModule.$document.trigger("wdShowVariationNotQuickView")),s.addClass("variation-swatch-selected"),c(s)||l()||o===e.image.full_src||m(),(r=g(".woocommerce-product-gallery__wrapper.owl-carousel")).hasClass("owl-carousel")&&("yes"===woodmart_settings.product_slider_auto_height?(!l()&&u(e.variation_id,s)&&d&&r.trigger("destroy.owl.carousel"),g(".product-images").imagesLoaded(function(){(r=r.owlCarousel(woodmartThemeModule.mainCarouselArg)).trigger("refresh.owl.carousel")})):(r=r.owlCarousel(woodmartThemeModule.mainCarouselArg)).trigger("refresh.owl.carousel"),i=g(".images .thumbnails"),r.trigger("to.owl.carousel",0),i.hasClass("owl-carousel")?(i.owlCarousel().trigger("to.owl.carousel",0),i.find(".active-thumb").removeClass("active-thumb"),i.find(".product-image-thumbnail").eq(0).addClass("active-thumb")):i.hasClass("slick-slider")&&(i.slick("slickGoTo",0),i.find(".product-image-thumbnail").eq(0).hasClass("active-thumb")||(i.find(".active-thumb").removeClass("active-thumb"),i.find(".product-image-thumbnail").eq(0).addClass("active-thumb")))))}))}),function(a){a.data("product_variations")&&a.find(".variations select").each(function(){var a=g(this),e=a.parent().find(".swatches-select"),a=a.html(),a=g(a);e.find("> div").removeClass("swatch-enabled").addClass("swatch-disabled"),a.each(function(){var a=g(this).val();g(this).hasClass("enabled")?e.find('div[data-value="'+a+'"]').removeClass("swatch-disabled").addClass("swatch-enabled"):e.find('div[data-value="'+a+'"]').addClass("swatch-disabled").removeClass("swatch-enabled")})})}),l=function(){return g(".single-product-content").hasClass("product-quick-view")},c=function(a){return a.parent().hasClass("quick-shop-form")},u=function(a,e){return"old"===woodmart_settings.variation_gallery_storage_method?o(a):i(a,e)},o=function(a){var e;if("undefined"!=typeof woodmart_variation_gallery_data||"undefined"!=typeof woodmart_qv_variation_gallery_data)return e=l()?woodmart_qv_variation_gallery_data:woodmart_variation_gallery_data,void 0!==e&&e&&e[a]},i=function(a,e){e=s(e);return void 0!==e&&e&&e[a]&&1';l()||(i+=''),i+=t[r].image,l()||(i+=""),i+="",o.append(i)}},_=function(a,e){var t,o,r,i=e.parents(".product").find(".woocommerce-product-gallery__wrapper");for(t in i.empty(),1",i.append(o))}},g(document).ready(function(){woodmartThemeModule.swatchesVariations()})}(jQuery);