1require(['jquery','mage/cookies','Magento_Customer/js/customer-data'],function($,mageCookies,customerData){(function(){'use strict';const COOKIE_NAME='pmTPTrack';const CONSENT_STORAGE_KEY='pfm-consent-granted';const DEFAULT_TIMESTAMP_OFFSET=100;function getQueryParam(paramName){const regex=new RegExp("[\\?&]"+paramName+"=([^&#]*)");const result=regex.exec(location.search);return result===null?"":decodeURIComponent(result[1].replace(/\+/g," "));} 2function parseGclidCookie(cookieValue){if(!cookieValue){return null;} 3const parts=cookieValue.split('.');if(parts.length>=3){const gclid=parts.slice(2).join('.');return gclid?gclid:null;} 4return null;} 5function getGoogleClickId(allCookies){const urlGclid=getQueryParam("gclid");if(urlGclid){return urlGclid;} 6const gclAwGclid=parseGclidCookie(allCookies['_gcl_aw']);if(gclAwGclid){return gclAwGclid;} 7const fpgclawGclid=parseGclidCookie(allCookies['FPGCLAW']);if(fpgclawGclid){return fpgclawGclid;} 8return"";} 9function parseGACookies(){const gaCookieRegex=/^_ga_([A-Z0-9]+)/;return document.cookie.split(';').map(cookie=>{const trimmedCookie=cookie.trim();const match=trimmedCookie.match(gaCookieRegex);if(!match){return null;} 10const measurementId=match[1];const cookieValue=trimmedCookie.substring(trimmedCookie.indexOf('=')+1);const cookieParts=cookieValue.split('.');const isGS2Format=cookieValue.includes('GS2');
10const parsedData={measurementId,sessionId:null,sessionCount:null};if(isGS2Format&&cookieParts.length>=3){const dataSegments=cookieParts[2].split('$');const sessionSegment=dataSegments.find(segment=>segment.startsWith('s'));const countSegment=dataSegments.find(segment=>segment.startsWith('o'));if(sessionSegment){parsedData.sessionId=sessionSegment.substring(1);} 11if(countSegment){parsedData.sessionCount=countSegment.substring(1);}}else if(!isGS2Format){if(cookieParts.length>=3){parsedData.sessionId=cookieParts[2];} 12if(cookieParts.length>=5){parsedData.sessionCount=cookieParts[4];}} 13return parsedData;}).filter(Boolean);} 14function loadTrackingData(){const stored=$.cookie(COOKIE_NAME);if(stored){try{return JSON.parse(stored);}catch(e){try{return JSON.parse(decodeURIComponent(stored));}catch(e2){}}} 15return{gclid:null,gacid:null,gacid_source:null,fbp:null,fbc:null,gbraid:null,wbraid:null,sccid:null,ttclid:null,msclkid:null,twclid:null,ga4SessionId:null,ga4SessionCount:null,timestamp:(Math.floor(Date.now()/ 1000)-DEFAULT_TIMESTAMP_OFFSET)};} 16function saveTrackingData(trackingData){const cookieValue=JSON.stringify(trackingData);$.cookie(COOKIE_NAME,cookieValue,{path:'/',expires:90});} 17function mergeTrackingUpdates(trackingData,updates){let hasChanges=false;const newData={...trackingData};for(const[key,value]of Object.entries(updates)){if(value!==null&&value!==undefined&&value!==""&&newData[key]!==value){if(key==='gacid'&&newData.gacid_source==='gatracker'&&updates.gacid_source!=='gatracker'){continue;} 18newData[key]=value;hasChanges=true;}} 19if(hasChanges){newData.timestamp=Math.floor(Date.now()/ 1000);} 20return newData;} 21function fetchAnalyticsClientId(currentData,retries=10){if(typeof ga!=='function'){if(retries>0){setTimeout(()=>fetchAnalyticsClientId(currentData,retries-1),100);} 22return;} 23try{ga(function(tracker){const gacid=tracker.get('clientId');if(gacid&&(currentData.gacid!==gacid||currentData.gacid_source!=='gatracker')){const updatedData=mergeTrackingUpdates(currentData,{gacid:gacid,gacid_source:'gatracker'});saveTrackingData(updatedData);}});}catch(error){}} 24function init(){let trackingData;try{trackingData=loadTrackingData();}catch(error){return;} 25const allCookies=document.cookie.split(';').reduce((acc,cookie)=>{const parts=cookie.trim().split('=');acc[parts.shift()]=parts.join('=');return acc;},{});const gaCookieData=parseGACookies();const{sessionIds,sessionCounts}=gaCookieData.reduce((acc,data)=>{if(data.sessionId){acc.sessionIds.push(`${data.measurementId}:${data.sessionId}`);} 26if(data.sessionCount){acc.sessionCounts.push(`${data.measurementId}:${data.sessionCount}`);} 27return acc;},{sessionIds:[],sessionCounts:[]});const updates={fbc:allCookies["_fbc"]||null,fbp:allCookies["_fbp"]||null,gacid:allCookies["_ga"]||null,gacid_source:null,gclid:getGoogleClickId(allCookies),gbraid:getQueryParam("gbraid"),wbraid:getQueryParam("wbraid"),sccid:getQueryParam("sccid"),ttclid:getQueryParam("ttclid"),msclkid:getQueryParam("msclkid"),twclid:getQueryParam("twclid"),ga4SessionId:sessionIds.join(','),ga4SessionCount:sessionCounts.join(','),cc_marketing:window.cc_marketing,cc_statistics:window.cc_statistics};trackingData=mergeTrackingUpdates(trackingData,updates);saveTrackingData(trackingData);document.dispatchEvent(new CustomEvent('profitmetrics:consentUpdated',{detail:{marketing:window.cc_marketing,statistics:window.cc_statistics}}));fetchAnalyticsClientId(trackingData);const consentGranted=window.cc_marketing||window.cc_statistics;localStorage.setItem(CONSENT_STORAGE_KEY,consentGranted);} 28window.cc_statistics=false;window.cc_marketing=false;function checkCookiebotConsent(){if(typeof Cookiebot!=='undefined'&&Cookiebot.consent){return{statistics:Cookiebot.consent.statistics,marketing:Cookiebot.consent.marketing};} 29return null;} 30function checkCookieInformationConsent(){if(typeof CookieInformation!=='undefined'&&typeof CookieInformation.getConsentGivenFor==='function'){return{statistics:CookieInformation.getConsentGivenFor('cookie_cat_statistic'),marketing:CookieInformation.getConsentGivenFor('cookie_cat_marketing')};} 31return null;} 32function checkOneTrustConsent(activeGroups){const groups=activeGroups||(typeof OnetrustActiveGroups!=='undefined'?OnetrustActiveGroups:null);if(groups){return{statistics:groups.includes("2"),marketing:groups.includes("4")};} 33return null;} 34function checkCookieYesConsent(acceptedCategories){if(acceptedCategories){return{statistics:acceptedCategories.includes("analytics"),marketing:acceptedCategories.includes("advertisement")};}else if(typeof getCkyConsent==='function'&&getCkyConsent()?.categories?.analytics!==undefined){const consent=getCkyConsent();return{statistics:consent.categories.analytics,marketing:consent.categories.advertisement};} 35return null;} 36function checkCookieFirstConsent(consentData){const consent=consentData||(typeof CookieFirst!=='undefined'?CookieFirst.consent:null);if(consent){return{statistics:consent.performance,marketing:consent.advertising};} 37return null;} 38function checkCookieScriptConsent(){if(typeof CookieScript!=='undefined'&&CookieScript.instance?.currentState){const categories=CookieScript.instance.currentState().categories||[];return{statistics:categories.includes("performance"),marketing:categories.includes("targeting")};} 39return null;} 40function checkGoogleConsentMode(){if(window.google_tag_data?.ics?.entries){const entries=window.google_tag_data.ics.entries;return{statistics:entries.analytics_storage?.update==='granted',marketing:entries.ad_storage?.update==='granted'};} 41return null;} 42function checkMagentoNativeConsent(){const consent=customerData.get('cookie-status')();if(consent&&typeof consent.allowed_cookies!=='undefined'){const isGranted=consent.allowed_cookies.length>0;return{statistics:isGranted,marketing:isGranted};} 43return null;} 44function processConsentChange(statisticsConsent,marketingConsent){const hasStatistics=!!statisticsConsent;const hasMarketing=!!marketingConsent;if(statisticsConsent===undefined&&marketingConsent===undefined)return;if(window.cc_statistics===hasStatistics&&window.cc_marketing===hasMarketing)return;window.cc_statistics=hasStatistics;window.cc_marketing=hasMarketing;init();} 45function initializeConsentListeners(){const consentPlatformConfigs={CookiebotOnConsentReady:{handler:()=>{const c=checkCookiebotConsent();if(c)processConsentChange(c.statistics,c.marketing);}},CookieInformationConsentGiven:{handler:()=>{const c=checkCookieInformationConsent();if(c)processConsentChange(c.statistics,c.marketing);}},OneTrustGroupsUpdated:{handler:(e)=>{const c=checkOneTrustConsent(e.detail||[]);if(c)processConsentChange(c.statistics,c.marketing);}},cookieyes_consent_update:{handler:(e)=>{const c=checkCookieYesConsent(e.detail.accepted||[]);if(c)processConsentChange(c.statistics,c.marketing);},target:document},cf_consent:{handler:(e)=>{const c=checkCookieFirstConsent(e.detail||{});if(c)processConsentChange(c.statistics,c.marketing);}},cf_consent_loaded:{handler:(e)=>{const c=checkCookieFirstConsent(e.detail||{});if(c)processConsentChange(c.statistics,c.marketing);}},'CookieScriptCategory-strict':{handler:()=>{const c=checkCookieScriptConsent();if(c)processConsentChange(c.statistics,c.marketing);}}};for(const[eventName,config]of Object.entries(consentPlatformConfigs)){(config.target||window).addEventListener(eventName,config.handler);} 46if(window.google_tag_data?.ics?.addListener){const processGoogleConsent=()=>{const c=checkGoogleConsentMode();if(c)processConsentChange(c.statistics,c.marketing);};window.google_tag_data.ics.addListener(["ad_storage","analytics_storage"],processGoogleConsent);} 47const magentoConsentObservable=customerData.get('cookie-status');magentoConsentObservable.subscribe(function(consentData){if(consentData&&typeof consentData.allowed_cookies!=='undefined'){const isGranted=consentData.allowed_cookies.length>0;processConsentChange(isGranted,isGranted);}});} 48function runInitialConsentCheck(){let consentDeterminedByCmp=false;const cmpChecks=[checkMagentoNativeConsent,checkCookiebotConsent,checkCookieInformationConsent,checkOneTrustConsent,checkCookieYesConsent,checkCookieFirstConsent,checkCookieScriptConsent,checkGoogleConsentMode];for(const check of cmpChecks){const consent=check();if(consent){processConsentChange(consent.statistics,consent.marketing);consentDeterminedByCmp=true;break;}} 49if(!consentDeterminedByCmp){const previousDecision=localStorage.getItem(CONSENT_STORAGE_KEY);if(!('blockScriptBeforeConsent'in window)||!window.blockScriptBeforeConsent||previousDecision==='true'){processConsentChange(true,true);}}} 50function startTracking(){initializeConsentListeners();runInitialConsentCheck();} 51if(document.readyState==='loading'){window.addEventListener("DOMContentLoaded",startTracking);}else{startTracking();} 52window.load_pmTPTrack=init;})();});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.