(()=>{(function(d,c){let e={instanceId:null,zone:"69",refreshInterval:parseInt("0"),site:"19",host:"https://d2.ads.rmbl.ws",sizing:{width:parseInt("300"),height:parseInt("250"),aspectRatio:null,minWidth:0,minHeight:0,minScalePercent:.35,activeWidth:parseInt("300"),activeHeight:parseInt("250"),maxShownWidth:0},pub:"22994",type:"3",loaded:!1,lazy:"true",correlator:"2zcG0ZxaGR4jvS1nFcaVjOp5pPU",parent:!1,script:null,scriptSrc:"id",adContainer:null,frame:{el:null,injected:!1,loaded:!1,count:0},log:!1,params:{},extra:[function(){let t="";return t.length>0?"keywords="+t:""},function(){let t=a.searchParam("rac_caid");if(t===null||t.length===0)return"";let n=a.searchParam("rac_crid"),i="";return i+="rac_caid="+t,n!==null&&n.length>0&&(i+="&rac_crid="+n),i}]},a={log:function(){e.log&&console.log("[Zone "+e.zone+": "+e.instanceId+"] ",...arguments)},isParent:function(){try{return d.self!==d.top}catch{return!0}},get:function(t){for(var n=!1,i=[function(){return localStorage[t]},function(){return sessionStorage[t]},function(){var s,o,u,l=c.cookie.split(";");for(s=0;s<l.length;s++)if(o=l[s].substr(0,l[s].indexOf("=")),u=l[s].substr(l[s].indexOf("=")+1),o=o.replace(/^\s+|\s+$/g,""),o===t)return decodeURI(u)}],r=0;r<i.length;r++)if(n=this.safe(i[r]),!a.undef(n)&&n!==!1)return n;return""},set:function(t,n){var i=[function(){localStorage[t]=n},function(){sessionStorage[t]=n},function(){var r=new Date,s=encodeURI(n)+"; expires="+r.setSeconds(r.getSeconds()+10*365*24*60*60).toUTCString();c.cookie=t+"="+s}];i.forEach(function(r){a.safe(r)})},safe:function(t){try{return t()}catch(n){return e.log&&console.warn(n),!1}},attr:function(t){var n=e.script.getAttribute(t);return n===null?"":encodeURIComponent(n)},style:function(t,n){return c.defaultView.getComputedStyle(t,null)[n]},searchParam:function(t){let n=window.location.search;return n.length===0?null:new URLSearchParams(n).get(t)},url:function(t){try{let n=(e.parent?c.referrer:c.location.href).substring(0,255);return t?encodeURIComponent(n):n}catch{return""}},title:function(){if(e.parent)return this.url(!1).replace(/[^a-z0-9]/gmi," ").replace(/(https?|www)/gmi," ").replace(/\s+/g," ").substring(0,255);let t=c.getElementsByTagName("title")[0];return(a.undef(t)?"":t.innerText).substring(0,255)},undef:function(t){return typeof t>"u"},objToHttpArr:function(t){if(typeof t!="object")return[];var n=[];for(var i in t){var r=t[i];Array.isArray(r)&&(r=r.join(",")),n.push(i+"="+encodeURIComponent(r))}return n},visible:function(t,n,i,r,s,o,u){var l=t.parentNode,p=2;return t===c.body||c.body.contains(t)?l.nodeType===9||l.nodeName==="HTML"?!0:t.nodeName!=="SCRIPT"&&(this.style(t,"opacity")==="0"||this.style(t,"display")==="none"||this.style(t,"visibility")==="hidden")?!1:((this.undef(n)||this.undef(s)||this.undef(r)||this.undef(i)||this.undef(o)||this.undef(u))&&(n=t.offsetTop,i=t.offsetLeft,r=n+t.offsetHeight,s=i+t.offsetWidth,o=t.offsetWidth,u=t.offsetHeight),l?t.offsetParent===l&&(this.style(l,"overflow")==="hidden"||this.style(l,"overflow")==="scroll")&&(i+p>l.offsetWidth+l.scrollLeft||i+o<l.scrollLeft||n+p>l.offsetHeight+l.scrollTop||n+u<l.scrollTop)?!1:(t.offsetParent===l&&(i+=l.offsetLeft,n+=l.offsetTop),this.visible(l,n,i,r,s,o,u)):!0):!1},isInViewport:function(t,n=1){let i=t.getBoundingClientRect(),r=d.innerHeight||c.documentElement.clientHeight,s=i.top;s>=0&&(s=0);let o=Math.floor(100-s/-i.height*100),u=Math.floor(100-(i.bottom-r)/i.height*100);return!(o<n||u<n)},visiblePercent:function(t){let n=t.getBoundingClientRect(),i=d.innerHeight||c.documentElement.clientHeight,r=d.innerWidth,s=Math.max(0,Math.min(n.bottom,i)-Math.max(n.top,0)),o=Math.max(0,Math.min(n.right,r)-Math.max(n.left,0)),u=n.width*n.height;return s*o/u*100},elementsVisibleSize(t,n,i){typeof n>"u"&&(n=Number.MAX_SAFE_INTEGER),typeof i>"u"&&(i=Number.MAX_SAFE_INTEGER);let r=t.parentNode,s=t.getBoundingClientRect(),o=Math.floor(s.width),u=Math.floor(s.height);return!isNaN(o)&&o>0&&(n=Math.min(n,o)),!isNaN(u)&&u>0&&(i=Math.min(i,u)),r!==null&&r.nodeType!==9&&r.nodeName!=="HTML"?a.elementsVisibleSize(r,n,i):[n,i]},canUseIntersectionObserver:function(){return"IntersectionObserver"in window&&"IntersectionObserverEntry"in window&&"intersectionRatio"in window.IntersectionObserverEntry.prototype},canUseResizeObserver:function(){return"ResizeObserver"in window},getFirstApplicableScriptById:function(){let t=c.querySelectorAll("script#nrp-"+e.zone+":not([data-rac-instance-id])");return t.length===0?null:t[0]},purgeScripts:function(){c.querySelectorAll('script[data-rac-instance-id="'+e.instanceId+'"]').forEach(function(n){a.safe(function(){n.remove()})})},getFirstAvailableInstanceId:function(){let t=Math.floor(Math.random()*9999999);return c.querySelectorAll('script[data-rac-instance-id="'+t+'"]').length>0?a.getFirstAvailableInstanceId():t},greatestCommonDivisor:function(t,n){return n===0?t:this.greatestCommonDivisor(n,t%n)},aspectRatio:function(t,n){let i=this.greatestCommonDivisor(t,n);return{widthRatio:t/i,heightRatio:n/i,ratio:t/i/(n/i),toString:function(){return this.widthRatio+":"+this.heightRatio}}},round(t,n){return Math.round(t*Math.pow(10,n))/Math.pow(10,n)},debounce:function(t,n){let i;return function(...r){let s=this;clearTimeout(i),i=setTimeout(function(){t.apply(s,r)},n)}}},f={isVisible:function(){return e.adContainer.offsetParent!==null},maxPossibleWidth:function(t){if(!t.parentElement)return t.clientWidth;let n=t.parentElement,i=n.style.position;if(n.style.width!==""||n.style.maxWidth!=="")return n.clientWidth;getComputedStyle(n).position==="static"&&(n.style.position="relative");let r="rac-ad-cs-"+e.instanceId,s=c.getElementById(r);return s||(s=c.createElement("div"),s.style.width="100%",s.style.position="absolute",s.style.visibility="hidden",s.style.height="0",s.style.margin="0",s.style.border="none",s.style.padding="0",s.style.overflow="hidden",s.style.pointerEvents="none",s.id=r,n.appendChild(s)),n.style.position=i,s.clientWidth},onResize:function(){let t=e.adContainer,n=t.offsetParent;if(t){if(f._resizeTimer&&clearTimeout(f._resizeTimer),!f.isVisible()){f._resizeTimer=setTimeout(function(){f.onResize()},150);return}n&&a.canUseResizeObserver()?new ResizeObserver(r=>{f.resizeToFitParent()}).observe(n):window.addEventListener("resize",function(){f.resizeToFitParent()})}},resizeToFitParent:a.debounce(function(){let t=e.adContainer;if(!t||!t.parentElement)return;let i=e.sizing.aspectRatio.ratio,r=f.maxPossibleWidth(t),s=r/i;(!r||r===0)&&(r=e.sizing.width,s=e.sizing.height),r=a.round(Math.min(Math.max(r,e.sizing.minWidth),e.sizing.width),4),s=a.round(Math.min(Math.max(s,e.sizing.minHeight),e.sizing.height),4),f.resize(r,s),g.resize(r,s),e.sizing.activeWidth=r,e.sizing.activeHeight=s,e.sizing.maxShownWidth=Math.max(e.sizing.maxShownWidth,r)},150),resize(t,n){e.adContainer.style.position="relative",e.adContainer.style.width=t+"px",e.adContainer.style.height=n+"px"}},g={syncTimer:null,lastLoad:null,contentWindow:function(){return e.frame.el?e.frame.el.contentWindow:null},send(t){return this.contentWindow().postMessage(t,"*")},recv(){this.sync()},sync(){let t=this;this.syncTimer!==null&&clearInterval(this.syncTimer);let n=function(){if(t.contentWindow()===null){clearInterval(t.syncTimer);return}let i=t.inViewPercent();t.send({type:"sync",data:{inViewPercent:i}}),t.canBeRefreshed()&&(a.log(`refreshing iframe source after ${e.refreshInterval} seconds`),t.setSrc(h.src()))};n(),this.syncTimer=setInterval(n,750)},canBeRefreshed(){let t=this.lastLoad!==null&&Date.now()/1e3-this.lastLoad>=e.refreshInterval;return e.frame.loaded&&c.hasFocus()&&e.refreshInterval>0&&this.inViewPercent()>25&&t},inViewPercent(){return e.frame.injected?a.visiblePercent(e.adContainer):e.lazy&&a.isInViewport(e.adContainer)?1:0},setLoaded(){this.lastLoad=Date.now()/1e3},setSrc(t){if(!e.frame.el)return;let n=this;a.safe(function(){e.frame.el.src=t,n.setLoaded(),e.frame.count++})},resize(t,n){e.frame.el&&e.frame.el.style.width!=="100%"&&(t!==e.sizing.width||n!==e.sizing.height)&&(e.frame.el.style.position="absolute",e.frame.el.style.top="0",e.frame.el.style.left="0",e.frame.el.style.bottom="0",e.frame.el.style.right="0",e.frame.el.style.width="100%",e.frame.el.style.height="100%")}},h={pre:function(){return d.rads=a.undef(d.rads)?{}:d.rads,d.rads.loaded=a.undef(d.rads.loaded)?[]:d.rads.loaded,a.undef(d.rads.correlator)&&!a.undef(e.correlator)&&e.correlator.length>0?d.rads.correlator=e.correlator:e.correlator=d.rads.correlator,d.rads.loaded.indexOf(e.zone)===-1&&d.rads.loaded.push(e.zone),e.lazy=e.lazy==="true",e.instanceId=a.getFirstAvailableInstanceId(),this.setSizing(),a.safe(h.setParams),!0},setSizing(){e.sizing.aspectRatio=a.aspectRatio(e.sizing.width,e.sizing.height),e.sizing.minWidth=e.sizing.width*e.sizing.minScalePercent,e.sizing.minHeight=e.sizing.height*e.sizing.minScalePercent},handleLazyLoad:function(t){if(a.canUseIntersectionObserver()){let i=new IntersectionObserver(r=>{a.isInViewport(t)&&(i.disconnect(),h.frame())},{threshold:.01});i.observe(t);return}let n=function(){if(a.isInViewport(t)&&!e.loaded){h.frame();return}setTimeout(n,100)};n()},shouldLazyLoad(t){return a.undef(c.currentScript)?!1:a.undef(t)||a.undef(t.lazy)?e.lazy:e.lazy=t.lazy==="true"},init:function(){if(a.log("init"),e.parent=a.isParent(),e.parent&&a.log("invoked within an iframe"),e.script=a.getFirstApplicableScriptById(),e.scriptSrc="id",e.script===null)return a.log("script element unavailable"),!1;a.log("visibility",a.visible(e.script)),!a.undef(c.currentScript)&&!a.undef(c.currentScript.dataset)&&(c.currentScript.dataset.racInstanceId=e.instanceId.toString());let t=e.script.dataset;t.racInstanceId=e.instanceId.toString();let n=e.script.parentElement;if(e.adContainer=c.createElement("div"),e.adContainer.id="rac-ad-"+e.instanceId.toString(),e.adContainer.style.maxWidth=`${e.sizing.width}px`,e.adContainer.style.maxHeight=`${e.sizing.height}px`,e.adContainer.style.minWidth=`${e.sizing.minWidth}px`,e.adContainer.style.minHeight=`${e.sizing.minHeight}px`,n.appendChild(e.adContainer),f.onResize(),h.shouldLazyLoad(t)){if(a.log("attempt lazy load"),n&&!a.isInViewport(e.adContainer))return this.handleLazyLoad(e.adContainer),!1;a.log("skipping lazy load")}return this.frame(),!0},src:function(){a.safe(h.setParams);var t=e.host+"/loader?a="+e.zone,n=a.url(!0),i=encodeURIComponent(a.title()),r=["if="+e.parent];return Object.keys(e.params).length>0&&r.push(a.objToHttpArr(e.params).join("&")),n.length!==0&&r.push("url="+n),i.length!==0&&r.push("title="+i),a.safe(function(){let[s,o]=a.elementsVisibleSize(e.adContainer);s>0&&s<Number.MAX_SAFE_INTEGER&&r.push("vw="+s),o>0&&o<Number.MAX_SAFE_INTEGER&&r.push("vh="+o)}),!a.undef(e.correlator)&&e.correlator.length>0&&r.push("pcorr="+e.correlator),e.extra.forEach(function(s){var o=a.safe(s);o=!o||o.length===0?"":r.push(o)}),t=t+"&"+r.join("&"),t},setParams:function(t){var n=t||d.rads.data||{};for(var i in n){let r=i.match(/s\d?\d\b/g);if(r!==null&&r.length>0){e.params[i]=n[i];continue}switch(i){case"debug":e.params.debug=n[i]==="true"||n[i]===!0;break;case"cpid":case"content_publisher_id":e.params.cpid=n[i];break;case"cuid":case"content_user_id":e.params.cuid=n[i];break;case"cvid":case"content_video_id":e.params.cvid=n[i];break;case"ccid":case"content_channel_id":e.params.ccid=n[i];break;case"keywords":e.params.keywords=n[i];break;case"categories":e.params.categories=Array.isArray(n[i])?n[i].join(","):n[i];break;case"log":e.log=n[i];break;case"cuab":e.params.cuab=n[i];break;case"cug":e.params.cug=n[i];break;case"cuuid":e.params.cuuid=n[i];break}}!a.undef(n.zones)&&!a.undef(n.zones[e.zone])&&h.setParams(n.zones[e.zone])},frame:function(){a.log("inject iframe");let t=e.script.parentNode,n=t;if(e.adContainer!==null&&(n=e.adContainer),t===null)return!1;let i=c.createElement("iframe");if(i.src=this.src(),i.width=String(e.sizing.width),i.height=String(e.sizing.height),i.scrolling="no",i.style.cssText="border:0;display:block;",i.sandbox="allow-popups allow-scripts allow-same-origin allow-forms",i.setAttribute("data-zone",e.zone),i.setAttribute("data-rac-instance-id",e.instanceId),i.onload=function(){e.frame.loaded=!0,g.recv()},e.frame.el=i,e.script.nodeName==="SCRIPT")return a.purgeScripts(),n.appendChild(i),e.frame.injected=!0,g.setLoaded(),f.resizeToFitParent(),!1;e.script.appendChild(i),e.frame.injected=!0,g.setLoaded(),f.resizeToFitParent()}};(function(){if(!h.pre())return!1;h.init()})()})(window,document);})();
