(()=>{var t={};t.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),((o,n)=>{if(!o)return;const{currency:e,products:i,purchase:a,add_to_cart:l,eventsToTrack:c}=(null===(n=t.g._googlesitekit)||void 0===n?void 0:n.wcdata)||{},r=null==c?void 0:c.includes("add_to_cart"),d=null==c?void 0:c.includes("purchase");if(l&&r){var u,s;const{price:o}=l,n=f(o,e,l);null===(u=t.g._googlesitekit)||void 0===u||null===(s=u.gtagEvent)||void 0===s||s.call(u,"add_to_cart",n)}if(a&&d){var g,_,p;const{id:o,totals:n,items:e,user_data:i}=a,l=f(n.total_price,n.currency_code,e,o,n.shipping_total,n.tax_total);null!==(g=t.g._googlesitekit)&&void 0!==g&&g.gtagUserData&&i&&(l.user_data=i),null===(_=t.g._googlesitekit)||void 0===_||null===(p=_.gtagEvent)||void 0===p||p.call(_,"purchase",l)}const v=o("body");function f(t,o,n){let e=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:null;const l={value:m(t),currency:o,items:[]};if(e&&(l.transaction_id=e),"number"==typeof i&&(l.shipping=i),"number"==typeof a&&(l.tax=a),n&&n.length)for(const t of n)l.items.push(h(t));else n&&n.id&&(l.items=[h(n)]);return l}function h(t){const{id:o,name:n,price:e,variation:i,quantity:a,categories:l}=t,c={item_id:o,item_name:n,price:m(e)};if(a&&(c.quantity=a),i&&(c.item_variant=i),l&&null!=l&&l.length){let t=1;for(const o of l)c[t>1?"item_category".concat(t):"item_category"]=o.name,t++}return c}function m(t){let o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;return parseInt(t,10)/10**o}r&&(v.on("added_to_cart",(o,n,a,l)=>{var c,r;const d=parseInt(l.data("product_id"),10);if(!d)return;const u=(null==i?void 0:i.find(t=>(null==t?void 0:t.id)===d))||{},{price:s}=u,g=f(s,e,u);null===(c=t.g._googlesitekit)||void 0===c||null===(r=c.gtagEvent)||void 0===r||r.call(c,"add_to_cart",g)}),o(".products-block-post-template .product, .wc-block-product-template .product").each(function(){const n=o(this),a=parseInt(n.find("[data-product_id]").attr("data-product_id"),10);a&&n.on("click",n=>{var l,c;const r=o(n.target).closest(".wc-block-components-product-button [data-product_id]");if(!r.length||!r.hasClass("add_to_cart_button")||r.hasClass("product_type_variable"))return;const d=(null==i?void 0:i.find(t=>(null==t?void 0:t.id)===a))||{},{price:u}=d,s=f(u,e,d);null===(l=t.g._googlesitekit)||void 0===l||null===(c=l.gtagEvent)||void 0===c||c.call(l,"add_to_cart",s)})}))})(t.g.jQuery)})();