@optable/web-sdk 0.26.1 → 0.26.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see sdk.js.LICENSE.txt */
2
- (()=>{var t={396:t=>{t.exports=function(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}},312:(t,e,i)=>{var r;!function(){"use strict";var e="input is invalid type",n="object"==typeof window,s=n?window:{};s.JS_SHA256_NO_WINDOW&&(n=!1);var o=!n&&"object"==typeof self,a=!s.JS_SHA256_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node;a?s=i.g:o&&(s=self);var c=!s.JS_SHA256_NO_COMMON_JS&&t.exports,h=i.amdO,u=!s.JS_SHA256_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,d="0123456789abcdef".split(""),p=[-2147483648,8388608,32768,128],f=[24,16,8,0],g=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],l=["hex","array","digest","arrayBuffer"],y=[];!s.JS_SHA256_NO_NODE_JS&&Array.isArray||(Array.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)}),!u||!s.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(t){return"object"==typeof t&&t.buffer&&t.buffer.constructor===ArrayBuffer});var m=function(t,e){return function(i){return new S(e,!0).update(i)[t]()}},w=function(t){var e=m("hex",t);a&&(e=v(e,t)),e.create=function(){return new S(t)},e.update=function(t){return e.create().update(t)};for(var i=0;i<l.length;++i){var r=l[i];e[r]=m(r,t)}return e},v=function(t,r){var n,o=i(394),a=i(903).Buffer,c=r?"sha224":"sha256";return n=a.from&&!s.JS_SHA256_NO_BUFFER_FROM?a.from:function(t){return new a(t)},function(i){if("string"==typeof i)return o.createHash(c).update(i,"utf8").digest("hex");if(null==i)throw new Error(e);return i.constructor===ArrayBuffer&&(i=new Uint8Array(i)),Array.isArray(i)||ArrayBuffer.isView(i)||i.constructor===a?o.createHash(c).update(n(i)).digest("hex"):t(i)}},A=function(t,e){return function(i,r){return new P(i,e,!0).update(r)[t]()}},b=function(t){var e=A("hex",t);e.create=function(e){return new P(e,t)},e.update=function(t,i){return e.create(t).update(i)};for(var i=0;i<l.length;++i){var r=l[i];e[r]=A(r,t)}return e};function S(t,e){e?(y[0]=y[16]=y[1]=y[2]=y[3]=y[4]=y[5]=y[6]=y[7]=y[8]=y[9]=y[10]=y[11]=y[12]=y[13]=y[14]=y[15]=0,this.blocks=y):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t?(this.h0=3238371032,this.h1=914150663,this.h2=812702999,this.h3=4144912697,this.h4=4290775857,this.h5=1750603025,this.h6=1694076839,this.h7=3204075428):(this.h0=1779033703,this.h1=3144134277,this.h2=1013904242,this.h3=2773480762,this.h4=1359893119,this.h5=2600822924,this.h6=528734635,this.h7=1541459225),this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0,this.is224=t}function P(t,i,r){var n,s=typeof t;if("string"===s){var o,a=[],c=t.length,h=0;for(n=0;n<c;++n)(o=t.charCodeAt(n))<128?a[h++]=o:o<2048?(a[h++]=192|o>>>6,a[h++]=128|63&o):o<55296||o>=57344?(a[h++]=224|o>>>12,a[h++]=128|o>>>6&63,a[h++]=128|63&o):(o=65536+((1023&o)<<10|1023&t.charCodeAt(++n)),a[h++]=240|o>>>18,a[h++]=128|o>>>12&63,a[h++]=128|o>>>6&63,a[h++]=128|63&o);t=a}else{if("object"!==s)throw new Error(e);if(null===t)throw new Error(e);if(u&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!(Array.isArray(t)||u&&ArrayBuffer.isView(t)))throw new Error(e)}t.length>64&&(t=new S(i,!0).update(t).array());var d=[],p=[];for(n=0;n<64;++n){var f=t[n]||0;d[n]=92^f,p[n]=54^f}S.call(this,i,r),this.update(p),this.oKeyPad=d,this.inner=!0,this.sharedMemory=r}S.prototype.update=function(t){if(!this.finalized){var i,r=typeof t;if("string"!==r){if("object"!==r)throw new Error(e);if(null===t)throw new Error(e);if(u&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!(Array.isArray(t)||u&&ArrayBuffer.isView(t)))throw new Error(e);i=!0}for(var n,s,o=0,a=t.length,c=this.blocks;o<a;){if(this.hashed&&(this.hashed=!1,c[0]=this.block,this.block=c[16]=c[1]=c[2]=c[3]=c[4]=c[5]=c[6]=c[7]=c[8]=c[9]=c[10]=c[11]=c[12]=c[13]=c[14]=c[15]=0),i)for(s=this.start;o<a&&s<64;++o)c[s>>>2]|=t[o]<<f[3&s++];else for(s=this.start;o<a&&s<64;++o)(n=t.charCodeAt(o))<128?c[s>>>2]|=n<<f[3&s++]:n<2048?(c[s>>>2]|=(192|n>>>6)<<f[3&s++],c[s>>>2]|=(128|63&n)<<f[3&s++]):n<55296||n>=57344?(c[s>>>2]|=(224|n>>>12)<<f[3&s++],c[s>>>2]|=(128|n>>>6&63)<<f[3&s++],c[s>>>2]|=(128|63&n)<<f[3&s++]):(n=65536+((1023&n)<<10|1023&t.charCodeAt(++o)),c[s>>>2]|=(240|n>>>18)<<f[3&s++],c[s>>>2]|=(128|n>>>12&63)<<f[3&s++],c[s>>>2]|=(128|n>>>6&63)<<f[3&s++],c[s>>>2]|=(128|63&n)<<f[3&s++]);this.lastByteIndex=s,this.bytes+=s-this.start,s>=64?(this.block=c[16],this.start=s-64,this.hash(),this.hashed=!0):this.start=s}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296|0,this.bytes=this.bytes%4294967296),this}},S.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var t=this.blocks,e=this.lastByteIndex;t[16]=this.block,t[e>>>2]|=p[3&e],this.block=t[16],e>=56&&(this.hashed||this.hash(),t[0]=this.block,t[16]=t[1]=t[2]=t[3]=t[4]=t[5]=t[6]=t[7]=t[8]=t[9]=t[10]=t[11]=t[12]=t[13]=t[14]=t[15]=0),t[14]=this.hBytes<<3|this.bytes>>>29,t[15]=this.bytes<<3,this.hash()}},S.prototype.hash=function(){var t,e,i,r,n,s,o,a,c,h=this.h0,u=this.h1,d=this.h2,p=this.h3,f=this.h4,l=this.h5,y=this.h6,m=this.h7,w=this.blocks;for(t=16;t<64;++t)e=((n=w[t-15])>>>7|n<<25)^(n>>>18|n<<14)^n>>>3,i=((n=w[t-2])>>>17|n<<15)^(n>>>19|n<<13)^n>>>10,w[t]=w[t-16]+e+w[t-7]+i|0;for(c=u&d,t=0;t<64;t+=4)this.first?(this.is224?(s=300032,m=(n=w[0]-1413257819)-150054599|0,p=n+24177077|0):(s=704751109,m=(n=w[0]-210244248)-1521486534|0,p=n+143694565|0),this.first=!1):(e=(h>>>2|h<<30)^(h>>>13|h<<19)^(h>>>22|h<<10),r=(s=h&u)^h&d^c,m=p+(n=m+(i=(f>>>6|f<<26)^(f>>>11|f<<21)^(f>>>25|f<<7))+(f&l^~f&y)+g[t]+w[t])|0,p=n+(e+r)|0),e=(p>>>2|p<<30)^(p>>>13|p<<19)^(p>>>22|p<<10),r=(o=p&h)^p&u^s,y=d+(n=y+(i=(m>>>6|m<<26)^(m>>>11|m<<21)^(m>>>25|m<<7))+(m&f^~m&l)+g[t+1]+w[t+1])|0,e=((d=n+(e+r)|0)>>>2|d<<30)^(d>>>13|d<<19)^(d>>>22|d<<10),r=(a=d&p)^d&h^o,l=u+(n=l+(i=(y>>>6|y<<26)^(y>>>11|y<<21)^(y>>>25|y<<7))+(y&m^~y&f)+g[t+2]+w[t+2])|0,e=((u=n+(e+r)|0)>>>2|u<<30)^(u>>>13|u<<19)^(u>>>22|u<<10),r=(c=u&d)^u&p^a,f=h+(n=f+(i=(l>>>6|l<<26)^(l>>>11|l<<21)^(l>>>25|l<<7))+(l&y^~l&m)+g[t+3]+w[t+3])|0,h=n+(e+r)|0,this.chromeBugWorkAround=!0;this.h0=this.h0+h|0,this.h1=this.h1+u|0,this.h2=this.h2+d|0,this.h3=this.h3+p|0,this.h4=this.h4+f|0,this.h5=this.h5+l|0,this.h6=this.h6+y|0,this.h7=this.h7+m|0},S.prototype.hex=function(){this.finalize();var t=this.h0,e=this.h1,i=this.h2,r=this.h3,n=this.h4,s=this.h5,o=this.h6,a=this.h7,c=d[t>>>28&15]+d[t>>>24&15]+d[t>>>20&15]+d[t>>>16&15]+d[t>>>12&15]+d[t>>>8&15]+d[t>>>4&15]+d[15&t]+d[e>>>28&15]+d[e>>>24&15]+d[e>>>20&15]+d[e>>>16&15]+d[e>>>12&15]+d[e>>>8&15]+d[e>>>4&15]+d[15&e]+d[i>>>28&15]+d[i>>>24&15]+d[i>>>20&15]+d[i>>>16&15]+d[i>>>12&15]+d[i>>>8&15]+d[i>>>4&15]+d[15&i]+d[r>>>28&15]+d[r>>>24&15]+d[r>>>20&15]+d[r>>>16&15]+d[r>>>12&15]+d[r>>>8&15]+d[r>>>4&15]+d[15&r]+d[n>>>28&15]+d[n>>>24&15]+d[n>>>20&15]+d[n>>>16&15]+d[n>>>12&15]+d[n>>>8&15]+d[n>>>4&15]+d[15&n]+d[s>>>28&15]+d[s>>>24&15]+d[s>>>20&15]+d[s>>>16&15]+d[s>>>12&15]+d[s>>>8&15]+d[s>>>4&15]+d[15&s]+d[o>>>28&15]+d[o>>>24&15]+d[o>>>20&15]+d[o>>>16&15]+d[o>>>12&15]+d[o>>>8&15]+d[o>>>4&15]+d[15&o];return this.is224||(c+=d[a>>>28&15]+d[a>>>24&15]+d[a>>>20&15]+d[a>>>16&15]+d[a>>>12&15]+d[a>>>8&15]+d[a>>>4&15]+d[15&a]),c},S.prototype.toString=S.prototype.hex,S.prototype.digest=function(){this.finalize();var t=this.h0,e=this.h1,i=this.h2,r=this.h3,n=this.h4,s=this.h5,o=this.h6,a=this.h7,c=[t>>>24&255,t>>>16&255,t>>>8&255,255&t,e>>>24&255,e>>>16&255,e>>>8&255,255&e,i>>>24&255,i>>>16&255,i>>>8&255,255&i,r>>>24&255,r>>>16&255,r>>>8&255,255&r,n>>>24&255,n>>>16&255,n>>>8&255,255&n,s>>>24&255,s>>>16&255,s>>>8&255,255&s,o>>>24&255,o>>>16&255,o>>>8&255,255&o];return this.is224||c.push(a>>>24&255,a>>>16&255,a>>>8&255,255&a),c},S.prototype.array=S.prototype.digest,S.prototype.arrayBuffer=function(){this.finalize();var t=new ArrayBuffer(this.is224?28:32),e=new DataView(t);return e.setUint32(0,this.h0),e.setUint32(4,this.h1),e.setUint32(8,this.h2),e.setUint32(12,this.h3),e.setUint32(16,this.h4),e.setUint32(20,this.h5),e.setUint32(24,this.h6),this.is224||e.setUint32(28,this.h7),t},P.prototype=new S,P.prototype.finalize=function(){if(S.prototype.finalize.call(this),this.inner){this.inner=!1;var t=this.array();S.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(t),S.prototype.finalize.call(this)}};var I=w();I.sha256=I,I.sha224=w(!0),I.sha256.hmac=b(),I.sha224.hmac=b(!0),c?t.exports=I:(s.sha256=I.sha256,s.sha224=I.sha224,h&&(void 0===(r=function(){return I}.call(I,i,I,t))||(t.exports=r)))}()},903:()=>{},394:()=>{}},e={};function i(r){var n=e[r];if(void 0!==n)return n.exports;var s=e[r]={exports:{}};return t[r](s,s.exports,i),s.exports}i.amdO={},i.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return i.d(e,{a:e}),e},i.d=(t,e)=>{for(var r in e)i.o(e,r)&&!i.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),(()=>{"use strict";var t=i(396),e=i.n(t);const r={r:"v0.26.1"},n={"Europe/Amsterdam":"gdpr","Europe/Athens":"gdpr","Europe/Berlin":"gdpr","Europe/Brussels":"gdpr","Europe/Bucharest":"gdpr","Europe/Budapest":"gdpr","Europe/Copenhagen":"gdpr","Europe/Dublin":"gdpr","Europe/Helsinki":"gdpr","Europe/Lisbon":"gdpr","Europe/London":"gdpr","Europe/Madrid":"gdpr","Europe/Oslo":"gdpr","Europe/Paris":"gdpr","Europe/Prague":"gdpr","Europe/Rome":"gdpr","Europe/Sofia":"gdpr","Europe/Stockholm":"gdpr","Europe/Vienna":"gdpr","Europe/Warsaw":"gdpr","Europe/Zurich":"gdpr","America/Toronto":"can","America/New_York":"us","America/Detroit":"us","America/Kentucky/Louisville":"us","America/Kentucky/Monticello":"us","America/Indiana/Indianapolis":"us","America/Indiana/Vincennes":"us","America/Indiana/Winamac":"us","America/Indiana/Marengo":"us","America/Indiana/Petersburg":"us","America/Indiana/Vevay":"us","America/Chicago":"us","America/Indiana/Tell_City":"us","America/Indiana/Knox":"us","America/Menominee":"us","America/North_Dakota/Center":"us","America/North_Dakota/New_Salem":"us","America/North_Dakota/Beulah":"us","America/Denver":"us","America/Boise":"us","America/Phoenix":"us","America/Los_Angeles":"us","America/Anchorage":"us","America/Juneau":"us","America/Sitka":"us","America/Metlakatla":"us","America/Yakutat":"us","America/Nome":"us","America/Adak":"us","Pacific/Honolulu":"us"},s=5,o="tcfcav1",a=2,c="tcfeuv2";function h(t,e,i){return!t.gdprApplies||(i?t.purpose.consents[e]&&t.vendor.consents[i]:!!t.publisher.consents[e])}function u(t,e,i){if(!t.applicableSections.includes(s))return!0;const r=e>1,n=t.parsedSections[o]||[];if("number"==typeof i){const t=n.find((t=>"Version"in t));if(!t)return!1;let s=t.PurposesExpressConsent.includes(e)&&t.VendorExpressConsent.includes(i);return r&&(s||=t.PurposesImpliedConsent.includes(e)&&t.VendorImpliedConsent.includes(i)),s}const a=n.find((t=>"SubsectionType"in t&&3===t.SubsectionType));if(!a)return!1;let c=a.PubPurposesExpressConsent.includes(e);return r&&(c||=a.PubPurposesImpliedConsent.includes(e)),c}function d(t,e,i){if(!t.applicableSections.includes(a))return!0;const r=e>1,n=t.parsedSections[c]||[];if("number"==typeof i){const t=n.find((t=>"Version"in t));if(!t)return!1;let s=t.PurposeConsent.includes(e)&&t.VendorConsent.includes(i);return r&&(s||=t.PurposesLITransparency.includes(e)&&t.VendorLegitimateInterest.includes(i)),s}const s=n.find((t=>"SegmentType"in t&&3===t.SegmentType));if(!s)return!1;let o=s.PubPurposesConsent.includes(e);return r&&(o||=s.PubPurposesLITransparency.includes(e)),o}function p(t){g()&&window.__gpp?.("addEventListener",((e,i)=>{i&&"signalStatus"===e.eventName&&"ready"===e.data&&t(e.pingData)}))}function f(t){l()&&window.__tcfapi?.("addEventListener",2,((e,i)=>{i&&("tcloaded"===e.eventStatus||"useractioncomplete"===e.eventStatus)&&t(e)}))}function g(){return"function"==typeof window.__gpp}function l(){return"function"==typeof window.__tcfapi}const y={cookies:!0,initPassport:!0,consent:{reg:null,deviceAccess:!0,createProfilesForAdvertising:!0,useProfilesForAdvertising:!0,measureAdvertisingPerformance:!0}};async function m(t){const e=await A("/config",t,{method:"GET",headers:{Accept:"application/json"}});return new v(t).setSite(e),e}class w{constructor(t){e()(this,"consent",void 0),this.consent=t}getItem(t){return this.consent.deviceAccess?window.localStorage.getItem(t):null}setItem(t,e){this.consent.deviceAccess&&window.localStorage.setItem(t,e)}removeItem(t){this.consent.deviceAccess&&window.localStorage.removeItem(t)}}class v{constructor(t){this.config=t,e()(this,"passportKey",void 0),e()(this,"targetingV1Key",void 0),e()(this,"targetingKey",void 0),e()(this,"siteKey",void 0),e()(this,"storage",void 0);const i=btoa(function(t){const e=new Uint16Array(t.length);for(let i=0;i<e.length;i++)e[i]=t.charCodeAt(i);return String.fromCharCode(...new Uint8Array(e.buffer))}(`${this.config.host}/${this.config.site}`));this.targetingV1Key="OPTABLE_TGT_"+i,this.passportKey="OPTABLE_PASS_"+i,this.targetingKey="OPTABLE_V2_TGT_"+i,this.siteKey="OPTABLE_SITE_"+i,this.storage=new w(this.config.consent)}getPassport(){return this.storage.getItem(this.passportKey)}getV1Targeting(){const t=this.storage.getItem(this.targetingV1Key),e=t?JSON.parse(t):null;return e?{user:[],audience:Object.entries(e).map((t=>{let[e,i]=t;return{provider:"optable.co",keyspace:e,rtb_segtax:5001,ids:[].concat(i).map((t=>({id:String(t)})))}}))}:null}getTargeting(){const t=this.storage.getItem(this.targetingKey);return(t?JSON.parse(t):null)||this.getV1Targeting()}setPassport(t){t&&t.length>0&&this.storage.setItem(this.passportKey,t)}setTargeting(t){t&&this.storage.setItem(this.targetingKey,JSON.stringify(t))}setSite(t){t&&this.storage.setItem(this.siteKey,JSON.stringify(t))}getSite(){const t=this.storage.getItem(this.siteKey);return t?JSON.parse(t):null}clearPassport(){this.storage.removeItem(this.passportKey)}clearTargeting(){this.storage.removeItem(this.targetingKey)}clearSite(){this.storage.removeItem(this.siteKey)}}async function A(t,e,i){const n=await globalThis.fetch(function(t,e,i){const{site:n,host:s,cookies:o}=e,a=new URL(`${n}${t}`,`https://${s}`);if(a.searchParams.set("osdk",`web-${r.r}`),e.consent.reg&&a.searchParams.set("reg",e.consent.reg),e.consent.gpp&&a.searchParams.set("gpp",e.consent.gpp),e.consent.gppSectionIDs&&a.searchParams.set("gpp_sid",e.consent.gppSectionIDs.join(",")),e.consent.tcf&&a.searchParams.set("tcf",e.consent.tcf),o)a.searchParams.set("cookies","yes");else{const t=new v(e).getPassport();a.searchParams.set("cookies","no"),a.searchParams.set("passport",t||"")}const c={...i};return c.credentials="include",new Request(a.toString(),c)}(t,e,i)),s=n.headers.get("Content-Type"),o=s?.startsWith("application/json")?await n.json():await n.text();if(!n.ok)throw new Error(o.error);return o.passport&&(new v(e).setPassport(o.passport),delete o.passport),o}var b;function S(t){return{user:{data:(t?.audience??[]).map((t=>({name:t.provider,segment:t.ids,ext:{segtax:t.rtb_segtax}}))),ext:{eids:(t?.user??[]).map((t=>({source:t.provider,uids:t.ids.map((t=>{let{id:e}=t;return{id:e,atype:b.PersonID}}))})))}}}}function P(t){const e={};if(!t)return e;for(const i of t.audience??[])i.keyspace&&(i.keyspace in e||(e[i.keyspace]=[]),e[i.keyspace].push(...i.ids.map((t=>t.id))));return e}!function(t){t[t.DeviceID=1]="DeviceID",t[t.InAppImpression=2]="InAppImpression",t[t.PersonID=3]="PersonID"}(b||(b={}));var I=i(312);class E{constructor(t){e()(this,"dcn",void 0),e()(this,"init",void 0),this.dcn=function(t){const e={host:t.host,site:t.site,cookies:t.cookies??y.cookies,initPassport:t.initPassport??y.initPassport,consent:y.consent};return t.consent?.static?e.consent=t.consent.static:t.consent?.cmpapi&&(e.consent=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i={reg:t,deviceAccess:!1,createProfilesForAdvertising:!1,useProfilesForAdvertising:!1,measureAdvertisingPerformance:!1};switch(p((t=>{i.gpp=t.gppString,i.gppSectionIDs=t.applicableSections})),f((t=>{i.tcf=t.gdprApplies?t.tcString:void 0})),t){case"gdpr":l()?f((t=>{i.deviceAccess=h(t,1,e.tcfeuVendorID),i.createProfilesForAdvertising=h(t,3,e.tcfeuVendorID),i.useProfilesForAdvertising=h(t,4,e.tcfeuVendorID),i.measureAdvertisingPerformance=h(t,7,e.tcfeuVendorID)})):g()&&p((t=>{i.deviceAccess=d(t,1,e.tcfeuVendorID),i.createProfilesForAdvertising=d(t,3,e.tcfeuVendorID),i.useProfilesForAdvertising=d(t,4,e.tcfeuVendorID),i.measureAdvertisingPerformance=d(t,7,e.tcfeuVendorID)}));break;case"can":i.deviceAccess=!0,p((t=>{i.createProfilesForAdvertising=u(t,3,e.tcfcaVendorID),i.useProfilesForAdvertising=u(t,4,e.tcfcaVendorID),i.measureAdvertisingPerformance=u(t,7,e.tcfcaVendorID)}));break;default:i.deviceAccess=!0,i.createProfilesForAdvertising=!0,i.useProfilesForAdvertising=!0,i.measureAdvertisingPerformance=!0}return i}(function(){const t=Intl.DateTimeFormat().resolvedOptions().timeZone,e=n[t];return"can"===e?["fr","fr-CA"].some((t=>navigator.languages.includes(t)))?"can":null:e??null}(),t.consent.cmpapi)),e}(t);const i=()=>{};this.init=this.dcn.initPassport?m(this.dcn).then(i).catch(i):Promise.resolve()}async identify(){await this.init;for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];return function(t,e){return A("/identify",t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}(this.dcn,e.filter((t=>t)))}async uid2Token(t){return await this.init,function(t,e){return A("/uid2/token",t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}(this.dcn,t)}async targeting(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"__passport__";return await this.init,async function(t,e){const i="/v2/targeting?"+new URLSearchParams({id:e}).toString(),r=await A(i,t,{method:"GET",headers:{Accept:"application/json"}});return r&&new v(t).setTargeting(r),r}(this.dcn,t)}targetingFromCache(){return t=this.dcn,new v(t).getTargeting();var t}async site(){return m(this.dcn)}siteFromCache(){return t=this.dcn,new v(t).getSite();var t}targetingClearCache(){var t;t=this.dcn,new v(t).clearTargeting()}async prebidORTB2(){return S(await this.targeting())}prebidORTB2FromCache(){return S(this.targetingFromCache())}async targetingKeyValues(){return P(await this.targeting())}targetingKeyValuesFromCache(){return P(this.targetingFromCache())}async witness(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return await this.init,function(t,e,i){const r={event:e,properties:i};return A("/witness",t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)})}(this.dcn,t,e)}async profile(t){return await this.init,function(t,e){const i={traits:e};return A("/profile",t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)})}(this.dcn,t)}async tokenize(t){return await this.init,function(t,e){let i={id:e};return A("/v1/tokenize",t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)})}(this.dcn,t)}async resolve(t){return await this.init,async function(t,e){const i=new URLSearchParams;"string"==typeof e&&i.append("id",e);const r="/v1/resolve?"+i.toString();return function(t){const e={clusters:[],lmpid:""};if("object"!=typeof t||null===t)return e;if("lmpid"in t&&"string"==typeof t?.lmpid&&(e.lmpid=t.lmpid),!("clusters"in t)||!Array.isArray(t?.clusters))return e;for(const i of t.clusters){const t={ids:[],traits:[]};if(Array.isArray(i?.ids))for(const e of i.ids)"string"==typeof e&&t.ids.push(e);if(Array.isArray(i?.traits))for(const e of i.traits)"string"==typeof e?.key&&"string"==typeof e?.value&&t.traits.push({key:e.key,value:e.value});(t.ids.length>0||t.traits.length>0)&&e.clusters.push(t)}return e}(await A(r,t,{method:"GET",headers:{Accept:"application/json"}}))}(this.dcn,t)}static eid(t){return t?"e:"+I.sha256.hex(t.toLowerCase().trim()):""}static sha256(t){return t?I.sha256.hex(t):""}static cid(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i="c:";if("string"!=typeof t)throw new Error("Invalid ppid");if("number"!=typeof e||isNaN(e)||e<0||e>9)throw new Error("Invalid variant");return e>0&&(i=`c${e}:`),t?i+t.trim():""}static TargetingKeyValues(t){return P(t)}static PrebidORTB2(t){return S(t)}}e()(E,"version",r.r);const _=E;function T(t){return{advertiserId:t.advertiserId?.toString(),campaignId:t.campaignId?.toString(),creativeId:t.creativeId?.toString(),isEmpty:t.isEmpty?.toString(),lineItemId:t.lineItemId?.toString(),serviceName:t.serviceName?.toString(),size:t.size?.toString(),slotElementId:t.slot?.getSlotElementId(),sourceAgnosticCreativeId:t.sourceAgnosticCreativeId?.toString(),sourceAgnosticLineItemId:t.sourceAgnosticLineItemId?.toString()}}_.prototype.installGPTEventListeners=function(){const t=this;t.installGPTEventListeners=function(){},window.googletag=window.googletag||{cmd:[]};const e=window.googletag;e.cmd.push((function(){e.pubads().addEventListener("slotRenderEnded",(function(e){t.witness("googletag.events.slotRenderEnded",T(e))})),e.pubads().addEventListener("impressionViewable",(function(e){t.witness("googletag.events.impressionViewable",T(e))}))}))},_.prototype.installGPTSecureSignals=function(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];window.googletag=window.googletag||{cmd:[]};const r=window.googletag;e&&e.length>0&&r.cmd.push((()=>{e.forEach((t=>{let{provider:e,id:i}=t;r.secureSignalProviders.push({id:e,collectorFunction:()=>Promise.resolve(i)})}))}))};const C=/^[a-f0-9]{64}$/i;_.prototype.tryIdentifyFromParams=function(t,e){const i=new RegExp(`^${t||"oeid"}$`,"i"),r=new URLSearchParams(window.location.search);let n="";for(const[t,e]of r)if(i.test(t)){n=e;break}""!=n&&(e||function(t){return C.test(t)}(n))&&this.identify((e||"e")+":"+n.toLowerCase())},_.prototype.auctionConfigFromCache=function(){const t=this.siteFromCache();return t?t.auctionConfig??null:null},_.prototype.installGPTAuctionConfigs=function(t){const e=this;e.installGPTAuctionConfigs=function(){},window.googletag=window.googletag||{cmd:[]};const i=window.googletag;i.cmd.push((function(){let r=i.pubads().getSlots();t&&(r=r.filter(t));const n=e.auctionConfigFromCache();if(n)for(const t of r){const e=t.getSizes(),i=[];for(const t of e)"fluid"!==t&&i.push({configKey:n.seller+"-"+t.getWidth()+"x"+t.getHeight(),auctionConfig:{...n,requestedSize:{width:t.getWidth()+"px",height:t.getHeight()+"px"}}});t.setConfig({componentAuction:i})}}))},_.prototype.runAdAuction=async function(t,e){if(!("runAdAuction"in navigator))throw"run-ad-auction not supported";const i=document.getElementById(t);if(!i)throw"spot not found";const r=function(t){const e=window.getComputedStyle(t,null);return{width:e.getPropertyValue("width"),height:e.getPropertyValue("height")}}(i),n=this.auctionConfigFromCache();if(!n)return!1;const s={...n,requestedSize:r,resolveToConfig:!0},o=e?.iframe??!1;o&&(s.resolveToConfig=!1);const a=await navigator.runAdAuction(s);if(!a)return i.replaceChildren(),!1;if(o){const t=document.createElement("iframe");t.src=a,t.style.border="none",t.style.width=r.width,t.style.height=r.height,i.replaceChildren(t)}else{const t=document.createElement("fencedframe");t.config=a,t.style.border="none",i.replaceChildren(t)}return!0},_.prototype.joinAdInterestGroups=async function(){if(!("joinAdInterestGroup"in navigator))throw"join-ad-interest-group not supported";if(!(this.dcn.consent.deviceAccess&&this.dcn.consent.createProfilesForAdvertising&&this.dcn.consent.measureAdvertisingPerformance))throw"consent not granted for joining interest groups";const t=await this.site();if(!t.interestGroupPixel)throw"origin not enabled for protected audience apis";const e=new URL(t.interestGroupPixel),i=document.createElement("iframe");i.src=e.toString(),i.allow="join-ad-interest-group "+e.origin,i.style.display="none";const r=new Promise(((t,e)=>{window.addEventListener("message",(r=>{r.source===i.contentWindow&&("success"!==r.data.result?e():t())}))}));return document.body.appendChild(i),r},_.prototype.getTopics=async function(){if(!("browsingTopics"in document))throw"browsing-topics not supported";if(!this.dcn.consent.deviceAccess)throw"consent not granted for reading browsing topics";const t=await this.site();if(!t.getTopicsURL)throw"origin not enabled for topics api";const e=new URL(t.getTopicsURL),i=document.createElement("iframe");i.src=e.toString(),i.allow="browsing-topics "+e.origin,i.style.display="none";const r=new Promise(((t,e)=>{window.addEventListener("message",(r=>{r.source===i.contentWindow&&(r.data.error?e(new Error(r.data.error.toString())):t(r.data.result))}))}));return document.body.appendChild(i),r},_.prototype.ingestTopics=function(){this.getTopics().then((t=>{if(!t.length)return;const e=t.reduce(((t,e)=>{const i=`topics_v${e.taxonomyVersion}`;return t[i]?t[i]+=",":t[i]="",t[i]+=String(e.topic),t}),{});this.profile(e)})).catch((()=>{}))},window.optable=window.optable||{},window.optable.SDK=_,window.optable.cmd=new class{constructor(t){if(this.cmds=t,Array.isArray(this.cmds))for(const t of this.cmds)"function"==typeof t&&t()}push(t){t()}}(window.optable.cmd||[])})()})();
2
+ (()=>{var t={396:t=>{t.exports=function(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}},312:(t,e,r)=>{var i;!function(){"use strict";var e="input is invalid type",n="object"==typeof window,s=n?window:{};s.JS_SHA256_NO_WINDOW&&(n=!1);var o=!n&&"object"==typeof self,a=!s.JS_SHA256_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node;a?s=r.g:o&&(s=self);var c=!s.JS_SHA256_NO_COMMON_JS&&t.exports,u=r.amdO,h=!s.JS_SHA256_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,p="0123456789abcdef".split(""),d=[-2147483648,8388608,32768,128],g=[24,16,8,0],l=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],f=["hex","array","digest","arrayBuffer"],m=[];!s.JS_SHA256_NO_NODE_JS&&Array.isArray||(Array.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)}),!h||!s.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(t){return"object"==typeof t&&t.buffer&&t.buffer.constructor===ArrayBuffer});var y=function(t,e){return function(r){return new b(e,!0).update(r)[t]()}},w=function(t){var e=y("hex",t);a&&(e=A(e,t)),e.create=function(){return new b(t)},e.update=function(t){return e.create().update(t)};for(var r=0;r<f.length;++r){var i=f[r];e[i]=y(i,t)}return e},A=function(t,i){var n,o=r(394),a=r(903).Buffer,c=i?"sha224":"sha256";return n=a.from&&!s.JS_SHA256_NO_BUFFER_FROM?a.from:function(t){return new a(t)},function(r){if("string"==typeof r)return o.createHash(c).update(r,"utf8").digest("hex");if(null==r)throw new Error(e);return r.constructor===ArrayBuffer&&(r=new Uint8Array(r)),Array.isArray(r)||ArrayBuffer.isView(r)||r.constructor===a?o.createHash(c).update(n(r)).digest("hex"):t(r)}},v=function(t,e){return function(r,i){return new I(r,e,!0).update(i)[t]()}},S=function(t){var e=v("hex",t);e.create=function(e){return new I(e,t)},e.update=function(t,r){return e.create(t).update(r)};for(var r=0;r<f.length;++r){var i=f[r];e[i]=v(i,t)}return e};function b(t,e){e?(m[0]=m[16]=m[1]=m[2]=m[3]=m[4]=m[5]=m[6]=m[7]=m[8]=m[9]=m[10]=m[11]=m[12]=m[13]=m[14]=m[15]=0,this.blocks=m):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t?(this.h0=3238371032,this.h1=914150663,this.h2=812702999,this.h3=4144912697,this.h4=4290775857,this.h5=1750603025,this.h6=1694076839,this.h7=3204075428):(this.h0=1779033703,this.h1=3144134277,this.h2=1013904242,this.h3=2773480762,this.h4=1359893119,this.h5=2600822924,this.h6=528734635,this.h7=1541459225),this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0,this.is224=t}function I(t,r,i){var n,s=typeof t;if("string"===s){var o,a=[],c=t.length,u=0;for(n=0;n<c;++n)(o=t.charCodeAt(n))<128?a[u++]=o:o<2048?(a[u++]=192|o>>>6,a[u++]=128|63&o):o<55296||o>=57344?(a[u++]=224|o>>>12,a[u++]=128|o>>>6&63,a[u++]=128|63&o):(o=65536+((1023&o)<<10|1023&t.charCodeAt(++n)),a[u++]=240|o>>>18,a[u++]=128|o>>>12&63,a[u++]=128|o>>>6&63,a[u++]=128|63&o);t=a}else{if("object"!==s)throw new Error(e);if(null===t)throw new Error(e);if(h&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!(Array.isArray(t)||h&&ArrayBuffer.isView(t)))throw new Error(e)}t.length>64&&(t=new b(r,!0).update(t).array());var p=[],d=[];for(n=0;n<64;++n){var g=t[n]||0;p[n]=92^g,d[n]=54^g}b.call(this,r,i),this.update(d),this.oKeyPad=p,this.inner=!0,this.sharedMemory=i}b.prototype.update=function(t){if(!this.finalized){var r,i=typeof t;if("string"!==i){if("object"!==i)throw new Error(e);if(null===t)throw new Error(e);if(h&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!(Array.isArray(t)||h&&ArrayBuffer.isView(t)))throw new Error(e);r=!0}for(var n,s,o=0,a=t.length,c=this.blocks;o<a;){if(this.hashed&&(this.hashed=!1,c[0]=this.block,this.block=c[16]=c[1]=c[2]=c[3]=c[4]=c[5]=c[6]=c[7]=c[8]=c[9]=c[10]=c[11]=c[12]=c[13]=c[14]=c[15]=0),r)for(s=this.start;o<a&&s<64;++o)c[s>>>2]|=t[o]<<g[3&s++];else for(s=this.start;o<a&&s<64;++o)(n=t.charCodeAt(o))<128?c[s>>>2]|=n<<g[3&s++]:n<2048?(c[s>>>2]|=(192|n>>>6)<<g[3&s++],c[s>>>2]|=(128|63&n)<<g[3&s++]):n<55296||n>=57344?(c[s>>>2]|=(224|n>>>12)<<g[3&s++],c[s>>>2]|=(128|n>>>6&63)<<g[3&s++],c[s>>>2]|=(128|63&n)<<g[3&s++]):(n=65536+((1023&n)<<10|1023&t.charCodeAt(++o)),c[s>>>2]|=(240|n>>>18)<<g[3&s++],c[s>>>2]|=(128|n>>>12&63)<<g[3&s++],c[s>>>2]|=(128|n>>>6&63)<<g[3&s++],c[s>>>2]|=(128|63&n)<<g[3&s++]);this.lastByteIndex=s,this.bytes+=s-this.start,s>=64?(this.block=c[16],this.start=s-64,this.hash(),this.hashed=!0):this.start=s}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296|0,this.bytes=this.bytes%4294967296),this}},b.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var t=this.blocks,e=this.lastByteIndex;t[16]=this.block,t[e>>>2]|=d[3&e],this.block=t[16],e>=56&&(this.hashed||this.hash(),t[0]=this.block,t[16]=t[1]=t[2]=t[3]=t[4]=t[5]=t[6]=t[7]=t[8]=t[9]=t[10]=t[11]=t[12]=t[13]=t[14]=t[15]=0),t[14]=this.hBytes<<3|this.bytes>>>29,t[15]=this.bytes<<3,this.hash()}},b.prototype.hash=function(){var t,e,r,i,n,s,o,a,c,u=this.h0,h=this.h1,p=this.h2,d=this.h3,g=this.h4,f=this.h5,m=this.h6,y=this.h7,w=this.blocks;for(t=16;t<64;++t)e=((n=w[t-15])>>>7|n<<25)^(n>>>18|n<<14)^n>>>3,r=((n=w[t-2])>>>17|n<<15)^(n>>>19|n<<13)^n>>>10,w[t]=w[t-16]+e+w[t-7]+r|0;for(c=h&p,t=0;t<64;t+=4)this.first?(this.is224?(s=300032,y=(n=w[0]-1413257819)-150054599|0,d=n+24177077|0):(s=704751109,y=(n=w[0]-210244248)-1521486534|0,d=n+143694565|0),this.first=!1):(e=(u>>>2|u<<30)^(u>>>13|u<<19)^(u>>>22|u<<10),i=(s=u&h)^u&p^c,y=d+(n=y+(r=(g>>>6|g<<26)^(g>>>11|g<<21)^(g>>>25|g<<7))+(g&f^~g&m)+l[t]+w[t])|0,d=n+(e+i)|0),e=(d>>>2|d<<30)^(d>>>13|d<<19)^(d>>>22|d<<10),i=(o=d&u)^d&h^s,m=p+(n=m+(r=(y>>>6|y<<26)^(y>>>11|y<<21)^(y>>>25|y<<7))+(y&g^~y&f)+l[t+1]+w[t+1])|0,e=((p=n+(e+i)|0)>>>2|p<<30)^(p>>>13|p<<19)^(p>>>22|p<<10),i=(a=p&d)^p&u^o,f=h+(n=f+(r=(m>>>6|m<<26)^(m>>>11|m<<21)^(m>>>25|m<<7))+(m&y^~m&g)+l[t+2]+w[t+2])|0,e=((h=n+(e+i)|0)>>>2|h<<30)^(h>>>13|h<<19)^(h>>>22|h<<10),i=(c=h&p)^h&d^a,g=u+(n=g+(r=(f>>>6|f<<26)^(f>>>11|f<<21)^(f>>>25|f<<7))+(f&m^~f&y)+l[t+3]+w[t+3])|0,u=n+(e+i)|0,this.chromeBugWorkAround=!0;this.h0=this.h0+u|0,this.h1=this.h1+h|0,this.h2=this.h2+p|0,this.h3=this.h3+d|0,this.h4=this.h4+g|0,this.h5=this.h5+f|0,this.h6=this.h6+m|0,this.h7=this.h7+y|0},b.prototype.hex=function(){this.finalize();var t=this.h0,e=this.h1,r=this.h2,i=this.h3,n=this.h4,s=this.h5,o=this.h6,a=this.h7,c=p[t>>>28&15]+p[t>>>24&15]+p[t>>>20&15]+p[t>>>16&15]+p[t>>>12&15]+p[t>>>8&15]+p[t>>>4&15]+p[15&t]+p[e>>>28&15]+p[e>>>24&15]+p[e>>>20&15]+p[e>>>16&15]+p[e>>>12&15]+p[e>>>8&15]+p[e>>>4&15]+p[15&e]+p[r>>>28&15]+p[r>>>24&15]+p[r>>>20&15]+p[r>>>16&15]+p[r>>>12&15]+p[r>>>8&15]+p[r>>>4&15]+p[15&r]+p[i>>>28&15]+p[i>>>24&15]+p[i>>>20&15]+p[i>>>16&15]+p[i>>>12&15]+p[i>>>8&15]+p[i>>>4&15]+p[15&i]+p[n>>>28&15]+p[n>>>24&15]+p[n>>>20&15]+p[n>>>16&15]+p[n>>>12&15]+p[n>>>8&15]+p[n>>>4&15]+p[15&n]+p[s>>>28&15]+p[s>>>24&15]+p[s>>>20&15]+p[s>>>16&15]+p[s>>>12&15]+p[s>>>8&15]+p[s>>>4&15]+p[15&s]+p[o>>>28&15]+p[o>>>24&15]+p[o>>>20&15]+p[o>>>16&15]+p[o>>>12&15]+p[o>>>8&15]+p[o>>>4&15]+p[15&o];return this.is224||(c+=p[a>>>28&15]+p[a>>>24&15]+p[a>>>20&15]+p[a>>>16&15]+p[a>>>12&15]+p[a>>>8&15]+p[a>>>4&15]+p[15&a]),c},b.prototype.toString=b.prototype.hex,b.prototype.digest=function(){this.finalize();var t=this.h0,e=this.h1,r=this.h2,i=this.h3,n=this.h4,s=this.h5,o=this.h6,a=this.h7,c=[t>>>24&255,t>>>16&255,t>>>8&255,255&t,e>>>24&255,e>>>16&255,e>>>8&255,255&e,r>>>24&255,r>>>16&255,r>>>8&255,255&r,i>>>24&255,i>>>16&255,i>>>8&255,255&i,n>>>24&255,n>>>16&255,n>>>8&255,255&n,s>>>24&255,s>>>16&255,s>>>8&255,255&s,o>>>24&255,o>>>16&255,o>>>8&255,255&o];return this.is224||c.push(a>>>24&255,a>>>16&255,a>>>8&255,255&a),c},b.prototype.array=b.prototype.digest,b.prototype.arrayBuffer=function(){this.finalize();var t=new ArrayBuffer(this.is224?28:32),e=new DataView(t);return e.setUint32(0,this.h0),e.setUint32(4,this.h1),e.setUint32(8,this.h2),e.setUint32(12,this.h3),e.setUint32(16,this.h4),e.setUint32(20,this.h5),e.setUint32(24,this.h6),this.is224||e.setUint32(28,this.h7),t},I.prototype=new b,I.prototype.finalize=function(){if(b.prototype.finalize.call(this),this.inner){this.inner=!1;var t=this.array();b.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(t),b.prototype.finalize.call(this)}};var P=w();P.sha256=P,P.sha224=w(!0),P.sha256.hmac=S(),P.sha224.hmac=S(!0),c?t.exports=P:(s.sha256=P.sha256,s.sha224=P.sha224,u&&(void 0===(i=function(){return P}.call(P,r,P,t))||(t.exports=i)))}()},903:()=>{},394:()=>{}},e={};function r(i){var n=e[i];if(void 0!==n)return n.exports;var s=e[i]={exports:{}};return t[i](s,s.exports,r),s.exports}r.amdO={},r.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return r.d(e,{a:e}),e},r.d=(t,e)=>{for(var i in e)r.o(e,i)&&!r.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),(()=>{"use strict";var t=r(396),e=r.n(t);const i={r:"v0.26.3"},n={"Europe/Vienna":"gdpr","Europe/Brussels":"gdpr","Europe/Sofia":"gdpr","Europe/Zagreb":"gdpr","Asia/Nicosia":"gdpr","Europe/Nicosia":"gdpr","Europe/Prague":"gdpr","Europe/Copenhagen":"gdpr","Europe/Tallinn":"gdpr","Europe/Helsinki":"gdpr","Europe/Paris":"gdpr","Europe/Berlin":"gdpr","Europe/Athens":"gdpr","Europe/Budapest":"gdpr","Atlantic/Reykjavik":"gdpr","Europe/Dublin":"gdpr","Europe/Rome":"gdpr","Europe/Riga":"gdpr","Europe/Vaduz":"gdpr","Europe/Vilnius":"gdpr","Europe/Luxembourg":"gdpr","Europe/Malta":"gdpr","Europe/Oslo":"gdpr","Europe/Warsaw":"gdpr","Europe/Lisbon":"gdpr","Europe/Bucharest":"gdpr","Europe/Bratislava":"gdpr","Europe/Ljubljana":"gdpr","Europe/Madrid":"gdpr","Europe/Stockholm":"gdpr","Europe/Amsterdam":"gdpr","Atlantic/Azores":"gdpr","Atlantic/Canary":"gdpr","America/Cayenne":"gdpr","America/Guadeloupe":"gdpr","Atlantic/Madeira":"gdpr","America/Martinique":"gdpr","Indian/Mayotte":"gdpr","Indian/Reunion":"gdpr","America/Marigot":"gdpr","Europe/Zurich":"gdpr","Europe/London":"gdpr","America/Toronto":"can","America/Adak":"us","America/Anchorage":"us","America/Atka":"us","America/Boise":"us","America/Chicago":"us","America/Denver":"us","America/Detroit":"us","America/Indiana/Indianapolis":"us","America/Indiana/Knox":"us","America/Indiana/Marengo":"us","America/Indiana/Petersburg":"us","America/Indiana/Tell_City":"us","America/Indiana/Vevay":"us","America/Indiana/Vincennes":"us","America/Indiana/Winamac":"us","America/Indianapolis":"us","America/Juneau":"us","America/Kentucky/Louisville":"us","America/Kentucky/Monticello":"us","America/Knox_IN":"us","America/Los_Angeles":"us","America/Louisville":"us","America/Menominee":"us","America/Metlakatla":"us","America/New_York":"us","America/Nome":"us","America/North_Dakota/Beulah":"us","America/North_Dakota/Center":"us","America/North_Dakota/New_Salem":"us","America/Phoenix":"us","America/Shiprock":"us","America/Sitka":"us","America/Yakutat":"us","Pacific/Honolulu":"us"},s="tcfcav1",o="tcfeuv2",a=[2],c=[5],u=[7,8,10,12,17,13,18,14,19,20,21,15,22,16,11,9];function h(t,e){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const i=function(t,e){const{gdprApplies:r,gppSectionIDs:i,gdprData:n}=e;if(void 0!==r)return r?"gdpr":"gdpr"===t?null:t;if(void 0!==n&&"gdpr"===t)return"gdpr";if(void 0===i||1===i.length&&0===i[0])return t;if(1===i.length&&-1===i[0])return null;if(i.some((t=>a.includes(t))))return"gdpr";if(i.some((t=>c.includes(t))))return"can";if(i.some((t=>u.includes(t))))return"us";switch(t){case"gdpr":if(!i.some((t=>a.includes(t))))return null;break;case"can":if(!i.some((t=>c.includes(t))))return null;break;case"us":if(!i.some((t=>u.includes(t))))return null}return t}(t,e),n={reg:i,gpp:e.gppString,gppSectionIDs:e.gppSectionIDs,gdpr:e.gdprString,gdprApplies:e.gdprApplies,deviceAccess:!1,createProfilesForAdvertising:!1,useProfilesForAdvertising:!1,measureAdvertisingPerformance:!1};switch(i){case"gdpr":e.gdprData?(n.deviceAccess=d(e.gdprData,1,r.tcfeuVendorID),n.createProfilesForAdvertising=d(e.gdprData,3,r.tcfeuVendorID),n.useProfilesForAdvertising=d(e.gdprData,4,r.tcfeuVendorID),n.measureAdvertisingPerformance=d(e.gdprData,7,r.tcfeuVendorID)):e.gppData&&(n.deviceAccess=l(e.gppData,1,r.tcfeuVendorID),n.createProfilesForAdvertising=l(e.gppData,3,r.tcfeuVendorID),n.useProfilesForAdvertising=l(e.gppData,4,r.tcfeuVendorID),n.measureAdvertisingPerformance=l(e.gppData,7,r.tcfeuVendorID));break;case"can":n.deviceAccess=!0,e.gppData&&(n.createProfilesForAdvertising=g(e.gppData,3,r.tcfcaVendorID),n.useProfilesForAdvertising=g(e.gppData,4,r.tcfcaVendorID),n.measureAdvertisingPerformance=g(e.gppData,7,r.tcfcaVendorID));break;default:n.deviceAccess=!0,n.createProfilesForAdvertising=!0,n.useProfilesForAdvertising=!0,n.measureAdvertisingPerformance=!0}return n}function p(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r={},i=h(t,r,e);return"function"==typeof window.__tcfapi&&window.__tcfapi?.("addEventListener",2,((n,s)=>{s&&("tcloaded"===n.eventStatus||"useractioncomplete"===n.eventStatus)&&(n=>{r.gdprString=n.tcString,r.gdprApplies=n.gdprApplies,r.gdprData=n,Object.assign(i,h(t,r,e))})(n)})),"function"==typeof window.__gpp&&window.__gpp?.("addEventListener",((n,s)=>{s&&"signalStatus"===n.eventName&&"ready"===n.data&&(n=>{r.gppString=n.gppString,r.gppSectionIDs=n.applicableSections,r.gppData=n,Object.assign(i,h(t,r,e))})(n.pingData)})),i}function d(t,e,r){return r?!!t.purpose?.consents?.[e]&&!!t.vendor?.consents?.[r]:!!t.publisher?.consents?.[e]}function g(t,e,r){const i=e>1,n=t.parsedSections?.[s]||[];if("number"==typeof r){const t=n.find((t=>"Version"in t));if(!t)return!1;let s=t.PurposesExpressConsent.includes(e)&&t.VendorExpressConsent.includes(r);return i&&(s||=t.PurposesImpliedConsent.includes(e)&&t.VendorImpliedConsent.includes(r)),s}const o=n.find((t=>"SubsectionType"in t&&3===t.SubsectionType));if(!o)return!1;let a=o.PubPurposesExpressConsent.includes(e);return i&&(a||=o.PubPurposesImpliedConsent.includes(e)),a}function l(t,e,r){const i=e>1,n=t.parsedSections?.[o]||[];if("number"==typeof r){const t=n.find((t=>"Version"in t));if(!t)return!1;let s=t.PurposeConsent.includes(e)&&t.VendorConsent.includes(r);return i&&(s||=t.PurposesLITransparency.includes(e)&&t.VendorLegitimateInterest.includes(r)),s}const s=n.find((t=>"SegmentType"in t&&3===t.SegmentType));if(!s)return!1;let a=s.PubPurposesConsent.includes(e);return i&&(a||=s.PubPurposesLITransparency.includes(e)),a}const f={cookies:!0,initPassport:!0,consent:{reg:null,deviceAccess:!0,createProfilesForAdvertising:!0,useProfilesForAdvertising:!0,measureAdvertisingPerformance:!0}};async function m(t){const e=await A("/config",t,{method:"GET",headers:{Accept:"application/json"}});return new w(t).setSite(e),e}class y{constructor(t){e()(this,"consent",void 0),this.consent=t}getItem(t){return this.consent.deviceAccess?window.localStorage.getItem(t):null}setItem(t,e){this.consent.deviceAccess&&window.localStorage.setItem(t,e)}removeItem(t){this.consent.deviceAccess&&window.localStorage.removeItem(t)}}class w{constructor(t){this.config=t,e()(this,"passportKey",void 0),e()(this,"targetingV1Key",void 0),e()(this,"targetingKey",void 0),e()(this,"siteKey",void 0),e()(this,"storage",void 0);const r=btoa(function(t){const e=new Uint16Array(t.length);for(let r=0;r<e.length;r++)e[r]=t.charCodeAt(r);return String.fromCharCode(...new Uint8Array(e.buffer))}(`${this.config.host}/${this.config.site}`));this.targetingV1Key="OPTABLE_TGT_"+r,this.passportKey="OPTABLE_PASS_"+r,this.targetingKey="OPTABLE_V2_TGT_"+r,this.siteKey="OPTABLE_SITE_"+r,this.storage=new y(this.config.consent)}getPassport(){return this.storage.getItem(this.passportKey)}getV1Targeting(){const t=this.storage.getItem(this.targetingV1Key),e=t?JSON.parse(t):null;return e?{user:[],audience:Object.entries(e).map((t=>{let[e,r]=t;return{provider:"optable.co",keyspace:e,rtb_segtax:5001,ids:[].concat(r).map((t=>({id:String(t)})))}}))}:null}getTargeting(){const t=this.storage.getItem(this.targetingKey);return(t?JSON.parse(t):null)||this.getV1Targeting()}setPassport(t){t&&t.length>0&&this.storage.setItem(this.passportKey,t)}setTargeting(t){t&&this.storage.setItem(this.targetingKey,JSON.stringify(t))}setSite(t){t&&this.storage.setItem(this.siteKey,JSON.stringify(t))}getSite(){const t=this.storage.getItem(this.siteKey);return t?JSON.parse(t):null}clearPassport(){this.storage.removeItem(this.passportKey)}clearTargeting(){this.storage.removeItem(this.targetingKey)}clearSite(){this.storage.removeItem(this.siteKey)}}async function A(t,e,r){const n=await globalThis.fetch(function(t,e,r){const{site:n,host:s,cookies:o}=e,a=new URL(`${n}${t}`,`https://${s}`);if(a.searchParams.set("osdk",`web-${i.r}`),void 0!==e.consent.gpp&&a.searchParams.set("gpp",e.consent.gpp),void 0!==e.consent.gppSectionIDs&&a.searchParams.set("gpp_sid",e.consent.gppSectionIDs.join(",")),void 0!==e.consent.gdpr&&a.searchParams.set("gdpr_consent",e.consent.gdpr),void 0!==e.consent.gdprApplies&&a.searchParams.set("gdpr",Number(e.consent.gdprApplies).toString()),o)a.searchParams.set("cookies","yes");else{const t=new w(e).getPassport();a.searchParams.set("cookies","no"),a.searchParams.set("passport",t||"")}const c={...r};return c.credentials="include",new Request(a.toString(),c)}(t,e,r)),s=n.headers.get("Content-Type"),o=s?.startsWith("application/json")?await n.json():await n.text();if(!n.ok)throw new Error(o.error);return o.passport&&(new w(e).setPassport(o.passport),delete o.passport),o}var v;function S(t){return{user:{data:(t?.audience??[]).map((t=>({name:t.provider,segment:t.ids,ext:{segtax:t.rtb_segtax}}))),ext:{eids:(t?.user??[]).map((t=>({source:t.provider,uids:t.ids.map((t=>{let{id:e}=t;return{id:e,atype:v.PersonID}}))})))}}}}function b(t){const e={};if(!t)return e;for(const r of t.audience??[])r.keyspace&&(r.keyspace in e||(e[r.keyspace]=[]),e[r.keyspace].push(...r.ids.map((t=>t.id))));return e}!function(t){t[t.DeviceID=1]="DeviceID",t[t.InAppImpression=2]="InAppImpression",t[t.PersonID=3]="PersonID"}(v||(v={}));var I=r(312);class P{constructor(t){e()(this,"dcn",void 0),e()(this,"init",void 0),this.dcn=function(t){const e={host:t.host,site:t.site,cookies:t.cookies??f.cookies,initPassport:t.initPassport??f.initPassport,consent:f.consent};return t.consent?.static?e.consent=t.consent.static:t.consent?.cmpapi&&(e.consent=p(function(){const t=Intl.DateTimeFormat().resolvedOptions().timeZone,e=n[t];return"can"===e?["fr","fr-CA"].some((t=>navigator.languages.includes(t)))?"can":null:e??null}(),t.consent.cmpapi)),e}(t);const r=()=>{};this.init=this.dcn.initPassport?m(this.dcn).then(r).catch(r):Promise.resolve()}async identify(){await this.init;for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return function(t,e){return A("/identify",t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}(this.dcn,e.filter((t=>t)))}async uid2Token(t){return await this.init,function(t,e){return A("/uid2/token",t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}(this.dcn,t)}async targeting(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"__passport__";return await this.init,async function(t,e){const r="/v2/targeting?"+new URLSearchParams({id:e}).toString(),i=await A(r,t,{method:"GET",headers:{Accept:"application/json"}});return i&&new w(t).setTargeting(i),i}(this.dcn,t)}targetingFromCache(){return t=this.dcn,new w(t).getTargeting();var t}async site(){return m(this.dcn)}siteFromCache(){return t=this.dcn,new w(t).getSite();var t}targetingClearCache(){var t;t=this.dcn,new w(t).clearTargeting()}async prebidORTB2(){return S(await this.targeting())}prebidORTB2FromCache(){return S(this.targetingFromCache())}async targetingKeyValues(){return b(await this.targeting())}targetingKeyValuesFromCache(){return b(this.targetingFromCache())}async witness(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return await this.init,function(t,e,r){const i={event:e,properties:r};return A("/witness",t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)})}(this.dcn,t,e)}async profile(t){return await this.init,function(t,e){const r={traits:e};return A("/profile",t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)})}(this.dcn,t)}async tokenize(t){return await this.init,function(t,e){let r={id:e};return A("/v1/tokenize",t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)})}(this.dcn,t)}async resolve(t){return await this.init,async function(t,e){const r=new URLSearchParams;"string"==typeof e&&r.append("id",e);const i="/v1/resolve?"+r.toString();return function(t){const e={clusters:[],lmpid:""};if("object"!=typeof t||null===t)return e;if("lmpid"in t&&"string"==typeof t?.lmpid&&(e.lmpid=t.lmpid),!("clusters"in t)||!Array.isArray(t?.clusters))return e;for(const r of t.clusters){const t={ids:[],traits:[]};if(Array.isArray(r?.ids))for(const e of r.ids)"string"==typeof e&&t.ids.push(e);if(Array.isArray(r?.traits))for(const e of r.traits)"string"==typeof e?.key&&"string"==typeof e?.value&&t.traits.push({key:e.key,value:e.value});(t.ids.length>0||t.traits.length>0)&&e.clusters.push(t)}return e}(await A(i,t,{method:"GET",headers:{Accept:"application/json"}}))}(this.dcn,t)}static eid(t){return t?"e:"+I.sha256.hex(t.toLowerCase().trim()):""}static sha256(t){return t?I.sha256.hex(t):""}static cid(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r="c:";if("string"!=typeof t)throw new Error("Invalid ppid");if("number"!=typeof e||isNaN(e)||e<0||e>9)throw new Error("Invalid variant");return e>0&&(r=`c${e}:`),t?r+t.trim():""}static TargetingKeyValues(t){return b(t)}static PrebidORTB2(t){return S(t)}}e()(P,"version",i.r);const E=P;function _(t){return{advertiserId:t.advertiserId?.toString(),campaignId:t.campaignId?.toString(),creativeId:t.creativeId?.toString(),isEmpty:t.isEmpty?.toString(),lineItemId:t.lineItemId?.toString(),serviceName:t.serviceName?.toString(),size:t.size?.toString(),slotElementId:t.slot?.getSlotElementId(),sourceAgnosticCreativeId:t.sourceAgnosticCreativeId?.toString(),sourceAgnosticLineItemId:t.sourceAgnosticLineItemId?.toString()}}E.prototype.installGPTEventListeners=function(){const t=this;t.installGPTEventListeners=function(){},window.googletag=window.googletag||{cmd:[]};const e=window.googletag;e.cmd.push((function(){e.pubads().addEventListener("slotRenderEnded",(function(e){t.witness("googletag.events.slotRenderEnded",_(e))})),e.pubads().addEventListener("impressionViewable",(function(e){t.witness("googletag.events.impressionViewable",_(e))}))}))},E.prototype.installGPTSecureSignals=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];window.googletag=window.googletag||{cmd:[]};const i=window.googletag;e&&e.length>0&&i.cmd.push((()=>{e.forEach((t=>{let{provider:e,id:r}=t;i.secureSignalProviders.push({id:e,collectorFunction:()=>Promise.resolve(r)})}))}))};const C=/^[a-f0-9]{64}$/i;E.prototype.tryIdentifyFromParams=function(t,e){const r=new RegExp(`^${t||"oeid"}$`,"i"),i=new URLSearchParams(window.location.search);let n="";for(const[t,e]of i)if(r.test(t)){n=e;break}""!=n&&(e||function(t){return C.test(t)}(n))&&this.identify((e||"e")+":"+n.toLowerCase())},E.prototype.auctionConfigFromCache=function(){const t=this.siteFromCache();return t?t.auctionConfig??null:null},E.prototype.installGPTAuctionConfigs=function(t){const e=this;e.installGPTAuctionConfigs=function(){},window.googletag=window.googletag||{cmd:[]};const r=window.googletag;r.cmd.push((function(){let i=r.pubads().getSlots();t&&(i=i.filter(t));const n=e.auctionConfigFromCache();if(n)for(const t of i){const e=t.getSizes(),r=[];for(const t of e)"fluid"!==t&&r.push({configKey:n.seller+"-"+t.getWidth()+"x"+t.getHeight(),auctionConfig:{...n,requestedSize:{width:t.getWidth()+"px",height:t.getHeight()+"px"}}});t.setConfig({componentAuction:r})}}))},E.prototype.runAdAuction=async function(t,e){if(!("runAdAuction"in navigator))throw"run-ad-auction not supported";const r=document.getElementById(t);if(!r)throw"spot not found";const i=function(t){const e=window.getComputedStyle(t,null);return{width:e.getPropertyValue("width"),height:e.getPropertyValue("height")}}(r),n=this.auctionConfigFromCache();if(!n)return!1;const s={...n,requestedSize:i,resolveToConfig:!0},o=e?.iframe??!1;o&&(s.resolveToConfig=!1);const a=await navigator.runAdAuction(s);if(!a)return r.replaceChildren(),!1;if(o){const t=document.createElement("iframe");t.src=a,t.style.border="none",t.style.width=i.width,t.style.height=i.height,r.replaceChildren(t)}else{const t=document.createElement("fencedframe");t.config=a,t.style.border="none",r.replaceChildren(t)}return!0},E.prototype.joinAdInterestGroups=async function(){if(!("joinAdInterestGroup"in navigator))throw"join-ad-interest-group not supported";if(!(this.dcn.consent.deviceAccess&&this.dcn.consent.createProfilesForAdvertising&&this.dcn.consent.measureAdvertisingPerformance))throw"consent not granted for joining interest groups";const t=await this.site();if(!t.interestGroupPixel)throw"origin not enabled for protected audience apis";const e=new URL(t.interestGroupPixel),r=document.createElement("iframe");r.src=e.toString(),r.allow="join-ad-interest-group "+e.origin,r.style.display="none";const i=new Promise(((t,e)=>{window.addEventListener("message",(i=>{i.source===r.contentWindow&&("success"!==i.data.result?e():t())}))}));return document.body.appendChild(r),i},E.prototype.getTopics=async function(){if(!("browsingTopics"in document))throw"browsing-topics not supported";if(!this.dcn.consent.deviceAccess)throw"consent not granted for reading browsing topics";const t=await this.site();if(!t.getTopicsURL)throw"origin not enabled for topics api";const e=new URL(t.getTopicsURL),r=document.createElement("iframe");r.src=e.toString(),r.allow="browsing-topics "+e.origin,r.style.display="none";const i=new Promise(((t,e)=>{window.addEventListener("message",(i=>{i.source===r.contentWindow&&(i.data.error?e(new Error(i.data.error.toString())):t(i.data.result))}))}));return document.body.appendChild(r),i},E.prototype.ingestTopics=function(){this.getTopics().then((t=>{if(!t.length)return;const e=t.reduce(((t,e)=>{const r=`topics_v${e.taxonomyVersion}`;return t[r]?t[r]+=",":t[r]="",t[r]+=String(e.topic),t}),{});this.profile(e)})).catch((()=>{}))},window.optable=window.optable||{},window.optable.SDK=E,window.optable.cmd=new class{constructor(t){if(this.cmds=t,Array.isArray(this.cmds))for(const t of this.cmds)"function"==typeof t&&t()}push(t){t()}}(window.optable.cmd||[])})()})();
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": "v0.26.1"
2
+ "version": "v0.26.3"
3
3
  }
@@ -13,17 +13,17 @@ function buildRequest(path, config, init) {
13
13
  const { site, host, cookies } = config;
14
14
  const url = new URL(`${site}${path}`, `https://${host}`);
15
15
  url.searchParams.set("osdk", `web-${buildInfo.version}`);
16
- if (config.consent.reg) {
17
- url.searchParams.set("reg", config.consent.reg);
18
- }
19
- if (config.consent.gpp) {
16
+ if (typeof config.consent.gpp !== "undefined") {
20
17
  url.searchParams.set("gpp", config.consent.gpp);
21
18
  }
22
- if (config.consent.gppSectionIDs) {
19
+ if (typeof config.consent.gppSectionIDs !== "undefined") {
23
20
  url.searchParams.set("gpp_sid", config.consent.gppSectionIDs.join(","));
24
21
  }
25
- if (config.consent.tcf) {
26
- url.searchParams.set("tcf", config.consent.tcf);
22
+ if (typeof config.consent.gdpr !== "undefined") {
23
+ url.searchParams.set("gdpr_consent", config.consent.gdpr);
24
+ }
25
+ if (typeof config.consent.gdprApplies !== "undefined") {
26
+ url.searchParams.set("gdpr", Number(config.consent.gdprApplies).toString());
27
27
  }
28
28
  if (cookies) {
29
29
  url.searchParams.set("cookies", "yes");
@@ -1,5 +1,7 @@
1
1
  import type { Regulation } from "./regulations";
2
2
  import { inferRegulation } from "./regulations";
3
+ import * as gpp from "./gpp";
4
+ import * as tcf from "./tcf";
3
5
  type CMPApiConfig = {
4
6
  tcfeuVendorID?: number;
5
7
  tcfcaVendorID?: number;
@@ -10,10 +12,20 @@ type Consent = {
10
12
  useProfilesForAdvertising: boolean;
11
13
  measureAdvertisingPerformance: boolean;
12
14
  reg: Regulation | null;
13
- tcf?: string;
15
+ gdpr?: string;
16
+ gdprApplies?: boolean;
14
17
  gpp?: string;
15
18
  gppSectionIDs?: number[];
16
19
  };
17
- declare function getConsent(reg: Regulation | null, conf?: CMPApiConfig): Consent;
18
- export { getConsent, inferRegulation };
20
+ type CMPSignals = {
21
+ gdprString?: string;
22
+ gdprApplies?: boolean;
23
+ gdprData?: tcf.cmpapi.TCData;
24
+ gppString?: string;
25
+ gppSectionIDs?: number[];
26
+ gppData?: gpp.cmpapi.PingReturn;
27
+ };
28
+ declare function applicableReg(defaultReg: Regulation | null, cmp: CMPSignals): Regulation | null;
29
+ declare function getConsent(defaultReg: Regulation | null, conf?: CMPApiConfig): Consent;
30
+ export { getConsent, inferRegulation, applicableReg };
19
31
  export type { Consent, CMPApiConfig };
@@ -1,46 +1,95 @@
1
1
  import { inferRegulation } from "./regulations";
2
2
  import * as gpp from "./gpp";
3
- function getConsent(reg, conf = {}) {
3
+ function applicableReg(defaultReg, cmp) {
4
+ const { gdprApplies, gppSectionIDs, gdprData } = cmp;
5
+ // Handle TCF signaling (preferred over GPP)
6
+ if (typeof gdprApplies !== "undefined") {
7
+ if (gdprApplies) {
8
+ return "gdpr";
9
+ }
10
+ // Override with unknown regulation if CMP indicates gdpr doesn't apply
11
+ return defaultReg === "gdpr" ? null : defaultReg;
12
+ }
13
+ // gdprApplies is optional, so gdprData presence is necessary
14
+ if (typeof gdprData !== "undefined" && defaultReg === "gdpr") {
15
+ return "gdpr";
16
+ }
17
+ // Handle GPP signaling
18
+ //
19
+ // Unknown regulation signal
20
+ if (typeof gppSectionIDs === "undefined" || (gppSectionIDs.length === 1 && gppSectionIDs[0] === 0)) {
21
+ return defaultReg;
22
+ }
23
+ // No applicable regulation
24
+ if (gppSectionIDs.length === 1 && gppSectionIDs[0] === -1) {
25
+ return null;
26
+ }
27
+ // GDPR > CAN > US
28
+ if (gppSectionIDs.some((sid) => gpp.euSectionIDs.includes(sid))) {
29
+ return "gdpr";
30
+ }
31
+ if (gppSectionIDs.some((sid) => gpp.caSectionIDs.includes(sid))) {
32
+ return "can";
33
+ }
34
+ if (gppSectionIDs.some((sid) => gpp.usSectionIDs.includes(sid))) {
35
+ return "us";
36
+ }
37
+ // Override with unknown regulation if CMP indicates the detected
38
+ // regulation doesn't apply
39
+ switch (defaultReg) {
40
+ case "gdpr":
41
+ if (!gppSectionIDs.some((sid) => gpp.euSectionIDs.includes(sid))) {
42
+ return null;
43
+ }
44
+ break;
45
+ case "can":
46
+ if (!gppSectionIDs.some((sid) => gpp.caSectionIDs.includes(sid))) {
47
+ return null;
48
+ }
49
+ break;
50
+ case "us":
51
+ if (!gppSectionIDs.some((sid) => gpp.usSectionIDs.includes(sid))) {
52
+ return null;
53
+ }
54
+ break;
55
+ }
56
+ return defaultReg;
57
+ }
58
+ function computeConsent(defaultReg, cmp, conf = {}) {
59
+ const reg = applicableReg(defaultReg, cmp);
4
60
  const consent = {
5
61
  reg,
62
+ gpp: cmp.gppString,
63
+ gppSectionIDs: cmp.gppSectionIDs,
64
+ gdpr: cmp.gdprString,
65
+ gdprApplies: cmp.gdprApplies,
6
66
  deviceAccess: false,
7
67
  createProfilesForAdvertising: false,
8
68
  useProfilesForAdvertising: false,
9
69
  measureAdvertisingPerformance: false,
10
70
  };
11
- onGPPChange((data) => {
12
- consent.gpp = data.gppString;
13
- consent.gppSectionIDs = data.applicableSections;
14
- });
15
- onTCFChange((data) => {
16
- consent.tcf = data.gdprApplies ? data.tcString : undefined;
17
- });
18
71
  switch (reg) {
19
72
  case "gdpr":
20
- if (hasTCF()) {
21
- onTCFChange((data) => {
22
- consent.deviceAccess = tcfPurpose(data, 1, conf.tcfeuVendorID);
23
- consent.createProfilesForAdvertising = tcfPurpose(data, 3, conf.tcfeuVendorID);
24
- consent.useProfilesForAdvertising = tcfPurpose(data, 4, conf.tcfeuVendorID);
25
- consent.measureAdvertisingPerformance = tcfPurpose(data, 7, conf.tcfeuVendorID);
26
- });
73
+ if (cmp.gdprData) {
74
+ consent.deviceAccess = tcfPurpose(cmp.gdprData, 1, conf.tcfeuVendorID);
75
+ consent.createProfilesForAdvertising = tcfPurpose(cmp.gdprData, 3, conf.tcfeuVendorID);
76
+ consent.useProfilesForAdvertising = tcfPurpose(cmp.gdprData, 4, conf.tcfeuVendorID);
77
+ consent.measureAdvertisingPerformance = tcfPurpose(cmp.gdprData, 7, conf.tcfeuVendorID);
27
78
  }
28
- else if (hasGPP()) {
29
- onGPPChange((data) => {
30
- consent.deviceAccess = gppEuPurpose(data, 1, conf.tcfeuVendorID);
31
- consent.createProfilesForAdvertising = gppEuPurpose(data, 3, conf.tcfeuVendorID);
32
- consent.useProfilesForAdvertising = gppEuPurpose(data, 4, conf.tcfeuVendorID);
33
- consent.measureAdvertisingPerformance = gppEuPurpose(data, 7, conf.tcfeuVendorID);
34
- });
79
+ else if (cmp.gppData) {
80
+ consent.deviceAccess = gppEuPurpose(cmp.gppData, 1, conf.tcfeuVendorID);
81
+ consent.createProfilesForAdvertising = gppEuPurpose(cmp.gppData, 3, conf.tcfeuVendorID);
82
+ consent.useProfilesForAdvertising = gppEuPurpose(cmp.gppData, 4, conf.tcfeuVendorID);
83
+ consent.measureAdvertisingPerformance = gppEuPurpose(cmp.gppData, 7, conf.tcfeuVendorID);
35
84
  }
36
85
  break;
37
86
  case "can":
38
87
  consent.deviceAccess = true;
39
- onGPPChange((data) => {
40
- consent.createProfilesForAdvertising = gppCanPurpose(data, 3, conf.tcfcaVendorID);
41
- consent.useProfilesForAdvertising = gppCanPurpose(data, 4, conf.tcfcaVendorID);
42
- consent.measureAdvertisingPerformance = gppCanPurpose(data, 7, conf.tcfcaVendorID);
43
- });
88
+ if (cmp.gppData) {
89
+ consent.createProfilesForAdvertising = gppCanPurpose(cmp.gppData, 3, conf.tcfcaVendorID);
90
+ consent.useProfilesForAdvertising = gppCanPurpose(cmp.gppData, 4, conf.tcfcaVendorID);
91
+ consent.measureAdvertisingPerformance = gppCanPurpose(cmp.gppData, 7, conf.tcfcaVendorID);
92
+ }
44
93
  break;
45
94
  case "us":
46
95
  default:
@@ -51,21 +100,34 @@ function getConsent(reg, conf = {}) {
51
100
  }
52
101
  return consent;
53
102
  }
103
+ function getConsent(defaultReg, conf = {}) {
104
+ const cmp = {};
105
+ const consent = computeConsent(defaultReg, cmp, conf);
106
+ onTCFChange((data) => {
107
+ cmp.gdprString = data.tcString;
108
+ cmp.gdprApplies = data.gdprApplies;
109
+ cmp.gdprData = data;
110
+ Object.assign(consent, computeConsent(defaultReg, cmp, conf));
111
+ });
112
+ onGPPChange((data) => {
113
+ cmp.gppString = data.gppString;
114
+ cmp.gppSectionIDs = data.applicableSections;
115
+ cmp.gppData = data;
116
+ Object.assign(consent, computeConsent(defaultReg, cmp, conf));
117
+ });
118
+ return consent;
119
+ }
54
120
  function tcfPurpose(data, purpose, vendorID) {
55
- if (!data.gdprApplies) {
56
- return true;
57
- }
121
+ var _a, _b, _c, _d, _e, _f;
58
122
  if (vendorID) {
59
- return data.purpose.consents[purpose] && data.vendor.consents[vendorID];
123
+ return !!((_b = (_a = data.purpose) === null || _a === void 0 ? void 0 : _a.consents) === null || _b === void 0 ? void 0 : _b[purpose]) && !!((_d = (_c = data.vendor) === null || _c === void 0 ? void 0 : _c.consents) === null || _d === void 0 ? void 0 : _d[vendorID]);
60
124
  }
61
- return !!data.publisher.consents[purpose];
125
+ return !!((_f = (_e = data.publisher) === null || _e === void 0 ? void 0 : _e.consents) === null || _f === void 0 ? void 0 : _f[purpose]);
62
126
  }
63
127
  function gppCanPurpose(data, purpose, vendorID) {
64
- if (!data.applicableSections.includes(gpp.tcfcav1.SectionID)) {
65
- return true;
66
- }
128
+ var _a;
67
129
  const includeImplied = purpose > 1;
68
- const section = data.parsedSections[gpp.tcfcav1.APIPrefix] || [];
130
+ const section = ((_a = data.parsedSections) === null || _a === void 0 ? void 0 : _a[gpp.tcfcav1.APIPrefix]) || [];
69
131
  if (typeof vendorID === "number") {
70
132
  const coreSegment = section.find((s) => "Version" in s);
71
133
  if (!coreSegment) {
@@ -88,11 +150,9 @@ function gppCanPurpose(data, purpose, vendorID) {
88
150
  return granted;
89
151
  }
90
152
  function gppEuPurpose(data, purpose, vendorID) {
91
- if (!data.applicableSections.includes(gpp.tcfeuv2.SectionID)) {
92
- return true;
93
- }
153
+ var _a;
94
154
  const includeLegitimateInterest = purpose > 1;
95
- const section = data.parsedSections[gpp.tcfeuv2.APIPrefix] || [];
155
+ const section = ((_a = data.parsedSections) === null || _a === void 0 ? void 0 : _a[gpp.tcfeuv2.APIPrefix]) || [];
96
156
  if (typeof vendorID === "number") {
97
157
  const coreSegment = section.find((s) => "Version" in s);
98
158
  if (!coreSegment) {
@@ -152,4 +212,4 @@ function hasGPP() {
152
212
  function hasTCF() {
153
213
  return typeof window.__tcfapi === "function";
154
214
  }
155
- export { getConsent, inferRegulation };
215
+ export { getConsent, inferRegulation, applicableReg };
@@ -34,7 +34,7 @@ type PingReturn = {
34
34
  sectionList: number[];
35
35
  applicableSections: number[];
36
36
  gppString: string;
37
- parsedSections: ParsedSections;
37
+ parsedSections?: ParsedSections;
38
38
  };
39
39
  type AddEventListener = {
40
40
  eventName: string;
@@ -1,18 +1,22 @@
1
- export * as tcfcav1 from "./tcfcav1";
2
- export * as tcfeuv2 from "./tcfeuv2";
3
- export * as usnat from "./usnat";
4
- export * as usca from "./usca";
5
- export * as usco from "./usco";
6
- export * as usct from "./usct";
7
- export * as usde from "./usde";
8
- export * as usfl from "./usfl";
9
- export * as usia from "./usia";
10
- export * as usmt from "./usmt";
11
- export * as usne from "./usne";
12
- export * as usnh from "./usnh";
13
- export * as usnj from "./usnj";
14
- export * as usor from "./usor";
15
- export * as ustn from "./ustn";
16
- export * as ustx from "./ustx";
17
- export * as usut from "./usut";
18
- export * as usva from "./usva";
1
+ import * as tcfcav1 from "./tcfcav1";
2
+ import * as tcfeuv2 from "./tcfeuv2";
3
+ import * as usnat from "./usnat";
4
+ import * as usca from "./usca";
5
+ import * as usco from "./usco";
6
+ import * as usct from "./usct";
7
+ import * as usde from "./usde";
8
+ import * as usfl from "./usfl";
9
+ import * as usia from "./usia";
10
+ import * as usmt from "./usmt";
11
+ import * as usne from "./usne";
12
+ import * as usnh from "./usnh";
13
+ import * as usnj from "./usnj";
14
+ import * as usor from "./usor";
15
+ import * as ustn from "./ustn";
16
+ import * as ustx from "./ustx";
17
+ import * as usut from "./usut";
18
+ import * as usva from "./usva";
19
+ export declare const euSectionIDs: number[];
20
+ export declare const caSectionIDs: number[];
21
+ export declare const usSectionIDs: number[];
22
+ export { tcfcav1, tcfeuv2, usnat, usca, usco, usct, usde, usfl, usia, usmt, usne, usnh, usnj, usor, ustn, ustx, usut, usva, };
@@ -1,18 +1,39 @@
1
- export * as tcfcav1 from "./tcfcav1";
2
- export * as tcfeuv2 from "./tcfeuv2";
3
- export * as usnat from "./usnat";
4
- export * as usca from "./usca";
5
- export * as usco from "./usco";
6
- export * as usct from "./usct";
7
- export * as usde from "./usde";
8
- export * as usfl from "./usfl";
9
- export * as usia from "./usia";
10
- export * as usmt from "./usmt";
11
- export * as usne from "./usne";
12
- export * as usnh from "./usnh";
13
- export * as usnj from "./usnj";
14
- export * as usor from "./usor";
15
- export * as ustn from "./ustn";
16
- export * as ustx from "./ustx";
17
- export * as usut from "./usut";
18
- export * as usva from "./usva";
1
+ import * as tcfcav1 from "./tcfcav1";
2
+ import * as tcfeuv2 from "./tcfeuv2";
3
+ import * as usnat from "./usnat";
4
+ import * as usca from "./usca";
5
+ import * as usco from "./usco";
6
+ import * as usct from "./usct";
7
+ import * as usde from "./usde";
8
+ import * as usfl from "./usfl";
9
+ import * as usia from "./usia";
10
+ import * as usmt from "./usmt";
11
+ import * as usne from "./usne";
12
+ import * as usnh from "./usnh";
13
+ import * as usnj from "./usnj";
14
+ import * as usor from "./usor";
15
+ import * as ustn from "./ustn";
16
+ import * as ustx from "./ustx";
17
+ import * as usut from "./usut";
18
+ import * as usva from "./usva";
19
+ export const euSectionIDs = [tcfeuv2.SectionID];
20
+ export const caSectionIDs = [tcfcav1.SectionID];
21
+ export const usSectionIDs = [
22
+ usnat.SectionID,
23
+ usca.SectionID,
24
+ usco.SectionID,
25
+ usct.SectionID,
26
+ usde.SectionID,
27
+ usfl.SectionID,
28
+ usia.SectionID,
29
+ usmt.SectionID,
30
+ usne.SectionID,
31
+ usnh.SectionID,
32
+ usnj.SectionID,
33
+ usor.SectionID,
34
+ ustn.SectionID,
35
+ ustx.SectionID,
36
+ usut.SectionID,
37
+ usva.SectionID,
38
+ ];
39
+ export { tcfcav1, tcfeuv2, usnat, usca, usco, usct, usde, usfl, usia, usmt, usne, usnh, usnj, usor, ustn, ustx, usut, usva, };
@@ -1,57 +1,125 @@
1
1
  const zones = {
2
- // EU
3
- "Europe/Amsterdam": "gdpr",
4
- "Europe/Athens": "gdpr",
5
- "Europe/Berlin": "gdpr",
2
+ // GDPR: EEA
3
+ // Austria
4
+ "Europe/Vienna": "gdpr",
5
+ // Belgium
6
6
  "Europe/Brussels": "gdpr",
7
- "Europe/Bucharest": "gdpr",
8
- "Europe/Budapest": "gdpr",
7
+ // Bulgaria
8
+ "Europe/Sofia": "gdpr",
9
+ // Croatia
10
+ "Europe/Zagreb": "gdpr",
11
+ // Cyprus
12
+ "Asia/Nicosia": "gdpr",
13
+ "Europe/Nicosia": "gdpr",
14
+ // Czech Republic
15
+ "Europe/Prague": "gdpr",
16
+ // Denmark
9
17
  "Europe/Copenhagen": "gdpr",
10
- "Europe/Dublin": "gdpr",
18
+ // Estonia
19
+ "Europe/Tallinn": "gdpr",
20
+ // Finland
11
21
  "Europe/Helsinki": "gdpr",
12
- "Europe/Lisbon": "gdpr",
13
- "Europe/London": "gdpr",
14
- "Europe/Madrid": "gdpr",
15
- "Europe/Oslo": "gdpr",
22
+ // France
16
23
  "Europe/Paris": "gdpr",
17
- "Europe/Prague": "gdpr",
24
+ // Germany
25
+ "Europe/Berlin": "gdpr",
26
+ // Greece
27
+ "Europe/Athens": "gdpr",
28
+ // Hungary
29
+ "Europe/Budapest": "gdpr",
30
+ // Iceland
31
+ "Atlantic/Reykjavik": "gdpr",
32
+ // Ireland
33
+ "Europe/Dublin": "gdpr",
34
+ // Italy
18
35
  "Europe/Rome": "gdpr",
19
- "Europe/Sofia": "gdpr",
20
- "Europe/Stockholm": "gdpr",
21
- "Europe/Vienna": "gdpr",
36
+ // Latvia
37
+ "Europe/Riga": "gdpr",
38
+ // Liechtenstein
39
+ "Europe/Vaduz": "gdpr",
40
+ // Lithuania
41
+ "Europe/Vilnius": "gdpr",
42
+ // Luxembourg
43
+ "Europe/Luxembourg": "gdpr",
44
+ // Malta
45
+ "Europe/Malta": "gdpr",
46
+ // Norway
47
+ "Europe/Oslo": "gdpr",
48
+ // Poland
22
49
  "Europe/Warsaw": "gdpr",
50
+ // Portugal
51
+ "Europe/Lisbon": "gdpr",
52
+ // Romania
53
+ "Europe/Bucharest": "gdpr",
54
+ // Slovakia
55
+ "Europe/Bratislava": "gdpr",
56
+ // Slovenia
57
+ "Europe/Ljubljana": "gdpr",
58
+ // Spain
59
+ "Europe/Madrid": "gdpr",
60
+ // Sweden
61
+ "Europe/Stockholm": "gdpr",
62
+ // The Netherlands
63
+ "Europe/Amsterdam": "gdpr",
64
+ // GDPR: Outside EEA
65
+ // Azores
66
+ "Atlantic/Azores": "gdpr",
67
+ // Canary Islands
68
+ "Atlantic/Canary": "gdpr",
69
+ // French Guiana
70
+ "America/Cayenne": "gdpr",
71
+ // Guadeloupe
72
+ "America/Guadeloupe": "gdpr",
73
+ // Madeira
74
+ "Atlantic/Madeira": "gdpr",
75
+ // Martinique
76
+ "America/Martinique": "gdpr",
77
+ // Mayotte
78
+ "Indian/Mayotte": "gdpr",
79
+ // Reunion
80
+ "Indian/Reunion": "gdpr",
81
+ // Saint Martin
82
+ "America/Marigot": "gdpr",
83
+ // Switzerland
23
84
  "Europe/Zurich": "gdpr",
24
- // CA (QC only)
85
+ // United Kingdom
86
+ "Europe/London": "gdpr",
87
+ // CAN: QC
25
88
  "America/Toronto": "can",
26
89
  // US
27
- "America/New_York": "us",
90
+ "America/Adak": "us",
91
+ "America/Anchorage": "us",
92
+ "America/Atka": "us",
93
+ "America/Boise": "us",
94
+ "America/Chicago": "us",
95
+ "America/Denver": "us",
28
96
  "America/Detroit": "us",
29
- "America/Kentucky/Louisville": "us",
30
- "America/Kentucky/Monticello": "us",
31
97
  "America/Indiana/Indianapolis": "us",
32
- "America/Indiana/Vincennes": "us",
33
- "America/Indiana/Winamac": "us",
98
+ "America/Indiana/Knox": "us",
34
99
  "America/Indiana/Marengo": "us",
35
100
  "America/Indiana/Petersburg": "us",
36
- "America/Indiana/Vevay": "us",
37
- "America/Chicago": "us",
38
101
  "America/Indiana/Tell_City": "us",
39
- "America/Indiana/Knox": "us",
102
+ "America/Indiana/Vevay": "us",
103
+ "America/Indiana/Vincennes": "us",
104
+ "America/Indiana/Winamac": "us",
105
+ "America/Indianapolis": "us",
106
+ "America/Juneau": "us",
107
+ "America/Kentucky/Louisville": "us",
108
+ "America/Kentucky/Monticello": "us",
109
+ "America/Knox_IN": "us",
110
+ "America/Los_Angeles": "us",
111
+ "America/Louisville": "us",
40
112
  "America/Menominee": "us",
113
+ "America/Metlakatla": "us",
114
+ "America/New_York": "us",
115
+ "America/Nome": "us",
116
+ "America/North_Dakota/Beulah": "us",
41
117
  "America/North_Dakota/Center": "us",
42
118
  "America/North_Dakota/New_Salem": "us",
43
- "America/North_Dakota/Beulah": "us",
44
- "America/Denver": "us",
45
- "America/Boise": "us",
46
119
  "America/Phoenix": "us",
47
- "America/Los_Angeles": "us",
48
- "America/Anchorage": "us",
49
- "America/Juneau": "us",
120
+ "America/Shiprock": "us",
50
121
  "America/Sitka": "us",
51
- "America/Metlakatla": "us",
52
122
  "America/Yakutat": "us",
53
- "America/Nome": "us",
54
- "America/Adak": "us",
55
123
  "Pacific/Honolulu": "us",
56
124
  };
57
125
  function inferRegulation() {
@@ -16,41 +16,41 @@ type TCData = {
16
16
  useNonStandardStacks: boolean;
17
17
  publisherCC: string;
18
18
  purposeOneTreatment: boolean;
19
- purpose: {
20
- consents: {
19
+ purpose?: {
20
+ consents?: {
21
21
  [purposeID: string]: boolean;
22
22
  };
23
- legitimateInterests: {
23
+ legitimateInterests?: {
24
24
  [purposeID: string]: boolean;
25
25
  };
26
26
  };
27
- vendor: {
28
- consents: {
27
+ vendor?: {
28
+ consents?: {
29
29
  [vendorID: string]: boolean;
30
30
  };
31
- legitimateInterests: {
31
+ legitimateInterests?: {
32
32
  [vendorID: string]: boolean;
33
33
  };
34
34
  };
35
35
  specialFeatureOptins: {
36
36
  [featureID: string]: boolean;
37
37
  };
38
- publisher: {
39
- consents: {
38
+ publisher?: {
39
+ consents?: {
40
40
  [purposeID: string]: boolean;
41
41
  };
42
- legitimateInterests: {
42
+ legitimateInterests?: {
43
43
  [purposeID: string]: boolean;
44
44
  };
45
- customPurpose: {
46
- consents: {
45
+ customPurpose?: {
46
+ consents?: {
47
47
  [purposeID: string]: boolean;
48
48
  };
49
- legitimateInterests: {
49
+ legitimateInterests?: {
50
50
  [purposeID: string]: boolean;
51
51
  };
52
52
  };
53
- restrictions: {
53
+ restrictions?: {
54
54
  [purposeID: string]: {
55
55
  [vendorID: string]: 0 | 1 | 2;
56
56
  };
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  },
10
10
  "homepage": "https://optable.co",
11
11
  "license": "SEE LICENSE IN LICENSE",
12
- "version": "v0.26.1",
12
+ "version": "v0.26.3",
13
13
  "devDependencies": {
14
14
  "@babel/core": "^7.12.3",
15
15
  "@babel/plugin-proposal-class-properties": "^7.12.1",