/** * @id5io/id5-api.js * @version v1.0.88 * @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 _(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 s,n=!0,o=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return n=e.done,e},e:function(e){o=!0,s=e},f:function(){try{n||null==r.return||r.return()}finally{if(o)throw s}}}}function r(e,t,r){return function(e,t){if(e!==t)throw new TypeError("Private static access of wrong provenance")}(e,t),r}class e{debug(){}info(){}warn(){}error(){}}const g=new e;function o(e,t){var r="^\\d+(\\.\\d+(\\.\\d+){0,1}){0,1}$";if(e.match(r)&&t.match(r)){var i=e.split("."),s=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(s[0]));if(0!==t)return t;t=e(r(i[1]),r(s[1]));return 0===t?e(r(i[2]),r(s[2])):t}}const n="Array",l="String",p="Function",v=Object.prototype.toString;function I(e,t){return v.call(e)==="[object "+t+"]"}function S(e){return I(e,p)}function w(e){return I(e,l)}function C(e){return I(e,n)}function y(e){return I(e,"Number")}function D(e){return I(e,"Object")}function b(e){return void 0!==e}function E(t,r){if(!function(e){if(!e)return 1;if(C(e)||w(e))return!(0{let r=t.split("="),i=h(r,2),s=i[0],n=i[1];return/\[\]$/.test(s)?(s=s.replace("[]",""),e[s]=e[s]||[],e[s].push(n)):e[s]=n||"",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 T(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(n^n>>>13,3266489909),n=i(n^n>>>16,2246822507)^i(s^s>>>13,3266489909),(4294967296*(2097151&n)+(s>>>0)).toString()}const O="TRUE"===V("id5_debug").toUpperCase(),R="TRACE"===V("id5_debug").toUpperCase(),N=Boolean(window.console);let x=!1;function L(e,t,r,i,s){F()&&N&&e&&e.apply(console,["%cID5 - ".concat(t,"#").concat(r),"color: #fff; background: #1c307e; padding: 1px 4px; border-radius: 3px;",i].concat(s))}function F(){return O||R||x}class U 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;r{this.options[e]=t,this.providedOptions[e]=t};Object.keys(a).forEach(e=>{if("segments"===e){const i=a[e],s=[];b(i)&&(k(i)?(i.forEach((e,t)=>{t="segments[".concat(t,"]");return k(e.ids)&&function(e,t){let r=!0;return E(e,e=>r=r&&t(e)),r}(e.ids,j)?e.ids.length<1?(d.error("Config option ".concat(t,".ids should contain at least one segment ID")),void(c.invalidSegments+=1)):j(e.destination)?void s.push(e):(Q(d,"".concat(t,".destination"),"String",e.destination),void(c.invalidSegments+=1)):(Q(d,"".concat(t,".ids"),"Array of String",e.ids),void(c.invalidSegments+=1))}),l(e,s)):Q(d,e,"Array",i))}else if("diagnostics"===e){const n=this.options.diagnostics,o=a.diagnostics;if(G(o,K.configTypes.diagnostics)){let t=_({},n);Object.keys(o).forEach(e=>{void 0!==n[e]&&typeof n[e]==typeof o[e]&&(t[e]=o[e])}),this.options[e]=t}this.providedOptions[e]=a[e]}else{var t,r;void 0!==Y[e]?(r=a[e])&&Y[e].includes(r)&&l(e,r):"partnerId"!==e&&(t=K.configTypes[e],b(r=a[e])&&(G(r,t)?l(e,r):Q(d,e,t,r)))}})}else d.error("Config options must be an object")}setPartnerId(e){let t;if(j(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 Q(e,t,r,i){e.error("Config option ".concat(t," must be of type ").concat(r," but was ").concat(toString.call(i),". Ignoring..."))}d(K,"configTypes",{debugBypassConsent:"Boolean",allowLocalStorageWithoutConsentApi:"Boolean",cmpApi:"String",consentData:"Object",refreshInSeconds:"Number",partnerUserId:"String",callbackOnAvailable:"Function",callbackOnUpdates:"Function",callbackTimeoutInMs:"Number",pd:"String",abTesting:"Object",provider:"String",maxCascades:"Number",applyCreativeRestrictions:"Boolean",acr:"Boolean",disableUaHints:"Boolean",storageExpirationDays:"Number",att:"Number",diagnostics:"Object",multiplexing:"Object",dynamicConfig:"Object",allowGCReclaim:"String"});const $="undefined"!=typeof Promise&&"undefined"!=typeof fetch;class Z{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:_(_({},this._metadata),t),measurements:e})})):Promise.resolve()}}class ee{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 te=Object.freeze({});var re={EMPTY:te,from:function(e){return e?e instanceof Map?Object.fromEntries(e):e:te},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 ie=Object.freeze({TIMER:"TIMER",SUMMARY:"SUMMARY",COUNTER:"COUNTER"});class se{constructor(e,t,r){d(this,"name",void 0),d(this,"tags",void 0),d(this,"values",void 0),this.name=e,this.tags=re.from(t),this.type=r,this.values=[]}reset(){this.values=[]}}class ne extends se{constructor(e){super(e,1{return h(e,2)[1]})}}function he(){return new oe}function ue(e){return{partner:e}}class ge 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=_(_({},this.commonTags),re.from(e))}timer(e){return this.getOrCreate(e,1new ne(e,t))}counter(e){return this.getOrCreate(e,1new ae(e,t))}summary(e){return this.getOrCreate(e,1new ce(e,t))}unregister(){void 0!==this._onUnregisterCallback&&this._onUnregisterCallback(this)}onUnregister(e){this._onUnregisterCallback=e}}{constructor(e,t){var r=2{let i=r.data;if(void 0!==r.data&&r.data._isId5Message&&r.data.src!==s._id&&(void 0===r.data.dst||r.data.dst===s._id))try{[Ie,i.type].forEach(e=>{let t=s._handlers[e];t&&t.forEach(e=>e(i,r.source))})}catch(e){s._log.error("Error while handling message",i,e)}},{capture:!1,signal:e})}unregister(){this._abortController&&this._abortController.abort()}onAnyMessage(e){return this.onMessage(Ie,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 De,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 Ue(i,Fe.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,Pe);return T(JSON.stringify(e))}static createFrom(e){const t=u(new Le,e);return b(t.api)&&(t.apiTypes=function(e){var t=e.api;if(t===Te.NONE)return[];if(t!==Te.PREBID)return[t];{const r=[];return(b(e.gdprApplies)||b(e.consentString))&&r.push(Te.TCF_V2),b(e.ccpaString)&&r.push(Te.USP_V1),b(e.gppData)&&b(e.gppData.version)&&r.push(e.gppData.version),r}}(e),t.api=void 0),D(t.gppData)&&(t.gppData=xe.createFrom(t.gppData)),t}getApiTypeData(e){if(this.apiTypes.includes(e)){if(e===Te.USP_V1)return{ccpaString:this.ccpaString};if(e===Te.TCF_V2)return{consentString:this.consentString,gdprApplies:this.gdprApplies,localStoragePurposeConsent:this.localStoragePurposeConsent};if(e===Te.GPP_V1_1||e===Te.GPP_V1_0)return this.gppData;if(e===Te.ID5_ALLOWED_VENDORS)return{allowedVendors:this.allowedVendors}}}toConsents(){let e={};return b(this.gdprApplies)&&(e.gdpr=this.gdprApplies),b(this.consentString)&&(e.gdpr_consent=this.consentString),b(this.ccpaString)&&(e.us_privacy=this.ccpaString),b(this.gppData)&&(e.gpp=this.gppData.gppString,e.gpp_sid=this.gppData.applicableSections.join(",")),e}}const Fe=Object.freeze({FORCE_ALLOWED_BY_CONFIG:"force_allowed_by_config",ID5_CONSENT:"id5_consent",PROVISIONAL:"provisional",JURISDICTION:"jurisdiction",CONSENT_API:"consent_api"});class Ue{constructor(e,t){var r=2{var t=e.cacheId;s.has(t)||(e=r.getResponseFor(e.integrationId))&&(this._clientStore.storeResponseV2(t,e,r.timestamp,i),s.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 ke(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=y(e.ttl)?e.ttl/86400:Me.DEFAULT.EXTENSIONS.expiresDays,t=new Ge(Me.DEFAULT.EXTENSIONS.name,t);return this._clientStore.storeExtensions(e,t)}}class ke{constructor(e,t){var r=2e}isStale(){return!this.timestamp||this._isOlderThanSec(1209600)}isResponseComplete(){return D(this.response)&&w(this.response.universal_uid)&&w(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 He="_exp";class We{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)}}class Ye{constructor(e){var t=1{const s=e.map(e=>{const t=e.cacheData;var r=null===t||void 0===t||null===(s=t.response)||void 0===s?void 0:s.signature,i=null===t||void 0===t?void 0:t.nb,s=null===t||void 0===t?void 0:t.getMaxAge();return this._createRequest(d,e,r,i,s,n,l)}),o=this._log,a=this._metrics,c=this;return new Promise((t,r)=>{const i=he();var e="".concat("https://id5-sync.com").concat("/gm/v3");o.info("Fetching ID5 ID from:",e,s),function(i,s,n,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&&n?r.send(n):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 ve(e,"success",1{var t=h(e,2),e=t[0],t=t[1];b(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=Xe.checkIfAccessible(),s=this._store.getCachedSignature();const c=new Map;let a=o;const n=this._followers.map(e=>{var t=e.getId(),r=(this._followersRequests[t]||0)+1,i=this._properties.id,s=!0===this._refreshRequired[e.getId()];a=a||s;var n,o=e.getCacheId();return c.has(o)||(n=this._store.getCachedResponse(o))&&c.set(o,n),_(_({},e.getFetchIdData()),{},{integrationId:t,requestCount:r,refresh:s,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(n,t,i,s).then(e=>{this._handleRefreshResult(n,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",_({target:t},2e.getDeclaredConsentSource()).filter(e=>e!==Oe.none));var r=e.source||Oe.cmp,i=1===s.size&&s.has(Oe.partner);this._awaitedConsentFrom?this._awaitedConsentFrom===t?(this._consentManager.setConsentData(e),this._awaitedConsentFrom=void 0):this._handleIgnoredConsent(e,"awaited"):r!==Oe.partner||i?this._consentManager.setConsentData(e):this._handleIgnoredConsent(e,"partner")}}_handleIgnoredConsentUpdate(e){try{const i=this._consentManager._consentDataHolder.getValue();if(i){const s={},n=Le.createFrom(e);Object.values(Te).forEach(e=>{var t,r;n.apiTypes.includes(e)&&i.apiTypes.includes(e)?(t=JSON.stringify(i.getApiTypeData(e)),r=JSON.stringify(n.getApiTypeData(e)),s[e]=t===r?"same":"different"):n.apiTypes.includes(e)?s[e]="added":i.apiTypes.includes(e)&&(s[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 s=new ot;return!0===this._firstFetchTriggered&&(s.lateJoiner=!0,s.uniqueLateJoiner=r,i&&this._callRefresh({forceFetch:!0})),s}_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=m(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 dt extends at{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,ye.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 lt extends at{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=m(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 ht extends Be{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,ye.STORAGE,e,t)}}class ut extends it{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 pt extends class{getConsentData(){}localStorageGrant(){}setStoredPrivacy(){}}{constructor(e,t,r,i,s){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 gt,this._forceAllowLocalStorageGrant=r,this._metrics=s}isForceAllowLocalStorageGrant(){return this._forceAllowLocalStorageGrant}resetConsentData(e){this._consentDataHolder.reset(),this.storedPrivacyData=void 0,this._forceAllowLocalStorageGrant=e}localStorageGrant(){var e=0_(_({},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,y(null==e?void 0:e.nb)?Math.round(e.nb)+r:r);return _(_({},e),{},{nb:t})})}static storedDataMatchesCurrentData(e,t){return null==e||e===t}storedConsentDataMatchesConsentData(e){return vt.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)}}class _t{constructor(e,t,r){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")}submitExtensionCall(t,r){var e=2{if(e.ok)return i.record(_e(this._metrics,r,!0)),e.json();i.record(_e(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(_e(this._metrics,r,!1)),this._log.warn("Got error from ".concat(t," endpoint"),e),{}))}gatherChunks(e,r){if(e){let t=he();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(_e(this._metrics,r.name,!0)),{[r.name]:e,[r.name+"Version"]:"".concat(r.version)})).catch(e=>(t.record(_e(this._metrics,r.name,!1)),this._log.warn("Got error when getting ".concat(r.name),e),{}))}return Promise.resolve({})}gather(e){var t=this._store.getCachedExtensions();if(void 0!==t)return Promise.resolve(t);let r=he(),i=this._submitBounce(e),s=this._submitLbs();return this.submitExtensionCall("https://lb.eu-1-id5-sync.com/lb/v1","lb").then(e=>{var t=this.getChunksEnabled(e);return Promise.allSettled([Promise.resolve(e),this.gatherChunks(t,_t.CHUNKS_CONFIGS.devChunks),this.gatherChunks(t,_t.CHUNKS_CONFIGS.groupChunks),i,s])}).then(e=>{r.record(_e(this._metrics,"all",!0));let t=_t.DEFAULT_RESPONSE;return e.forEach(e=>{e.value&&(t=_(_({},t),e.value))}),this._store.storeExtensions(t),t}).catch(e=>(r.record(_e(this._metrics,"all",!1)),this._log.error("Got error ".concat(e," when gathering extensions data")),_t.DEFAULT_RESPONSE))}_submitLbs(){const e=new AbortController,t=setTimeout(()=>e.abort(),3e3);let r=this.submitExtensionCall("https://lbs.eu-1-id5-sync.com/lbs/v1","lbs",{signal:e.signal});return r.finally(()=>{clearTimeout(t)})}_submitBounce(e){return e.some(e=>{return b(null===(e=e.cacheData)||void 0===e?void 0:e.signature)})?Promise.resolve({}):this.submitExtensionCall("https://id5-sync.com/bounce","bounce",{credentials:"include"})}getChunksEnabled(e){e=null==e?void 0:e.chunks;return 0!==e&&e}}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 ft={createExtensions:function(e,t,r){return new _t(e,t,r)}},mt=Object.freeze({UNKNOWN:"unknown",LEADER:"leader",FOLLOWER:"follower"}),It=Object.freeze({MULTIPLEXING:"multiplexing",SINGLETON:"singleton",MULTIPLEXING_PASSIVE:"multiplexing-passive"}),St=Object.freeze({AWAITING_SCHEDULE:"awaiting_schedule",SKIPPED:"skipped",SCHEDULED:"scheduled",COMPLETED:"completed",CANCELED:"canceled"});class wt{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===It.MULTIPLEXING||e===It.MULTIPLEXING_PASSIVE}isLeaderCapable(){var e;return(null===(e=this.knownState)||void 0===e?void 0:e.operatingMode)===It.MULTIPLEXING}isPassive(){var e;return(null===(e=this.knownState)||void 0===e?void 0:e.operatingMode)===It.MULTIPLEXING_PASSIVE}getInstanceMultiplexingLeader(){var e,t;if((null===(e=this.knownState)||void 0===e?void 0:e.operatingMode)===It.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 Ct{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 s=b(globalThis)&&b(globalThis.crypto)&&S(globalThis.crypto.randomUUID)?globalThis.crypto.randomUUID():"".concat(1e6*Math.random()|0);this.properties=u({id:s,version:"1.0.41",href:null===(s=e.location)||void 0===s?void 0:s.href,domain:null===(s=e.location)||void 0===s?void 0:s.hostname},t),this.role=mt.UNKNOWN,this._metrics=r,this._loadTime=performance.now(),this._logger=new yt(i,this),this._window=e,this._dispatcher=new et(this._logger),this._followerRole=new st(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),Ce.TYPE)}catch(e){this._logger.error("Failed to register integration instance",e)}return this}init(){let i=this,s=i._window;i._mode=It.MULTIPLEXING_PASSIVE,i._messenger=new Ee(i.properties.id,s,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 Ce,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 s=new wt(e.instance,e.instanceState,r);this._knownInstances.get(s.getId())?this._logger.debug("Instance already known",s.getId()):(this._knownInstances.set(s.getId(),s),i||this._messenger.sendResponseMessage(t,this._createHelloMessage(!0),Ce.TYPE),this._logger.debug("Instance joined",s.getId()),this._doFireEvent($e.ID5_INSTANCE_JOINED,s.properties),this._onInstanceDiscovered(e,s))}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 Ce(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(St.COMPLETED))},t._delayMs),t._state=St.SCHEDULED,t._scheduleTime=performance.now()}skip(){this._closeWithState(St.SKIPPED)}cancel(){this._timeoutId&&(clearTimeout(this._timeoutId),this._timeoutId=void 0),this._closeWithState(St.CANCELED)}_closeWithState(e){this._state=e,this._closeTime=performance.now()}}class Pt extends Ct{constructor(e,t,r,i,s,n,o){super(e,t,i,s),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 lt,this._remoteCallsToLeaderHandler=new lt,this._instanceCounters=new bt(i,this.properties),this._storage=r,this._trueLinkAdapter=n,this._cachedIdProvider=new nt("self",new je(o,n),this._logger,this._metrics),this._election=new Et(this)}init(){super.init();var e,t=this;t._mode=!0===t.properties.singletonMode?It.SINGLETON:It.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 be(t._logger).registerTarget(ye.LEADER,t._remoteCallsToLeaderHandler).registerTarget(ye.FOLLOWER,t._followerRole).registerTarget(ye.STORAGE,t._storage)),t._mode===It.SINGLETON?(t._election.skip(),t._onLeaderElected(t.properties)):t._mode===It.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"),s,n,t),this._trueLinkAdapter),n=new Ke(r,t,ft.createExtensions(r,t,s));const a=new ct(this._window,e,i,s,o,r,t,n);a.addFollower(this._followerRole),this._leader.assignLeader(a),this._remoteCallsToLeaderHandler.assignLeader(a),this._mode===It.MULTIPLEXING&&Array.from(this._knownInstances.values()).filter(e=>e.isMultiplexingPartyAllowed()).map(e=>a.addFollower(new ut(e,this._messenger,t,e.isPassive()?rt.PASSIVE:rt.STANDARD))),a.start()}_followRemoteLeader(e){this._leader.assignLeader(new dt(this._messenger,e)),this._remoteCallsToLeaderHandler.assignLeader(new At(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|o(e.version,t.version));var i,s,n;return 0===r&&(r=e.source.localeCompare(t.source),0===r&&(r=-(0|o(e.sourceVersion,t.sourceVersion))),0===r&&(s=(null===(s=e.fetchIdData)||void 0===s||null===(i=s.refererInfo)||void 0===i?void 0:i.numIframes)||Number.MAX_SAFE_INTEGER,n=(null===(i=t.fetchIdData)||void 0===i||null===(n=i.refererInfo)||void 0===n?void 0:n.numIframes)||Number.MAX_SAFE_INTEGER,r=s-n),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",_({},1w(e.brand)&&e.brand.search(t)<0)),C(e.fullVersionList)&&(e.fullVersionList=e.fullVersionList.filter(e=>w(e.brand)&&e.brand.search(t)<0)),e}}}const Rt={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 Nt=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"}}),xt=Object.freeze({TCF:0,USP:1,GPP:2});class Lt{constructor(e,t){d(this,"direct",void 0),d(this,"version",void 0),this.direct=e,this.version=t}getConsentData(){var e=this;return f(function*(){return e.getClientConsentData()})()}static create(a,c){return f(function*(){var e=Mt._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=Mt._buildCmpSurrogate(Nt.gppv1,t);r=function(e,t,r){o(e,r,t)}}var s=yield new Promise(t=>{var e=r("ping",function(e){t(e)});W(e)&&t(e)});switch(s.gppVersion){case Ut.version:return new Ut(s,r,i);case Gt.version:return new Gt(s,r,i,c);default:var n="Unsupported version of gpp: ".concat(s.gppVersion);return a.warn(n),Promise.reject(n)}})()}static caTcfDataHasExpressConsent(e){e=e.PurposesExpressConsent;if(k(e)&&0e==Ae)}static tcfDataHasLocalStorageGrant(e){e=r(Lt,Lt,Ft).call(Lt,e,"PurposeConsent","PurposeConsents");if(k(e)&&0e==Ae))}static getTcfData(e){let t=void 0;return k(e)&&W(e[0])?t=e[0]:W(e)&&(t=e),t}}function Ft(e,t,r){return t in e?e[t]:e[r]}class Ut extends Lt{constructor(e,t,r){super(r,Ut.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 f(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 xe(Te.GPP_V1_0,t.applicableSections,t.gppString);return e&&(r.euTcfSection=new Ne(Lt.tcfDataHasLocalStorageGrant(e),Lt.tcfDataHasID5VendorConsented(e))),r})()}}function Vt(e,t,r){r&&(e.apiTypes.push(t),u(e,r))}d(Ut,"version","1.0");class Gt extends Lt{constructor(e,t,r,i){super(r,Gt.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 f(function*(){const n=o.metrics;return new Promise(r=>{let i=!1;if(o.readyPingData)r(o.parsePingData(o.readyPingData));else{const s=Date.now();let t=setTimeout(()=>{t=void 0,o.gppFn("ping",e=>{"stub"===e.cmpStatus&&(n.counter("gpp.stubUsed",{cmpId:e.cmpId}).inc(),r(o.parsePingData(e)))})},1e3);o.gppFn("addEventListener",e=>"ready"===e.pingData.signalStatus&&void(i?Gt.measureAdditionalEvent(e,n,s):(t?(clearTimeout(t),t=void 0):i||n.timer("gpp.lateCmp",{cmpId:e.pingData.cmpId}).record(Date.now()-s),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 xe(Te.GPP_V1_1,e.applicableSections,e.gppString);var r;return!t.applicableSections.includes(Re.TCFEUV2)||(r=Lt.getTcfData(null===(r=e.parsedSections)||void 0===r?void 0:r.tcfeuv2))&&(t.euTcfSection=new Ne(Lt.tcfDataHasLocalStorageGrant(r),Lt.tcfDataHasID5VendorConsented(r))),!t.applicableSections.includes(Re.TCFCAV1)||(e=Lt.getTcfData(null===(e=e.parsedSections)||void 0===e?void 0:e.tcfcav1))&&(t.canadaTcfSection=new Ne(Lt.caTcfDataHasExpressConsent(e),Lt.caTcfDataHasVendorExpressConsent(e))),t}}d(Gt,"version","1.1");class Mt{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 Le;return e.forcedGrantByConfig=!0,e.source=Oe.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 Le;if(r.source=Oe.partner,W(e.getTCData)){const i=this._parseTcfData(e.getTCData);Vt(r,Te.TCF_V2,i);try{const s=this._metrics;this._lookupTcf(e=>{pe(s,{apiType:Te.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(k(e.allowedVendors)&&Vt(r,Te.ID5_ALLOWED_VENDORS,{allowedVendors:e.allowedVendors.map(e=>e.toString()),gdprApplies:!0}),W(e.getUSPData)){const n=this._parseUspData(e.getUSPData);Vt(r,Te.USP_V1,n);try{const o=this._metrics;this._lookupUsp(e=>{pe(o,{apiType:Te.USP_V1,sameString:(null==e?void 0:e.ccpaString)===(null===n||void 0===n?void 0:n.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 s=[];let n=new Le;n.source=Oe.cmp;var e=r=>(s[r]=0,(e,t)=>{s[r]||(s[r]=Date.now(),e&&Vt(n,t,e),s.every(e=>0{t?r(this._parseUspData(e),Te.USP_V1):(this._log.error("cmpApi: USP callback not successful. Using defaults for CCPA."),r())})}_lookupGpp(n){var o=this;return f(function*(){var t=Date.now();try{let e=yield Lt.create(o._log,o._metrics);if(e){var r={gppVersion:e.version,directCmp:e.direct};try{var i=yield e.getConsentData();n({gppData:i},i.version);var s=Date.now();o._metrics.timer("gpp.delay",r).record(s-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."),n()}}else n()}catch(e){o._metrics.counter("gpp.failure",{type:"CLIENT"}).inc(),o._log.error("cmpApi: creating GPP client not successful. Using defaults for Gpp."),n()}})()}static _buildCmpSurrogate(a,c){return(e,t,r)=>{const i=Math.random()+"",s={},n={};n[a.objKeys[0]]=e,n[a.objKeys[1]]=t,n.callId=i,s[a.objName]=n;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(s,"*")}}_lookupTcf(e){var t=Mt._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=Mt._buildCmpSurrogate(Nt.tcfv2,e);this._lookupDirectTcf(e,t)}_lookupDirectTcf(e,s){const n=this._log;e("addEventListener",2,(e,t)=>{var r,i;return r="event",i=e,n.info("cmpApi: TCFv2 - Received a call back: ".concat(r),i),t?!(!e||!1!==e.gdprApplies&&"tcloaded"!==e.eventStatus&&"useractioncomplete"!==e.eventStatus)&&void s(this._parseTcfData(e),Te.TCF_V2):(n.error("cmpApi: TCFv2 - Received insuccess: ".concat("addEventListener",". Please check your CMP setup. Using defaults for GDPR.")),void s())})}_parseUspData(e){if(W(e)&&j(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=Mt._isValidV2ConsentObject,i=Mt._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||j(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[Ae])}static _normalizeV2Data(e){let t=J(e,"purpose.consents.1");q(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=Rt[t];if(void 0!==t)return 0!=(t&1<<6-r%6-1)}}(e.tcString,1));var r=Mt._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 jt{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)}}const kt="id5-prebid-ext-module";class Ht{set debug(e){e=e,x=!!e}get debug(){return F()}constructor(){d(this,"invocationId",0),d(this,"_version",X),d(this,"userIdReady",!1),this._isUsingCdn=!!(document&&document.currentScript&&document.currentScript.src&&0===document.currentScript.src.indexOf("https://cdn.id5-sync.com"))}fetchId5Id(d,l,h,u,g,p){var v=this;return f(function*(){var e;v.invocationId+=1;var t=v.getPrebidVersion();const s=new U(kt,v.invocationId);s.info("ID5 API Prebid external module version ".concat(v._version,". Invoking fetchId5Id()"),d,l);const r=new K({partnerId:l.partner,pd:l.pd,abTesting:l.abTesting,multiplexing:l.multiplexing,diagnostics:l.diagnostics,segments:l.segments,disableUaHints:l.disableUaHints,dynamicConfig:d},s);var i=r.getOptions();const n=v._configureDiagnostics(i.partnerId,i.diagnostics,h,s,t);n&&(!function(e,t){return e.timer("instance.load.delay",1{a.on(Qe.USER_ID_READY,(e,t)=>{try{var r=null!=t&&t.tags?_({},t.tags):{};null!=t&&t.timestamp&&n.timer("userid.provisioning.delivery.delay",r).record(Date.now()-t.timestamp),c.record(function(e,t,r){return e.timer("userid.provisioning.delay",_({cachedResponseUsed:t},2{s.info("ID5 User ID fetch canceled:",e.reason),t(e.reason)})}),t=yield v._gatherFetchIdData(r,h,s,t);return a.register({source:kt,sourceVersion:X,sourceConfiguration:{options:r.getOptions()},fetchIdData:t,singletonMode:!0===(null==i||null===(e=i.multiplexing)||void 0===e?void 0:e._disabled),canDoCascade:null!==(e=l.canCookieSync)&&void 0!==e&&e,forceAllowLocalStorageGrant:!1,storageExpirationDays:i.storageExpirationDays}),o})()}getPrebidVersion(){if(B(null===(e=window.pbjs)||void 0===e?void 0:e.version))return window.pbjs.version;if(k(window._pbjsGlobals)&&0new Z(a,{sampling:o}).publish(e,t):e=>e));null!=r&&r.publishAfterLoadInMsec&&0