/** * @id5io/id5-api.js * @version v1.0.97 * @link https://id5.io/ * @license Apache-2.0 */ !function(){"use strict";function i(t,e){var r,i=Object.keys(t);return Object.getOwnPropertySymbols&&(r=Object.getOwnPropertySymbols(t),e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),i.push.apply(i,r)),i}function v(t){for(var e=1;ee.length)&&(t=e.length);for(var r=0,i=new Array(t);r=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:t}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var n,s=!0,o=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return s=e.done,e},e:function(e){o=!0,n=e},f:function(){try{s||null==r.return||r.return()}finally{if(o)throw n}}}}function r(e,t,r){return function(e,t){if(e!==t)throw new TypeError("Private static access of wrong provenance")}(e,t),r}function o(e,t,r){if(!t.has(e))throw new TypeError("attempted to get private field on non-instance");return r}class e{debug(){}info(){}warn(){}error(){}}const g=new e;function l(e,t){var r="^\\d+(\\.\\d+(\\.\\d+){0,1}){0,1}$";if(e.match(r)&&t.match(r)){var i=e.split("."),n=t.split("."),r=e=>parseInt(e)||0,e=(e,t)=>{t=e-t;return 0==t?0:t<0?-1:1},t=e(r(i[0]),r(n[0]));if(0!==t)return t;t=e(r(i[1]),r(n[1]));return 0===t?e(r(i[2]),r(n[2])):t}}const s="Array",p="String",m="Function",I=Object.prototype.toString;function w(e,t){return I.call(e)==="[object "+t+"]"}function S(e){return w(e,m)}function y(e){return w(e,p)}function C(e){return w(e,s)}function b(e){return w(e,"Number")}function D(e){return w(e,"Object")}function E(e){return void 0!==e}function T(t,r){if(!function(e){if(!e)return 1;if(C(e)||y(e))return!(0{let r=t.split("="),i=h(r,2),n=i[0],s=i[1];return/\[\]$/.test(n)?(n=n.replace("[]",""),e[n]=e[n]||[],e[n].push(s)):e[n]=s||"",e},{}):{},hash:(r.hash||"").replace(/^#/,""),host:r.host||window.location.host}}function A(e){return(e.protocol||"http")+"://"+(e.host||e.hostname+(e.port?":".concat(e.port):""))+(e.pathname||"")+(e.search?"?".concat((r=e.search||"",Object.keys(r).map(t=>Array.isArray(r[t])?r[t].map(e=>"".concat(t,"[]=").concat(e)).join("&"):"".concat(t,"=").concat(r[t])).join("&"))):"")+(e.hash?"#".concat(e.hash):"");var r}function O(r,e){function i(e,t){if(S(Math.imul))return Math.imul(e,t);var r=(4194303&e)*(t|=0);return 4290772992&e&&(r+=(4290772992&e)*t|0),0|r}e=1>>16,2246822507)^i(s^s>>>13,3266489909),s=i(s^s>>>16,2246822507)^i(n^n>>>13,3266489909),(4294967296*(2097151&s)+(n>>>0)).toString()}const R="TRUE"===k("id5_debug").toUpperCase(),N="TRACE"===k("id5_debug").toUpperCase(),x=Boolean(window.console);let L=!1;function F(e,t,r,i,n){U()&&x&&e&&e.apply(console,["%cID5 - ".concat(t,"#").concat(r),"color: #fff; background: #1c307e; padding: 1px 4px; border-radius: 3px;",i].concat(n))}function U(){return R||N||L}class j extends e{constructor(e,t){super(),d(this,"_invocationId",void 0),d(this,"_origin",void 0),this._invocationId=t,this._origin=e}debug(){for(var e=arguments.length,t=new Array(e),r=0;rnull!=e&&"object"==typeof e;function X(e,t){if(!(z(e)&&z(t)))return e===t;if(W(e)&&W(t))return function(t,r){var e=t.length===r.length;if(!e)return;for(let e=0;e{let i=r.data;if(void 0!==r.data&&r.data._isId5Message&&r.data.src!==n._id&&(void 0===r.data.dst||r.data.dst===n._id))try{[Z,i.type].forEach(e=>{let t=n._handlers[e];t&&t.forEach(e=>e(i,r.source))})}catch(e){n._log.error("Error while handling message",i,e)}},{capture:!1,signal:e})}unregister(){this._abortController&&this._abortController.abort()}onAnyMessage(e){return this.onMessage(Z,e)}onMessage(e,t){const r=this._handlers[e];return r?r.push(t):this._handlers[e]=[t],this}broadcastMessage(e,t){this._log.debug("Broadcasting message",t,e),this._postMessage(this._messageFactory.createBroadcastMessage(e,t))}sendResponseMessage(e,t){var r=2void 0===e.dst?(this._countInvalidMessage(e,"no-destination-proxy"),void this._log.error("Received invalid RemoteMethodCallMessage message",JSON.stringify(e),"Ignoring it....")):void t._handle(u(new ne,e.payload)))}_countInvalidMessage(e,t){var r=e=>null!=e;void 0!==this._metrics&&!function(e,t){return e.counter("instance.message.invalid.count",1t[e]).reduce((e,t)=>e&&t,!0);return new _e(i,ve.CONSENT_API,t,r)}_addToDebugInfo(e,t,r){return void 0!==t.localStoragePurposeConsent&&(r[e+"-localStoragePurposeConsent"]=t.localStoragePurposeConsent),void 0!==t.vendorsConsentForId5Granted&&(r[e+"-vendorsConsentForId5Granted"]=t.vendorsConsentForId5Granted),r}_isGranted(){return!1===this.gdprApplies||!0===this.localStoragePurposeConsent&&!1!==this.vendorsConsentForId5Granted}hashCode(){this.localStoragePurposeConsent,this.ccpaString;var e=t(this,ae);return O(JSON.stringify(e))}static createFrom(e){const t=u(new pe,e);return E(t.api)&&(t.apiTypes=function(e){var t=e.api;if(t===de.NONE)return[];if(t!==de.PREBID)return[t];{const r=[];return(E(e.gdprApplies)||E(e.consentString))&&r.push(de.TCF_V2),E(e.ccpaString)&&r.push(de.USP_V1),E(e.gppData)&&E(e.gppData.version)&&r.push(e.gppData.version),r}}(e),t.api=void 0),D(t.gppData)&&(t.gppData=ge.createFrom(t.gppData)),t}getApiTypeData(e){if(this.apiTypes.includes(e)){if(e===de.USP_V1)return{ccpaString:this.ccpaString};if(e===de.TCF_V2)return{consentString:this.consentString,gdprApplies:this.gdprApplies,localStoragePurposeConsent:this.localStoragePurposeConsent};if(e===de.GPP_V1_1||e===de.GPP_V1_0)return this.gppData;if(e===de.ID5_ALLOWED_VENDORS)return{allowedVendors:this.allowedVendors}}}toConsents(){let e={};return E(this.gdprApplies)&&(e.gdpr=this.gdprApplies),E(this.consentString)&&(e.gdpr_consent=this.consentString),E(this.ccpaString)&&(e.us_privacy=this.ccpaString),E(this.gppData)&&(e.gpp=this.gppData.gppString,e.gpp_sid=this.gppData.applicableSections.join(",")),e}}const ve=Object.freeze({FORCE_ALLOWED_BY_CONFIG:"force_allowed_by_config",ID5_CONSENT:"id5_consent",PROVISIONAL:"provisional",JURISDICTION:"jurisdiction",CONSENT_API:"consent_api"});class _e{constructor(e,t){var r=2{var t=e.cacheId;n.has(t)||(e=r.getResponseFor(e.integrationId))&&(this._clientStore.storeResponseV2(t,e,r.timestamp,i),n.add(t))}),this._trueLinkAdapter.setPrivacy(null===(e=r.getGenericResponse())||void 0===e?void 0:e.privacy)}clearAll(e){this._clientStore.clearResponseV1(),this._clientStore.clearDateTime(),e.forEach(e=>{e=e.cacheId;this._clientStore.clearResponseV2(e)}),this._clientStore.clearHashedConsentData(),this._trueLinkAdapter.clearPrivacy(),this._clientStore.clearExtensions(),this._clientStore.clearSignature()}getCachedResponse(e){e=this._clientStore.getStoredResponseV2(e);if(e)return new Se(e.response,e.responseTimestamp,e.nb,e.consents)}getCachedSignature(){var e;return null===(e=this._clientStore.getStoredSignature())||void 0===e?void 0:e.signature}getCachedExtensions(){return this._clientStore.getExtensions()}storeExtensions(e){var t=b(e.ttl)?e.ttl/86400:Ie.DEFAULT.EXTENSIONS.expiresDays,t=new me(Ie.DEFAULT.EXTENSIONS.name,t);return this._clientStore.storeExtensions(e,t)}}class Se{constructor(e,t){var r=2e}isStale(){return!this.timestamp||this._isOlderThanSec(1209600)}isResponseComplete(){return D(this.response)&&y(this.response.universal_uid)&&y(this.response.signature)}isValid(){return this.isResponseComplete()&&!this.isStale()}getMaxAge(){var e,t;return null===(e=this.response)||void 0===e||null===(t=e.cache_control)||void 0===t?void 0:t.max_age_sec}getAgeSec(){return(Date.now()-this.timestamp)/1e3|0}}const ye="_exp";class Ce{constructor(e){var t=1{e.removeItem(t)};this._replicas.forEach(e),this._lastKeyOperation[t]=e}setItem(t,r){this._primaryStorage.setItem(t,r);var e=e=>{e.setItem(t,r)};this._replicas.forEach(e),this._lastKeyOperation[t]=e}addReplica(t){Object.values(this._lastKeyOperation).forEach(e=>e(t)),this._replicas.push(t)}getKeysWithPrefix(e){return this._primaryStorage.getKeysWithPrefix(e)}}const Ae="undefined"!=typeof Promise&&"undefined"!=typeof fetch;class Oe{constructor(e){var t=1function(r){Object.keys(r).forEach(function(e){var t=r[e];t&&(t instanceof Object?r[e]=JSON.stringify(t):r[e]="".concat(t))})}(e.tags)),fetch(this.url,{method:"POST",headers:{"Content-Type":"text/plain"},mode:"no-cors",body:JSON.stringify({metadata:v(v({},this._metadata),t),measurements:e})})):Promise.resolve()}}class Re{constructor(e,t){d(this,"_publisher",void 0),d(this,"_scheduled",void 0),this.meterRegistry=e,this._publisher=t;const r=this;this.meterRegistry.onUnregister(function(){const e=r._onUnloadPublishAbortController;if(e)return e.abort(),r.publish({trigger:"unregister"})})}publish(){let t=0this._publisher(e,t)).then(()=>this.meterRegistry.reset())}schedulePublishAfterMsec(e){const t=this;return t._scheduled||(setTimeout(()=>(t._scheduled=!1,t.publish({trigger:"fixed-time",fixed_time_msec:e})),e),t._scheduled=!0),this}schedulePublishBeforeUnload(){const e=this;var t="undefined"!=typeof AbortController?new AbortController:void 0;return t&&(addEventListener("beforeunload",()=>e.publish({trigger:"beforeunload"}),{capture:!1,signal:t.signal}),this._onUnloadPublishAbortController=t),this}}const Ne=Object.freeze({});var xe={EMPTY:Ne,from:function(e){return e?e instanceof Map?Object.fromEntries(e):e:Ne},toString:function(e){return Array.from(Object.entries(e),e=>{var t=h(e,2),e=t[0],t=t[1];return"".concat(e,"=").concat(t)}).sort().toString()}};const Le=Object.freeze({TIMER:"TIMER",SUMMARY:"SUMMARY",COUNTER:"COUNTER"});class Fe{constructor(e,t,r){d(this,"name",void 0),d(this,"tags",void 0),d(this,"values",void 0),this.name=e,this.tags=xe.from(t),this.type=r,this.values=[]}reset(){this.values=[]}}class Ue extends Fe{constructor(e){super(e,1{return h(e,2)[1]})}}function We(){return new je}class He{constructor(e){var t=1{const n=e.map(e=>{const t=e.cacheData;var r=null===t||void 0===t||null===(n=t.response)||void 0===n?void 0:n.signature,i=null===t||void 0===t?void 0:t.nb,n=null===t||void 0===t?void 0:t.getMaxAge();return this._createRequest(d,e,r,i,n,s,l)}),o=this._log,a=this._metrics,c=this;return new Promise((t,r)=>{const i=We();var e="".concat("https://id5-sync.com").concat("/gm/v3");o.info("Fetching ID5 ID from:",e,n),function(i,n,s,o,e){o=3{r.setRequestHeader(t,e)}),o.preflight&&r.setRequestHeader("X-Requested-With","XMLHttpRequest"),r.setRequestHeader("Content-Type",o.contentType||"text/plain"),"POST"===d&&s?r.send(s):r.send()}catch(e){a.error("ajax","xhr construction",e)}}(e,{success:function(e){o.info("Success at fetch call:",e),i.record(function(e,t){return Y(e,"success",1{var t=h(e,2),e=t[0],t=t[1];E(r[e])&&(l[t]=r[e])});e=r.abTesting;e&&!0===e.enabled&&(l.ab_testing={enabled:!0,control_group_pct:e.controlGroupPct});e=r.invalidSegmentsCount;return e&&0void 0!==e.find(e=>t.getId()===e)&&t.canDoCascade()).sort((e,t)=>{function r(e){var t;return(null===(e=e.getFetchIdData().refererInfo)||void 0===e||null===(t=e.stack)||void 0===t?void 0:t.length)||Number.MAX_SAFE_INTEGER}return r(e)-r(t)});if(0{const e=this._consentManager.localStorageGrant("fetch-before-request");if(d.info("Local storage grant",e),e.allowed){var r=this._store.hasConsentChanged(t);e.isDefinitivelyAllowed()&&this._store.storeConsent(t);var i=Te.checkIfAccessible(),n=this._store.getCachedSignature();const c=new Map;let a=o;const s=this._followers.map(e=>{var t=e.getId(),r=(this._followersRequests[t]||0)+1,i=this._properties.id,n=!0===this._refreshRequired[e.getId()];a=a||n;var s,o=e.getCacheId();return c.has(o)||(s=this._store.getCachedResponse(o))&&c.set(o,s),v(v({},e.getFetchIdData()),{},{integrationId:t,requestCount:r,refresh:n,role:i===e.getId()?"leader":e.type||"follower",cacheId:o,cacheData:c.get(o),sourceVersion:e.getSourceVersion(),source:e.getSource()})});r||a?(d.info("Decided to fetch a fresh ID5 ID",{consentHasChanged:r,shouldRefresh:a}),d.info("Fetching ID5 ID (forceFetch:".concat(o,")")),this._inProgressFetch=!0,this._firstFetchTriggered=!0,this._fetcher.fetchId(s,t,i,n).then(e=>{this._handleRefreshResult(s,c,t,e),this._handleFetchCompleted()}).catch(e=>{this._handleFailed(e),this._handleFetchCompleted()})):(d.info("Not decided to refresh ID5 ID",{consentHasChanged:r,shouldRefresh:a}),this._handleFetchCompleted())}else d.info("No legal basis to use ID5",t),this._store.clearAll(this._followers.map(e=>({cacheId:e.getCacheId()}))),this._handleCancel("No legal basis to use ID5")})}_waitForConsent(){const t=this._log,e=this._consentManager,r=this._metrics;t.info("Waiting for consent");const i=r.timer("fetch.consent.wait.time");return e.getConsentData().then(e=>(t.info("Consent received",e),i&&i.recordNow(),e))}start(){!0!==this._started&&(this._getId(!1),this._started=!0)}refreshUid(){var e=0e.getId()===t))&&this._provisionFromCache(r)),function(e,t,r){return e.counter("refresh.call.count",v({target:t},2e.getDeclaredConsentSource()).filter(e=>e!==le.none));var r=e.source||le.cmp,i=1===n.size&&n.has(le.partner);this._awaitedConsentFrom?this._awaitedConsentFrom===t?(this._consentManager.setConsentData(e),this._awaitedConsentFrom=void 0):this._handleIgnoredConsent(e,"awaited"):r!==le.partner||i?this._consentManager.setConsentData(e):this._handleIgnoredConsent(e,"partner")}}_handleIgnoredConsentUpdate(e){try{const i=this._consentManager._consentDataHolder.getValue();if(i){const n={},s=pe.createFrom(e);Object.values(de).forEach(e=>{var t,r;s.apiTypes.includes(e)&&i.apiTypes.includes(e)?(t=JSON.stringify(i.getApiTypeData(e)),r=JSON.stringify(s.getApiTypeData(e)),n[e]=t===r?"same":"different"):s.apiTypes.includes(e)?n[e]="added":i.apiTypes.includes(e)&&(n[e]="missed")}),function(e,t){return e.counter("leader.consent.change.count",1r[e]=!0),function(e,t){return e.counter("leader.consent.ignore.count",1e.getId()===t);var i=r.getCacheId();r.updateFetchIdData(e);e=r.getCacheId();e!==i&&(this._log.info("Follower",r.getId(),"cacheId changed from",i," to",e,"required refresh"),this._refreshRequired[r.getId()]=!0)}addFollower(t){const e=this._log;var r=void 0===this._followers.find(e=>e.getCacheId()===t.getCacheId());this._followers.push(t),e.debug("Added follower",t.getId(),"cacheId",t.getCacheId()),this._window!==t.getWindow()&&(i=t.getStorage(),e.debug("Adding follower's",t.getId(),"storage as replica"),this._leaderStorage.addReplica(i));var i=this._provisionFromCache(t);let n=new et;return!0===this._firstFetchTriggered&&(n.lateJoiner=!0,n.uniqueLateJoiner=r,i&&this._callRefresh({forceFetch:!0})),n}_provisionFromCache(e){var t=this._cachedIdProvider.provisionFromCache(e);return this._refreshRequired[e.getId()]=t.refreshRequired,t.provisioned&&this._store.incNb(t.cacheId),t.refreshRequired}getProperties(){return this._properties}_handleFetchCompleted(){this._inProgressFetch=void 0,this._queuedRefreshArgs&&(this._callRefresh(...this._queuedRefreshArgs),this._queuedRefreshArgs=void 0)}_handleFailed(e){this._log.error("Fetch id failed",e);var t,r=f(this._followers);try{for(r.s();!(t=r.n()).done;){const i=t.value;i.notifyFetchUidCanceled({reason:"error"})}}catch(e){r.e(e)}finally{r.f()}}}class it extends tt{constructor(e,t){super(),d(this,"_messenger",void 0),d(this,"_leaderInstanceProperties",void 0),this._messenger=e,this._leaderInstanceProperties=t}_sendToLeader(e,t){this._messenger.callProxyMethod(this._leaderInstanceProperties.id,ie.LEADER,e,t)}updateConsent(e,t){this._sendToLeader("updateConsent",[e,t])}refreshUid(e,t){this._sendToLeader("refreshUid",[e,t])}updateFetchIdData(e,t){this._sendToLeader("updateFetchIdData",[e,t])}getProperties(){return this._leaderInstanceProperties}}class nt extends tt{constructor(){super(...arguments),d(this,"_callsQueue",[]),d(this,"_assignedLeader",void 0)}updateConsent(e,t){this._callOrBuffer("updateConsent",[e,t])}updateFetchIdData(e,t){this._callOrBuffer("updateFetchIdData",[e,t])}refreshUid(e,t){this._callOrBuffer("refreshUid",[e,t])}addFollower(e){return this._callOrBuffer("addFollower",[e])}getProperties(){if(this._assignedLeader)return this._assignedLeader.getProperties()}assignLeader(e){this._assignedLeader=e;var t,r=f(this._callsQueue);try{for(r.s();!(t=r.n()).done;){var i=t.value;this._callAssignedLeader(i.name,i.args)}}catch(e){r.e(e)}finally{r.f()}this._callsQueue=[]}_callOrBuffer(e,t){if(this._assignedLeader)return this._callAssignedLeader(e,t);this._callsQueue.push({name:e,args:t})}_callAssignedLeader(e,t){return this._assignedLeader[e](...t)}}class st extends De{constructor(e,t){super(),d(this,"_messenger",void 0),d(this,"_destinationId",void 0),this._messanger=e,this._destinationId=t}getItem(){}removeItem(e){this._remoteCall("removeItem",[e])}setItem(e,t){this._remoteCall("setItem",[e,t])}_remoteCall(e,t){this._messanger.callProxyMethod(this._destinationId,ie.STORAGE,e,t)}}class ot extends Qe{constructor(e,t){var r=2{this._resolve=e})}set(e){this._hasValue?this._valuePromise=Promise.resolve(e):(this._hasValue=!0,this._resolve(e)),this._value=e}getValuePromise(){return this._valuePromise}hasValue(){return this._hasValue}getValue(){return this._value}}class ct extends class{getConsentData(){}localStorageGrant(){}setStoredPrivacy(){}}{constructor(e,t,r,i,n){super(),d(this,"_consentDataHolder",void 0),d(this,"storedPrivacyData",void 0),d(this,"localStorage",void 0),d(this,"_forceAllowLocalStorageGrant",void 0),this._log=i,this.localStorage=e,this.storageConfig=t,this._consentDataHolder=new at,this._forceAllowLocalStorageGrant=r,this._metrics=n}isForceAllowLocalStorageGrant(){return this._forceAllowLocalStorageGrant}resetConsentData(e){this._consentDataHolder.reset(),this.storedPrivacyData=void 0,this._forceAllowLocalStorageGrant=e}localStorageGrant(){var e=0v(v({},e),{},{response:t,responseTimestamp:r,consents:i}))}getStoredResponseV2(e){return this._getObject(this.storageConfig.ID5_V2.withNameSuffixed(e))}storeSignature(e){return this._updateObject(this.storageConfig.ID5_SIGNATURE,()=>({signature:e}))}getStoredSignature(){return this._getObject(this.storageConfig.ID5_SIGNATURE)}clearSignature(){return this._clearObject(this.storageConfig.ID5_SIGNATURE)}incNbV2(e){let r=1{var t=Math.max(0,b(null==e?void 0:e.nb)?Math.round(e.nb)+r:r);return v(v({},e),{},{nb:t})})}static storedDataMatchesCurrentData(e,t){return null==e||e===t}storedConsentDataMatchesConsentData(e){return dt.storedDataMatchesCurrentData(this.getHashedConsentData(),e.hashCode())}getExtensions(){return this._getObject(this.storageConfig.EXTENSIONS)}storeExtensions(e,t){return this._updateObject(t,()=>e)}clearExtensions(){return this.clear(this.storageConfig.EXTENSIONS)}}var lt=new WeakSet,ht=new WeakSet,ut=new WeakSet,gt=new WeakSet,pt=new WeakSet,vt=new WeakSet;class _t{constructor(e,t,r){vt.add(this),pt.add(this),gt.add(this),ut.add(this),ht.add(this),lt.add(this),d(this,"_metrics",void 0),d(this,"_log",void 0),d(this,"_store",void 0),this._metrics=e,this._log=t,this._store=r}static getChunkUrl(e,t){return"https://d".concat(e,".eu-").concat(t,"-id5-sync.com")}gather(r){var e=this._store.getCachedExtensions();if(void 0!==e)return Promise.resolve(e);let i=We(),n=o(this,gt,wt).call(this,r),s=o(this,ut,It).call(this);return o(this,lt,ft).call(this,"https://lb.eu-1-id5-sync.com/lb/v1","lb").then(e=>{var t=o(this,pt,St).call(this,e,o(this,vt,yt).call(this,r));return Promise.allSettled([Promise.resolve(e),o(this,ht,mt).call(this,t,_t.CHUNKS_CONFIGS.devChunks),o(this,ht,mt).call(this,t,_t.CHUNKS_CONFIGS.groupChunks),n,s])}).then(e=>{i.record(K(this._metrics,"all",!0));let t=_t.DEFAULT_RESPONSE;return e.forEach(e=>{e.value&&(t=v(v({},t),e.value))}),this._store.storeExtensions(t),t}).catch(e=>(i.record(K(this._metrics,"all",!1)),this._log.error("Got error ".concat(e," when gathering extensions data")),_t.DEFAULT_RESPONSE))}}function ft(t,r){var e=2{if(e.ok)return i.record(K(this._metrics,r,!0)),e.json();i.record(K(this._metrics,r,!1));e="The call to get extensions at ".concat(t," was not ok, status: ").concat(e.status,", statusText: ").concat(e.statusText);return this._log.warn(e),Promise.reject(new Error(e))}).catch(e=>(i.record(K(this._metrics,r,!1)),this._log.warn("Got error from ".concat(t," endpoint"),e),{}))}function mt(e,r){if(e){let t=We();return Promise.all(Array.from({length:r.length},(e,t)=>{t=_t.getChunkUrl(t,r.urlVersion);return fetch(t).then(e=>{if(e.ok)return e.text();throw new Error("The call to get ".concat(r.name," was not ok, status: ").concat(e.status,", statusText: ").concat(e.statusText))})})).then(e=>(t.record(K(this._metrics,r.name,!0)),{[r.name]:e,[r.name+"Version"]:"".concat(r.version)})).catch(e=>(t.record(K(this._metrics,r.name,!1)),this._log.warn("Got error when getting ".concat(r.name),e),{}))}return Promise.resolve({})}function It(){const e=new AbortController,t=setTimeout(()=>e.abort(),3e3);let r=o(this,lt,ft).call(this,"https://lbs.eu-1-id5-sync.com/lbs/v1","lbs",{signal:e.signal});return r.finally(()=>{clearTimeout(t)})}function wt(e){return e.some(e=>{return E(null===(e=e.cacheData)||void 0===e?void 0:e.signature)})||o(this,vt,yt).call(this,e)?Promise.resolve({}):o(this,lt,ft).call(this,"https://id5-sync.com/bounce","bounce",{credentials:"include"})}function St(e,t){e=null==e?void 0:e.chunks;return 0!==e&&!t&&e}function yt(e){return e.some(e=>!0===e.idLookupMode)}d(_t,"CHUNKS_CONFIGS",Object.freeze({devChunks:{name:"devChunks",urlVersion:3,length:8,version:4},groupChunks:{name:"groupChunks",urlVersion:4,length:8,version:4}})),d(_t,"DEFAULT_RESPONSE",{lbCDN:"%%LB_CDN%%"});const Ct={createExtensions:function(e,t,r){return new _t(e,t,r)}},bt=Object.freeze({UNKNOWN:"unknown",LEADER:"leader",FOLLOWER:"follower"}),Dt=Object.freeze({MULTIPLEXING:"multiplexing",SINGLETON:"singleton",MULTIPLEXING_PASSIVE:"multiplexing-passive"}),Et=Object.freeze({AWAITING_SCHEDULE:"awaiting_schedule",SKIPPED:"skipped",SCHEDULED:"scheduled",COMPLETED:"completed",CANCELED:"canceled"});class Tt{constructor(e,t,r){d(this,"properties",void 0),d(this,"knownState",void 0),d(this,"_joinTime",void 0),d(this,"_window",void 0),this.properties=e,this.knownState=t,this._window=r,this._joinTime=performance.now()}getId(){return this.properties.id}isMultiplexingPartyAllowed(){var e=null===(e=this.knownState)||void 0===e?void 0:e.operatingMode;return e===Dt.MULTIPLEXING||e===Dt.MULTIPLEXING_PASSIVE}isLeaderCapable(){var e;return(null===(e=this.knownState)||void 0===e?void 0:e.operatingMode)===Dt.MULTIPLEXING}isPassive(){var e;return(null===(e=this.knownState)||void 0===e?void 0:e.operatingMode)===Dt.MULTIPLEXING_PASSIVE}getInstanceMultiplexingLeader(){var e,t;if((null===(e=this.knownState)||void 0===e?void 0:e.operatingMode)===Dt.MULTIPLEXING)return null===(e=this.knownState)||void 0===e||null===(t=e.multiplexing)||void 0===t?void 0:t.leader}getWindow(){return this._window}}class Pt{constructor(e,t,r,i){d(this,"properties",void 0),d(this,"_messenger",void 0),d(this,"_knownInstances",new Map),d(this,"role",void 0),d(this,"_mode",void 0),d(this,"_metrics",void 0),d(this,"_logger",void 0),d(this,"_window",void 0);var n=E(globalThis)&&E(globalThis.crypto)&&S(globalThis.crypto.randomUUID)?globalThis.crypto.randomUUID():"".concat(1e6*Math.random()|0);this.properties=u({id:n,version:"1.0.44",href:null===(n=e.location)||void 0===n?void 0:n.href,domain:null===(n=e.location)||void 0===n?void 0:n.hostname},t),this.role=bt.UNKNOWN,this._metrics=r,this._loadTime=performance.now(),this._logger=new At(i,this),this._window=e,this._dispatcher=new Xe(this._logger),this._followerRole=new $e(this._window,this.properties,this._dispatcher,this._logger,this._metrics)}updateConfig(e){u(this.properties,e)}register(e){try{this.updateConfig(e),this.init(),this._messenger.broadcastMessage(this._createHelloMessage(!1),re.TYPE)}catch(e){this._logger.error("Failed to register integration instance",e)}return this}init(){let i=this,n=i._window;i._mode=Dt.MULTIPLEXING_PASSIVE,i._messenger=new oe(i.properties.id,n,i._logger,i._metrics),i._messenger.onAnyMessage((e,t)=>{var r=Date.now()-e.timestamp|0;!function(e,t){return e.timer("instance.message.delivery.time",1{let r=u(new re,e.payload);void 0===r.isResponse&&(r.isResponse=void 0!==e.dst),i._handleHelloMessage(r,e,t)})}_handleHelloMessage(e,t,r){var i=e.isResponse;const n=new Tt(e.instance,e.instanceState,r);this._knownInstances.get(n.getId())?this._logger.debug("Instance already known",n.getId()):(this._knownInstances.set(n.getId(),n),i||this._messenger.sendResponseMessage(t,this._createHelloMessage(!0),re.TYPE),this._logger.debug("Instance joined",n.getId()),this._doFireEvent(Je.ID5_INSTANCE_JOINED,n.properties),this._onInstanceDiscovered(e,n))}unregister(){this._logger.info("Unregistering"),this._messenger&&this._messenger.unregister()}on(e,t){return this._dispatcher.on(e,t),this}_onInstanceDiscovered(){}_createHelloMessage(){var e=0e.properties)};return new re(this.properties,e,t)}_doFireEvent(e){for(var t=arguments.length,r=new Array(1{t._timeoutId&&(t._timeoutId=void 0,t._instance._doElection(),t._closeWithState(Et.COMPLETED))},t._delayMs),t._state=Et.SCHEDULED,t._scheduleTime=performance.now()}skip(){this._closeWithState(Et.SKIPPED)}cancel(){this._timeoutId&&(clearTimeout(this._timeoutId),this._timeoutId=void 0),this._closeWithState(Et.CANCELED)}_closeWithState(e){this._state=e,this._closeTime=performance.now()}}class xt extends Pt{constructor(e,t,r,i,n,s,o){super(e,t,i,n),d(this,"_lastJoinedInstance",void 0),d(this,"_leader",void 0),d(this,"_remoteCallsToLeaderHandler",void 0),d(this,"_instanceCounters",void 0),d(this,"_election",void 0),d(this,"_storage",void 0),d(this,"_trueLinkAdapter",void 0),d(this,"_cachedIdProvider",void 0),this._leader=new nt,this._remoteCallsToLeaderHandler=new nt,this._instanceCounters=new Rt(i,this.properties),this._storage=r,this._trueLinkAdapter=s,this._cachedIdProvider=new Ze("self",new we(o,s),this._logger,this._metrics),this._election=new Nt(this)}init(){super.init();var e,t=this;t._mode=!0===t.properties.singletonMode?Dt.SINGLETON:Dt.MULTIPLEXING,t._instanceCounters.addInstance(t.properties),function(r){const i=r._metrics;[100,200,500,1e3,2e3,3e3,5e3].forEach(t=>{setTimeout(()=>{var e=((null===(e=r._knownInstances)||void 0===e?void 0:e.size)||0)+1;i.summary("instance.partySize",{after:t,electionState:r._election._state}).record(e)},t)})}(t),t._messenger.onProxyMethodCall(new se(t._logger).registerTarget(ie.LEADER,t._remoteCallsToLeaderHandler).registerTarget(ie.FOLLOWER,t._followerRole).registerTarget(ie.STORAGE,t._storage)),t._mode===Dt.SINGLETON?(t._election.skip(),t._onLeaderElected(t.properties)):t._mode===Dt.MULTIPLEXING&&(e=t.properties.electionDelayMSec||500,t._election.schedule(e))}_onInstanceDiscovered(e,t){e=e.isResponse;this._lastJoinedInstance=t,this._instanceCounters.addInstance(t.properties),function(e,t){return e.timer("instance.join.delay.time",1o.localStorageGrant("client-store"),n,s,t),this._trueLinkAdapter),s=new qe(r,t,Ct.createExtensions(r,t,n));const a=new rt(this._window,e,i,n,o,r,t,s);a.addFollower(this._followerRole),this._leader.assignLeader(a),this._remoteCallsToLeaderHandler.assignLeader(a),this._mode===Dt.MULTIPLEXING&&Array.from(this._knownInstances.values()).filter(e=>e.isMultiplexingPartyAllowed()).map(e=>a.addFollower(new ot(e,this._messenger,t,e.isPassive()?Ke.PASSIVE:Ke.STANDARD))),a.start()}_followRemoteLeader(e){this._leader.assignLeader(new it(this._messenger,e)),this._remoteCallsToLeaderHandler.assignLeader(new Lt(e.id,this._logger,this._metrics)),this._logger.info("Following remote leader ",e)}updateConsent(e){this._leader.updateConsent(e,this.properties.id)}updateFetchIdData(e){this._leader.updateFetchIdData(this.properties.id,e),u(this.properties.fetchIdData,e)}refreshUid(e){this._leader.refreshUid(e,this.properties.id)}_doElection(){var e=this._election;const t=this._knownInstances;let r=Array.from(t.values()).filter(e=>e.isMultiplexingPartyAllowed()&&e.isLeaderCapable()).map(e=>e.properties);r.push(this.properties),this._onLeaderElected(function(e){if(!e||0===e.length)return;e=e.sort((e,t)=>{let r=-(0|l(e.version,t.version));var i,n,s;return 0===r&&(r=e.source.localeCompare(t.source),0===r&&(r=-(0|l(e.sourceVersion,t.sourceVersion))),0===r&&(n=(null===(n=e.fetchIdData)||void 0===n||null===(i=n.refererInfo)||void 0===i?void 0:i.numIframes)||Number.MAX_SAFE_INTEGER,s=(null===(i=t.fetchIdData)||void 0===i||null===(s=i.refererInfo)||void 0===s?void 0:s.numIframes)||Number.MAX_SAFE_INTEGER,r=n-s),0===r&&(r=e.id.localeCompare(t.id))),r});return e[0]}(r));var i=this._lastJoinedInstance;i&&!function(e,t){return e.timer("instance.lastJoin.delay",v({},1{!function(t,r){try{const i=t._window;let e=Ut(i);e=e||(i.pbjs=i.pbjs||{});const n=e.que=e.que||[];n.push(()=>{t._pbjs=Ut(i),r(t._pbjs)})}catch(e){t._logger.error("PbjsDetector: Failed to setup detection:",e),r(null)}}(t,e)}),t._pbjsPromise)})()}}const kt="1.0.97",Vt=Object.freeze({NEVER:"never",AFTER_UID_SET:"after-uid-set",ASAP:"asap"}),Mt=Object.freeze({allowGCReclaim:Object.values(Vt)});class Gt{constructor(e){var t=1{this.options[e]=t,this.providedOptions[e]=t};var e;void 0!==a.partnerData&&(e=a.partnerData,E(a.pd)&&d.info("Both pd and partnerData provided. Using partnerData and ignoring pd."),this.options.partnerData=e,this.providedOptions.partnerData=e),Object.keys(a).forEach(e=>{if("segments"===e){const i=a[e],n=[];E(i)&&(W(i)?(i.forEach((e,t)=>{t="segments[".concat(t,"]");return W(e.ids)&&function(e,t){let r=!0;return T(e,e=>r=r&&t(e)),r}(e.ids,G)?e.ids.length<1?(d.error("Config option ".concat(t,".ids should contain at least one segment ID")),void(c.invalidSegments+=1)):G(e.destination)?void n.push(e):(Wt(d,"".concat(t,".destination"),"String",e.destination),void(c.invalidSegments+=1)):(Wt(d,"".concat(t,".ids"),"Array of String",e.ids),void(c.invalidSegments+=1))}),l(e,n)):Wt(d,e,"Array",i))}else if("diagnostics"===e){const s=this.options.diagnostics,o=a.diagnostics;if(V(o,Gt.configTypes.diagnostics)){let t=v({},s);Object.keys(o).forEach(e=>{void 0!==s[e]&&typeof s[e]==typeof o[e]&&(t[e]=o[e])}),this.options[e]=t}this.providedOptions[e]=a[e]}else{var t,r;void 0!==Mt[e]?(r=a[e])&&Mt[e].includes(r)&&l(e,r):"partnerId"!==e&&"partnerData"!==e&&(t=Gt.configTypes[e],E(r=a[e])&&(V(r,t)?l(e,r):Wt(d,e,t,r)))}})}else d.error("Config options must be an object")}setPartnerId(e){let t;if(G(e)){if(t=parseInt(e),isNaN(t)||t<0)throw new Error("partnerId is required and must parse to a positive integer")}else H(e)&&(t=e);if(H(t)){if(H(this.options.partnerId)&&t!==this.options.partnerId)throw new Error("Cannot update config with a different partnerId");this.options.partnerId=t,this.providedOptions.partnerId=e}}}function Wt(e,t,r,i){e.error("Config option ".concat(t," must be of type ").concat(r," but was ").concat(toString.call(i),". Ignoring..."))}function Ht(e){return{partner:e}}d(Gt,"configTypes",{debugBypassConsent:"Boolean",allowLocalStorageWithoutConsentApi:"Boolean",cmpApi:"String",consentData:"Object",refreshInSeconds:"Number",partnerUserId:"String",callbackOnAvailable:"Function",callbackOnUpdates:"Function",callbackTimeoutInMs:"Number",pd:"String",partnerData:"Object",abTesting:"Object",provider:"String",maxCascades:"Number",applyCreativeRestrictions:"Boolean",acr:"Boolean",disableUaHints:"Boolean",storageExpirationDays:"Number",att:"Number",diagnostics:"Object",multiplexing:"Object",dynamicConfig:"Object",allowGCReclaim:"String",gssProvider:"Object",gamTargetingPrefix:"String",exposeTargeting:"Boolean",idLookupMode:"Boolean"});class qt extends class{constructor(){var e=0({name:e.name,type:e.type,tags:e.tags,values:e.values})).filter(function(e){return e.values&&0e.reset())}addCommonTags(e){this.commonTags=v(v({},this.commonTags),xe.from(e))}timer(e){return this.getOrCreate(e,1new Ue(e,t))}counter(e){return this.getOrCreate(e,1new ke(e,t))}summary(e){return this.getOrCreate(e,1new Ve(e,t))}unregister(){void 0!==this._onUnregisterCallback&&this._onUnregisterCallback(this)}onUnregister(e){this._onUnregisterCallback=e}}{constructor(e,t){var r=2y(e.brand)&&e.brand.search(t)<0)),C(e.fullVersionList)&&(e.fullVersionList=e.fullVersionList.filter(e=>y(e.brand)&&e.brand.search(t)<0)),e}}}const zt={A:0,B:1,C:2,D:3,E:4,F:5,G:6,H:7,I:8,J:9,K:10,L:11,M:12,N:13,O:14,P:15,Q:16,R:17,S:18,T:19,U:20,V:21,W:22,X:23,Y:24,Z:25,a:26,b:27,c:28,d:29,e:30,f:31,g:32,h:33,i:34,j:35,k:36,l:37,m:38,n:39,o:40,p:41,q:42,r:43,s:44,t:45,u:46,v:47,w:48,x:49,y:50,z:51,0:52,1:53,2:54,3:55,4:56,5:57,6:58,7:59,8:60,9:61,"-":62,_:63,"+":62,"/":63};const Xt=Object.freeze({tcfv2:{objName:"__tcfapiCall",objKeys:["command","version"],returnObjName:"__tcfapiReturn"},uspv1:{objName:"__uspapiCall",objKeys:["command","version"],returnObjName:"__uspapiReturn"},gppv1:{objName:"__gppCall",objKeys:["command","parameter"],returnObjName:"__gppReturn"}}),Yt=Object.freeze({TCF:0,USP:1,GPP:2});class Kt{constructor(e,t){d(this,"direct",void 0),d(this,"version",void 0),this.direct=e,this.version=t}getConsentData(){var e=this;return _(function*(){return e.getClientConsentData()})()}static create(a,c){return _(function*(){var e=tr._findCmpApi("__gpp"),t=e.cmpApiFrame,e=e.cmpApiFunction;let r,i=!1;if(!t)return a.warn("cmpApi: GPP not found! Using defaults."),Promise.resolve();if(M(e))i=!0,a.info("cmpApi: Detected GPP is directly accessible, calling it now."),r=e;else{a.info("cmpApi: Detected GPP is outside the current iframe. Using message passing.");const o=tr._buildCmpSurrogate(Xt.gppv1,t);r=function(e,t,r){o(e,r,t)}}var n=yield new Promise(t=>{var e=r("ping",function(e){t(e)});q(e)&&t(e)});switch(n.gppVersion){case $t.version:return new $t(n,r,i);case er.version:return new er(n,r,i,c);default:var s="Unsupported version of gpp: ".concat(n.gppVersion);return a.warn(s),Promise.reject(s)}})()}static caTcfDataHasExpressConsent(e){e=e.PurposesExpressConsent;if(W(e)&&0e==ce)}static tcfDataHasLocalStorageGrant(e){e=r(Kt,Kt,Qt).call(Kt,e,"PurposeConsent","PurposeConsents");if(W(e)&&0e==ce))}static getTcfData(e){let t=void 0;return W(e)&&q(e[0])?t=e[0]:q(e)&&(t=e),t}}function Qt(e,t,r){return t in e?e[t]:e[r]}class $t extends Kt{constructor(e,t,r){super(r,$t.version),d(this,"gppFn",void 0),d(this,"ready",void 0),this.gppFn=t,this.ready=this.isReady(e)}isReady(e){return"loaded"===e.cmpStatus&&"visible"!==e.cmpDisplayStatus}getClientConsentData(){var i=this;return _(function*(){i.ready||(i.ready=yield new Promise(t=>{i.gppFn("addEventListener",e=>!!i.isReady(e.pingData)&&void t(!0))}));var e=new Promise(t=>{i.gppFn("getGPPData",e=>{t(e)})}),t=new Promise(t=>{i.gppFn("getSection",e=>{t(e)},"tcfeuv2")}),e=h(yield Promise.all([e,t]),2),t=e[0],e=e[1];const r=new ge(de.GPP_V1_0,t.applicableSections,t.gppString);return e&&(r.euTcfSection=new ue(Kt.tcfDataHasLocalStorageGrant(e),Kt.tcfDataHasID5VendorConsented(e))),r})()}}function Zt(e,t,r){r&&(e.apiTypes.push(t),u(e,r))}d($t,"version","1.0");class er extends Kt{constructor(e,t,r,i){super(r,er.version),d(this,"gppFn",void 0),d(this,"readyPingData",void 0),d(this,"metrics",void 0),this.gppFn=t,"ready"===e.signalStatus&&(this.readyPingData=e),this.metrics=i}getClientConsentData(){var o=this;return _(function*(){const s=o.metrics;return new Promise(r=>{let i=!1;if(o.readyPingData)r(o.parsePingData(o.readyPingData));else{const n=Date.now();let t=setTimeout(()=>{t=void 0,o.gppFn("ping",e=>{"stub"===e.cmpStatus&&(s.counter("gpp.stubUsed",{cmpId:e.cmpId}).inc(),r(o.parsePingData(e)))})},1e3);o.gppFn("addEventListener",e=>"ready"===e.pingData.signalStatus&&void(i?er.measureAdditionalEvent(e,s,n):(t?(clearTimeout(t),t=void 0):i||s.timer("gpp.lateCmp",{cmpId:e.pingData.cmpId}).record(Date.now()-n),r(o.parsePingData(e.pingData)),i=!0)))}})})()}static measureAdditionalEvent(e,t,r){["cmpStatus","cmpDisplayStatus","signalStatus","sectionChange"].includes(e.eventName)&&t.timer("gpp.additionalEvents",{cmpId:e.pingData.cmpId,name:e.eventName}).record(Date.now()-r)}parsePingData(e){const t=new ge(de.GPP_V1_1,e.applicableSections,e.gppString);var r;return!t.applicableSections.includes(he.TCFEUV2)||(r=Kt.getTcfData(null===(r=e.parsedSections)||void 0===r?void 0:r.tcfeuv2))&&(t.euTcfSection=new ue(Kt.tcfDataHasLocalStorageGrant(r),Kt.tcfDataHasID5VendorConsented(r))),!t.applicableSections.includes(he.TCFCAV1)||(e=Kt.getTcfData(null===(e=e.parsedSections)||void 0===e?void 0:e.tcfcav1))&&(t.canadaTcfSection=new ue(Kt.caTcfDataHasExpressConsent(e),Kt.caTcfDataHasVendorExpressConsent(e))),t}}d(er,"version","1.1");class tr{constructor(e){var t=1{i._lookupInProgress=!1})),this._consentDataPromise}_lookupConsentData(e,t,r){if(e){this._log.warn("cmpApi: ID5 is operating in forced consent mode and will not retrieve any consent signals from the CMP");let e=new pe;return e.forcedGrantByConfig=!0,e.source=le.partner,Promise.resolve(e)}switch(t){case"static":return new Promise(e=>{this._parseStaticConsentData(r,e)});case"iab":return new Promise(e=>{this._lookupIabConsent(e)});default:return this._log.error("cmpApi: Unknown consent API: ".concat(t)),Promise.reject(new Error("Unknown consent API: ".concat(t)))}}_parseStaticConsentData(e,t){e=e||{};let r=new pe;if(r.source=le.partner,q(e.getTCData)){const i=this._parseTcfData(e.getTCData);Zt(r,de.TCF_V2,i);try{const n=this._metrics;this._lookupTcf(e=>{Bt(n,{apiType:de.TCF_V2,sameString:(null==e?void 0:e.consentString)===(null===i||void 0===i?void 0:i.consentString),sameLSPC:(null==e?void 0:e.localStoragePurposeConsent)===(null===i||void 0===i?void 0:i.localStoragePurposeConsent),sameVendorsConsentForId5Granted:(null==e?void 0:e.vendorsConsentForId5Granted)===(null===i||void 0===i?void 0:i.vendorsConsentForId5Granted),sameGdpr:(null==e?void 0:e.gdprApplies)===(null===i||void 0===i?void 0:i.gdprApplies)}).inc()})}catch(e){}}if(W(e.allowedVendors)&&Zt(r,de.ID5_ALLOWED_VENDORS,{allowedVendors:e.allowedVendors.map(e=>e.toString()),gdprApplies:!0}),q(e.getUSPData)){const s=this._parseUspData(e.getUSPData);Zt(r,de.USP_V1,s);try{const o=this._metrics;this._lookupUsp(e=>{Bt(o,{apiType:de.USP_V1,sameString:(null==e?void 0:e.ccpaString)===(null===s||void 0===s?void 0:s.ccpaString)}).inc()})}catch(e){}}0===r.apiTypes.length&&this._log.warn("cmpApi: No static consent data detected! Using defaults."),this._log.info("cmpApi: Detected APIs '".concat(r.apiTypes,"' from static consent data"),e),t(r)}_lookupIabConsent(i){const n=[];let s=new pe;s.source=le.cmp;var e=r=>(n[r]=0,(e,t)=>{n[r]||(n[r]=Date.now(),e&&Zt(s,t,e),n.every(e=>0{t?r(this._parseUspData(e),de.USP_V1):(this._log.error("cmpApi: USP callback not successful. Using defaults for CCPA."),r())})}_lookupGpp(s){var o=this;return _(function*(){var t=Date.now();try{let e=yield Kt.create(o._log,o._metrics);if(e){var r={gppVersion:e.version,directCmp:e.direct};try{var i=yield e.getConsentData();s({gppData:i},i.version);var n=Date.now();o._metrics.timer("gpp.delay",r).record(n-t)}catch(e){o._metrics.counter("gpp.failure",u({type:"CONSENT"},r)).inc(),o._log.error("cmpApi: getting GPP consent not successful. Using defaults for Gpp."),s()}}else s()}catch(e){o._metrics.counter("gpp.failure",{type:"CLIENT"}).inc(),o._log.error("cmpApi: creating GPP client not successful. Using defaults for Gpp."),s()}})()}static _buildCmpSurrogate(a,c){return(e,t,r)=>{const i=Math.random()+"",n={},s={};s[a.objKeys[0]]=e,s[a.objKeys[1]]=t,s.callId=i,n[a.objName]=s;const o=e=>{e=J(e,"data.".concat(a.returnObjName));e&&e.callId===i&&(void 0!==(e=r(e.returnValue,e.success))&&!0!==e||window.removeEventListener("message",o))};window.addEventListener("message",o,!1),c.postMessage(n,"*")}}_lookupTcf(e){var t=tr._findTCF(),r=t.cmpFrame,t=t.cmpFunction;if(!r)return this._log.warn("cmpApi: TCF not found! Using defaults for GDPR."),void e();M(t)?this._lookupDirectTcf(t,e):(this._log.info("cmpApi: Detected TCF is outside the current iframe. Using message passing."),this._lookupMessageTcf(r,e))}_lookupMessageTcf(e,t){e=tr._buildCmpSurrogate(Xt.tcfv2,e);this._lookupDirectTcf(e,t)}_lookupDirectTcf(e,n){const s=this._log;e("addEventListener",2,(e,t)=>{var r,i;return r="event",i=e,s.info("cmpApi: TCFv2 - Received a call back: ".concat(r),i),t?!(!e||!1!==e.gdprApplies&&"tcloaded"!==e.eventStatus&&"useractioncomplete"!==e.eventStatus)&&void n(this._parseTcfData(e),de.TCF_V2):(s.error("cmpApi: TCFv2 - Received insuccess: ".concat("addEventListener",". Please check your CMP setup. Using defaults for GDPR.")),void n())})}_parseUspData(e){if(q(e)&&G(e.uspString))return{ccpaString:e.uspString};this._log.error("cmpApi: No or malformed USP data. Using defaults for CCPA.")}_parseTcfData(e){let t=this._log,r,i;if(r=tr._isValidV2ConsentObject,i=tr._normalizeV2Data,r(e))return i(e);t.error("cmpApi: Invalid CMP data. Using defaults for GDPR.",e)}static _isValidV2ConsentObject(e){var t=e&&e.gdprApplies,e=e&&e.tcString;return!1===t||G(e)}static _tcfDataHasID5VendorConsented(e){var t,r;return!0===(null==e||null===(t=e.vendor)||void 0===t||null===(r=t.consents)||void 0===r?void 0:r[ce])}static _normalizeV2Data(e){let t=J(e,"purpose.consents.1");B(t)||(t=function(e,t){var r=152+t-1,t=~~(r/6);if(e&&"C"===e.charAt(0)&&!(e.length<=t)){t=e.charAt(t),t=zt[t];if(void 0!==t)return 0!=(t&1<<6-r%6-1)}}(e.tcString,1));var r=tr._tcfDataHasID5VendorConsented(e);return{consentString:e.tcString,localStoragePurposeConsent:t,gdprApplies:e.gdprApplies,vendorsConsentForId5Granted:r}}static _findTCF(){let e=window,t,r;for(;!t;){try{if("function"==typeof e.__tcfapi){r=e.__tcfapi,t=e;break}}catch(e){}try{if(e.frames.__tcfapiLocator){t=e;break}}catch(e){}if(e===window.top)break;e=e.parent}return{cmpFrame:t,cmpFunction:r}}static _findCmpApi(e){let t=window,r,i;for(;!r;){try{if("function"==typeof t[e]){i=t[e],r=t;break}}catch(e){}try{if(t.frames["".concat(e,"Locator")]){r=t;break}}catch(e){}if(t===window.top)break;t=t.parent}return{cmpApiFrame:r,cmpApiFunction:i}}}class rr{isBooted(){return D(window.id5Bootstrap)}getTrueLink(){return this.isBooted()?window.id5Bootstrap.getTrueLinkInfo():{booted:!1}}setPrivacy(e){this.isBooted()&&window.id5Bootstrap.setPrivacy&&window.id5Bootstrap.setPrivacy(e)}clearPrivacy(){this.setPrivacy(void 0)}}var ir=Object.freeze({AUCTION_END:"auctionEnd",BID_WON:"bidWon",TCF2_ENFORCEMENT:"tcf2Enforcement",AD_RENDER_FAILED:"adRenderFailed",AD_RENDER_SUCCEEDED:"adRenderSucceeded"});const nr=[ir.AUCTION_END,ir.BID_WON,ir.AD_RENDER_FAILED,ir.AD_RENDER_SUCCEEDED],sr=(new Date).getTimezoneOffset(),or=Array.isArray,ar="id5-api-js",cr={};cr[ir.AUCTION_END]=function(e){const t={auctionId:e.auctionId,timestamp:e.timestamp,auctionEnd:e.auctionEnd};or(e.bidsReceived)&&(t.bidsReceived=e.bidsReceived.map(pr));or(e.noBids)&&(t.noBids=e.noBids.map(ur));or(e.bidderRequests)&&(t.bidderRequests=e.bidderRequests.map(lr));return t},cr[ir.BID_WON]=vr,cr[ir.AD_RENDER_FAILED]=function(e){return{adId:e.adId,reason:e.reason}},cr[ir.AD_RENDER_SUCCEEDED]=function(e){return{adId:e.adId,bid:vr(e.bid)}},cr.analyticsError=e=>e;class dr{constructor(e,t,r,i){var n=4{n._logger.error("pbjsEventsTracker: sendEvent failed",e)})}catch(e){n._logger.error("pbjsEventsTracker: sendEvent failed (sync)",e)}return Promise.resolve()})()}makeEvent(e,t){t=cr[e]?cr[e](t):{};return{source:ar,event:e,payload:t,partnerId:this._partnerId,meta:{sampling:this._sampling,pbjs:this._pbjsVersion,version:kt,tz:sr}}}sendErrorEvent(e){return this.sendEvent(this.makeEvent("analyticsError",{message:e.message,stack:e.stack}))}}function lr(e){if(e){const t={};return e.bidderCode&&(t.bidderCode=e.bidderCode),or(e.bids)&&(t.bids=e.bids.map(gr)),e.ortb2&&(t.ortb2=_r(e.ortb2)),t}}function hr(e){if(e){const t={};return e.ext&&(t.ext=function(e){if(e)return{linkType:e.linkType,pba:e.pba,abTestingControlGroup:e.abTestingControlGroup}}(e.ext)),t}}function ur(e){if(e){const t={};return t.bidId=e.bidId,t}}function gr(e){if(e){const t={};return e.adUnitCode&&(t.adUnitCode=e.adUnitCode),e.bidId&&(t.bidId=e.bidId),e.userId&&(t.userId=function(t){if(t){const r={};return Object.keys(t).forEach(e=>{"id5id"===e?r.id5id=hr(t[e]):r[e]=1}),r}}(e.userId)),e.ortb2&&(t.ortb2=_r(e.ortb2)),or(e.userIdAsEids)&&(t.userIdAsEids=e.userIdAsEids.map(fr)),t}}function pr(r){if(r){const i={};return["adUnitCode","bidderCode","requestId","creativeId","dealId","responseTimestamp","requestTimestamp","width","height","netRevenue","mediaType","originalCpm","originalCurrency","cpm","currency"].forEach(e=>{var t=r[e];t&&(i[e]=t)}),i}}function vr(r){if(r){const i={};return["auctionId","adUnitCode","bidderCode","requestId","creativeId","dealId","responseTimestamp","requestTimestamp","width","height","netRevenue","mediaType","originalCpm","originalCurrency","cpm","currency"].forEach(e=>{var t=r[e];t&&(i[e]=t)}),i}}function _r(e){if(e){const t={};return e.user&&(t.user=function(e){if(e){const t={};return e.ext&&(t.ext=function(e){if(e){const t={};return or(e.eids)&&(t.eids=e.eids.map(fr)),t}return}(e.ext)),t}return}(e.user)),t}}function fr(e){if(e){const t={};return e.source&&(t.source=e.source),or(e.uids)&&"id5-sync.com"===e.source&&(t.uids=e.uids.map(hr)),t}}function mr(t,e){let r=1{!function(o,a){let c=2e.json()).then(e=>{c.info("pbjsEventsTracker: Received from configuration endpoint",e);var t="number"==typeof e.sampling?e.sampling:0;if("string"!=typeof e.ingestUrl)return c.error("pbjsEventsTracker: cannot find ingestUrl in config endpoint response; no analytics will be available"),!1;var r=e.ingestUrl;const i=or(e.eventsToTrack)?e.eventsToTrack:nr;if(0{c.debug("pbjsEventsTracker: Past event found",e),e&&0<=i.indexOf(e.eventType)?s.push(n.track(e.eventType,e.args)):c.debug("pbjsEventsTracker: Past event ignored",e)}),c.info("pbjsEventsTracker: Register event handlers for",i),i.forEach(t=>{o.onEvent(t,e=>n.track(t,e))}),Promise.all(s).then(()=>!0)}return!1}).catch(e=>(c.error("pbjsEventsTracker: Failed to fetch configuration",e),!1)):(c.error("pbjsEventsTracker: prebidGlobal is not defined"),Promise.resolve(!1))}(e,t,r)}))}catch(e){r.error("pbjsEventsTracker: Failed to register",e)}}const Ir="id5-prebid-ext-module";class wr{set debug(e){e=e,L=!!e}get debug(){return U()}constructor(){d(this,"invocationId",0),d(this,"_version",kt),d(this,"userIdReady",!1),this._isUsingCdn=!!(document&&document.currentScript&&document.currentScript.src&&0===document.currentScript.src.indexOf("https://cdn.id5-sync.com"))}fetchId5Id(i,d,l,h,u,g){var p=this;return _(function*(){p.invocationId+=1;var e=p.getPrebidVersion();const n=new j(Ir,p.invocationId);n.info("ID5 API Prebid external module version ".concat(p._version,". Invoking fetchId5Id()"),i,d);const t=new Gt({partnerId:d.partner,pd:d.pd,abTesting:d.abTesting,multiplexing:d.multiplexing,diagnostics:d.diagnostics,segments:d.segments,disableUaHints:d.disableUaHints,gamTargetingPrefix:d.gamTargetingPrefix,exposeTargeting:!0===d.exposeTargeting,idLookupMode:d.idLookupMode,dynamicConfig:i},n),s=t.getOptions(),o=p._configureDiagnostics(s.partnerId,s.diagnostics,l,n,e,s.idLookupMode);o&&(!function(e,t){return e.timer("instance.load.delay",1{a.on(Be.USER_ID_READY,(e,t)=>{try{var r=null!=t&&t.tags?v({},t.tags):{};null!=t&&t.timestamp&&o.timer("userid.provisioning.delivery.delay",r).record(Date.now()-t.timestamp),c.record(function(e,t,r){return e.timer("userid.provisioning.delay",v({cachedResponseUsed:t},2{for(const e in n)window.googletag.setConfig({targeting:{[t+"_"+e]:n[e]}})})),n&&r&&!X(null===(r=window)||void 0===r||null===(i=r.id5tags)||void 0===i?void 0:i.tags,n)&&(window.id5tags=window.id5tags||{cmd:[]},window.id5tags.cmd=window.id5tags.cmd||[],window.id5tags.cmd.forEach(e=>{setTimeout(()=>e(n),0)}),window.id5tags.cmd.push=function(e){e(n),Array.prototype.push.call(window.id5tags.cmd,e)},window.id5tags.tags=n)}}.updateTargeting(e,s.gamTargetingPrefix,s.exposeTargeting),i(e.responseObj)}).on(Be.USER_ID_FETCH_CANCELED,e=>{n.info("ID5 User ID fetch canceled:",e.reason),t(e.reason)})}),e=yield p._gatherFetchIdData(t,l,n,e);return a.register({source:Ir,sourceVersion:kt,sourceConfiguration:{options:t.getOptions()},fetchIdData:e,singletonMode:!0===(null===(e=s.multiplexing)||void 0===e?void 0:e._disabled)||!0===s.idLookupMode,canDoCascade:null!==(e=d.canCookieSync)&&void 0!==e&&e&&!0!==s.idLookupMode,forceAllowLocalStorageGrant:!1,storageExpirationDays:s.storageExpirationDays}),setTimeout(()=>mr(d.partner,n),0),r})()}getPrebidVersion(){var e;return null!==(e=null===(e=Ut(window))||void 0===e?void 0:e.version)&&void 0!==e?e:"unknown"}_buildConsentData(e,t,r){const i=new pe;var n;return i.source=le.prebid,e&&(i.apiTypes.push(de.TCF_V2),i.gdprApplies=e.gdprApplies,i.consentString=e.consentString,i.localStoragePurposeConsent=J(e.vendorData,"purpose.consents.1")),t&&(i.apiTypes.push(de.USP_V1),i.ccpaString=t,i.localStoragePurposeConsent=!0),null!=r&&r.gppString&&(t=(e=Kt.getTcfData(null===(n=r.parsedSections)||void 0===n?void 0:n.tcfeuv2))?Kt.tcfDataHasLocalStorageGrant(e):void 0,n=e?Kt.tcfDataHasID5VendorConsented(e):void 0,(e=this._translateGppVersion(r.gppVersion))&&(i.apiTypes.push(e),i.gppData=new ge(e,r.applicableSections,r.gppString),void 0===t&&void 0===n||(i.gppData.euTcfSection=new ue(t,n)))),i}_translateGppVersion(e){switch(e){case"1.0":return de.GPP_V1_0;case"1.1":return de.GPP_V1_1;default:return}}_configureDiagnostics(t,r,i,n,s,o){try{let e=new qt(Ir,this._version);if(e.addCommonTags(v(v({},Ht(t)),{},{tml:null==i?void 0:i.topmostLocation,prebidVersion:s,idLookupMode:o?"true":"false"})),null==r||!r.publishingDisabled){const d=new Re(e,(a=r.publishingSampleRatio,Math.random()new Oe(c,{sampling:a}).publish(e,t):e=>e));null!=r&&r.publishAfterLoadInMsec&&0