Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@britannica/ads

Package Overview
Dependencies
Maintainers
5
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@britannica/ads - npm Package Compare versions

Comparing version 1.0.0-beta.1 to 1.0.0-beta.2

3

dist/AdsManager.d.ts
import './AdsManager.scss';
import { IAd } from './common/types';
export declare class _AdsManager {

@@ -8,3 +9,3 @@ private static providerClasses;

init(): Promise<void>;
contentLoadInit($container?: HTMLElement): Promise<void>;
contentLoadInit($container?: HTMLElement, adDef?: IAd[]): Promise<void>;
private isInViewPortObserver;

@@ -11,0 +12,0 @@ private static timerCallback;

@@ -1,2 +0,2 @@

"use strict";var e,t,i;!function(e){e[e.Debug=0]="Debug",e[e.Info2=1]="Info2",e[e.Info=2]="Info",e[e.None=3]="None"}(e||(e={}));class o{static INFO_STYLE="font-weight:bold; background-color: #084466; color: white; border-radius:3px;display:inline-block;padding:2px 4px";static INFO_STYLE2="font-weight:bold; background-color: rebeccapurple; color: white; border-radius:3px;display:inline-block;padding:2px 4px";static ERR_STYLE="font-weight:bold; background-color: red; color: white; border-radius:3px;display:inline-block;padding:2px 4px;";static WARN_STYLE="font-weight:bold; background-color: orange; color: white; border-radius:3px;display:inline-block;padding:2px 4px;";static DEBUG_STYLE="font-weight:bold; background-color: #88A95B; color: white; border-radius:3px;display:inline-block;padding:2px 4px;";error=console.error.bind(window.console,"%cAd Lib",o.ERR_STYLE);warning=console.warn.bind(window.console,"%cAd Lib",o.WARN_STYLE);debug;info;info2;level;constructor(t){this.level=t,this.info=e.Info>=t?console.log.bind(window.console,"%cAd Lib",o.INFO_STYLE):()=>null,this.info2=e.Info2>=t?console.log.bind(window.console,"%cAd Lib",o.INFO_STYLE2):()=>null,this.debug=e.Debug>=t?console.debug.bind(window.console,"%cAd Lib",o.DEBUG_STYLE):()=>null}getLevel(){return this.level}}class n{static isDefined(e){return void 0!==e}static isFunction(e){return"function"==typeof e}}!function(e){e.before="beforeBegin",e.after="afterEnd",e.prepend="afterBegin",e.append="beforeEnd"}(t||(t={}));class s{static insert(e,t,i){t.insertAdjacentHTML(e,i)}static remove(e){e&&e.parentNode.removeChild(e)}static loadScript(e,t={}){return new Promise(((i,o)=>{let n=document.createElement("script");n.src=e,n.onload=()=>i(),n.onerror=()=>o();for(const[e,i]of Object.entries(t))n.setAttribute(e,i);document.head.append(n)}))}static css(e,t,i){e.style.setProperty(t,i)}static addClass(e,...t){t.forEach((t=>{t&&e.classList.add(t)}))}static removeClass(e,t){e.classList.remove(t)}static onDocumentReady(e){"loading"!=document.readyState?e():document.addEventListener("DOMContentLoaded",e)}static get(e,t=document.body){return t.querySelector(e)}static getAll(e,t=document.body){return t.querySelectorAll(e)}static setEventListener(e,t,i){e.addEventListener(t,i)}static removeEventListener(e,t,i){e.removeEventListener(t,i)}static onInViewPort(e,t){new IntersectionObserver(((i,o)=>{i.forEach((i=>{i.isIntersecting&&(t(e),o.disconnect(),o=null)}))}),{threshold:1}).observe(e)}static onScroll(e,t){window.addEventListener("scroll",function(e,t){var i=!1;return function(){i||(e(window.scrollY),i=!0,setTimeout((function(){i=!1}),t))}}(e,t))}static delayedCall(e,t){t?setTimeout(e,1e3*t):e()}}class a{static createCookieSession(e,t,i){document.cookie=`${e}=${t}; path=/${i?";domain="+i:""}`}static readCookie(e){return document.cookie.split("; ").find((t=>t.startsWith(`${e}=`))).split("=")[1]}static isCookieExists(e){return document.cookie.split(";").some((t=>t.trim().startsWith(`${e}=`)))}}class r{static substringBefore(e,t){if(!e||!t)return e;const i=e.indexOf(t);return-1==i?"":e.substring(0,i)}static substringAfter(e,t){if(!e||!t)return e;const i=e.indexOf(t);return-1==i?"":e.substring(i+1)}static defaultIfBlank(e,t){return e&&0!=e.length?e:t}}class d{static getJsonFromScriptSnippet(e,t=document.body){const i=s.get(`script[type="application/json"].${e}`,t);return i?d.elementContentToJson(i):null}static elementContentToJson(e){var t=e.innerText;try{return JSON.parse(t)}catch(e){return Log.error("JSON parsing error: ",e),null}}}!function(e){e.PAUSED="PAUSED",e.RUNNING="RUNNING",e.STOPPED="STOPPED"}(i||(i={}));class l{_id=(Date.now()+Math.floor(100*Math.random())).toString().slice(-5);_state=i.STOPPED;internalTimerId;restartTimerId;lastStart;remaining;callback;delay;constructor(e,t){this.callback=e,this.delay=t}get id(){return this._id}get state(){return this._state}callbackFn(){this.lastStart=Date.now(),this.remaining=this.delay,this.callback()}pause(){this.state==i.RUNNING&&(this.stopInternalTimer(),this.stopResumeTimer(),this.remaining-=Date.now()-this.lastStart,this._state=i.PAUSED,Log.debug(`Timer [${this._id}] Paused - Remaining [${this.remaining}ms]`))}resume(){this.state==i.PAUSED&&(this.restartTimerId=window.setTimeout((()=>{this.callback(),this.start()}),this.remaining),this.lastStart=Date.now(),this._state=i.RUNNING,Log.debug(`Timer [${this._id}] Resumed in [${this.remaining}ms].`))}stop(){this.state!=i.STOPPED&&(this.stopInternalTimer(),this.stopResumeTimer(),this.remaining=this.delay,this._state=i.STOPPED,Log.debug(`Timer [${this._id}] - Internal id [${this.internalTimerId}] Stopped`))}start(){this.lastStart=Date.now(),this.remaining=this.delay,this.internalTimerId=window.setInterval((()=>this.callbackFn()),this.delay),this._state=i.RUNNING,Log.debug(`Started Timer [${this._id}] - Internal id [${this.internalTimerId}]`)}restart(){this.stop(),this.start()}stopInternalTimer(){this.internalTimerId&&(window.clearInterval(this.internalTimerId),this.internalTimerId=null)}stopResumeTimer(){this.restartTimerId&&(window.clearTimeout(this.restartTimerId),this.restartTimerId=null)}}var c,g;!function(e,t){void 0===t&&(t={});var i=t.insertAt;if(e&&"undefined"!=typeof document){var o=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css","top"===i&&o.firstChild?o.insertBefore(n,o.firstChild):o.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}}('/* banner ad */\n.__alAd {\n overflow: hidden;\n display: block;\n}\n.__alAd iframe {\n overflow: hidden;\n}\n\n/* sticky ad */\n.__alSticky {\n top: 0;\n position: sticky;\n}\n\n/* catfish */\n.__alCatfish {\n position: fixed;\n bottom: 0;\n left: 0;\n right: 0;\n margin: auto;\n z-index: 1030;\n width: fit-content;\n}\n\n/* preroll ad */\n.__alPrerollContainer {\n position: relative !important;\n}\n\n.__alPrerollWrapper {\n position: absolute;\n width: 100%;\n height: 100%;\n display: table;\n background: black url("https://cdn.britannica.com/ads/resources/loading.gif") center center no-repeat;\n}\n\n#__alPreroll {\n display: table-cell;\n vertical-align: middle;\n}\n\n/* inline ad */\n.__alInline {\n text-align: center;\n margin: 0 auto 20px auto;\n}\n.__alInline::before {\n border-bottom: 1px solid #ddd;\n color: #aaa;\n content: "Advertisement - Continue reading below";\n display: block;\n font-family: "Helvetica", "Segoe UI", "Arial", sans-serif;\n font-size: 11px;\n font-weight: bold;\n margin-bottom: 20px;\n padding-bottom: 5px;\n clear: left;\n}'),function(e){e.REGULAR="REGULAR",e.CATFISH="CATFISH"}(c||(c={}));class f{static US_PrivacyCookieName="usprivacy";static US_PrivacyCookieDuration=365;static init(){Log.info2("Init IAB: Insert iframe locator into body"),s.insert(t.append,document.body,'<iframe name="__uspapiLocator" style="display:none;height:0;opacity:0;visibility:hidden;border:0;width:0;"></iframe>'),Log.info2("Install IAB message handler"),window.addEventListener("message",f.optOutMsgHandler,!1),Log.info2("Install global __uspapi function"),window.__uspapi=(e,t,i)=>{if(Log.info2(`IAB: __uspapi function called. Command: [${e}] `),"getuspdata"===e.toLowerCase()){var o={version:t,uspString:a.readCookie(f.US_PrivacyCookieName)};Log.info2("IAB: getuspdata command. Response: ",o),i(o,null!=o.uspString)}},a.isCookieExists(f.US_PrivacyCookieName)||(__adLib.usPrivacyConsent?(Log.info2("IAB: US privacy consent needed (CCPA), create default cookie [1YNY]"),f.createCookie(1,!0,!1,!0)):(Log.info2("IAB: No US privacy consent needed, create default cookie [1---]"),f.createCookie()))}static createCookie(e=1,t,i,o){var n=e=>!0===e?"Y":!1===e?"N":"-",s=e.toString()+n(t)+n(i)+n(o),a=`${f.US_PrivacyCookieName}=${s}; `,r=new Date;r.setTime(r.getTime()+24*f.US_PrivacyCookieDuration*60*60*1e3);var d=`expires=${r.toUTCString()}; `;document.cookie=a+d+"path=/; SameSite=Lax; "}static optOutMsgHandler(e){let t,i="string"==typeof e.data;if(t=i?-1!==e.data.indexOf("__uspapiCall")?JSON.parse(e.data):{}:e.data,t.__uspapiCall){Log.info2("Received __uspapiCall event. Will post message to sender with the cookie content");var o=t.__uspapiCall;window.__uspapi(o.command,o.version,(function(t,n){var s={__uspapiReturn:{returnValue:t,success:n,callId:o.callId}};let a=e.source;Log.info2("IAB: post message back ",s,a),a.postMessage(i?JSON.stringify(s):s,"*")}))}}}!function(e){e.DFP="DFP"}(g||(g={}));class p extends class{type;ads;constructor(){this.ads=[],this.type=this.getType()}addAd(e){this.ads.push(e)}}{static PAGELOAD_TARGETING="PAGELOAD";index=1;getName(){return"Google DFP"}getType(){return g.DFP}constructor(){super()}async initProvider(){if(window.googletag={cmd:[]},!n.isDefined(window.googletag.defineSlot))try{await s.loadScript("https://securepubads.g.doubleclick.net/tag/js/gpt.js")}catch(e){throw Log.error("**** Unable to load gpt.js -> most ads and scripts will be broken ***"),e}if(class{static async loadPrebidScript(){if(!__adLib.videoForPrebidLoaded&&!n.isDefined(window.pbjs)){Log.info(`Loading [${__adLib.prebidScriptUrl}] prebid script now`),window.pbjs={que:[]};try{await s.loadScript(__adLib.prebidScriptUrl)}catch(e){return void Log.error(`Unable to load [${__adLib.prebidScriptUrl}] prebid script -> skip ad`)}__adLib.videoForPrebidLoaded=!0}}}.loadPrebidScript(),!n.isDefined(window.headertag)&&__adLib.includeIndex)try{await s.loadScript(__adLib.indexScriptUrl)}catch(e){Log.error(`Unable to load [${__adLib.indexScriptUrl}] Index script. We won't use it.`)}if(!n.isDefined(window.apstag)&&__adLib.includeA9)try{await s.loadScript("https://c.amazon-adsystem.com/aax2/apstag.js"),function(e,t){function i(i,o){t[e]._Q.push([i,o])}t[e]||(t[e]={init:function(){i("i",arguments)},fetchBids:function(){i("f",arguments)},setDisplayBids:function(){},targetingKeys:function(){return[]},_Q:[]})}("apstag",window)}catch(e){Log.error("Unable to load A9 script. Will disable it"),__adLib.includeA9=!1}googletag.cmd.push((function(){if(googletag.pubads().setTargeting("dc_ref",__adLib.url),n.isDefined(Storage)){var e=localStorage.getItem("bcDFPTargetingParams");if(e)Log.info("Setting Blueconic targeting parameters"),JSON.parse(e).forEach((e=>googletag.pubads().setTargeting(e.key,e.value)))}if(Log.info(`targeting: ${googletag.pubads().getTargetingKeys()}`),googletag.pubads().disableInitialLoad(),googletag.pubads().enableSingleRequest(),googletag.pubads().enableAsyncRendering(),googletag.pubads().setTagForChildDirectedTreatment(0),googletag.pubads().setTagForUnderAgeOfConsent(0),__adLib.dfpLazyLoad&&googletag.pubads().enableLazyLoad(__adLib.dfpLazyLoadParameters),googletag.enableServices(),__adLib.includeA9){var t={pubID:__adLib.a9Id,adServer:"googletag",bidTimeout:1200};__uspapi&&__uspapi("getuspdata","1",((e,i)=>{i&&(t.params={us_privacy:e.uspString})})),Log.info("Init A9 with ",t),apstag.init(t)}}))}createSlot(e,t){return this.initSlot(e,t)}initSlot(e,i){try{Log.info("process DFP ad: ",e);var o=e.adParameters,n=o.size[0][0],a=o.size[0][1];Log.info("Content container for this ad is ",i);var d="";if(e.displayType!=c.CATFISH)if(o.placeholderSize)d=`min-width:${r.substringBefore(o.placeholderSize,"x")}px;min-height:${r.substringAfter(o.placeholderSize,"x")}px;`;else if(1==o.size.length)d=`width:${n}px;height:${a}px;`;else{d=`min-height:${Math.round(o.size.map((e=>e[1])).reduce(((e,t)=>e+t))/o.size.length)}px;`}var l="DFP_"+this.index++;e.containerId=l,e.dfpSize=1==o.size.length?o.size[0]:o.size;var g=`style="${d}${r.defaultIfBlank(o.style,"")}"`,f=`<div data-type="${e.type}" class="__alAd ${r.defaultIfBlank(__adLib.adClass,"")} ${r.defaultIfBlank(o.cssClass,"")}" ${g} id="${l}"></div>`;Log.info(`Inject DIV: [${f}] into `,i),s.insert(t[e.injector],i,f),this.setDfpA9Slot(e);let p=s.get(`#${l}`);return p.setAttribute("data-identifier",e.dfpSlot.getAdUnitPath()),p}catch(t){return Log.error("Init Slot Error: ",e,t),null}}setDfpA9Slot=function(e){Log.info("Initializes DFP slot and A9 slot for ",e);var t=e.adParameters,i=__adLib.dfpIdPrefix.replace("${LEG}",__adLib.leg)+(__adLib.isPhone?"MOBILE":"DESKTOP")+"_",o=`/${__adLib.googleDfpId}/${i}${t.id}`;Log.info(`Define new slot: [${o}] with: size [${e.dfpSize}] id [${e.containerId}]`),e.dfpSlot=googletag.defineSlot(o,e.dfpSize,e.containerId),t.targeting&&Object.entries(t.targeting).forEach((([t,i])=>{e.dfpSlot.setTargeting(t,String(i))})),e.dfpSlot.addService(googletag.pubads()),__adLib.includeIndex&&(e.a9Slot={slotID:e.containerId,slotName:o,sizes:t.size}),Log.info("DFP/A9 slot defined for ",e)};refreshAllAds(){Log.info("Refresh all DFP ads."),googletag.cmd.push((()=>{p.setPageLoadTargeting(this.ads),this.refreshSlots()}))}requestBids(e){this.refreshAds(e)}refreshAds(e){Log.info("Refresh ads: ",e),googletag.cmd.push((()=>{p.setPageLoadTargeting(e),this.refreshSlots(e)}))}static setPageLoadTargeting(e){for(let t of e){const e=`REFRESH${t.refreshCounter}`;Log.info(`Update ${p.PAGELOAD_TARGETING} targeting ${e} for `,t),t.dfpSlot.setTargeting(p.PAGELOAD_TARGETING,e)}}refreshSlots(t=this.ads){Log.info("Refresh slots - ads : ",t);let i=!1,o=!1,n=!1,s=()=>{n||!o||!i&&__adLib.includeA9||(-1!=c&&window.clearTimeout(c),Log.info("Prebid is completed and A9 completed or disabled -> call DFP"),a())},a=()=>{Log.info("Refresh ads ",t);let e=t.map((e=>e.dfpSlot));Log.info("Refresh DFP slots ",e),googletag.pubads().refresh(e)},r=[];for(let e of t)r.push({code:e.dfpSlot.getAdUnitPath(),mediaTypes:{banner:{sizes:e.adParameters.size}},bids:__adLib.prebidBannerBiddersConfiguration});Log.info("Prebid ad unit configuration: ",r);let d={...__adLib.prebidConfiguration,debug:Log.getLevel()==e.Debug};if(__adLib.includeA9){var l=t.map((e=>e.a9Slot));Log.info("Calls A9 with these slots:",l),apstag.fetchBids({slots:l},(()=>{Log.info("A9 bid request completed"),apstag.setDisplayBids(),i=!0,s()}))}pbjs.que.push((()=>{Log.info("Set Prebid Config: ",d),pbjs.setConfig(d),pbjs.addAdUnits(r),Log.info("Request Prebid bids"),pbjs.requestBids({timeout:__adLib.prebidTimeout,bidsBackHandler:()=>{Log.info("Prebid request bid completed"),pbjs.setTargetingForGPTAsync(t.map((e=>e.dfpSlot.getAdUnitPath()))),o=!0,s()}})}));let c=-1;0!=__adLib.biddersFailsafeTimeout&&(Log.info(`Bidders failsafe timeout set to [${__adLib.biddersFailsafeTimeout}] ms`),c=window.setTimeout((()=>{Log.info("Bidding Timeout! -> calls DFP directly"),n=!0,a()}),__adLib.biddersFailsafeTimeout))}}class u{static async init(){if(__adLib.requiresConsent){if(!n.isDefined(window.__tcfapi)){Log.info2("__tcfapi not found -> Will load the oneTrust scripts");try{await s.loadScript("https://cdn.cookielaw.org/consent/cmp.stub.js",{"data-domain-script":__adLib.oneTrustId})}catch(e){throw Log.error("Unable to load oneTrust cmp.stub.js script"),e}try{await s.loadScript("https://cdn.cookielaw.org/scripttemplates/otSDKStub.js",{"data-domain-script":__adLib.oneTrustId})}catch(e){throw Log.error("Unable to load oneTrust otSDKStub.js script "),e}Log.info2("oneTrust scripts loaded")}Log.info2("set OptanonWrapper function"),window.OptanonWrapper=()=>{Log.info2(`OptanonWrapper called. Defer Ads status is [${u.getDeferAdsStatus()}]`),u.getDeferAdsStatus()&&(Log.info2("Defer Ads status is true -> Set Read TCData callback"),window.__tcfapi("getTCData",2,((e,t)=>{if(Log.info2(`TCData read: success = [${t}] data = `,e),!t||u.statusOk(e))return Log.info2("Error or status already OK -> send message to the app to load the ads immediately "),void u.setDeferAdsStatus(!1);const i=(e,t)=>{Log.info2("Received __tcpapi status change Event: ",e),t&&u.statusOk(e)&&(Log.info2("Status now OK, remove the event listener and send message to the app to load the ads immediately"),window.__tcfapi("removeEventListener",2,i),u.setDeferAdsStatus(!1))};Log.info2("Status not OK yet. Set event listener to load the ads when it will be OK"),window.__tcfapi("addEventListener",2,i)})))},Log.info2("Defer the ads loading by default"),u.setDeferAdsStatus(!0)}else Log.info2("Not Consent Required")}static getDeferAdsStatus(){return __adLib.deferAds}static setDeferAdsStatus(e){__adLib.deferAds=e,e||document.dispatchEvent(new Event("endDeferAds"))}static statusOk(e){return"useractioncomplete"==e.eventStatus||"tcloaded"==e.eventStatus}static onDNSMILinkClicked(){Log.info2("CCPA consent called"),Log.info2("create default IAB cookie [1YYY]"),f.createCookie(1,!0,!0,!0),Log.info2("Modifies onetrust OptanonConsent cookies and ActiveGroups global variables");let e=[4],t=decodeURIComponent(a.readCookie("OptanonConsent "));Log.info2("Current OptanonConsent cookie value = ",t);for(let i of e)t=t.replace(`,${i}:1,`,`,${i}:0,`),window.OptanonActiveGroups=window.OptanonActiveGroups.replace(`,${i},`,","),window.OnetrustActiveGroups=window.OnetrustActiveGroups.replace(`,${i},`,",");Log.info2("New OptanonConsent cookie value = ",t),Log.info2(`New OptanonActiveGroups = [${window.OptanonActiveGroups}]`),Log.info2(`New OneTrustActiveGroups = [${window.OnetrustActiveGroups}]`),a.createCookieSession("OptanonConsent",encodeURI(t),__adLib.topDomain),a.createCookieSession("EbConsentClosed","true"),Log.info2("created new OptanonConsent and EbConsentClosed cookies")}}class h{static CATFISH_ID="AD_STATIC_CATFISH";static newCatfish(e,i){Log.info("Create a catfish container");var o=`<div id="${h.CATFISH_ID}" class="__alCatfish" style=" ${e?`width:${e}px;`:""} ${i?`height:${i}px`:""}"></div>`;return s.insert(t.append,document.body,o),Log.info("Static Catfish Inserted",h.getCurrentCatfishElement()),h.getCurrentCatfishElement()}static getCurrentCatfishElement(){return s.get(`#${h.CATFISH_ID}`)}}class m{static providerClasses=new Map([[g.DFP,p]]);providers=new Map;timers=[];isAdBlockerActivated(){var e=s.get("#_MGS_");e||(s.insert(t.append,document.body,'<div id="_MGS_"><div class="adBanner" style="height:1px"></div></div>'),e=s.get("#_MGS_"));var i=s.get("div",e);return"none"===window.getComputedStyle(i).display}async init(){Log.info("Init Ads manager at page load"),f.init(),await u.init(),Log.info("Set tab visibility event handler"),s.setEventListener(document,"visibilitychange",(()=>{var e="visible"===document.visibilityState;Log.info(`Tab visibility changed to [${e}]`),e?this.resumeAllPausedTimers():this.pauseAllRunningTimers()})),__adLib.deferAds?(Log.info("Ads need to be deferred. Will wait until the [endDeferAds] is fired"),s.setEventListener(document,"endDeferAds",(()=>{Log.info("Deferred Ads event triggered. Will now initialize the ads"),this.contentLoadInit()}))):(Log.info("No deferred ads. Will initialize the ads now"),this.contentLoadInit())}async contentLoadInit(e=document.body){Log.info(" ============================================================================================="),Log.info("Initialize container with ads"),Log.info(" ============================================================================================="),Log.info("Look for json ads definition in ",e);var t=d.getJsonFromScriptSnippet("ads-script",e);if(!t)return void Log.info("Did not find ads definition.");var i=t;if(!i)return;Log.info("Found ad definitions: ",i);let o=new Map;for(let t of i){if(Log.info("Init this ad: ",t),!this.providers.has(t.type)){Log.info(`Initializes Provider: [${t.type}]`);try{let e=new(m.providerClasses.get(t.type));await e.initProvider(),this.providers.set(t.type,e)}catch(e){Log.error(`Unable to instantiate Ad Provider: [${t.type}]`,t,e);continue}}var n=this.providers.get(t.type);o.has(t.type)||o.set(t.type,[]),t.provider=n;let i=null;if(t.displayType==c.REGULAR)i=s.get(t.selector,e);else if(t.displayType==c.CATFISH){if(i=h.getCurrentCatfishElement(),i){let e=s.get(".__alAd",i).ad;e.provider.refreshAds([e]),Log.info("Catfish already exists, just refresh its ad");continue}i=h.newCatfish(),t.injector="append"}i?(t.$container=n.createSlot(t,i),t.$container?(t.$container.ad=t,t.refreshCounter=0,n.addAd(t),o.get(t.type).push(t),t.autoRefresh?(t.$container.isInViewPort=!1,t.refreshTimer=new l((()=>{m.timerCallback(t)}),1e3*__adLib.refreshTimer),this.timers.push(t.refreshTimer),Log.info("This ad is autorefresh, added refresh timer: ",t.refreshTimer)):(t.refreshTimer=null,t.$container.isInViewPort=!0,Log.info("This ad is not autorefresh -> no refresh timer")),t.displayType==c.CATFISH?(Log.info("The ad is a catfish -> always in viewport and start refresh timer"),t.$container.isInViewPort=!0,t.refreshTimer&&t.refreshTimer.start()):t.autoRefresh&&(Log.info("Add the ad container to the observer -> ",t.$container),this.isInViewPortObserver.observe(t.$container)),Log.info("Ad initialized",t)):Log.info("Slot creation failed -> skip this ad")):Log.info("Error when initializing the ad/Existing ad -> skip it: ",t)}for(let[e,t]of o)0==t.length?Log.info(`No ads for [${e}] provider`):(Log.info(`Request Bids for [${e}] provider: `,t),this.providers.get(e).requestBids(t));if(__adLib.stickyContainerSelector){const t=s.getAll(`${__adLib.stickyContainerSelector} .__alAd`,e);var a=t.length;if(a>0){let e=t.item(a-1);Log.info("Last ad is sticky",e),s.addClass(e,"__alSticky",__adLib.stickyAdClass)}}}isInViewPortObserver=new IntersectionObserver((e=>{e.forEach((e=>{var t=e.target;t.isInViewPort=e.intersectionRatio>=__adLib.viewportThreshold,t.isInViewPort?(Log.info("Ad in viewport -> resume timer",t.ad),m.resumeRefreshTimer(t.ad)):(Log.info("Ad out of viewport -> stop timer",t.ad),m.pauseRefreshTimer(t.ad))}))}),{threshold:__adLib.viewportThreshold});static timerCallback(e){Log.info("Ad is refreshed.",e),e.refreshCounter++,e.provider.refreshAds([e])}static resumeRefreshTimer(e){Log.info("Resume refresh timer for ",e),e.refreshTimer.state==i.PAUSED?e.refreshTimer.resume():e.refreshTimer.state==i.STOPPED&&e.refreshTimer.start()}static pauseRefreshTimer(e){Log.info("Pause refresh timer for ",e),e.refreshTimer.pause()}pausedTimers=[];pauseAllRunningTimers(){this.pausedTimers=this.timers.filter((e=>e.state==i.RUNNING)),0!=this.pausedTimers.length&&(this.pausedTimers.forEach((e=>e.pause())),Log.info("Pause these timers: ",this.pausedTimers.map((e=>e.id))))}resumeAllPausedTimers(){0!=this.pausedTimers.length&&(this.pausedTimers.forEach((e=>e.resume())),Log.info("Resume these timers: ",this.pausedTimers.map((e=>e.id))))}refreshAllAds(){Log.info("Refresh All ads"),this.providers.forEach((e=>{Log.info(`will refresh ads for this provider: [${e.getName()}]`);for(let t of e.ads)t.refreshCounter++;e.refreshAllAds();for(let t of e.ads)t.refreshTimer&&t.refreshTimer.restart()}))}}n.isDefined(typeof window.__adLib)&&s.onDocumentReady((()=>{window.Log=new o(e[__adLib.logLevel]),window.Log.info("Ad Library Loaded"),window.AdsManager=new m,AdsManager.init()}));
"use strict";var e,t,i;!function(e){e[e.Debug=0]="Debug",e[e.Info2=1]="Info2",e[e.Info=2]="Info",e[e.None=3]="None"}(e||(e={}));class o{static INFO_STYLE="font-weight:bold; background-color: #084466; color: white; border-radius:3px;display:inline-block;padding:2px 4px";static INFO_STYLE2="font-weight:bold; background-color: rebeccapurple; color: white; border-radius:3px;display:inline-block;padding:2px 4px";static ERR_STYLE="font-weight:bold; background-color: red; color: white; border-radius:3px;display:inline-block;padding:2px 4px;";static WARN_STYLE="font-weight:bold; background-color: orange; color: white; border-radius:3px;display:inline-block;padding:2px 4px;";static DEBUG_STYLE="font-weight:bold; background-color: #88A95B; color: white; border-radius:3px;display:inline-block;padding:2px 4px;";error=console.error.bind(window.console,"%cAd Lib",o.ERR_STYLE);warning=console.warn.bind(window.console,"%cAd Lib",o.WARN_STYLE);debug;info;info2;level;constructor(t){this.level=t,this.info=e.Info>=t?console.log.bind(window.console,"%cAd Lib",o.INFO_STYLE):()=>null,this.info2=e.Info2>=t?console.log.bind(window.console,"%cAd Lib",o.INFO_STYLE2):()=>null,this.debug=e.Debug>=t?console.debug.bind(window.console,"%cAd Lib",o.DEBUG_STYLE):()=>null}getLevel(){return this.level}}class n{static isDefined(e){return void 0!==e}static isFunction(e){return"function"==typeof e}}!function(e){e.before="beforeBegin",e.after="afterEnd",e.prepend="afterBegin",e.append="beforeEnd"}(t||(t={}));class s{static insert(e,t,i){t.insertAdjacentHTML(e,i)}static remove(e){e&&e.parentNode.removeChild(e)}static loadScript(e,t={}){return new Promise(((i,o)=>{let n=document.createElement("script");n.src=e,n.onload=()=>i(),n.onerror=()=>o();for(const[e,i]of Object.entries(t))n.setAttribute(e,i);document.head.append(n)}))}static css(e,t,i){e.style.setProperty(t,i)}static addClass(e,...t){t.forEach((t=>{t&&e.classList.add(t)}))}static removeClass(e,t){e.classList.remove(t)}static onDocumentReady(e){"loading"!=document.readyState?e():document.addEventListener("DOMContentLoaded",e)}static get(e,t=document.body){return t.querySelector(e)}static getAll(e,t=document.body){return t.querySelectorAll(e)}static setEventListener(e,t,i){e.addEventListener(t,i)}static removeEventListener(e,t,i){e.removeEventListener(t,i)}static onInViewPort(e,t){new IntersectionObserver(((i,o)=>{i.forEach((i=>{i.isIntersecting&&(t(e),o.disconnect(),o=null)}))}),{threshold:1}).observe(e)}static onScroll(e,t){window.addEventListener("scroll",function(e,t){let i=!1;return function(){i||(e(window.scrollY),i=!0,setTimeout((function(){i=!1}),t))}}(e,t))}static delayedCall(e,t){t?setTimeout(e,1e3*t):e()}}class a{static createCookieSession(e,t,i){document.cookie=`${e}=${t}; path=/${i?";domain="+i:""}`}static readCookie(e){return document.cookie.split("; ").find((t=>t.startsWith(`${e}=`))).split("=")[1]}static isCookieExists(e){return document.cookie.split(";").some((t=>t.trim().startsWith(`${e}=`)))}}class r{static substringBefore(e,t){if(!e||!t)return e;const i=e.indexOf(t);return-1==i?"":e.substring(0,i)}static substringAfter(e,t){if(!e||!t)return e;const i=e.indexOf(t);return-1==i?"":e.substring(i+1)}static defaultIfBlank(e,t){return e&&0!=e.length?e:t}}class d{static getJsonFromScriptSnippet(e,t=document.body){const i=s.get(`script[type="application/json"].${e}`,t);return i?d.elementContentToJson(i):null}static elementContentToJson(e){let t=e.innerText;try{return JSON.parse(t)}catch(e){return Log.error("JSON parsing error: ",e),null}}}!function(e){e.PAUSED="PAUSED",e.RUNNING="RUNNING",e.STOPPED="STOPPED"}(i||(i={}));class l{_id=(Date.now()+Math.floor(100*Math.random())).toString().slice(-5);_state=i.STOPPED;internalTimerId;restartTimerId;lastStart;remaining;callback;delay;constructor(e,t){this.callback=e,this.delay=t}get id(){return this._id}get state(){return this._state}callbackFn(){this.lastStart=Date.now(),this.remaining=this.delay,this.callback()}pause(){this.state==i.RUNNING&&(this.stopInternalTimer(),this.stopResumeTimer(),this.remaining-=Date.now()-this.lastStart,this._state=i.PAUSED,Log.debug(`Timer [${this._id}] Paused - Remaining [${this.remaining}ms]`))}resume(){this.state==i.PAUSED&&(this.restartTimerId=window.setTimeout((()=>{this.callback(),this.start()}),this.remaining),this.lastStart=Date.now(),this._state=i.RUNNING,Log.debug(`Timer [${this._id}] Resumed in [${this.remaining}ms].`))}stop(){this.state!=i.STOPPED&&(this.stopInternalTimer(),this.stopResumeTimer(),this.remaining=this.delay,this._state=i.STOPPED,Log.debug(`Timer [${this._id}] - Internal id [${this.internalTimerId}] Stopped`))}start(){this.lastStart=Date.now(),this.remaining=this.delay,this.internalTimerId=window.setInterval((()=>this.callbackFn()),this.delay),this._state=i.RUNNING,Log.debug(`Started Timer [${this._id}] - Internal id [${this.internalTimerId}]`)}restart(){this.stop(),this.start()}stopInternalTimer(){this.internalTimerId&&(window.clearInterval(this.internalTimerId),this.internalTimerId=null)}stopResumeTimer(){this.restartTimerId&&(window.clearTimeout(this.restartTimerId),this.restartTimerId=null)}}var c,g;!function(e,t){void 0===t&&(t={});var i=t.insertAt;if(e&&"undefined"!=typeof document){var o=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css","top"===i&&o.firstChild?o.insertBefore(n,o.firstChild):o.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}}('/* banner ad */\n.__alAd {\n overflow: hidden;\n display: block;\n margin-left: auto;\n margin-right: auto;\n}\n\n.__alAd > div {\n text-align: center !important;\n display: block !important;\n margin: auto !important;\n}\n\n.__alAd > div > iframe,\n.__alAd > div > div {\n display: block !important;\n margin: auto !important;\n}\n\n/* sticky ad */\n.__alSticky {\n top: 0;\n position: sticky;\n}\n\n/* catfish */\n.__alCatfish {\n position: fixed;\n bottom: 0;\n left: 0;\n right: 0;\n margin: auto;\n z-index: 1030;\n width: fit-content;\n}\n\n/* preroll ad */\n.__alPrerollContainer {\n position: relative !important;\n}\n\n.__alPrerollWrapper {\n position: absolute;\n width: 100%;\n height: 100%;\n display: table;\n background: black url("https://cdn.britannica.com/ads/resources/loading.gif") center center no-repeat;\n}\n\n#__alPreroll {\n display: table-cell;\n vertical-align: middle;\n}\n\n/* inline ad */\n.__alInline {\n text-align: center;\n margin: 0 auto 20px auto;\n}\n.__alInline::before {\n border-bottom: 1px solid #ddd;\n color: #aaa;\n content: "Advertisement - Continue reading below";\n display: block;\n font-family: "Helvetica", "Segoe UI", "Arial", sans-serif;\n font-size: 11px;\n font-weight: bold;\n margin-bottom: 20px;\n padding-bottom: 5px;\n clear: left;\n}'),function(e){e.REGULAR="REGULAR",e.CATFISH="CATFISH"}(c||(c={}));class p{static US_PrivacyCookieName="usprivacy";static US_PrivacyCookieDuration=365;static init(){Log.info2("Init IAB: Insert iframe locator into body"),s.insert(t.append,document.body,'<iframe name="__uspapiLocator" style="display:none;height:0;opacity:0;visibility:hidden;border:0;width:0;"></iframe>'),Log.info2("Install IAB message handler"),window.addEventListener("message",p.optOutMsgHandler,!1),Log.info2("Install global __uspapi function"),window.__uspapi=(e,t,i)=>{if(Log.info2(`IAB: __uspapi function called. Command: [${e}] `),"getuspdata"===e.toLowerCase()){let e={version:t,uspString:a.readCookie(p.US_PrivacyCookieName)};Log.info2("IAB: getuspdata command. Response: ",e),i(e,null!=e.uspString)}},a.isCookieExists(p.US_PrivacyCookieName)||(__adLib.usPrivacyConsent?(Log.info2("IAB: US privacy consent needed (CCPA), create default cookie [1YNY]"),p.createCookie(1,!0,!1,!0)):(Log.info2("IAB: No US privacy consent needed, create default cookie [1---]"),p.createCookie()))}static createCookie(e=1,t,i,o){let n=e=>!0===e?"Y":!1===e?"N":"-",s=e.toString()+n(t)+n(i)+n(o),a=`${p.US_PrivacyCookieName}=${s}; `,r=new Date;r.setTime(r.getTime()+24*p.US_PrivacyCookieDuration*60*60*1e3);let d=`expires=${r.toUTCString()}; `;document.cookie=a+d+"path=/; SameSite=Lax; "}static optOutMsgHandler(e){let t,i="string"==typeof e.data;if(t=i?-1!==e.data.indexOf("__uspapiCall")?JSON.parse(e.data):{}:e.data,t.__uspapiCall){Log.info2("Received __uspapiCall event. Will post message to sender with the cookie content");let o=t.__uspapiCall;window.__uspapi(o.command,o.version,(function(t,n){let s={__uspapiReturn:{returnValue:t,success:n,callId:o.callId}},a=e.source;Log.info2("IAB: post message back ",s,a),a.postMessage(i?JSON.stringify(s):s,"*")}))}}}!function(e){e.DFP="DFP"}(g||(g={}));class f extends class{type;ads;constructor(){this.ads=[],this.type=this.getType()}addAd(e){this.ads.push(e)}}{static PAGELOAD_TARGETING="PAGELOAD";index=1;getName(){return"Google DFP"}getType(){return g.DFP}constructor(){super()}async initProvider(){if(window.googletag={cmd:[]},!n.isDefined(window.googletag.defineSlot))try{await s.loadScript("https://securepubads.g.doubleclick.net/tag/js/gpt.js")}catch(e){throw Log.error("**** Unable to load gpt.js -> most ads and scripts will be broken ***"),e}if(class{static async loadPrebidScript(){if(!__adLib.videoForPrebidLoaded&&!n.isDefined(window.pbjs)){Log.info(`Loading [${__adLib.prebidScriptUrl}] prebid script now`),window.pbjs={que:[]};try{await s.loadScript(__adLib.prebidScriptUrl)}catch(e){return void Log.error(`Unable to load [${__adLib.prebidScriptUrl}] prebid script -> skip ad`)}__adLib.videoForPrebidLoaded=!0}}}.loadPrebidScript(),!n.isDefined(window.headertag)&&__adLib.includeIndex)try{await s.loadScript(__adLib.indexScriptUrl)}catch(e){Log.error(`Unable to load [${__adLib.indexScriptUrl}] Index script. We won't use it.`)}if(!n.isDefined(window.apstag)&&__adLib.includeA9)try{await s.loadScript("https://c.amazon-adsystem.com/aax2/apstag.js"),function(e,t){function i(i,o){t[e]._Q.push([i,o])}t[e]||(t[e]={init:function(){i("i",arguments)},fetchBids:function(){i("f",arguments)},setDisplayBids:function(){},targetingKeys:function(){return[]},_Q:[]})}("apstag",window)}catch(e){Log.error("Unable to load A9 script. Will disable it"),__adLib.includeA9=!1}googletag.cmd.push((function(){if(googletag.pubads().setTargeting("dc_ref",__adLib.url),n.isDefined(Storage)){let e=localStorage.getItem("bcDFPTargetingParams");if(e){Log.info("Setting Blueconic targeting parameters"),JSON.parse(e).forEach((e=>googletag.pubads().setTargeting(e.key,e.value)))}}if(Log.info(`targeting: ${googletag.pubads().getTargetingKeys()}`),googletag.pubads().disableInitialLoad(),googletag.pubads().enableSingleRequest(),googletag.pubads().enableAsyncRendering(),googletag.pubads().setTagForChildDirectedTreatment(0),googletag.pubads().setTagForUnderAgeOfConsent(0),__adLib.dfpLazyLoad&&googletag.pubads().enableLazyLoad(__adLib.dfpLazyLoadParameters),googletag.enableServices(),__adLib.includeA9){let e={pubID:__adLib.a9Id,adServer:"googletag",bidTimeout:1200};__uspapi&&__uspapi("getuspdata","1",((t,i)=>{i&&(e.params={us_privacy:t.uspString})})),Log.info("Init A9 with ",e),apstag.init(e)}}))}createSlot(e,t){return this.initSlot(e,t)}initSlot(e,i){try{Log.info("process DFP ad: ",e);let o=e.adParameters,n=o.size[0][0],a=o.size[0][1];Log.info("Content container for this ad is ",i);let d="";if(e.displayType!=c.CATFISH)if(o.placeholderSize)d=`min-width:${r.substringBefore(o.placeholderSize,"x")}px;min-height:${r.substringAfter(o.placeholderSize,"x")}px;`;else if(1==o.size.length)d=`width:${n}px;height:${a}px;`;else{d=`min-height:${Math.round(o.size.map((e=>e[1])).reduce(((e,t)=>e+t))/o.size.length)}px;`}let l="DFP_"+this.index++;e.containerId=l,e.dfpSize=1==o.size.length?o.size[0]:o.size;let g=`style="${d}${r.defaultIfBlank(o.style,"")}"`,p=`<div data-type="${e.type}" class="__alAd ${r.defaultIfBlank(__adLib.adClass,"")} ${r.defaultIfBlank(o.cssClass,"")}" ${g} id="${l}"></div>`;Log.info(`Inject DIV: [${p}] into `,i),s.insert(t[e.injector],i,p);let f=this.setDfpA9Slot(e),u=s.get(`#${l}`);return u.setAttribute("data-identifier",e.dfpSlot.getAdUnitPath()),u.setAttribute("data-qa-identifier",f),u}catch(t){return Log.error("Init Slot Error: ",e,t),null}}setDfpA9Slot=function(e){Log.info("Initializes DFP slot and A9 slot for ",e);let t=e.adParameters,i=__adLib.dfpIdPrefix.replace("${LEG}",__adLib.leg),o=`${__adLib.isPhone?"MOBILE":"DESKTOP"}_${t.id}`,n=`/${__adLib.googleDfpId}/${i}${o}`;return Log.info(`Define new slot: [${n}] with: size [${e.dfpSize}] id [${e.containerId}]`),e.dfpSlot=googletag.defineSlot(n,e.dfpSize,e.containerId),t.targeting&&Object.entries(t.targeting).forEach((([t,i])=>{e.dfpSlot.setTargeting(t,String(i))})),e.dfpSlot.addService(googletag.pubads()),__adLib.includeIndex&&(e.a9Slot={slotID:e.containerId,slotName:n,sizes:t.size}),Log.info("DFP/A9 slot defined for ",e),o};refreshAllAds(){Log.info("Refresh all DFP ads."),googletag.cmd.push((()=>{f.setPageLoadTargeting(this.ads),this.refreshSlots()}))}requestBids(e){this.refreshAds(e)}refreshAds(e){Log.info("Refresh ads: ",e),googletag.cmd.push((()=>{f.setPageLoadTargeting(e),this.refreshSlots(e)}))}static setPageLoadTargeting(e){for(let t of e){const e=`REFRESH${t.refreshCounter}`;Log.info(`Update ${f.PAGELOAD_TARGETING} targeting ${e} for `,t),t.dfpSlot.setTargeting(f.PAGELOAD_TARGETING,e)}}refreshSlots(t=this.ads){Log.info("Refresh slots - ads : ",t);let i=!1,o=!1,n=!1,s=()=>{n||!o||!i&&__adLib.includeA9||(-1!=l&&window.clearTimeout(l),Log.info("Prebid is completed and A9 completed or disabled -> call DFP"),a())},a=()=>{Log.info("Refresh ads ",t);let e=t.map((e=>e.dfpSlot));Log.info("Refresh DFP slots ",e),googletag.pubads().refresh(e)},r=[];for(let e of t)r.push({code:e.dfpSlot.getAdUnitPath(),mediaTypes:{banner:{sizes:e.adParameters.size}},bids:__adLib.prebidBannerBiddersConfiguration});Log.info("Prebid ad unit configuration: ",r);let d={...__adLib.prebidConfiguration,debug:Log.getLevel()==e.Debug};if(__adLib.includeA9){let e=t.map((e=>e.a9Slot));Log.info("Calls A9 with these slots:",e),apstag.fetchBids({slots:e},(()=>{Log.info("A9 bid request completed"),apstag.setDisplayBids(),i=!0,s()}))}pbjs.que.push((()=>{Log.info("Set Prebid Config: ",d),pbjs.setConfig(d),pbjs.addAdUnits(r),Log.info("Request Prebid bids"),pbjs.requestBids({timeout:__adLib.prebidTimeout,bidsBackHandler:()=>{Log.info("Prebid request bid completed"),pbjs.setTargetingForGPTAsync(t.map((e=>e.dfpSlot.getAdUnitPath()))),o=!0,s()}})}));let l=-1;0!=__adLib.biddersFailsafeTimeout&&(Log.info(`Bidders failsafe timeout set to [${__adLib.biddersFailsafeTimeout}] ms`),l=window.setTimeout((()=>{Log.info("Bidding Timeout! -> calls DFP directly"),n=!0,a()}),__adLib.biddersFailsafeTimeout))}}class u{static async init(){if(__adLib.requiresConsent){if(!n.isDefined(window.__tcfapi)){Log.info2("__tcfapi not found -> Will load the oneTrust scripts");try{await s.loadScript("https://cdn.cookielaw.org/consent/cmp.stub.js",{"data-domain-script":__adLib.oneTrustId})}catch(e){throw Log.error("Unable to load oneTrust cmp.stub.js script"),e}try{await s.loadScript("https://cdn.cookielaw.org/scripttemplates/otSDKStub.js",{"data-domain-script":__adLib.oneTrustId})}catch(e){throw Log.error("Unable to load oneTrust otSDKStub.js script "),e}Log.info2("oneTrust scripts loaded")}Log.info2("set OptanonWrapper function"),window.OptanonWrapper=()=>{Log.info2(`OptanonWrapper called. Defer Ads status is [${u.getDeferAdsStatus()}]`),u.getDeferAdsStatus()&&(Log.info2("Defer Ads status is true -> Set Read TCData callback"),window.__tcfapi("getTCData",2,((e,t)=>{if(Log.info2(`TCData read: success = [${t}] data = `,e),!t||u.statusOk(e))return Log.info2("Error or status already OK -> send message to the app to load the ads immediately "),void u.setDeferAdsStatus(!1);const i=(e,t)=>{Log.info2("Received __tcpapi status change Event: ",e),t&&u.statusOk(e)&&(Log.info2("Status now OK, remove the event listener and send message to the app to load the ads immediately"),window.__tcfapi("removeEventListener",2,i),u.setDeferAdsStatus(!1))};Log.info2("Status not OK yet. Set event listener to load the ads when it will be OK"),window.__tcfapi("addEventListener",2,i)})))},Log.info2("Defer the ads loading by default"),u.setDeferAdsStatus(!0)}else Log.info2("Not Consent Required")}static getDeferAdsStatus(){return __adLib.deferAds}static setDeferAdsStatus(e){__adLib.deferAds=e,e||document.dispatchEvent(new Event("endDeferAds"))}static statusOk(e){return"useractioncomplete"==e.eventStatus||"tcloaded"==e.eventStatus}static getPrebidConsentParameters(){return __adLib.usPrivacyConsent?__adLib.prebidCcpaConfiguration:__adLib.requiresConsent?__adLib.prebidGdprConfiguration:null}static onDNSMILinkClicked(){Log.info2("CCPA consent called"),Log.info2("create default IAB cookie [1YYY]"),p.createCookie(1,!0,!0,!0),Log.info2("Modifies onetrust OptanonConsent cookies and ActiveGroups global variables");let e=[4],t=decodeURIComponent(a.readCookie("OptanonConsent "));Log.info2("Current OptanonConsent cookie value = ",t);for(let i of e)t=t.replace(`,${i}:1,`,`,${i}:0,`),window.OptanonActiveGroups=window.OptanonActiveGroups.replace(`,${i},`,","),window.OnetrustActiveGroups=window.OnetrustActiveGroups.replace(`,${i},`,",");Log.info2("New OptanonConsent cookie value = ",t),Log.info2(`New OptanonActiveGroups = [${window.OptanonActiveGroups}]`),Log.info2(`New OneTrustActiveGroups = [${window.OnetrustActiveGroups}]`),a.createCookieSession("OptanonConsent",encodeURI(t),__adLib.topDomain),a.createCookieSession("EbConsentClosed","true"),Log.info2("created new OptanonConsent and EbConsentClosed cookies")}}class h{static CATFISH_ID="AD_STATIC_CATFISH";static newCatfish(e,i){Log.info("Create a catfish container");let o=`<div id="${h.CATFISH_ID}" class="__alCatfish" style=" ${e?`width:${e}px;`:""} ${i?`height:${i}px`:""}"></div>`;return s.insert(t.append,document.body,o),Log.info("Static Catfish Inserted",h.getCurrentCatfishElement()),h.getCurrentCatfishElement()}static getCurrentCatfishElement(){return s.get(`#${h.CATFISH_ID}`)}}class m{static providerClasses=new Map([[g.DFP,f]]);providers=new Map;timers=[];isAdBlockerActivated(){let e=s.get("#_MGS_");e||(s.insert(t.append,document.body,'<div id="_MGS_"><div class="adBanner" style="height:1px"></div></div>'),e=s.get("#_MGS_"));let i=s.get("div",e);return"none"===window.getComputedStyle(i).display}async init(){Log.info("Init Ads manager at page load"),p.init(),await u.init(),Log.info("Set tab visibility event handler"),s.setEventListener(document,"visibilitychange",(()=>{let e="visible"===document.visibilityState;Log.info(`Tab visibility changed to [${e}]`),e?this.resumeAllPausedTimers():this.pauseAllRunningTimers()})),__adLib.deferAds?(Log.info("Ads need to be deferred. Will wait until the [endDeferAds] is fired"),s.setEventListener(document,"endDeferAds",(()=>{Log.info("Deferred Ads event triggered. Will now initialize the ads"),this.contentLoadInit()}))):(Log.info("No deferred ads. Will initialize the ads now"),this.contentLoadInit(document.body,__adLib.initialLoadAds))}async contentLoadInit(e=document.body,t){let i;if(Log.info(" ============================================================================================="),Log.info("Initialize container with ads"),Log.info(" ============================================================================================="),t)i=t;else{Log.info("Look for json ads definition in ",e);let t=d.getJsonFromScriptSnippet("ads-script",e);if(!t)return void Log.info("Did not find ads definition.");if(i=t,!i)return;Log.info("Found ad definitions: ",i)}let o=new Map;for(let t of i){if(Log.info("Init this ad: ",t),!this.providers.has(t.type)){Log.info(`Initializes Provider: [${t.type}]`);try{let e=new(m.providerClasses.get(t.type));await e.initProvider(),this.providers.set(t.type,e)}catch(e){Log.error(`Unable to instantiate Ad Provider: [${t.type}]`,t,e);continue}}let i=this.providers.get(t.type);o.has(t.type)||o.set(t.type,[]),t.provider=i;let n=null;if(t.displayType==c.REGULAR)n=s.get(t.selector,e);else if(t.displayType==c.CATFISH){if(n=h.getCurrentCatfishElement(),n){let e=s.get(".__alAd",n).ad;e.provider.refreshAds([e]),Log.info("Catfish already exists, just refresh its ad");continue}n=h.newCatfish(),t.injector="append"}n?(t.$container=i.createSlot(t,n),t.$container?(t.$container.ad=t,t.refreshCounter=0,i.addAd(t),o.get(t.type).push(t),t.autoRefresh?(t.$container.isInViewPort=!1,t.refreshTimer=new l((()=>{m.timerCallback(t)}),1e3*__adLib.refreshTimer),this.timers.push(t.refreshTimer),Log.info("This ad is autorefresh, added refresh timer: ",t.refreshTimer)):(t.refreshTimer=null,t.$container.isInViewPort=!0,Log.info("This ad is not autorefresh -> no refresh timer")),t.displayType==c.CATFISH?(Log.info("The ad is a catfish -> always in viewport and start refresh timer"),t.$container.isInViewPort=!0,t.refreshTimer&&t.refreshTimer.start()):t.autoRefresh&&(Log.info("Add the ad container to the observer -> ",t.$container),this.isInViewPortObserver.observe(t.$container)),Log.info("Ad initialized",t)):Log.info("Slot creation failed -> skip this ad")):Log.info("Error when initializing the ad/Existing ad -> skip it: ",t)}for(let[e,t]of o)0==t.length?Log.info(`No ads for [${e}] provider`):(Log.info(`Request Bids for [${e}] provider: `,t),this.providers.get(e).requestBids(t));if(__adLib.stickyContainerSelector){const t=s.getAll(`${__adLib.stickyContainerSelector} .__alAd`,e);let i=t.length;if(i>0){let e=t.item(i-1);Log.info("Last ad is sticky",e),s.addClass(e,"__alSticky",__adLib.stickyAdClass)}}}isInViewPortObserver=new IntersectionObserver((e=>{e.forEach((e=>{let t=e.target;t.isInViewPort=e.intersectionRatio>=__adLib.viewportThreshold,t.isInViewPort?(Log.info("Ad in viewport -> resume timer",t.ad),m.resumeRefreshTimer(t.ad)):(Log.info("Ad out of viewport -> stop timer",t.ad),m.pauseRefreshTimer(t.ad))}))}),{threshold:__adLib.viewportThreshold});static timerCallback(e){Log.info("Ad is refreshed.",e),e.refreshCounter++,e.provider.refreshAds([e])}static resumeRefreshTimer(e){Log.info("Resume refresh timer for ",e),e.refreshTimer.state==i.PAUSED?e.refreshTimer.resume():e.refreshTimer.state==i.STOPPED&&e.refreshTimer.start()}static pauseRefreshTimer(e){Log.info("Pause refresh timer for ",e),e.refreshTimer.pause()}pausedTimers=[];pauseAllRunningTimers(){this.pausedTimers=this.timers.filter((e=>e.state==i.RUNNING)),0!=this.pausedTimers.length&&(this.pausedTimers.forEach((e=>e.pause())),Log.info("Pause these timers: ",this.pausedTimers.map((e=>e.id))))}resumeAllPausedTimers(){0!=this.pausedTimers.length&&(this.pausedTimers.forEach((e=>e.resume())),Log.info("Resume these timers: ",this.pausedTimers.map((e=>e.id))))}refreshAllAds(){Log.info("Refresh All ads"),this.providers.forEach((e=>{Log.info(`will refresh ads for this provider: [${e.getName()}]`);for(let t of e.ads)t.refreshCounter++;e.refreshAllAds();for(let t of e.ads)t.refreshTimer&&t.refreshTimer.restart()}))}}n.isDefined(typeof window.__adLib)&&s.onDocumentReady((()=>{window.Log=new o(e[__adLib.logLevel]),window.Log.info("Ad Library Loaded"),window.AdsManager=new m,AdsManager.init()}));
//# sourceMappingURL=britannica-ads.cjs.js.map

@@ -1,2 +0,2 @@

var e,t,i;!function(e){e[e.Debug=0]="Debug",e[e.Info2=1]="Info2",e[e.Info=2]="Info",e[e.None=3]="None"}(e||(e={}));class o{static INFO_STYLE="font-weight:bold; background-color: #084466; color: white; border-radius:3px;display:inline-block;padding:2px 4px";static INFO_STYLE2="font-weight:bold; background-color: rebeccapurple; color: white; border-radius:3px;display:inline-block;padding:2px 4px";static ERR_STYLE="font-weight:bold; background-color: red; color: white; border-radius:3px;display:inline-block;padding:2px 4px;";static WARN_STYLE="font-weight:bold; background-color: orange; color: white; border-radius:3px;display:inline-block;padding:2px 4px;";static DEBUG_STYLE="font-weight:bold; background-color: #88A95B; color: white; border-radius:3px;display:inline-block;padding:2px 4px;";error=console.error.bind(window.console,"%cAd Lib",o.ERR_STYLE);warning=console.warn.bind(window.console,"%cAd Lib",o.WARN_STYLE);debug;info;info2;level;constructor(t){this.level=t,this.info=e.Info>=t?console.log.bind(window.console,"%cAd Lib",o.INFO_STYLE):()=>null,this.info2=e.Info2>=t?console.log.bind(window.console,"%cAd Lib",o.INFO_STYLE2):()=>null,this.debug=e.Debug>=t?console.debug.bind(window.console,"%cAd Lib",o.DEBUG_STYLE):()=>null}getLevel(){return this.level}}class n{static isDefined(e){return void 0!==e}static isFunction(e){return"function"==typeof e}}!function(e){e.before="beforeBegin",e.after="afterEnd",e.prepend="afterBegin",e.append="beforeEnd"}(t||(t={}));class s{static insert(e,t,i){t.insertAdjacentHTML(e,i)}static remove(e){e&&e.parentNode.removeChild(e)}static loadScript(e,t={}){return new Promise(((i,o)=>{let n=document.createElement("script");n.src=e,n.onload=()=>i(),n.onerror=()=>o();for(const[e,i]of Object.entries(t))n.setAttribute(e,i);document.head.append(n)}))}static css(e,t,i){e.style.setProperty(t,i)}static addClass(e,...t){t.forEach((t=>{t&&e.classList.add(t)}))}static removeClass(e,t){e.classList.remove(t)}static onDocumentReady(e){"loading"!=document.readyState?e():document.addEventListener("DOMContentLoaded",e)}static get(e,t=document.body){return t.querySelector(e)}static getAll(e,t=document.body){return t.querySelectorAll(e)}static setEventListener(e,t,i){e.addEventListener(t,i)}static removeEventListener(e,t,i){e.removeEventListener(t,i)}static onInViewPort(e,t){new IntersectionObserver(((i,o)=>{i.forEach((i=>{i.isIntersecting&&(t(e),o.disconnect(),o=null)}))}),{threshold:1}).observe(e)}static onScroll(e,t){window.addEventListener("scroll",function(e,t){var i=!1;return function(){i||(e(window.scrollY),i=!0,setTimeout((function(){i=!1}),t))}}(e,t))}static delayedCall(e,t){t?setTimeout(e,1e3*t):e()}}class a{static createCookieSession(e,t,i){document.cookie=`${e}=${t}; path=/${i?";domain="+i:""}`}static readCookie(e){return document.cookie.split("; ").find((t=>t.startsWith(`${e}=`))).split("=")[1]}static isCookieExists(e){return document.cookie.split(";").some((t=>t.trim().startsWith(`${e}=`)))}}class r{static substringBefore(e,t){if(!e||!t)return e;const i=e.indexOf(t);return-1==i?"":e.substring(0,i)}static substringAfter(e,t){if(!e||!t)return e;const i=e.indexOf(t);return-1==i?"":e.substring(i+1)}static defaultIfBlank(e,t){return e&&0!=e.length?e:t}}class d{static getJsonFromScriptSnippet(e,t=document.body){const i=s.get(`script[type="application/json"].${e}`,t);return i?d.elementContentToJson(i):null}static elementContentToJson(e){var t=e.innerText;try{return JSON.parse(t)}catch(e){return Log.error("JSON parsing error: ",e),null}}}!function(e){e.PAUSED="PAUSED",e.RUNNING="RUNNING",e.STOPPED="STOPPED"}(i||(i={}));class l{_id=(Date.now()+Math.floor(100*Math.random())).toString().slice(-5);_state=i.STOPPED;internalTimerId;restartTimerId;lastStart;remaining;callback;delay;constructor(e,t){this.callback=e,this.delay=t}get id(){return this._id}get state(){return this._state}callbackFn(){this.lastStart=Date.now(),this.remaining=this.delay,this.callback()}pause(){this.state==i.RUNNING&&(this.stopInternalTimer(),this.stopResumeTimer(),this.remaining-=Date.now()-this.lastStart,this._state=i.PAUSED,Log.debug(`Timer [${this._id}] Paused - Remaining [${this.remaining}ms]`))}resume(){this.state==i.PAUSED&&(this.restartTimerId=window.setTimeout((()=>{this.callback(),this.start()}),this.remaining),this.lastStart=Date.now(),this._state=i.RUNNING,Log.debug(`Timer [${this._id}] Resumed in [${this.remaining}ms].`))}stop(){this.state!=i.STOPPED&&(this.stopInternalTimer(),this.stopResumeTimer(),this.remaining=this.delay,this._state=i.STOPPED,Log.debug(`Timer [${this._id}] - Internal id [${this.internalTimerId}] Stopped`))}start(){this.lastStart=Date.now(),this.remaining=this.delay,this.internalTimerId=window.setInterval((()=>this.callbackFn()),this.delay),this._state=i.RUNNING,Log.debug(`Started Timer [${this._id}] - Internal id [${this.internalTimerId}]`)}restart(){this.stop(),this.start()}stopInternalTimer(){this.internalTimerId&&(window.clearInterval(this.internalTimerId),this.internalTimerId=null)}stopResumeTimer(){this.restartTimerId&&(window.clearTimeout(this.restartTimerId),this.restartTimerId=null)}}var c,g;!function(e,t){void 0===t&&(t={});var i=t.insertAt;if(e&&"undefined"!=typeof document){var o=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css","top"===i&&o.firstChild?o.insertBefore(n,o.firstChild):o.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}}('/* banner ad */\n.__alAd {\n overflow: hidden;\n display: block;\n}\n.__alAd iframe {\n overflow: hidden;\n}\n\n/* sticky ad */\n.__alSticky {\n top: 0;\n position: sticky;\n}\n\n/* catfish */\n.__alCatfish {\n position: fixed;\n bottom: 0;\n left: 0;\n right: 0;\n margin: auto;\n z-index: 1030;\n width: fit-content;\n}\n\n/* preroll ad */\n.__alPrerollContainer {\n position: relative !important;\n}\n\n.__alPrerollWrapper {\n position: absolute;\n width: 100%;\n height: 100%;\n display: table;\n background: black url("https://cdn.britannica.com/ads/resources/loading.gif") center center no-repeat;\n}\n\n#__alPreroll {\n display: table-cell;\n vertical-align: middle;\n}\n\n/* inline ad */\n.__alInline {\n text-align: center;\n margin: 0 auto 20px auto;\n}\n.__alInline::before {\n border-bottom: 1px solid #ddd;\n color: #aaa;\n content: "Advertisement - Continue reading below";\n display: block;\n font-family: "Helvetica", "Segoe UI", "Arial", sans-serif;\n font-size: 11px;\n font-weight: bold;\n margin-bottom: 20px;\n padding-bottom: 5px;\n clear: left;\n}'),function(e){e.REGULAR="REGULAR",e.CATFISH="CATFISH"}(c||(c={}));class f{static US_PrivacyCookieName="usprivacy";static US_PrivacyCookieDuration=365;static init(){Log.info2("Init IAB: Insert iframe locator into body"),s.insert(t.append,document.body,'<iframe name="__uspapiLocator" style="display:none;height:0;opacity:0;visibility:hidden;border:0;width:0;"></iframe>'),Log.info2("Install IAB message handler"),window.addEventListener("message",f.optOutMsgHandler,!1),Log.info2("Install global __uspapi function"),window.__uspapi=(e,t,i)=>{if(Log.info2(`IAB: __uspapi function called. Command: [${e}] `),"getuspdata"===e.toLowerCase()){var o={version:t,uspString:a.readCookie(f.US_PrivacyCookieName)};Log.info2("IAB: getuspdata command. Response: ",o),i(o,null!=o.uspString)}},a.isCookieExists(f.US_PrivacyCookieName)||(__adLib.usPrivacyConsent?(Log.info2("IAB: US privacy consent needed (CCPA), create default cookie [1YNY]"),f.createCookie(1,!0,!1,!0)):(Log.info2("IAB: No US privacy consent needed, create default cookie [1---]"),f.createCookie()))}static createCookie(e=1,t,i,o){var n=e=>!0===e?"Y":!1===e?"N":"-",s=e.toString()+n(t)+n(i)+n(o),a=`${f.US_PrivacyCookieName}=${s}; `,r=new Date;r.setTime(r.getTime()+24*f.US_PrivacyCookieDuration*60*60*1e3);var d=`expires=${r.toUTCString()}; `;document.cookie=a+d+"path=/; SameSite=Lax; "}static optOutMsgHandler(e){let t,i="string"==typeof e.data;if(t=i?-1!==e.data.indexOf("__uspapiCall")?JSON.parse(e.data):{}:e.data,t.__uspapiCall){Log.info2("Received __uspapiCall event. Will post message to sender with the cookie content");var o=t.__uspapiCall;window.__uspapi(o.command,o.version,(function(t,n){var s={__uspapiReturn:{returnValue:t,success:n,callId:o.callId}};let a=e.source;Log.info2("IAB: post message back ",s,a),a.postMessage(i?JSON.stringify(s):s,"*")}))}}}!function(e){e.DFP="DFP"}(g||(g={}));class p extends class{type;ads;constructor(){this.ads=[],this.type=this.getType()}addAd(e){this.ads.push(e)}}{static PAGELOAD_TARGETING="PAGELOAD";index=1;getName(){return"Google DFP"}getType(){return g.DFP}constructor(){super()}async initProvider(){if(window.googletag={cmd:[]},!n.isDefined(window.googletag.defineSlot))try{await s.loadScript("https://securepubads.g.doubleclick.net/tag/js/gpt.js")}catch(e){throw Log.error("**** Unable to load gpt.js -> most ads and scripts will be broken ***"),e}if(class{static async loadPrebidScript(){if(!__adLib.videoForPrebidLoaded&&!n.isDefined(window.pbjs)){Log.info(`Loading [${__adLib.prebidScriptUrl}] prebid script now`),window.pbjs={que:[]};try{await s.loadScript(__adLib.prebidScriptUrl)}catch(e){return void Log.error(`Unable to load [${__adLib.prebidScriptUrl}] prebid script -> skip ad`)}__adLib.videoForPrebidLoaded=!0}}}.loadPrebidScript(),!n.isDefined(window.headertag)&&__adLib.includeIndex)try{await s.loadScript(__adLib.indexScriptUrl)}catch(e){Log.error(`Unable to load [${__adLib.indexScriptUrl}] Index script. We won't use it.`)}if(!n.isDefined(window.apstag)&&__adLib.includeA9)try{await s.loadScript("https://c.amazon-adsystem.com/aax2/apstag.js"),function(e,t){function i(i,o){t[e]._Q.push([i,o])}t[e]||(t[e]={init:function(){i("i",arguments)},fetchBids:function(){i("f",arguments)},setDisplayBids:function(){},targetingKeys:function(){return[]},_Q:[]})}("apstag",window)}catch(e){Log.error("Unable to load A9 script. Will disable it"),__adLib.includeA9=!1}googletag.cmd.push((function(){if(googletag.pubads().setTargeting("dc_ref",__adLib.url),n.isDefined(Storage)){var e=localStorage.getItem("bcDFPTargetingParams");if(e)Log.info("Setting Blueconic targeting parameters"),JSON.parse(e).forEach((e=>googletag.pubads().setTargeting(e.key,e.value)))}if(Log.info(`targeting: ${googletag.pubads().getTargetingKeys()}`),googletag.pubads().disableInitialLoad(),googletag.pubads().enableSingleRequest(),googletag.pubads().enableAsyncRendering(),googletag.pubads().setTagForChildDirectedTreatment(0),googletag.pubads().setTagForUnderAgeOfConsent(0),__adLib.dfpLazyLoad&&googletag.pubads().enableLazyLoad(__adLib.dfpLazyLoadParameters),googletag.enableServices(),__adLib.includeA9){var t={pubID:__adLib.a9Id,adServer:"googletag",bidTimeout:1200};__uspapi&&__uspapi("getuspdata","1",((e,i)=>{i&&(t.params={us_privacy:e.uspString})})),Log.info("Init A9 with ",t),apstag.init(t)}}))}createSlot(e,t){return this.initSlot(e,t)}initSlot(e,i){try{Log.info("process DFP ad: ",e);var o=e.adParameters,n=o.size[0][0],a=o.size[0][1];Log.info("Content container for this ad is ",i);var d="";if(e.displayType!=c.CATFISH)if(o.placeholderSize)d=`min-width:${r.substringBefore(o.placeholderSize,"x")}px;min-height:${r.substringAfter(o.placeholderSize,"x")}px;`;else if(1==o.size.length)d=`width:${n}px;height:${a}px;`;else{d=`min-height:${Math.round(o.size.map((e=>e[1])).reduce(((e,t)=>e+t))/o.size.length)}px;`}var l="DFP_"+this.index++;e.containerId=l,e.dfpSize=1==o.size.length?o.size[0]:o.size;var g=`style="${d}${r.defaultIfBlank(o.style,"")}"`,f=`<div data-type="${e.type}" class="__alAd ${r.defaultIfBlank(__adLib.adClass,"")} ${r.defaultIfBlank(o.cssClass,"")}" ${g} id="${l}"></div>`;Log.info(`Inject DIV: [${f}] into `,i),s.insert(t[e.injector],i,f),this.setDfpA9Slot(e);let p=s.get(`#${l}`);return p.setAttribute("data-identifier",e.dfpSlot.getAdUnitPath()),p}catch(t){return Log.error("Init Slot Error: ",e,t),null}}setDfpA9Slot=function(e){Log.info("Initializes DFP slot and A9 slot for ",e);var t=e.adParameters,i=__adLib.dfpIdPrefix.replace("${LEG}",__adLib.leg)+(__adLib.isPhone?"MOBILE":"DESKTOP")+"_",o=`/${__adLib.googleDfpId}/${i}${t.id}`;Log.info(`Define new slot: [${o}] with: size [${e.dfpSize}] id [${e.containerId}]`),e.dfpSlot=googletag.defineSlot(o,e.dfpSize,e.containerId),t.targeting&&Object.entries(t.targeting).forEach((([t,i])=>{e.dfpSlot.setTargeting(t,String(i))})),e.dfpSlot.addService(googletag.pubads()),__adLib.includeIndex&&(e.a9Slot={slotID:e.containerId,slotName:o,sizes:t.size}),Log.info("DFP/A9 slot defined for ",e)};refreshAllAds(){Log.info("Refresh all DFP ads."),googletag.cmd.push((()=>{p.setPageLoadTargeting(this.ads),this.refreshSlots()}))}requestBids(e){this.refreshAds(e)}refreshAds(e){Log.info("Refresh ads: ",e),googletag.cmd.push((()=>{p.setPageLoadTargeting(e),this.refreshSlots(e)}))}static setPageLoadTargeting(e){for(let t of e){const e=`REFRESH${t.refreshCounter}`;Log.info(`Update ${p.PAGELOAD_TARGETING} targeting ${e} for `,t),t.dfpSlot.setTargeting(p.PAGELOAD_TARGETING,e)}}refreshSlots(t=this.ads){Log.info("Refresh slots - ads : ",t);let i=!1,o=!1,n=!1,s=()=>{n||!o||!i&&__adLib.includeA9||(-1!=c&&window.clearTimeout(c),Log.info("Prebid is completed and A9 completed or disabled -> call DFP"),a())},a=()=>{Log.info("Refresh ads ",t);let e=t.map((e=>e.dfpSlot));Log.info("Refresh DFP slots ",e),googletag.pubads().refresh(e)},r=[];for(let e of t)r.push({code:e.dfpSlot.getAdUnitPath(),mediaTypes:{banner:{sizes:e.adParameters.size}},bids:__adLib.prebidBannerBiddersConfiguration});Log.info("Prebid ad unit configuration: ",r);let d={...__adLib.prebidConfiguration,debug:Log.getLevel()==e.Debug};if(__adLib.includeA9){var l=t.map((e=>e.a9Slot));Log.info("Calls A9 with these slots:",l),apstag.fetchBids({slots:l},(()=>{Log.info("A9 bid request completed"),apstag.setDisplayBids(),i=!0,s()}))}pbjs.que.push((()=>{Log.info("Set Prebid Config: ",d),pbjs.setConfig(d),pbjs.addAdUnits(r),Log.info("Request Prebid bids"),pbjs.requestBids({timeout:__adLib.prebidTimeout,bidsBackHandler:()=>{Log.info("Prebid request bid completed"),pbjs.setTargetingForGPTAsync(t.map((e=>e.dfpSlot.getAdUnitPath()))),o=!0,s()}})}));let c=-1;0!=__adLib.biddersFailsafeTimeout&&(Log.info(`Bidders failsafe timeout set to [${__adLib.biddersFailsafeTimeout}] ms`),c=window.setTimeout((()=>{Log.info("Bidding Timeout! -> calls DFP directly"),n=!0,a()}),__adLib.biddersFailsafeTimeout))}}class u{static async init(){if(__adLib.requiresConsent){if(!n.isDefined(window.__tcfapi)){Log.info2("__tcfapi not found -> Will load the oneTrust scripts");try{await s.loadScript("https://cdn.cookielaw.org/consent/cmp.stub.js",{"data-domain-script":__adLib.oneTrustId})}catch(e){throw Log.error("Unable to load oneTrust cmp.stub.js script"),e}try{await s.loadScript("https://cdn.cookielaw.org/scripttemplates/otSDKStub.js",{"data-domain-script":__adLib.oneTrustId})}catch(e){throw Log.error("Unable to load oneTrust otSDKStub.js script "),e}Log.info2("oneTrust scripts loaded")}Log.info2("set OptanonWrapper function"),window.OptanonWrapper=()=>{Log.info2(`OptanonWrapper called. Defer Ads status is [${u.getDeferAdsStatus()}]`),u.getDeferAdsStatus()&&(Log.info2("Defer Ads status is true -> Set Read TCData callback"),window.__tcfapi("getTCData",2,((e,t)=>{if(Log.info2(`TCData read: success = [${t}] data = `,e),!t||u.statusOk(e))return Log.info2("Error or status already OK -> send message to the app to load the ads immediately "),void u.setDeferAdsStatus(!1);const i=(e,t)=>{Log.info2("Received __tcpapi status change Event: ",e),t&&u.statusOk(e)&&(Log.info2("Status now OK, remove the event listener and send message to the app to load the ads immediately"),window.__tcfapi("removeEventListener",2,i),u.setDeferAdsStatus(!1))};Log.info2("Status not OK yet. Set event listener to load the ads when it will be OK"),window.__tcfapi("addEventListener",2,i)})))},Log.info2("Defer the ads loading by default"),u.setDeferAdsStatus(!0)}else Log.info2("Not Consent Required")}static getDeferAdsStatus(){return __adLib.deferAds}static setDeferAdsStatus(e){__adLib.deferAds=e,e||document.dispatchEvent(new Event("endDeferAds"))}static statusOk(e){return"useractioncomplete"==e.eventStatus||"tcloaded"==e.eventStatus}static onDNSMILinkClicked(){Log.info2("CCPA consent called"),Log.info2("create default IAB cookie [1YYY]"),f.createCookie(1,!0,!0,!0),Log.info2("Modifies onetrust OptanonConsent cookies and ActiveGroups global variables");let e=[4],t=decodeURIComponent(a.readCookie("OptanonConsent "));Log.info2("Current OptanonConsent cookie value = ",t);for(let i of e)t=t.replace(`,${i}:1,`,`,${i}:0,`),window.OptanonActiveGroups=window.OptanonActiveGroups.replace(`,${i},`,","),window.OnetrustActiveGroups=window.OnetrustActiveGroups.replace(`,${i},`,",");Log.info2("New OptanonConsent cookie value = ",t),Log.info2(`New OptanonActiveGroups = [${window.OptanonActiveGroups}]`),Log.info2(`New OneTrustActiveGroups = [${window.OnetrustActiveGroups}]`),a.createCookieSession("OptanonConsent",encodeURI(t),__adLib.topDomain),a.createCookieSession("EbConsentClosed","true"),Log.info2("created new OptanonConsent and EbConsentClosed cookies")}}class h{static CATFISH_ID="AD_STATIC_CATFISH";static newCatfish(e,i){Log.info("Create a catfish container");var o=`<div id="${h.CATFISH_ID}" class="__alCatfish" style=" ${e?`width:${e}px;`:""} ${i?`height:${i}px`:""}"></div>`;return s.insert(t.append,document.body,o),Log.info("Static Catfish Inserted",h.getCurrentCatfishElement()),h.getCurrentCatfishElement()}static getCurrentCatfishElement(){return s.get(`#${h.CATFISH_ID}`)}}class m{static providerClasses=new Map([[g.DFP,p]]);providers=new Map;timers=[];isAdBlockerActivated(){var e=s.get("#_MGS_");e||(s.insert(t.append,document.body,'<div id="_MGS_"><div class="adBanner" style="height:1px"></div></div>'),e=s.get("#_MGS_"));var i=s.get("div",e);return"none"===window.getComputedStyle(i).display}async init(){Log.info("Init Ads manager at page load"),f.init(),await u.init(),Log.info("Set tab visibility event handler"),s.setEventListener(document,"visibilitychange",(()=>{var e="visible"===document.visibilityState;Log.info(`Tab visibility changed to [${e}]`),e?this.resumeAllPausedTimers():this.pauseAllRunningTimers()})),__adLib.deferAds?(Log.info("Ads need to be deferred. Will wait until the [endDeferAds] is fired"),s.setEventListener(document,"endDeferAds",(()=>{Log.info("Deferred Ads event triggered. Will now initialize the ads"),this.contentLoadInit()}))):(Log.info("No deferred ads. Will initialize the ads now"),this.contentLoadInit())}async contentLoadInit(e=document.body){Log.info(" ============================================================================================="),Log.info("Initialize container with ads"),Log.info(" ============================================================================================="),Log.info("Look for json ads definition in ",e);var t=d.getJsonFromScriptSnippet("ads-script",e);if(!t)return void Log.info("Did not find ads definition.");var i=t;if(!i)return;Log.info("Found ad definitions: ",i);let o=new Map;for(let t of i){if(Log.info("Init this ad: ",t),!this.providers.has(t.type)){Log.info(`Initializes Provider: [${t.type}]`);try{let e=new(m.providerClasses.get(t.type));await e.initProvider(),this.providers.set(t.type,e)}catch(e){Log.error(`Unable to instantiate Ad Provider: [${t.type}]`,t,e);continue}}var n=this.providers.get(t.type);o.has(t.type)||o.set(t.type,[]),t.provider=n;let i=null;if(t.displayType==c.REGULAR)i=s.get(t.selector,e);else if(t.displayType==c.CATFISH){if(i=h.getCurrentCatfishElement(),i){let e=s.get(".__alAd",i).ad;e.provider.refreshAds([e]),Log.info("Catfish already exists, just refresh its ad");continue}i=h.newCatfish(),t.injector="append"}i?(t.$container=n.createSlot(t,i),t.$container?(t.$container.ad=t,t.refreshCounter=0,n.addAd(t),o.get(t.type).push(t),t.autoRefresh?(t.$container.isInViewPort=!1,t.refreshTimer=new l((()=>{m.timerCallback(t)}),1e3*__adLib.refreshTimer),this.timers.push(t.refreshTimer),Log.info("This ad is autorefresh, added refresh timer: ",t.refreshTimer)):(t.refreshTimer=null,t.$container.isInViewPort=!0,Log.info("This ad is not autorefresh -> no refresh timer")),t.displayType==c.CATFISH?(Log.info("The ad is a catfish -> always in viewport and start refresh timer"),t.$container.isInViewPort=!0,t.refreshTimer&&t.refreshTimer.start()):t.autoRefresh&&(Log.info("Add the ad container to the observer -> ",t.$container),this.isInViewPortObserver.observe(t.$container)),Log.info("Ad initialized",t)):Log.info("Slot creation failed -> skip this ad")):Log.info("Error when initializing the ad/Existing ad -> skip it: ",t)}for(let[e,t]of o)0==t.length?Log.info(`No ads for [${e}] provider`):(Log.info(`Request Bids for [${e}] provider: `,t),this.providers.get(e).requestBids(t));if(__adLib.stickyContainerSelector){const t=s.getAll(`${__adLib.stickyContainerSelector} .__alAd`,e);var a=t.length;if(a>0){let e=t.item(a-1);Log.info("Last ad is sticky",e),s.addClass(e,"__alSticky",__adLib.stickyAdClass)}}}isInViewPortObserver=new IntersectionObserver((e=>{e.forEach((e=>{var t=e.target;t.isInViewPort=e.intersectionRatio>=__adLib.viewportThreshold,t.isInViewPort?(Log.info("Ad in viewport -> resume timer",t.ad),m.resumeRefreshTimer(t.ad)):(Log.info("Ad out of viewport -> stop timer",t.ad),m.pauseRefreshTimer(t.ad))}))}),{threshold:__adLib.viewportThreshold});static timerCallback(e){Log.info("Ad is refreshed.",e),e.refreshCounter++,e.provider.refreshAds([e])}static resumeRefreshTimer(e){Log.info("Resume refresh timer for ",e),e.refreshTimer.state==i.PAUSED?e.refreshTimer.resume():e.refreshTimer.state==i.STOPPED&&e.refreshTimer.start()}static pauseRefreshTimer(e){Log.info("Pause refresh timer for ",e),e.refreshTimer.pause()}pausedTimers=[];pauseAllRunningTimers(){this.pausedTimers=this.timers.filter((e=>e.state==i.RUNNING)),0!=this.pausedTimers.length&&(this.pausedTimers.forEach((e=>e.pause())),Log.info("Pause these timers: ",this.pausedTimers.map((e=>e.id))))}resumeAllPausedTimers(){0!=this.pausedTimers.length&&(this.pausedTimers.forEach((e=>e.resume())),Log.info("Resume these timers: ",this.pausedTimers.map((e=>e.id))))}refreshAllAds(){Log.info("Refresh All ads"),this.providers.forEach((e=>{Log.info(`will refresh ads for this provider: [${e.getName()}]`);for(let t of e.ads)t.refreshCounter++;e.refreshAllAds();for(let t of e.ads)t.refreshTimer&&t.refreshTimer.restart()}))}}n.isDefined(typeof window.__adLib)&&s.onDocumentReady((()=>{window.Log=new o(e[__adLib.logLevel]),window.Log.info("Ad Library Loaded"),window.AdsManager=new m,AdsManager.init()}));
var e,t,i;!function(e){e[e.Debug=0]="Debug",e[e.Info2=1]="Info2",e[e.Info=2]="Info",e[e.None=3]="None"}(e||(e={}));class o{static INFO_STYLE="font-weight:bold; background-color: #084466; color: white; border-radius:3px;display:inline-block;padding:2px 4px";static INFO_STYLE2="font-weight:bold; background-color: rebeccapurple; color: white; border-radius:3px;display:inline-block;padding:2px 4px";static ERR_STYLE="font-weight:bold; background-color: red; color: white; border-radius:3px;display:inline-block;padding:2px 4px;";static WARN_STYLE="font-weight:bold; background-color: orange; color: white; border-radius:3px;display:inline-block;padding:2px 4px;";static DEBUG_STYLE="font-weight:bold; background-color: #88A95B; color: white; border-radius:3px;display:inline-block;padding:2px 4px;";error=console.error.bind(window.console,"%cAd Lib",o.ERR_STYLE);warning=console.warn.bind(window.console,"%cAd Lib",o.WARN_STYLE);debug;info;info2;level;constructor(t){this.level=t,this.info=e.Info>=t?console.log.bind(window.console,"%cAd Lib",o.INFO_STYLE):()=>null,this.info2=e.Info2>=t?console.log.bind(window.console,"%cAd Lib",o.INFO_STYLE2):()=>null,this.debug=e.Debug>=t?console.debug.bind(window.console,"%cAd Lib",o.DEBUG_STYLE):()=>null}getLevel(){return this.level}}class n{static isDefined(e){return void 0!==e}static isFunction(e){return"function"==typeof e}}!function(e){e.before="beforeBegin",e.after="afterEnd",e.prepend="afterBegin",e.append="beforeEnd"}(t||(t={}));class s{static insert(e,t,i){t.insertAdjacentHTML(e,i)}static remove(e){e&&e.parentNode.removeChild(e)}static loadScript(e,t={}){return new Promise(((i,o)=>{let n=document.createElement("script");n.src=e,n.onload=()=>i(),n.onerror=()=>o();for(const[e,i]of Object.entries(t))n.setAttribute(e,i);document.head.append(n)}))}static css(e,t,i){e.style.setProperty(t,i)}static addClass(e,...t){t.forEach((t=>{t&&e.classList.add(t)}))}static removeClass(e,t){e.classList.remove(t)}static onDocumentReady(e){"loading"!=document.readyState?e():document.addEventListener("DOMContentLoaded",e)}static get(e,t=document.body){return t.querySelector(e)}static getAll(e,t=document.body){return t.querySelectorAll(e)}static setEventListener(e,t,i){e.addEventListener(t,i)}static removeEventListener(e,t,i){e.removeEventListener(t,i)}static onInViewPort(e,t){new IntersectionObserver(((i,o)=>{i.forEach((i=>{i.isIntersecting&&(t(e),o.disconnect(),o=null)}))}),{threshold:1}).observe(e)}static onScroll(e,t){window.addEventListener("scroll",function(e,t){let i=!1;return function(){i||(e(window.scrollY),i=!0,setTimeout((function(){i=!1}),t))}}(e,t))}static delayedCall(e,t){t?setTimeout(e,1e3*t):e()}}class a{static createCookieSession(e,t,i){document.cookie=`${e}=${t}; path=/${i?";domain="+i:""}`}static readCookie(e){return document.cookie.split("; ").find((t=>t.startsWith(`${e}=`))).split("=")[1]}static isCookieExists(e){return document.cookie.split(";").some((t=>t.trim().startsWith(`${e}=`)))}}class r{static substringBefore(e,t){if(!e||!t)return e;const i=e.indexOf(t);return-1==i?"":e.substring(0,i)}static substringAfter(e,t){if(!e||!t)return e;const i=e.indexOf(t);return-1==i?"":e.substring(i+1)}static defaultIfBlank(e,t){return e&&0!=e.length?e:t}}class d{static getJsonFromScriptSnippet(e,t=document.body){const i=s.get(`script[type="application/json"].${e}`,t);return i?d.elementContentToJson(i):null}static elementContentToJson(e){let t=e.innerText;try{return JSON.parse(t)}catch(e){return Log.error("JSON parsing error: ",e),null}}}!function(e){e.PAUSED="PAUSED",e.RUNNING="RUNNING",e.STOPPED="STOPPED"}(i||(i={}));class l{_id=(Date.now()+Math.floor(100*Math.random())).toString().slice(-5);_state=i.STOPPED;internalTimerId;restartTimerId;lastStart;remaining;callback;delay;constructor(e,t){this.callback=e,this.delay=t}get id(){return this._id}get state(){return this._state}callbackFn(){this.lastStart=Date.now(),this.remaining=this.delay,this.callback()}pause(){this.state==i.RUNNING&&(this.stopInternalTimer(),this.stopResumeTimer(),this.remaining-=Date.now()-this.lastStart,this._state=i.PAUSED,Log.debug(`Timer [${this._id}] Paused - Remaining [${this.remaining}ms]`))}resume(){this.state==i.PAUSED&&(this.restartTimerId=window.setTimeout((()=>{this.callback(),this.start()}),this.remaining),this.lastStart=Date.now(),this._state=i.RUNNING,Log.debug(`Timer [${this._id}] Resumed in [${this.remaining}ms].`))}stop(){this.state!=i.STOPPED&&(this.stopInternalTimer(),this.stopResumeTimer(),this.remaining=this.delay,this._state=i.STOPPED,Log.debug(`Timer [${this._id}] - Internal id [${this.internalTimerId}] Stopped`))}start(){this.lastStart=Date.now(),this.remaining=this.delay,this.internalTimerId=window.setInterval((()=>this.callbackFn()),this.delay),this._state=i.RUNNING,Log.debug(`Started Timer [${this._id}] - Internal id [${this.internalTimerId}]`)}restart(){this.stop(),this.start()}stopInternalTimer(){this.internalTimerId&&(window.clearInterval(this.internalTimerId),this.internalTimerId=null)}stopResumeTimer(){this.restartTimerId&&(window.clearTimeout(this.restartTimerId),this.restartTimerId=null)}}var c,g;!function(e,t){void 0===t&&(t={});var i=t.insertAt;if(e&&"undefined"!=typeof document){var o=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css","top"===i&&o.firstChild?o.insertBefore(n,o.firstChild):o.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}}('/* banner ad */\n.__alAd {\n overflow: hidden;\n display: block;\n margin-left: auto;\n margin-right: auto;\n}\n\n.__alAd > div {\n text-align: center !important;\n display: block !important;\n margin: auto !important;\n}\n\n.__alAd > div > iframe,\n.__alAd > div > div {\n display: block !important;\n margin: auto !important;\n}\n\n/* sticky ad */\n.__alSticky {\n top: 0;\n position: sticky;\n}\n\n/* catfish */\n.__alCatfish {\n position: fixed;\n bottom: 0;\n left: 0;\n right: 0;\n margin: auto;\n z-index: 1030;\n width: fit-content;\n}\n\n/* preroll ad */\n.__alPrerollContainer {\n position: relative !important;\n}\n\n.__alPrerollWrapper {\n position: absolute;\n width: 100%;\n height: 100%;\n display: table;\n background: black url("https://cdn.britannica.com/ads/resources/loading.gif") center center no-repeat;\n}\n\n#__alPreroll {\n display: table-cell;\n vertical-align: middle;\n}\n\n/* inline ad */\n.__alInline {\n text-align: center;\n margin: 0 auto 20px auto;\n}\n.__alInline::before {\n border-bottom: 1px solid #ddd;\n color: #aaa;\n content: "Advertisement - Continue reading below";\n display: block;\n font-family: "Helvetica", "Segoe UI", "Arial", sans-serif;\n font-size: 11px;\n font-weight: bold;\n margin-bottom: 20px;\n padding-bottom: 5px;\n clear: left;\n}'),function(e){e.REGULAR="REGULAR",e.CATFISH="CATFISH"}(c||(c={}));class p{static US_PrivacyCookieName="usprivacy";static US_PrivacyCookieDuration=365;static init(){Log.info2("Init IAB: Insert iframe locator into body"),s.insert(t.append,document.body,'<iframe name="__uspapiLocator" style="display:none;height:0;opacity:0;visibility:hidden;border:0;width:0;"></iframe>'),Log.info2("Install IAB message handler"),window.addEventListener("message",p.optOutMsgHandler,!1),Log.info2("Install global __uspapi function"),window.__uspapi=(e,t,i)=>{if(Log.info2(`IAB: __uspapi function called. Command: [${e}] `),"getuspdata"===e.toLowerCase()){let e={version:t,uspString:a.readCookie(p.US_PrivacyCookieName)};Log.info2("IAB: getuspdata command. Response: ",e),i(e,null!=e.uspString)}},a.isCookieExists(p.US_PrivacyCookieName)||(__adLib.usPrivacyConsent?(Log.info2("IAB: US privacy consent needed (CCPA), create default cookie [1YNY]"),p.createCookie(1,!0,!1,!0)):(Log.info2("IAB: No US privacy consent needed, create default cookie [1---]"),p.createCookie()))}static createCookie(e=1,t,i,o){let n=e=>!0===e?"Y":!1===e?"N":"-",s=e.toString()+n(t)+n(i)+n(o),a=`${p.US_PrivacyCookieName}=${s}; `,r=new Date;r.setTime(r.getTime()+24*p.US_PrivacyCookieDuration*60*60*1e3);let d=`expires=${r.toUTCString()}; `;document.cookie=a+d+"path=/; SameSite=Lax; "}static optOutMsgHandler(e){let t,i="string"==typeof e.data;if(t=i?-1!==e.data.indexOf("__uspapiCall")?JSON.parse(e.data):{}:e.data,t.__uspapiCall){Log.info2("Received __uspapiCall event. Will post message to sender with the cookie content");let o=t.__uspapiCall;window.__uspapi(o.command,o.version,(function(t,n){let s={__uspapiReturn:{returnValue:t,success:n,callId:o.callId}},a=e.source;Log.info2("IAB: post message back ",s,a),a.postMessage(i?JSON.stringify(s):s,"*")}))}}}!function(e){e.DFP="DFP"}(g||(g={}));class f extends class{type;ads;constructor(){this.ads=[],this.type=this.getType()}addAd(e){this.ads.push(e)}}{static PAGELOAD_TARGETING="PAGELOAD";index=1;getName(){return"Google DFP"}getType(){return g.DFP}constructor(){super()}async initProvider(){if(window.googletag={cmd:[]},!n.isDefined(window.googletag.defineSlot))try{await s.loadScript("https://securepubads.g.doubleclick.net/tag/js/gpt.js")}catch(e){throw Log.error("**** Unable to load gpt.js -> most ads and scripts will be broken ***"),e}if(class{static async loadPrebidScript(){if(!__adLib.videoForPrebidLoaded&&!n.isDefined(window.pbjs)){Log.info(`Loading [${__adLib.prebidScriptUrl}] prebid script now`),window.pbjs={que:[]};try{await s.loadScript(__adLib.prebidScriptUrl)}catch(e){return void Log.error(`Unable to load [${__adLib.prebidScriptUrl}] prebid script -> skip ad`)}__adLib.videoForPrebidLoaded=!0}}}.loadPrebidScript(),!n.isDefined(window.headertag)&&__adLib.includeIndex)try{await s.loadScript(__adLib.indexScriptUrl)}catch(e){Log.error(`Unable to load [${__adLib.indexScriptUrl}] Index script. We won't use it.`)}if(!n.isDefined(window.apstag)&&__adLib.includeA9)try{await s.loadScript("https://c.amazon-adsystem.com/aax2/apstag.js"),function(e,t){function i(i,o){t[e]._Q.push([i,o])}t[e]||(t[e]={init:function(){i("i",arguments)},fetchBids:function(){i("f",arguments)},setDisplayBids:function(){},targetingKeys:function(){return[]},_Q:[]})}("apstag",window)}catch(e){Log.error("Unable to load A9 script. Will disable it"),__adLib.includeA9=!1}googletag.cmd.push((function(){if(googletag.pubads().setTargeting("dc_ref",__adLib.url),n.isDefined(Storage)){let e=localStorage.getItem("bcDFPTargetingParams");if(e){Log.info("Setting Blueconic targeting parameters"),JSON.parse(e).forEach((e=>googletag.pubads().setTargeting(e.key,e.value)))}}if(Log.info(`targeting: ${googletag.pubads().getTargetingKeys()}`),googletag.pubads().disableInitialLoad(),googletag.pubads().enableSingleRequest(),googletag.pubads().enableAsyncRendering(),googletag.pubads().setTagForChildDirectedTreatment(0),googletag.pubads().setTagForUnderAgeOfConsent(0),__adLib.dfpLazyLoad&&googletag.pubads().enableLazyLoad(__adLib.dfpLazyLoadParameters),googletag.enableServices(),__adLib.includeA9){let e={pubID:__adLib.a9Id,adServer:"googletag",bidTimeout:1200};__uspapi&&__uspapi("getuspdata","1",((t,i)=>{i&&(e.params={us_privacy:t.uspString})})),Log.info("Init A9 with ",e),apstag.init(e)}}))}createSlot(e,t){return this.initSlot(e,t)}initSlot(e,i){try{Log.info("process DFP ad: ",e);let o=e.adParameters,n=o.size[0][0],a=o.size[0][1];Log.info("Content container for this ad is ",i);let d="";if(e.displayType!=c.CATFISH)if(o.placeholderSize)d=`min-width:${r.substringBefore(o.placeholderSize,"x")}px;min-height:${r.substringAfter(o.placeholderSize,"x")}px;`;else if(1==o.size.length)d=`width:${n}px;height:${a}px;`;else{d=`min-height:${Math.round(o.size.map((e=>e[1])).reduce(((e,t)=>e+t))/o.size.length)}px;`}let l="DFP_"+this.index++;e.containerId=l,e.dfpSize=1==o.size.length?o.size[0]:o.size;let g=`style="${d}${r.defaultIfBlank(o.style,"")}"`,p=`<div data-type="${e.type}" class="__alAd ${r.defaultIfBlank(__adLib.adClass,"")} ${r.defaultIfBlank(o.cssClass,"")}" ${g} id="${l}"></div>`;Log.info(`Inject DIV: [${p}] into `,i),s.insert(t[e.injector],i,p);let f=this.setDfpA9Slot(e),u=s.get(`#${l}`);return u.setAttribute("data-identifier",e.dfpSlot.getAdUnitPath()),u.setAttribute("data-qa-identifier",f),u}catch(t){return Log.error("Init Slot Error: ",e,t),null}}setDfpA9Slot=function(e){Log.info("Initializes DFP slot and A9 slot for ",e);let t=e.adParameters,i=__adLib.dfpIdPrefix.replace("${LEG}",__adLib.leg),o=`${__adLib.isPhone?"MOBILE":"DESKTOP"}_${t.id}`,n=`/${__adLib.googleDfpId}/${i}${o}`;return Log.info(`Define new slot: [${n}] with: size [${e.dfpSize}] id [${e.containerId}]`),e.dfpSlot=googletag.defineSlot(n,e.dfpSize,e.containerId),t.targeting&&Object.entries(t.targeting).forEach((([t,i])=>{e.dfpSlot.setTargeting(t,String(i))})),e.dfpSlot.addService(googletag.pubads()),__adLib.includeIndex&&(e.a9Slot={slotID:e.containerId,slotName:n,sizes:t.size}),Log.info("DFP/A9 slot defined for ",e),o};refreshAllAds(){Log.info("Refresh all DFP ads."),googletag.cmd.push((()=>{f.setPageLoadTargeting(this.ads),this.refreshSlots()}))}requestBids(e){this.refreshAds(e)}refreshAds(e){Log.info("Refresh ads: ",e),googletag.cmd.push((()=>{f.setPageLoadTargeting(e),this.refreshSlots(e)}))}static setPageLoadTargeting(e){for(let t of e){const e=`REFRESH${t.refreshCounter}`;Log.info(`Update ${f.PAGELOAD_TARGETING} targeting ${e} for `,t),t.dfpSlot.setTargeting(f.PAGELOAD_TARGETING,e)}}refreshSlots(t=this.ads){Log.info("Refresh slots - ads : ",t);let i=!1,o=!1,n=!1,s=()=>{n||!o||!i&&__adLib.includeA9||(-1!=l&&window.clearTimeout(l),Log.info("Prebid is completed and A9 completed or disabled -> call DFP"),a())},a=()=>{Log.info("Refresh ads ",t);let e=t.map((e=>e.dfpSlot));Log.info("Refresh DFP slots ",e),googletag.pubads().refresh(e)},r=[];for(let e of t)r.push({code:e.dfpSlot.getAdUnitPath(),mediaTypes:{banner:{sizes:e.adParameters.size}},bids:__adLib.prebidBannerBiddersConfiguration});Log.info("Prebid ad unit configuration: ",r);let d={...__adLib.prebidConfiguration,debug:Log.getLevel()==e.Debug};if(__adLib.includeA9){let e=t.map((e=>e.a9Slot));Log.info("Calls A9 with these slots:",e),apstag.fetchBids({slots:e},(()=>{Log.info("A9 bid request completed"),apstag.setDisplayBids(),i=!0,s()}))}pbjs.que.push((()=>{Log.info("Set Prebid Config: ",d),pbjs.setConfig(d),pbjs.addAdUnits(r),Log.info("Request Prebid bids"),pbjs.requestBids({timeout:__adLib.prebidTimeout,bidsBackHandler:()=>{Log.info("Prebid request bid completed"),pbjs.setTargetingForGPTAsync(t.map((e=>e.dfpSlot.getAdUnitPath()))),o=!0,s()}})}));let l=-1;0!=__adLib.biddersFailsafeTimeout&&(Log.info(`Bidders failsafe timeout set to [${__adLib.biddersFailsafeTimeout}] ms`),l=window.setTimeout((()=>{Log.info("Bidding Timeout! -> calls DFP directly"),n=!0,a()}),__adLib.biddersFailsafeTimeout))}}class u{static async init(){if(__adLib.requiresConsent){if(!n.isDefined(window.__tcfapi)){Log.info2("__tcfapi not found -> Will load the oneTrust scripts");try{await s.loadScript("https://cdn.cookielaw.org/consent/cmp.stub.js",{"data-domain-script":__adLib.oneTrustId})}catch(e){throw Log.error("Unable to load oneTrust cmp.stub.js script"),e}try{await s.loadScript("https://cdn.cookielaw.org/scripttemplates/otSDKStub.js",{"data-domain-script":__adLib.oneTrustId})}catch(e){throw Log.error("Unable to load oneTrust otSDKStub.js script "),e}Log.info2("oneTrust scripts loaded")}Log.info2("set OptanonWrapper function"),window.OptanonWrapper=()=>{Log.info2(`OptanonWrapper called. Defer Ads status is [${u.getDeferAdsStatus()}]`),u.getDeferAdsStatus()&&(Log.info2("Defer Ads status is true -> Set Read TCData callback"),window.__tcfapi("getTCData",2,((e,t)=>{if(Log.info2(`TCData read: success = [${t}] data = `,e),!t||u.statusOk(e))return Log.info2("Error or status already OK -> send message to the app to load the ads immediately "),void u.setDeferAdsStatus(!1);const i=(e,t)=>{Log.info2("Received __tcpapi status change Event: ",e),t&&u.statusOk(e)&&(Log.info2("Status now OK, remove the event listener and send message to the app to load the ads immediately"),window.__tcfapi("removeEventListener",2,i),u.setDeferAdsStatus(!1))};Log.info2("Status not OK yet. Set event listener to load the ads when it will be OK"),window.__tcfapi("addEventListener",2,i)})))},Log.info2("Defer the ads loading by default"),u.setDeferAdsStatus(!0)}else Log.info2("Not Consent Required")}static getDeferAdsStatus(){return __adLib.deferAds}static setDeferAdsStatus(e){__adLib.deferAds=e,e||document.dispatchEvent(new Event("endDeferAds"))}static statusOk(e){return"useractioncomplete"==e.eventStatus||"tcloaded"==e.eventStatus}static getPrebidConsentParameters(){return __adLib.usPrivacyConsent?__adLib.prebidCcpaConfiguration:__adLib.requiresConsent?__adLib.prebidGdprConfiguration:null}static onDNSMILinkClicked(){Log.info2("CCPA consent called"),Log.info2("create default IAB cookie [1YYY]"),p.createCookie(1,!0,!0,!0),Log.info2("Modifies onetrust OptanonConsent cookies and ActiveGroups global variables");let e=[4],t=decodeURIComponent(a.readCookie("OptanonConsent "));Log.info2("Current OptanonConsent cookie value = ",t);for(let i of e)t=t.replace(`,${i}:1,`,`,${i}:0,`),window.OptanonActiveGroups=window.OptanonActiveGroups.replace(`,${i},`,","),window.OnetrustActiveGroups=window.OnetrustActiveGroups.replace(`,${i},`,",");Log.info2("New OptanonConsent cookie value = ",t),Log.info2(`New OptanonActiveGroups = [${window.OptanonActiveGroups}]`),Log.info2(`New OneTrustActiveGroups = [${window.OnetrustActiveGroups}]`),a.createCookieSession("OptanonConsent",encodeURI(t),__adLib.topDomain),a.createCookieSession("EbConsentClosed","true"),Log.info2("created new OptanonConsent and EbConsentClosed cookies")}}class h{static CATFISH_ID="AD_STATIC_CATFISH";static newCatfish(e,i){Log.info("Create a catfish container");let o=`<div id="${h.CATFISH_ID}" class="__alCatfish" style=" ${e?`width:${e}px;`:""} ${i?`height:${i}px`:""}"></div>`;return s.insert(t.append,document.body,o),Log.info("Static Catfish Inserted",h.getCurrentCatfishElement()),h.getCurrentCatfishElement()}static getCurrentCatfishElement(){return s.get(`#${h.CATFISH_ID}`)}}class m{static providerClasses=new Map([[g.DFP,f]]);providers=new Map;timers=[];isAdBlockerActivated(){let e=s.get("#_MGS_");e||(s.insert(t.append,document.body,'<div id="_MGS_"><div class="adBanner" style="height:1px"></div></div>'),e=s.get("#_MGS_"));let i=s.get("div",e);return"none"===window.getComputedStyle(i).display}async init(){Log.info("Init Ads manager at page load"),p.init(),await u.init(),Log.info("Set tab visibility event handler"),s.setEventListener(document,"visibilitychange",(()=>{let e="visible"===document.visibilityState;Log.info(`Tab visibility changed to [${e}]`),e?this.resumeAllPausedTimers():this.pauseAllRunningTimers()})),__adLib.deferAds?(Log.info("Ads need to be deferred. Will wait until the [endDeferAds] is fired"),s.setEventListener(document,"endDeferAds",(()=>{Log.info("Deferred Ads event triggered. Will now initialize the ads"),this.contentLoadInit()}))):(Log.info("No deferred ads. Will initialize the ads now"),this.contentLoadInit(document.body,__adLib.initialLoadAds))}async contentLoadInit(e=document.body,t){let i;if(Log.info(" ============================================================================================="),Log.info("Initialize container with ads"),Log.info(" ============================================================================================="),t)i=t;else{Log.info("Look for json ads definition in ",e);let t=d.getJsonFromScriptSnippet("ads-script",e);if(!t)return void Log.info("Did not find ads definition.");if(i=t,!i)return;Log.info("Found ad definitions: ",i)}let o=new Map;for(let t of i){if(Log.info("Init this ad: ",t),!this.providers.has(t.type)){Log.info(`Initializes Provider: [${t.type}]`);try{let e=new(m.providerClasses.get(t.type));await e.initProvider(),this.providers.set(t.type,e)}catch(e){Log.error(`Unable to instantiate Ad Provider: [${t.type}]`,t,e);continue}}let i=this.providers.get(t.type);o.has(t.type)||o.set(t.type,[]),t.provider=i;let n=null;if(t.displayType==c.REGULAR)n=s.get(t.selector,e);else if(t.displayType==c.CATFISH){if(n=h.getCurrentCatfishElement(),n){let e=s.get(".__alAd",n).ad;e.provider.refreshAds([e]),Log.info("Catfish already exists, just refresh its ad");continue}n=h.newCatfish(),t.injector="append"}n?(t.$container=i.createSlot(t,n),t.$container?(t.$container.ad=t,t.refreshCounter=0,i.addAd(t),o.get(t.type).push(t),t.autoRefresh?(t.$container.isInViewPort=!1,t.refreshTimer=new l((()=>{m.timerCallback(t)}),1e3*__adLib.refreshTimer),this.timers.push(t.refreshTimer),Log.info("This ad is autorefresh, added refresh timer: ",t.refreshTimer)):(t.refreshTimer=null,t.$container.isInViewPort=!0,Log.info("This ad is not autorefresh -> no refresh timer")),t.displayType==c.CATFISH?(Log.info("The ad is a catfish -> always in viewport and start refresh timer"),t.$container.isInViewPort=!0,t.refreshTimer&&t.refreshTimer.start()):t.autoRefresh&&(Log.info("Add the ad container to the observer -> ",t.$container),this.isInViewPortObserver.observe(t.$container)),Log.info("Ad initialized",t)):Log.info("Slot creation failed -> skip this ad")):Log.info("Error when initializing the ad/Existing ad -> skip it: ",t)}for(let[e,t]of o)0==t.length?Log.info(`No ads for [${e}] provider`):(Log.info(`Request Bids for [${e}] provider: `,t),this.providers.get(e).requestBids(t));if(__adLib.stickyContainerSelector){const t=s.getAll(`${__adLib.stickyContainerSelector} .__alAd`,e);let i=t.length;if(i>0){let e=t.item(i-1);Log.info("Last ad is sticky",e),s.addClass(e,"__alSticky",__adLib.stickyAdClass)}}}isInViewPortObserver=new IntersectionObserver((e=>{e.forEach((e=>{let t=e.target;t.isInViewPort=e.intersectionRatio>=__adLib.viewportThreshold,t.isInViewPort?(Log.info("Ad in viewport -> resume timer",t.ad),m.resumeRefreshTimer(t.ad)):(Log.info("Ad out of viewport -> stop timer",t.ad),m.pauseRefreshTimer(t.ad))}))}),{threshold:__adLib.viewportThreshold});static timerCallback(e){Log.info("Ad is refreshed.",e),e.refreshCounter++,e.provider.refreshAds([e])}static resumeRefreshTimer(e){Log.info("Resume refresh timer for ",e),e.refreshTimer.state==i.PAUSED?e.refreshTimer.resume():e.refreshTimer.state==i.STOPPED&&e.refreshTimer.start()}static pauseRefreshTimer(e){Log.info("Pause refresh timer for ",e),e.refreshTimer.pause()}pausedTimers=[];pauseAllRunningTimers(){this.pausedTimers=this.timers.filter((e=>e.state==i.RUNNING)),0!=this.pausedTimers.length&&(this.pausedTimers.forEach((e=>e.pause())),Log.info("Pause these timers: ",this.pausedTimers.map((e=>e.id))))}resumeAllPausedTimers(){0!=this.pausedTimers.length&&(this.pausedTimers.forEach((e=>e.resume())),Log.info("Resume these timers: ",this.pausedTimers.map((e=>e.id))))}refreshAllAds(){Log.info("Refresh All ads"),this.providers.forEach((e=>{Log.info(`will refresh ads for this provider: [${e.getName()}]`);for(let t of e.ads)t.refreshCounter++;e.refreshAllAds();for(let t of e.ads)t.refreshTimer&&t.refreshTimer.restart()}))}}n.isDefined(typeof window.__adLib)&&s.onDocumentReady((()=>{window.Log=new o(e[__adLib.logLevel]),window.Log.info("Ad Library Loaded"),window.AdsManager=new m,AdsManager.init()}));
//# sourceMappingURL=britannica-ads.esm.js.map

@@ -1,2 +0,2 @@

!function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";var e,t,i;!function(e){e[e.Debug=0]="Debug",e[e.Info2=1]="Info2",e[e.Info=2]="Info",e[e.None=3]="None"}(e||(e={}));class o{static INFO_STYLE="font-weight:bold; background-color: #084466; color: white; border-radius:3px;display:inline-block;padding:2px 4px";static INFO_STYLE2="font-weight:bold; background-color: rebeccapurple; color: white; border-radius:3px;display:inline-block;padding:2px 4px";static ERR_STYLE="font-weight:bold; background-color: red; color: white; border-radius:3px;display:inline-block;padding:2px 4px;";static WARN_STYLE="font-weight:bold; background-color: orange; color: white; border-radius:3px;display:inline-block;padding:2px 4px;";static DEBUG_STYLE="font-weight:bold; background-color: #88A95B; color: white; border-radius:3px;display:inline-block;padding:2px 4px;";error=console.error.bind(window.console,"%cAd Lib",o.ERR_STYLE);warning=console.warn.bind(window.console,"%cAd Lib",o.WARN_STYLE);debug;info;info2;level;constructor(t){this.level=t,this.info=e.Info>=t?console.log.bind(window.console,"%cAd Lib",o.INFO_STYLE):()=>null,this.info2=e.Info2>=t?console.log.bind(window.console,"%cAd Lib",o.INFO_STYLE2):()=>null,this.debug=e.Debug>=t?console.debug.bind(window.console,"%cAd Lib",o.DEBUG_STYLE):()=>null}getLevel(){return this.level}}class n{static isDefined(e){return void 0!==e}static isFunction(e){return"function"==typeof e}}!function(e){e.before="beforeBegin",e.after="afterEnd",e.prepend="afterBegin",e.append="beforeEnd"}(t||(t={}));class s{static insert(e,t,i){t.insertAdjacentHTML(e,i)}static remove(e){e&&e.parentNode.removeChild(e)}static loadScript(e,t={}){return new Promise(((i,o)=>{let n=document.createElement("script");n.src=e,n.onload=()=>i(),n.onerror=()=>o();for(const[e,i]of Object.entries(t))n.setAttribute(e,i);document.head.append(n)}))}static css(e,t,i){e.style.setProperty(t,i)}static addClass(e,...t){t.forEach((t=>{t&&e.classList.add(t)}))}static removeClass(e,t){e.classList.remove(t)}static onDocumentReady(e){"loading"!=document.readyState?e():document.addEventListener("DOMContentLoaded",e)}static get(e,t=document.body){return t.querySelector(e)}static getAll(e,t=document.body){return t.querySelectorAll(e)}static setEventListener(e,t,i){e.addEventListener(t,i)}static removeEventListener(e,t,i){e.removeEventListener(t,i)}static onInViewPort(e,t){new IntersectionObserver(((i,o)=>{i.forEach((i=>{i.isIntersecting&&(t(e),o.disconnect(),o=null)}))}),{threshold:1}).observe(e)}static onScroll(e,t){window.addEventListener("scroll",function(e,t){var i=!1;return function(){i||(e(window.scrollY),i=!0,setTimeout((function(){i=!1}),t))}}(e,t))}static delayedCall(e,t){t?setTimeout(e,1e3*t):e()}}class a{static createCookieSession(e,t,i){document.cookie=`${e}=${t}; path=/${i?";domain="+i:""}`}static readCookie(e){return document.cookie.split("; ").find((t=>t.startsWith(`${e}=`))).split("=")[1]}static isCookieExists(e){return document.cookie.split(";").some((t=>t.trim().startsWith(`${e}=`)))}}class r{static substringBefore(e,t){if(!e||!t)return e;const i=e.indexOf(t);return-1==i?"":e.substring(0,i)}static substringAfter(e,t){if(!e||!t)return e;const i=e.indexOf(t);return-1==i?"":e.substring(i+1)}static defaultIfBlank(e,t){return e&&0!=e.length?e:t}}class d{static getJsonFromScriptSnippet(e,t=document.body){const i=s.get(`script[type="application/json"].${e}`,t);return i?d.elementContentToJson(i):null}static elementContentToJson(e){var t=e.innerText;try{return JSON.parse(t)}catch(e){return Log.error("JSON parsing error: ",e),null}}}!function(e){e.PAUSED="PAUSED",e.RUNNING="RUNNING",e.STOPPED="STOPPED"}(i||(i={}));class l{_id=(Date.now()+Math.floor(100*Math.random())).toString().slice(-5);_state=i.STOPPED;internalTimerId;restartTimerId;lastStart;remaining;callback;delay;constructor(e,t){this.callback=e,this.delay=t}get id(){return this._id}get state(){return this._state}callbackFn(){this.lastStart=Date.now(),this.remaining=this.delay,this.callback()}pause(){this.state==i.RUNNING&&(this.stopInternalTimer(),this.stopResumeTimer(),this.remaining-=Date.now()-this.lastStart,this._state=i.PAUSED,Log.debug(`Timer [${this._id}] Paused - Remaining [${this.remaining}ms]`))}resume(){this.state==i.PAUSED&&(this.restartTimerId=window.setTimeout((()=>{this.callback(),this.start()}),this.remaining),this.lastStart=Date.now(),this._state=i.RUNNING,Log.debug(`Timer [${this._id}] Resumed in [${this.remaining}ms].`))}stop(){this.state!=i.STOPPED&&(this.stopInternalTimer(),this.stopResumeTimer(),this.remaining=this.delay,this._state=i.STOPPED,Log.debug(`Timer [${this._id}] - Internal id [${this.internalTimerId}] Stopped`))}start(){this.lastStart=Date.now(),this.remaining=this.delay,this.internalTimerId=window.setInterval((()=>this.callbackFn()),this.delay),this._state=i.RUNNING,Log.debug(`Started Timer [${this._id}] - Internal id [${this.internalTimerId}]`)}restart(){this.stop(),this.start()}stopInternalTimer(){this.internalTimerId&&(window.clearInterval(this.internalTimerId),this.internalTimerId=null)}stopResumeTimer(){this.restartTimerId&&(window.clearTimeout(this.restartTimerId),this.restartTimerId=null)}}var c,f;!function(e,t){void 0===t&&(t={});var i=t.insertAt;if(e&&"undefined"!=typeof document){var o=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css","top"===i&&o.firstChild?o.insertBefore(n,o.firstChild):o.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}}('/* banner ad */\n.__alAd {\n overflow: hidden;\n display: block;\n}\n.__alAd iframe {\n overflow: hidden;\n}\n\n/* sticky ad */\n.__alSticky {\n top: 0;\n position: sticky;\n}\n\n/* catfish */\n.__alCatfish {\n position: fixed;\n bottom: 0;\n left: 0;\n right: 0;\n margin: auto;\n z-index: 1030;\n width: fit-content;\n}\n\n/* preroll ad */\n.__alPrerollContainer {\n position: relative !important;\n}\n\n.__alPrerollWrapper {\n position: absolute;\n width: 100%;\n height: 100%;\n display: table;\n background: black url("https://cdn.britannica.com/ads/resources/loading.gif") center center no-repeat;\n}\n\n#__alPreroll {\n display: table-cell;\n vertical-align: middle;\n}\n\n/* inline ad */\n.__alInline {\n text-align: center;\n margin: 0 auto 20px auto;\n}\n.__alInline::before {\n border-bottom: 1px solid #ddd;\n color: #aaa;\n content: "Advertisement - Continue reading below";\n display: block;\n font-family: "Helvetica", "Segoe UI", "Arial", sans-serif;\n font-size: 11px;\n font-weight: bold;\n margin-bottom: 20px;\n padding-bottom: 5px;\n clear: left;\n}'),function(e){e.REGULAR="REGULAR",e.CATFISH="CATFISH"}(c||(c={}));class g{static US_PrivacyCookieName="usprivacy";static US_PrivacyCookieDuration=365;static init(){Log.info2("Init IAB: Insert iframe locator into body"),s.insert(t.append,document.body,'<iframe name="__uspapiLocator" style="display:none;height:0;opacity:0;visibility:hidden;border:0;width:0;"></iframe>'),Log.info2("Install IAB message handler"),window.addEventListener("message",g.optOutMsgHandler,!1),Log.info2("Install global __uspapi function"),window.__uspapi=(e,t,i)=>{if(Log.info2(`IAB: __uspapi function called. Command: [${e}] `),"getuspdata"===e.toLowerCase()){var o={version:t,uspString:a.readCookie(g.US_PrivacyCookieName)};Log.info2("IAB: getuspdata command. Response: ",o),i(o,null!=o.uspString)}},a.isCookieExists(g.US_PrivacyCookieName)||(__adLib.usPrivacyConsent?(Log.info2("IAB: US privacy consent needed (CCPA), create default cookie [1YNY]"),g.createCookie(1,!0,!1,!0)):(Log.info2("IAB: No US privacy consent needed, create default cookie [1---]"),g.createCookie()))}static createCookie(e=1,t,i,o){var n=e=>!0===e?"Y":!1===e?"N":"-",s=e.toString()+n(t)+n(i)+n(o),a=`${g.US_PrivacyCookieName}=${s}; `,r=new Date;r.setTime(r.getTime()+24*g.US_PrivacyCookieDuration*60*60*1e3);var d=`expires=${r.toUTCString()}; `;document.cookie=a+d+"path=/; SameSite=Lax; "}static optOutMsgHandler(e){let t,i="string"==typeof e.data;if(t=i?-1!==e.data.indexOf("__uspapiCall")?JSON.parse(e.data):{}:e.data,t.__uspapiCall){Log.info2("Received __uspapiCall event. Will post message to sender with the cookie content");var o=t.__uspapiCall;window.__uspapi(o.command,o.version,(function(t,n){var s={__uspapiReturn:{returnValue:t,success:n,callId:o.callId}};let a=e.source;Log.info2("IAB: post message back ",s,a),a.postMessage(i?JSON.stringify(s):s,"*")}))}}}!function(e){e.DFP="DFP"}(f||(f={}));class p extends class{type;ads;constructor(){this.ads=[],this.type=this.getType()}addAd(e){this.ads.push(e)}}{static PAGELOAD_TARGETING="PAGELOAD";index=1;getName(){return"Google DFP"}getType(){return f.DFP}constructor(){super()}async initProvider(){if(window.googletag={cmd:[]},!n.isDefined(window.googletag.defineSlot))try{await s.loadScript("https://securepubads.g.doubleclick.net/tag/js/gpt.js")}catch(e){throw Log.error("**** Unable to load gpt.js -> most ads and scripts will be broken ***"),e}if(class{static async loadPrebidScript(){if(!__adLib.videoForPrebidLoaded&&!n.isDefined(window.pbjs)){Log.info(`Loading [${__adLib.prebidScriptUrl}] prebid script now`),window.pbjs={que:[]};try{await s.loadScript(__adLib.prebidScriptUrl)}catch(e){return void Log.error(`Unable to load [${__adLib.prebidScriptUrl}] prebid script -> skip ad`)}__adLib.videoForPrebidLoaded=!0}}}.loadPrebidScript(),!n.isDefined(window.headertag)&&__adLib.includeIndex)try{await s.loadScript(__adLib.indexScriptUrl)}catch(e){Log.error(`Unable to load [${__adLib.indexScriptUrl}] Index script. We won't use it.`)}if(!n.isDefined(window.apstag)&&__adLib.includeA9)try{await s.loadScript("https://c.amazon-adsystem.com/aax2/apstag.js"),function(e,t){function i(i,o){t[e]._Q.push([i,o])}t[e]||(t[e]={init:function(){i("i",arguments)},fetchBids:function(){i("f",arguments)},setDisplayBids:function(){},targetingKeys:function(){return[]},_Q:[]})}("apstag",window)}catch(e){Log.error("Unable to load A9 script. Will disable it"),__adLib.includeA9=!1}googletag.cmd.push((function(){if(googletag.pubads().setTargeting("dc_ref",__adLib.url),n.isDefined(Storage)){var e=localStorage.getItem("bcDFPTargetingParams");if(e)Log.info("Setting Blueconic targeting parameters"),JSON.parse(e).forEach((e=>googletag.pubads().setTargeting(e.key,e.value)))}if(Log.info(`targeting: ${googletag.pubads().getTargetingKeys()}`),googletag.pubads().disableInitialLoad(),googletag.pubads().enableSingleRequest(),googletag.pubads().enableAsyncRendering(),googletag.pubads().setTagForChildDirectedTreatment(0),googletag.pubads().setTagForUnderAgeOfConsent(0),__adLib.dfpLazyLoad&&googletag.pubads().enableLazyLoad(__adLib.dfpLazyLoadParameters),googletag.enableServices(),__adLib.includeA9){var t={pubID:__adLib.a9Id,adServer:"googletag",bidTimeout:1200};__uspapi&&__uspapi("getuspdata","1",((e,i)=>{i&&(t.params={us_privacy:e.uspString})})),Log.info("Init A9 with ",t),apstag.init(t)}}))}createSlot(e,t){return this.initSlot(e,t)}initSlot(e,i){try{Log.info("process DFP ad: ",e);var o=e.adParameters,n=o.size[0][0],a=o.size[0][1];Log.info("Content container for this ad is ",i);var d="";if(e.displayType!=c.CATFISH)if(o.placeholderSize)d=`min-width:${r.substringBefore(o.placeholderSize,"x")}px;min-height:${r.substringAfter(o.placeholderSize,"x")}px;`;else if(1==o.size.length)d=`width:${n}px;height:${a}px;`;else{d=`min-height:${Math.round(o.size.map((e=>e[1])).reduce(((e,t)=>e+t))/o.size.length)}px;`}var l="DFP_"+this.index++;e.containerId=l,e.dfpSize=1==o.size.length?o.size[0]:o.size;var f=`style="${d}${r.defaultIfBlank(o.style,"")}"`,g=`<div data-type="${e.type}" class="__alAd ${r.defaultIfBlank(__adLib.adClass,"")} ${r.defaultIfBlank(o.cssClass,"")}" ${f} id="${l}"></div>`;Log.info(`Inject DIV: [${g}] into `,i),s.insert(t[e.injector],i,g),this.setDfpA9Slot(e);let p=s.get(`#${l}`);return p.setAttribute("data-identifier",e.dfpSlot.getAdUnitPath()),p}catch(t){return Log.error("Init Slot Error: ",e,t),null}}setDfpA9Slot=function(e){Log.info("Initializes DFP slot and A9 slot for ",e);var t=e.adParameters,i=__adLib.dfpIdPrefix.replace("${LEG}",__adLib.leg)+(__adLib.isPhone?"MOBILE":"DESKTOP")+"_",o=`/${__adLib.googleDfpId}/${i}${t.id}`;Log.info(`Define new slot: [${o}] with: size [${e.dfpSize}] id [${e.containerId}]`),e.dfpSlot=googletag.defineSlot(o,e.dfpSize,e.containerId),t.targeting&&Object.entries(t.targeting).forEach((([t,i])=>{e.dfpSlot.setTargeting(t,String(i))})),e.dfpSlot.addService(googletag.pubads()),__adLib.includeIndex&&(e.a9Slot={slotID:e.containerId,slotName:o,sizes:t.size}),Log.info("DFP/A9 slot defined for ",e)};refreshAllAds(){Log.info("Refresh all DFP ads."),googletag.cmd.push((()=>{p.setPageLoadTargeting(this.ads),this.refreshSlots()}))}requestBids(e){this.refreshAds(e)}refreshAds(e){Log.info("Refresh ads: ",e),googletag.cmd.push((()=>{p.setPageLoadTargeting(e),this.refreshSlots(e)}))}static setPageLoadTargeting(e){for(let t of e){const e=`REFRESH${t.refreshCounter}`;Log.info(`Update ${p.PAGELOAD_TARGETING} targeting ${e} for `,t),t.dfpSlot.setTargeting(p.PAGELOAD_TARGETING,e)}}refreshSlots(t=this.ads){Log.info("Refresh slots - ads : ",t);let i=!1,o=!1,n=!1,s=()=>{n||!o||!i&&__adLib.includeA9||(-1!=c&&window.clearTimeout(c),Log.info("Prebid is completed and A9 completed or disabled -> call DFP"),a())},a=()=>{Log.info("Refresh ads ",t);let e=t.map((e=>e.dfpSlot));Log.info("Refresh DFP slots ",e),googletag.pubads().refresh(e)},r=[];for(let e of t)r.push({code:e.dfpSlot.getAdUnitPath(),mediaTypes:{banner:{sizes:e.adParameters.size}},bids:__adLib.prebidBannerBiddersConfiguration});Log.info("Prebid ad unit configuration: ",r);let d={...__adLib.prebidConfiguration,debug:Log.getLevel()==e.Debug};if(__adLib.includeA9){var l=t.map((e=>e.a9Slot));Log.info("Calls A9 with these slots:",l),apstag.fetchBids({slots:l},(()=>{Log.info("A9 bid request completed"),apstag.setDisplayBids(),i=!0,s()}))}pbjs.que.push((()=>{Log.info("Set Prebid Config: ",d),pbjs.setConfig(d),pbjs.addAdUnits(r),Log.info("Request Prebid bids"),pbjs.requestBids({timeout:__adLib.prebidTimeout,bidsBackHandler:()=>{Log.info("Prebid request bid completed"),pbjs.setTargetingForGPTAsync(t.map((e=>e.dfpSlot.getAdUnitPath()))),o=!0,s()}})}));let c=-1;0!=__adLib.biddersFailsafeTimeout&&(Log.info(`Bidders failsafe timeout set to [${__adLib.biddersFailsafeTimeout}] ms`),c=window.setTimeout((()=>{Log.info("Bidding Timeout! -> calls DFP directly"),n=!0,a()}),__adLib.biddersFailsafeTimeout))}}class u{static async init(){if(__adLib.requiresConsent){if(!n.isDefined(window.__tcfapi)){Log.info2("__tcfapi not found -> Will load the oneTrust scripts");try{await s.loadScript("https://cdn.cookielaw.org/consent/cmp.stub.js",{"data-domain-script":__adLib.oneTrustId})}catch(e){throw Log.error("Unable to load oneTrust cmp.stub.js script"),e}try{await s.loadScript("https://cdn.cookielaw.org/scripttemplates/otSDKStub.js",{"data-domain-script":__adLib.oneTrustId})}catch(e){throw Log.error("Unable to load oneTrust otSDKStub.js script "),e}Log.info2("oneTrust scripts loaded")}Log.info2("set OptanonWrapper function"),window.OptanonWrapper=()=>{Log.info2(`OptanonWrapper called. Defer Ads status is [${u.getDeferAdsStatus()}]`),u.getDeferAdsStatus()&&(Log.info2("Defer Ads status is true -> Set Read TCData callback"),window.__tcfapi("getTCData",2,((e,t)=>{if(Log.info2(`TCData read: success = [${t}] data = `,e),!t||u.statusOk(e))return Log.info2("Error or status already OK -> send message to the app to load the ads immediately "),void u.setDeferAdsStatus(!1);const i=(e,t)=>{Log.info2("Received __tcpapi status change Event: ",e),t&&u.statusOk(e)&&(Log.info2("Status now OK, remove the event listener and send message to the app to load the ads immediately"),window.__tcfapi("removeEventListener",2,i),u.setDeferAdsStatus(!1))};Log.info2("Status not OK yet. Set event listener to load the ads when it will be OK"),window.__tcfapi("addEventListener",2,i)})))},Log.info2("Defer the ads loading by default"),u.setDeferAdsStatus(!0)}else Log.info2("Not Consent Required")}static getDeferAdsStatus(){return __adLib.deferAds}static setDeferAdsStatus(e){__adLib.deferAds=e,e||document.dispatchEvent(new Event("endDeferAds"))}static statusOk(e){return"useractioncomplete"==e.eventStatus||"tcloaded"==e.eventStatus}static onDNSMILinkClicked(){Log.info2("CCPA consent called"),Log.info2("create default IAB cookie [1YYY]"),g.createCookie(1,!0,!0,!0),Log.info2("Modifies onetrust OptanonConsent cookies and ActiveGroups global variables");let e=[4],t=decodeURIComponent(a.readCookie("OptanonConsent "));Log.info2("Current OptanonConsent cookie value = ",t);for(let i of e)t=t.replace(`,${i}:1,`,`,${i}:0,`),window.OptanonActiveGroups=window.OptanonActiveGroups.replace(`,${i},`,","),window.OnetrustActiveGroups=window.OnetrustActiveGroups.replace(`,${i},`,",");Log.info2("New OptanonConsent cookie value = ",t),Log.info2(`New OptanonActiveGroups = [${window.OptanonActiveGroups}]`),Log.info2(`New OneTrustActiveGroups = [${window.OnetrustActiveGroups}]`),a.createCookieSession("OptanonConsent",encodeURI(t),__adLib.topDomain),a.createCookieSession("EbConsentClosed","true"),Log.info2("created new OptanonConsent and EbConsentClosed cookies")}}class h{static CATFISH_ID="AD_STATIC_CATFISH";static newCatfish(e,i){Log.info("Create a catfish container");var o=`<div id="${h.CATFISH_ID}" class="__alCatfish" style=" ${e?`width:${e}px;`:""} ${i?`height:${i}px`:""}"></div>`;return s.insert(t.append,document.body,o),Log.info("Static Catfish Inserted",h.getCurrentCatfishElement()),h.getCurrentCatfishElement()}static getCurrentCatfishElement(){return s.get(`#${h.CATFISH_ID}`)}}class m{static providerClasses=new Map([[f.DFP,p]]);providers=new Map;timers=[];isAdBlockerActivated(){var e=s.get("#_MGS_");e||(s.insert(t.append,document.body,'<div id="_MGS_"><div class="adBanner" style="height:1px"></div></div>'),e=s.get("#_MGS_"));var i=s.get("div",e);return"none"===window.getComputedStyle(i).display}async init(){Log.info("Init Ads manager at page load"),g.init(),await u.init(),Log.info("Set tab visibility event handler"),s.setEventListener(document,"visibilitychange",(()=>{var e="visible"===document.visibilityState;Log.info(`Tab visibility changed to [${e}]`),e?this.resumeAllPausedTimers():this.pauseAllRunningTimers()})),__adLib.deferAds?(Log.info("Ads need to be deferred. Will wait until the [endDeferAds] is fired"),s.setEventListener(document,"endDeferAds",(()=>{Log.info("Deferred Ads event triggered. Will now initialize the ads"),this.contentLoadInit()}))):(Log.info("No deferred ads. Will initialize the ads now"),this.contentLoadInit())}async contentLoadInit(e=document.body){Log.info(" ============================================================================================="),Log.info("Initialize container with ads"),Log.info(" ============================================================================================="),Log.info("Look for json ads definition in ",e);var t=d.getJsonFromScriptSnippet("ads-script",e);if(!t)return void Log.info("Did not find ads definition.");var i=t;if(!i)return;Log.info("Found ad definitions: ",i);let o=new Map;for(let t of i){if(Log.info("Init this ad: ",t),!this.providers.has(t.type)){Log.info(`Initializes Provider: [${t.type}]`);try{let e=new(m.providerClasses.get(t.type));await e.initProvider(),this.providers.set(t.type,e)}catch(e){Log.error(`Unable to instantiate Ad Provider: [${t.type}]`,t,e);continue}}var n=this.providers.get(t.type);o.has(t.type)||o.set(t.type,[]),t.provider=n;let i=null;if(t.displayType==c.REGULAR)i=s.get(t.selector,e);else if(t.displayType==c.CATFISH){if(i=h.getCurrentCatfishElement(),i){let e=s.get(".__alAd",i).ad;e.provider.refreshAds([e]),Log.info("Catfish already exists, just refresh its ad");continue}i=h.newCatfish(),t.injector="append"}i?(t.$container=n.createSlot(t,i),t.$container?(t.$container.ad=t,t.refreshCounter=0,n.addAd(t),o.get(t.type).push(t),t.autoRefresh?(t.$container.isInViewPort=!1,t.refreshTimer=new l((()=>{m.timerCallback(t)}),1e3*__adLib.refreshTimer),this.timers.push(t.refreshTimer),Log.info("This ad is autorefresh, added refresh timer: ",t.refreshTimer)):(t.refreshTimer=null,t.$container.isInViewPort=!0,Log.info("This ad is not autorefresh -> no refresh timer")),t.displayType==c.CATFISH?(Log.info("The ad is a catfish -> always in viewport and start refresh timer"),t.$container.isInViewPort=!0,t.refreshTimer&&t.refreshTimer.start()):t.autoRefresh&&(Log.info("Add the ad container to the observer -> ",t.$container),this.isInViewPortObserver.observe(t.$container)),Log.info("Ad initialized",t)):Log.info("Slot creation failed -> skip this ad")):Log.info("Error when initializing the ad/Existing ad -> skip it: ",t)}for(let[e,t]of o)0==t.length?Log.info(`No ads for [${e}] provider`):(Log.info(`Request Bids for [${e}] provider: `,t),this.providers.get(e).requestBids(t));if(__adLib.stickyContainerSelector){const t=s.getAll(`${__adLib.stickyContainerSelector} .__alAd`,e);var a=t.length;if(a>0){let e=t.item(a-1);Log.info("Last ad is sticky",e),s.addClass(e,"__alSticky",__adLib.stickyAdClass)}}}isInViewPortObserver=new IntersectionObserver((e=>{e.forEach((e=>{var t=e.target;t.isInViewPort=e.intersectionRatio>=__adLib.viewportThreshold,t.isInViewPort?(Log.info("Ad in viewport -> resume timer",t.ad),m.resumeRefreshTimer(t.ad)):(Log.info("Ad out of viewport -> stop timer",t.ad),m.pauseRefreshTimer(t.ad))}))}),{threshold:__adLib.viewportThreshold});static timerCallback(e){Log.info("Ad is refreshed.",e),e.refreshCounter++,e.provider.refreshAds([e])}static resumeRefreshTimer(e){Log.info("Resume refresh timer for ",e),e.refreshTimer.state==i.PAUSED?e.refreshTimer.resume():e.refreshTimer.state==i.STOPPED&&e.refreshTimer.start()}static pauseRefreshTimer(e){Log.info("Pause refresh timer for ",e),e.refreshTimer.pause()}pausedTimers=[];pauseAllRunningTimers(){this.pausedTimers=this.timers.filter((e=>e.state==i.RUNNING)),0!=this.pausedTimers.length&&(this.pausedTimers.forEach((e=>e.pause())),Log.info("Pause these timers: ",this.pausedTimers.map((e=>e.id))))}resumeAllPausedTimers(){0!=this.pausedTimers.length&&(this.pausedTimers.forEach((e=>e.resume())),Log.info("Resume these timers: ",this.pausedTimers.map((e=>e.id))))}refreshAllAds(){Log.info("Refresh All ads"),this.providers.forEach((e=>{Log.info(`will refresh ads for this provider: [${e.getName()}]`);for(let t of e.ads)t.refreshCounter++;e.refreshAllAds();for(let t of e.ads)t.refreshTimer&&t.refreshTimer.restart()}))}}n.isDefined(typeof window.__adLib)&&s.onDocumentReady((()=>{window.Log=new o(e[__adLib.logLevel]),window.Log.info("Ad Library Loaded"),window.AdsManager=new m,AdsManager.init()}))}));
!function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";var e,t,i;!function(e){e[e.Debug=0]="Debug",e[e.Info2=1]="Info2",e[e.Info=2]="Info",e[e.None=3]="None"}(e||(e={}));class o{static INFO_STYLE="font-weight:bold; background-color: #084466; color: white; border-radius:3px;display:inline-block;padding:2px 4px";static INFO_STYLE2="font-weight:bold; background-color: rebeccapurple; color: white; border-radius:3px;display:inline-block;padding:2px 4px";static ERR_STYLE="font-weight:bold; background-color: red; color: white; border-radius:3px;display:inline-block;padding:2px 4px;";static WARN_STYLE="font-weight:bold; background-color: orange; color: white; border-radius:3px;display:inline-block;padding:2px 4px;";static DEBUG_STYLE="font-weight:bold; background-color: #88A95B; color: white; border-radius:3px;display:inline-block;padding:2px 4px;";error=console.error.bind(window.console,"%cAd Lib",o.ERR_STYLE);warning=console.warn.bind(window.console,"%cAd Lib",o.WARN_STYLE);debug;info;info2;level;constructor(t){this.level=t,this.info=e.Info>=t?console.log.bind(window.console,"%cAd Lib",o.INFO_STYLE):()=>null,this.info2=e.Info2>=t?console.log.bind(window.console,"%cAd Lib",o.INFO_STYLE2):()=>null,this.debug=e.Debug>=t?console.debug.bind(window.console,"%cAd Lib",o.DEBUG_STYLE):()=>null}getLevel(){return this.level}}class n{static isDefined(e){return void 0!==e}static isFunction(e){return"function"==typeof e}}!function(e){e.before="beforeBegin",e.after="afterEnd",e.prepend="afterBegin",e.append="beforeEnd"}(t||(t={}));class s{static insert(e,t,i){t.insertAdjacentHTML(e,i)}static remove(e){e&&e.parentNode.removeChild(e)}static loadScript(e,t={}){return new Promise(((i,o)=>{let n=document.createElement("script");n.src=e,n.onload=()=>i(),n.onerror=()=>o();for(const[e,i]of Object.entries(t))n.setAttribute(e,i);document.head.append(n)}))}static css(e,t,i){e.style.setProperty(t,i)}static addClass(e,...t){t.forEach((t=>{t&&e.classList.add(t)}))}static removeClass(e,t){e.classList.remove(t)}static onDocumentReady(e){"loading"!=document.readyState?e():document.addEventListener("DOMContentLoaded",e)}static get(e,t=document.body){return t.querySelector(e)}static getAll(e,t=document.body){return t.querySelectorAll(e)}static setEventListener(e,t,i){e.addEventListener(t,i)}static removeEventListener(e,t,i){e.removeEventListener(t,i)}static onInViewPort(e,t){new IntersectionObserver(((i,o)=>{i.forEach((i=>{i.isIntersecting&&(t(e),o.disconnect(),o=null)}))}),{threshold:1}).observe(e)}static onScroll(e,t){window.addEventListener("scroll",function(e,t){let i=!1;return function(){i||(e(window.scrollY),i=!0,setTimeout((function(){i=!1}),t))}}(e,t))}static delayedCall(e,t){t?setTimeout(e,1e3*t):e()}}class a{static createCookieSession(e,t,i){document.cookie=`${e}=${t}; path=/${i?";domain="+i:""}`}static readCookie(e){return document.cookie.split("; ").find((t=>t.startsWith(`${e}=`))).split("=")[1]}static isCookieExists(e){return document.cookie.split(";").some((t=>t.trim().startsWith(`${e}=`)))}}class r{static substringBefore(e,t){if(!e||!t)return e;const i=e.indexOf(t);return-1==i?"":e.substring(0,i)}static substringAfter(e,t){if(!e||!t)return e;const i=e.indexOf(t);return-1==i?"":e.substring(i+1)}static defaultIfBlank(e,t){return e&&0!=e.length?e:t}}class d{static getJsonFromScriptSnippet(e,t=document.body){const i=s.get(`script[type="application/json"].${e}`,t);return i?d.elementContentToJson(i):null}static elementContentToJson(e){let t=e.innerText;try{return JSON.parse(t)}catch(e){return Log.error("JSON parsing error: ",e),null}}}!function(e){e.PAUSED="PAUSED",e.RUNNING="RUNNING",e.STOPPED="STOPPED"}(i||(i={}));class l{_id=(Date.now()+Math.floor(100*Math.random())).toString().slice(-5);_state=i.STOPPED;internalTimerId;restartTimerId;lastStart;remaining;callback;delay;constructor(e,t){this.callback=e,this.delay=t}get id(){return this._id}get state(){return this._state}callbackFn(){this.lastStart=Date.now(),this.remaining=this.delay,this.callback()}pause(){this.state==i.RUNNING&&(this.stopInternalTimer(),this.stopResumeTimer(),this.remaining-=Date.now()-this.lastStart,this._state=i.PAUSED,Log.debug(`Timer [${this._id}] Paused - Remaining [${this.remaining}ms]`))}resume(){this.state==i.PAUSED&&(this.restartTimerId=window.setTimeout((()=>{this.callback(),this.start()}),this.remaining),this.lastStart=Date.now(),this._state=i.RUNNING,Log.debug(`Timer [${this._id}] Resumed in [${this.remaining}ms].`))}stop(){this.state!=i.STOPPED&&(this.stopInternalTimer(),this.stopResumeTimer(),this.remaining=this.delay,this._state=i.STOPPED,Log.debug(`Timer [${this._id}] - Internal id [${this.internalTimerId}] Stopped`))}start(){this.lastStart=Date.now(),this.remaining=this.delay,this.internalTimerId=window.setInterval((()=>this.callbackFn()),this.delay),this._state=i.RUNNING,Log.debug(`Started Timer [${this._id}] - Internal id [${this.internalTimerId}]`)}restart(){this.stop(),this.start()}stopInternalTimer(){this.internalTimerId&&(window.clearInterval(this.internalTimerId),this.internalTimerId=null)}stopResumeTimer(){this.restartTimerId&&(window.clearTimeout(this.restartTimerId),this.restartTimerId=null)}}var c,g;!function(e,t){void 0===t&&(t={});var i=t.insertAt;if(e&&"undefined"!=typeof document){var o=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css","top"===i&&o.firstChild?o.insertBefore(n,o.firstChild):o.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}}('/* banner ad */\n.__alAd {\n overflow: hidden;\n display: block;\n margin-left: auto;\n margin-right: auto;\n}\n\n.__alAd > div {\n text-align: center !important;\n display: block !important;\n margin: auto !important;\n}\n\n.__alAd > div > iframe,\n.__alAd > div > div {\n display: block !important;\n margin: auto !important;\n}\n\n/* sticky ad */\n.__alSticky {\n top: 0;\n position: sticky;\n}\n\n/* catfish */\n.__alCatfish {\n position: fixed;\n bottom: 0;\n left: 0;\n right: 0;\n margin: auto;\n z-index: 1030;\n width: fit-content;\n}\n\n/* preroll ad */\n.__alPrerollContainer {\n position: relative !important;\n}\n\n.__alPrerollWrapper {\n position: absolute;\n width: 100%;\n height: 100%;\n display: table;\n background: black url("https://cdn.britannica.com/ads/resources/loading.gif") center center no-repeat;\n}\n\n#__alPreroll {\n display: table-cell;\n vertical-align: middle;\n}\n\n/* inline ad */\n.__alInline {\n text-align: center;\n margin: 0 auto 20px auto;\n}\n.__alInline::before {\n border-bottom: 1px solid #ddd;\n color: #aaa;\n content: "Advertisement - Continue reading below";\n display: block;\n font-family: "Helvetica", "Segoe UI", "Arial", sans-serif;\n font-size: 11px;\n font-weight: bold;\n margin-bottom: 20px;\n padding-bottom: 5px;\n clear: left;\n}'),function(e){e.REGULAR="REGULAR",e.CATFISH="CATFISH"}(c||(c={}));class p{static US_PrivacyCookieName="usprivacy";static US_PrivacyCookieDuration=365;static init(){Log.info2("Init IAB: Insert iframe locator into body"),s.insert(t.append,document.body,'<iframe name="__uspapiLocator" style="display:none;height:0;opacity:0;visibility:hidden;border:0;width:0;"></iframe>'),Log.info2("Install IAB message handler"),window.addEventListener("message",p.optOutMsgHandler,!1),Log.info2("Install global __uspapi function"),window.__uspapi=(e,t,i)=>{if(Log.info2(`IAB: __uspapi function called. Command: [${e}] `),"getuspdata"===e.toLowerCase()){let e={version:t,uspString:a.readCookie(p.US_PrivacyCookieName)};Log.info2("IAB: getuspdata command. Response: ",e),i(e,null!=e.uspString)}},a.isCookieExists(p.US_PrivacyCookieName)||(__adLib.usPrivacyConsent?(Log.info2("IAB: US privacy consent needed (CCPA), create default cookie [1YNY]"),p.createCookie(1,!0,!1,!0)):(Log.info2("IAB: No US privacy consent needed, create default cookie [1---]"),p.createCookie()))}static createCookie(e=1,t,i,o){let n=e=>!0===e?"Y":!1===e?"N":"-",s=e.toString()+n(t)+n(i)+n(o),a=`${p.US_PrivacyCookieName}=${s}; `,r=new Date;r.setTime(r.getTime()+24*p.US_PrivacyCookieDuration*60*60*1e3);let d=`expires=${r.toUTCString()}; `;document.cookie=a+d+"path=/; SameSite=Lax; "}static optOutMsgHandler(e){let t,i="string"==typeof e.data;if(t=i?-1!==e.data.indexOf("__uspapiCall")?JSON.parse(e.data):{}:e.data,t.__uspapiCall){Log.info2("Received __uspapiCall event. Will post message to sender with the cookie content");let o=t.__uspapiCall;window.__uspapi(o.command,o.version,(function(t,n){let s={__uspapiReturn:{returnValue:t,success:n,callId:o.callId}},a=e.source;Log.info2("IAB: post message back ",s,a),a.postMessage(i?JSON.stringify(s):s,"*")}))}}}!function(e){e.DFP="DFP"}(g||(g={}));class f extends class{type;ads;constructor(){this.ads=[],this.type=this.getType()}addAd(e){this.ads.push(e)}}{static PAGELOAD_TARGETING="PAGELOAD";index=1;getName(){return"Google DFP"}getType(){return g.DFP}constructor(){super()}async initProvider(){if(window.googletag={cmd:[]},!n.isDefined(window.googletag.defineSlot))try{await s.loadScript("https://securepubads.g.doubleclick.net/tag/js/gpt.js")}catch(e){throw Log.error("**** Unable to load gpt.js -> most ads and scripts will be broken ***"),e}if(class{static async loadPrebidScript(){if(!__adLib.videoForPrebidLoaded&&!n.isDefined(window.pbjs)){Log.info(`Loading [${__adLib.prebidScriptUrl}] prebid script now`),window.pbjs={que:[]};try{await s.loadScript(__adLib.prebidScriptUrl)}catch(e){return void Log.error(`Unable to load [${__adLib.prebidScriptUrl}] prebid script -> skip ad`)}__adLib.videoForPrebidLoaded=!0}}}.loadPrebidScript(),!n.isDefined(window.headertag)&&__adLib.includeIndex)try{await s.loadScript(__adLib.indexScriptUrl)}catch(e){Log.error(`Unable to load [${__adLib.indexScriptUrl}] Index script. We won't use it.`)}if(!n.isDefined(window.apstag)&&__adLib.includeA9)try{await s.loadScript("https://c.amazon-adsystem.com/aax2/apstag.js"),function(e,t){function i(i,o){t[e]._Q.push([i,o])}t[e]||(t[e]={init:function(){i("i",arguments)},fetchBids:function(){i("f",arguments)},setDisplayBids:function(){},targetingKeys:function(){return[]},_Q:[]})}("apstag",window)}catch(e){Log.error("Unable to load A9 script. Will disable it"),__adLib.includeA9=!1}googletag.cmd.push((function(){if(googletag.pubads().setTargeting("dc_ref",__adLib.url),n.isDefined(Storage)){let e=localStorage.getItem("bcDFPTargetingParams");if(e){Log.info("Setting Blueconic targeting parameters"),JSON.parse(e).forEach((e=>googletag.pubads().setTargeting(e.key,e.value)))}}if(Log.info(`targeting: ${googletag.pubads().getTargetingKeys()}`),googletag.pubads().disableInitialLoad(),googletag.pubads().enableSingleRequest(),googletag.pubads().enableAsyncRendering(),googletag.pubads().setTagForChildDirectedTreatment(0),googletag.pubads().setTagForUnderAgeOfConsent(0),__adLib.dfpLazyLoad&&googletag.pubads().enableLazyLoad(__adLib.dfpLazyLoadParameters),googletag.enableServices(),__adLib.includeA9){let e={pubID:__adLib.a9Id,adServer:"googletag",bidTimeout:1200};__uspapi&&__uspapi("getuspdata","1",((t,i)=>{i&&(e.params={us_privacy:t.uspString})})),Log.info("Init A9 with ",e),apstag.init(e)}}))}createSlot(e,t){return this.initSlot(e,t)}initSlot(e,i){try{Log.info("process DFP ad: ",e);let o=e.adParameters,n=o.size[0][0],a=o.size[0][1];Log.info("Content container for this ad is ",i);let d="";if(e.displayType!=c.CATFISH)if(o.placeholderSize)d=`min-width:${r.substringBefore(o.placeholderSize,"x")}px;min-height:${r.substringAfter(o.placeholderSize,"x")}px;`;else if(1==o.size.length)d=`width:${n}px;height:${a}px;`;else{d=`min-height:${Math.round(o.size.map((e=>e[1])).reduce(((e,t)=>e+t))/o.size.length)}px;`}let l="DFP_"+this.index++;e.containerId=l,e.dfpSize=1==o.size.length?o.size[0]:o.size;let g=`style="${d}${r.defaultIfBlank(o.style,"")}"`,p=`<div data-type="${e.type}" class="__alAd ${r.defaultIfBlank(__adLib.adClass,"")} ${r.defaultIfBlank(o.cssClass,"")}" ${g} id="${l}"></div>`;Log.info(`Inject DIV: [${p}] into `,i),s.insert(t[e.injector],i,p);let f=this.setDfpA9Slot(e),u=s.get(`#${l}`);return u.setAttribute("data-identifier",e.dfpSlot.getAdUnitPath()),u.setAttribute("data-qa-identifier",f),u}catch(t){return Log.error("Init Slot Error: ",e,t),null}}setDfpA9Slot=function(e){Log.info("Initializes DFP slot and A9 slot for ",e);let t=e.adParameters,i=__adLib.dfpIdPrefix.replace("${LEG}",__adLib.leg),o=`${__adLib.isPhone?"MOBILE":"DESKTOP"}_${t.id}`,n=`/${__adLib.googleDfpId}/${i}${o}`;return Log.info(`Define new slot: [${n}] with: size [${e.dfpSize}] id [${e.containerId}]`),e.dfpSlot=googletag.defineSlot(n,e.dfpSize,e.containerId),t.targeting&&Object.entries(t.targeting).forEach((([t,i])=>{e.dfpSlot.setTargeting(t,String(i))})),e.dfpSlot.addService(googletag.pubads()),__adLib.includeIndex&&(e.a9Slot={slotID:e.containerId,slotName:n,sizes:t.size}),Log.info("DFP/A9 slot defined for ",e),o};refreshAllAds(){Log.info("Refresh all DFP ads."),googletag.cmd.push((()=>{f.setPageLoadTargeting(this.ads),this.refreshSlots()}))}requestBids(e){this.refreshAds(e)}refreshAds(e){Log.info("Refresh ads: ",e),googletag.cmd.push((()=>{f.setPageLoadTargeting(e),this.refreshSlots(e)}))}static setPageLoadTargeting(e){for(let t of e){const e=`REFRESH${t.refreshCounter}`;Log.info(`Update ${f.PAGELOAD_TARGETING} targeting ${e} for `,t),t.dfpSlot.setTargeting(f.PAGELOAD_TARGETING,e)}}refreshSlots(t=this.ads){Log.info("Refresh slots - ads : ",t);let i=!1,o=!1,n=!1,s=()=>{n||!o||!i&&__adLib.includeA9||(-1!=l&&window.clearTimeout(l),Log.info("Prebid is completed and A9 completed or disabled -> call DFP"),a())},a=()=>{Log.info("Refresh ads ",t);let e=t.map((e=>e.dfpSlot));Log.info("Refresh DFP slots ",e),googletag.pubads().refresh(e)},r=[];for(let e of t)r.push({code:e.dfpSlot.getAdUnitPath(),mediaTypes:{banner:{sizes:e.adParameters.size}},bids:__adLib.prebidBannerBiddersConfiguration});Log.info("Prebid ad unit configuration: ",r);let d={...__adLib.prebidConfiguration,debug:Log.getLevel()==e.Debug};if(__adLib.includeA9){let e=t.map((e=>e.a9Slot));Log.info("Calls A9 with these slots:",e),apstag.fetchBids({slots:e},(()=>{Log.info("A9 bid request completed"),apstag.setDisplayBids(),i=!0,s()}))}pbjs.que.push((()=>{Log.info("Set Prebid Config: ",d),pbjs.setConfig(d),pbjs.addAdUnits(r),Log.info("Request Prebid bids"),pbjs.requestBids({timeout:__adLib.prebidTimeout,bidsBackHandler:()=>{Log.info("Prebid request bid completed"),pbjs.setTargetingForGPTAsync(t.map((e=>e.dfpSlot.getAdUnitPath()))),o=!0,s()}})}));let l=-1;0!=__adLib.biddersFailsafeTimeout&&(Log.info(`Bidders failsafe timeout set to [${__adLib.biddersFailsafeTimeout}] ms`),l=window.setTimeout((()=>{Log.info("Bidding Timeout! -> calls DFP directly"),n=!0,a()}),__adLib.biddersFailsafeTimeout))}}class u{static async init(){if(__adLib.requiresConsent){if(!n.isDefined(window.__tcfapi)){Log.info2("__tcfapi not found -> Will load the oneTrust scripts");try{await s.loadScript("https://cdn.cookielaw.org/consent/cmp.stub.js",{"data-domain-script":__adLib.oneTrustId})}catch(e){throw Log.error("Unable to load oneTrust cmp.stub.js script"),e}try{await s.loadScript("https://cdn.cookielaw.org/scripttemplates/otSDKStub.js",{"data-domain-script":__adLib.oneTrustId})}catch(e){throw Log.error("Unable to load oneTrust otSDKStub.js script "),e}Log.info2("oneTrust scripts loaded")}Log.info2("set OptanonWrapper function"),window.OptanonWrapper=()=>{Log.info2(`OptanonWrapper called. Defer Ads status is [${u.getDeferAdsStatus()}]`),u.getDeferAdsStatus()&&(Log.info2("Defer Ads status is true -> Set Read TCData callback"),window.__tcfapi("getTCData",2,((e,t)=>{if(Log.info2(`TCData read: success = [${t}] data = `,e),!t||u.statusOk(e))return Log.info2("Error or status already OK -> send message to the app to load the ads immediately "),void u.setDeferAdsStatus(!1);const i=(e,t)=>{Log.info2("Received __tcpapi status change Event: ",e),t&&u.statusOk(e)&&(Log.info2("Status now OK, remove the event listener and send message to the app to load the ads immediately"),window.__tcfapi("removeEventListener",2,i),u.setDeferAdsStatus(!1))};Log.info2("Status not OK yet. Set event listener to load the ads when it will be OK"),window.__tcfapi("addEventListener",2,i)})))},Log.info2("Defer the ads loading by default"),u.setDeferAdsStatus(!0)}else Log.info2("Not Consent Required")}static getDeferAdsStatus(){return __adLib.deferAds}static setDeferAdsStatus(e){__adLib.deferAds=e,e||document.dispatchEvent(new Event("endDeferAds"))}static statusOk(e){return"useractioncomplete"==e.eventStatus||"tcloaded"==e.eventStatus}static getPrebidConsentParameters(){return __adLib.usPrivacyConsent?__adLib.prebidCcpaConfiguration:__adLib.requiresConsent?__adLib.prebidGdprConfiguration:null}static onDNSMILinkClicked(){Log.info2("CCPA consent called"),Log.info2("create default IAB cookie [1YYY]"),p.createCookie(1,!0,!0,!0),Log.info2("Modifies onetrust OptanonConsent cookies and ActiveGroups global variables");let e=[4],t=decodeURIComponent(a.readCookie("OptanonConsent "));Log.info2("Current OptanonConsent cookie value = ",t);for(let i of e)t=t.replace(`,${i}:1,`,`,${i}:0,`),window.OptanonActiveGroups=window.OptanonActiveGroups.replace(`,${i},`,","),window.OnetrustActiveGroups=window.OnetrustActiveGroups.replace(`,${i},`,",");Log.info2("New OptanonConsent cookie value = ",t),Log.info2(`New OptanonActiveGroups = [${window.OptanonActiveGroups}]`),Log.info2(`New OneTrustActiveGroups = [${window.OnetrustActiveGroups}]`),a.createCookieSession("OptanonConsent",encodeURI(t),__adLib.topDomain),a.createCookieSession("EbConsentClosed","true"),Log.info2("created new OptanonConsent and EbConsentClosed cookies")}}class h{static CATFISH_ID="AD_STATIC_CATFISH";static newCatfish(e,i){Log.info("Create a catfish container");let o=`<div id="${h.CATFISH_ID}" class="__alCatfish" style=" ${e?`width:${e}px;`:""} ${i?`height:${i}px`:""}"></div>`;return s.insert(t.append,document.body,o),Log.info("Static Catfish Inserted",h.getCurrentCatfishElement()),h.getCurrentCatfishElement()}static getCurrentCatfishElement(){return s.get(`#${h.CATFISH_ID}`)}}class m{static providerClasses=new Map([[g.DFP,f]]);providers=new Map;timers=[];isAdBlockerActivated(){let e=s.get("#_MGS_");e||(s.insert(t.append,document.body,'<div id="_MGS_"><div class="adBanner" style="height:1px"></div></div>'),e=s.get("#_MGS_"));let i=s.get("div",e);return"none"===window.getComputedStyle(i).display}async init(){Log.info("Init Ads manager at page load"),p.init(),await u.init(),Log.info("Set tab visibility event handler"),s.setEventListener(document,"visibilitychange",(()=>{let e="visible"===document.visibilityState;Log.info(`Tab visibility changed to [${e}]`),e?this.resumeAllPausedTimers():this.pauseAllRunningTimers()})),__adLib.deferAds?(Log.info("Ads need to be deferred. Will wait until the [endDeferAds] is fired"),s.setEventListener(document,"endDeferAds",(()=>{Log.info("Deferred Ads event triggered. Will now initialize the ads"),this.contentLoadInit()}))):(Log.info("No deferred ads. Will initialize the ads now"),this.contentLoadInit(document.body,__adLib.initialLoadAds))}async contentLoadInit(e=document.body,t){let i;if(Log.info(" ============================================================================================="),Log.info("Initialize container with ads"),Log.info(" ============================================================================================="),t)i=t;else{Log.info("Look for json ads definition in ",e);let t=d.getJsonFromScriptSnippet("ads-script",e);if(!t)return void Log.info("Did not find ads definition.");if(i=t,!i)return;Log.info("Found ad definitions: ",i)}let o=new Map;for(let t of i){if(Log.info("Init this ad: ",t),!this.providers.has(t.type)){Log.info(`Initializes Provider: [${t.type}]`);try{let e=new(m.providerClasses.get(t.type));await e.initProvider(),this.providers.set(t.type,e)}catch(e){Log.error(`Unable to instantiate Ad Provider: [${t.type}]`,t,e);continue}}let i=this.providers.get(t.type);o.has(t.type)||o.set(t.type,[]),t.provider=i;let n=null;if(t.displayType==c.REGULAR)n=s.get(t.selector,e);else if(t.displayType==c.CATFISH){if(n=h.getCurrentCatfishElement(),n){let e=s.get(".__alAd",n).ad;e.provider.refreshAds([e]),Log.info("Catfish already exists, just refresh its ad");continue}n=h.newCatfish(),t.injector="append"}n?(t.$container=i.createSlot(t,n),t.$container?(t.$container.ad=t,t.refreshCounter=0,i.addAd(t),o.get(t.type).push(t),t.autoRefresh?(t.$container.isInViewPort=!1,t.refreshTimer=new l((()=>{m.timerCallback(t)}),1e3*__adLib.refreshTimer),this.timers.push(t.refreshTimer),Log.info("This ad is autorefresh, added refresh timer: ",t.refreshTimer)):(t.refreshTimer=null,t.$container.isInViewPort=!0,Log.info("This ad is not autorefresh -> no refresh timer")),t.displayType==c.CATFISH?(Log.info("The ad is a catfish -> always in viewport and start refresh timer"),t.$container.isInViewPort=!0,t.refreshTimer&&t.refreshTimer.start()):t.autoRefresh&&(Log.info("Add the ad container to the observer -> ",t.$container),this.isInViewPortObserver.observe(t.$container)),Log.info("Ad initialized",t)):Log.info("Slot creation failed -> skip this ad")):Log.info("Error when initializing the ad/Existing ad -> skip it: ",t)}for(let[e,t]of o)0==t.length?Log.info(`No ads for [${e}] provider`):(Log.info(`Request Bids for [${e}] provider: `,t),this.providers.get(e).requestBids(t));if(__adLib.stickyContainerSelector){const t=s.getAll(`${__adLib.stickyContainerSelector} .__alAd`,e);let i=t.length;if(i>0){let e=t.item(i-1);Log.info("Last ad is sticky",e),s.addClass(e,"__alSticky",__adLib.stickyAdClass)}}}isInViewPortObserver=new IntersectionObserver((e=>{e.forEach((e=>{let t=e.target;t.isInViewPort=e.intersectionRatio>=__adLib.viewportThreshold,t.isInViewPort?(Log.info("Ad in viewport -> resume timer",t.ad),m.resumeRefreshTimer(t.ad)):(Log.info("Ad out of viewport -> stop timer",t.ad),m.pauseRefreshTimer(t.ad))}))}),{threshold:__adLib.viewportThreshold});static timerCallback(e){Log.info("Ad is refreshed.",e),e.refreshCounter++,e.provider.refreshAds([e])}static resumeRefreshTimer(e){Log.info("Resume refresh timer for ",e),e.refreshTimer.state==i.PAUSED?e.refreshTimer.resume():e.refreshTimer.state==i.STOPPED&&e.refreshTimer.start()}static pauseRefreshTimer(e){Log.info("Pause refresh timer for ",e),e.refreshTimer.pause()}pausedTimers=[];pauseAllRunningTimers(){this.pausedTimers=this.timers.filter((e=>e.state==i.RUNNING)),0!=this.pausedTimers.length&&(this.pausedTimers.forEach((e=>e.pause())),Log.info("Pause these timers: ",this.pausedTimers.map((e=>e.id))))}resumeAllPausedTimers(){0!=this.pausedTimers.length&&(this.pausedTimers.forEach((e=>e.resume())),Log.info("Resume these timers: ",this.pausedTimers.map((e=>e.id))))}refreshAllAds(){Log.info("Refresh All ads"),this.providers.forEach((e=>{Log.info(`will refresh ads for this provider: [${e.getName()}]`);for(let t of e.ads)t.refreshCounter++;e.refreshAllAds();for(let t of e.ads)t.refreshTimer&&t.refreshTimer.restart()}))}}n.isDefined(typeof window.__adLib)&&s.onDocumentReady((()=>{window.Log=new o(e[__adLib.logLevel]),window.Log.info("Ad Library Loaded"),window.AdsManager=new m,AdsManager.init()}))}));
//# sourceMappingURL=britannica-ads.umd.js.map

@@ -12,3 +12,4 @@ export interface ItcData {

private static statusOk;
static getPrebidConsentParameters(): object;
static onDNSMILinkClicked(): void;
}
export declare class PrebidForVideo {
static prebidDFPIdPrefix: string;
static getPrebidUrl(adUnitId: string, callback: (url: string) => void): void;
static addJwPlayerAdSetup(prebidUrl: string, jwplayerSetup: any): void;
}
{
"name": "@britannica/ads",
"version": "1.0.0-beta.1",
"version": "1.0.0-beta.2",
"description": "Britannica and MW ad library",

@@ -5,0 +5,0 @@ "main": "dist/britannica-ads.cjs.js",

@@ -26,3 +26,3 @@ import './AdsManager.scss';

public isAdBlockerActivated(): boolean {
var $container = alDOM.get('#_MGS_');
let $container = alDOM.get('#_MGS_');
if (!$container) {

@@ -36,3 +36,3 @@ alDOM.insert(

}
var $adBanner = alDOM.get('div', $container);
let $adBanner = alDOM.get('div', $container);
return window.getComputedStyle($adBanner).display === 'none';

@@ -66,3 +66,3 @@ }

alDOM.setEventListener(document, 'visibilitychange', () => {
var isTabVisible = document.visibilityState === 'visible';
let isTabVisible = document.visibilityState === 'visible';
Log.info(`Tab visibility changed to [${isTabVisible}]`);

@@ -93,3 +93,3 @@ if (isTabVisible) {

Log.info('No deferred ads. Will initialize the ads now');
this.contentLoadInit();
this.contentLoadInit(document.body, __adLib.initialLoadAds);
}

@@ -103,3 +103,3 @@ }

public async contentLoadInit($container: HTMLElement = document.body) {
public async contentLoadInit($container: HTMLElement = document.body, adDef?: IAd[]) {
Log.info(' =============================================================================================');

@@ -109,18 +109,28 @@ Log.info('Initialize container with ads');

let adDefinitions: IAd[];
// ---------------------------------------------------------------------------------------------------------------
// --- get the ads definition in the content
// --- adDefinitions are passed as parameter
// ---------------------------------------------------------------------------------------------------------------
Log.info('Look for json ads definition in ', $container);
var adsJson: object = alJson.getJsonFromScriptSnippet('ads-script', $container);
if (!adsJson) {
Log.info('Did not find ads definition.');
return;
if (adDef) {
adDefinitions = adDef;
}
var adDefinitions: IAd[] = adsJson as IAd[];
if (!adDefinitions) {
return;
// ---------------------------------------------------------------------------------------------------------------
// --- otherwise get the ads definition in the content
// ---------------------------------------------------------------------------------------------------------------
else {
Log.info('Look for json ads definition in ', $container);
let adsJson: object = alJson.getJsonFromScriptSnippet('ads-script', $container);
if (!adsJson) {
Log.info('Did not find ads definition.');
return;
}
adDefinitions = adsJson as IAd[];
if (!adDefinitions) {
return;
}
Log.info('Found ad definitions: ', adDefinitions);
}
Log.info('Found ad definitions: ', adDefinitions);

@@ -153,3 +163,3 @@ // ---------------------------------------------------------------------------------------------------------------

var adProvider: AbstractProvider = this.providers.get(ad.type);
let adProvider: AbstractProvider = this.providers.get(ad.type);
if (!adsMap.has(ad.type)) {

@@ -262,3 +272,3 @@ adsMap.set(ad.type, []);

const $rrAds = alDOM.getAll(`${__adLib.stickyContainerSelector} .__alAd`, $container);
var l = $rrAds.length;
let l = $rrAds.length;
if (l > 0) {

@@ -283,3 +293,3 @@ let $stickyAd = $rrAds.item(l - 1);

entries.forEach((entry) => {
var $adContainer: IAdContainer = entry.target as IAdContainer;
let $adContainer: IAdContainer = entry.target as IAdContainer;
$adContainer.isInViewPort = entry.intersectionRatio >= __adLib.viewportThreshold;

@@ -286,0 +296,0 @@ if ($adContainer.isInViewPort) {

@@ -105,2 +105,30 @@ import { alCookie, alDOM, alObject } from '../helpers';

// ========================================================================================================================
// --- Returns consent properties to be added to the prebid request
// ========================================================================================================================
public static getPrebidConsentParameters(): object {
// -----------------
// --- requires ccpa
// -----------------
if (__adLib.usPrivacyConsent) {
return __adLib.prebidCcpaConfiguration;
}
// -----------------
// --- requires gdpr
// -----------------
else if (__adLib.requiresConsent) {
return __adLib.prebidGdprConfiguration;
}
// ---------------------
// --- No consent needed
// ---------------------
else {
return null;
}
}
// ========================================================================================================================
// --- Set the IAB cookie / update onetrust when the user clicks on the DNSMI link in CA

@@ -107,0 +135,0 @@ // ========================================================================================================================

@@ -55,3 +55,3 @@ //US Privacy String API - required by the IAB to be a specific format

case 'getuspdata':
var privacyObject: IabPrivacyObject = {
let privacyObject: IabPrivacyObject = {
version: version,

@@ -90,13 +90,13 @@ uspString: alCookie.readCookie(Iab.US_PrivacyCookieName),

public static createCookie(version: number = 1, notice?: boolean, optOutSale?: boolean, lspa?: boolean): void {
var charValue = (c: boolean): string => (c === true ? 'Y' : c === false ? 'N' : '-');
let charValue = (c: boolean): string => (c === true ? 'Y' : c === false ? 'N' : '-');
var value = version.toString() + charValue(notice) + charValue(optOutSale) + charValue(lspa);
let value = version.toString() + charValue(notice) + charValue(optOutSale) + charValue(lspa);
var samesiteString = 'SameSite=Lax; ',
let samesiteString = 'SameSite=Lax; ',
secureString = '',
pathString = 'path=/; ',
nameString = `${Iab.US_PrivacyCookieName}=${value}; `;
var date = new Date();
let date = new Date();
date.setTime(date.getTime() + Iab.US_PrivacyCookieDuration * 24 * 60 * 60 * 1000);
var expireString = `expires=${date.toUTCString()}; `;
let expireString = `expires=${date.toUTCString()}; `;

@@ -118,5 +118,5 @@ document.cookie = nameString + expireString + pathString + samesiteString + secureString;

Log.info2('Received __uspapiCall event. Will post message to sender with the cookie content');
var i = json.__uspapiCall;
let i = json.__uspapiCall;
window.__uspapi(i.command, i.version, function (retValue, success) {
var returnMsg = {
let returnMsg = {
__uspapiReturn: {

@@ -123,0 +123,0 @@ returnValue: retValue,

@@ -7,2 +7,3 @@ import { alLog, callbackFunction } from './helpers';

import IBidderInfo = pbjs.IBidderInfo;
import { IAd } from './common/types';

@@ -37,2 +38,4 @@ declare module '*.module.scss';

prebidTimeout: number;
prebidCcpaConfiguration: object;
prebidGdprConfiguration: object;
includeIndex: boolean;

@@ -47,2 +50,3 @@ includeA9: boolean;

showPrerollAd: boolean;
prerollAdIsRunning: boolean;
showPrerollAdInVideos: boolean;

@@ -53,2 +57,3 @@ videoForPrebidLoaded: boolean;

stickyAdClass: string;
initialLoadAds?: IAd[];
}

@@ -55,0 +60,0 @@

@@ -190,4 +190,4 @@ export type callbackFunction = () => void;

static onScroll(callback: callbackFunctionWithParameters, timeout: number): void {
var f = function (callback: callbackFunctionWithParameters, timeout: number) {
var tick = false;
let f = function (callback: callbackFunctionWithParameters, timeout: number) {
let tick = false;
return function () {

@@ -226,3 +226,3 @@ if (!tick) {

public static isAdBlockerActivated(): boolean {
var $container = alDOM.get('#_MGS_');
let $container = alDOM.get('#_MGS_');
if (!$container) {

@@ -322,3 +322,3 @@ alDOM.insert(

static elementContentToJson($container: HTMLElement): object {
var json = $container.innerText;
let json = $container.innerText;
try {

@@ -325,0 +325,0 @@ return JSON.parse(json);

@@ -21,8 +21,14 @@ import { IAd } from '../common/types';

public abstract getType(): ProviderType;
public abstract initProvider(): void; // async
public abstract getName(): string;
public abstract createSlot(ad: IAd, $adContainer: HTMLElement): HTMLElement;
public abstract requestBids(ads: IAd[]): void;
public abstract refreshAds(ads: IAd[]): void;
public abstract refreshAllAds(): void;
}

@@ -12,3 +12,3 @@ // ============================================================================================================================

Log.info('Create a catfish container');
var _catfishHtml = `<div id="${Catfish.CATFISH_ID}" class="__alCatfish" style=" ${
let _catfishHtml = `<div id="${Catfish.CATFISH_ID}" class="__alCatfish" style=" ${
width ? `width:${width}px;` : ''

@@ -15,0 +15,0 @@ } ${height ? `height:${height}px` : ''}"></div>`;

@@ -31,3 +31,5 @@ // ***************************************

function init(initParams: InitParameters): void;
function fetchBids(params: { slots: Ia9Slot[] }, f: callbackFunction): void;
function setDisplayBids(): void;

@@ -148,6 +150,6 @@ }

if (alObject.isDefined(Storage)) {
var targetingParamStr = localStorage.getItem('bcDFPTargetingParams');
let targetingParamStr = localStorage.getItem('bcDFPTargetingParams');
if (targetingParamStr) {
Log.info('Setting Blueconic targeting parameters');
var targetingParameters = JSON.parse(targetingParamStr);
let targetingParameters = JSON.parse(targetingParamStr);
targetingParameters.forEach((i: { key: string; value: string }) =>

@@ -178,3 +180,3 @@ googletag.pubads().setTargeting(i.key, i.value)

if (__adLib.includeA9) {
var a9InitParams: InitParameters = {
let a9InitParams: InitParameters = {
pubID: __adLib.a9Id,

@@ -215,5 +217,5 @@ adServer: 'googletag',

var params = ad.adParameters;
var defaultWidth = params.size[0][0];
var defaultHeight = params.size[0][1];
let params = ad.adParameters;
let defaultWidth = params.size[0][0];
let defaultHeight = params.size[0][1];

@@ -226,3 +228,3 @@ // --- container

var placeholderCss = '';
let placeholderCss = '';

@@ -239,3 +241,3 @@ if (ad.displayType != DisplayType.CATFISH) {

// find the average heigh of all possible renditions
var avgHeight = Math.round(
let avgHeight = Math.round(
params.size.map((s) => s[1] as number).reduce((sum, height) => sum + height) / params.size.length

@@ -249,3 +251,3 @@ );

var id = `DFP_${this.index++}`;
let id = `DFP_${this.index++}`;
ad.containerId = id;

@@ -256,4 +258,4 @@ ad.dfpSize = params.size.length == 1 ? params.size[0] : params.size;

var style = `style="${placeholderCss}${alString.defaultIfBlank(params.style, '')}"`;
var html = `<div data-type="${ad.type}" class="__alAd ${alString.defaultIfBlank(
let style = `style="${placeholderCss}${alString.defaultIfBlank(params.style, '')}"`;
let html = `<div data-type="${ad.type}" class="__alAd ${alString.defaultIfBlank(
__adLib.adClass,

@@ -267,3 +269,3 @@ ''

this.setDfpA9Slot(ad);
let idSuffix = this.setDfpA9Slot(ad);

@@ -274,2 +276,3 @@ // --- update container

$container.setAttribute('data-identifier', ad.dfpSlot.getAdUnitPath());
$container.setAttribute('data-qa-identifier', idSuffix);
return $container;

@@ -286,7 +289,8 @@ } catch (e) {

private setDfpA9Slot = function (ad: IdfpAd): void {
private setDfpA9Slot = function (ad: IdfpAd): string {
Log.info('Initializes DFP slot and A9 slot for ', ad);
var params = ad.adParameters;
var idPrefix = __adLib.dfpIdPrefix.replace('${LEG}', __adLib.leg) + `${__adLib.isPhone ? 'MOBILE' : 'DESKTOP'}_`;
var adUnit = `/${__adLib.googleDfpId}/${idPrefix}${params.id}`;
let params = ad.adParameters;
let idPrefix = __adLib.dfpIdPrefix.replace('${LEG}', __adLib.leg);
let idSuffix = `${__adLib.isPhone ? 'MOBILE' : 'DESKTOP'}_${params.id}`;
let adUnit = `/${__adLib.googleDfpId}/${idPrefix}${idSuffix}`;
Log.info(`Define new slot: [${adUnit}] with: size [${ad.dfpSize}] id [${ad.containerId}]`);

@@ -304,2 +308,3 @@ ad.dfpSlot = googletag.defineSlot(adUnit, ad.dfpSize, ad.containerId);

Log.info('DFP/A9 slot defined for ', ad);
return idSuffix;
};

@@ -406,3 +411,3 @@

if (__adLib.includeA9) {
var a9Slots = ads.map((ad) => ad.a9Slot);
let a9Slots = ads.map((ad) => ad.a9Slot);
Log.info('Calls A9 with these slots:', a9Slots);

@@ -409,0 +414,0 @@

@@ -9,4 +9,2 @@ import { LogLevel } from '../helpers';

static prebidDFPIdPrefix = `${__adLib.googleDfpId}/EB_${__adLib.leg}/${__adLib.dfpUnitPrefix}`;
public static getPrebidUrl(adUnitId: string, callback: (url: string) => void) {

@@ -44,6 +42,7 @@ // ----------------------------

bidsBackHandler: () => {
var params = { iu: `${PrebidForVideo.prebidDFPIdPrefix}${adUnitId}`, output: 'vast' };
let prebidDFPIdPrefix = `${__adLib.googleDfpId}/EB_${__adLib.leg}/${__adLib.dfpUnitPrefix}`;
let params = { iu: `${prebidDFPIdPrefix}${adUnitId}`, output: 'vast' };
Log.info('Prebid video url called. Params = ', params);
var prebidUrl = pbjs.adServers.dfp.buildVideoUrl({
let prebidUrl = pbjs.adServers.dfp.buildVideoUrl({
adUnit: __adLib.prebidVideoAdUnit,

@@ -50,0 +49,0 @@ params: params,

@@ -18,2 +18,11 @@ import { alAdUtils, alDOM, alObject, callbackFunction, DomInsertPosition } from '../helpers';

) {
// ------------------------------------------------
// --- Check if a preroll ad is not already running
// ------------------------------------------------
if (__adLib.prerollAdIsRunning) {
Log.info('Preroll Ad is already running. Ignore this one');
return;
}
// -------------------------------

@@ -38,2 +47,8 @@ // --- Preroll not enabled -> exit

// --------------------
// --- set running flag
// --------------------
__adLib.prerollAdIsRunning = true;
// -------------------------------------------

@@ -49,2 +64,3 @@ // -- jwplayer not present -> loads the script

Log.error('Unable to load jwplayer script -> skip ad');
__adLib.prerollAdIsRunning = false;
callback();

@@ -108,2 +124,3 @@ return;

alDOM.removeClass($container, PrerollAd.CONTAINER_CLASS);
__adLib.prerollAdIsRunning = false;
callback();

@@ -110,0 +127,0 @@ };

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc