(()=>{"use strict";const n=window.redditAdsTrackingData;let e=function(n){return n.PAGE_VIEW="PageVisit",n.VIEW_CONTENT="ViewContent",n.ADD_TO_CART="AddToCart",n}({});const t=(n,e)=>{if("function"!=typeof rdt)throw new Error("Function rdt not implemented.");window.rdt("track",n,{...e})},o=e=>{var t;return n.pixel_data.products[e.id]&&(e.name=n.pixel_data.products[e.id].name,e.prices=(t=n.pixel_data.products[e.id].price,{price:Math.round(t*10**n.pixel_data.currency_minor_unit),currency_minor_unit:n.pixel_data.currency_minor_unit})),e},r=(o,r=1,i=null)=>{const{id:c,name:a,price:d}=((n,e)=>{const t={id:n.id,name:n.name,quantity:e};return n?.prices?.price&&(t.price=parseInt(n.prices.price,10)/10**n.prices.currency_minor_unit),t})(o,r),u={itemCount:parseInt(r,10),value:d*parseInt(r,10),currency:n.currency,products:[{id:c,name:a}]};i&&(u.conversionId=i),t(e.ADD_TO_CART,u)};function i(e=""){return`${n.prefix}${e}`}function c(e,t={}){"string"==typeof e&&e&&"object"==typeof t&&fetch(`${n.ajax_url}`,{method:"POST",credentials:"same-origin",keepalive:!0,body:new URLSearchParams({action:i(e),payload:JSON.stringify(t),security:n.capi_nonce})})}function a(n,e){document.defaultView.addEventListener("DOMContentLoaded",function(){n.forEach(n=>{document.querySelectorAll(n).forEach(n=>{n.addEventListener("click",e)})})})}function d(){return"function"!=typeof wp_has_consent||wp_has_consent("marketing")}function u(){if("undefined"==typeof performance)return!0;if(performance.getEntriesByType){const n=performance.getEntriesByType("navigation");if(n.length>0){const e=n[0].type;return"navigate"===e||"back_forward"===e}}return 0===performance.navigation?.type}const _=n.is_pixel_enabled,s=n.is_conversion_enabled;d()&&function(){const n=new URL(window.location.href).searchParams.get("rdt_cid");n&&(document.cookie=`rdtCid=${encodeURIComponent(n)}; path=/;`)}(),document.addEventListener("DOMContentLoaded",()=>{d()?(a([".single_add_to_cart_button"],e=>{const t=document.querySelector(`[name=${n.event_id_el_name}]`)?.value;_&&function(n,e=""){const t=n.target.closest("form.cart");if(!t)return;const i=t.querySelector("[name=add-to-cart]");if(!i)return;const c=t.querySelector("[name=variation_id]"),a=t.querySelector("[name=quantity]"),d=o({id:parseInt(c?c.value:i.value,10)});r(d,a?parseInt(a.value,10):1,e)}(e,t)}),a([".add_to_cart_button:not(.product_type_variable):not(.product_type_grouped):not(.wc-block-components-product-button__button)",'[data-block-name="woocommerce/product-button"] > .add_to_cart_button:not(.product_type_variable):not(.product_type_grouped)'],n=>{const t=window.crypto.randomUUID();_&&function(n,e=""){const t=n.currentTarget.dataset,i=o({id:t.product_id});r(i,t.quantity||1,e)}(n,t);const i=n.currentTarget.dataset;s&&i?.product_id&&c(e.ADD_TO_CART,{conversionId:t,productId:i.product_id,quantity:1})}),(()=>{if(u()&&n.VIEW_CONTENT){const o={...n.VIEW_CONTENT,conversionId:window.crypto.randomUUID()};n.is_pixel_enabled&&t(e.VIEW_CONTENT,o),n.is_conversion_enabled&&c(e.VIEW_CONTENT,{conversionId:o.conversionId,products:{id:o.products[0]?.id,name:o.products[0]?.name}})}})(),(()=>{if(u()&&n.PAGE_VIEW){const o={conversionId:window.crypto.randomUUID()};n.is_pixel_enabled&&t(e.PAGE_VIEW,o),n.is_conversion_enabled&&c(e.PAGE_VIEW,o)}})()):console.info("[Reddit] Marketing consent denied. Tracking skipped.")}),document.addEventListener("wp_listen_for_consent_change",n=>{"allow"===n.detail.marketing&&window.location.reload()}),"function"==typeof jQuery&&jQuery(document).on("found_variation","form.cart",function(e,t){(e=>{e?.variation_id&&(n.pixel_data.products[e.variation_id]={price:e.display_price,name:n.VIEW_CONTENT.products.name})})(t)})})();