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