!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;"undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.sbjs=e()}}(function(){return function e(t,r,a){function n(s,o){if(!r[s]){if(!t[s]){var c="function"==typeof require&&require;if(!o&&c)return c(s,!0);if(i)return i(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var p=r[s]={exports:{}};t[s][0].call(p.exports,function(e){var r=t[s][1][e];return n(r||e)},p,p.exports,e,t,r,a)}return r[s].exports}for(var i="function"==typeof require&&require,s=0;s0))return r=s.getHost(e),!0;for(var t=0;t0)for(var i=0;i0)for(var s=0;se.split(".").reduce((t,e)=>t&&t[e],t)),s=()=>null,o=t=>null===t||void 0===t?"":t,i="wc/store/checkout";function a(t){!function(){const t=new Set;document.querySelectorAll("wc-order-attribution-inputs").forEach(e=>{const n=e.closest("form")||document;t.has(n)?e.remove():t.add(n)})}();for(const e of document.querySelectorAll("wc-order-attribution-inputs"))e.values=t}function c(t){window.wp&&window.wp.data&&window.wp.data.dispatch&&window.wc&&window.wc.wcBlocksData&&window.wp.data.dispatch(window.wc.wcBlocksData.CHECKOUT_STORE_KEY).setExtensionData("woocommerce/order-attribution",t,!0)}function r(){return"undefined"!=typeof sbjs}function d(){if(window.wp&&window.wp.data&&"function"==typeof window.wp.data.subscribe){const e=window.wp.data.subscribe(function(){e(),c(t.getAttributionData())},i)}}t.getAttributionData=function(){const o=e.allowTracking&&r()?n:s,i=r()?sbjs.get:{},a=Object.entries(t.fields).map(([t,e])=>[t,o(i,e)]);return Object.fromEntries(a)},t.setOrderTracking=function(n){if(e.allowTracking=n,n){if(!r())return;sbjs.init({lifetime:Number(e.lifetime),session_length:Number(e.session),base64:Boolean(e.base64),timezone_offset:"0"})}else!function(){const t=window.location.hostname;["sbjs_current","sbjs_current_add","sbjs_first","sbjs_first_add","sbjs_session","sbjs_udata","sbjs_migrations","sbjs_promo"].forEach(e=>{document.cookie=`${e}=; path=/; max-age=-999; domain=.${t};`})}();const s=t.getAttributionData();a(s),c(s)},t.setOrderTracking(e.allowTracking),"loading"===document.readyState?document.addEventListener("DOMContentLoaded",d):d(),window.customElements.define("wc-order-attribution-inputs",class extends HTMLElement{constructor(){if(super(),this._fieldNames=Object.keys(t.fields),this.hasOwnProperty("_values")){let t=this.values;delete this.values,this.values=t||{}}}connectedCallback(){this.innerHTML="";const t=new DocumentFragment;for(const n of this._fieldNames){const s=document.createElement("input");s.type="hidden",s.name=`${e.prefix}${n}`,s.value=o(this.values&&this.values[n]||""),t.appendChild(s)}this.appendChild(t)}set values(t){if(this._values=t,this.isConnected)for(const t of this._fieldNames){const n=this.querySelector(`input[name="${e.prefix}${t}"]`);n?n.value=o(this.values[t]):console.warn(`Field "${t}" not found. `+"Most likely, the '' element was manipulated.")}}get values(){return this._values}})}(window.wc_order_attribution); (function(){'use strict';var data=(typeof wc_facebook_pixel_data!=='undefined'&&wc_facebook_pixel_data)?wc_facebook_pixel_data:{eventQueue:[]};window.wcFacebookPixelFiredEvents=window.wcFacebookPixelFiredEvents||{};var firedEvents=window.wcFacebookPixelFiredEvents;function isCachedPage(){return window.__wc_fb_page_generated&&(Math.floor(Date.now()/1000)-window.__wc_fb_page_generated)>1800} function buildEventData(event){return{method:event.method||'track',name:event.name,params:event.params||{},eventId:isCachedPage()?null:(event.eventId||null)}} function shouldSkipEvent(eventId){return eventId&&firedEvents[eventId]} function markEventFired(eventId){if(eventId){firedEvents[eventId]=!0}} function logWarning(message,data){if(typeof console!=='undefined'&&console.warn){console.warn('[FB Pixel]',message,data)}} function fireEvent(event){var eventData=buildEventData(event);if(shouldSkipEvent(eventData.eventId)){return} try{var params=eventData.params;if(window.FacebookSignals&&typeof window.FacebookSignals.trackEvent==='function'){window.FacebookSignals.trackEvent(eventData.name,params,null,eventData.method,eventData.eventId)}else{if(typeof fbq!=='function'){logWarning('fbq not available, skipping event:',eventData.name);return} if(eventData.eventId){fbq(eventData.method,eventData.name,params,{eventID:eventData.eventId})}else{fbq(eventData.method,eventData.name,params)}} markEventFired(eventData.eventId)}catch(e){logWarning('Event error: '+eventData.name,e)}} function fireQueuedEvents(){var events=data.eventQueue;if(!events||!Array.isArray(events)){return} for(var i=0;i=200&&item.status<300){processStoreApiEvent(item.body.extensions['facebook-for-woocommerce'])}}}} function setupFetchInterceptor(){var originalFetch=window.fetch;if(!originalFetch){return} window.fetch=function(){var args=arguments;var url=getRequestUrl(args[0]);var isAddToCartRequest=isStoreApiAddItemRequest(url);var isBatchRequest=isStoreApiBatchRequest(url);return originalFetch.apply(this,args).then(function(response){if((isAddToCartRequest||isBatchRequest)&&response.ok){response.clone().json().then(function(responseData){processStoreApiResponseData(responseData)}).catch(function(e){logWarning('Store API JSON parse error:',e)})} return response})}} function init(){setupFetchInterceptor();if(typeof fbq==='function'){fireQueuedEvents();return} var _fbq=window.fbq;Object.defineProperty(window,'fbq',{configurable:!0,enumerable:!0,get:function(){return _fbq},set:function(value){_fbq=value;if(typeof value==='function'){Object.defineProperty(window,'fbq',{configurable:!0,enumerable:!0,writable:!0,value:value});setTimeout(fireQueuedEvents,0)}}})} if(document.readyState==='complete'){init()}else{window.addEventListener('load',init)}})();