!function(){"use strict";class e{constructor(e){this.app=e,this.getCanvasImage(),this.canvasHolder&&this.init()}init(){if(document.addEventListener("click",(e=>{let t=e.target.closest(".wapf-swatch");e.target&&t&&this.goToItem()})),"undefined"!=typeof jQuery){var e,t=rey.vars.is_desktop?500:reycore_wapf.typing_timer||1e3;jQuery(document).on("livecontent/before_drawing_text lcp/after_drawing_image",(s=>{clearTimeout(e),e=setTimeout((()=>{rey.vars.is_desktop?this.goToItem():this.scrollToItem()}),t)}))}}scrollToItem(){window.scrollTo({behavior:"smooth",top:rey.dom.offset(this.app.elements.gallery).top}),this.goToItem()}goToItem(){this.app.goToItem(this.canvasIndex)}getCanvasImage(){this.canvasIndex;for(let e=0;e<this.app.elements.galleryItems.length;e++){if(this.app.elements.galleryItems[e].querySelector(".wapf_canvas_wrapper")){this.canvasIndex=e,this.canvasHolder=this.app.elements.galleryItems[e],this.canvasHolder.setAttribute("data-no-zoom",""),this.canvasHolder.classList.add("wapf_canvas_wrapper--item");break}}}}document.addEventListener("rey/pdpGallery/beforeComponents",(function(t){new e(t.detail.app)}))}();