"use strict";(globalThis.webpackChunkwoocommerce_product_options=globalThis.webpackChunkwoocommerce_product_options||[]).push([[846],{8071:(e,t,r)=>{r.d(t,{default:()=>c});const i=()=>{const e=window.jQuery;"function"==typeof e.fn.slick&&e(".tbh-carousel").slick("slickGoTo",0)},o=(e,t)=>{var r,o;const c=window.jQuery,s=(e||t)?.closest("form");if(!s)return;const l=s.closest(".product"),n=l.querySelector(".images"),a=n?.querySelector("img.wp-post-image"),d=l.querySelector(".flex-control-nav");if(!1===e)return c(d?.querySelector("li:nth-child(1) img")).trigger("click"),void i();const u=JSON.parse(null!==(r=e?.dataset?.image)&&void 0!==r&&r),g=null!==(o=u?.gallery_thumbnail_src)&&void 0!==o?o:"";t?.classList.contains("wpo-image-selected")&&i(),a?.dataset&&!a.dataset.srcset&&(a.dataset.srcset=a.srcset);const m=d?.querySelectorAll('li img[src="'+g+'"]');m?.length>0?(c(m).trigger("click"),window.setTimeout(function(){c(window).trigger("resize"),c(n).trigger("woocommerce_gallery_init_zoom")},20)):((e,t)=>{var r;const o=window.jQuery,c=o(e.closest(".product")),s=c.find(".images"),l=c.find(".flex-control-nav"),n=JSON.parse(null!==(r=t?.dataset?.image)&&void 0!==r&&r);if(n?.src){const t=l.find('li img[src="'+n?.gallery_thumbnail_src+'"]');if(t.length>0)return t.trigger("click"),e.setAttribute("current-image",n?.image_id),void window.setTimeout(function(){o(window).trigger("resize"),s.trigger("woocommerce_gallery_init_zoom")},20);if("function"==typeof o.fn.slick&&n?.gallery_thumbnail_src){const e=o(".thb-carousel"),t=e.find(`div[data-thumb="${n.gallery_thumbnail_src}"]`).index();return void e.slick("slickGoTo",t)}const r=s.find("img.wp-post-image"),i=r.closest(".woocommerce-product-gallery__image").find("img.zoomImg");r.length>0&&(r.attr("src",n.src),r.attr("srcset",n.srcset),r.attr("sizes",n.sizes),i.attr("src",n.full_src),e.setAttribute("current-image",n.image_id))}else i()})(s,e)},c={init:function(){Array.from(document.querySelectorAll(".wpo-field-with-images")).forEach(e=>{const t=e?.classList?.contains("wpo-field-dropdown")?"option":"input",r=e.querySelector(".wpo-image-active"),i=e.querySelectorAll(t);Array.from(i).forEach(e=>{e.addEventListener("change",()=>{Array.from(i).filter(e=>e?.checked).length<1&&o(!1,r)})}),e.addEventListener("click",t=>{if(e.classList.contains("wpo-field-dropdown")){const i=e.querySelector("select");if(i){const e=i.querySelector(`[value="${t.target?.dataset?.value}"]`);e&&o(e,r)}}else o(t.target.closest("[data-image]"),r)})})}}}}]);