(()=>{"use strict";const t=window;t.blogherads=t.blogherads||{adq:[]};const e=()=>t.blogherads,n=()=>"function"==typeof e().reloadAds,d=t=>Boolean(t?.domId?.length);function s(t,...e){console.debug.bind(null,t)(...e)}const o=(()=>{let t=1;return{send:function(e,n,d){const s={type:"SKMBoomerangMessageRequest",requestId:t++,data:d,method:n};e.postMessage(s,"*")}}})(),a=window,i=a.document;class l{constructor(t){t.forEach((t=>this.push(t)))}push(t){try{t.call(null)}catch(t){}}attachConnatix(t){if(i.documentElement.classList.contains("floatingplayer-nofloat"))t.disableFloatingMode();else{a.addEventListener("message",(({data:e})=>{"pmcadm:floatingplayer=nofloat"===e&&t.disableFloatingMode()}),!1);const n=e();n.adq.push((()=>{n.trackVideoPlayerFloatingState&&n.trackVideoPlayerFloatingState(t)}))}}sendAtlasMessage(t,e){o.send(a,t,e)}}const r=window;if(r.pmc=r.pmc||{adm:[]},r.pmc.adm=r.pmc.adm||[],Array.isArray(r.pmc.adm)){const t=r.pmc.adm;r.pmc.adm=new l(t)}const c=()=>r.pmc,m=window,h=c();h.displayAds=new function(){const t=e();this.init=function(){this.bind_events(),this.handle_delay_loading()}.bind(this),this.bind_events=function(){const e=c();e.hooks?.add_action?.("pmc_gallery_rotate_ads",this.rotate_ads_for_gallery),e.hooks?.add_action?.("pmc_rotate_ads",this.rotate_ads),"loading"!==document.readyState?this.display():document.addEventListener("DOMContentLoaded",this.display),m.addEventListener("message",this.direct_sold_ad_event_listener,!1),t.addEventListener("blankAdServed",this.blank_ad_event_listener),t.addEventListener("slotRefresh",this.slot_refresh_event_listener)}.bind(this),this.rotate_ads=function(e){if(!e||this.is_direct_sold||!n())return;const d=[];jQuery("div.slot-rotate-"+e).each((function(){let e="";e=1===parseInt(jQuery(this).data("is-adhesion-ad"))?"skm-ad-bottom":jQuery(this).attr("id");const n=t.getSlotById(e);n&&d.push(n)})),d&&d.length&&t.reloadAds(d)}.bind(this),this.rotate_ads_for_gallery=function(){if(!n())return;const e=m.pmc_meta;"mobile"===e?.env?t.reloadAds(t.getSlots()):t.reloadAds()}.bind(this),this.handle_delay_loading=function(){if(!n())return;if(void 0===window?.pmc_adm_display_ads?.delay_loading)return;const e=window.pmc_adm_display_ads.delay_loading;Object.keys(e).forEach((n=>{const d=e[n],o=[];void 0!==d.time&&d.time>0&&o.push(new Promise((t=>{s(`Delay loading set time: ${d.time}`,n),setTimeout((()=>{t("time")}),1e3*d.time)}))),void 0!==d.scroll_depth&&d.scroll_depth>0&&o.push(new Promise((t=>{function e(){const a=window.innerHeight,i=d.scroll_depth*a;window.scrollY>i&&(s("Delay loading add scroll depth hit",n),"onscrollend"in window?window.removeEventListener("scrollend",e):window.removeEventListener("scroll",o),t("scroll_depth"))}const o=function(t){let e;return(...n)=>{clearTimeout(e),e=setTimeout((()=>{t.apply(this,n)}),100)}}(e);s(`Delay loading add scroll depth listener: ${d.time}`,n),"onscrollend"in window?window.addEventListener("scrollend",e):window.addEventListener("scroll",o)}))),o.length>0&&Promise.race(o).then((e=>{s(`Delay loading winner: ${e}`,n),t.getSlotById(n).removeBlock("pmc-adm-v2-delay-loading")}))}))}.bind(this),this.display=function(){""!==function(){const t=document.querySelector("#pmc-adm-ad-interrupts div.pmc-adm-boomerang-pub-div div");let e="";return t&&(e=t.id),e}()?m.pmc_admanager.show_interrupt_ads():t.getSlots().forEach((function(t){t.removeBlock("gallery"),t.display()}))}.bind(this),this.has_ads=function(e){return!!t.getSlots().find((t=>function(t,e){return Boolean(t&&"object"==typeof t&&"string"==typeof t.subAdUnitPath&&t.subAdUnitPath.includes(e))}(t,e)))}.bind(this),this.direct_sold_ad_event_listener=function(e){const n=c();if(!n.hooks||"string"!=typeof e.data)return;"pmcadm:dfp:isdirect=true"===e.data.substring(0,24)&&(this.is_direct_sold=!0,m.document.documentElement.classList.add("pmcadm-direct-sold"),t.getSlots().forEach((t=>t.setAutoRefreshTime(0))),n.hooks.do_action?.("pmc_adm_dfp_direct_sold",e));"pmcadm:dfp:isFullySponsored=true"===e.data.substring(0,32)&&(this.is_fully_sponsored=!0,m.document.documentElement.classList.add("pmcadm-fully-sponsored"),n.hooks.do_action?.("pmc_adm_dfp_fully_sponsored",e))}.bind(this),this.blank_ad_event_listener=function(t){if(!d(t))return;let e=m.document.getElementById(t.domId);for(;e&&!e.matches(".adma");)e=e.parentElement;if(e&&e.matches(".adma")){for(e.classList.add("ad-empty");e&&!e.matches('[data-component="ad-unit"]');)e=e.parentElement;e&&e.setAttribute("data-ad-empty",!0)}}.bind(this),this.slot_refresh_event_listener=function(t){if(!d(t))return;let e=m.document.getElementById(t.domId);for(;e&&!e.matches(".adma");)e=e.parentElement;if(e&&e.matches(".ad-empty")){for(e.classList.remove("ad-empty");e&&!e.matches('[data-component="ad-unit"]');)e=e.parentElement;e&&e.matches("[data-ad-empty]")&&e.removeAttribute("data-ad-empty")}}.bind(this)},e().adq.push((function(){h.displayAds.init()}))})();