"use strict";if(void 0===e){var e={};e.carouselActionReady=[]}var galleries=document.querySelectorAll(".product-gallery");function woostifyStickySummary(e){if(woostify_woocommerce_general.enabled_sticky_product_summary){var t=!!e.classList.contains("has-product-thumbnails")&&e,i=!!document.body.classList.contains("has-gallery-list-layout")&&document.querySelector(".has-gallery-list-layout .product-summary");if(t&&i&&!(window.innerWidth<992)&&!(t.offsetHeight<=i.offsetHeight)){var r=new WSYSticky(".summary.entry-summary",{stickyContainer:".product-page-container",marginTop:parseInt(woostify_woocommerce_general.sticky_top_space),marginBottom:parseInt(woostify_woocommerce_general.sticky_bottom_space)});return jQuery("form.variations_form").on("found_variation",function(){r.update()}),r}}}function renderSlider(e,t){return!(!e||e.classList.contains("flickity-enabled"))&&!(e.querySelectorAll(t.cellSelector).length<2)&&new Flickity(e,t)}window.addEventListener("load",function(){galleries&&(galleries.forEach(function(e,t){woostifyStickySummary(e)}),setTimeout(function(){window.dispatchEvent(new Event("resize"))},200))});class WoostifyGallery{constructor(e,t){var i=this;return"string"==typeof e&&(e=document.querySelector(e)),i.el=e,i.mobileSlider={},i.imageCarousel={},i.thumbCarousel={},i.options=t,i.sliderOptions={...t.main},i.thumbOptions={...t.thumb},i.init(),i}init(){var e=this,t=e.el;e.productThumbnails=e.getProductThumbnails(),e.checkDragable(),e.noSliderLayout=t.classList.contains("column-style")||t.classList.contains("grid-style"),e.prevBtn=document.createElement("button"),e.nextBtn=document.createElement("button"),e.initSlider(),e.events()}initSlider(){var e=this;if(e.el,e.noSliderLayout)e.woostifyGalleryCarouselMobile();else{if(e.productThumbnails=e.getProductThumbnails(),!e.productThumbnails)return!1;e.sliderOptions.on={ready:function(){e.changeImageCarouselButtonIcon(),e.calculateVerticalSliderHeight()}},e.imageCarousel=e.renderSlider(e.sliderOptions.container,e.sliderOptions),e.galleryThumbnailCarousel()}"function"==typeof easyZoomHandle&&easyZoomHandle(),"function"==typeof initPhotoSwipe&&initPhotoSwipe(".product-images-container"),setTimeout(function(){window.dispatchEvent(new Event("resize"))},200)}renderSlider(e,t){return!!e&&new Flickity(e,t)}createImages(e,t,i){var r='';return r+="',r+="
',r+="",r+=""}createThumbnails(e){var t='
';return t+='

',t+="
"}changeImageCarouselButtonIcon(){var e=this.el,t=e.querySelector(".flickity-button.next"),i=e.querySelector(".flickity-button.previous");t&&(t.innerHTML=this.options.next_icon),i&&(i.innerHTML=this.options.prev_icon)}woostifyGalleryCarouselMobile(){var e=this,t=e.el;t.querySelector(".has-gallery-list-layout .product-gallery.has-product-thumbnails")&&!(window.innerWidth>991)&&(e.sliderOptions.on={ready:function(){e.changeImageCarouselButtonIcon()}},e.mobileSlider=new Flickity(t.querySelector(".product-images-container"),e.sliderOptions))}calculateVerticalSliderHeight(){var e=this,t=e.el;if(window.matchMedia("( min-width: 768px )").matches&&t.classList.contains("vertical-style")){var i=t.querySelector(".image-item img");e._setVerticalSliderHeight(i),e.waitImageLoad(i,t=>{e._setVerticalSliderHeight(t)}).then(e=>{}).catch(e=>{console.error("Error loading image",e)})}}_setVerticalSliderHeight(e){var t=e?e.offsetHeight:0,i=this.getProductThumbnails();t&&(i.style.maxHeight=t+"px")}isImageOk(e){return!!e.complete&&(void 0===e.naturalWidth||0!=e.naturalWidth)}async waitImageLoad_v2(e,t){var i=0,r=0;r=setInterval(function(){IsImageOk(e)&&i<20&&((e?e.offsetHeight:0)&&_setVerticalSliderHeight(e),clearInterval(r)),i++},200)}async waitImageLoad(e,t){return new Promise((i,r)=>{e.addEventListener("load",()=>{t(e),i(e)}),e.addEventListener("error",r)})}galleryThumbnailCarousel(){this.horizontalThumbnailCarousel()||this.verticalThumbnailCarousel()}verticalThumbnailCarousel(){var e=this,t=e.el,i=e.getProductThumbnails();if(i){var r=e.thumbOptions;window.matchMedia("( max-width: 767px )").matches?e.thumbCarousel=new Flickity(i,r):t.classList.contains("vertical-style")?(e.calculateVerticalSliderHeight(),e.verticalThumbnailSliderAction(e),e.addThumbButtons()):e.thumbCarousel=new Flickity(i,r)}}verticalThumbnailSliderAction(){var e=this.getProductThumbnails(),t=e.querySelectorAll(".thumbnail-item"),i=this.imageCarousel;t[0].classList.add("is-nav-selected"),t[0].classList.add("is-selected"),t.forEach(function(e,t){e.addEventListener("click",function(){i.select(t)})});var r=0t.offsetHeight?(t.classList.add("has-buttons"),e.nextBtn.style.display="block",e.prevBtn.style.display="block"):(t.classList.remove("has-buttons"),e.nextBtn.style.display="none",e.prevBtn.style.display="none")}horizontalThumbnailCarousel(){var e=this,t=e.el,i=!1;if(e.productThumbnails=e.getProductThumbnails(),e.productThumbnails){var r=e.productThumbnails,a=e.thumbCarousel,n=e.thumbOptions;if(t.classList.contains("horizontal-style")||window.matchMedia("( max-width: 767px )").matches){var s=r.querySelectorAll(".thumbnail-item"),l=0;s.length&&s.forEach(function(e){var t=e.offsetWidth;t+=parseInt(window.getComputedStyle(e).getPropertyValue("margin-left")),t+=parseInt(window.getComputedStyle(e).getPropertyValue("margin-right")),l+=t}),l>=r.offsetWidth?(n.groupCells="60%",n.wrapAround=!0):(n.groupCells="3",n.wrapAround=!1),a&&a.slider&&a.destroy(),e.thumbCarousel=new Flickity(e.productThumbnails,n),i=!0}return i}}resetCarousel(){this.imageCarousel||this.imageCarousel.slider||imageCarousel.select(0),this.mobileSlider||this.mobileSlider.slider||mobileSlider.select(0)}updateGallery(e,t,i){var r=this.el;if(!(!e.length||document.documentElement.classList.contains("quick-view-open"))){for(var a="",n="",s=this.imageCarousel||{},l=this.thumbCarousel||{},o=this.mobileSlider||{},c=0,u=e.length;c1?this.createThumbnails(e[c].gallery_thumbnail_src):""}else if(i&&i==e[c][0].variation_id){if(1>=e[c].length-1){n="";for(var h=1,m=e[c].length;h1?this.createThumbnails(e[c][h].gallery_thumbnail_src):""}}if(s&&s.slider&&s.destroy(),l&&l.slider&&l.destroy(),o&&o.slider&&o.destroy(),a&&r.querySelector(".product-images")&&(r.querySelector(".product-images").querySelector(".product-images-container").innerHTML=a),r.querySelector(".product-thumbnail-images")){if(""!==n){var g=r.querySelector(".product-thumbnail-images").querySelector(".product-thumbnail-images-container");g||(g=document.createElement("div")).classList.add("product-thumbnail-images-container"),g.classList.remove("flickity-enabled"),r.querySelector(".product-thumbnail-images").innerHTML="",r.querySelector(".product-thumbnail-images").appendChild(g).innerHTML=n,r.querySelector(".product-gallery")&&r.querySelector(".product-gallery").classList.add("has-product-thumbnails"),r.classList.contains("product-gallery")&&r.classList.add("has-product-thumbnails")}else r.querySelector(".product-thumbnail-images").innerHTML=""}this.initSlider()}}checkDragable(){window.matchMedia("( min-width: 768px )").matches&&this.el.classList.contains("vertical-style")&&(this.thumbOptions.draggable=!1)}getProductThumbnails(){var e=this,t=e.el;return"string"==typeof this.thumbOptions.asNavFor&&t.querySelector(e.thumbOptions.asNavFor)&&(e.thumbOptions.asNavFor=t.querySelector(e.thumbOptions.asNavFor)),"string"==typeof this.sliderOptions.container&&t.querySelector(e.sliderOptions.container)&&(e.sliderOptions.container=t.querySelector(e.sliderOptions.container)),"string"==typeof this.thumbOptions.container&&t.querySelector(e.thumbOptions.container)&&(e.thumbOptions.container=t.querySelector(e.thumbOptions.container)),"string"!=typeof this.thumbOptions.container&&this.thumbOptions.container}events(){var e=this;e.el,window.addEventListener("resize",function(){e.checkDragable()}),e.changeImageCarouselButtonEvents(),e.listenResetVariations(),e.listenFoundVariations()}changeImageCarouselButtonEvents(){var e=this,t=e.el.querySelectorAll(".thumb-btn");t.length&&t.forEach(function(t){t.addEventListener("click",function(){this.classList.contains("prev")?e.imageCarousel.previous():e.imageCarousel.next()})})}listenFoundVariations(){var e=this,t=e.el;e.listEvents=e.listEvents||{},!e.listEvents.found_variation&&(jQuery("form.variations_form").on("found_variation",function(i,r){if("undefined"!=typeof woostify_variation_gallery&&woostify_variation_gallery.length)e.updateGallery(woostify_variation_gallery,!1,r.variation_id);else if(r.variation_gallery_images){var a=t.querySelector(".product-thumbnail-images");if(r.variation_gallery_images.length>1||r.variation_gallery_images.length&&r.image&&r.variation_gallery_images[0].full_src!=r.image.full_src)e.updateGallery(r.variation_gallery_images,!0,r.variation_id),a&&a.classList.add("variation-gallery");else if("undefined"!=typeof woostify_default_gallery&&woostify_default_gallery.length){var n=[];r.image?(n.push(r.image),woostify_default_gallery.forEach(function(e,t,i){t&&n.push(e)},n)):n=woostify_default_gallery,e.updateGallery(e,n,!0),a&&a.classList.remove("variation-gallery")}}var s=e.thumbCarousel,l=e.imageCarousel;t.classList.contains("horizontal-style")&&(l&&l.slider&&l.select(0),s&&s.slider&&s.select(0))}),e.listEvents.found_variation=1)}listenResetVariations(){var e=this,t=e.el;e.listEvents=e.listEvents||{},!e.listEvents.reset_variations&&(jQuery(".reset_variations").on("click",function(){"undefined"!=typeof woostify_default_gallery&&woostify_default_gallery.length&&(e.updateGallery(woostify_default_gallery,!0),t.querySelector(".product-thumbnail-images")&&t.querySelector(".product-thumbnail-images").classList.remove("variation-gallery")),e.resetCarousel(),setTimeout(function(){window.dispatchEvent(new Event("resize"))},200),(document.body.classList.contains("elementor-editor-active")||document.body.classList.contains("elementor-editor-preview"))&&!t.querySelector(".product-thumbnail-images-container")&&t.querySelector(".product-gallery").classList.remove("has-product-thumbnails")}),e.listEvents.reset_variations=!0)}}function renderSlideLayoutColumnGrid(){var e=document.querySelector("body"),t=document.querySelector(".product-images .product-images-container");if(t&&(e.classList.contains("has-gallery-layout-column")||e.classList.contains("has-gallery-layout-grid"))){var i={contain:!0,freeScroll:!0,wrapAround:!0},r=new Flickity(t,i),a=!1,n=t.querySelectorAll(".flickity-button");if(0!=n.length){var s=woostify_product_images_slider_options.next_icon,l=woostify_product_images_slider_options.prev_icon;n.forEach(function(e){e.classList.contains("previous")&&(e.innerHTML=l),e.classList.contains("next")&&(e.innerHTML=s)})}window.matchMedia("(max-width: 991px)").matches||(a=!0),a?r.destroy():r=new Flickity(t,i)}}window.addEventListener("resize",function(){renderSlideLayoutColumnGrid()});var woostifyGalleries=[];document.addEventListener("DOMContentLoaded",function(){!e.productImagesReady&&(galleries.forEach(function(e,t){var i=new WoostifyGallery(e,woostify_product_images_slider_options);woostifyGalleries.push(i)}),renderSlideLayoutColumnGrid(),"function"==typeof onElementorLoaded&&onElementorLoaded(function(){window.elementorFrontend.hooks.addAction("frontend/element_ready/global",function(){setTimeout(function(){document.querySelectorAll(".product-gallery").forEach(function(e,t){renderSlider(e.querySelector(woostify_product_images_slider_options.main.container),woostify_product_images_slider_options)})},200)})}),e.productImagesReady=1)});