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