cdn-adm.pbstck.com Open in urlscan Pro
2606:4700:10::6816:5d  Public Scan

URL: https://cdn-adm.pbstck.com/kleanads/js/kleanads-2410241839.js
Submission: On October 25 via api from IT — Scanned from IT

Form analysis 0 forms found in the DOM

Text Content

var kleanads=function(e){"use strict";var t,i,n;!function(e){e.HISTORY_MUTATION="_pbstck_kleanads_historyMutation",e.PAGE_CHANGE="_pbstck_kleanads_pageChange",e.REFRESH_INIT="_pbstck_kleanads_refreshInit"}(t||(t={})),function(e){e.SPA_RELOAD="admSPAReload"}(i||(i={})),function(e){e.REPLACE_STATE="replaceState",e.PUSH_STATE="pushState"}(n||(n={}));const s=e=>{window.history[e]=new Proxy(window.history[e],{apply(i,n,s){const o=window.location.href,a=i.apply(n,s),r=new CustomEvent(t.HISTORY_MUTATION,{detail:{referrer:o,stateObj:s[0],title:s[1],url:s[2],type:e}});return dispatchEvent(r),a}})},o=()=>{s(n.REPLACE_STATE),s(n.PUSH_STATE)};var a;const r=/kleanads:debug/.test(window.location.href),d=!!(null===(a=window.localStorage)||void 0===a?void 0:a.getItem)&&null!==window.localStorage.getItem("kleanads");function l(){return r||d}function c(e,t){return`[${e}] [${performance.now().toFixed(2)}] ${t}`}function u(e,t,...i){l()&&console.log(c(e,t),...i)}function f(e,t,...i){l()&&console.debug(c(e,t),...i)}function h(e,t,...i){l()&&console.error(c(e,t),...i)}function g(e,t){const i={type:"customEvent",eventName:e,message:t};window.postMessage(i,"*")}function p(e){const t=document.createElement("meta");t.setAttribute("name","pbstck_context:pbstck_ab_test"),t.content=e,document.head.appendChild(t)}function v(e,t){const i=document.createElement("meta");i.setAttribute("name",`pbstck:${e}`),i.content=t,document.head.appendChild(i)}function m(e){const t={};e.document.querySelectorAll('meta[name^="ad:"]').forEach((e=>{const i=function(e){var t;const i=(null===(t=e.attributes.getNamedItem("name"))||void 0===t?void 0:t.value)||"";return i.startsWith("ad:")?i.slice(3):i}(e);i&&(t[i]=function(e){var t;const i=(null===(t=e.attributes.getNamedItem("content"))||void 0===t?void 0:t.value)||"";return i.split(",")}(e))}));const i=new URLSearchParams(e.location.search);for(const e of i.keys())e.startsWith("ad:")&&(u("kleanads-common",`Add key ${e} found in URL to metaTargetings`),t[e.slice(3)]=i.getAll(e));return t}function b(){const e=document.head.querySelector('meta[name="ad:no_cmp"]');return!!e&&"true"===e.content}var y;!function(e){e.Stop="stop",e.Continue="continue",e.InstantSecondChance="instantSecondChance"}(y||(y={}));const A={advertisers:[],orders:[],lineItems:[]},S="adm";class I{constructor(e,t,i,n=1){this.tagId=e,this.kleanadsVersion=t,this.throttling=n,this.device=i||"na"}handleMessage(e,t,i){const n={source:"kleanads",type:"log",level:e,message:t,tagId:this.tagId,kleanadsVersion:this.kleanadsVersion,href:window.location.href,device:this.device,...i};var s,o;s=n,o=this.throttling,100*Math.random()<o&&navigator.sendBeacon("https://intake.pbstck.com/v1/trace",JSON.stringify(s))}error(e){this.handleMessage("error",e)}warn(e){this.handleMessage("warn",e)}logWithPayload(e,t){this.handleMessage("info",e,t)}errorWithPayload(e,t){this.handleMessage("error",e,t)}}const C="kleanads";let w,E="na",_="na",k="na";function T(e){k=e}function O(e,...t){u(C,e,...t)}function R(e,...t){f(C,e,...t)}function $(e,...t){!function(e,t,...i){l()&&console.warn(c(e,t),...i)}(C,e,...t),null==w||w.warn(e)}function P(e,...t){h(C,e,...t),null==w||w.error(e),navigator.sendBeacon(`https://intake.pbstck.com/v1/intake/error?tId=${E}&v=${_}&s=${k}&c=1`,JSON.stringify([{message:e}]))}function L(e,t){null==w||w.logWithPayload(e,t)}function N(e){return null!==document.getElementById(e)}function U(e){const t=document.getElementById(e);if(t){return t.getBoundingClientRect().top}return O(`[DOM] div ${e} not found during get distance from top`),0}function x(e,t){return new Promise(((i,n)=>e().then(i).catch((i=>{return t>1?(s=100,new Promise((e=>setTimeout(e,s)))).then(x.bind(null,e,t-1)).then((e=>e)).catch(n):n(i);var s}))))}const D=async(e,t=3)=>x((()=>import(e)),t).then((e=>e)).catch((i=>{throw P(`Failed to load module ${e} after ${t} retries`,i),new Error("Too many failed attempt to load external module.")})),j=(e,t)=>{const i=function(e,t){const i=document.createElement("script");return i.setAttribute("src",e),i}(e);i.setAttribute("async","true"),i.setAttribute("data-kleanads","true"),document.head.append(i)};async function M(e,t){const{beforeStart:i}=t,n=function(e,t){var i;return(null!==(i=e.extraScripts)&&void 0!==i?i:[]).filter((i=>i.tagId===e.tagId&&!!i.beforeStart===t))}(e,i);if(n.length>0){O(i?"Loading extraScripts before config":"Loading extraScripts after consent");const e=n.filter((({synchronous:e})=>!e)).flatMap((e=>e.scripts)),t=n.filter((({synchronous:e})=>e)).flatMap((e=>e.scripts));O(`downloading async extra script ${e}`),e.forEach((e=>j(e))),O(`downloading sync extra script ${t}`);for(const e of t)try{await D(e)}catch(e){O("[extra-script] Error while loading sync extra script",e)}}}function B(e,t){return e.size<t.size?1:e.size>t.size?-1:0}function V(e){return e.filter(G)}function F(e){if("fluid"===e)return"fluid";const[t,i]=e.split("x");return[parseInt(t,10),parseInt(i,10)]}function z(e){return e>=100||e>=Math.floor(100*Math.random())+1}function W(e){if(100!==e.reduce(((e,t)=>e+t),0))return O("The sum of all probabilities should be equal to 100 and is not, we use the first version of the ab test"),1;const t=e.reduce(((e,t)=>(e.length?e.push(e[e.length-1]+t):e.push(t),e)),[]),i=Math.floor(100*Math.random())+1;return t.findIndex((e=>i<=e))+1}function G(e){return Array.isArray(e)&&2===e.length&&"number"==typeof e[0]&&"number"==typeof e[1]}const H=["master","master-1","master-2","master-3","companion",void 0],J=(e,t)=>H.indexOf(e.roadblock)-H.indexOf(t.roadblock)||U(e.divId)-U(t.divId);var K;!function(e){e.USE_EXISTING_DIV="useExistingDiv",e.CREATE_NEW_DIV="createNewDiv"}(K||(K={}));const Y=(e,t)=>"fluid"===e&&"fluid"===t||e[0]===t[0]&&e[1]===t[1],q=e=>!!e.sizes.find((e=>Y(e,[1800,1e3])));function X(e){var t;const i=null!==(t=e.values)&&void 0!==t?t:[];return e.value?e.value:i}const Q=(e,t)=>{var i;return{...t,bids:e.bidders.map((e=>({bidder:e.bidder,params:e.params}))),mediaTypes:{video:null===(i=e.instreamParams)||void 0===i?void 0:i.mediaTypeParams}}},Z=(e,t)=>({...t,bids:e.bidders.filter((e=>e.mediaTypes.includes("Outstream"))).map((e=>({bidder:e.bidder,params:e.params}))),mediaTypes:{video:{context:"outstream",playerSize:[640,480],mimes:["video/mp4","video/ogg","video/webm","application/javascript"],protocols:[1,2,3,4,5,6,7,8,11,12,13,14],api:[1,2,3,5,6,7],playbackmethod:[2,3,4],skip:1,linearity:2,startdelay:0,placement:3,plcmt:4,maxduration:30,playVideoVisibleThreshold:25,nonViewableBehavior:"pause"}},renderer:{url:"https://acdn.adnxs.com/video/outstream/ANOutstreamVideo.js",options:{adText:"",aspectRatio:"16:9",skippable:{enabled:!0,skipButtonText:"SKIP"}}}}),ee=["adyoulike"],te=(e,t)=>{const i=e.bidders,n=e.biddersSkin?i.filter((t=>{var i;return null===(i=e.biddersSkin)||void 0===i?void 0:i.includes(t.bidder)})):i,s={...t,bids:n.filter((e=>!ee.includes(e.bidder))).map((e=>({bidder:e.bidder,params:e.params}))),mediaTypes:{banner:{sizes:[[1800,1e3]]}}},o=V(e.sizes).filter((e=>!Y(e,[1800,1e3])));if(o.length>0){return[{...t,bids:i.map((e=>({bidder:e.bidder,params:e.params}))),mediaTypes:{banner:{sizes:o}}},s]}return[s]},ie=(e,t)=>({...t,bids:e.bidders.filter((e=>e.mediaTypes.includes("Banner"))).map((e=>({bidder:e.bidder,params:e.params}))),mediaTypes:{banner:{sizes:V(e.sizes)}}}),ne=(e,t)=>({...t,bids:e.bidders.filter((e=>e.mediaTypes.includes("Native"))).map((e=>({bidder:e.bidder,params:e.params}))),mediaTypes:{native:e.nativeParams}});function se(e,t){var i;const n=e.floors;n&&t&&(n.values.banner=Math.max(n.values.banner,t));const s={code:e.divId,pubstack:{adUnitName:e.adServerAdUnitName,adUnitPath:oe(e)},floors:n,ortb2Imp:e.ortb2Imp},o=e.getTargetings();if(o.find((e=>"ad_index"===e.key))){const e=null===(i=o.find((e=>"ad_index"===e.key)))||void 0===i?void 0:i.value;s.pubstack&&(s.pubstack.tags=[`ad_index:${e}`])}const a=e.mediaTypes;if(a.includes("Instream"))return[Q(e,s)];const r=[];return a.includes("Banner")&&(q(e)?r.push(...te(e,s)):e.sizes.length>0&&r.push(ie(e,s))),a.includes("Outstream")&&r.push(Z(e,s)),a.includes("Native")&&r.push(ne(e,s)),r}function oe(e){var t;const i=[...e.getTargetings()],n=(null!==(t=e.pubstackDeclarationTargetingKeys)&&void 0!==t?t:[]).map((e=>{const t=i.find((t=>t.key===e));if(t)return t;{const t=m(window)[e];return t?{key:e,values:t}:void 0}})).filter((e=>!!e)).map((e=>`${e.key}=${function(e){const t=e.values?e.values.join(","):"";return e.value?e.value:t}(e)}`)).join("&"),s=e.adUnitPath.includes("?")?"&":"?";return n.length>0?`${e.adUnitPath}${s}${n}`:e.adUnitPath}class ae{constructor(){this.uprEnabled=!0,this.disableGptPreAuction=!1,this.kleanadsRunCount=1}setUprState(e,t){switch("true"===function(e,t){const i=`meta[name="${t}"]`,n=e.document.querySelector(i);return null!==n?n.getAttribute("content"):null}(window,"adm_feature:upr_disabled")&&(e="disabled"),e){case"disabled":this.uprEnabled=!1;break;case"tested":this.uprEnabled=z(null!=t?t:50),this.uprTested=!0;break;default:this.uprEnabled=!0}}setKleanadsRunCount(e){this.kleanadsRunCount=e}static getInstance(){return ae.instance||(ae.instance=new ae),ae.instance}}function re(e){if("string"==typeof e)return!0;if(Array.isArray(e)){for(const t of e)if("string"!=typeof t)return!1;return!0}return!1}function de(e,t,i){const n=t.getTargeting(i);n&&n.length>0&&(O(`removing ${i} targeting from slot ${e}`),t.clearTargeting(i))}const le="bid_bidder",ce="bid_size",ue="bid_mediatype",fe="[instream] [Dailymotion]";class he{constructor(e,t,i,n){this.callbackAdded=!1,this.configSetOnce=!1,this.adReadyToFetchReceivedOnce=!1,this.adReadyToFetchCallback=()=>{},this.declaredAdUnit="",this.pubstackWindow=e,this.pageContext=t,this.device=i,this.targetings=pe(this.device,this.pubstackWindow),this.instreamType=null!=n?n:"dailymotion-v1"}declareAdUnit(e){"dailymotion-v3"===this.instreamType&&""===this.declaredAdUnit&&(this.declaredAdUnit=e.divId,this.executeWhenAdServerReady((()=>{const t=this.pubstackWindow.dailymotion;t?t.getPlayer(e.divId).then((t=>{var i;t.on(null===(i=this.pubstackWindow.dailymotion)||void 0===i?void 0:i.events.AD_READYTOFETCH,(()=>{O(`${fe} ${e.divId} event AD_READYTOFETCH received`),this.adReadyToFetchReceivedOnce||(this.adReadyToFetchReceivedOnce=!0),this.adReadyToFetchCallback()}))})):P(`${fe} unable to get dailymotion on the page`)})))}setApsTargetings(e){var t;if(0!==e.length){O(`${fe} putting targeting keys for aps auction of winning bidder`,e[0]);try{const i=null===(t=e[0].helpers)||void 0===t?void 0:t.qsParams();if(i)return void this.targetings.push(i.slice(1));const n=e[0].qsParams;if(n)return void this.targetings.push(n.slice(1))}catch(e){P(`${fe} error setting APS targetings`,e)}}}executeWhenAdServerReady(e){this.pubstackWindow.dailymotion?e():setTimeout(this.executeWhenAdServerReady.bind(this,e),100)}async callAdServer(e,t){var i,n,s;const o=e.divId;if("dailymotion-v3"===this.instreamType&&e.divId!==this.declaredAdUnit)return void P(`${fe} ${e.divId} call ad server but it is not the same divId as the one declared ${this.declaredAdUnit}`);O(`${fe} ${o} call ad server`);const a=await(null===(i=this.pubstackWindow.dailymotion)||void 0===i?void 0:i.getPlayer(o));if(!a)return void P(`${fe} no player found for ${o}`);O(`${fe} ${o} player:`,a);const r=await a.getState();switch(this.customConfig=function(e,t,i,n){var s,o;const a=function(e){return e.getTargetings().map(ge)}(e);O(`${fe} adUnitTargetings`,a);const r=Array.from(i.entries()).filter((([,e])=>!!e)).map((([e,t])=>`${e}=${t}`)),d=a.concat(t).concat(r).join("&"),l={...null===(s=e.instreamParams)||void 0===s?void 0:s.vast,vpmute:n.playerIsMuted?1:0},c=Object.keys(l).map((function(e){return`${e}=${l[e]}`})).join("&"),u=null===(o=e.instreamParams)||void 0===o?void 0:o.adDeactivationContext;let f=!1;if(u){const e=i.get(u.key);f=!!e&&u.values.includes(e)}const h={dynamiciu:e.adUnitPath,keyvalues:d,keyvalues2:c};return f?{...h,premium:"true"}:h}(e,this.targetings,this.pageContext,r),O(`${fe} generated customConfig`,this.customConfig),this.instreamType){case"dailymotion-v1":O(`${fe} ${o} setCustomConfig`,this.customConfig),a.setCustomConfig(this.customConfig),O(`${fe} ad server called ${o}`),document.dispatchEvent(new CustomEvent("admDailymotionReady",{detail:{divId:o}})),O(`${fe} ${o} admDailymotionReady event dispatched`);break;case"dailymotion-v2":this.callbackAdded||(O(`${fe} ${o} add callback to event ${null===(n=this.pubstackWindow.dailymotion)||void 0===n?void 0:n.events.AD_READYTOFETCH}`),a.on(null===(s=this.pubstackWindow.dailymotion)||void 0===s?void 0:s.events.AD_READYTOFETCH,(()=>{O(`${fe} ${o} event AD_READYTOFETCH received, setCustomConfig`,this.customConfig),this.customConfig&&a.setCustomConfig(this.customConfig),t&&(O(`${fe} ${o} event AD_READYTOFETCH, call "onCallFinished"`),t())})),this.callbackAdded=!0);break;case"dailymotion-v3":!this.configSetOnce&&this.adReadyToFetchReceivedOnce?(O(`${fe} ${e.divId} event AD_READYTOFETCH already received, setting customConfig"`,this.customConfig),this.customConfig&&(a.setCustomConfig(this.customConfig),this.configSetOnce=!0),t&&(O(`${fe} ${e.divId} event AD_READYTOFETCH, call "onCallFinished"`),t())):this.adReadyToFetchCallback=()=>{O(`${fe} ${e.divId} event AD_READYTOFETCH callback, setting customConfig"`,this.customConfig),this.customConfig&&a.setCustomConfig(this.customConfig)}}}setPbjsTargetings(e,t){if(e){O(`${fe} put pbjs targeting keys for ${t.divId}`);const i=e.getAdserverTargetingForAdUnitCode(t.divId);for(const e of Object.keys(i)){const n=i[e];re(n)?this.targetings.push(`${e}=${n}`):$(`${fe} [targeting] unable to set targeting ${e}=${n} on adUnit ${t.divId}`)}}else P(`${fe} no pbjs given: unable to put header bidding targetings`)}cleanTargetings(){this.targetings.splice(0),this.targetings.push(...pe(this.device,this.pubstackWindow))}}function ge(e){const t=X(e);return`${e.key}=${"string"==typeof t?t:t.join(",")}`}function pe(e,t){const i=[],n=m(t);Object.keys(n).forEach((e=>{const t=n[e].join(",");i.push(`${e}=${t}`)})),i.push(`${S}=1`),i.push(`device=${e}`);const s=ae.getInstance().grapeshotValues;(null==s?void 0:s.length)&&i.push(`gs_cat=${s.join(",")}`);try{const e=JSON.parse(t.localStorage._pdfps).slice(0,250).join(",");""!==e?i.push(`permutive=${e}`):O(`[${fe}] no permutive targeting found`)}catch(e){O(`[${fe}] error reading permutive targeting, ${e}`)}return i}const ve="adServerAdUnitName";function me(e,t,i,n){const s=[];if("number"!=typeof t&&""===t||s.push(t),i&&0!==i.length){const e=function(e,t){return e.filter((e=>e!==ve)).map((e=>t.get(e))).filter((e=>e)).join("/")}(i,n);e&&s.push(e)}else $("Ad unit path config is missing for this site");const o=`/${s.join("/")}`;return i&&i.includes(ve)?`${o}/${e}`:`${o}`}function be(e){return new Promise(((t,i)=>{if(window.lucead_loaded)return void t();window.lucead_loaded=!0;const n=document.createElement("script");n.src=`https://s.lucead.com/prebid/${e}.js`,n.onload=()=>t(window.lucead_prebid),n.onerror=i,document.head.appendChild(n)}))}function ye(e){return e&&"string"==typeof e?e:void 0}function Ae(e){if(null!=e&&"number"==typeof e)return e}function Se(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function Ie(e,t){if("string"!=typeof e)throw new Error(`Unable to parse JSON: the ${t} field ${e} is not a valid string`);return e}function Ce(e){var t,i,n,s,o,a,r,d,l;if(!Se(e))throw new Error("unable to parse JSON: adUnit is not valid");const c=Ie(e.divId,"divId"),u=Ie(e.adUnitName,"adUnitName"),f=function(e,t){if(!Array.isArray(e))throw new Error(`Unable to parse JSON: the ${t} field ${e} is not a valid list of Size`);return e}(e.sizes,"sizes"),h=function(e,t){if(!Array.isArray(e))throw new Error(`Unable to parse JSON: the ${t} field ${e} is not a valid list of PrebidBidder`);for(const t of e)if("string"!=typeof t.bidder)throw new Error(`Unable to parse JSON: the bidder field ${t.bidder} (inside bidders) is not a valid bidder name`);return e}(e.bidders,"bidders"),g=we(e.parallax,"parallax",!1),p=we(e.dynamic,"dynamic",!1),v=Ee(e.targeting,"targeting"),m=function(e,t){if(!e)return;if(!Array.isArray(e))throw new Error(`Unable to parse JSON: the ${t} field ${e} is not valid KeyValueTargeting list`);const i=[];for(const n of e){const e=Ee(n,t);e&&i.push(e)}return i}(e.extraTargetings,"extraTargetings");if(void 0!==e.floors&&!Se(e.floors))throw new Error("unable to parse JSON: the floors field is not valid");if(void 0!==(null===(t=e.floors)||void 0===t?void 0:t.currency)&&"string"!=typeof(null===(i=e.floors)||void 0===i?void 0:i.currency))throw new Error("unable to parse JSON: the floors field is missing the currency");if(void 0!==(null===(n=e.floors)||void 0===n?void 0:n.schema)&&!Se(null===(s=e.floors)||void 0===s?void 0:s.schema))throw new Error("unable to parse JSON: the floors field is missing the schema");if(e.floors){if("string"!=typeof(null===(o=e.floors.schema)||void 0===o?void 0:o.delimiter))throw new Error("unable to parse JSON: the floors schema field is missing the delimiter");if(!Array.isArray(null===(a=e.floors.schema)||void 0===a?void 0:a.fields))throw new Error("unable to parse JSON: the floors field schema delimiter is not an array");for(const t of e.floors.schema.fields)if(void 0===t||"string"!=typeof t)throw new Error("unable to parse JSON: the bidder field inside bidders array is not valid")}if(void 0!==(null===(r=e.floors)||void 0===r?void 0:r.values)&&"object"!=typeof(null===(d=e.floors)||void 0===d?void 0:d.values))throw new Error("unable to parse JSON: the floors field is missing the values or they are not well formed");if(void 0!==e.extraAdServerSizes&&!Array.isArray(e.extraAdServerSizes))throw new Error(`unable to parse JSON: the extraAdServerSizes field for adunit ${c} is not valid: ${e.extraAdServerSizes}`);let b,y,A,S;if(void 0!==e.canOutstream&&"boolean"!=typeof e.canOutstream)throw new Error("unable to parse JSON: the canOutstream field is not valid");if(b=e.canOutstream,void 0!==e.isInstream&&"boolean"!=typeof e.isInstream)throw new Error("unable to parse JSON: the isInstream field is not valid");if(y=e.isInstream,e.biddersOutstream){if(!Array.isArray(e.biddersOutstream))throw new Error(`unable to parse JSON: the biddersOutstream field for adunit ${c} is not valid: ${e.biddersOutstream}`);for(const t of e.biddersOutstream)if("string"!=typeof t)throw new Error("unable to parse JSON: the value inside biddersOutstream array is not valid")}switch(e.outOfPageType){case"interstitial":case"default":A=e.outOfPageType;break;default:A=void 0}switch(e.roadblock){case"master":case"master-1":case"master-2":case"master-3":case"companion":S=e.roadblock;break;default:S=void 0}return{divId:c,adUnitName:u,sizes:f,adServerAdUnitName:e.adServerAdUnitName,slotName:e.slotName,bidders:h,parallax:g,dynamic:p,targeting:v,extraTargetings:m,anchor:e.anchor,floors:e.floors,extraAdServerSizes:e.extraAdServerSizes,headerBiddingEnabled:we(e.headerBiddingEnabled,"headerBiddingEnabled",!0),canOutstream:b,isInstream:y,biddersOutstream:null!==(l=e.biddersOutstream)&&void 0!==l?l:[],outOfPageType:A,roadblock:S}}function we(e,t,i){if(void 0!==e&&"boolean"!=typeof e)throw new Error(`Unable to parse JSON: the ${t} field ${e} is not a valid boolean`);return null!=e?e:i}function Ee(e,t){if(!e)return;if(!Se(e))throw new Error(`Unable to parse JSON: the ${t} field ${e} is not a valid KeyValueTargeting`);const i=Ie(e.key,t),n=ye(e.value),s=function(e){if(e&&Array.isArray(e))return e}(e.values);if(!n&&!s)throw new Error(`Unable to parse JSON: targeting.value(s) is not valid for field ${t}`);return{key:i,value:n,values:s}}function _e(e){return e.startsWith("css:")?e.replace("css:",""):void 0}const ke=(e,t,i)=>e.includes("Outstream")?i.includes(t.bidder)?[...e]:[...e.filter((e=>"Outstream"!==e))]:[...e],Te=e=>{var t;const i=(e=>{var t;const i=[];return e.isInstream?["Instream"]:((e.sizes.length>0||(null!==(t=e.extraAdServerSizes)&&void 0!==t?t:[]).length>0)&&i.push("Banner"),e.canOutstream&&i.push("Outstream"),e.canNative&&i.push("Native"),i)})(e);let n=e.bidders.map((t=>({mediaTypes:ke(i,t,e.biddersOutstream),bidder:t.bidder,params:t.params})));if(i.includes("Native")&&(null===(t=e.biddersNative)||void 0===t?void 0:t.length)){n=n.map((e=>({...e,mediaTypes:e.mediaTypes.filter((e=>"Native"!==e))})));const t=e.biddersNative.map((e=>({mediaTypes:["Native"],bidder:e.bidder,params:e.params})));n.push(...t)}return{bidders:n,mediaTypes:i}};function Oe(e,t,i,n,s){return e.flatMap((e=>{var o,a,r,d,l,c;const u=me(e.adServerAdUnitName||e.divId,i,n,t);if(e.bidders.forEach((e=>{var t;if("lucead"===e.bidder&&(null===(t=e.params)||void 0===t?void 0:t.siteId)){const{siteId:t,...i}=e.params;e.params={...i,loader:be(t)}}})),e.dynamic)return function(e,t,i){return function(e){const t=_e(e.divId)||`[id^="${e.divId}"]`;try{return Array.from(document.querySelectorAll(t))}catch(e){return P(`${t} is not a valid CSS selector, ${e}`),[]}}(e).map((n=>{var s,o,a;const r=n.id;return r||P(`Unable to find an id on DOM element for adUnit.divId ${e.divId}`),{...e,...Te(e),divId:r,slotName:(null===(s=null==n?void 0:n.attributes.getNamedItem("data-aps-slotname"))||void 0===s?void 0:s.value)||e.slotName||t,dynamic:!1,adUnitPath:(null===(o=null==n?void 0:n.attributes.getNamedItem("data-adunitpath"))||void 0===o?void 0:o.value)||t,adServerAdUnitName:null!==(a=e.adServerAdUnitName)&&void 0!==a?a:e.divId,pubstackDeclarationTargetingKeys:null!=i?i:[],getTargetings:()=>[...[...e.targeting?[e.targeting]:[],...e.extraTargetings||[]],...[...$e(null==n?void 0:n.attributes),Re(r)]]}}))}(e,u,s);{const t=function(e){const t=_e(e);try{return t?document.querySelector(t):document.getElementById(e)}catch(t){return P(`${e} is not a valid CSS selector, ${t}`),null}}(e.divId);if(t||"interstitial"===e.outOfPageType||(null===(o=e.anchor)||void 0===o?void 0:o.mode)===K.CREATE_NEW_DIV){t&&!(null==t?void 0:t.id)&&P(`Unable to find an id on DOM element for adUnit.divId ${e.divId}`);const i=(null===(a=null==t?void 0:t.attributes.getNamedItem("data-adunitpath"))||void 0===a?void 0:a.value)||u;return[{...e,...Te(e),divId:null!==(r=null==t?void 0:t.id)&&void 0!==r?r:e.divId,adUnitPath:i,slotName:(null===(d=null==t?void 0:t.attributes.getNamedItem("data-aps-slotname"))||void 0===d?void 0:d.value)||e.slotName||i,adServerAdUnitName:null!==(c=null!==(l=e.adServerAdUnitName)&&void 0!==l?l:null==t?void 0:t.id)&&void 0!==c?c:e.divId,pubstackDeclarationTargetingKeys:null!=s?s:[],getTargetings:()=>[...[...e.targeting?[e.targeting]:[],...e.extraTargetings||[]],...[...$e(null==t?void 0:t.attributes)]]}]}return O(`Div id missing for ${e.divId}, no further action on this ad unit`),[]}}))}function Re(e){const t=new RegExp("\\D","g");return{key:"ad_index",value:e.replace(t,"")}}function $e(e){return Array.from(null!=e?e:[]).filter((e=>e.name.startsWith("data-ad-"))).map((e=>({key:e.name.replace("data-ad-",""),value:e.value})))}var Pe,Le,Ne;function Ue(e){if(!e)return;if(!Se(e))throw new Error("unable to parse JSON: lazyLoadingGoogle field is not valid");if(0===Object.keys(e).length||!e.googleFetchMarginPercent&&!e.googleRenderMarginPercent&&!e.googleMobileScaling)return{};const t={};return"number"==typeof e.googleFetchMarginPercent&&(t.googleFetchMarginPercent=e.googleFetchMarginPercent),"number"==typeof e.googleRenderMarginPercent&&(t.googleRenderMarginPercent=e.googleRenderMarginPercent),"number"==typeof e.googleMobileScaling&&(t.googleMobileScaling=e.googleMobileScaling),t}function xe(e){if(null==e)return;if(!Se(e))throw new Error("unable to parse JSON: lazyLoadingKleanads field is not valid");let t;return"number"!=typeof e.viewportPercent?e.numberOfViewports&&"number"==typeof e.numberOfViewports?t=e.numberOfViewports:($("unable to parse JSON: the lazyLoadingKleanads field is not valid, falling back to 0 viewport"),t=0):t=e.viewportPercent,{viewportPercent:t}}function De(e){if(null!=e){if(!Se(e))throw new Error("unable to parse JSON: lazyLoading field is not valid");if("string"!=typeof e.configName)throw new Error("unable to parse JSON: the lazyLoading's configName field is not valid");return{configName:e.configName,lazyLoadingGoogle:Ue(e.lazyLoadingGoogle),lazyLoadingKleanads:xe(e.lazyLoadingKleanads)}}}function je(e){if(!Array.isArray(e))throw new Error("unable to parse JSON: the adUnits field is not valid");const t=[];for(const i of e)try{t.push(Ce(i))}catch(e){P("Invalid ad unit configuration",e)}return t}function Me(e){if(!e)return;if(!Se(e))throw new Error("unable to parse JSON: the refreshConfig field is not valid");if(!Array.isArray(e.adUnitConfig))throw new Error("unable to parse JSON: the refreshConfig field is not valid");const t=[];for(const i of e.adUnitConfig)try{t.push(Be(i))}catch(e){P("Invalid refresh configuration",e)}return{adUnitConfig:t}}function Be(e){if(!Se(e))throw new Error("unable to parse JSON: the adUnitRefreshConfig field is not valid");if(!Array.isArray(e.specificRules))throw new Error("unable to parse JSON: the adUnitRefreshConfig specificRules field is not valid");if("number"!=typeof e.timer)throw new Error("unable to parse JSON: the adUnitRefreshConfig timer field is not valid");if(void 0===e.adUnitNames)throw new Error("unable to parse JSON: the adUnitRefreshConfig adUnitNames field is missing");if(!Array.isArray(e.adUnitNames))throw new Error("unable to parse JSON: the adUnitRefreshConfig adUnitNames field is not valid");if(void 0!==e.alwaysInView&&"boolean"!=typeof e.alwaysInView)throw new Error("unable to parse JSON: the adUnitRefreshConfig alwaysInView field is not valid");let t,i;if(void 0!==e.refreshBehaviorOnEmpty)switch(e.refreshBehaviorOnEmpty){case"continue":t=y.Continue;break;case"instantSecondChance":t=y.InstantSecondChance;break;case"stop":t=y.Stop;break;default:throw new Error("unable to parse JSON: the adUnitRefreshConfig refreshBehaviorOnEmpty field is not valid")}if(void 0!==e.refreshOutOfFocusConfig){if(!Se(e.refreshOutOfFocusConfig))throw new Error("unable to parse JSON: the adUnitRefreshConfig refreshOutOfFocusConfig field is not valid");if(void 0===e.refreshOutOfFocusConfig.timerInView||"number"!=typeof e.refreshOutOfFocusConfig.timerInView)throw new Error("unable to parse JSON: the adUnitRefreshConfig refreshOutOfFocusConfig timerInView field is not valid");if(void 0!==e.refreshOutOfFocusConfig.refreshOutOfView&&"boolean"!=typeof e.refreshOutOfFocusConfig.refreshOutOfView)throw new Error("unable to parse JSON: the adUnitRefreshConfig refreshOutOfFocusConfig refreshOutOfView field is not valid");i={timerInView:e.refreshOutOfFocusConfig.timerInView,refreshOutOfView:e.refreshOutOfFocusConfig.refreshOutOfView}}return{adUnitNames:e.adUnitNames,timer:e.timer,capping:Ae(e.capping),specificRules:e.specificRules,alwaysInView:e.alwaysInView,refreshBehaviorOnEmpty:t,refreshOutOfFocusConfig:i}}function Ve(e){if(!function(e){if(!e)throw new Error("unable to parse JSON: prebidConfig field is not valid");return Object.keys(e).includes("adCallTimeout")&&Object.keys(e).includes("pbjsConfig")}(e))throw new Error("unable to parse JSON: prebidConfig field is not valid");if("number"!=typeof e.adCallTimeout)throw new Error("unable to parse JSON: the prebidConfig's adCallTimeout field is not valid");return{adCallTimeout:e.adCallTimeout,pbjsConfig:Ke(e.pbjsConfig)}}function Fe(e){var t;if(!e)return;if(!Array.isArray(e))throw new Error("unable to parse JSON: the abTest field is not valid");const i=null===(t=e.find((e=>e.configToMerge)))||void 0===t?void 0:t.configToMerge;if(!i)throw new Error("unable to parse JSON: the abTest field is not valid");return i.adUnits?ze(e,Ge):i.lazyLoading?ze(e,Je):i.refreshConfig?ze(e,He):void 0}function ze(e,t){const i=[];for(const n of e){const e=We(n,t);i.push(e)}return i}function We(e,t){if(!Se(e))throw new Error("unable to parse JSON: the abTest field is not valid");return{name:Ie(e.name,"name"),ratio:function(e,t){if("number"!=typeof e)throw new Error(`Unable to parse JSON: the ${t} field ${e} is not a valid number`);return e}(e.ratio,"ratio"),configToMerge:t(e.configToMerge)}}function Ge(e){if(e){if(!Se(e))throw new Error("unable to parse JSON: the configToMerge field is not valid");if(!e.adUnits)throw new Error(`unable to parse JSON: the A/B test contains an invalid variant: ${JSON.stringify(e)}`);return{adUnits:je(e.adUnits)}}}function He(e){if(e){if(!Se(e))throw new Error("unable to parse JSON: the configToMerge field is not valid");if(!e.refreshConfig)throw new Error(`unable to parse JSON: the A/B test contains an invalid variant: ${JSON.stringify(e)}`);return{refreshConfig:Me(e.refreshConfig)}}}function Je(e){if(e){if(!Se(e))throw new Error("unable to parse JSON: the configToMerge field is not valid");if(!e.lazyLoading)throw new Error(`unable to parse JSON: the A/B test contains an invalid variant: ${JSON.stringify(e)}`);return{lazyLoading:De(e.lazyLoading)}}}function Ke(e){if(!Se(e))throw new Error("unable to parse JSON: pbjsConfig field is not valid");void 0===e.allowLocalStorage&&(e.allowLocalStorage=!0);const t=Ye(e,"userSync"),i=Ye(e,"outbrain"),n=Ye(e,"realTimeData"),s=Ye(e,"analytics"),o=Ye(e,"currency"),a=Ye(e,"bidderConfigs"),r=Ye(e,"priceGranularity"),d=Ye(e,"floors"),l=Ye(e,"schain"),c=function(e){if(e&&Array.isArray(e))return e}(e.bidderAliases);return{...e,...c&&{bidderAliases:c},...t&&{userSync:t},...i&&{outbrain:i},...n&&{realTimeData:n},...s&&{analytics:s},...a&&{bidderConfigs:a},...o&&{currency:o},...r&&{priceGranularity:r},...d&&{floors:d},...l&&{schain:l}}}!function(e){e.DISABLED="DISABLED",e.ENABLED_ALL_SLOTS="ENABLED_ALL_SLOTS"}(Pe||(Pe={})),function(e){e.firstId="firstId",e.utiqId="utiqId",e.sharedId="sharedId"}(Le||(Le={})),function(e){e.id5id="id5Id"}(Ne||(Ne={}));const Ye=(e,t)=>{if(!(t in e))return;const i=ye(e[t]);if(i)try{return JSON.parse(i)}catch(e){P(`unable to parse JSON in pbjsConfigFromPartial: ${t} `,e)}};async function qe(e,t,i,n){const s=function(e,t,i,n){const s=function(e,t,i,n,s){return`${e}/config/${t.scopeId.substring(0,8)}/${n.substring(0,8)}/${t.stackId}/${i}/${s}.json`}(e.configUrl,i,n,e.tagId,t);return s.replace(/([^:]\/)\/+/g,"$1")}(e,t,i,n);return new Promise((e=>{fetch(s).then((t=>{t.text().then((async t=>{const i=function(e){const t=JSON.parse(e);return{...t,lazyLoading:De(t.lazyLoading),adUnits:je(t.adUnits),prebidConfig:Ve(t.prebidConfig),refreshConfig:Me(t.refreshConfig),abTest:Fe(t.abTest)}}(t);e(i)}))})).catch((async t=>{P(`unable to load the configuration ${t}`),e(void 0)}))}))}var Xe,Qe,Ze;!function(e){e.BEGIN_INIT="begin_init",e.CMP_RESPONSE_AVAILABLE="cmp_response_available",e.MAIN_THREAD_END="main_thread_end",e.GOOGLETAG_READY="googletag_ready",e.APSTAG_READY="apstag_ready",e.PREBID_READY="prebid_ready"}(Xe||(Xe={})),function(e){e.BEGIN_CONFIGURE="begin_configure",e.BEGIN_START="begin_start",e.SPA_RELOAD="spa_reload"}(Qe||(Qe={})),function(e){e.START_AUCTION="start_auction",e.END_PBJS_AUCTION="end_pbjs_auction",e.END_APS_AUCTION="end_aps_auction",e.START_AD_SERVER_CALL="start_ad_server_call",e.SLOT_RENDER_ENDED_TIME="slot_render_ended_time",e.SLOT_RESPONSE_RECEIVED_TIME="slot_response_received_time"}(Ze||(Ze={}));const et=[],tt=[],it="getEntriesByName"in performance&&"measure"in performance&&"mark"in performance;function nt(e){et.includes(e)||(ft(e),et.push(e))}function st(e){ft(e)}function ot(e,t){const i=ut(e,t);tt.includes(i)||(ft(i),tt.push(i))}function at(e){return function(e){if(it)return performance.getEntriesByName(e).map((e=>e.startTime));return[]}(e)}function rt(e){if(et.includes(e))return function(e){if(it)return performance.getEntriesByName(e)[0].startTime;return}(e)}function dt(e,t){if(et.includes(e)&&et.includes(t))return ht(e,t)}function lt(e,t,i){const n=ut(e,i);if(et.includes(t)&&tt.includes(n))return ht(t,n)}function ct(e,t,i){const n=ut(e,t),s=ut(e,i);if(tt.includes(n)&&tt.includes(s))return ht(n,s)}function ut(e,t){return`${e}_${t}`}function ft(e){it&&(performance.mark(e.toString()),O(`[performance] [mark] ${e}: ${performance.getEntriesByName(e)[0].startTime.toFixed(2)}`))}function ht(e,t){if(it){const i=`measure_${e}_${t}`,n=performance.getEntriesByName(i);if(0!==n.length&&"measure"===n[0].entryType)return n[0].duration;try{return performance.measure(i,e,t).duration}catch{return}}}var gt;!function(e){e.UNKNOWN="unknown",e.WAIT_USER_CONSENT="wait_user_consent",e.WAIT_USER_REFUSED="wait_user_refused"}(gt||(gt={}));let pt=gt.UNKNOWN;function vt(e){pt=e}const mt=[];function bt(e,t){mt.includes(e)||(L("[metric] adunit",{...St(e,t)}),mt.push(e))}const yt=new Map;function At(e){const t=function(e){const t=performance.getEntriesByName(e);return t.length>0&&"mark"===t[0].entryType}(Xe.GOOGLETAG_READY);yt.set(e,t)}function St(e,t){return{adUnit:e,consentType:pt,eventOrigin:t,startAuctionFromConsent:lt(e,Xe.CMP_RESPONSE_AVAILABLE,Ze.START_AUCTION),pbjsAuctionDuration:ct(e,Ze.START_AUCTION,Ze.END_PBJS_AUCTION),apsAuctionDuration:ct(e,Ze.START_AUCTION,Ze.END_APS_AUCTION),startAdServerCallFromConsent:lt(e,Xe.CMP_RESPONSE_AVAILABLE,Ze.START_AD_SERVER_CALL),slotRenderEndedFromConsent:lt(e,Xe.CMP_RESPONSE_AVAILABLE,Ze.SLOT_RENDER_ENDED_TIME),adServerResponseDuration:ct(e,Ze.START_AD_SERVER_CALL,Ze.SLOT_RESPONSE_RECEIVED_TIME),totalAdCallDuration:ct(e,Ze.START_AUCTION,Ze.SLOT_RENDER_ENDED_TIME),isGoogletagReadyAtPbjsAuctionEnd:yt.get(e)}}function It(){const e=rt(Xe.BEGIN_INIT),t=at(Qe.BEGIN_CONFIGURE),i=at(Qe.BEGIN_START),n=at(Qe.SPA_RELOAD),s=function(e){if(e.length>=2)return e[e.length-1]-e[e.length-2];return}(n),o={countSpaReloads:n.length,countConfigures:t.length,countStarts:i.length};e&&t.length>0&&(o.initToConfigure=t[t.length-1]-e),t.length>0&&i.length>0&&(o.configureToStart=i[i.length-1]-t[t.length-1]),s?o.diffSpaReload=s:t[0]&&n[0]&&(o.diffSpaReload=n[0]-t[0]),L("[metric] start",o)}function Ct(e){return new Promise(((t,i)=>{!function(e,t,i){(n=e,new Promise(((e,t)=>wt(n,e)))).then((()=>{try{!function(e,t){const i=function(e){return e.__tcfapi}(e);i("addEventListener",2,(e=>{if(e&&("useractioncomplete"===e.eventStatus||"tcloaded"===e.eventStatus)){O("[consent] Consent status ",e.eventStatus),nt(Xe.CMP_RESPONSE_AVAILABLE);const i=function(e){if(!e.purpose.consents||0===Object.keys(e.purpose.consents).length)return!1;for(const t in e.purpose.consents)if(!e.purpose.consents[t])return!1;return!0}(e);vt(i?gt.WAIT_USER_CONSENT:gt.WAIT_USER_REFUSED),t(i)}}))}(e,t)}catch(e){O("[consent] Error while loading tcf api"),i(e)}})).catch((e=>{O("[consent] Error while loading tcf api",e),i(e)}));var n}(e,t,i)}))}function wt(e,t,i){const n=e.__tcfapi;n&&function(e){if("function"!=typeof e)throw new Error("__tcfapi is not a function");return!0}(n)?t():setTimeout((()=>wt(e,t)),100)}function Et(e){return e.map((e=>({key:e.key.toLowerCase(),defaultValue:e.defaultValue?e.defaultValue.toLowerCase():void 0,otherValues:e.otherValues?e.otherValues.map((e=>e.toLowerCase())):[]})))}function _t(e,t,i){(function(e,t,i){const n=[],s=Et(t).filter((e=>void 0!==e.defaultValue)).map((e=>e.key.toLowerCase())),o=[];e.document.querySelectorAll('meta[name^="pbstck_context:"]').forEach((e=>{var t;const i=null===(t=e.attributes.getNamedItem("name"))||void 0===t?void 0:t.value.substring(15).toLowerCase();i&&o.push(i)}));for(const e of i)s.includes(e)&&!o.includes(e)&&n.push(e);return n})(e,t,i).forEach((e=>{$(`[context] Missing ${e} context key used in adunit path`)}))}const kt={pbjsFinished:!1,apsFinished:!1},Tt="[executor] [instream]";class Ot{constructor(e,t,i,n){this.rank=1,this.adServer=e,this.pbjs=t,this.aps=i,this.kleanadsRunCount=n}executeAdCall(e){setTimeout((()=>{bt(e.divId,"executorTimeout")}),2e4),this.adServer.declareAdUnit(e),this.adUnitAuctionStatus?$(`${Tt} cannot make a new ad call, existing one on ${e.divId}.`):(O(`${Tt} executeAdCall for adunit`,e),this.startAuction(e))}executeRefresh(e){this.adServer.cleanTargetings();const t={labels:["pubstackRefresh",`pubstackRefreshRank:${e.rank}`]};this.startAuction(e.adUnit,t)}startAuction(e,t){this.adUnitAuctionStatus=kt,ot(e.divId,Ze.START_AUCTION),O(`${Tt} starting auctions for ${e.divId}`);const i=ae.getInstance().kleanadsRunCount;if(this.pbjs){const n=this.pbjs.getPbjs();this.pbjs.startPbjsAuction([e],(()=>{this.kleanadsRunCount===i?this.pbjsFinished(n,e):O(`${Tt} kleanads run count has changed (from ${this.kleanadsRunCount} to ${i}), avoid calling pbjsFinished`)}),t)}this.aps&&this.aps.startApsAuction([e],(t=>{this.kleanadsRunCount===i?this.apsFinished(e,t):O(`${Tt} kleanads run count has changed (from ${this.kleanadsRunCount} to ${i}), avoid calling apsFinished`)})),this.pbjs||this.aps||this.adServer.executeWhenAdServerReady((()=>{this.kleanadsRunCount===i?this.callAdServer(e):O(`${Tt} kleanads run count has changed (from ${this.kleanadsRunCount} to ${i}), avoid calling AdServer`)}))}isAlreadyMonetized(){return!!this.adUnitAuctionStatus}pbjsFinished(e,t){O(`${Tt} pbjs end callback for ${t.divId}`,e.getAllPrebidWinningBids()),ot(t.divId,Ze.END_PBJS_AUCTION),At(t.divId),this.adServer.executeWhenAdServerReady((()=>{O(`${Tt} pbjs end callback ad server ready ${t.divId}`),this.adServer.setPbjsTargetings(e,t),this.adUnitAuctionStatus&&(this.adUnitAuctionStatus.pbjsFinished=!0),this.canCallAdServer()&&this.callAdServer(t)}))}apsFinished(e,t){O(`${Tt} aps end callback ${e.divId}`,t),ot(e.divId,Ze.END_APS_AUCTION),this.adServer.executeWhenAdServerReady((()=>{O(`${Tt} aps end callback ad server ready ${e.divId}`),this.adServer.setApsTargetings(t),this.adUnitAuctionStatus&&(this.adUnitAuctionStatus.apsFinished=!0),this.canCallAdServer()&&this.callAdServer(e)}))}canCallAdServer(){const e=this.adUnitAuctionStatus;return this.aps&&!this.pbjs?e&&e.apsFinished:this.pbjs&&!this.aps?e&&e.pbjsFinished:this.pbjs&&this.aps?e&&e.apsFinished&&e.pbjsFinished:void 0}callAdServer(e){ot(e.divId,Ze.START_AD_SERVER_CALL),this.adServer.callAdServer(e,(()=>{O(`${Tt} onCallFinished called, adding setTimeout to a new auction`),setTimeout((()=>{this.executeRefresh({adUnit:e,rank:this.rank}),this.rank++}),5e3)})),O(`${Tt} ad server called ${e.divId}`)}}for(var Rt,$t=[],Pt=0;Pt<256;++Pt)$t.push((Pt+256).toString(16).slice(1));var Lt=new Uint8Array(16);function Nt(){if(!Rt&&!(Rt="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Rt(Lt)}var Ut={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function xt(e,t,i){if(Ut.randomUUID&&!t&&!e)return Ut.randomUUID();var n=(e=e||{}).random||(e.rng||Nt)();return n[6]=15&n[6]|64,n[8]=63&n[8]|128,function(e,t=0){return($t[e[t+0]]+$t[e[t+1]]+$t[e[t+2]]+$t[e[t+3]]+"-"+$t[e[t+4]]+$t[e[t+5]]+"-"+$t[e[t+6]]+$t[e[t+7]]+"-"+$t[e[t+8]]+$t[e[t+9]]+"-"+$t[e[t+10]]+$t[e[t+11]]+$t[e[t+12]]+$t[e[t+13]]+$t[e[t+14]]+$t[e[t+15]]).toLowerCase()}(n)}const Dt="[pbjs] [sublime]";function jt(e,t){const i=function(e,t){var i,n;const s=null===(i=null==t?void 0:t.find((e=>"sublime"===e.bidderSource)))||void 0===i?void 0:i.bidderLabel,o=e.filter((e=>e.bidders.find((e=>"sublime"===e.bidder||e.bidder===s))));if(0===o.length)return;if(o.length>1)return void $(`${Dt} Sublime bidder has multiple adUnits ${o.map((e=>e.divId)).join("")}`,o);const a=null===(n=o[0].bidders.find((e=>"sublime"===e.bidder||e.bidder===s)))||void 0===n?void 0:n.params;if(a){const e=a.zoneId;if(e&&("string"==typeof e||"number"==typeof e))return`${e}`}else $(`${Dt} unable to extract Sublime zoneId from ${o[0].divId}`,o[0])}(e,t);if(i){const e=`https://sac.ayads.co/sublime/${i}/prebid`;O(`${Dt}[initPbjs] loading sublime script ${e}`),j(e)}}function Mt(e,t){const i=function(){window.sublime=window.sublime||{};const e=window.sublime.notifyId||xt();return window.sublime.notifyId=e,e}();return"sublime"===e.bidder||(null==t?void 0:t.some((t=>"sublime"===t.bidderSource&&t.bidderLabel===e.bidder)))?(O(`${Dt} generate notify id`),{...e,params:{...e.params,notifyId:i}}):e}const Bt=(e,t)=>e.delimiter===t.delimiter&&"|"===e.delimiter&&e.fields.length+1===t.fields.length&&e.fields.every(((e,i)=>e===t.fields[i])),Vt=1900,Ft="[pbjs]";function zt(e,t=[]){const i=null==t?void 0:t.map((e=>e.bidderSource));return Array.from(new Set(e.flatMap((e=>e.bidders)).map((e=>e.bidder)).concat(i)))}function Wt(e,t,i,n,s){var o,a,r,d,l,c,u,f,h,g,p;O(`${Ft}[initPbjs] Start prebid initialization`);const{currency:v,userSync:m,priceGranularity:b,bidderAdjustments:y,bidderAliases:A,bidderConfigs:S,floors:I,analytics:C,schain:w,outbrain:E,realTimeData:_,allowLocalStorage:k,fledgeForGpt:T,paapi:R,dsaConfig:P,s2sConfig:N,enableTIDs:U}=i,x=zt(t,A);if(e.setConfig(n),v&&(O(`${Ft}[initPbjs] set currency config`,v),e.setConfig({currency:v,priceGranularity:"dense"}),b&&(O(`${Ft}[initPbjs] set priceGranularity config`,b),e.setConfig({priceGranularity:b}))),N&&(O(`${Ft}[initPbjs] set prebid server config`,N),e.setConfig({s2sConfig:N})),m){const t=Object.keys(null!==(a=null===(o=null==N?void 0:N.extPrebid)||void 0===o?void 0:o.aliases)&&void 0!==a?a:{}),i={filterSettings:{iframe:{bidders:Object.values(null!==(d=null===(r=null==N?void 0:N.extPrebid)||void 0===r?void 0:r.aliases)&&void 0!==d?d:{}).concat(null!==(c=null===(l=null==N?void 0:N.bidders)||void 0===l?void 0:l.filter((e=>!t.includes(e))))&&void 0!==c?c:[]).concat(["optidigital","richaudience","justpremium","impactify","smilewanted","onetag","connectad","adagio"]),filter:"include"},image:{bidders:"*",filter:"include"}},...m};O(`${Ft}[initPbjs] set userSync config`,i),e.setConfig({userSync:i})}E&&(O(`${Ft}[initPbjs] set Outbrain config:`,E),e.setConfig({outbrain:E})),_&&(O(`${Ft}[initPbjs] set realTimeData config`,_),e.setConfig({realTimeData:_})),I&&(O(`${Ft}[initPbjs] set floors config`,I),e.setConfig({floors:I}));const D=null==_?void 0:_.dataProviders.find((e=>"greenbidsRtdProvider"===e.name));if(C||D){const t=C||[];if(D){const e=null===(u=D.params)||void 0===u?void 0:u.pbuid;if(e&&!t.find((e=>"greenbids"===e.provider))){const i=function(e,t){return{provider:"greenbids",options:{pbuid:e,sampling:t}}}(e,null===(f=D.params)||void 0===f?void 0:f.sampling);t.push(i)}}O(`${Ft}[initPbjs] enable analytics`,t),e.enableAnalytics(t)}if(w&&(O(`${Ft}[initPbjs] set schain config`,w),e.setConfig({schain:w})),T&&e.setConfig({fledgeForGpt:{enabled:!0}}),R&&e.setConfig({paapi:R}),S){O(`${Ft}[initPbjs] set bidder config`,S);for(const t of S)e.setBidderConfig(t)}const j={};if(y){O(`${Ft}[initPbjs] set bidder adjustments config`,y);for(const e of y)j[e.bidder]={bidCpmAdjustment:function(t){return t*e.adjustment}}}if(k)for(const e of x)j[e]={...j[e],storageAllowed:!0};if(j.standard={adserverTargeting:[{key:le,val:function(e){return e.bidderCode}},{key:"bid_id",val:function(e){return e.adId}},{key:"bid_cpm",val:function(e){return e.pbCg}},{key:ce,val:function(e){return e.size}},{key:ue,val:function(e){return e.mediaType}},{key:"bid_videoId",val:function(e){return e.videoCacheKey}}]},s&&ae.getInstance().uprEnabled&&(j.standard={adserverTargeting:[...j.standard.adserverTargeting,{key:"prkv",val:e=>Gt(e,s)},{key:"ad_floor-rule",val:e=>Gt(e,s)}]}),Object.keys(j).length>0&&(e.bidderSettings=j),A){O(`${Ft}[initPbjs] set alias bidder`,A);for(const t of A)e.aliasBidder(t.bidderSource,t.bidderLabel)}if(Jt(t,"sublime",A)&&jt(t,A),null===(h=e.installedModules)||void 0===h?void 0:h.includes("utiqSystem")){const t=localStorage.getItem("utiqPass");if(t)try{const i=JSON.parse(t),n=null!==(null===(p=null===(g=null==i?void 0:i.connectId)||void 0===g?void 0:g.idGraph)||void 0===p?void 0:p[0].atid);O(`${Ft}[initPbjs] set Utiq key values isUtiqPresent=`,n),e.mergeConfig({ortb2:{site:{keywords:"isUtiqPresent="+n}}})}catch(e){$(`${Ft}[initPbjs] Utiq config is not valid JSON, ${e}`,t)}}P&&(O(`${Ft}[initPbjs] set DSA config`,P),e.mergeConfig({ortb2:{regs:{ext:{dsa:P}}}})),Jt(t,"criteo",A)&&e.setConfig({criteo:{fastBidVersion:"latest"}}),void 0!==U&&(O(`${Ft}[initPbjs] setting enableTIDs to`,U),e.setConfig({enableTIDs:U})),ae.getInstance().disableGptPreAuction&&e.setConfig({gptPreAuction:{enabled:!1}}),nt(Xe.PREBID_READY),L("[metric] pbjs",{consentType:pt,pbjsReady:dt(Xe.CMP_RESPONSE_AVAILABLE,Xe.PREBID_READY)}),O(`${Ft}[initPbjs] Prebid is initialized`)}function Gt(e,t){const i=e.cpm,n=i>0?function(e,t){let i;if(t.forEach((t=>{const n=parseFloat(t.max);n>e&&(i=!i||n<parseFloat(i.max)?t:i)})),!i)return Math.max(...t.map((e=>parseFloat(e.max))));const n=parseFloat(i.increment);return parseFloat((Math.floor(e/n)*n).toFixed(2))}(i,t):0,s=Math.max(...t.map((e=>parseFloat(e.max))));return Math.min(n,s).toFixed(2)}function Ht(e,t,i,n){const[s,o,a]=function(e){const t=[],i=[],n=[];return e.forEach((e=>{e.headerBiddingEnabled&&e.bidders.length>0?(t.push(e),i.push(e.divId)):n.push(e.divId)})),[t,i.join(","),n.join(",")]}(t),r=s.flatMap((t=>{if(t.dynamicPrebidFloor){const i=e.getHighestCpmBids(t.divId);if(i.length>0){const e=i[0].cpm;return se(t,Math.floor(100*e)/100)}}return se(t)}));if(r.length>0){const t=null==n?void 0:n.timeout,d=null==n?void 0:n.labels,l=function(e){const t=e.getConfig("bidderTimeout");if(t){if("number"==typeof t)return t+Vt;if(parseInt(t))return parseInt(t)+Vt}return 3e3+Vt}(e);let c=!1;setTimeout((()=>{c||($(`${Ft}prebid requestBids did not response before ${l}ms, calling callback`),c=!0,i())}),l);const u=()=>{c||(c=!0,i())};if(!(e=>1===new Set(e.map((e=>e.floors)).filter((e=>void 0!==e)).map((e=>[...e.schema.fields,e.schema.delimiter].join("")))).size)(s)){const e=(e=>e.map((e=>e.floors)).filter((e=>void 0!==e)).map((e=>e.schema)).reduce(((e,t)=>(e?t.fields.length>e.fields.length&&(e=t):e=t,e)),void 0))(s);e&&(O(`${Ft}floors schema are not the same, unifying schema`),((e,t)=>{e.forEach((i=>{var n;if(i.floors&&(null===(n=i.floors)||void 0===n?void 0:n.schema)!==t){const n=i.floors.schema;if(Bt(n,t)){i.floors.schema=t;const e=i.floors.values;i.floors.values={};for(const t of Object.keys(e))i.floors.values[`${t}|*`]=e[t]}else P(`Unable to unify schema for adUnits ${e.map((e=>e.divId)).join(", ")}.`,t)}}))})(s,e))}O(`${Ft}[executor] [pbjs] calling requestBids for ${r.map((e=>e.code)).join(",")}`),e.requestBids({timeout:t,adUnits:r,bidsBackHandler:u,labels:d}),O(`${Ft}[executor] [pbjs] prebid auction started for [${o}] | prebid auction skipped for [${a}]`,s)}else O(`${Ft}[executor] [pbjs] no prebid auction to start for [${t.map((e=>e.divId)).join(",")}]`),i()}function Jt(e,t,i){const n=e.flatMap((e=>e.bidders)).map((e=>e.bidder)),s=[...new Set(n)],o=[t,...(null==i?void 0:i.filter((e=>e.bidderSource===t)).map((e=>e.bidderLabel)))||[]];return s.some((e=>null==o?void 0:o.includes(e)))}class Kt{constructor(e){this.pbjs=e.getPbjs()}initPbjs(e,t,i,n){Wt(this.pbjs,e,t,i,n)}extractUniqAdaptersName(e,t=[]){return zt(e,t)}roundUpToNearestIncrement(e,t){return function(e,t){const i=e.sort(((e,t)=>e.max<t.max?-1:1)),n=i.filter((e=>t<=e.max));if(0===n.length)return O(`${Ft}[Price granularity] round up - initial CpmValue : ${t} // rounded value : ${i[i.length-1].max} `),i[i.length-1].max.toFixed(2);const s=n[0].increment;let o=t%s==0?t:t+(s-t%s);const a=t.toString().split("."),r=a.length>1?a[1].split("").length:0;(o-s).toFixed(r)===t.toFixed(r)&&(o=t);const d=o.toFixed(2);return O(`${Ft}[Price granularity] round up - initial CpmValue : ${t} // rounded value : ${d} `),d}(e,t)}startPbjsAuction(e,t,i){Ht(this.pbjs,e,t,i)}getPbjs(){return this.pbjs}setContextValuesAsTargeting(e,t,i){const n={};for(const[t,i]of e)n[t]=i;for(const e in t)1===t[e].length?n[e]=t[e][0]:n[e]=t[e];this.pbjs.setBidderConfig({bidders:i,config:{ortb2:{site:{ext:{data:n}}},appnexusAuctionKeywords:n}})}}let Yt=4400;const qt="[executor] [APS]";let Xt=!1,Qt=!1;function Zt(e){const t=e.apstag;if(t.kleanadsBlocker){O(`${qt} getting apstag from blocker's methods`);const e=t;return{...t,fetchBids:e.fetchBidsKleanads,setDisplayBids:e.setDisplayBidsKleanads}}return t}class ei{constructor(e,t){this.pubstackWindow=e,this.apsPubId=t}setEnableApsForTests(e){!function(e){P(`${qt} this function should be used only for testing purpose`),Xt=e}(e)}load(){!function(e){function t(t,i){var n,s;null===(s=null===(n=Zt(e))||void 0===n?void 0:n._Q)||void 0===s||s.push([t,i])}Xt=!0,e.apstag||(O(`${qt} overriding apstag`),e.apstag={_Q:[]}),O(`${qt} overriding apstag functions`),e.apstag.init=(...e)=>t("i",e),O(`${qt} init set!`,e.apstag.init),e.apstag.fetchBids=(...e)=>t("f",e),e.apstag.setDisplayBids=()=>{},e.apstag.targetingKeys=()=>[],j("//c.amazon-adsystem.com/aax2/apstag.js")}(this.pubstackWindow)}startApsAuction(e,t){if(!Xt)return O(`${qt} skipping auction for adunits [${e.map((e=>e.divId)).join(",")}]`),void t([]);if(!Qt)return $(`${qt} cannot start auction: apstag is not initialized`),void t([]);const i=Zt(this.pubstackWindow);if(!i)return $(`${qt} cannot find apstag on the page`),void t([]);const n=function(e){return e.filter((e=>e.headerBiddingEnabled)).reduce(((e,t)=>{const i=t.mediaTypes;if(i.includes("Instream")){const t={slotID:"videoSlot",mediaType:"video",sizes:[[640,480]]};return[...e,t]}if(i.includes("Banner")){const i={slotID:t.divId,slotName:t.slotName,sizes:V(t.sizes)};return i.sizes.length?[...e,i]:e}if(i.includes("Outstream")){const i={slotID:t.divId,mediaType:"video",sizes:[[640,480]]};return[...e,i]}return[]}),[])}(e);if(O(`${qt} apsSlots created`,n),0===n.length)return void t([]);O(`${qt} calling fetchBids`);let s=!1;setTimeout((()=>{s||($(`${qt} fetchbids did not response before ${Yt}ms, calling callback`),s=!0,t([]))}),Yt),i.fetchBids({slots:n},(e=>{s||(s=!0,t(e))})),O(`${qt} auction started`,n)}initAps(e,t){if(Xt){Yt=e+1400,O(`${qt} updating failsafe timeout to ${Yt}`);const i=Zt(this.pubstackWindow);if(!i)return void $(`${qt} cannot find apstag on the page`);const n=null==t?void 0:t.config;i.init({pubID:this.apsPubId,adServer:"googletag",bidTimeout:e,deals:!0,videoAdServer:"DFP",schain:n},(()=>{O(`${qt} apstag init done`),nt(Xe.APSTAG_READY),L("[metric] apstag",{consentType:pt,apstagReady:dt(Xe.CMP_RESPONSE_AVAILABLE,Xe.APSTAG_READY)})})),Qt=!0}else O(`${qt} apstag init skipped`)}}const ti="[GAM]",ii="pbstck_ab_test",ni="xp_variant",si={},oi=[3,1];let ai=!1;const ri=[];function di(e){return new Promise(((t,i)=>ci(e,t,i)))}const li=50;function ci(e,t,i){if(e.googletag)try{e.googletag.apiReady?t():setTimeout((()=>ci(e,t,i)),li)}catch(e){i(e)}else setTimeout((()=>ci(e,t,i)),li)}function ui(e,t,i,n,s){di(e).then((()=>{var o,a;O(`${ti} googletag ready, starting initialization`),e.googletag.pubads().disableInitialLoad(),(null==n?void 0:n.disableSingleRequest)?O(`${ti} single request disabled`):e.googletag.pubads().enableSingleRequest()||P("unable to enable single request"),function(e,t,i){const n=e.googletag.pubads();t.forEach(((e,t)=>{e&&n.setTargeting(t,e)}));const s=m(e);O("[targetings] here are the targetings",s),Object.keys(s).forEach((e=>{n.setTargeting(e,s[e])})),n.setTargeting(S,"1");const o=ae.getInstance().grapeshotValues;(null==o?void 0:o.length)&&n.setTargeting("gs_cat",o);if(null==i||i.filter((e=>e.gamTargeting)).forEach((e=>n.setTargeting(e.name,e.value))),ae.getInstance().uprTested){O(`${ti} setting xp_variant/pbstck_ab_test gam targeting value any previous value will be ignored`);const e=`floor_optimization:${ae.getInstance().uprEnabled}`;n.setTargeting(ni,e),n.setTargeting(ii,e)}}(e,t,s),n&&n.ppidValue&&e.googletag.pubads().setPublisherProvidedId(n.ppidValue),n&&(null==n?void 0:n.threadYieldConfig)&&e.googletag.setConfig({threadYield:n.threadYieldConfig}),e.googletag.enableServices(),(null===(o=null==i?void 0:i.lazyLoadingGoogle)||void 0===o?void 0:o.googleFetchMarginPercent)&&(null===(a=null==i?void 0:i.lazyLoadingGoogle)||void 0===a?void 0:a.googleRenderMarginPercent)&&e.googletag.pubads().enableLazyLoad({fetchMarginPercent:i.lazyLoadingGoogle.googleFetchMarginPercent,renderMarginPercent:i.lazyLoadingGoogle.googleRenderMarginPercent,mobileScaling:i.lazyLoadingGoogle.googleMobileScaling}),e.googletag.pubads().setCentering(!0),O("googletag initialized"),ai=!0,ri.forEach((e=>e())),nt(Xe.GOOGLETAG_READY),L("[metric] googletag",{consentType:pt,googletagReady:dt(Xe.CMP_RESPONSE_AVAILABLE,Xe.GOOGLETAG_READY),adUnitWithAuctionEnded:Array.from(yt.keys())}),R("GAM","googletag slotRenderEnded listener added"),e.googletag.pubads().addEventListener("slotRenderEnded",fi),e.googletag.pubads().addEventListener("slotResponseReceived",gi),e.googletag.pubads().addEventListener("slotOnload",hi)}))}const fi=e=>{const t=e.slot,i=t.getSlotElementId();ot(i,Ze.SLOT_RENDER_ENDED_TIME),bt(i,"slotRenderEnded"),function(e,t){de(e,t,"ad_floor-rule"),de(e,t,"prkv")}(i,t),O(`slot render ended for ${i}`)},hi=e=>{const t=e.slot.getSlotElementId();O(`slot onload received for ${t}`),setTimeout((()=>{const e=document.getElementById(t);if(e){const s=function(e){if(e.scrollHeight>e.clientHeight)return{overflow:"height",scroll:e.scrollHeight,client:e.clientHeight};if(e.scrollWidth>e.clientWidth)return{overflow:"width",scroll:e.scrollWidth,client:e.clientWidth};return}(e);if(s){const e=si[t];i=`${ti} Overflow problem while rendering '${JSON.stringify(e)}' | ${JSON.stringify(s)}`,n={...e,size:`${e.size}`},h(C,i,n),null==w||w.errorWithPayload(i,n),navigator.sendBeacon(`https://intake.pbstck.com/v1/intake/error?tId=${E}&v=${_}&s=${k}&c=1`,JSON.stringify([{message:i}]))}}var i,n}),100)},gi=e=>{const t=e.slot.getSlotElementId();O(`slot response received for ${t}`),ot(t,Ze.SLOT_RESPONSE_RECEIVED_TIME)};function pi(e,t){for(const i of e.getTargetings()){const n=X(i),s=i.key;t.setTargeting(s,n),O(`${ti} adding targeting (${s}, ${n}) to adunit ${e.divId}`)}t.setTargeting("ad_adunitname",[e.adServerAdUnitName])}function vi(e){ai?e():ri.push(e)}class mi{constructor(e,t){this.externalTargetingDeclarations=[],this.googletagSlotsInitialized={},this.pubstackWindow=e,this.prebidOrderIds=t}prebidReady(e){O(`${ti} prebidReady`,e)}init(e,t,i,n){ui(this.pubstackWindow,e,t,i,n)}declareAdUnits(e){return this.declareGoogleSlots(e)}registerExternalTargetingDeclaration(e){this.externalTargetingDeclarations.push(e)}clean(){this.externalTargetingDeclarations=[],this.executeWhenAdServerReady((()=>{O(`${ti} cleaning slots`,this.pubstackWindow.googletag.pubads().getSlots().map((e=>e.getSlotElementId())),this.pubstackWindow.googletag.pubads().getSlots());const e=[];this.pubstackWindow.googletag.pubads().getSlots().forEach((t=>{const i=this.pubstackWindow.googletag.destroySlots([t]);R(`${ti} slot ${t.getSlotElementId()} destroyed ? ${i}`),i||(e.push(t),O(`${ti} slot ${t.getSlotElementId()} not destroyed, retrying later`))})),e.length?P(`${ti} unable to destroy slot ${bi(e)}`):R(`${ti} all slots destroyed`),this.pubstackWindow.googletag.pubads().removeEventListener("slotRenderEnded",fi),this.pubstackWindow.googletag.pubads().removeEventListener("slotResponseReceived",gi),this.pubstackWindow.googletag.pubads().removeEventListener("slotOnload",hi),ri.splice(0)}))}setPbjsTargetings(e,t){e?(O(`${ti} try to put pbjs targeting keys for ${t.map((e=>e.divId)).join(",")}`),t.forEach((t=>{const i=this.getSlot(t,"setPbjsTargetings");i&&function(e,t,i){i.getTargetingKeys().forEach((e=>{"bid_"!==e.substring(0,4)&&"hb_"!==e.substring(0,3)||i.clearTargeting(e)}));const n=t.getAdserverTargetingForAdUnitCode(e.divId);for(const t of Object.keys(n)){const s=n[t];re(s)?i.setTargeting(t,s):$(`[targeting] unable to set targeting ${t}=${s} on adUnit ${e.divId}`)}i.setTargeting("kuc_version","2408211643")}(t,e,i)}))):P(`${ti} no pbjs given: unable to put header bidding targetings`)}setApsTargetings(e,t){O(`${ti} putting targeting keys for aps auction`,t),function(e){var t;null===(t=Zt(e))||void 0===t||t.setDisplayBids()}(this.pubstackWindow)}setRefreshTargeting(e){const t=this.getSlot(e.adUnit,"setPbjsTargetings");var i,n;t&&(i=t,n=e.rank,i.setTargeting("ad_refresh","1"),i.setTargeting("pbstck_refresh","1"),i.setTargeting("ad_refresh-rank",function(e){return e<10?`${e}`:"10-more"}(n)))}callAdServer(e){O(`${ti} preparing call to GAM for ${e.map((e=>e.divId)).join(",")}`,e);const t=this.pubstackWindow.googletag.pubads().getSlots(),i=e.map((e=>({adUnit:e,slot:t.find((t=>t.getSlotElementId()===e.divId))}))).filter((e=>!!e.slot));i.forEach((({adUnit:e,slot:t})=>pi(e,t)));const n=i.map((({slot:e})=>e));O(`${ti} calling GAM with ${n.length} slots`,bi(n),bi(t)),g("googletag:refresh",{slotIds:n.map((e=>e.getSlotElementId()))}),this.refresh(n)}refresh(e){e.every((e=>this.googletagSlotsInitialized[e.getSlotElementId()]))?this.pubstackWindow.googletag.pubads().refresh(e):setTimeout((()=>this.refresh(e)),50)}executeWhenAdServerReady(e){ai?e():ri.push(e)}renderListener(e){vi((()=>{this.renderListenerCallback=t=>{const i=t.slot,n=t.campaignId,s={divId:i.getSlotElementId(),creativeId:t.creativeId,lineItemId:t.lineItemId,orderId:n,size:yi(t),isEmpty:t.isEmpty,advertiserId:t.advertiserId};if(n&&this.prebidOrderIds.includes(n)){const e=i.getTargeting(le);e&&(s.hb_bidder=Array.isArray(e)?e[0]:e);const t=i.getTargeting(ce);t&&t[0]&&(s.size=F(t[0]));const n=i.getTargeting(ue);n&&(s.hb_mediaType=Array.isArray(n)?n[0]:n)}si[s.divId]=s,e(s)},this.pubstackWindow.googletag.pubads().addEventListener("slotRenderEnded",this.renderListenerCallback)}))}removeRenderListener(){this.renderListenerCallback&&(R("GAM","removing render listener"),this.pubstackWindow.googletag.pubads().removeEventListener("slotRenderEnded",this.renderListenerCallback))}getSlot(e,t){const i=this.pubstackWindow.googletag.pubads().getSlots().filter((t=>t.getSlotElementId()===e.divId));if(0!==i.length)return i.length>1&&P(`${ti} multiple slot found for adunit ${e.divId} on operation ${t}`),i[0];P(`${ti} slot not found for adunit ${e.divId} on operation ${t}`)}declareGoogleSlots(e){return new Promise((t=>{vi((()=>{const i=e.sort(J),n=[],s=[];if(i.forEach((e=>{var t,i,o;if("interstitial"===e.outOfPageType){O(`${ti} define slot interstitial for ${e.divId} (${e.adUnitPath})`);const t=window.googletag.defineOutOfPageSlot(e.adUnitPath,googletag.enums.OutOfPageFormat.INTERSTITIAL);t&&(O("slot interstitial created"),t.addService(googletag.pubads()),n.push(t),s.push(t),pi(e,t))}else if(document.getElementById(e.divId)){let n;if("default"===e.outOfPageType)O(`${ti} define slot out of page for ${e.divId} (${e.adUnitPath})`),n=null===(t=window.googletag.defineOutOfPageSlot(e.adUnitPath,e.divId))||void 0===t?void 0:t.addService(googletag.pubads());else{const t=[oi,...e.sizes,...null!==(i=e.extraAdServerSizes)&&void 0!==i?i:[]];O(`${ti} define slot for ${e.divId} (${e.adUnitPath})`),n=null===(o=window.googletag.defineSlot(e.adUnitPath,t,e.divId))||void 0===o?void 0:o.addService(googletag.pubads())}n?(O(`${ti} slot created, displaying ${e.divId}`),googletag.display(e.divId),s.push(n)):P(`${ti} unable to create slot for ${e.divId}`)}else O(`${ti} unable to display ${e.divId}, the div does not exist`)})),n.forEach((e=>{O(`${ti} calling googletag.display for interstitial slot`,e),googletag.display(e)})),n.length>0&&googletag.pubads().refresh(n),this.externalTargetingDeclarations.length>0){const e=performance.now();let i;const n=new Promise((e=>{i=setTimeout((()=>{$(`${ti} failsafe promise for external targeting declarations, some targetings may be missing`),e()}),3e3)}));Promise.race([Promise.all(this.externalTargetingDeclarations.map((e=>e(s)))).then((()=>{i&&clearTimeout(i)})),n]).then((()=>{const i=performance.now();O(`${ti} external targetings declarations took ${i-e}ms`),s.forEach((e=>{this.googletagSlotsInitialized[e.getSlotElementId()]=!0})),t()}))}else s.forEach((e=>{this.googletagSlotsInitialized[e.getSlotElementId()]=!0})),t()}))}))}}function bi(e){return e.map((e=>({id:e.getSlotElementId(),path:e.getAdUnitPath()})))}function yi(e){return e.size}const Ai="[Local-AdServer]";class Si{constructor(){this.managedDivs=[],this.callbacks=[]}prebidReady(e){this.pbjs=e}callAdServer(e){this.pbjs?(O(`${Ai} callAdServer`,e),e.forEach((e=>{if(this.managedDivs.includes(e.divId)){const t=this.pbjs.getHighestCpmBids(e.divId);if(t.length>0){const e=t[0];try{!function(e,t){var i,n;if(O(`${Ai} renderOne`,t),!t||!t.adId)throw new Error(`${Ai} no winning bid or adId provided ${t}`);{const s=document.getElementById(t.adUnitCode);if(!s)throw new Error(`${Ai} unable to find div ${t.adUnitCode}`);{const o=s.getElementsByTagName("iframe");O(`${Ai} found ${o.length} iframe to remove`),Array.from(o).forEach((e=>e.remove()));const a=document.createElement("iframe");a.scrolling="no",a.frameBorder="0",a.marginHeight="0",a.name=`prebid_ads_iframe_${t.adUnitCode}`,a.title="3rd party ad content",null===(i=a.sandbox)||void 0===i||i.add("allow-forms","allow-popups","allow-popups-to-escape-sandbox","allow-same-origin","allow-scripts","allow-top-navigation-by-user-activation"),a.setAttribute("aria-label","Advertisment"),a.style.setProperty("border","0"),a.style.setProperty("margin","0"),a.style.setProperty("overflow","hidden"),s.appendChild(a);const r=null===(n=a.contentWindow)||void 0===n?void 0:n.document;if(!r)throw new Error(`${Ai} error while getting document from iframe`);{e.renderAd(r,t.adId);const i="/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */button,hr,input{overflow:visible}progress,sub,sup{vertical-align:baseline}[type=checkbox],[type=radio],legend{box-sizing:border-box;padding:0}html{line-height:1.15;-webkit-text-size-adjust:100%}body{margin:0}details,main{display:block}h1{font-size:2em;margin:.67em 0}hr{box-sizing:content-box;height:0}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}a{background-color:transparent}abbr[title]{border-bottom:none;text-decoration:underline;text-decoration:underline dotted}b,strong{font-weight:bolder}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}img{border-style:none}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;line-height:1.15;margin:0}button,select{text-transform:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{border-style:none;padding:0}[type=button]:-moz-focusring,[type=reset]:-moz-focusring,[type=submit]:-moz-focusring,button:-moz-focusring{outline:ButtonText dotted 1px}fieldset{padding:.35em .75em .625em}legend{color:inherit;display:table;max-width:100%;white-space:normal}textarea{overflow:auto}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}[hidden],template{display:none}",n=r.createElement("style");n.appendChild(r.createTextNode(i)),r.head.appendChild(n)}}}}(this.pbjs,e);const t={divId:e.adUnitCode,isEmpty:!1,hb_bidder:e.adserverTargeting.bid_bidder,hb_mediaType:e.adserverTargeting.bid_mediatype,size:e.adserverTargeting.bid_size?F(e.adserverTargeting.bid_size):null,advertiserId:null,lineItemId:null,orderId:null,creativeId:null};this.renderListenerCallback(t)}catch(e){P(`${Ai} unable to render: ${e}`)}}else{const t={divId:e.divId,isEmpty:!0,size:null,advertiserId:null,lineItemId:null,orderId:null,creativeId:null};this.renderListenerCallback(t)}}}))):P(`${Ai} pbjs is not available`)}clean(){O(`${Ai} cleanAdUnits - START`),this.managedDivs.forEach((e=>{const t=document.getElementById(e);if(t){const e=t.getElementsByTagName("iframe");O(`${Ai} found ${e.length} iframe to remove`),Array.from(e).forEach((e=>e.remove()))}})),this.managedDivs=[],O(`${Ai} cleanAdUnits - END`,this.managedDivs)}declareAdUnits(e){return O(`${Ai} declareAdUnits (adUnits, managedDivs)`,e,this.managedDivs),e.forEach((e=>{this.managedDivs.includes(e.divId)?P(`${Ai} adUnit already declared ${e.divId}`):this.managedDivs.push(e.divId)})),Promise.resolve(void 0)}executeWhenAdServerReady(e){O(`${Ai} executeWhenAdServerReady`,e),e()}init(e,t,i,n){O(`${Ai} init (nothing to do), this are the input params:`,e,t,i,n)}removeRenderListener(){O(`${Ai} removeRenderListener`),this.callbacks=[]}renderListenerCallback(e){O(`${Ai} renderListenerCallback called event:`,e),this.callbacks.forEach((t=>t(e)))}renderListener(e){O(`${Ai} renderListener`,e),this.callbacks.push(e)}setApsTargetings(){}setPbjsTargetings(){}setRefreshTargeting(){}registerExternalTargetingDeclaration(){}}function Ii(e,t,i,n,s){const o=`${n}_${s}`;navigator.sendBeacon(`https://intake.pbstck.com/v1/intake/gam-impression?sId=${t}&tId=${e}&c=1&s=${o}&v=${i}`)}class Ci{constructor(){this.name="AdServer",this.scriptLoaded=!1,this.loaded=!1}get adServer(){return this._adServer}isLoaded(){return this.loaded}async load(){this.loaded=!0}async onAfterConsentRefused({config:e}){var t;if(!this._adServer)switch(e.consentlessMode){case"GAM":this._adServer=new mi(window,(null===(t=e.globalRefreshConfig)||void 0===t?void 0:t.prebidOrderIds)||[]),this._adServer.renderListener((t=>{t.isEmpty||Ii(e.tagId,e.stack.scopeId,e.kleanadsVersion,e.stack.stackId,e.stackVersion)})),this.scriptLoaded||(j("https://pagead2.googlesyndication.com/tag/js/gpt.js"),this.scriptLoaded=!0);break;case"local":this._adServer=new Si;break;default:O("AdServerModule - onAfterConsentRefused - no ad server configured for consentless")}}async onAfterConsentAccepted({config:e}){var t;this._adServer||(this._adServer=new mi(window,(null===(t=e.globalRefreshConfig)||void 0===t?void 0:t.prebidOrderIds)||[]),this._adServer.renderListener((t=>{t.isEmpty||Ii(e.tagId,e.stack.scopeId,e.kleanadsVersion,e.stack.stackId,e.stackVersion)})),this.scriptLoaded||(j("https://securepubads.g.doubleclick.net/tag/js/gpt.js"),this.scriptLoaded=!0))}async onStackConfigLoad({config:e,stackConfig:t}){this._adServer?this._adServer.init(e.pageContext,t.lazyLoading,t.gamConfig,t.runningABTest):P("AdServerModule - onStackConfigLoad - no ad server configured")}async onPrepareAdUnits({toPreparedAdUnits:e}){var t;const i=(null!=e?e:[]).filter((e=>!e.mediaTypes.includes("Instream")));return null===(t=this._adServer)||void 0===t?void 0:t.declareAdUnits(i)}async onAfterPrebidReady({prebid:e}){const t=e.getPbjs();this._adServer?this._adServer.prebidReady(t):P("AdServerModule - onAfterPrebidReady - no ad server configured")}async clean(){this._adServer?this._adServer.clean():P("AdServerModule - clean - no ad server configured")}}function wi(e,t,i,n,s,o){function a(e){if(void 0!==e&&"function"!=typeof e)throw new TypeError("Function expected");return e}for(var r,d=n.kind,l="getter"===d?"get":"setter"===d?"set":"value",c=!t&&e?n.static?e:e.prototype:null,u=t||(c?Object.getOwnPropertyDescriptor(c,n.name):{}),f=!1,h=i.length-1;h>=0;h--){var g={};for(var p in n)g[p]="access"===p?{}:n[p];for(var p in n.access)g.access[p]=n.access[p];g.addInitializer=function(e){if(f)throw new TypeError("Cannot add initializers after decoration has completed");o.push(a(e||null))};var v=(0,i[h])("accessor"===d?{get:u.get,set:u.set}:u[l],g);if("accessor"===d){if(void 0===v)continue;if(null===v||"object"!=typeof v)throw new TypeError("Object expected");(r=a(v.get))&&(u.get=r),(r=a(v.set))&&(u.set=r),(r=a(v.init))&&s.unshift(r)}else(r=a(v))&&("field"===d?s.unshift(r):u[l]=r)}c&&Object.defineProperty(c,n.name,u),f=!0}function Ei(e,t,i){for(var n=arguments.length>2,s=0;s<t.length;s++)i=n?t[s].call(e,i):t[s].call(e);return n?i:void 0}function _i(e,t,i){return"symbol"==typeof t&&(t=t.description?"[".concat(t.description,"]"):""),Object.defineProperty(e,"name",{configurable:!0,value:t})}function ki(e){return function(t,i){return class extends t{constructor(){super(...arguments),this.deferLoadingTo=e}}}}"function"==typeof SuppressedError&&SuppressedError;let Ti=(()=>{let e,t,i=[ki("onStackConfigLoad")],n=[];return t=class{constructor(){this.name="Aps"}get aps(){return this._aps}isLoaded(){return!!this._aps}async load({stackConfig:e}){var t;this._aps=function(e,t){if(e&&t.some((e=>e.headerBiddingEnabled&&(e.isInstream||e.canOutstream||e.sizes.some((e=>"fluid"!==e)))))){O("downloading amazon apstag");const t=new ei(window,e);return t.load(),t}}(null===(t=e.tamConfig)||void 0===t?void 0:t.apsPubId,e.adUnits)}async onStackConfigLoad({config:e,stackConfig:t}){var i,n,s,o,a;const r=(null===(i=t.tamConfig)||void 0===i?void 0:i.disableSchain)||null===(n=t.prebidConfig)||void 0===n?void 0:n.pbjsConfig.schain;null===(s=this._aps)||void 0===s||s.initAps(null!==(a=null===(o=t.prebidConfig)||void 0===o?void 0:o.adCallTimeout)&&void 0!==a?a:e.adCallTimeout,r)}async clean(){}},_i(t,"ApsModule"),(()=>{const s="function"==typeof Symbol&&Symbol.metadata?Object.create(null):void 0;wi(null,e={value:t},i,{kind:"class",name:t.name,metadata:s},null,n),t=e.value,s&&Object.defineProperty(t,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:s}),Ei(t,n)})(),t})();const Oi="ModuleService";class Ri{constructor(e,t){this.modules=t,this.lifecycleState={config:e},O(`[${Oi}] Init: ${this.modules.length} modules registered`);for(const e of this.modules)e.isLoaded()?O(`[${Oi}] Module ${e.name} is already loaded`):O(`[${Oi}] Registered module ${e.name}.${e.deferLoadingTo?`Deferred loading to ${e.deferLoadingTo}`:""}`)}getModules(){return this.modules}getLoadedModuleInstance(e){return this.modules.filter((e=>e.isLoaded())).find((t=>t instanceof e))}async loadModules(e){for(const t of e){O(Oi,`Loading module ${t.name}`);try{await t.load(this.lifecycleState)}catch(e){P(Oi,`Error while loading module ${t.name}`,e)}}}async loadInitialModules(){const e=this.modules.filter((e=>!e.deferLoadingTo&&!e.isLoaded()));O(`[${Oi}] Loading initial modules. ${e.length} modules to load`),await this.loadModules(e)}async modulesDispatchEvent(e,...t){this.lifecycleState={...this.lifecycleState,...t[0]};const i=this.lifecycleState,n=this.modules.filter((t=>t.deferLoadingTo===e&&!t.isLoaded()));return O(`[${Oi}] event call: ${e}. ${n.length} deferred modules to load`),await this.loadModules(n),new Promise((t=>{var n;const s=this.modules.filter((t=>t.isLoaded()&&t[e]&&"function"==typeof t[e]));O(`[${Oi}] event call: ${e}. ${s.length} modules to call`);const o=[];for(const t of s){O(Oi,`Calling ${e} on module ${t.name}`);const s=null===(n=t[e])||void 0===n?void 0:n.call(t,i);s instanceof Promise&&o.push(s)}t(o)}))}async modulesCleanUp(){const e=this.modules.filter((e=>e.isLoaded()));O(`[${Oi}] Cleaning modules. ${e.length} modules cleanup started`);for(const t of e)O(Oi,`Cleaning module ${t.name}`),await t.clean(this.lifecycleState);this.modules=[]}}let $i=(()=>{let e,t,i=[ki("onStackConfigLoad")],n=[];return t=class{constructor(){this.name="Prebid"}get pbjs(){return this._pbjs}isLoaded(){return!!this._pbjs}async load({config:e,stackConfig:t}){this._pbjs=await async function(e,t){if(t.some((e=>e.headerBiddingEnabled&&e.bidders.length)))try{const t=await D(e);return new Kt(t)}catch(e){return void O("[config] Error while loading the kleanadsPbjs module",e)}}(e.newPrebidUrl,t.adUnits),this._pbjs&&this.aliasWindowPbjs(window,this._pbjs.getPbjs())}async onStackConfigLoad({config:e,stackConfig:t}){var i,n,s;if(!this._pbjs)throw new Error("PrebidModule is not loaded");const o=null!==(n=null===(i=null==t?void 0:t.prebidConfig)||void 0===i?void 0:i.adCallTimeout)&&void 0!==n?n:e.adCallTimeout,a=t.prebidConfig.pbjsConfig,r={gdpr:{cmpApi:"iab",timeout:8e3,defaultGdprScope:!0}},d=this._pbjs.getPbjs().installedModules;d.includes("consentManagementUsp")&&(r.usp={cmpApi:"iab",timeout:8e3}),d.includes("consentManagementGpp")&&(r.gpp={cmpApi:"iab",timeout:8e3}),d.includes("anonymisedRtdProvider")&&(r.gdpr.rules=[{purpose:"storage",enforcePurpose:!0,enforceVendor:!0,vendorExceptions:["anonymised"]}]);const l={bidderTimeout:o,useBidCache:!0,maxRequestsPerOrigin:6,consentManagement:e.noCmp?void 0:r,enableSendAllBids:!1,pageUrl:document.location.href,cache:{url:"https://prebid.adnxs.com/pbc/v1/cache",ignoreBidderCacheKey:!0},timeoutBuffer:400};if(this._pbjs.initPbjs(t.adUnits,a,l,e.priceRuleBuckets),null===(s=null==a?void 0:a.targetingBehaviors)||void 0===s?void 0:s.sendKVTargetings){const i=m(window),n=this._pbjs.extractUniqAdaptersName(t.adUnits,a.bidderAliases).filter((e=>{var t;return!(null===(t=a.targetingBehaviors)||void 0===t?void 0:t.biddersBlackList.includes(e))}));this._pbjs.setContextValuesAsTargeting(e.pageContext,i,n)}}async clean(){var e;this.setDefaultPbjsConfig();const t=null===(e=this._pbjs)||void 0===e?void 0:e.getPbjs();t&&(t.bidderSettings={})}aliasWindowPbjs(e,t){e.pbjs=t}setDefaultPbjsConfig(){var e;null===(e=this._pbjs)||void 0===e||e.getPbjs().setConfig({bidderTimeout:3e3,enableSendAllBids:!0,useBidCache:!1,deviceAccess:!0,timeoutBuffer:400,disableAjaxTimeout:!1,maxNestedIframes:10,priceGranularity:"medium",customPriceBucket:{},mediaTypePriceGranularity:{},bidderSequence:"random",auctionOptions:{},userSync:{syncEnabled:!0,filterSettings:{image:{bidders:"*",filter:"include"}},syncsPerBidder:5,syncDelay:3e3,auctionDelay:0}})}},_i(t,"PrebidModule"),(()=>{const s="function"==typeof Symbol&&Symbol.metadata?Object.create(null):void 0;wi(null,e={value:t},i,{kind:"class",name:t.name,metadata:s},null,n),t=e.value,s&&Object.defineProperty(t,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:s}),Ei(t,n)})(),t})();class Pi{constructor(e,t){this.pubstackWindow=e,this.rule=t}isDivIdMatchingRule(e){const t=document.getElementById(e);if(t){const e=t.getBoundingClientRect();return this.rule(this.pubstackWindow,e)}return!1}}const Li=(e,t,i)=>{if(function(e){return 0===e.top&&0===e.bottom&&0===e.left&&0===e.right&&0===e.width&&0===e.height}(t))return!1;const n=-i*e.innerHeight,s=(1+i)*e.innerHeight>t.top,o=t.bottom>n;return s&&o};function Ni(e,t,i,n){const s=e.filter((e=>e.roadblock)).filter((e=>!e.mediaTypes.includes("Instream"))).filter((e=>N(e.divId))),o=e.filter((e=>!e.roadblock)).filter((e=>!e.mediaTypes.includes("Instream"))).filter((e=>N(e.divId))),a=e.filter((e=>e.mediaTypes.includes("Instream"))).filter((e=>N(e.divId)));t.executeAdCallRoadblock(s),a.length>0&&(a.length>1&&$(`cannot monetize multiple instream adunits, using only the first one ${a[0].divId}`),null==i||i.executeAdCall(a[0]));const r=function(e){if(e&&e.lazyLoadingKleanads){const t=e.lazyLoadingKleanads.viewportPercent/100;return O(`[lazyloading] lazy loading enabled with ${t} viewports`),(e,i)=>Li(e,i,t)}}(n);if(r){const e=new Pi(window,r);s.length>0?setTimeout((()=>Ui(o,e,t)),1e3):Ui(o,e,t)}else s.length>0?setTimeout((()=>t.executeAdCall(o)),1e3):t.executeAdCall(o)}function Ui(e,t,i){const n=e.filter((e=>{var i;return(null===(i=e.anchor)||void 0===i?void 0:i.mode)||e.outOfPageType||t.isDivIdMatchingRule(e.divId)})),s=n.filter((e=>!i.isAlreadyMonetized(e)));i.executeAdCall(s),setTimeout((()=>Ui(e,t,i)),200)}const xi="[optimization]",Di=async e=>{try{const t=await ji();if(null==e?void 0:e.prebidConfig.adCallTimeout){const i=t.getTimeout(null==e?void 0:e.prebidConfig.adCallTimeout);O(`${xi} Ad call timeout optimized from ${null==e?void 0:e.prebidConfig.adCallTimeout} to ${i}`),e.prebidConfig.adCallTimeout=i}}catch(e){P(`${xi} Error while loading optimization engine`,e)}return e},ji=async()=>new Promise(((e,t)=>{try{const i={env:{}};WebAssembly.instantiateStreaming(fetch("https://cdn-adm.pbstck.com/kleanads/wasm/volt.wasm"),i).then((t=>{O(`${xi} WebAssembly module loaded successfully`,t),e(t.instance.exports)})).catch((e=>{t(e)}))}catch(e){t(e)}}));var Mi,Bi,Vi,Fi,zi,Wi,Gi,Hi,Ji,Ki;!function(e){e.INSTREAM="instream",e.OUTSTREAM="outstream"}(Mi||(Mi={})),function(e){e[e.LINEAR=1]="LINEAR",e[e.NON_LINEAR=2]="NON_LINEAR"}(Bi||(Bi={})),function(e){e[e.IN_STREAM=1]="IN_STREAM",e[e.IN_BANNER=2]="IN_BANNER",e[e.IN_ARTICLE=3]="IN_ARTICLE",e[e.IN_FEED=4]="IN_FEED",e[e.INTERSTITIAL=5]="INTERSTITIAL"}(Vi||(Vi={})),function(e){e[e.INSTREAM=1]="INSTREAM",e[e.ACCOMPANYING_CONTENT=2]="ACCOMPANYING_CONTENT",e[e.INTERSTITIAL=3]="INTERSTITIAL",e[e.NO_CONTENT=4]="NO_CONTENT"}(Fi||(Fi={})),function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.ABOVE_THE_FOLD=1]="ABOVE_THE_FOLD",e[e.LOCKED=2]="LOCKED",e[e.BELOW_THE_FOLD=3]="BELOW_THE_FOLD",e[e.HEADER=4]="HEADER",e[e.FOOTER=5]="FOOTER",e[e.SIDEBAR=6]="SIDEBAR",e[e.FULLSCREEN=7]="FULLSCREEN"}(zi||(zi={})),function(e){e[e.VAST_1_0=1]="VAST_1_0",e[e.VAST_2_0=2]="VAST_2_0",e[e.VAST_3_0=3]="VAST_3_0",e[e.VAST_1_0_WRAPPER=4]="VAST_1_0_WRAPPER",e[e.VAST_2_0_WRAPPER=5]="VAST_2_0_WRAPPER",e[e.VAST_3_0_WRAPPER=6]="VAST_3_0_WRAPPER",e[e.VAST_4_0=7]="VAST_4_0",e[e.VAST_4_0_WRAPPER=8]="VAST_4_0_WRAPPER",e[e.DAAST_1_0=9]="DAAST_1_0",e[e.DAAST_1_0_WRAPPER=10]="DAAST_1_0_WRAPPER",e[e.VAST_4_1=11]="VAST_4_1",e[e.VAST_4_1_WRAPPER=12]="VAST_4_1_WRAPPER",e[e.VAST_4_2=13]="VAST_4_2",e[e.VAST_4_2_WRAPPER=14]="VAST_4_2_WRAPPER"}(Wi||(Wi={})),function(e){e[e.VPAID_1_0=1]="VPAID_1_0",e[e.VPAID_2_0=2]="VPAID_2_0",e[e.MRAID_1_0=3]="MRAID_1_0",e[e.ORMMA=4]="ORMMA",e[e.MRAID_2_0=5]="MRAID_2_0",e[e.MRAID_3_0=6]="MRAID_3_0",e[e.OMID_1_0=7]="OMID_1_0",e[e.SIMID_1_0=8]="SIMID_1_0",e[e.SIMID_1_1=9]="SIMID_1_1"}(Gi||(Gi={})),function(e){e[e.AUTO_PLAY_SOUND_ON=1]="AUTO_PLAY_SOUND_ON",e[e.AUTO_PLAY_SOUND_OFF=2]="AUTO_PLAY_SOUND_OFF",e[e.CLICK_TO_PLAY=3]="CLICK_TO_PLAY",e[e.MOUSE_OVER=4]="MOUSE_OVER",e[e.INVIEW_SOUND_ON=5]="INVIEW_SOUND_ON",e[e.INVIEW_SOUND_OFF=6]="INVIEW_SOUND_OFF",e[e.CONTINUOUS_PLAYBACK=7]="CONTINUOUS_PLAYBACK"}(Hi||(Hi={})),function(e){e.VIDEO_MP4="video/mp4",e.VIDEO_WEBM="video/webm",e.VIDEO_OGG="video/ogg",e.VIDEO_MPEG="video/mpeg",e.APPLICATION_JAVASCRIPT="application/javascript"}(Ji||(Ji={})),function(e){e[e.NON_SKIPPABLE=0]="NON_SKIPPABLE",e[e.SKIPPABLE=1]="SKIPPABLE"}(Ki||(Ki={}));const Yi={playerSize:[[640,480]],context:Mi.INSTREAM,api:[Gi.VPAID_1_0,Gi.VPAID_2_0],linearity:Bi.LINEAR,mimes:[Ji.VIDEO_MP4,Ji.VIDEO_MPEG,Ji.APPLICATION_JAVASCRIPT],startdelay:0,minduration:0,maxduration:32,protocols:[Wi.VAST_2_0,Wi.VAST_2_0_WRAPPER,Wi.VAST_3_0,Wi.VAST_3_0_WRAPPER,Wi.VAST_4_0,Wi.VAST_4_0_WRAPPER],placement:Vi.IN_STREAM,plcmt:Fi.INSTREAM,pos:zi.ABOVE_THE_FOLD,playbackmethod:[Hi.AUTO_PLAY_SOUND_ON],skipafter:0,minbitrate:0,maxbitrate:700,protocol:Wi.VAST_4_0_WRAPPER},qi={playerSize:[[640,480]],context:Mi.INSTREAM,api:[Gi.VPAID_1_0,Gi.VPAID_2_0,Gi.MRAID_1_0,Gi.MRAID_2_0,Gi.MRAID_3_0,Gi.OMID_1_0],linearity:Bi.LINEAR,mimes:[Ji.VIDEO_MP4,Ji.VIDEO_OGG,Ji.VIDEO_WEBM,Ji.APPLICATION_JAVASCRIPT],maxduration:30,minduration:1,protocols:[Wi.VAST_1_0,Wi.VAST_2_0,Wi.VAST_3_0,Wi.VAST_4_0,Wi.VAST_1_0_WRAPPER,Wi.VAST_2_0_WRAPPER,Wi.VAST_3_0_WRAPPER,Wi.VAST_4_0_WRAPPER,Wi.VAST_4_1,Wi.VAST_4_1_WRAPPER,Wi.VAST_4_2,Wi.VAST_4_2_WRAPPER],startdelay:0,placement:Vi.IN_STREAM,plcmt:Fi.INSTREAM,playbackmethod:[Hi.AUTO_PLAY_SOUND_OFF,Hi.CLICK_TO_PLAY,Hi.MOUSE_OVER],skip:Ki.SKIPPABLE,skipafter:0,pos:zi.UNKNOWN,minbitrate:1,maxbitrate:6e3},Xi={playerSize:[[640,480]],context:Mi.INSTREAM,mimes:[Ji.VIDEO_MP4,Ji.VIDEO_WEBM,Ji.APPLICATION_JAVASCRIPT],minduration:0,maxduration:15,startdelay:0,protocols:[Wi.VAST_2_0,Wi.VAST_2_0_WRAPPER,Wi.VAST_3_0,Wi.VAST_3_0_WRAPPER,Wi.VAST_4_0,Wi.VAST_4_0_WRAPPER,Wi.VAST_4_1,Wi.VAST_4_1_WRAPPER,Wi.VAST_4_2,Wi.VAST_4_2_WRAPPER],placement:Vi.IN_STREAM,plcmt:Fi.INSTREAM,linearity:Bi.LINEAR,skip:Ki.NON_SKIPPABLE,skipmin:0,skipafter:0,minbitrate:1,maxbitrate:6e3,playbackmethod:[Hi.AUTO_PLAY_SOUND_OFF],pos:zi.ABOVE_THE_FOLD,api:[Gi.VPAID_2_0,Gi.OMID_1_0,Gi.SIMID_1_0,Gi.SIMID_1_1]},Qi={pubstack:{playerSize:[640,480],mimes:[Ji.VIDEO_MP4,Ji.VIDEO_WEBM,Ji.APPLICATION_JAVASCRIPT],context:Mi.INSTREAM},dailymotion:Xi,jwplayerHbv:qi,dailymotionPrsm:Yi};function Zi(e,t){var i;Object.keys(null!=e?e:{}).some((e=>"scope"!==e&&"sites"!==e))&&P("Invalid override object",e);const n=null===(i=null==e?void 0:e.sites)||void 0===i?void 0:i[t],s=null==e?void 0:e.scope;return null!=n?n:s}function en(e,t){var i;if(t)return null!==(i=t[e])&&void 0!==i?i:t.type}function tn(e){var t;const i=("; "+document.cookie).split("; "+e+"=");if(2===i.length)return null===(t=i.pop())||void 0===t?void 0:t.split(";").shift()}function nn(e,t){return t.flatMap((t=>[t,...e.filter((e=>e.bidderSource===t)).map((e=>e.bidderLabel))]))}class sn{constructor(e,t){this.stackLoadedConfig={...e,runningABTest:[]},this.pocOverrides=t}withConvertToInstreamAdUnit(){const e=this.pocOverrides.convertToInstreamAdUnits;let t;switch(W([25,25,25,25])){case 1:t=Qi.pubstack,this.stackLoadedConfig.runningABTest.push({name:"instreamMediaType",value:"pubstack"});break;case 2:t=Qi.dailymotion,this.stackLoadedConfig.runningABTest.push({name:"instreamMediaType",value:"dailymotion"});break;case 3:t=Qi.dailymotionPrsm,this.stackLoadedConfig.runningABTest.push({name:"instreamMediaType",value:"dailymotionPrsm"});break;case 4:t=Qi.jwplayerHbv,this.stackLoadedConfig.runningABTest.push({name:"instreamMediaType",value:"jwplayerHbv"})}return e&&this.stackLoadedConfig.adUnits.forEach((i=>{var n;const s=e[i.adUnitName];s&&(i.isInstream=!0,i.dynamic=!1,i.parallax=!1,i.anchor=void 0,i.canOutstream=!1,i.biddersOutstream=[],i.floors=s.floors,i.instreamParams={...s.instreamParams,vast:(null===(n=s.instreamParams)||void 0===n?void 0:n.vast)||{},mediaTypeParams:t})})),this}withConvertToNativeAdUnit(){const e=this.pocOverrides.convertToNativeAdUnits;return e&&this.stackLoadedConfig.adUnits.forEach((t=>{var i;const n=e[t.adUnitName];n&&(t.canNative=!0,t.nativeParams=n.nativeParams,n.useNativeAlias&&(t.biddersNative=t.bidders.filter((e=>e.bidder.includes("native"))),t.bidders=t.bidders.filter((e=>!e.bidder.includes("native")))),n.nativeOnly&&(t.sizes=[],(null===(i=t.extraAdServerSizes)||void 0===i?void 0:i.includes("fluid"))?t.extraAdServerSizes=["fluid"]:t.extraAdServerSizes=[],t.isInstream=!1,t.parallax=!1,t.anchor=void 0,t.canOutstream=!1,t.biddersOutstream=[]))})),this}withFirstId(){var e,t,i;if(null===(e=this.pocOverrides)||void 0===e?void 0:e.firstId){const e=this.stackLoadedConfig.prebidConfig.pbjsConfig.bidderAliases||[],n=function(){const e=new RegExp("(?:(?:^|.*; *)firstid *= *([^;]*).*$)|^.*$","i"),t=document.cookie.match(e);return t&&t[1]?decodeURIComponent(t[1]):void 0}();if(n){const s=null!==(i=null===(t=this.stackLoadedConfig.prebidConfig.pbjsConfig.userSync)||void 0===t?void 0:t.userIds)&&void 0!==i?i:[];s.push({name:"pubProvidedId",bidders:nn(e,["appnexus","pubmatic","rubicon","ix","nexx360","criteo","smartadserver","mediasquare","ogury","freewheel-ssp","outbrain","taboola","adf"]),params:{eids:[{source:"first-id.fr",uids:[{id:n,atype:1,ext:{stype:"ppuid"}}]}]}}),this.stackLoadedConfig.prebidConfig.pbjsConfig.userSync={...this.stackLoadedConfig.prebidConfig.pbjsConfig.userSync,userIds:s}}}return this}withId5Id(){var e,t,i;if(null===(e=this.pocOverrides)||void 0===e?void 0:e.id5id){const e=localStorage.getItem(this.pocOverrides.id5id.pd);e&&(null!==(i=null===(t=this.stackLoadedConfig.prebidConfig.pbjsConfig.userSync)||void 0===t?void 0:t.userIds)&&void 0!==i?i:[]).forEach((t=>{"id5Id"===t.name&&(t.params||(t.params={}),t.params.pd=e)}))}return this}withConvertToInterstitialAdUnit(){const e=this.pocOverrides.convertToInterstitialAdUnits;return e&&this.stackLoadedConfig.adUnits.forEach((t=>{e.includes(t.adUnitName)&&(t.outOfPageType="interstitial",O(`Interstitial adUnit found: ${t.adUnitName}`))})),this}withSkinRenderingSettings(e,t){var i,n,s;const o=null===(i=this.pocOverrides)||void 0===i?void 0:i.skinRenderingSettings,a=null===(n=null==o?void 0:o.stackLevel)||void 0===n?void 0:n[t],r=null===(s=null==o?void 0:o.siteLevel)||void 0===s?void 0:s[e];return(null==r?void 0:r.disableSkinBids)||(null==a?void 0:a.disableSkinBids)?this.stackLoadedConfig.adUnits=this.stackLoadedConfig.adUnits.map((e=>({...e,sizes:e.sizes.filter((e=>!Y(e,[1800,1e3])))}))):((null==r?void 0:r.biddersOverride)||(null==a?void 0:a.biddersOverride))&&(this.stackLoadedConfig.adUnits=this.stackLoadedConfig.adUnits.map((e=>{var t;return e.sizes.some((e=>Y(e,[1800,1e3])))?{...e,biddersSkin:null!==(t=null==a?void 0:a.biddersOverride)&&void 0!==t?t:null==r?void 0:r.biddersOverride}:e}))),this}withRefreshOutOfFocus(e){var t,i;const n=null===(t=this.pocOverrides)||void 0===t?void 0:t.refreshOutOfFocus;if(n){const t=Zi(n,e);t&&(null===(i=this.stackLoadedConfig.refreshConfig)||void 0===i||i.adUnitConfig.forEach((e=>{e.refreshOutOfFocusConfig=t})))}return this}withPpidSolution(e){var t;const i=Zi(null===(t=this.pocOverrides)||void 0===t?void 0:t.ppidSolutions,e);if(i){const e=Array.isArray(i.ppidSolution)?i.ppidSolution:[i.ppidSolution],{type:t,value:n}=function(e){var t,i;for(const n of e)switch(n){case Le.firstId:return{type:"prebid",value:"first-id.fr"};case Le.sharedId:return{type:"prebid",value:"pubcid.org"};case Le.utiqId:return{type:"prebid",value:"utiq.com"};case Ne.id5id:{const e=localStorage.getItem("id5id");if(e)return{type:"other",value:(i=e,JSON.parse(decodeURIComponent(i)).gp)};break}default:{let e=localStorage.getItem(n);if(e)return{type:"other",value:e};if(e=null!==(t=tn(n))&&void 0!==t?t:null,e)return{type:"other",value:e}}}return{type:"other",value:""}}(e);if("prebid"===t)this.stackLoadedConfig.prebidConfig.pbjsConfig.userSync={...this.stackLoadedConfig.prebidConfig.pbjsConfig.userSync,ppid:n};else this.stackLoadedConfig.gamConfig&&n&&(this.stackLoadedConfig.gamConfig.ppidValue=n)}return this}withRefreshAlwaysInView(){var e;const t=null===(e=this.pocOverrides)||void 0===e?void 0:e.refreshAlwaysInViewAdUnitNames;if(this.stackLoadedConfig.refreshConfig&&t&&t.length>0){const e=[];this.stackLoadedConfig.refreshConfig.adUnitConfig.forEach((i=>{t.forEach((t=>{var n;(null===(n=i.adUnitNames)||void 0===n?void 0:n.includes(t))&&(e.push({...i,alwaysInView:!0,adUnitNames:[t]}),i.adUnitNames.splice(i.adUnitNames.indexOf(t),1))}))})),this.stackLoadedConfig.refreshConfig.adUnitConfig=[...this.stackLoadedConfig.refreshConfig.adUnitConfig.filter((e=>(e.adUnitNames||[]).length>0)),...e]}return this}withrefreshBehaviorOnEmpty(){var e,t;const i=null===(e=this.pocOverrides)||void 0===e?void 0:e.refreshBehaviorOnEmpty;return i&&(null===(t=this.stackLoadedConfig.refreshConfig)||void 0===t||t.adUnitConfig.forEach((e=>{e.refreshBehaviorOnEmpty=i}))),this}withOutbrainConfig(e){var t;if(null===(t=this.pocOverrides)||void 0===t?void 0:t.outbrainConfig){const t=this.pocOverrides.outbrainConfig.find((t=>t.siteId===e)),i=this.pocOverrides.outbrainConfig.find((e=>!e.siteId)),n=t||i;n&&(this.stackLoadedConfig.prebidConfig.pbjsConfig.outbrain={bidderUrl:n.bidderUrl,usersyncUrl:n.usersyncUrl})}return this}withXplnConfig(e){const t=Zi(this.pocOverrides.xplnConfig,e);return t&&(this.stackLoadedConfig.xplnConfig=t),this}withFloorEnforcement(e){var t,i,n,s,o,a;if(null===(t=this.pocOverrides)||void 0===t?void 0:t.floorEnforcement){const t=null===(s=null===(n=null===(i=this.pocOverrides)||void 0===i?void 0:i.floorEnforcement)||void 0===n?void 0:n.sites)||void 0===s?void 0:s[e],r=null===(a=null===(o=this.pocOverrides)||void 0===o?void 0:o.floorEnforcement)||void 0===a?void 0:a.scope;(t||r)&&(this.stackLoadedConfig.prebidConfig.pbjsConfig.floors={...this.stackLoadedConfig.prebidConfig.pbjsConfig.floors,enforcement:{...null!=t?t:r}})}return this}withDynamicPrebidFloors(e){var t,i,n,s,o,a;if(null===(t=this.pocOverrides)||void 0===t?void 0:t.dynamicPrebidFloors){const t=null===(s=null===(n=null===(i=this.pocOverrides)||void 0===i?void 0:i.dynamicPrebidFloors)||void 0===n?void 0:n.sites)||void 0===s?void 0:s[e],r=null===(a=null===(o=this.pocOverrides)||void 0===o?void 0:o.dynamicPrebidFloors)||void 0===a?void 0:a.scope;(t||r)&&this.stackLoadedConfig.adUnits.forEach((e=>{e.dynamicPrebidFloor=!0}))}return this}withFledgeForGpt(){var e,t;if(null===(e=this.pocOverrides)||void 0===e?void 0:e.fledgeForGpt){const e=nn(this.stackLoadedConfig.prebidConfig.pbjsConfig.bidderAliases||[],["criteo"]);this.stackLoadedConfig.adUnits.forEach((t=>{var i;t.bidders.find((t=>e.includes(t.bidder)))&&(t.ortb2Imp={...t.ortb2Imp,ext:{...null===(i=t.ortb2Imp)||void 0===i?void 0:i.ext,ae:1}})})),this.stackLoadedConfig.prebidConfig.pbjsConfig.bidderConfigs||(this.stackLoadedConfig.prebidConfig.pbjsConfig.bidderConfigs=[]);const i=this.stackLoadedConfig.prebidConfig.pbjsConfig.bidderConfigs.find((t=>Array.isArray(t.bidders)&&t.bidders.find((t=>e.includes(t)))));i&&i.config?i.config.fledgeEnabled=!0:null===(t=this.stackLoadedConfig.prebidConfig.pbjsConfig.bidderConfigs)||void 0===t||t.push({bidders:[...e],config:{fledgeEnabled:!0}}),this.stackLoadedConfig.prebidConfig.pbjsConfig={...this.stackLoadedConfig.prebidConfig.pbjsConfig,fledgeForGpt:!0}}return this}withRtbHousePaapi(){if(this.pocOverrides.rtbhousePaapi){const e=nn(this.stackLoadedConfig.prebidConfig.pbjsConfig.bidderAliases||[],["rtbhouse"]);this.stackLoadedConfig.adUnits.some((t=>t.bidders.some((t=>e.includes(t.bidder)))))&&(this.stackLoadedConfig.prebidConfig.pbjsConfig={...this.stackLoadedConfig.prebidConfig.pbjsConfig,paapi:{enabled:!0,bidders:[...e],defaultForSlots:1,gpt:{autoconfig:!0}}})}return this}withSkinFloor(e){var t,i,n;const s=null===(t=this.pocOverrides)||void 0===t?void 0:t.skinFloor;if(s){const t=null!==(n=null===(i=s.specificFloor)||void 0===i?void 0:i[e])&&void 0!==n?n:s.defaultFloor;this.stackLoadedConfig.adUnits.forEach((e=>{var i;if(e.sizes.some((e=>Y(e,[1800,1e3]))))if(e.floors){const n=null===(i=e.floors)||void 0===i?void 0:i.values.banner;n?e.floors={...e.floors,schema:{delimiter:"|",fields:["mediaType","size"]},values:{"banner|*":n,"banner|1800x1000":t}}:P("no banner value found in floors, skin floor cannot be applied.",e.floors)}else e.floors={currency:s.currency,schema:{delimiter:"|",fields:["mediaType","size"]},values:{"banner|1800x1000":t}}}))}return this}withDsaConfig(){var e,t;return(null===(e=this.pocOverrides)||void 0===e?void 0:e.dsaConfig)&&(this.stackLoadedConfig.prebidConfig.pbjsConfig={...this.stackLoadedConfig.prebidConfig.pbjsConfig,dsaConfig:null===(t=this.pocOverrides)||void 0===t?void 0:t.dsaConfig}),this}withPrebidServerConfig(e){var t,i,n,s,o,a;if((null===(t=this.pocOverrides)||void 0===t?void 0:t.prebidServer)&&this.pocOverrides.prebidServer.siteIds.includes(e)){if(z(this.pocOverrides.prebidServer.ratio)){O("Run ABTest hybrid monetization PBJS + PBS");const e=z(void 0!==(null===(i=this.stackLoadedConfig.prebidConfig.pbjsConfig)||void 0===i?void 0:i.priceGranularity)&&this.pocOverrides.prebidServer.ratioPriceGranularity?this.pocOverrides.prebidServer.ratioPriceGranularity:0);this.stackLoadedConfig.prebidConfig.pbjsConfig={...this.stackLoadedConfig.prebidConfig.pbjsConfig,s2sConfig:{...this.pocOverrides.prebidServer.s2sConfig}};let t=null!==(n=this.pocOverrides.prebidServer.metaABTestServerSide)&&void 0!==n?n:"rule2";e&&(null===(o=null===(s=this.stackLoadedConfig.prebidConfig.pbjsConfig.s2sConfig)||void 0===s?void 0:s.extPrebid)||void 0===o?void 0:o.targeting)&&(this.stackLoadedConfig.prebidConfig.pbjsConfig.s2sConfig.extPrebid.targeting.priceGranularity=this.stackLoadedConfig.prebidConfig.pbjsConfig.priceGranularity,t=`${t}_with_pg`,O("Run ABTest for PriceGranularity on Prebid Server side")),p(t)}else p(null!==(a=this.pocOverrides.prebidServer.metaABTestClientSide)&&void 0!==a?a:"rule1")}return this}withPbjsAnalytics(e){var t;const i=Zi(null===(t=this.pocOverrides)||void 0===t?void 0:t.pbjsAnalytics,e);if(i){const e=this.stackLoadedConfig.prebidConfig.pbjsConfig.analytics||[];this.stackLoadedConfig.prebidConfig.pbjsConfig.analytics=[...e,...i]}return this}withRoadblockOrder(e){var t;const i=Zi(null===(t=this.pocOverrides)||void 0===t?void 0:t.roadblockOrder,e);return i&&this.stackLoadedConfig.adUnits.forEach((e=>{i[e.adUnitName]&&(e.roadblock=i[e.adUnitName])})),this}withDisableThreadYield(e){var t;const i=window.location.search,n=new URLSearchParams(i);return(Zi(null===(t=this.pocOverrides)||void 0===t?void 0:t.disableThreadYield,e)||n.get("disableThreadYield"))&&this.stackLoadedConfig.gamConfig&&(this.stackLoadedConfig.gamConfig.threadYieldConfig=Pe.DISABLED),this}withDisableGptPreAuction(e){var t;return Zi(null===(t=this.pocOverrides)||void 0===t?void 0:t.disableGptPreAuction,e)&&(ae.getInstance().disableGptPreAuction=!0),this}withDisableSchainForTam(e){var t;return Zi(null===(t=this.pocOverrides)||void 0===t?void 0:t.disableSchainForTam,e)&&this.stackLoadedConfig.tamConfig&&(this.stackLoadedConfig.tamConfig={...this.stackLoadedConfig.tamConfig,disableSchain:!0}),this}withIASConfig(e){const t=Zi(this.pocOverrides.iasConfig,e);return t&&(this.stackLoadedConfig.iasConfig=t,O("[IAS Module] IAS Config override",t)),this}withDisableSingleRequest(e){var t;const i=Zi(null===(t=this.pocOverrides)||void 0===t?void 0:t.disableSingleRequest,e),n=this.stackLoadedConfig.adUnits.some((e=>e.roadblock));return O(`[GAM] ${i} - ${n}`),i&&this.stackLoadedConfig.gamConfig&&!n&&(this.stackLoadedConfig.gamConfig.disableSingleRequest=!0),this}build(){return this.stackLoadedConfig}}function on(e,t,i,n){var s;const{pocOverrides:o,runningABTest:a}=function(e,t){const{overrideABTest:i,...n}=e,s=Zi(i,t);if(!s||!function(e){return"populationB"in e&&"object"==typeof e.populationB&&"ratio"in e&&"number"==typeof e.ratio||(P("ABTest populationB should be an object and ratio a number"),!1)}(s))return{pocOverrides:n,runningABTest:[]};const o=z(s.ratio),a=Object.keys(s.populationB);if(o){return{pocOverrides:Object.assign({...n},{...s.populationB}),runningABTest:[{name:"adm_ab_test",value:"poc:B",gamTargeting:!0},...a.map((e=>({name:e,value:"B"})))]}}return{pocOverrides:n,runningABTest:[{name:"adm_ab_test",value:"poc:A",gamTargeting:!0},...a.map((e=>({name:e,value:"A"})))]}}(null!==(s=t.pocOverrides)&&void 0!==s?s:{},t.tagId),r=new sn(e,o).withConvertToInstreamAdUnit().withConvertToNativeAdUnit().withFirstId().withId5Id().withSkinRenderingSettings(t.tagId,n.stackId).withRefreshAlwaysInView().withrefreshBehaviorOnEmpty().withRefreshOutOfFocus(t.tagId).withXplnConfig(t.tagId).withOutbrainConfig(t.tagId).withFledgeForGpt().withRtbHousePaapi().withSkinFloor(t.tagId).withDsaConfig().withPrebidServerConfig(t.tagId).withPpidSolution(t.tagId).withConvertToInterstitialAdUnit().withPbjsAnalytics(t.tagId).withFloorEnforcement(t.tagId).withDynamicPrebidFloors(t.tagId).withRoadblockOrder(t.tagId).withDisableThreadYield(t.tagId).withDisableGptPreAuction(t.tagId).withDisableSchainForTam(t.tagId).withIASConfig(t.tagId).withDisableSingleRequest(t.tagId).build();return{...r,runningABTest:[...a,...r.runningABTest]}}const an=e=>!!e.priority&&!!e.conditions,rn=e=>!e.priority&&!e.conditions,dn=e=>"elements"in e;const ln={AND:({elements:e},t)=>e.every((e=>un(e,t))),OR:({elements:e},t)=>e.some((e=>un(e,t)))},cn={IN:({key:e,values:t},i)=>t.some((t=>t===i.get(e))),NOT_IN:({key:e,values:t},i)=>!t.some((t=>t===i.get(e)))};function un(e,t){return dn(e)?ln[e.op](e,t):cn[e.op](e,t)}const fn=e=>{if(e.abTest){if(!(e.abTest.length<2)){O("[A/B test] variants",e.abTest.map((e=>e.name)).join(", "));const t=W(e.abTest.map((e=>e.ratio))),i=e.abTest[t-1];return O("[A/B test] winner",i.name),{config:{...e,...i.configToMerge},winner:i.name}}P("The A/B test config is invalid: not enough variants")}return{config:e}},hn={pbjsFinished:!1,apsFinished:!1},gn="[executor] [buffered]";var pn;!function(e){e[e.FirstCall=0]="FirstCall",e[e.Refresh=1]="Refresh"}(pn||(pn={}));class vn{constructor(e,t,i,n){this.buffer=[],this.auctionRunning=!1,this.adUnitAuctionStatus=new Map,this.adServer=e,this.pbjs=t,this.aps=i,this.kleanadsRunCount=n}executeAdCall(e){if(0===e.length)return;setTimeout((()=>{e.forEach((e=>bt(e.divId,"executorTimeout")))}),2e4);const t=e.filter((e=>!this.adUnitAuctionStatus.has(e.divId))).sort(((e,t)=>U(e.divId)-U(t.divId)));this.logAlreadyMonetizedAdUnits(e,t),O(`${gn} buffering adunits`,e),t.forEach((e=>{this.bufferAdUnits({adUnits:[e],origin:pn.FirstCall})}))}executeAdCallRoadblock(e){if(0===e.length)return;setTimeout((()=>{e.forEach((e=>bt(e.divId,"executorTimeout")))}),2e4);const t=e.filter((e=>!this.adUnitAuctionStatus.has(e.divId))).sort(J);this.logAlreadyMonetizedAdUnits(e,t),O(`${gn} buffering adunits`,e),g("executor:roadblock",{slotIds:t.map((e=>e.divId))}),this.bufferAdUnits({adUnits:t,origin:pn.FirstCall})}bufferAdUnits(e){var t;switch(this.buffer.push(e),e.origin){case pn.FirstCall:null===(t=e.adUnits)||void 0===t||t.forEach((e=>{this.adUnitAuctionStatus.set(e.divId,hn)}));break;case pn.Refresh:this.adUnitAuctionStatus.set(e.refreshableAdUnit.adUnit.divId,hn);break;default:P(`${gn} unknown buffer entry origin`)}this.startAuctionForBufferedAdUnits()}executeRefresh(e){this.bufferAdUnits({refreshableAdUnit:e,origin:pn.Refresh})}startAuctionForBufferedAdUnits(){if(this.auctionRunning)return void O(`${gn} auction already running, not starting a new one`);O(`${gn} looking at buffer with ${this.buffer.length} entries`);const e=this.buffer.shift();if(O(`${gn} adunits taken from buffer`,e),e)switch(e.origin){case pn.FirstCall:this.startAuction(e.adUnits);break;case pn.Refresh:this.startAuction([e.refreshableAdUnit.adUnit],{labels:["pubstackRefresh",`pubstackRefreshRank:${e.refreshableAdUnit.rank}`]});break;default:P(`${gn} unknown buffer entry origin`)}else O(`${gn} no more adunit to monetize in buffer`)}startAuction(e,t){this.auctionRunning=!0,e.forEach((e=>{ot(e.divId,Ze.START_AUCTION)})),O(`${gn} starting auctions for ${e.map((e=>e.divId))}`);const i=ae.getInstance().kleanadsRunCount;if(this.pbjs){const n=this.pbjs.getPbjs();this.pbjs.startPbjsAuction(e,(()=>{this.kleanadsRunCount===i?this.pbjsFinished(n,e):O(`${gn} kleanads run count has changed (from ${this.kleanadsRunCount} to ${i}), avoid calling pbjsFinished`)}),t)}this.aps&&this.aps.startApsAuction(e,(t=>{this.kleanadsRunCount===i?this.apsFinished(e,t):O(`${gn} kleanads run count has changed (from ${this.kleanadsRunCount} to ${i}), avoid calling apsFinished`)})),this.pbjs||this.aps||this.adServer.executeWhenAdServerReady((()=>{this.kleanadsRunCount===i?this.callAdServer(e):O(`${gn} kleanads run count has changed (from ${this.kleanadsRunCount} to ${i}), avoid calling AdServer`)}))}isAlreadyMonetized(e){return this.adUnitAuctionStatus.has(e.divId)}logAlreadyMonetizedAdUnits(e,t){if(e.length!==t.length){const t=e.filter((e=>this.adUnitAuctionStatus.has(e.divId)));$(`${gn} cannot make a new ad call, existing one on ${t.map((e=>e.divId)).join(",")}.`)}}pbjsFinished(e,t){O(`${gn} pbjs end callback for ${t.map((e=>e.divId)).join(",")}`,e.getAllPrebidWinningBids()),t.forEach((e=>{ot(e.divId,Ze.END_PBJS_AUCTION),At(e.divId)})),this.adServer.executeWhenAdServerReady((()=>{O(`${gn} pbjs end callback ad server ready ${t.map((e=>e.divId)).join(",")}`),this.adServer.setPbjsTargetings(e,t),t.forEach((e=>{const t=this.adUnitAuctionStatus.get(e.divId);t&&this.adUnitAuctionStatus.set(e.divId,{...t,pbjsFinished:!0})})),this.canCallAdServer(t)&&this.callAdServer(t)}))}apsFinished(e,t){O(`${gn} aps end callback ${e.map((e=>e.divId)).join(",")}`,t),e.forEach((e=>ot(e.divId,Ze.END_APS_AUCTION))),this.adServer.executeWhenAdServerReady((()=>{O(`${gn} aps end callback ad server ready ${e.map((e=>e.divId)).join(",")}`),this.adServer.setApsTargetings(e,t),e.forEach((e=>{const t=this.adUnitAuctionStatus.get(e.divId);t&&this.adUnitAuctionStatus.set(e.divId,{...t,apsFinished:!0})})),this.canCallAdServer(e)&&this.callAdServer(e)}))}canCallAdServer(e){const t=e.filter((e=>{const t=this.adUnitAuctionStatus.get(e.divId);return this.aps&&!this.pbjs?t&&t.apsFinished:this.pbjs&&!this.aps?t&&t.pbjsFinished:this.pbjs&&this.aps?t&&t.apsFinished&&t.pbjsFinished:void 0}));return t.length>0&&t.length!==e.length&&P(`${gn} cannot call ad server for ${e.map((e=>e.divId)).join(",")}, some ad units are not ready`),t.length>0}callAdServer(e){if(this.auctionRunning=!1,this.startAuctionForBufferedAdUnits(),e.forEach((e=>{ot(e.divId,Ze.START_AD_SERVER_CALL)})),e.length>0){this.adServer.callAdServer(e);const t=e.map((e=>e.divId));O(`${gn} ad server called ${t.join(",")}`)}}}class mn{constructor(e,t,i){this.stackConfig=e,this.kleanAdsConfig=t,this.pageContext=i,this.adUnits=[],this.callbacks=[]}alreadyUsedDivIds(){return this.adUnits.map((e=>e.divId))}setConfig(e,t,i){this.stackConfig=e,this.kleanAdsConfig=t,this.pageContext=i,this.adUnits=[],this.callbacks=[]}async executeWhenAdUnitsFound(e){const t=(i=this.stackConfig,n=this.kleanAdsConfig,s=this.pageContext,bn(i.adUnits,i,n,s)).filter((e=>!this.alreadyUsedDivIds().includes(e.divId)));var i,n,s;if(this.adUnits.push(...t),await e(this.adUnits),this.callbacks.push(e),!this.adUnitObserver){const e=async e=>{const t=function(e,t,i,n){return bn([e],t,i,n)}(e,this.stackConfig,this.kleanAdsConfig,this.pageContext).filter((e=>!this.alreadyUsedDivIds().includes(e.divId))).reduce(((e,t)=>(e.find((e=>e.divId===t.divId))?P(`We tried to prepare two times the same divId, skipping adUnit ${t.adServerAdUnitName} from the list`,t):(e.push(t),R("New adUnit dynamicaly loaded",t.divId)),e)),[]);t.length>0&&(this.adUnits.push(...t),this.callbacks.forEach((async e=>{await e(t)})))};this.startAdUnitObserver(e)}}cleanObserverAndAdUnits(){var e;null===(e=this.adUnitObserver)||void 0===e||e.disconnect(),this.adUnitObserver=void 0,this.adUnits=[]}startAdUnitObserver(e){const t=this.alreadyUsedDivIds(),i=this.stackConfig.adUnits.filter((e=>!t.includes(e.divId)||e.dynamic)),n=document.body;if(!n)return void P("Body not found, cannot start observer");const s=new MutationObserver(function(e,t){return(i,n)=>{i.filter((e=>"childList"===e.type&&e.addedNodes.length>0)).forEach((i=>{Array.from(i.addedNodes).filter((e=>e.nodeType===Node.ELEMENT_NODE)).forEach((i=>{e.forEach((e=>{const n=e.divId.startsWith("css:")?e.divId.replace("css:",""):e.dynamic?`[id^="${e.divId}"]`:`[id="${e.divId}"]`;(i.matches(n)||i.querySelectorAll(n).length>0)&&t(e)}))}))}))}}(i,e));s.observe(n,{childList:!0,subtree:!0}),this.adUnitObserver=s}}function bn(e,t,i,n){var s,o;const a=null!==(o=null===(s=null==t?void 0:t.gamConfig)||void 0===s?void 0:s.adUnitPathConfig)&&void 0!==o?o:[];return Oe(e,n,function(e,t){var i,n,s,o,a;const r=null!==(n=null===(i=null==t?void 0:t.gamConfig)||void 0===i?void 0:i.networkId)&&void 0!==n?n:e.networkId,d=(null===(s=null==t?void 0:t.gamConfig)||void 0===s?void 0:s.mcmIds)&&(null===(o=null==t?void 0:t.gamConfig)||void 0===o?void 0:o.mcmIds.length)>0?null===(a=null==t?void 0:t.gamConfig)||void 0===a?void 0:a.mcmIds:e.mcmIds;return r?d?[r,...d].join(","):r:""}(i,t),a,i.pubstackDeclarationTargetingKeys)}let yn=(()=>{let e,t,i=[ki("onStackConfigLoad")],n=[];return t=class{constructor(){this.name="AdUnitsManager"}get adUnitsManager(){return this._adUnitsManager}isLoaded(){return!!this._adUnitsManager}async load({config:e,stackConfig:t}){this._adUnitsManager=new mn(t,e,e.pageContext)}async onStackConfigLoad({config:e,stackConfig:t}){var i;null===(i=this._adUnitsManager)||void 0===i||i.setConfig(t,e,e.pageContext)}async clean(){var e;null===(e=this._adUnitsManager)||void 0===e||e.cleanObserverAndAdUnits()}},_i(t,"AdUnitsManagerModule"),(()=>{const s="function"==typeof Symbol&&Symbol.metadata?Object.create(null):void 0;wi(null,e={value:t},i,{kind:"class",name:t.name,metadata:s},null,n),t=e.value,s&&Object.defineProperty(t,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:s}),Ei(t,n)})(),t})();class An{constructor(e,t){this.element=e,this.dateIn=0,this.pastTimeInView=0,this.isInview=!1,this.alwaysInView=null!=t&&t,this.isTabActivated="visible"===window.document.visibilityState,this.isVisible=!window.document.hidden,this.resetAt=0,this.hasBeenReset=!1}getTimeInView(e){return this.hasBeenReset?e>=this.dateIn&&this.dateIn>0&&(this.isInview||this.alwaysInView)&&this.isTabActivated?this.pastTimeInView+(e-this.dateIn):this.pastTimeInView:0}getTimeOnPage(e){return this.hasBeenReset?e-this.resetAt:0}resetTimer(e){(this.isInview||this.alwaysInView)&&this.isTabActivated&&(this.dateIn=e),this.resetAt=e,this.hasBeenReset=!0,this.pastTimeInView=0}updateTimerOnInViewChange(e,t){this.isInview=e,this.updateTimer(t)}updateTimerOnTabStatusChange(e,t){this.isTabActivated=e,this.updateTimer(t)}updateTimerOnVisibleChange(e,t){this.isVisible=e,this.updateTimer(t)}updateTimer(e){if((this.isInview||this.alwaysInView)&&this.isTabActivated)return 0===this.dateIn?void(this.dateIn=e):this.dateIn>0?void 0:void(this.dateIn=e);this.dateIn>0&&(e>=this.dateIn&&(this.pastTimeInView=this.pastTimeInView+(e-this.dateIn)),this.dateIn=0)}}const Sn="kleanads-refresh";function In(e,...t){u(Sn,e,...t)}function Cn(e,...t){f(Sn,e,...t)}const wn={root:null,rootMargin:"0px",threshold:.5};class En{constructor(e,t){this.elements={},this.observer=new IntersectionObserver((e=>{this.handleIntersect(e,this),Cn("AdUnitsObserver",this)}),wn),this.configAlwaysInView=t,e.forEach((e=>{this.elements[e.id]=new An(e,null==t?void 0:t[e.id]),this.observer.observe(e)})),addEventListener("visibilitychange",(()=>{Cn("visibilitychange",window.document.visibilityState),"visible"===window.document.visibilityState?Object.keys(this.elements).forEach((e=>{this.elements[e].updateTimerOnTabStatusChange(!0,Date.now())})):Object.keys(this.elements).forEach((e=>{this.elements[e].updateTimerOnTabStatusChange(!1,Date.now())}))}))}isObserving(e){return e in this.elements}unobserve(e){this.isObserving(e)&&(this.observer.unobserve(this.elements[e].element),delete this.elements[e])}observe(e){var t;this.isObserving(e.id)||(this.elements[e.id]=new An(e,null===(t=this.configAlwaysInView)||void 0===t?void 0:t[e.id]),this.observer.observe(e))}getObservedDivIds(){return Object.keys(this.elements)}getTimeInView(e,t){return this.isObserving(e)?this.elements[e].getTimeInView(t):0}isInView(e){return!!this.isObserving(e)&&this.elements[e].isInview}getTimeOnPage(e,t){return this.isObserving(e)?this.elements[e].getTimeOnPage(t):0}resetTimers(e,t){e.forEach((e=>{this.isObserving(e)&&(Cn(`reseting time for ${e}`),this.elements[e].resetTimer(t))}))}getAdUnitInViewTimer(e){return this.elements[e]}handleIntersect(e,t){e.forEach((e=>{const i=Date.now();t.elements[e.target.id].updateTimerOnInViewChange(e.isIntersecting,i),Cn("AdUnitsObserver",e.target.id,t.elements[e.target.id])}))}}class _n{constructor(e,t,i){this.adUnitsObserver=new En(e,i),this.exclusions=t,this.lastRenderInfo={},this.refreshRank={},this.hasAuctionInProgress={},this.shouldRefreshBeforeTimerEnd={},this.consecutiveSecondChanceAttempts={},e.forEach((e=>{this.refreshRank[e.id]=0,this.hasAuctionInProgress[e.id]=!1,this.shouldRefreshBeforeTimerEnd[e.id]=!1,this.consecutiveSecondChanceAttempts[e.id]=0}))}unobserve(e){Cn("refresh unobserve",e),this.adUnitsObserver.unobserve(e)}addAdUnits(e){e.forEach((e=>{Cn("refresh addAdUnit",e.id),this.adUnitsObserver.observe(e),this.refreshRank[e.id]=0,this.hasAuctionInProgress[e.id]=!1}))}getTimeInView(e,t){return this.adUnitsObserver.getTimeInView(e,t)}getTimeOnPage(e,t){return this.adUnitsObserver.getTimeOnPage(e,t)}isInView(e){return this.adUnitsObserver.isInView(e)}needRefresh(e,t,i){var n,s;if(!this.adUnitsObserver.isObserving(e))return!1;if(this.cappingReached(e,i.capping))return!1;if(this.hasAuctionInProgress[e])return!1;if(this.shouldRefreshBeforeTimerEnd[e])return this.shouldRefreshBeforeTimerEnd[e]=!1,!0;const o=this.getTimeInView(e,t),a=this.getTimer(e,i.timer,i.refreshSpecificRules);!function(e,t,i,n,s,o){if(l()){const a=document.getElementById(t),r=null==a?void 0:a.parentElement,d="refresh_kleanads";let l=document.getElementById(`${d}_${t}-refresh-debug`);l||(l=document.createElement("div"),l.id=`${d}_${t}-refresh-debug`,l.style.position="absolute",l.style.bottom="5px",l.style.left="5px",l.style.zIndex="99999999",l.style.backdropFilter="blur(6px)",l.style.textShadow="1px 1px 1px rgba(0, 0, 0, 0.3)",l.style.fontFamily="Arial, sans-serif",l.style.borderRadius="5px",l.style.color="white",l.style.padding="8px 16px",l.style.display="flex",l.style.flexDirection="column",l.style.gap="5px",l.style.textAlign="left",l.style.border="1px solid white",l.style.transition="background-color 250ms linear",null==r||r.prepend(l));let c=document.getElementById(`${d}_${t}-refresh-div-id`);c||(c=document.createElement("span"),c.id=`${d}_${t}-refresh-div-id`,l.appendChild(c)),c.textContent=`${t}`,c.style.fontSize="1rem",c.style.fontWeight="bold";let u=document.getElementById(`${d}_${t}-refresh-debug-timer`);u||(u=document.createElement("span"),u.id=`${d}_${t}-refresh-debug-timer`,l.appendChild(u)),u.textContent=`Time in view : ${Math.floor(i/1e3).toString()}`,u.style.fontSize="1rem";let f=document.getElementById(`${d}_${t}-refresh-debug-refresh-rank`);f||(f=document.createElement("span"),f.id=`${d}_${t}-refresh-debug-refresh-rank`,l.appendChild(f));const h=null!=n?n:"∞";f.textContent=`Refresh rank : ${e.getRefreshRank(t).toString()} / ${h}`,f.style.fontSize="1rem",l.style.backgroundColor=s&&o?"rgba(55, 110, 79, 0.7)":"rgba(140, 71, 79, 0.7)"}}(this,e,o,i.capping,null===(n=this.adUnitsObserver.getAdUnitInViewTimer(e))||void 0===n?void 0:n.isTabActivated,null===(s=this.adUnitsObserver.getAdUnitInViewTimer(e))||void 0===s?void 0:s.isInview);const r=i.refreshOutOfFocusConfig,d=i.alwaysInView,c=this.getLastWinningMediaType(e);if(r&&!d&&"video"!==c){const i=this.getTimeOnPage(e,t),n=this.isInView(e),s=1e3*r.timerInView;return r.refreshOutOfView?o>=s&&i>=a:n&&o>=s&&i>=a}return o>=a}cappingReached(e,t){return!!t&&t<this.getRefreshRank(e)}getTimer(e,t,i){if("video"===this.getLastWinningMediaType(e))return 3e4;const n=this.getLastWinningBidder(e),s=this.getLastSize(e),o=[];return i.forEach((e=>{if(!e.timer)return;const t=!!n&&e.bidders.includes(n)&&0===e.sizes.length,i=s&&e.sizes.find((e=>Y(e,s)))&&0===e.bidders.length,a=n&&s&&e.bidders.includes(n)&&e.sizes.find((e=>Y(e,s)));(t||i||a)&&o.push(1e3*e.timer)})),o.length>0?Math.max(...o):1e3*t}getObservedDivIds(){return this.adUnitsObserver.getObservedDivIds()}getRefreshRank(e){const t=this.refreshRank[e];return this.adUnitsObserver.isObserving(e)&&t?t:0}updateAdUnitStatus(e,t){const i=e.divId;if(this.refreshRank[i]+=1,this.lastRenderInfo[i]=e,Cn(`update status ${i} new refresh rank ${this.refreshRank[i]}`),e.isEmpty){if(t.refreshBehaviorOnEmpty===y.Continue)return;if(t.refreshBehaviorOnEmpty===y.InstantSecondChance)return void(this.consecutiveSecondChanceAttempts[t.divId]<1&&(this.consecutiveSecondChanceAttempts[t.divId]++,this.shouldRefreshBeforeTimerEnd[t.divId]=!0));Cn(`${i} is excluded from refresh from now on (empty impression)`),this.unobserve(i)}else this.consecutiveSecondChanceAttempts[t.divId]=0;const n=t.refreshSpecificRules.filter((e=>!e.timer)),s=this.getLastWinningBidder(t.divId),o=this.getLastSize(t.divId);(!!n.find((e=>{const t=!!s&&e.bidders.includes(s),i=!!o&&!!e.sizes.find((e=>Y(e,o))),n=t&&0===e.sizes.length,a=i&&0===e.bidders.length;return n||a||t&&i}))||this.isExcludedByConfig(t.divId)||this.cappingReached(i,t.capping))&&(Cn(`${i} is excluded from refresh from now on`),this.unobserve(i))}getLastSize(e){var t;return(null===(t=this.lastRenderInfo[e])||void 0===t?void 0:t.size)||void 0}getLastAdvertiserId(e){var t;return(null===(t=this.lastRenderInfo[e])||void 0===t?void 0:t.advertiserId)||void 0}getLastWinningBidder(e){var t;return null===(t=this.lastRenderInfo[e])||void 0===t?void 0:t.hb_bidder}getLastWinningMediaType(e){var t;return null===(t=this.lastRenderInfo[e])||void 0===t?void 0:t.hb_mediaType}resetTimer(e,t){this.adUnitsObserver.resetTimers([e],t),this.hasAuctionInProgress[e]=!1}setAuctionInProgress(e){this.hasAuctionInProgress[e]=!0}isExcludedByConfig(e){const t=this.getLastAdvertiserId(e),i=this.getLastWinningLineItemId(e),n=this.getLastWinningOrderId(e),s=!!t&&this.exclusions.advertisers.includes(t),o=!!n&&this.exclusions.orders.includes(n),a=!!i&&this.exclusions.lineItems.includes(i);return s||o||a}getLastWinningLineItemId(e){var t;return(null===(t=this.lastRenderInfo[e])||void 0===t?void 0:t.lineItemId)||void 0}getLastWinningOrderId(e){var t;return(null===(t=this.lastRenderInfo[e])||void 0===t?void 0:t.orderId)||void 0}}async function kn(e,i,n,s,o){const a=[],r=[],d={},l=new _n([],s,d);e.executeWhenAdUnitsFound((async e=>{In("adUnits found for refresh",e),function(e,t){return e.flatMap((e=>{const i=e.adUnitNames.flatMap((e=>t.filter((t=>t.adUnitName.startsWith(e))))),n=e.specificRules.map((e=>e.bidder?{bidders:[e.bidder],sizes:[],timer:e.timer}:e));return i.filter((e=>!!e)).flatMap((t=>({...t,alwaysInView:e.alwaysInView,capping:e.capping,timer:e.timer,refreshSpecificRules:n,refreshBehaviorOnEmpty:e.refreshBehaviorOnEmpty,refreshOutOfFocusConfig:e.refreshOutOfFocusConfig})))}))}(n,e).forEach((e=>{a.push(e),e.alwaysInView&&(d[e.divId]=!0);const t=document.getElementById(e.divId);t?(r.push(t),l.addAdUnits([t])):In("element to refresh not found with id",e.divId)}))})),o.renderListener((e=>function(e,t,i){const n=e.divId,s=t.find((e=>e.divId===n));if(s){const t=e.hb_bidder;i.resetTimer(n,Date.now()),i.updateAdUnitStatus(e,s),t&&Cn(`we have a winning bidder for ${n} that is from prebid: ${t}`),Cn("render on",n)}}(e,a,l)));const c=()=>{const e=[],t=Date.now();l.getObservedDivIds().forEach((i=>{const n=a.find((e=>e.divId===i));n&&l.needRefresh(i,t,n)&&e.push(n)})),e.length>0&&e.forEach((e=>{const t=l.getRefreshRank(e.divId);In(`refresh on ${e.divId} with rank ${t}`);const n={adUnit:e,rank:t};o.setRefreshTargeting(n),i.executeRefresh(n),l.setAuctionInProgress(e.divId)})),l.getObservedDivIds().length>=0?setTimeout((()=>{c()}),100):In("There is no more adUnits observed, stop refreshCycle")};c();window.dispatchEvent(new CustomEvent(t.REFRESH_INIT,{detail:{stopRefresh:e=>{e&&Array.isArray(e)&&(null==e?void 0:e.length)>0?e.forEach((e=>{l.unobserve(e)})):l.getObservedDivIds().forEach((e=>{l.unobserve(e)}))}}}));const u=()=>{window.removeEventListener(t.PAGE_CHANGE,u),In("history mutation event received"),o.removeRenderListener(),r.forEach((e=>{l.resetTimer(e.id,Date.now()),l.unobserve(e.id)})),l.refreshRank={},l.lastRenderInfo={}};window.addEventListener(t.PAGE_CHANGE,u)}async function Tn(e,t){var i,n,s,o,a,r,d;st(Qe.BEGIN_CONFIGURE),await M(e,{beforeStart:!0});const l=window;O(`Configure kleanads.js (version: ${e.kleanadsVersion}, run count: ${ae.getInstance().kleanadsRunCount})`);const c=function(e,t){const i=t.sort(B);for(const t of i)if(e>=t.size)return t.device;return"desktop"}(l.innerWidth,e.screenSizeBreakpoints);!function(e,t,i,n){w=new I(e,t,i,n),E=e,_=t}(e.tagId,e.kleanadsVersion,c,Zi(null===(i=e.pocOverrides)||void 0===i?void 0:i.traceThrottling,e.tagId)),ae.getInstance().setUprState(null===(n=e.pocOverrides)||void 0===n?void 0:n.uprState,null===(s=e.pocOverrides)||void 0===s?void 0:s.uprRatio);const u=function(e,t){const i=Et(t),n=new Map(i.map((({key:e,defaultValue:t})=>[e,t])));e.document.querySelectorAll('meta[name^="pbstck_context:"]').forEach((e=>{var t,s;const o=null===(t=e.attributes.getNamedItem("name"))||void 0===t?void 0:t.value.substring(15).toLowerCase(),a=null===(s=e.attributes.getNamedItem("content"))||void 0===s?void 0:s.value.toLowerCase();if(o&&a){const e=i.find((({key:e})=>e===o));e&&(function(e,t){var i;return t.defaultValue===e||(null!==(i=t.otherValues)&&void 0!==i?i:[]).includes(e)}(a,e)?(n.set(o,a),O(`[context] found context ${o} with content ${a}`)):$(`[context] Unknown ${o} value ${a}`))}}));const s=new URLSearchParams(e.location.search);for(const e of s.keys())e.startsWith("pbstck_context:")&&(O(`[context] Add key ${e} found in URL to context`),n.set(e.slice(15),s.get(e)||""));return n}(l,e.context);0===u.size?O("[context] No context set"):(O("[context] The following context will be used:"),u.forEach(((e,t)=>{O(`[context] ${t} => ${e}`)})));const f=function(e,t){const i=e.filter(an).sort(((e,t)=>e.priority-t.priority)),n=e.filter(rn);0===n.length&&P("[stacks] Could not find default stack"),n.length>1&&P("[stacks] Multiple default stacks found");const s=n[0],o=i.find((e=>un(e.conditions,t))),a=null!=o?o:s;return a?O(`[stacks] served stack: ${a.stackId} ${a===s?"(default stack)":""}`,a):P("[stacks] No stack to serve"),a}(e.stacks,u);if(!f)return void P("No stack found, stopping monetization");const h=$n(f.versions).toString(),g={...e,device:c,stack:f,stackVersion:h,pageContext:u,consentlessMode:null===(o=e.pocOverrides)||void 0===o?void 0:o.consentlessMode,noCmp:b(),spaMode:null===(r=null===(a=e.spaConfig)||void 0===a?void 0:a[e.tagId])||void 0===r?void 0:r.mode,pubstackWindow:l,instreamType:en(e.tagId,null===(d=e.pocOverrides)||void 0===d?void 0:d.instreamConfig)},p=new Ri(g,t);await p.loadInitialModules(),T(h);return{configPromise:On(e,c,f,h,u),kleanAdsConfig:g,moduleService:p}}async function On(e,t,i,n,s){return qe(e,t,i,n).then((t=>{if(t){const{config:s,winner:o}=fn(t),a=e.pocOverrides?on(s,e,0,i):{...s,runningABTest:[]},r=o?[...a.runningABTest,{name:"pbstck_ab_test",value:o,gamTargeting:!0}]:a.runningABTest;return function(e){var t;const i=null!==(t=e.prebidConfig.pbjsConfig.bidderAliases)&&void 0!==t?t:[];return e.adUnits.forEach((e=>{e.bidders=e.bidders.map((e=>Mt(e,i)))})),e}({...a,stackId:i.stackId,version:n,runningABTest:r})}return t}))}async function Rn(e){var t,i,n,s,a,r,d,l;const{configPromise:c,kleanAdsConfig:{device:u,pageContext:f,...h},moduleService:g}=e;O("StartKleanAds"),st(Qe.BEGIN_START),It();const p=h.noCmp||await Ct(window);pt!==gt.UNKNOWN&&L("[metric] cmpResponseAvailable",{cmpResponseAvailable:rt(Xe.CMP_RESPONSE_AVAILABLE),fromBeginCmpResponseAvailable:dt(Xe.BEGIN_INIT,Xe.CMP_RESPONSE_AVAILABLE),consentType:pt}),await g.modulesDispatchEvent("onAfterConsent"),await M(h,{beforeStart:!1});const v=h.stacks.find((e=>e.stackId===function(e){var t,i;return null===(i=null===(t=e.pocOverrides)||void 0===t?void 0:t.consentlessStacks)||void 0===i?void 0:i[e.tagId]}(h)));if(p){const e=await g.modulesDispatchEvent("onAfterConsentAccepted");await Promise.all(e)}else{O("Consent refused");const e=await g.modulesDispatchEvent("onAfterConsentRefused");await Promise.all(e),v&&(O("Consentless stack is the following",v),h.stack=v,h.stackVersion=$n(v.versions).toString(),T(h.stackVersion),O("Consent not given, using override consentless stack: ",v.stackId))}if(p||h.consentlessMode||v){await g.modulesDispatchEvent("onBeforeStackConfigLoad");const e=p?c:On(h,u,h.stack,h.stackVersion);let o=await e;if(o&&(null===(t=h.pocOverrides)||void 0===t?void 0:t.optimizationModule)&&(o=await Di(o),O("[pocOverrides] Optimization module finished")),O("[config] kleanAdsConfig:",h),O("[config] stackLoadedConfig:",o),o){if(h.pocOverrides&&h.pocOverrides.grapeshotTargetings){O("[pocOverrides] Poc Grapeshot enabled");const e=await async function(e){return new Promise((t=>{const i=`${e}${encodeURIComponent(window.location.href)}`,n=document.createElement("script");n.async=!0,n.src=i,n.onload=()=>t(window.gs_channels),setTimeout((()=>t(void 0)),3e3),n.onerror=()=>t(void 0),document.head.append(n)}))}(h.pocOverrides.grapeshotTargetings);ae.getInstance().grapeshotValues=e}await g.modulesDispatchEvent("onStackConfigLoad",{stackConfig:o});const e=null===(i=g.getLoadedModuleInstance($i))||void 0===i?void 0:i.pbjs;e&&(O("[config] Prebid is ready, onAfterPrebidReady is sent"),await g.modulesDispatchEvent("onAfterPrebidReady",{prebid:e}));const t=null===(n=g.getLoadedModuleInstance(Ti))||void 0===n?void 0:n.aps,c=null===(s=g.getLoadedModuleInstance(Ci))||void 0===s?void 0:s.adServer;c&&await g.modulesDispatchEvent("onAfterAdServerReady",{adServer:c});const p=null===(a=g.getLoadedModuleInstance(yn))||void 0===a?void 0:a.adUnitsManager;if(!c)return void P("no adServer found, stopping monetization");if(!p)return void P("no adUnitManager found, stopping monetization");_t(window,h.context,null!==(d=null===(r=o.gamConfig)||void 0===r?void 0:r.adUnitPathConfig)&&void 0!==d?d:[]);const v=ae.getInstance().kleanadsRunCount,m=new vn(c,e,t,v),b=o.adUnits.some((e=>e.isInstream))?new Ot(new he(window,f,u,h.instreamType),e,t,v):void 0,y=async e=>{O("[config] adUnits to monetize:",e),await g.modulesDispatchEvent("onPrepareAdUnits",{toPreparedAdUnits:e}),Ni(e,m,b,o.lazyLoading)};await p.executeWhenAdUnitsFound(y);const S=o.refreshConfig;if(h.globalRefreshConfig&&S){const e=Zi(null===(l=h.pocOverrides)||void 0===l?void 0:l.disableRefreshExclusions,h.tagId),t=h.networkId&&!e?await Un(h.configUrl,h.networkId,h.stack.scopeId):A;kn(p,m,S.adUnitConfig,t,c)}}else P("no input configuration, stopping monetization")}else O("consent not given, no monetization");switch(h.spaMode){case"manual":O("[SPA] manual SPA enabled"),Nn((()=>{O("[SPA] manual page change requested, restarting kleanads.js"),Pn(h,g)}));break;case"auto":O("[SPA] auto SPA enabled"),o(),Ln((()=>{O("[SPA] page change detected, restarting kleanads.js"),Pn(h,g)}))}nt(Xe.MAIN_THREAD_END)}function $n(e){const t=e.sort(((e,t)=>e.ratio-t.ratio));return z(void 0!==t[0].ratio?t[0].ratio:100)?t[0].version:t[1].version}const Pn=async(e,t)=>{st(Qe.SPA_RELOAD);const i=ae.getInstance();i.setKleanadsRunCount(i.kleanadsRunCount+1),O("Unloading Kleanads, run cleanup on all modules");const n=t.getModules();await t.modulesCleanUp(),O("Kleanads unloaded, restarting");const s=await Tn(e,n);s&&Rn(s)},Ln=e=>{const i=new MutationObserver((()=>{s()})),n=e=>{const t=e,n=new URL(t.detail.referrer),s=(o=t.detail.url)?`${o}`.startsWith("http")?new URL(o).pathname:`${o}`:"";var o;n.pathname!==s&&i.observe(document.head,{attributes:!0,childList:!0,subtree:!0})};window.addEventListener(t.HISTORY_MUTATION,n);const s=()=>{window.removeEventListener(t.HISTORY_MUTATION,n),i.disconnect(),window.dispatchEvent(new CustomEvent(t.PAGE_CHANGE)),e()}},Nn=e=>{const n=()=>{s()};window.addEventListener(i.SPA_RELOAD,n);const s=()=>{window.removeEventListener(i.SPA_RELOAD,n),window.dispatchEvent(new CustomEvent(t.PAGE_CHANGE)),e()}},Un=async(e,t,i)=>await fetch(`${e}/refresh-exclusions/${t}/${i}/currentExclusions.json`).then((async e=>e.json().then((e=>e)).catch((e=>{P(`unable to extract line items with no refresh: ${e}`)})))).catch((e=>P(`unable to get line items with no refresh: ${e}`)));let xn=(()=>{let e,t,i=[ki("onAfterConsent")],n=[];return t=class{constructor(){this.name="Collector",this._isLoaded=!1,this._scriptAdded=!1}isLoaded(){return this._isLoaded}async load(){this._isLoaded=!0}async onAfterConsent({config:e}){this._scriptAdded||(setTimeout((()=>{O("Downloading pubstack collector"),j(`https://boot.pbstck.com/v1/tag/${e.tagId}`)}),200),this._scriptAdded=!0)}async clean(){}},_i(t,"CollectorModule"),(()=>{const s="function"==typeof Symbol&&Symbol.metadata?Object.create(null):void 0;wi(null,e={value:t},i,{kind:"class",name:t.name,metadata:s},null,n),t=e.value,s&&Object.defineProperty(t,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:s}),Ei(t,n)})(),t})();const Dn="[parallax]";class jn{constructor(e){this.id=e.divId;const t=document.getElementById(this.id);if(!t)throw new Error(`${Dn} container not found for adUnit ${this.id}`);const i=e.sizes.filter((e=>"fluid"!==e)).reduce(((e,[,t])=>t>e?t:e),0);this.adUnitContainerMaxHeightPx=Math.max(i,600)/2,this.minViewableHeightPx=Math.min(this.adUnitContainerMaxHeightPx+10,310),this.adUnitContainer=t;const n=this.adUnitContainer.attachShadow({mode:"open"});n.innerHTML=`\n      <div id="${jn.PARALLAX_CLIP_ID}"><slot></slot></div>\n    `,this.adUnitContainerShadowRoot=n,this.cacheLatestBidWon(),this.observeMutations(),O(`${Dn} prepareGoodParallax for adUnit ${this.id}`)}getHighestChildRect(e){const t=e.children;if(0===t.length)return;const i=(e=>e.reduce(((e,t)=>{const i=getComputedStyle(e),n=getComputedStyle(t);return parseInt(n.height)>parseInt(i.height)?t:e}),e[0]))(Array.from(t));return i.getBoundingClientRect()}cacheLatestBidWon(){const e=null===window||void 0===window?void 0:window.kleanadsPbjs;if(e)try{e.onEvent("auctionEnd",(e=>{var t;(null===(t=e.adUnitCodes)||void 0===t?void 0:t.includes(this.id))&&(this.latestBidWonInfo=void 0)})),e.onEvent("bidWon",(t=>{if(t.adUnitCode===this.id){const{bidderCode:i,size:n}=t,s=jn.BLOCKED_BIDDERS.some((t=>{var n;return i===t||(null===(n=null==e?void 0:e.aliasRegistry)||void 0===n?void 0:n[i])===t})),o=jn.BLOCKED_SIZES.some((e=>e===n)),a="banner"===(null==t?void 0:t.mediaType);this.latestBidWonInfo={isParallaxable:a&&!o&&!s}}}))}catch(e){$(`${Dn} unable to listen to bidWon event`,e)}else $(`${Dn} pbjs not loaded, unable to listen to bidWon event`)}observeMutations(){this.resizeObserver=new ResizeObserver((e=>{const t=e.some((e=>{var t,i;return Array.from(null!==(i=null===(t=e.target.parentElement)||void 0===t?void 0:t.children)&&void 0!==i?i:[]).some((e=>e.getBoundingClientRect().height>this.adUnitContainerMaxHeightPx))}));(this.latestBidWonInfo?this.latestBidWonInfo.isParallaxable&&t:t)?this.renderParallax():this.cleanUp()})),this.mutationObserver=new MutationObserver((e=>{this.mutationDebounceTimeout&&clearTimeout(this.mutationDebounceTimeout),this.mutationDebounceTimeout=setTimeout((()=>{this.mutationDebounceTimeout=void 0,e.flatMap((e=>Array.from(e.addedNodes))).forEach((e=>{var t;e instanceof HTMLElement&&(null===(t=this.resizeObserver)||void 0===t||t.observe(e))})),e.flatMap((e=>Array.from(e.removedNodes))).forEach((e=>{var t;e instanceof HTMLElement&&(null===(t=this.resizeObserver)||void 0===t||t.unobserve(e))}))}),jn.MUTATION_DEBOUNCE_TIMEOUT_VALUE_MS)})),this.mutationObserver.observe(this.adUnitContainer,{childList:!0})}renderParallax(){var e,t,i;this.adUnitContainer.classList.add(jn.PARALLAX_ADUNIT_CONTAINER_CLASS),null===(e=this.adUnitContainerShadowRoot.getElementById(jn.PARALLAX_CLIP_ID))||void 0===e||e.classList.add(jn.PARALLAX_CLIP_ENABLED_CLASS);const n=this.getHighestChildRect(this.adUnitContainer),s=10+(window.innerHeight-(null!==(t=null==n?void 0:n.height)&&void 0!==t?t:0))/2,o=new CSSStyleSheet;o.insertRule(`#${jn.PARALLAX_CLIP_ID}.${jn.PARALLAX_CLIP_ENABLED_CLASS} { height: ${this.minViewableHeightPx}px; width: ${null!==(i=null==n?void 0:n.width)&&void 0!==i?i:0}px; clip-path: rect(0 auto ${this.minViewableHeightPx}px 0); position: relative; margin: 0 auto; } `),o.insertRule(`#${jn.PARALLAX_CLIP_ID}.${jn.PARALLAX_CLIP_ENABLED_CLASS} ::slotted(*) {\n        position: fixed;\n        top: ${s}px;\n      }`),this.adUnitContainerShadowRoot.adoptedStyleSheets=[o]}cleanUp(){var e;this.adUnitContainer.classList.remove(jn.PARALLAX_ADUNIT_CONTAINER_CLASS),null===(e=this.adUnitContainerShadowRoot.getElementById(jn.PARALLAX_CLIP_ID))||void 0===e||e.classList.remove(jn.PARALLAX_CLIP_ENABLED_CLASS)}}jn.MUTATION_DEBOUNCE_TIMEOUT_VALUE_MS=40,jn.PARALLAX_ADUNIT_CONTAINER_CLASS="adm-parallax",jn.PARALLAX_CLIP_ID="adm-parallax-clip",jn.PARALLAX_CLIP_ENABLED_CLASS="adm-parallax-clip-enabled",jn.BLOCKED_BIDDERS=["invibes","seedtag","kargo"],jn.BLOCKED_SIZES=["1x1"];const Mn=e=>{try{return new jn(e)}catch(t){$(`${Dn} unable to prepareParallax for adUnit ${e.divId}`,t)}};var Bn;class Vn extends HTMLElement{constructor(){super();const e=window.kleanadsPbjs;if(e)try{e.onEvent("bidWon",this.winningBid.bind(this))}catch(e){$("[pbstck-sticky] unable to listen to bidWon event",e)}else $("[pbstck-sticky] pbjs not loaded, unable to listen to bidWon event");this.attachShadow({mode:"open"}),this.mutationObserver=new MutationObserver((e=>{O("[pbstck-sticky] [mutationObs]",e),this.isAddingCreative(e)&&(O("[pbstck-sticky] [mutationObs] add element on nested"),Bn.shouldDisplay=!0),this.updateShadowLayout()})),this.addEventListener("close",(()=>{O('[pbstck-sticky] event "close" caught, closing sticky component'),this.close()}))}winningBid(e){e.adUnitCode===this.id&&(O("[pbstck-sticky] [winningBid]",e),O("[pbstck-sticky] [winningBid]",e.bidderCode,e.adUnitCode),Bn.biddersNotToDisplay.includes(e.bidderCode)&&(Bn.shouldDisplay=!1,this.updateShadowLayout()))}close(){O("[pbstck-sticky] closing sticky component"),this.shadowRoot&&(this.mutationObserver.disconnect(),this.shadowRoot.innerHTML="\n          <style>\n              :host {\n                display: none;\n              }\n          </style>")}isAddingCreative(e){var t,i,n;return(null===(t=e[0])||void 0===t?void 0:t.addedNodes[0])&&(null===(n=null===(i=e[0])||void 0===i?void 0:i.target.parentElement)||void 0===n?void 0:n.id)===this.id}connectedCallback(){this.isConnected&&(O("[pbstck-sticky] no-ad"),this.setAttribute("data-pbstck-component","no-ad"),this.setShadowDom("<div></div>"),this.updateShadowLayout(),this.mutationObserver.observe(this,{subtree:!0,childList:!0}))}disconnectedCallback(){this.mutationObserver.disconnect()}attributeChangedCallback(){this.updateShadowLayout()}getHighestChild(){const e=Array.from(this.children);if(0!==e.length)return Fn(e)}setShadowDom(e){this.shadowRoot&&(Bn.shouldDisplay?this.shadowRoot.innerHTML=`\n          <style> \n              :host {\n                display: block;\n                max-height: ${Bn.maxHeight}px;\n                overflow: hidden;\n                position: fixed;\n                bottom: 0;\n                left: 0;\n                right: 0;\n                margin: 0;\n                padding: 0;\n                z-index: 99999999;\n              }\n              .sticky-button {\n                height: 28px;\n                width: 28px;\n                background: ${Bn.backgroundColor};\n                position: absolute;\n                bottom: 0;\n                right: 0;\n                border-radius: 5px 0 0 0;\n                box-shadow: rgba(0, 0, 0, 0.2) -2px -2px 3px -1px, rgba(0, 0, 0, 0.1) -1px -1px 2px -1px !important;\n              }\n              .sticky-button-container {\n                height: 30px;\n                position: relative;\n              }\n              .sticky-button-text {\n                display: block;\n                height: 22px;\n                width: 22px;\n                padding: 3px;\n              }\n              .sticky-container {\n                background: ${Bn.backgroundColor};\n                padding: 8px 0;\n                box-shadow: rgba(0, 0, 0, 0.2) 0px -1px 5px -1px, rgba(0, 0, 0, 0.1) 0px 1px 2px -1px !important;\n              }\n              .sticky-container slot > * {\n                position: relative;\n              }\n              ::slotted(*) {\n                position: relative;\n              }\n              .cross {\n                display: block;\n              }\n              .sticky-container slot {\n                width: fit-content;\n                width: -moz-fit-content;\n                block-size: fit-content;\n                margin: 0 auto !important;\n                display: block;\n              }\n            }\n          </style>\n          ${e}`:this.shadowRoot.innerHTML="\n          <style>\n              :host {\n                display: block;\n                width: 100%;\n                height: 1px;\n                background: transparent;\n                position: fixed;\n                bottom: 0;\n              }\n          </style><div></div>")}updateShadowLayout(){if(O(`[pbstck-sticky] updating element ${this.id}`),!this.shadowRoot)return;this.setAttribute("data-pbstck-component","sticky");const e=document.createElement("div");e.className="sticky-container";const t=document.createElement("slot");e.append(t),this.setShadowDom(`${e.outerHTML}`);const i=this.getHighestChild();if(i&&Bn.shouldDisplay){i.style.display="block",i.style.margin="0 auto",i.style.bottom="0",i.style.maxHeight=`${Bn.maxCreativeHeight}px`;const e=document.createElement("div");e.className="sticky-button-container";const t=document.createElement("div");t.className="sticky-button";const n=document.createElement("div");n.className="sticky-button-text",n.addEventListener("click",(()=>{O("[pbstck-sticky] Close button pressed, hiding the sticky adunit"),this.close()}));const s=document.createElementNS("http://www.w3.org/2000/svg","path");s.setAttribute("d","M 5.3,18.7 C 5.5,18.9 5.7,19 6,19 6.3,19 6.5,18.9 6.7,18.7 l 5.3,-5.3 5.3,5.3 c 0.2,0.2 0.5,0.3 0.7,0.3 0.2,0 0.5,-0.1 0.7,-0.3 0.4,-0.4 0.4,-1 0,-1.4 L 13.4,12 18.7,6.7 c 0.4,-0.4 0.4,-1 0,-1.4 -0.4,-0.4 -1,-0.4 -1.4,0 L 12,10.6 6.7,5.3 c -0.4,-0.4 -1,-0.4 -1.4,0 -0.4,0.4 -0.4,1 0,1.4 l 5.3,5.3 -5.3,5.3 c -0.4,0.4 -0.4,1 0,1.4 z");const o=document.createElementNS("http://www.w3.org/2000/svg","svg");o.setAttribute("viewBox","0 0 24 24"),o.setAttribute("class","cross"),o.setAttribute("height","22px"),o.setAttribute("width","22px"),o.setAttribute("fill","#333"),o.append(s),n.append(o),t.append(n),e.append(t),this.shadowRoot.prepend(e)}}}Bn=Vn,Vn.backgroundColor="rgb(250, 250, 250)",Vn.maxCreativeHeight=216,Vn.buttonHeight=32,Vn.maxHeight=Bn.maxCreativeHeight+Bn.buttonHeight,Vn.shouldDisplay=!1,Vn.biddersNotToDisplay=["ogury","missena","seedtag","kargo","gumgum","bliink"];const Fn=e=>e.reduce(((e,t)=>t.offsetHeight>e.offsetHeight?t:e),e[0]);function zn(e){if(e.anchor){const t=e.divId,i=document.getElementById(t);if(O("[pbstck-sticky]",e),"pbstck-sticky"===(null==i?void 0:i.localName))return void O(`[pbstck-sticky] div ${t} already prepared`);const n=document.createElement("pbstck-sticky");n.id=t;const s=`adm-sticky-${t}`;if(i)O(`[pbstck-sticky] div ${t} existing`),i.id=s,i.appendChild(n);else{O(`[pbstck-sticky] div ${t} not existing`);const e=document.createElement("div");e.id=s,e.appendChild(n),document.body.appendChild(e)}}}let Wn=(()=>{let e,t,i=[ki("onStackConfigLoad")],n=[];return t=class{constructor(){this.name="ContainersModule",this.loaded=!1,this.firstStickyDefined=!1}isLoaded(){return this.loaded}async load(){if("function"==typeof(null===customElements||void 0===customElements?void 0:customElements.define)&&"function"==typeof MutationObserver)try{customElements.define("pbstck-sticky",Vn)}catch(e){P(`[ContainersModule] unable to define custom elements, error "${e}"`)}else $('[ContainersModule] unable to define custom elements, error: "browser not compatible"');this.loaded=!0}async onPrepareAdUnits({toPreparedAdUnits:e}){for(const t of null!=e?e:[])t.parallax&&Mn(t),t.anchor&&!this.firstStickyDefined&&(zn(t),this.firstStickyDefined=!0)}async clean(){}},_i(t,"ContainersModule"),(()=>{const s="function"==typeof Symbol&&Symbol.metadata?Object.create(null):void 0;wi(null,e={value:t},i,{kind:"class",name:t.name,metadata:s},null,n),t=e.value,s&&Object.defineProperty(t,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:s}),Ei(t,n)})(),t})();const Gn="adm-ad-loading",Hn="adm-ad-empty",Jn="adm-ad-rendered",Kn="adm-ad-skin",Yn="data-adm-skin",qn=["sublime","justpremium","gumgum","dspx"];let Xn=(()=>{let e,t,i=[ki("onStackConfigLoad")],n=[];return t=class{constructor(){this.name="CssClass",this._isLoaded=!1}async load(){this._isLoaded=!0}async onAfterAdServerReady({adServer:e}){e.renderListener(this.applyClassBySlotRenderEndedEvent)}async onAfterPrebidReady({prebid:e}){O("[CssClassModule] onAfterPrebidReady event received"),e.getPbjs().onEvent("bidWon",this.applyClassByBidWon)}async applyClassBySlotRenderEndedEvent(e){var t;const i=e.divId,n=document.getElementById(i);n&&(e.isEmpty?(n.classList.replace(Gn,Hn),O(`[CSS Class] slot empty: ${i}`)):(n.classList.replace(Gn,Jn),n.classList.replace(Hn,Jn),(null===(t=e.size)||void 0===t?void 0:t.length)&&1800===e.size[0]&&1e3===e.size[1]?(n.classList.add(Kn),n.setAttribute(Yn,"gam"),O(`[CSS Class] slot rendered is skin: ${i}`)):(n.classList.remove(Kn),n.removeAttribute(Yn)),O(`[CSS Class] slot rendered: ${i}`)))}applyClassByBidWon(e){const t=document.getElementById(e.adUnitCode);"1800x1000"===e.size&&(null==t||t.classList.add(Kn),null==t||t.setAttribute(Yn,"prebid"),qn.includes(e.bidderCode)||null==t||t.classList.add("adm-ad-skin-resizable"),O(`[CSS Class] bidWon is skin: ${e.adUnitCode}`))}async onPrepareAdUnits({toPreparedAdUnits:e}){e&&e.forEach((e=>{const t=document.getElementById(e.divId);t&&t.classList.add(Gn)}))}isLoaded(){return this._isLoaded}clean(){return this._isLoaded=!1,Promise.resolve(void 0)}},_i(t,"CssClassModule"),(()=>{const s="function"==typeof Symbol&&Symbol.metadata?Object.create(null):void 0;wi(null,e={value:t},i,{kind:"class",name:t.name,metadata:s},null,n),t=e.value,s&&Object.defineProperty(t,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:s}),Ei(t,n)})(),t})();let Qn=(()=>{let e,t,i=[ki("onStackConfigLoad")],n=[];return t=class{constructor(){this.name="XplnModule",this.loaded=!1}async load(){this.loaded=!0}async onStackConfigLoad({config:e,stackConfig:t}){var i,n;if((null===(i=t.xplnConfig)||void 0===i?void 0:i.enabled)&&(null===(n=t.xplnConfig)||void 0===n?void 0:n.publisherId)){const i=t.xplnConfig.publisherId;((e,t)=>{const i=e.document.createElement("script"),n=e.document.createElement("script");i.innerHTML=`(function(x,p,l,n,a,i) {\n          a=p.createElement(l);a.async=!0;a.src=n;a.xpln=x;\n          i=p.currentScript||p.getElementsByTagName(l)[0];i.parentNode.insertBefore(a,i);\n          })({xid:'${t}'},document,'script','https://cdn.xpln.tech/page.js');`,n.innerHTML=`(function(x,p,l,n,a,i) {\n          self.xpln_targeting=function(){};\n          a=x.createElement(p);a.async=!0;\n          a.src=l+'${t}'+'/'+location.hostname+'.js';\n          i=x.currentScript||x.getElementsByTagName(p)[0];i.parentNode.insertBefore(a,i);\n          })(document,'script','https://cdn.xpln.tech/');`,i.type="text/javascript",n.type="text/javascript",i.setAttribute("data-kleanads","true"),n.setAttribute("data-kleanads","true"),e.document.head.appendChild(i),e.document.head.appendChild(n)})(e.pubstackWindow,i)}}async onAfterAdServerReady({config:e,stackConfig:t,adServer:i}){(null==t?void 0:t.xplnConfig)&&(O("XplnModule declare xpln targeting when ready"),i.registerExternalTargetingDeclaration((()=>es(e.pubstackWindow))))}async clean(){this.loaded=!1}isLoaded(){return this.loaded}},_i(t,"XplnModule"),(()=>{const s="function"==typeof Symbol&&Symbol.metadata?Object.create(null):void 0;wi(null,e={value:t},i,{kind:"class",name:t.name,metadata:s},null,n),t=e.value,s&&Object.defineProperty(t,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:s}),Ei(t,n)})(),t})();const Zn=(e,t,i,n)=>t>15?($("Could not declare XPLN targetings, xpln_targeting function is undefined"),void n()):e.xpln_targeting&&e.xpln_targeting.toString().length>100?(e.xpln_targeting(),O(`XPLN targeting called after ${t} retry`),void i()):void setTimeout((()=>Zn(e,t+1,i,n)),300),es=e=>new Promise(((t,i)=>Zn(e,0,t,i))),ts="[IAS Module]";let is=(()=>{let e,t,i=[ki("onAfterAdServerReady")],n=[];return t=class{constructor(){this.name="IasModule",this.loaded=!1}async load(){this.loaded=!0}async onAfterAdServerReady({config:e,stackConfig:t,adServer:i}){var n;const s=null===(n=t.iasConfig)||void 0===n?void 0:n.pubId;s&&i.registerExternalTargetingDeclaration((t=>this.declareIasTargetingsWhenReady(e.pubstackWindow,s,t)))}async clean(){this.loaded=!1}isLoaded(){return this.loaded}declareIasTargetingsWhenReady(e,t,i){return new Promise(((n,s)=>this.tryDeclareIasTargetings(e,0,t,i,n,s)))}async tryDeclareIasTargetings(e,t,i,n,s,o){if(t>15)return $(`${ts} Could not declare IAS targetings because they could not be retrieved`),void o();const a=this.prepareSlots(n),r=await this.getTargetings(i,a,e);if(r){const e=await r.json();return n.forEach((t=>{e.slots[t.getSlotElementId()]&&(t.setTargeting("ias-kw",e.custom["ias-kw"]),Object.keys(e.brandSafety).forEach((i=>{t.setTargeting(i,e.brandSafety[i])})),void 0!==e.fr&&t.setTargeting("fr",e.fr))})),O(`${ts} IAS targeting called after ${t} retry`),void s()}setTimeout((()=>this.tryDeclareIasTargetings(e,t+1,i,n,s,o)),300)}async getTargetings(e,t,i){let n=`https://pixel.adsafeprotected.com/services/pub?anId=${e}`;t.forEach((e=>{n=n.concat(`&slot=${e}`)})),n=n.concat(`&wr=${this.viewports(i)}&sr=${this.browserSize(i)}&sessionId=${xt()}&url=${encodeURIComponent(i.location.href)}`),O(`${ts} URL:`,n);try{return await fetch(n.toString())}catch(e){$(`${ts} Error while fetching IAS targetings`,e)}}prepareSlots(e){const t=[];return e.length>0&&e.forEach((e=>{t.push(this.slotsToString(e))})),t}slotsToString(e){return`%7Bid:${e.getSlotElementId()},ss:[${e.getSizes().filter((e=>"fluid"!==e)).map((e=>`${e.width}.${e.height}`)).join(",")}],p:${e.getAdUnitPath()},t:display%7D`}viewports(e){return`${e.innerWidth}.${e.innerHeight}`}browserSize(e){return`${e.screen.width}.${e.screen.height}`}},_i(t,"IasModule"),(()=>{const s="function"==typeof Symbol&&Symbol.metadata?Object.create(null):void 0;wi(null,e={value:t},i,{kind:"class",name:t.name,metadata:s},null,n),t=e.value,s&&Object.defineProperty(t,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:s}),Ei(t,n)})(),t})(),ns=(()=>{let e,i,n=[ki("onStackConfigLoad")],s=[];return i=class{constructor(){this.name="PublicAccessModule",this._isLoaded=!1}isLoaded(){return this._isLoaded}async load({config:e,stackConfig:i}){e.pubstackWindow._pbstckKleanAds.getBootstrapConfig=()=>{const{pubstackWindow:t,...i}=e;return i},e.pubstackWindow._pbstckKleanAds.getStackConfig=()=>i,e.pubstackWindow._pbstckKleanAds.apiReady=!0,window.addEventListener(t.REFRESH_INIT,(t=>{e.pubstackWindow._pbstckKleanAds.stopRefresh=e=>{var i,n;null===(n=null===(i=null==t?void 0:t.detail)||void 0===i?void 0:i.stopRefresh)||void 0===n||n.call(i,e)},e.pubstackWindow._pbstckKleanAds.refreshApiReady=!0})),this._isLoaded=!0}async clean({config:e}){e.pubstackWindow._pbstckKleanAds.apiReady=!1,e.pubstackWindow._pbstckKleanAds.getBootstrapConfig=()=>{throw new Error("Not ready yet, wait for apiLoaded.")},e.pubstackWindow._pbstckKleanAds.getStackConfig=()=>{throw new Error("Not ready yet, wait for apiLoaded.")}}},_i(i,"PublicAccessModule"),(()=>{const t="function"==typeof Symbol&&Symbol.metadata?Object.create(null):void 0;wi(null,e={value:i},n,{kind:"class",name:i.name,metadata:t},null,s),i=e.value,t&&Object.defineProperty(i,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:t}),Ei(i,s)})(),i})();let ss=(()=>{let e,t,i=[ki("onStackConfigLoad")],n=[];var s=t=class{constructor(){this.name="SkinRendering",this._isLoaded=!1,this.eligibleForSkinRendering=!1}isLoaded(){return this._isLoaded}async load({config:e,stackConfig:t}){var i,n,s,o,a,r,d,l,c,u;if(this.eligibleForSkinRendering=function(e,t){var i,n,s,o,a,r,d,l,c;return!!(null===(o=null===(s=null===(n=null===(i=e.pocOverrides)||void 0===i?void 0:i.skinRenderingSettings)||void 0===n?void 0:n.siteLevel)||void 0===s?void 0:s[e.tagId])||void 0===o?void 0:o.enabledSkinRenderAdaptation)&&!(null===(l=null===(d=null===(r=null===(a=e.pocOverrides)||void 0===a?void 0:a.skinRenderingSettings)||void 0===r?void 0:r.stackLevel)||void 0===d?void 0:d[e.stack.stackId])||void 0===l?void 0:l.disableSkinRenderAdaptation)&&(null===(c=t.adUnits)||void 0===c?void 0:c.some((e=>e.sizes.some((e=>Y(e,[1800,1e3]))))))}(e,t),this.eligibleForSkinRendering){const{maxHeaderHeightPx:t,marginTopPx:f,siteContentWidthPx:h,additionalSkinRenderingCss:g}=null!==(u=null!==(a=null===(o=null===(s=null===(n=null===(i=e.pocOverrides)||void 0===i?void 0:i.skinRenderingSettings)||void 0===n?void 0:n.stackLevel)||void 0===s?void 0:s[e.stack.stackId])||void 0===o?void 0:o.style)&&void 0!==a?a:null===(c=null===(l=null===(d=null===(r=e.pocOverrides)||void 0===r?void 0:r.skinRenderingSettings)||void 0===d?void 0:d.siteLevel)||void 0===l?void 0:l[e.tagId])||void 0===c?void 0:c.style)&&void 0!==u?u:{};this.configuredMaxHeaderHeightPx=t,this.configuredMarginTopPx=f,this.configuredSiteContentWidthPx=h,this.configuredAdditionalSkinRenderingCss=g,this._isLoaded=!0,O("[Skin] Configuration eligible for skin rendering.")}}async onAfterPrebidReady({prebid:e,config:{pubstackWindow:t}}){this.pbjs=e,this.eligibleForSkinRendering&&(this.onBidWonHandler=this.onBidWon.bind(this),this.pbjs.getPbjs().onEvent("bidWon",this.onBidWonHandler),vi((()=>{this.onSlotRenderEndedHandler=this.onSlotRenderEnded.bind(this),t.googletag.pubads().addEventListener("slotRenderEnded",this.onSlotRenderEndedHandler)})))}async clean(){var e;this.onBidWonHandler&&(null===(e=this.pbjs)||void 0===e||e.getPbjs().offEvent("bidWon",this.onBidWonHandler),this.onBidWonHandler=void 0),this.onSlotRenderEndedHandler&&(window.googletag.pubads().removeEventListener("slotRenderEnded",this.onSlotRenderEndedHandler),this.onSlotRenderEndedHandler=void 0),this._isLoaded=!1}onBidWon(e){this.shouldApplyPrebidSkinRendering(e)?this.applySkinCSS(e.adUnitCode,"prebid"):this.removeSkinRendering(e.adUnitCode)}onSlotRenderEnded(e){this.isFromGAM(e)?this.applySkinCSS(e.slot.getSlotElementId(),"gam"):e.size&&!Y(e.size,[3,1])&&this.removeSkinRendering(e.slot.getSlotElementId())}removeSkinRendering(e){const t=document.getElementById(e);t&&t.classList.remove(s.SKIN_RENDERING_CSS_CLASS)}shouldApplyPrebidSkinRendering(e){var t;const i=["sublime","justpremium","gumgum"],n=null===(t=this.pbjs)||void 0===t?void 0:t.getPbjs();if(n){const t=i.some((t=>e.bidderCode===t||n.aliasRegistry[e.bidderCode]===t));return"1800x1000"===e.size&&!t}return function(e,...t){h(Sn,e,...t)}("shouldApplyPrebidSkinRendering: unable to get aliasRegistry: prebid is not defined"),!1}isFromGAM(e){var t;return!!(null===(t=e.size)||void 0===t?void 0:t.length)&&1800===e.size[0]&&1e3===e.size[1]}applySkinCSS(e,t){var i,n,o,a;const r=document.getElementById(e);if(r){if("gam"===t)return;O(`[Skin] applying rendering for ${e} from ${t}`);const d=null!==(i=this.configuredMaxHeaderHeightPx)&&void 0!==i?i:250,l=null!==(n=this.configuredMarginTopPx)&&void 0!==n?n:0,c=null!==(o=this.configuredSiteContentWidthPx)&&void 0!==o?o:1e3,u=null!==(a=this.configuredAdditionalSkinRenderingCss)&&void 0!==a?a:"",f=1e3,h=(1800-c)/2,g=h+c,p=document.createElement("style");p.setAttribute("data-kleanads","true"),p.textContent=`\n        #${e}.${s.SKIN_RENDERING_CSS_CLASS} {\n          /* leave security margin to help display top of creative */\n          height: ${d}px;\n          /* set it properly in page flow */\n          display: block;\n          margin-top: ${l}px;\n        }\n  \n        #${e}.${s.SKIN_RENDERING_CSS_CLASS} > div {\n          /* horizontally center creative */\n          transform: translateX(-50%);\n          position: absolute;\n          left: 50%;\n  \n          /* clipping out the unused part of the creative to leave content visible */\n          clip-path: polygon(0 0, 0% 100%, ${h}px ${f}px, ${h}px ${d}px, ${g}px ${d}px, ${g}px 100%, 100% 100%, 100% 0%);\n        }\n  \n        ${u}\n        `,document.head.appendChild(p),r.classList.add(s.SKIN_RENDERING_CSS_CLASS)}else $(`skin rendering impossible - adUnitDiv not found for ${e}`)}};return _i(t,"SkinRenderingModule"),(()=>{const o="function"==typeof Symbol&&Symbol.metadata?Object.create(null):void 0;wi(null,e={value:t},i,{kind:"class",name:t.name,metadata:o},null,n),s=t=e.value,o&&Object.defineProperty(t,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:o})})(),t.SKIN_RENDERING_CSS_CLASS="pbstck_skin_rendering",Ei(t,n),s=t})();const os=[class{constructor(){this.name="Metas",this._isLoaded=!1,this.customFields=[],this.targetings=[]}async load({config:e}){v("kleanads-version",e.kleanadsVersion),this.customFields.push("kleanads-version"),ae.getInstance().uprTested&&(v("xp_variant",`floor_optimization:${ae.getInstance().uprEnabled}`),this.customFields.push("xp_variant")),this._isLoaded=!0}async onStackConfigLoad({stackConfig:e}){v("config-version",`${e.version}`),v("kleanads-stack-id",e.stackId),this.customFields.push("config-version","kleanads-stack-id"),function(e,t){const i=document.createElement("meta");i.setAttribute("name",`ad:${e}`),i.content=t,document.head.appendChild(i)}("adm_stack",`${e.stackId}_v${e.version}`),this.targetings.push("adm_stack"),e.runningABTest.forEach((e=>{v(e.name,e.value),this.customFields.push(e.name)}))}isLoaded(){return this._isLoaded}async clean(){this.customFields.forEach((e=>{try{!function(e){const t=document.querySelector(`meta[name="pbstck:${e}"]`);t&&t.remove()}(e)}catch(t){$(`Unable to remove CustomField meta tag ${e}`,t)}})),this.customFields=[],this.targetings.forEach((e=>{try{!function(e){const t=document.querySelector(`meta[name="ad:${e}"]`);t&&t.remove()}(e)}catch(t){$(`Unable to remove targeting meta tag ${e}`,t)}})),this.targetings=[],this._isLoaded=!1}},$i,Ti,Wn,Ci,xn,yn,ss,Xn,Qn,ns,is];class as{static getModules(){return os}}async function rs(e){var t,i,n;if(window._kleanadslock)return void O("kleanads.js already started");window._kleanadslock=!0,nt(Xe.BEGIN_INIT);const s=async()=>{const t=await Tn(e,as.getModules().map((e=>new e)));t&&await Rn(t)};if(null===(t=e.pocOverrides)||void 0===t?void 0:t.waitForEventToInit){const t=setTimeout((()=>{P("Wait for init event is too long")}),6e4),o=()=>{var i;window.removeEventListener((null===(i=e.pocOverrides)||void 0===i?void 0:i.waitForEventToInit)||"",o),clearTimeout(t),s()};O(`[INIT] wait for event ${null===(i=e.pocOverrides)||void 0===i?void 0:i.waitForEventToInit} to start kleanads`),window.addEventListener(null===(n=e.pocOverrides)||void 0===n?void 0:n.waitForEventToInit,o)}else await s()}return window._pbstckKleanAds={initKleanAds:rs,apiReady:!1,getBootstrapConfig:()=>{throw new Error("Not ready yet, wait for apiReady.")},getStackConfig:()=>{throw new Error("Not ready yet, wait for apiReady.")},refreshApiReady:!1,stopRefresh:()=>{throw new Error("Not ready yet, wait for refreshApiReady.")}},e.initKleanAds=rs,e}({});