r(e=>ae(r,e,t)),devices:r.devices,pageSelector:f(r.dynamic.pageSelector,``).trim(),elementSelector:f(r.dynamic.elementSelector,``).trim(),position:f(r.dynamic.position,`beforebegin`),max:Math.floor(f(r.dynamic.max,0)),spacing:f(r.dynamic.spacing,0),skip:Math.floor(f(r.dynamic.skip,0)),every:Math.max(Math.floor(f(r.dynamic.every,1)),1),classNames:r.dynamic.classNames||[],sticky:oe(r,n.adOptions.stickyContainerConfig),stickyOverlapSelector:f(r.stickyOverlapSelector,``).trim(),autosize:r.autosize,special:f(r.targeting,[]).filter(e=>e.key===`special`).reduce((e,t)=>e.concat(...t.value),[]),lazy:f(r.dynamic.lazy,!1),lazyMax:f(r.dynamic.lazyMax,o),lazyMaxDefaulted:r.dynamic.lazyMax===0?!1:!r.dynamic.lazyMax,name:r.name}})},w=(t,n)=>{let r=y(n),i=t.sticky&&t.location===e.Sidebar;return t.sizes.filter(e=>{let n=t.autosize?e[0]<=r||e[0]<=320:!0,a=i?e[1]<=window.innerHeight-100:!0;return n&&a})},ce=(e,t)=>e.devices.includes(t),le=e=>e.pageSelector.length===0||document.querySelector(e.pageSelector)!==null,T=new class{info(e,t,...n){this.call(console.info,e,t,...n)}warn(e,t,...n){this.call(console.warn,e,t,...n)}error(e,t,...n){this.call(console.error,e,t,...n),this.sendErrorLogToCommandQueue(e,t,...n)}event(e,t,...n){var r;((r=window.adthriveCLS)==null?void 0:r.bucket)===`debug`&&this.info(e,t)}sendErrorLogToCommandQueue(e,t,...n){window.adthrive=window.adthrive||{},window.adthrive.cmd=window.adthrive.cmd||[],window.adthrive.cmd.push(()=>{window.adthrive.logError!==void 0&&typeof window.adthrive.logError==`function`&&window.adthrive.logError(e,t,n)})}call(e,t,n,...r){let i=[`%c${t}::${n} `],a=[`color: #999; font-weight: bold;`];r.length>0&&typeof r[0]==`string`&&i.push(r.shift()),a.push(...r);try{Function.prototype.apply.call(e,console,[i.join(``),...a])}catch(e){console.error(e);return}}},E={Desktop:`desktop`,Mobile:`mobile`},ue=e=>{let t=document.body,n=`adthrive-device-${e}`;if(!t.classList.contains(n))try{t.classList.add(n)}catch(e){T.error(`BodyDeviceClassComponent`,`init`,{message:e.message});let t=`classList`in document.createElement(`_`);T.error(`BodyDeviceClassComponent`,`init.support`,{support:t})}},D=e=>`adthrive-${e.location.replace(`_`,`-`).toLowerCase()}`,O=e=>`${D(e)}-${e.sequence}`,de=(e,t)=>{let n=window.innerWidth;return n>=t?`desktop`:n>=e?`tablet`:`phone`},fe=e=>{let t=e.offsetHeight,n=e.offsetWidth,r=e.getBoundingClientRect(),i=document.body,a=document.documentElement,o=window.pageYOffset||a.scrollTop||i.scrollTop,s=window.pageXOffset||a.scrollLeft||i.scrollLeft,c=a.clientTop||i.clientTop||0,l=a.clientLeft||i.clientLeft||0,u=Math.round(r.top+o-c),d=Math.round(r.left+s-l);return{top:u,left:d,bottom:u+t,right:d+n,width:n,height:t}},pe=(e=document)=>(e===document?document.body:e).getBoundingClientRect().top,me=e=>e.includes(`,`)?e.split(`,`):[e],he=(e=document)=>{let t=e.querySelectorAll(`article`);if(t.length===0)return null;let n=Array.from(t).reduce((e,t)=>t.offsetHeight>e.offsetHeight?t:e);return n&&n.offsetHeight>window.innerHeight*1.5?n:null},ge=(e,t,n=document)=>{let r=he(n),i=r?[r]:[],a=[];e.forEach(e=>{let r=Array.from(n.querySelectorAll(e.elementSelector)).slice(0,e.skip);me(e.elementSelector).forEach(o=>{let s=n.querySelectorAll(o);for(let n=0;ne.isEqualNode(o)))continue;let c=o&&o.parentElement;c&&c!==document.body?i.push(c):i.push(o),r.indexOf(o)===-1&&a.push({dynamicAd:e,element:o})}})});let o=pe(n),s=a.sort((e,t)=>e.element.getBoundingClientRect().top-o-(t.element.getBoundingClientRect().top-o));return[i,s]},_e=(e,t,n=document)=>{let[r,i]=ge(e,t,n);return r.length===0?[null,i]:[Array.from(r).reduce((e,t)=>t.offsetHeight>e.offsetHeight?t:e)||document.body,i]},ve=(e,t=`div #comments, section .comments`)=>{let n=e.querySelector(t);return n?e.offsetHeight-n.offsetHeight:e.offsetHeight},k=()=>{let e=document.body,t=document.documentElement;return Math.max(e.scrollHeight,e.offsetHeight,t.clientHeight,t.scrollHeight,t.offsetHeight)},A=()=>{let e=document.body,t=document.documentElement;return Math.max(e.scrollWidth,e.offsetWidth,t.clientWidth,t.scrollWidth,t.offsetWidth)};function j(e,t){t===void 0&&(t={});var n=t.insertAt;if(!(!e||typeof document>`u`)){var r=document.head||document.getElementsByTagName(`head`)[0],i=document.createElement(`style`);i.type=`text/css`,n===`top`&&r.firstChild?r.insertBefore(i,r.firstChild):r.appendChild(i),i.styleSheet?i.styleSheet.cssText=e:i.appendChild(document.createTextNode(e))}}var M=j;let N=e=>M(` .adthrive-device-phone .adthrive-sticky-content { height: 450px !important; margin-bottom: 100px !important; } .adthrive-content.adthrive-sticky { position: -webkit-sticky; position: sticky !important; top: 42px !important; margin-top: 42px !important; } .adthrive-content.adthrive-sticky:after { content: "— Advertisement. Scroll down to continue. —"; font-size: 10pt; margin-top: 5px; margin-bottom: 5px; display:block; color: #888; } .adthrive-sticky-container { position: relative; display: flex; flex-direction: column; justify-content: flex-start; align-items: center; min-height:${e||400}px; margin: 10px 0 10px 0; background-color: #FAFAFA; padding-bottom:0px; } `),P=e=>{M(` .adthrive-recipe.adthrive-sticky { position: -webkit-sticky; position: sticky !important; top: 42px !important; margin-top: 42px !important; } .adthrive-recipe-sticky-container { position: relative; display: flex; flex-direction: column; justify-content: flex-start; align-items: center; min-height:${e||400}px !important; margin: 10px 0 10px 0; background-color: #FAFAFA; padding-bottom:0px; } `)},F=e=>e.some(e=>document.querySelector(e)!==null),ye=e=>/^[-_a-zA-Z]+[-_a-zA-Z0-9]*$/.test(e),be=(e,t,n)=>{let r=e=>e?!!(e.classList.contains(`adthrive-ad`)||e.id.includes(`_${n}_`)):!1;switch(t){case`beforebegin`:return r(e.previousElementSibling);case`afterend`:return r(e.nextElementSibling);case`afterbegin`:return r(e.firstElementChild);case`beforeend`:return r(e.lastElementChild);default:return!1}};function I(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function L(e){for(var t=1;t{try{return{valid:!0,elements:document.querySelectorAll(e)}}catch(e){return L({valid:!1},e)}},z=e=>e===``?{valid:!0}:R(e),xe=(e,t)=>Math.random()*(t-e)+e;var B=class e extends b{constructor(e=[],t){super(),this._choices=e,this._default=t}static fromArray(t,n){return new e(t.map(([e,t])=>({choice:e,weight:t})),n)}addChoice(e,t){this._choices.push({choice:e,weight:t})}get(){let e=xe(0,100),t=0;for(let{choice:n,weight:r}of this._choices)if(t+=r,t>=e)return n;return this._default}get totalWeight(){return this._choices.reduce((e,{weight:t})=>e+t,0)}};let V={AdDensity:`addensity`,AdLayout:`adlayout`,FooterCloseButton:`footerclose`,Interstitial:`interstitial`,RemoveVideoTitleWrapper:`removevideotitlewrapper`,StickyOutstream:`stickyoutstream`,StickyOutstreamOnStickyPlayer:`sospp`,VideoAdvancePlaylistRelatedPlayer:`videoadvanceplaylistrp`,MobileStickyPlayerPosition:`mspp`};var Se=class{constructor(){s(this,`name`,void 0),s(this,`disable`,void 0),s(this,`gdprPurposes`,void 0)}};let Ce=[`mcmpfreqrec`],H=new class extends Se{constructor(...e){super(...e),s(this,`name`,`BrowserStorage`),s(this,`disable`,!1),s(this,`gdprPurposes`,[1]),s(this,`_sessionStorageHandlerQueue`,[]),s(this,`_localStorageHandlerQueue`,[]),s(this,`_cookieHandlerQueue`,[]),s(this,`_gdpr`,void 0),s(this,`_shouldQueue`,!1)}init(e){this._gdpr=e.gdpr===`true`,this._shouldQueue=this._gdpr}clearQueue(e){this._gdpr&&this._hasStorageConsent()===!1||(e&&(this._shouldQueue=!1,this._sessionStorageHandlerQueue.forEach(e=>{this.setSessionStorage(e.key,e.value)}),this._localStorageHandlerQueue.forEach(e=>{if(e.key===`adthrive_abgroup`){let t=Object.keys(e.value)[0],n=e.value[t],r=e.value[`${t}_weight`];this.getOrSetABGroupLocalStorageValue(t,n,r,{value:24,unit:`hours`})}else e.expiry?e.type===`internal`?this.setExpirableInternalLocalStorage(e.key,e.value,{expiry:e.expiry,resetOnRead:e.resetOnRead}):this.setExpirableExternalLocalStorage(e.key,e.value,{expiry:e.expiry,resetOnRead:e.resetOnRead}):e.type===`internal`?this.setInternalLocalStorage(e.key,e.value):this.setExternalLocalStorage(e.key,e.value)}),this._cookieHandlerQueue.forEach(e=>{e.type===`internal`?this.setInternalCookie(e.key,e.value):this.setExternalCookie(e.key,e.value)})),this._sessionStorageHandlerQueue=[],this._localStorageHandlerQueue=[],this._cookieHandlerQueue=[])}readInternalCookie(e){return this._verifyInternalKey(e),this._readCookie(e)}readExternalCookie(e){return this._readCookie(e)}readExternalCookieList(e){return this._readCookieList(e)}getAllCookies(){return this._getCookies()}readInternalLocalStorage(e){return this._verifyInternalKey(e),this._readFromLocalStorage(e)}readExternalLocalStorage(e){return this._readFromLocalStorage(e)}readSessionStorage(e){let t=(window.sessionStorage.getItem(e));if(!t)return null;try{return JSON.parse(t)}catch(e){return t}}deleteCookie(e){document.cookie=`${e}=; SameSite=None; Secure; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/`}deleteLocalStorage(e){window.localStorage.removeItem(e)}deleteSessionStorage(e){window.sessionStorage.removeItem(e)}_hasStorageConsent(){if(typeof window.__cmp==`function`)try{let e=(window.__cmp(`getCMPData`));if(!e||!e.purposeConsents)return;let t=e.purposeConsents[1];return t===!0?!0:t===!1||t==null?!1:void 0}catch(e){return}}setInternalCookie(e,t,n){this.disable||(this._verifyInternalKey(e),this._setCookieValue(`internal`,e,t,n))}setExternalCookie(e,t,n){this.disable||this._setCookieValue(`external`,e,t,n)}setInternalLocalStorage(e,t){if(!this.disable)if(this._verifyInternalKey(e),this._gdpr&&this._shouldQueue){let n={key:e,value:t,type:`internal`};this._localStorageHandlerQueue.push(n)}else{let n=typeof t==`string`?t:JSON.stringify(t);window.localStorage.setItem(e,n)}}setExternalLocalStorage(e,t){if(!this.disable)if(this._gdpr&&this._shouldQueue){let n={key:e,value:t,type:`external`};this._localStorageHandlerQueue.push(n)}else{let n=typeof t==`string`?t:JSON.stringify(t);window.localStorage.setItem(e,n)}}setExpirableInternalLocalStorage(e,t,n){if(!this.disable){this._verifyInternalKey(e);try{var r,i;let a=(r=n==null?void 0:n.expiry)==null?{value:400,unit:`days`}:r,o=(i=n==null?void 0:n.resetOnRead)==null?!1:i;if(this._gdpr&&this._shouldQueue){let n={key:e,value:t,type:`internal`,expires:this._getExpiryDate(a),expiry:a,resetOnRead:o};this._localStorageHandlerQueue.push(n)}else{let n={value:t,type:`internal`,expires:this._getExpiryDate(a),expiry:a,resetOnRead:o};window.localStorage.setItem(e,JSON.stringify(n))}}catch(e){console.error(e)}}}setExpirableExternalLocalStorage(e,t,n){if(!this.disable)try{var r,i;let a=(r=n==null?void 0:n.expiry)==null?{value:400,unit:`days`}:r,o=(i=n==null?void 0:n.resetOnRead)==null?!1:i;if(this._gdpr&&this._shouldQueue){let n={key:e,value:JSON.stringify(t),type:`external`,expires:this._getExpiryDate(a),expiry:a,resetOnRead:o};this._localStorageHandlerQueue.push(n)}else{let n={value:t,type:`external`,expires:this._getExpiryDate(a),expiry:a,resetOnRead:o};window.localStorage.setItem(e,JSON.stringify(n))}}catch(e){console.error(e)}}setSessionStorage(e,t){if(!this.disable)if(this._gdpr&&this._shouldQueue){let n={key:e,value:t};this._sessionStorageHandlerQueue.push(n)}else{let n=typeof t==`string`?t:JSON.stringify(t);window.sessionStorage.setItem(e,n)}}getOrSetABGroupLocalStorageValue(e,t,n,r,i=!0){let a=`adthrive_abgroup`,o=(this.readInternalLocalStorage(a));if(o!==null){var s;let t=o[e],n=(s=o[`${e}_weight`])==null?null:s;if(this._isValidABGroupLocalStorageValue(t))return[t,n]}let c=(L(L({},o),{},{[e]:t,[`${e}_weight`]:n}));return r?this.setExpirableInternalLocalStorage(a,c,{expiry:r,resetOnRead:i}):this.setInternalLocalStorage(a,c),[t,n]}_isValidABGroupLocalStorageValue(e){return e!=null&&!(typeof e==`number`&&isNaN(e))}_getExpiryDate({value:e,unit:t}){let n=new Date;return t===`milliseconds`?n.setTime(n.getTime()+e):t==`seconds`?n.setTime(n.getTime()+e*1e3):t===`minutes`?n.setTime(n.getTime()+e*60*1e3):t===`hours`?n.setTime(n.getTime()+e*60*60*1e3):t===`days`?n.setTime(n.getTime()+e*24*60*60*1e3):t===`months`&&n.setTime(n.getTime()+e*30*24*60*60*1e3),n.toUTCString()}_resetExpiry(e){return e.expires=this._getExpiryDate(e.expiry),e}_readCookie(e){let t=(document.cookie.split(`; `).find(t=>t.split(`=`)[0]===e));if(!t)return null;let n=(t.split(`=`))[1];if(n)try{return JSON.parse(decodeURIComponent(n))}catch(e){return decodeURIComponent(n)}return null}_readCookieList(e){let t;for(let n of document.cookie.split(`;`)){let[r,...i]=(n.split(`=`));r.trim()===e&&(t=i.join(`=`).trim())}return t&&JSON.parse(t)||[]}_getCookies(){let e=[];return document.cookie.split(`;`).forEach(t=>{let[n,r]=t.split(`=`).map(e=>e.trim());e.push({name:n,value:r})}),e}_readFromLocalStorage(e){let t=(window.localStorage.getItem(e));if(!t)return null;try{let r=(JSON.parse(t)),i=r.expires&&(new Date().getTime())>=(new Date(r.expires).getTime());if(e===`adthrive_abgroup`&&r.created)return window.localStorage.removeItem(e),null;if(r.resetOnRead&&r.expires&&!i){var n;let t=(this._resetExpiry(r));return window.localStorage.setItem(e,JSON.stringify(r)),(n=t.value)==null?t:n}else if(i)return window.localStorage.removeItem(e),null;if(Object.prototype.hasOwnProperty.call(r,`value`))try{return JSON.parse(r.value)}catch(e){return r.value}else return r}catch(e){return t}}_setCookieValue(e,t,n,r){try{if(this._gdpr&&this._shouldQueue){let r={key:t,value:n,type:e};this._cookieHandlerQueue.push(r)}else{var i,a,o;let e=(this._getExpiryDate((i=r==null?void 0:r.expiry)==null?{value:400,unit:`days`}:i)),s=(a=r==null?void 0:r.sameSite)==null?`None`:a,c=(o=r==null?void 0:r.secure)==null?!0:o,l=typeof n==`object`?JSON.stringify(n):n;document.cookie=`${t}=${l}; SameSite=${s}; ${c?`Secure;`:``} expires=${e}; path=/`}}catch(e){}}_verifyInternalKey(e){let t=(e.startsWith(`adthrive_`)),n=(e.startsWith(`adt_`));if(!t&&!n&&!Ce.includes(e))throw Error(`When reading an internal cookie, the key must start with "adthrive_" or "adt_" or be part of the allowed legacy keys.`)}},we=e=>{let t=5381,n=e.length;for(;n;)t=t*33^e.charCodeAt(--n);return t>>>0},Te=e=>we(e).toString(16),Ee=e=>{if(e===null)return null;let t=e.map(({choice:e})=>e);return Te(JSON.stringify(t))},De=(e,t)=>{var n,r;return(n=(r=e.find(({choice:e})=>e===t))==null?void 0:r.weight)==null?null:n},Oe=e=>e!=null&&!(typeof e==`number`&&isNaN(e)),ke=(e,t)=>{let n=Ee(e._choices),r=e._expConfigABGroup?e._expConfigABGroup:e.abgroup,i=r?r.toLowerCase():e.key?e.key.toLowerCase():``,a=n?`${i}_${n}`:i,o=e.localStoragePrefix?`${e.localStoragePrefix}-${a}`:a,s=`config`in window.adthrive?window.adthrive.config.gdpr.enabled:window.adthrive.gdpr===`true`;if([V.AdLayout,V.AdDensity].includes(i)&&s)return t();let c=H.readInternalLocalStorage(`adthrive_branch`);(c&&c.enabled)===!1&&H.deleteLocalStorage(o);let l=t(),u=De(e._choices,l),[d,f]=H.getOrSetABGroupLocalStorageValue(o,l,u,{value:24,unit:`hours`});return e._stickyResult=d,e._stickyWeight=f,d},U=()=>(e,t,n)=>{let r=n.value;r&&(n.value=function(...e){return ke(this,()=>r.apply(this,e))})},Ae=(e=window.location.search)=>{let t=e.indexOf(`?`)===0?1:0;return e.slice(t).split(`&`).reduce((e,t)=>{let[n,r]=t.split(`=`);return e.set(n,r),e},new Map)},je=e=>{let t={},n=Ae().get(e);if(n)try{let r=decodeURIComponent(n).replace(/\+/g,``);t=JSON.parse(r),T.event(`ExperimentOverridesUtil`,`getExperimentOverrides`,e,t)}catch(e){e instanceof URIError}return t},Me=(e,t)=>typeof e==typeof t,Ne=(e,t)=>{let n=e.adDensityEnabled,r=e.adDensityLayout.pageOverrides.find(e=>!!document.querySelector(e.pageSelector)&&(e[t].onePerViewport||typeof e[t].adDensity==`number`));return n?!r:!0},Pe=e=>{var t;let n=(t=e.videoPlayers)==null||(t=t.partners)==null||(t=t.stickyOutstream)==null?void 0:t.blockedPageSelectors;return n?!document.querySelector(n):!0},Fe=e=>{let t=e.adOptions.interstitialBlockedPageSelectors;return t?!document.querySelector(t):!0},Ie=(e,t,n)=>{switch(t){case V.AdDensity:return Ne(e,n);case V.StickyOutstream:return Pe(e);case V.Interstitial:return Fe(e);default:return!0}},Le=e=>e.length===1,Re=e=>{let t=e.reduce((e,t)=>t.weight?t.weight+e:e,0);return e.length>0&&e.every(e=>{let t=e.value,n=e.weight;return!!(t!=null&&!(typeof t==`number`&&isNaN(t))&&n)})&&t===100},ze=(e,t)=>{if(!e)return!1;let n=!!e.enabled,r=e.dateStart==null||Date.now()>=e.dateStart,i=e.dateEnd==null||Date.now()<=e.dateEnd,a=e.selector===null||e.selector!==``&&!!document.querySelector(e.selector),o=e.platform===`mobile`&&t===`mobile`,s=e.platform===`desktop`&&t===`desktop`,c=e.platform===null||e.platform===`all`||o||s,l=e.experimentType===`bernoulliTrial`?Le(e.variants):Re(e.variants);return l||T.error(`SiteTest`,`validateSiteExperiment`,`experiment presented invalid choices for key:`,e.key,e.variants),n&&r&&i&&a&&c&&l};var W=class{constructor(e){var t,n;s(this,`siteExperiments`,[]),s(this,`_clsOptions`,void 0),s(this,`_device`,void 0),this._clsOptions=e,this._device=u()?`mobile`:`desktop`,this.siteExperiments=(t=(n=this._clsOptions.siteAds.siteExperiments)==null?void 0:n.filter(e=>{let t=e.key,n=ze(e,this._device),r=Ie(this._clsOptions.siteAds,t,this._device);return n&&r}))==null?[]:t}getSiteExperimentByKey(e){let t=this.siteExperiments.filter(t=>t.key.toLowerCase()===e.toLowerCase())[0],n=je(`at_site_features`),r=Me(t!=null&&t.variants[1]?t==null?void 0:t.variants[1].value:t==null?void 0:t.variants[0].value,n[e]);return t&&n[e]&&r&&(t.variants=[{displayName:`test`,value:n[e],weight:100,id:0}]),t}},Be=class{constructor(){s(this,`experimentConfig`,void 0)}get enabled(){return this.experimentConfig!==void 0}_isValidResult(e,t=()=>!0){return t()&&Oe(e)}},G=class extends Be{constructor(...e){super(...e),s(this,`_resultValidator`,()=>!0)}_isValidResult(e){return super._isValidResult(e,()=>this._resultValidator(e)||e===`control`)}run(){if(!this.enabled)return T.error(`CLSWeightedChoiceSiteExperiment`,`run`,`() => %o`,`No experiment config found. Defaulting to control.`),`control`;if(!this._mappedChoices||this._mappedChoices.length===0)return T.error(`CLSWeightedChoiceSiteExperiment`,`run`,`() => %o`,`No experiment variants found. Defaulting to control.`),`control`;let e=new B(this._mappedChoices).get();return this._isValidResult(e)?e:(T.error(`CLSWeightedChoiceSiteExperiment`,`run`,`() => %o`,`Invalid result from experiment choices. Defaulting to control.`),`control`)}};function K(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var q=class extends G{constructor(e){super(),s(this,`_choices`,[]),s(this,`_mappedChoices`,[]),s(this,`_result`,``),s(this,`_clsSiteExperiments`,void 0),s(this,`_resultValidator`,e=>typeof e==`string`),s(this,`key`,V.AdLayout),s(this,`abgroup`,V.AdLayout),this._clsSiteExperiments=new W(e),this.experimentConfig=this._clsSiteExperiments.getSiteExperimentByKey(this.key),this.enabled&&this.experimentConfig&&(this._choices=this.experimentConfig.variants,this._mappedChoices=this._mapChoices(),this._result=this.run(),e.setWeightedChoiceExperiment(this.abgroup,this._result,!0))}get result(){return this._result}run(){if(!this.enabled)return T.error(`CLSAdLayoutSiteExperiment`,`run`,`() => %o`,`No experiment config found. Defaulting to empty class name.`),``;let e=new B(this._mappedChoices).get();return this._isValidResult(e)?e:(T.error(`CLSAdLayoutSiteExperiment`,`run`,`() => %o`,`Invalid result from experiment choices. Defaulting to empty class name.`),``)}_mapChoices(){return this._choices.map(({weight:e,value:t})=>({weight:e,choice:t}))}};K([U()],q.prototype,`run`,null);var J=class extends G{constructor(e){super(),s(this,`_choices`,[]),s(this,`_mappedChoices`,[]),s(this,`_result`,`control`),s(this,`_clsSiteExperiments`,void 0),s(this,`_resultValidator`,e=>typeof e==`number`),s(this,`key`,V.AdDensity),s(this,`abgroup`,V.AdDensity),this._clsSiteExperiments=new W(e),this.experimentConfig=this._clsSiteExperiments.getSiteExperimentByKey(this.key),this.enabled&&this.experimentConfig&&(this._choices=this.experimentConfig.variants,this._mappedChoices=this._mapChoices(),this._result=this.run(),e.setWeightedChoiceExperiment(this.abgroup,this._result,!0))}get result(){return this._result}run(){if(!this.enabled)return T.error(`CLSTargetAdDensitySiteExperiment`,`run`,`() => %o`,`No experiment config found. Defaulting to control.`),`control`;let e=new B(this._mappedChoices).get();return this._isValidResult(e)?e:(T.error(`CLSTargetAdDensitySiteExperiment`,`run`,`() => %o`,`Invalid result from experiment choices. Defaulting to control.`),`control`)}_mapChoices(){return this._choices.map(({weight:e,value:t})=>({weight:e,choice:typeof t==`number`?(t||0)/100:`control`}))}};K([U()],J.prototype,`run`,null);let Y=`250px`;var Ve=class{constructor(t,n){this._clsOptions=t,this._adInjectionMap=n,s(this,`_recipeCount`,0),s(this,`_mainContentHeight`,0),s(this,`_mainContentDiv`,null),s(this,`_totalAvailableElements`,[]),s(this,`_minDivHeight`,250),s(this,`_densityDevice`,E.Desktop),s(this,`_pubLog`,{onePerViewport:!1,targetDensity:0,targetDensityUnits:0,combinedMax:0}),s(this,`_densityMax`,.99),s(this,`_smallerIncrementAttempts`,0),s(this,`_absoluteMinimumSpacingByDevice`,250),s(this,`_usedAbsoluteMinimum`,!1),s(this,`_infPageEndOffset`,0),s(this,`locationMaxLazySequence`,new Map([[e.Recipe,5]])),s(this,`locationToMinHeight`,{Below_Post:Y,Content:Y,Recipe:Y,Sidebar:Y}),s(this,`_device`,void 0),s(this,`_clsTargetAdDensitySiteExperiment`,void 0);let{tablet:r,desktop:i}=this._clsOptions.siteAds.breakpoints;this._device=de(r,i),this._clsTargetAdDensitySiteExperiment=this._clsOptions.siteAds.siteExperiments?new J(this._clsOptions):null}start(){try{var e;ue(this._device);let n=new q(this._clsOptions);if(n.enabled){let e=n.result,t=e.startsWith(`.`)?e.substring(1):e;if(ye(t))try{document.body.classList.add(t)}catch(e){T.error(`ClsDynamicAdsInjector`,`start`,`Uncaught CSS Class error: ${e}`)}else T.error(`ClsDynamicAdsInjector`,`start`,`Invalid class name: ${t}`)}let r=se(this._device,this._clsOptions.siteAds).filter(e=>this._locationEnabled(e)).filter(e=>ce(e,this._device)).filter(e=>le(e)),i=this.inject(r),a=this._clsOptions.siteAds.adOptions.stickyContainerConfig;if(!(a==null||(e=a.content)==null)&&e.enabled&&!F(a.blockedSelectors||[])){var t;N(a==null||(t=a.content)==null?void 0:t.minHeight)}i.forEach(e=>this._clsOptions.setInjectedSlots(e))}catch(e){T.error(`ClsDynamicAdsInjector`,`start`,e)}}inject(t,n=document){this._densityDevice=this._device===`desktop`?E.Desktop:E.Mobile,this._overrideDefaultAdDensitySettingsWithSiteExperiment();let r=this._clsOptions.siteAds,i=f(r.adDensityEnabled,!0),a=r.adDensityLayout&&i,o=t.filter(t=>a?t.location!==e.Content:t),s=t.filter(t=>a?t.location===e.Content:null);return this._capturePreSlotInsertionPageAreaMeasurement(),[...o.length?this._injectNonDensitySlots(o,n):[],...s.length?this._injectDensitySlots(s,n):[]]}_injectNonDensitySlots(t,n=document){var r;let i=[],a=[],o=!1;if(t.some(t=>t.location===e.Recipe&&t.sticky)&&!F(((r=this._clsOptions.siteAds.adOptions.stickyContainerConfig)==null?void 0:r.blockedSelectors)||[])){var s,c;let e=this._clsOptions.siteAds.adOptions.stickyContainerConfig,t=this._device===`phone`?e==null||(s=e.recipeMobile)==null?void 0:s.minHeight:e==null||(c=e.recipeDesktop)==null?void 0:c.minHeight;P(t),o=!0}for(let e of t)this._insertNonDensityAds(e,i,a,n);return o||a.forEach(({location:e,element:t})=>{t.style.minHeight=this.locationToMinHeight[e]}),i}_injectDensitySlots(e,t=document){try{this._calculateMainContentHeightAndAllElements(e,t),this._capturePreSlotInsertionMainContentMeasurement()}catch(e){return[]}let{onePerViewport:n,targetAll:r,targetDensityUnits:i,combinedMax:a,numberOfUnits:o}=this._getDensitySettings(e,t);return this._absoluteMinimumSpacingByDevice=n?window.innerHeight:this._absoluteMinimumSpacingByDevice,o?(this._adInjectionMap.filterUsed(),this._findElementsForAds(o,n,r,a,i,t),this._insertAds()):[]}_overrideDefaultAdDensitySettingsWithSiteExperiment(){var e;if((e=this._clsTargetAdDensitySiteExperiment)!=null&&e.enabled){let e=this._clsTargetAdDensitySiteExperiment.result;typeof e==`number`&&(this._clsOptions.siteAds.adDensityEnabled=!0,this._clsOptions.siteAds.adDensityLayout[this._densityDevice].adDensity=e)}}_getDensitySettings(e,t=document){let n=this._clsOptions.siteAds.adDensityLayout,r=this._determineOverrides(n.pageOverrides),i=r.length?r[0]:n[this._densityDevice],a=i.adDensity,o=i.onePerViewport,s=this._shouldTargetAllEligible(a),c=this._getTargetDensityUnits(a,s),l=this._getCombinedMax(e,t),u=Math.min(this._totalAvailableElements.length,c,...l>0?[l]:[]);return this._pubLog={onePerViewport:o,targetDensity:a,targetDensityUnits:c,combinedMax:l},{onePerViewport:o,targetAll:s,targetDensityUnits:c,combinedMax:l,numberOfUnits:u}}_determineOverrides(e){return e.filter(e=>{let t=z(e.pageSelector);return e.pageSelector===``||t.elements&&t.elements.length}).map(e=>e[this._densityDevice])}_shouldTargetAllEligible(e){return e===this._densityMax}_getTargetDensityUnits(e,t){return t?this._totalAvailableElements.length:Math.floor(e*this._mainContentHeight/(1-e)/this._minDivHeight)-this._recipeCount}_getCombinedMax(e,t=document){return f(e.filter(e=>{let n;try{n=t.querySelector(e.elementSelector)}catch(e){}return n}).map(e=>Number(e.max)+Number(e.lazyMaxDefaulted?0:e.lazyMax)).sort((e,t)=>t-e)[0],0)}_elementLargerThanMainContent(e){return e.offsetHeight>=this._mainContentHeight&&this._totalAvailableElements.length>1}_elementDisplayNone(e){let t=window.getComputedStyle(e,null).display;return t&&t===`none`||e.style.display===`none`}_isBelowMaxes(e,t){return this._adInjectionMap.map.length{for(let{dynamicAd:t,element:o}of this._totalAvailableElements){if(this._logDensityInfo(o,t.elementSelector,e),!n&&this._elementLargerThanMainContent(o)||this._elementDisplayNone(o))continue;if(this._isBelowMaxes(r,i))this._checkElementSpacing({dynamicAd:t,element:o,insertEvery:e,targetAll:n,target:a});else break}!this._usedAbsoluteMinimum&&this._smallerIncrementAttempts<5&&(++this._smallerIncrementAttempts,o(this._getSmallerIncrement(e)))},s=this._getInsertEvery(e,t,i);o(s)}_getSmallerIncrement(e){let t=e*.6;return t<=this._absoluteMinimumSpacingByDevice&&(t=this._absoluteMinimumSpacingByDevice,this._usedAbsoluteMinimum=!0),t}_insertNonDensityAds(t,n,r,i=document){let a=0,o=0,s=0;t.spacing>0&&(a=window.innerHeight*t.spacing,o=a);let c=this._repeatDynamicAds(t),l=this.getElements(t.elementSelector,i);t.skip;for(let u=t.skip;uc.length);u+=t.every){let d=l[u];if(a>0){let{bottom:e}=fe(d);if(e<=o)continue;o=e+a}let f=c[s],p=`${f.location}_${f.sequence}`;n.some(e=>e.name===p)&&(s+=1);let m=this.getDynamicElementId(f),h=D(t),g=O(t),_=t.location===e.Sidebar&&t.sticky&&t.sequence&&t.sequence<=5?`adthrive-sticky-sidebar`:``,v=t.location===e.Recipe&&t.sticky?`adthrive-recipe-sticky-container`:``,y=[_,v,h,g,...t.classNames];if(be(d,t.position,t.location)&&t.location===e.Recipe)continue;let b=this.addAd(d,m,t.position,y);if(b){let a=w(f,b);if(a.length){let o={clsDynamicAd:t,dynamicAd:f,element:b,sizes:a,name:p,infinite:i!==document};n.push(o),r.push({location:f.location,element:b}),t.location===e.Recipe&&++this._recipeCount,s+=1}d=b}}}_insertAds(){let e=[],t=0;return this._adInjectionMap.filterUsed(),this._adInjectionMap.map.forEach(({el:n,dynamicAd:r,target:i},a)=>{let o=Number(r.sequence)+a,s=r.max,c=r.lazy&&o>s;r.sequence=o,r.lazy=c;let l=this._addContentAd(n,r,i);l&&(r.used=!0,e.push(l),++t)}),e}_getInsertEvery(e,t,n){let r=this._absoluteMinimumSpacingByDevice;return this._moreAvailableElementsThanUnitsToInject(n,e)?(this._usedAbsoluteMinimum=!1,r=this._useWiderSpacing(n,e)):(this._usedAbsoluteMinimum=!0,r=this._useSmallestSpacing(t)),t&&window.innerHeight>r?window.innerHeight:r}_useWiderSpacing(e,t){return this._mainContentHeight/Math.min(e,t)}_useSmallestSpacing(e){return e&&window.innerHeight>this._absoluteMinimumSpacingByDevice?window.innerHeight:this._absoluteMinimumSpacingByDevice}_moreAvailableElementsThanUnitsToInject(e,t){return this._totalAvailableElements.length>e||this._totalAvailableElements.length>t}_logDensityInfo(e,t,n){let{onePerViewport:r,targetDensity:i,targetDensityUnits:a,combinedMax:o}=this._pubLog;this._totalAvailableElements.length}_checkElementSpacing({dynamicAd:e,element:t,insertEvery:n,targetAll:r,target:i=document}){(this._isFirstAdInjected()||this._hasProperSpacing(t,e,r,n))&&this._markSpotForContentAd(t,L({},e),i)}_isFirstAdInjected(){return!this._adInjectionMap.map.length}_markSpotForContentAd(e,t,n=document){let r=t.position===`beforebegin`||t.position===`afterbegin`;this._adInjectionMap.addSorted(e,this._getElementCoords(e,r),t,n)}_hasProperSpacing(t,n,r,i){let a=n.position===`beforebegin`||n.position===`afterbegin`,o=n.position===`beforeend`||n.position===`afterbegin`,s=r||this._isElementFarEnoughFromOtherAdElements(t,i,a),c=o||this._isElementNotInRow(t,a),l=t.id.indexOf(`AdThrive_${e.Below_Post}`)===-1;return s&&c&&l}_isElementFarEnoughFromOtherAdElements(e,t,n){let r=this._getElementCoords(e,n),[i,a]=this._adInjectionMap.findNeighborIndices(r),o=i===null?void 0:this._adInjectionMap.map[i].coords,s=a===null?void 0:this._adInjectionMap.map[a].coords;return(o===void 0||r-t>o)&&(s===void 0||r+t`;e.insertAdjacentHTML(n,i)}return document.getElementById(t)}_repeatDynamicAds(t){let n=[],r=t.location===e.Recipe?99:this.locationMaxLazySequence.get(t.location),i=t.lazy?f(r,0):0,a=t.max,o=t.lazyMax,s=i===0&&t.lazy?a+o:Math.min(Math.max(i-t.sequence+1,0),a+o),c=Math.max(a,s);for(let e=0;e=a,o=r;t.name===`Recipe_1`&&r>=5&&(o=r+1),n.push(L(L({},t),{},{sequence:o,lazy:i}))}return n}_locationEnabled(e){let t=this._clsOptions.enabledLocations.includes(e.location),n=this._clsOptions.disableAds&&this._clsOptions.disableAds.all||document.body.classList.contains(`adthrive-disable-all`),r=!document.body.classList.contains(`adthrive-disable-content`)&&!this._clsOptions.disableAds.reasons.has(`content_plugin`);return t&&!n&&r}},He=class{constructor(){s(this,`_map`,[])}add(e,t,n,r=document){this._map.push({el:e,coords:t,dynamicAd:n,target:r})}addSorted(e,t,n,r=document){let i=this._upperBoundIndex(t);this._map.splice(i,0,{el:e,coords:t,dynamicAd:n,target:r})}get map(){return this._map}sort(){this._map.sort(({coords:e},{coords:t})=>e-t)}filterUsed(){this._map=this._map.filter(({dynamicAd:e})=>!e.used)}findNeighborIndices(e){let t=this._upperBoundIndex(e),n=t-1>=0?t-1:null,r=t>>1;this._map[r].coords<=e?t=r+1:n=r}return t}reset(){this._map=[]}},Ue=class extends He{};let X=l((e=navigator.userAgent)=>/(Windows NT|Macintosh|X11;[^)]*(Linux|CrOS))/i.test(e)),Z=()=>{let e=u()?`mobile`:`tablet`;return X(h)?`desktop`:e},We=e=>{let t=v(),n=Z(),r=e.siteAdsProfiles,i=null;if(r&&r.length)for(let e of r){let r=e.targeting.device,a=e.targeting.browserEngine,o=r&&r.length&&r.includes(n),s=a&&a.length&&a.includes(t);o&&s&&(i=e)}return i},Ge=e=>{let t=We(e);if(t){let e=t.profileId;document.body.classList.add(`raptive-profile-${e}`)}},Q={Video_Collapse_Autoplay_SoundOff:`Video_Collapse_Autoplay_SoundOff`,Video_Individual_Autoplay_SOff:`Video_Individual_Autoplay_SOff`,Video_Coll_SOff_Smartphone:`Video_Coll_SOff_Smartphone`,Video_In_Post_ClicktoPlay_SoundOn:`Video_In-Post_ClicktoPlay_SoundOn`,Video_Collapse_Autoplay_SoundOff_15s:`Video_Collapse_Autoplay_SoundOff_15s`,Video_Individual_Autoplay_SOff_15s:`Video_Individual_Autoplay_SOff_15s`,Video_Coll_SOff_Smartphone_15s:`Video_Coll_SOff_Smartphone_15s`,Video_In_Post_ClicktoPlay_SoundOn_15s:`Video_In-Post_ClicktoPlay_SoundOn_15s`};var Ke=class{get enabled(){return!0}};function qe(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.includes(r))continue;n[r]=e[r]}return n}function $(e,t){if(e==null)return{};var n,r,i=qe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;re.type===`stationaryRelated`&&e.enabled),this._potentialPlayerMap=t,this._potentialPlayerMap}_filterPlayerMap(){let e=this._videoConfig.players,t={stickyRelated:[],stickyPlaylist:[],stationaryRelated:[]};return e&&e.length?e.filter(e=>{var t;return(t=e.devices)==null?void 0:t.includes(this._device)}).reduce((e,t)=>(e[t.type]||(T.event(this._component,`constructor`,`Unknown Video Player Type detected`,t.type),e[t.type]=[]),t.enabled&&e[t.type].push(t),e),t):t}_checkPlayerSelectorOnPage(e){for(let t of this._potentialPlayerMap[e]){let e=this._getPlacementElement(t);if(e)return{player:t,playerElement:e}}return{player:null,playerElement:null}}_getOverrideElement(e,t,n){if(e&&t){let r=document.createElement(`div`);t.insertAdjacentElement(e.position,r),n=r}else{let{player:e,playerElement:t}=this._checkPlayerSelectorOnPage(`stickyPlaylist`);if(e&&t){let r=document.createElement(`div`);t.insertAdjacentElement(e.position,r),n=r}}return n}_shouldOverrideElement(e){let t=e.getAttribute(`override-embed`);return t===`true`||t===`false`?t===`true`:this._videoConfig.relatedSettings?this._videoConfig.relatedSettings.overrideEmbedLocation:!1}_checkPageSelector(e,t,n=[]){return e&&t&&n.length===0?(window.location.pathname!==`/`&&T.event(`VideoUtils`,`getPlacementElement`,Error(`PSNF: ${e} does not exist on the page`)),!1):!0}_getElementSelector(e,t,n){return t&&t.length>n?t[n]:(T.event(`VideoUtils`,`getPlacementElement`,Error(`ESNF: ${e} does not exist on the page`)),null)}_getPlacementElement(e){let{pageSelector:t,elementSelector:n,skip:r}=e,i=z(t),{valid:a,elements:o}=i,s=$(i,Je),c=R(n),{valid:l,elements:u}=c,d=$(c,Ye);return t!==``&&!a?(T.error(`VideoUtils`,`getPlacementElement`,Error(`${t} is not a valid selector`),s),null):l?this._checkPageSelector(t,a,o)&&this._getElementSelector(n,u,r)||null:(T.error(`VideoUtils`,`getPlacementElement`,Error(`${n} is not a valid selector`),d),null)}_getEmbeddedPlayerType(e){let t=e.getAttribute(`data-player-type`);return(!t||t===`default`)&&(t=this._videoConfig.relatedSettings?this._videoConfig.relatedSettings.defaultPlayerType:`static`),this._stickyRelatedOnPage&&(t=`static`),t}_getMediaId(e){let t=e.getAttribute(`data-video-id`);return t?(this._relatedMediaIds.push(t),t):!1}_createRelatedPlayer(e,t,n,r){t===`collapse`?this._createCollapsePlayer(e,n):t===`static`&&this._createStaticPlayer(e,n,r)}_createCollapsePlayer(e,t){let{player:n,playerElement:r}=this._checkPlayerSelectorOnPage(`stickyRelated`),i=n||this._potentialPlayerMap.stationaryRelated[0];i&&i.playerId?(this._shouldOverrideElement(t)&&(t=this._getOverrideElement(n,r,t)),t=document.querySelector(`#cls-video-container-${e} > div`)||t,this._createStickyRelatedPlayer(L(L({},i),{},{mediaId:e}),t)):T.error(this._component,`_createCollapsePlayer`,`No video player found`)}_createStaticPlayer(e,t,n){if(this._potentialPlayerMap.stationaryRelated.length&&this._potentialPlayerMap.stationaryRelated[0].playerId){let r=this._potentialPlayerMap.stationaryRelated[0];this._createStationaryRelatedPlayer(L(L({},r),{},{mediaOrPlaylistId:e}),t,n)}else T.error(this._component,`_createStaticPlayer`,`No video player found`)}_shouldRunAutoplayPlayers(){return!!(this._isVideoAllowedOnPage()&&(this._potentialPlayerMap.stickyRelated.length||this._potentialPlayerMap.stickyPlaylist.length))}_setPlaylistMediaIdWhenStationaryOnPage(e,t){if(this._potentialPlayerMap.stationaryRelated.length&&this._potentialPlayerMap.stationaryRelated[0].playerId&&e&&e.length){let n=e[0].getAttribute(`data-video-id`);return n?L(L({},t),{},{mediaId:n}):t}return t}_determineAutoplayPlayers(e){let t=this._component,n=t===`VideoManagerComponent`,r=this._context;if(this._stickyRelatedOnPage){T.event(t,`stickyRelatedOnPage`,n&&{device:r&&r.device,isDesktop:this._device}||{});return}let{playerElement:i}=this._checkPlayerSelectorOnPage(`stickyPlaylist`),{player:a}=this._checkPlayerSelectorOnPage(`stickyPlaylist`);a&&a.playerId&&i?(a=this._setPlaylistMediaIdWhenStationaryOnPage(e,a),this._createPlaylistPlayer(a,i)):Math.random()<.01&&setTimeout(()=>{T.event(t,`noStickyPlaylist`,n&&{vendor:`none`,device:r&&r.device,isDesktop:this._device}||{})},1e3)}_initializeRelatedPlayers(e){let t=new Map;for(let n=0;n{let e=new c;!e||!e.enabled||(e.siteAds&&Ge(e.siteAds),new Ve(e,new Ue).start(),new Ze(new m(e),e).init())})()}catch(e){T.error(`CLS`,`pluginsertion-iife`,e),window.adthriveCLS&&(window.adthriveCLS.injectedFromPlugin=!1)}})();