(()=>{"use strict";var t={n:e=>{var o=e&&e.__esModule?()=>e.default:()=>e;return t.d(o,{a:o}),o},d:(e,o)=>{for(var n in o)t.o(o,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:o[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)};const e=jQuery;var o=t.n(e);function n(t=document){try{if("editor-canvas"===window.frameElement?.getAttribute?.("name"))return!0}catch(t){}const e=t?.body;return!!e&&(!!e.classList.contains("wp-admin")||(!!e.classList.contains("block-editor-iframe__body")||!!e.classList.contains("editor-styles-wrapper")))}document.addEventListener("DOMContentLoaded",function(){i.init()});const i={init:function(t){this.holder=document.querySelectorAll(".qi-block-product-list"),this.holder.length&&[...this.holder].map(e=>{i.initItem(e,t)})},getRealCurrentItem:function(t){return"string"==typeof t&&""!==t&&(t=qiBlocksEditor.qodefGetCurrentBlockElement.get(t)),t},initItem:function(t,e){if(!(t=i.getRealCurrentItem(t)))return;const o=t.querySelectorAll(".qi-block-button");o.length&&[...o].map(t=>{i.initButtonAction(t)}),i.initInfoBelowSwap(t,e)},initButtonAction:function(t){const e=t.querySelector(".qodef-m-icon"),r=t.querySelector(".qodef-add-to-cart-button-link");if(e){const o=n()?300:0;let i="auto";setTimeout(()=>{t&&t.classList.contains("qodef-type--icon-boxed")?i=parseInt(window.getComputedStyle(t).getPropertyValue("height"),10)+"px":r&&r.classList.contains("qodef-type--icon-boxed")&&(i=parseInt(window.getComputedStyle(r).getPropertyValue("height"),10)+"px"),e.style.width=i},o)}o()(document.body).on("added_to_cart",()=>{const e=setInterval(()=>{let o;o=t.classList.contains("add_to_cart_button")?t.nextElementSibling:t.querySelector(".added_to_cart"),o&&(clearInterval(e),i.setViewButtonMarkup(t,o))},100)})},setViewButtonMarkup:function(t,e){let o,n=["product_type_simple","add_to_cart_button","ajax_add_to_cart","added"];o=t.classList.contains("add_to_cart_button")?t:t.querySelector(".add_to_cart_button");let i=o.getAttribute("class").split(" ");i.length&&i.forEach(t=>{n.includes(t)||e.classList.add(t)}),e.innerHTML=o.innerHTML,e.querySelector(".qodef-m-text").innerHTML=qiBlocks.vars.viewCartText,e.classList.add("qodef--init")},initInfoBelowSwap:function(t,e){if(t.classList.contains("qodef-item-layout--info-below-swap")){const o=t.querySelectorAll(".qodef-e");o.length&&[...o].map(t=>{let o=t.querySelector(".qodef-e-swap-holder");if(o){let t=0;e&&(t=200,o.style.removeProperty("--qodef-max-width"),o.style.removeProperty("--qodef-max-height")),setTimeout(()=>{let t=o.querySelector(".qodef-woo-product-price"),e=o.querySelector(".qodef-e-to-swap .qi-block-button"),n=e?e.getBoundingClientRect().width:0,i=e?e.getBoundingClientRect().height:0,r=t?t.getBoundingClientRect().width:0,a=t?t.getBoundingClientRect().height:0,d=Math.ceil(Math.max(n,r)),c=Math.ceil(Math.max(i,a))+"px",l=o.parentNode.getBoundingClientRect().width;o.style.setProperty("--qodef-max-width",(l<d?l:d)+"px"),o.style.setProperty("--qodef-max-height",c),o.classList.add("qodef--initialized")},t)}})}}}})();