(function(){'use strict';var enableLogging_SendEvents=false;if(typeof UniPixelConsoleState!=='undefined'&&UniPixelConsoleState.logSendEvents===true){enableLogging_SendEvents=true;}
function log_Send(message,data){if(enableLogging_SendEvents&&typeof UniPixelConsoleLogger!=='undefined'){UniPixelConsoleLogger.log('SEND',message,data);}}
function getCookie(name){const match=document.cookie.match(new RegExp('(?:^|; )'+name.replace(/([$?*|{}()[\]\\/+^])/g,'\\$1')+'=([^;]*)'));return match?decodeURIComponent(match[1]):null;}
function parseOneTrust(){const consent=getCookie('OptanonConsent');if(!consent)return{};const parsed={};const groupsMatch=consent.match(/groups=([^;]+)/);if(!groupsMatch)return{};const pairs=groupsMatch[1].split(',');pairs.forEach(pair=>{const[group,value]=pair.split(':');if(group&&value){if(group==='C0001')parsed.marketing=(value==='1');if(group==='C0002')parsed.performance=(value==='1');if(group==='C0003')parsed.functional=(value==='1');}});return parsed;}
function parseSilktide(){const cookie=getCookie('CookieControl');if(!cookie)return{};try{const json=JSON.parse(cookie);if(!json||!json.categories)return{};return{marketing:!!json.categories.marketing,performance:!!json.categories.performance,functional:!!json.categories.functional};}catch(e){return{};}}
function parseCookiebot(){const cookie=getCookie('CookieConsent');if(!cookie)return{};try{const json=JSON.parse(cookie);return{necessary:!!json.necessary,performance:!!(json.statistics||json.preferences),marketing:!!json.marketing};}catch(e){return{};}}
function parseOsano(){const cookie=getCookie('osano_consentmanager');if(!cookie)return{};try{const json=JSON.parse(cookie);if(!json||!json.consent)return{};return{marketing:!!json.consent.marketing,performance:!!json.consent.performance,functional:!!json.consent.functional};}catch(e){return{};}}
function parseOrestBida(){const cookie=getCookie('cc_cookie')||getCookie('cookie_consent');if(!cookie)return{};try{const json=JSON.parse(cookie);const accepted=json.categories||json.acceptedCategories||[];return{necessary:accepted.includes('necessary'),functional:accepted.includes('functional')||accepted.includes('preferences'),performance:accepted.includes('performance')||accepted.includes('analytics')||accepted.includes('statistics'),marketing:accepted.includes('marketing')||accepted.includes('advertising')};}catch(e){return{};}}
function parseComplianz(){const marketing=getCookie('cmplz_marketing');const statistics=getCookie('cmplz_statistics');const functional=getCookie('cmplz_functional');const preferences=getCookie('cmplz_preferences');if(!marketing&&!statistics&&!functional&&!preferences)return{};return{necessary:true,marketing:marketing==='allow',performance:statistics==='allow',functional:functional==='allow'||preferences==='allow'};}
function parseCookieYes(){const cookie=getCookie('cookieyes-consent');if(!cookie)return{};const parsed={};const pairs=cookie.split(',');pairs.forEach(function(pair){const parts=pair.split(':');if(parts.length>=2){parsed[parts[0].trim()]=parts[1].trim();}});return{necessary:true,functional:parsed.functional==='yes',performance:parsed.analytics==='yes'||parsed.performance==='yes',marketing:parsed.advertisement==='yes'};}
function parseMooveGdpr(){const cookie=getCookie('moove_gdpr_popup');if(!cookie)return{};const parsed={};const pairs=cookie.split(',');pairs.forEach(function(pair){const parts=pair.split(':');if(parts.length===2){parsed[parts[0].trim()]=parts[1].trim();}});return{necessary:true,marketing:parsed.thirdparty==='1',performance:parsed.advanced==='1'};}
function unipixel_applyConsentToGtag(){if(typeof gtag!=='function'){setTimeout(unipixel_applyConsentToGtag,100);return;}
try{const match=document.cookie.match(/(?:^|; )unipixel_consent_summary=([^;]*)/);if(!match)return;const summary=JSON.parse(decodeURIComponent(match[1]));gtag('consent','update',{'ad_storage':summary.marketing?'granted':'denied','analytics_storage':summary.performance?'granted':'denied','functionality_storage':summary.functional?'granted':'denied','security_storage':'granted'});console.log('UniPixel → Google consent updated:',summary);}catch(e){console.warn('UniPixel → Google consent mapping failed',e);}}
function unipixel_applyConsentToMicrosoftUET(){if(typeof window.uetq==='undefined')return;try{const match=document.cookie.match(/(?:^|; )unipixel_consent_summary=([^;]*)/);if(!match)return;const summary=JSON.parse(decodeURIComponent(match[1]));window.uetq.push('consent','ad_storage',summary.marketing?'granted':'denied');console.log('UniPixel → Microsoft UET consent updated:',summary.marketing?'granted':'denied');}catch(e){console.warn('UniPixel → Microsoft UET consent mapping failed',e);}}
window.unipixelCreateConsentSummaryFromVendors=function(){const summary={necessary:true,functional:null,performance:null,marketing:null};Object.assign(summary,parseOneTrust());Object.assign(summary,parseSilktide());Object.assign(summary,parseOsano());Object.assign(summary,parseCookiebot());Object.assign(summary,parseOrestBida());Object.assign(summary,parseComplianz());Object.assign(summary,parseCookieYes());Object.assign(summary,parseMooveGdpr());document.cookie='unipixel_consent_summary='+
encodeURIComponent(JSON.stringify(summary))+'; path=/; SameSite=Lax';};window.addEventListener('load',()=>{if(typeof window.UniPixelSettings==='undefined'){return;}
if(typeof window.UniPixelSettings.consent_honour==='undefined'){return;}
if(window.UniPixelSettings.consent_honour!=1){return;}else{}
if(typeof window.unipixelCreateConsentSummaryFromVendors!=='function'){return;}
if(window.UniPixelSettings&&window.UniPixelSettings.consent_honour==1&&window.UniPixelSettings.consent_ui==='unipixel'){return;}
window.unipixelCreateConsentSummaryFromVendors();unipixel_applyConsentToGtag();unipixel_applyConsentToMicrosoftUET();});window.unipixelCheckConsentForEvent=function(){try{if(!window.UniPixelSettings||parseInt(window.UniPixelSettings.consent_honour,10)!==1){log_Send('UniPixel | Consent Check | Honour-Consent setting is OFF: allowing event.');return true;}
var cookie=document.cookie.match(/(?:^|; )unipixel_consent_summary=([^;]*)/);if(!cookie){log_Send('UniPixel | Consent Check | Honour-Consent setting is ON, but no consent cookie found: blocking event.');return false;}
var summary=JSON.parse(decodeURIComponent(cookie[1]));if(!summary.marketing||!summary.performance){log_Send('UniPixel | Consent Check | Honour-Consent setting is ON and choices say not allowed: blocking event | marketing: '+summary.marketing+' | performance: '+summary.performance);return false;}
log_Send('UniPixel | Consent | Honour Consent is ON and choices allow event: allowing event | marketing: '+summary.marketing+' | performance: '+summary.performance);return true;}catch(e){log_Send('UniPixel | Consent | Consent check failed, blocking event by default.',e);return false;}};})();