!function(r){woodmartThemeModule.$document.on("wdReplaceMainGallery",function(){woodmartThemeModule.productImagesGallery(!0)}),r.each(["frontend/element_ready/wd_single_product_gallery.default"],function(e,o){woodmartThemeModule.wdElementorAddAction(o,function(e){woodmartThemeModule.productImagesGallery(),e.find(".woocommerce-product-gallery").css("opacity","1")})}),woodmartThemeModule.productImagesGallery=function(n=!1){woodmartThemeModule.setupMainCarouselArg(),r(".woocommerce-product-gallery").each(function(){var d,o,e=r(this),t=e.find(".woocommerce-product-gallery__wrapper:not(.quick-view-gallery)"),a=e.find(".thumbnails"),i=t.find(".wp-post-image").first();function l(){void 0!==r.fn.owlCarousel&&(woodmartThemeModule.$document.trigger("wood-images-loaded"),t.trigger("destroy.owl.carousel"),t.addClass("owl-carousel wd-owl").owlCarousel(woodmartThemeModule.mainCarouselArg))}function s(){var e,o=a.data("vertical_items");i.hasClass("wd-lazy-load")&&!i.attr("data-loaded")||(a.hasClass("wd-v-thumb-default")||a.hasClass("wd-height-calculated")||(e=t.height(),"undefined"!=typeof elementorFrontend&&elementorFrontend.isEditMode()&&(e=t.find(".wp-post-image").height()),a.css("--wd-slick-h",e+"px"),a.addClass("wd-height-calculated")),a.slick({slidesToShow:o,slidesToScroll:o,vertical:!0,verticalSwiping:!0,infinite:!1,listHeight:100,adaptiveHeight:!0}),a.on("afterChange",function(){woodmartThemeModule.$document.trigger("wood-images-loaded")}),a.on("click",".product-image-thumbnail",function(){t.trigger("to.owl.carousel",r(this).index())}),t.on("changed.owl.carousel",function(e){e=e.item.index;a.slick("slickGoTo",e),a.find(".active-thumb").removeClass("active-thumb"),a.find(".product-image-thumbnail").eq(e).addClass("active-thumb")}),a.find(".product-image-thumbnail").eq(0).addClass("active-thumb"),a.imagesLoaded(function(){a.slick("setPosition")}))}a.addClass("thumbnails-ready"),(e.hasClass("thumbs-position-without")||e.hasClass("thumbs-position-centered")||e.hasClass("thumbs-position-bottom")||e.hasClass("thumbs-position-left")||e.hasClass("thumbs-position-carousel_two_columns")||woodmartThemeModule.$window.width()<=1024&&(e.hasClass("thumbs-position-bottom_combined")||e.hasClass("thumbs-position-bottom_column")||e.hasClass("thumbs-position-bottom_grid")))&&("yes"===woodmart_settings.product_slider_auto_height?e.imagesLoaded(function(){l()}):l()),0!==a.length&&(n&&(d="",t.find(".woocommerce-product-gallery__image").each(function(){var e=r(this),o=e.data("thumb"),t=e.find("a img").attr("alt"),a=e.find("a img").attr("title"),i="";!a&&e.find("a picture").length&&(a=e.find("a picture").attr("title")),e.find(".wd-product-video").length&&(i+=" wd-with-video"),d=(d+='<div class="product-image-thumbnail'+i+'">')+'<img alt="'+t+'" title="'+a+'" src="'+o+'" /></div>'}),a.hasClass("slick-slider")?a.slick("unslick"):a.hasClass("owl-carousel")&&a.trigger("destroy.owl.carousel"),a.empty(),a.append(d)),e.hasClass("thumbs-position-left")&&1024<woodmartThemeModule.$body.width()&&void 0!==r.fn.slick?s():void 0!==r.fn.owlCarousel&&(a.addClass("owl-carousel").owlCarousel({rtl:woodmartThemeModule.$body.hasClass("rtl"),items:a.data("desktop"),responsive:{1025:{items:a.data("desktop")},769:{items:a.data("tablet")},577:{items:a.data("tablet")},0:{items:a.data("mobile")}},dots:!1,nav:!0,navText:!1,navClass:["owl-prev wd-btn-arrow","owl-next wd-btn-arrow"]}),o=a.owlCarousel(),a.on("mouseup",".owl-item",function(){var e=r(this).index();o.trigger("to.owl.carousel",e),t.trigger("to.owl.carousel",e)}),t.on("changed.owl.carousel",function(e){e=e.item.index;o.trigger("to.owl.carousel",e),a.find(".active-thumb").removeClass("active-thumb"),a.find(".product-image-thumbnail").eq(e).addClass("active-thumb")}),a.find(".product-image-thumbnail").eq(0).addClass("active-thumb"))),i.on("load",function(){i.hasClass("wd-lazy-load")&&e.hasClass("thumbs-position-left")&&!i.attr("data-loaded")&&1024<woodmartThemeModule.$body.width()&&void 0!==r.fn.slick&&(a.hasClass("slick-slider")&&a.slick("unslick"),i.attr("data-loaded",!0),s())})})},woodmartThemeModule.$window.on("elementor/frontend/init",function(){elementorFrontend.isEditMode()&&woodmartThemeModule.$window.on("resize",woodmartThemeModule.debounce(function(){woodmartThemeModule.productImagesGallery()},300))}),r(document).ready(function(){woodmartThemeModule.productImagesGallery()})}(jQuery);