!function($){"use strict";jQuery((function(){var wcgs_swiper_thumb,wcgs_swiper_gallery,players=[];$.fn.wpgspimagesLoaded=function(){var $imgs=this.find('img[src!=""]');if(!$imgs.length)return $.Deferred().resolve().promise();var dfds=[];return $imgs.each((function(){var dfd=$.Deferred();dfds.push(dfd);var img=new Image;img.onload=function(){dfd.resolve()},img.onerror=function(){dfd.resolve()},img.src=this.src})),$.when.apply($,dfds)};var settings=wcgs_object.wcgs_settings,wcgs_product_wrapper=wcgs_object.wcgs_product_wrapper,wcgs_body_font_size=parseInt(wcgs_object.wcgs_body_font_size),gallery_w=0,summary_w=0,pagination="1"==settings.pagination,navigation=!0;void 0!==settings.navigation&&(navigation="1"==settings.navigation);var wcgs_zoom=!0;void 0!==settings.zoom&&(wcgs_zoom="1"==settings.zoom);var video_only_popup=!0;void 0!==settings.video_popup_place&&"inline"==settings.video_popup_place&&(video_only_popup=!1);var $single_combination=void 0!==settings.single_combination?settings.single_combination:"all",wcgs_swiper=!0;function SwiperSlide(selector,options){return"undefined"!=typeof WCGSSwiper?new WCGSSwiper(selector,options):"undefined"!=typeof Swiper?new Swiper(selector,options):(console.log("Swiper is undefined"),void(wcgs_swiper=!1))}function wcgs_add_youtube_api_script(){var youtubeScriptId="youtube-api",youtubeScript;if(null===document.getElementById("youtube-api")){var tag=document.createElement("script"),firstScript=document.getElementsByTagName("script")[0];tag.src="https://www.youtube.com/iframe_api",tag.id="youtube-api",firstScript.parentNode.insertBefore(tag,firstScript)}}function initializeYouTubeVideos(){$(".wcgs-carousel .wcgs-slider-image .wcgs-youtube-video").each((function(index){var videoId=$(this).data("video-id"),playbackTimes={},wcgs_player=new YT.Player(this,{videoId:videoId,playerVars:{modestbranding:1,showinfo:0,fs:1,start:playbackTimes[videoId]||0},events:{onStateChange:function(event){event.data!==YT.PlayerState.PAUSED&&event.data!==YT.PlayerState.ENDED||(playbackTimes[videoId]=event.target.getCurrentTime())}}});players[videoId]=wcgs_player}))}if(!video_only_popup){wcgs_add_youtube_api_script();var checkYTInterval=setInterval((function(){"object"==typeof YT&&"function"==typeof YT.Player&&(clearInterval(checkYTInterval),initializeYouTubeVideos())}),300)}function videoIcon(){$(".wcgs-slider-image, .wcgs-thumb").each((function(){var icon;$(this).find("img").data("type")&&$(this).append('<div class="wcgs-video-icon"></div>')}))}function checkArrowsVisibility(nav_swiper){setTimeout((function(){var allowSlidePrev=void 0!==nav_swiper.allowSlidePrev&&nav_swiper.allowSlidePrev,allowSlideNext=void 0!==nav_swiper.allowSlideNext&&nav_swiper.allowSlideNext;allowSlidePrev||allowSlideNext?$(".gallery-navigation-carousel-wrapper .wcgs-swiper-arrow").show():$(".gallery-navigation-carousel-wrapper .wcgs-swiper-arrow").hide()}),300)}function wcgs_slider_func(width){var width_unit=width>100?"px":"%";$(window).width()<992&&settings.gallery_responsive_width.width>0&&(width_unit=settings.gallery_responsive_width.unit),$(window).width()<768&&(width_unit=settings.gallery_responsive_width.unit),setTimeout((function(){if("%"===width_unit)summary_w=(summary_w=100-width)>20?"calc( "+summary_w+"% - 30px )":"";else{var parent_wrapper=$("#wpgs-gallery").parent("*"),parent_wrapper_width=parent_wrapper.width()>$("#wpgs-gallery").width()+100?parent_wrapper.width():0;summary_w=(summary_w=parent_wrapper_width>200?parent_wrapper_width-width:0)>150?summary_w-35+width_unit:"","em"===width_unit&&(summary_w=(summary_w=(parent_wrapper_width/=wcgs_body_font_size)>width?parent_wrapper_width-width:0)>12?summary_w-3+width_unit:"")}$("#wpgs-gallery ~ .summary").css("maxWidth",summary_w)}),100),$("#wpgs-gallery").css("minWidth","auto").css("maxWidth",width+width_unit);var wcgs_img_count=$("#wpgs-gallery").find(".gallery-navigation-carousel .wcgs-thumb").length,thumbnails_item_to_show=parseInt(settings.thumbnails_item_to_show),thumbnails_sliders_space=void 0!==settings.thumbnails_sliders_space?settings.thumbnails_sliders_space.width:6,adaptive_height="1"==settings.adaptive_height,accessibility="1"==settings.accessibility,slider_dir=!("1"!=settings.slider_dir&&!$("body").hasClass("rtl")),thumbnail_nav=1==settings.thumbnailnavigation,slide_orientation="horizontal";void 0!==settings.slide_orientation&&(slide_orientation="vertical"==settings.slide_orientation?"vertical":"horizontal");var infinite_loop=!0;void 0!==settings.infinite_loop&&(infinite_loop="1"==settings.infinite_loop);var free_mode=!0;void 0!==settings.free_mode&&(free_mode="1"==settings.free_mode);var mouse_wheel=!1,carousel_items,pagination_visibility,navigation_visibility,thumb_navigation_visibility,isPreloader;if(void 0!==settings.mouse_wheel&&(mouse_wheel="1"==settings.mouse_wheel),wcgs_img_count<=1?($("#wpgs-gallery").find(".gallery-navigation-carousel-wrapper").hide(),$("#wpgs-gallery .wcgs-swiper-arrow").hide()):($("#wpgs-gallery").find(".gallery-navigation-carousel-wrapper").show(),$("#wpgs-gallery .wcgs-swiper-arrow:not(.swiper-button-lock)").show()),$("#wpgs-gallery").wpgspimagesLoaded().then((function(){wcgs_img_count>1&&setTimeout((function(){var maxHeight=0,selector;$(".wcgs-carousel .wcgs-slider-image img").each((function(i){$(this).innerHeight()>maxHeight&&(maxHeight=$(this).innerHeight())})),"vertical"==slide_orientation&&$("#wpgs-gallery .wcgs-carousel .swiper-slide").css({maxHeight:maxHeight}),$("#wpgs-gallery .wcgs-carousel .swiper-slide").css({display:"flex","justify-content":"center","align-items":"center"})}),200)})),$(".wcgs-carousel .wcgs-slider-image").length>0&&(wcgs_swiper_thumb=new SwiperSlide(".gallery-navigation-carousel",{slidesPerView:thumbnails_item_to_show,direction:"horizontal",loop:infinite_loop,autoplay:!1,watchSlidesVisibility:!0,watchSlidesProgress:!0,autoHeight:!1,watchOverflow:!0,spaceBetween:parseInt(thumbnails_sliders_space),freeMode:free_mode,observer:!0,mousewheel:mouse_wheel,simulateTouch:!0,a11y:!!accessibility&&{prevSlideMessage:"Previous slide",nextSlideMessage:"Next slide"},on:{afterInit:function(){setTimeout(()=>{$("#wpgs-gallery").removeClass("wcgs-swiper-before-init"),pagination&&($(".wcgs-carousel .swiper-slide.swiper-slide-active").find(".wcgs-youtube-video").length>0?$(".wcgs-carousel .swiper-pagination").hide():$(".wcgs-carousel .swiper-pagination").show())},400)}}}),"vertical"==slide_orientation&&(adaptive_height=!0),wcgs_swiper_gallery=new SwiperSlide(".wcgs-carousel",{autoplay:!1,autoHeight:adaptive_height,direction:slide_orientation,slidesPerView:1,spaceBetween:0,loop:infinite_loop,effect:"slide",speed:500,observer:!0,watchOverflow:!0,observeParents:!0,a11y:!!accessibility&&{prevSlideMessage:"Previous slide",nextSlideMessage:"Next slide"},navigation:navigation?{nextEl:".wcgs-carousel .wcgs-swiper-button-next",prevEl:".wcgs-carousel .wcgs-swiper-button-prev"}:!!thumbnail_nav&&{nextEl:".gallery-navigation-carousel .wcgs-swiper-button-next",prevEl:".gallery-navigation-carousel .wcgs-swiper-button-prev"},pagination:!!pagination&&{el:".wcgs-carousel .swiper-pagination",type:"bullets",clickable:!0},thumbs:{swiper:wcgs_swiper_thumb}})),$(document).find(".wcgs-thumb").on("click",(function(){if(infinite_loop){let index=$(this).data("swiper-slide-index");wcgs_swiper_gallery.slideToLoop(index)}else{let index=$(this).index();wcgs_swiper_gallery.slideTo(index)}})),checkArrowsVisibility(wcgs_swiper_thumb),wcgs_swiper&&wcgs_swiper_gallery.on("slideChange",()=>{var currentSlide=wcgs_swiper_gallery.activeIndex,previousIndex=wcgs_swiper_gallery.previousIndex,$previousItem=$(".wcgs-carousel .swiper-slide").eq(previousIndex),$activeItem=$(".wcgs-carousel .swiper-slide").eq(currentSlide);setTimeout((function(){if(pagination&&($($activeItem).find(".wcgs-youtube-video").length>0?$(".wcgs-carousel .swiper-pagination").hide():$(".wcgs-carousel .swiper-pagination").show()),$($previousItem).find(".wcgs-youtube-video").length>0){var video_id=$($previousItem).find(".wcgs-youtube-video").data("video-id");players.hasOwnProperty(video_id)&&(players[video_id]&&$.isFunction(players[video_id].pauseVideo)?players[video_id].pauseVideo():$.isFunction(players[video_id].stopVideo)&&players[video_id].stopVideo())}}),500)}),$(document).on("click",".wcgs-carousel .wcgs-lightbox,.wcgs-carousel .wcgs-video-icon, .wcgs-carousel .wcgs-photo",(function(e){$(document).find(".wcgs-carousel .swiper-slide-active a.wcgs-slider-lightbox").trigger("click")})),$("body").hasClass("theme-savoy")){var swiperArrow=[".sp_wgs-icon-left-open",".sp_wgs-icon-right-open",".sp_wgs-icon-left-open",".sp_wgs-icon-right-open"];$.each(swiperArrow,(function(i,item){$("#wpgs-gallery "+item).addClass("wcgs-swiper-arrow")}))}"1"==settings.lightbox&&($("#wpgs-gallery .wcgs-carousel .wcgs-lightbox").length||$("#wpgs-gallery .wcgs-carousel").append('<div class="wcgs-lightbox top_right"><span class="sp_wgs-lightbox"><span class="sp_wgs-icon-search"></span></button></div>')),"hover"==settings.pagination_visibility&&($("#wpgs-gallery .swiper-pagination").hide(),$("#wpgs-gallery .wcgs-carousel").on({mouseenter:function(){$("#wpgs-gallery .swiper-pagination").show()},mouseleave:function(){$("#wpgs-gallery .swiper-pagination").hide()}})),"hover"==settings.navigation_visibility&&($("#wpgs-gallery .wcgs-carousel .wcgs-swiper-arrow").hide(),$("#wpgs-gallery .wcgs-carousel").on({mouseenter:function(){$("#wpgs-gallery .wcgs-carousel .wcgs-swiper-arrow:not(.swiper-button-lock)").show()},mouseleave:function(){$("#wpgs-gallery .wcgs-carousel .wcgs-swiper-arrow").hide()}})),"hover"==settings.thumb_nav_visibility&&($("#wpgs-gallery .gallery-navigation-carousel .wcgs-swiper-arrow").hide(),$("#wpgs-gallery .gallery-navigation-carousel").on({mouseenter:function(){$("#wpgs-gallery .gallery-navigation-carousel .wcgs-swiper-arrow:not(.swiper-button-lock)").show()},mouseleave:function(){$("#wpgs-gallery .gallery-navigation-carousel .wcgs-swiper-arrow").hide()}})),1==settings.preloader&&($(".wcgs-gallery-preloader").length||$("#wpgs-gallery").append('<div class="wcgs-gallery-preloader"></div>'))}function dataZoom(){$(".wcgs-slider-image").on("mouseenter mouseleave",(function(){$(this).attr("data-scale","1.5");var img=$(this).find("img").attr("src");$(this).attr("data-image",img)}))}function zoomFunction(){$(".wcgs-slider-image").on("mouseover",(function(){$(this).children(".wcgs-photo").css({transform:"scale("+$(this).attr("data-scale")+")",transition:"all .5s"})})).on("mouseout",(function(){$(this).children(".wcgs-photo").css({transform:"scale(1)",transition:"all .5s"})})).on("mousemove",(function(e){$(this).children(".wcgs-photo").css({"transform-origin":(e.pageX-$(this).offset().left)/$(this).width()*100+"% "+(e.pageY-$(this).offset().top)/$(this).height()*100+"%",transition:"transform 1s ease-in"})})).each((function(){var icon=$(this).find("img").data("type"),photoLength;0!==$(this).find(".wcgs-photo").length||icon||$(this).append('<div class="wcgs-photo"></div>'),$(this).children(".wcgs-photo").css({"background-image":"url("+$(this).find("img").attr("src")+")"})}))}function zoomEffect(){if($(window).width()<480&&1==settings.mobile_zoom)return"";$(document).on("click",".wcgs-slider-image",(function(){zoomFunction()})),$(".wcgs-slider-image").on({mouseenter:function(){zoomFunction()},mouseleave:function(){zoomFunction()}})}function wcgsLightbox(){var lightbox;if(1==settings.lightbox&&void 0!==$.fancybox){var gl_btns=["zoom"];1==settings.gallery_fs_btn&&gl_btns.push("fullScreen"),1==settings.gallery_share&&gl_btns.push("share"),gl_btns.push("close"),$.fancybox.defaults.buttons=gl_btns;var counter=1==settings.l_img_counter;$(".wcgs-carousel").fancybox({selector:".wcgs-carousel .wcgs-slider-lightbox",backFocus:!1,baseClass:"wcgs-fancybox-custom-wrapper",caption:function(){var caption="";return 1==settings.lightbox_caption&&(caption=$(this).parent(".wcgs-slider-image ").find("img").data("cap")||""),caption},afterShow:function(instance,current){$(".wcgs-fancybox-custom-wrapper~.elementor-lightbox").remove()},infobar:counter,buttons:gl_btns,loop:!0})}else $(".wcgs-carousel .wcgs-slider-lightbox").removeAttr("data-fancybox href"),console.error("Fancybox is not defined.")}function wcgs_initialize(){var gallery_width=settings.gallery_width;if(gallery_w=gallery_width,summary_w=100-gallery_width,$(window).width()>=992&&(summary_w=summary_w>20?summary_w:"100%",$("#wpgs-gallery ~ .summary").css("maxWidth","calc("+summary_w+"% - 30px)")),$("body").hasClass("et_divi_builder")||$("body").hasClass("theme-Divi")){var gallery_divi_width=$(".wcgs-gallery-slider.et-db #et-boc .et-l .et_pb_gutters3 .et_pb_column_1_2").width();"number"==typeof gallery_divi_width&&(gallery_w=gallery_divi_width)}if($("body").hasClass("theme-flatsome")){var gallery_flatsome_width=$(".single-product .product .row.content-row .product-gallery").width();"number"==typeof gallery_flatsome_width&&(gallery_w=gallery_flatsome_width)}if($(".wcgs-woocommerce-product-gallery").parents(".hestia-product-image-wrap").length){var gallery_hestia_width=$(".wcgs-woocommerce-product-gallery").parents(".hestia-product-image-wrap").width();"number"==typeof gallery_hestia_width&&(gallery_w=gallery_hestia_width)}$(window).width()<992&&settings.gallery_responsive_width.width>0&&(gallery_w=settings.gallery_responsive_width.width),$(window).width()<768&&(gallery_w=settings.gallery_responsive_width.height),$(window).width()<480&&(gallery_w=settings.gallery_responsive_width.height2),wcgs_slider_func(gallery_w)}function uniqueMultidimensionalArray(arr,key){var uniqueArray=[],uniqueKeys=[];return $.each(arr,(function(index,item){-1===$.inArray(item[key],uniqueKeys)&&(uniqueKeys.push(item[key]),uniqueArray.push(item))})),uniqueArray}$("#wpgs-gallery").wpgspimagesLoaded().then((function(){$(".wcgs-gallery-preloader").css("opacity",0),$(".wcgs-gallery-preloader").css("z-index",-99)})),navigation&&($(".gallery-navigation-carousel .wcgs-swiper-button-next").on("click",(function(){$(".wcgs-carousel .wcgs-swiper-button-next").trigger("click")})),$(".gallery-navigation-carousel .wcgs-swiper-button-prev").on("click",(function(){$(".wcgs-carousel .wcgs-swiper-button-prev").trigger("click")}))),wcgs_initialize(),$(window).on("resize",(function(){wcgs_initialize()})),$(window).on("load",(function(){$(".wcgs-gallery-preloader").css("opacity",0),$(".wcgs-gallery-preloader").css("z-index",-99)})),videoIcon(),wcgs_zoom&&(dataZoom(),zoomEffect()),wcgsLightbox(),$(document).on("change",".variations select",(function(){var variations_items=[],variationsArray={};$(".variations tr").each((function(i){var attributeName=$(this).find("select").data("attribute_name"),attributeValue=$(this).find("select").val();attributeValue&&(variationsArray[attributeName]=attributeValue)}));var video_showed=!1;if(wcgs_object.wcgs_data&&wcgs_object.wcgs_data.length>0){var data=wcgs_object.wcgs_data,gallery;if($.each(data,(function(i,v){var v0="[]"==JSON.stringify(v[0])?"{}":JSON.stringify(v[0]),applied_variation=JSON.stringify(variationsArray),response,response;(applied_variation="all"!==$single_combination?applied_variation.slice(1,-1):applied_variation,$.isEmptyObject(variationsArray))?v0===JSON.stringify(variationsArray)&&(response=v[1]).length>0&&$.merge(variations_items,response):-1!==v0.indexOf(applied_variation)&&(response=v[1]).length>0&&$.merge(variations_items,response)})),variations_items.length>0)variations_items=uniqueMultidimensionalArray(variations_items,"full_url"),$(".wcgs-gallery-preloader").css("z-index",99),$(".wcgs-gallery-preloader").css("opacity",0),$("#wpgs-gallery").addClass("wcgs-transition-none"),wcgs_swiper_thumb.destroy(!0),wcgs_swiper_gallery.destroy(!0),$("#wpgs-gallery .wcgs-carousel .swiper-wrapper > *, #wpgs-gallery .gallery-navigation-carousel .swiper-wrapper > *").remove(),variations_items.forEach((function(item,index){var caption=item.cap.length>0?item.cap:"";if(null!=item)if(void 0!==item.video&&0===Object.keys(variationsArray).length&&item.video.indexOf("youtub")>-1&&!video_showed){var video=item.video,youtubeCheck;if(video.indexOf("youtub")>-1){var regExp=/^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/,match=video.match(regExp),id=!(!match||11!=match[7].length)&&match[7];video_only_popup?($("#wpgs-gallery .wcgs-carousel .swiper-wrapper").append('<div class="swiper-slide"><div class="wcgs-slider-image"><a class="wcgs-slider-lightbox" href="'+video+'" data-fancybox="view" data-fancybox-height="600" data-fancybox-width="400" aria-label="lightbox" ></a><img alt="'+caption+'" src="'+item.url+'" data-type="youtube" data-image="'+item.full_url+'" /></div></div>'),$("#wpgs-gallery .gallery-navigation-carousel .swiper-wrapper").append('<div class="wcgs-thumb swiper-slide"><img alt="'+caption+'" src="'+item.thumb_url+'" data-type="youtube" data-image="'+item.url+'" /></div>')):($("#wpgs-gallery .wcgs-carousel .swiper-wrapper").append('<div class="swiper-slide"><div class="wcgs-slider-image"><a class="wcgs-slider-lightbox" href="'+video+'" data-fancybox="view" data-fancybox-height="600" data-fancybox-width="400" aria-label="lightbox" ></a><div class="wcgs-iframe-wrapper"><div class="skip-lazy wcgs-iframe wcgs-youtube-video" data-video-id="'+id+'" data-src="'+video+'"></div><img style="visibility: hidden" alt="'+caption+'" src="'+item.url+'" data-type="youtube" data-image="'+item.full_url+'" /></div></div></div>'),$("#wpgs-gallery .gallery-navigation-carousel .swiper-wrapper").append('<div class="wcgs-thumb swiper-slide"><img alt="'+caption+'" src="'+item.thumb_url+'" data-type="youtube" data-image="'+item.url+'" /></div>')),video_showed=!0}}else $("#wpgs-gallery .wcgs-carousel .swiper-wrapper").append('<div class="swiper-slide"><div class="wcgs-slider-image"><a class="wcgs-slider-lightbox" href="'+item.full_url+'" data-fancybox="view" aria-label="lightbox"></a><img alt="'+caption+'" src="'+item.url+'" data-image="'+item.full_url+'" /></div></div>'),$("#wpgs-gallery .gallery-navigation-carousel .swiper-wrapper").append('<div class="wcgs-thumb swiper-slide"><img alt="'+caption+'" src="'+item.thumb_url+'" data-image="'+item.url+'" /></div>')})),$("#wpgs-gallery").wpgspimagesLoaded().then((function(){setTimeout((function(){wcgs_zoom&&(dataZoom(),zoomEffect()),initializeYouTubeVideos(),videoIcon(),wcgsLightbox(),$(".wcgs-gallery-preloader").css("z-index",-99),$(".wcgs-gallery-preloader").css("opacity",0),setTimeout(()=>{$("#wpgs-gallery").removeClass("wcgs-transition-none")},600)}),200)}))}})),$(document).on("click",".wcgs-gallery-slider .variations .select-option.swatch-wrapper",(function(e){var $this,$option_wrapper,$wc_select_box;$(this).closest("div.select").eq(0).find("select").first().trigger("change")}))}))}(jQuery);