console.log("loading config for destructoid");window.gamursInfScrollCustomSiteConfig={site:"destructoid",useCategories:true,useTags:true,categories:undefined,tags:undefined,sameCategory:false,timeDecay:false,timeDecayOffset:"30d",timeDecayScale:"90d",timeDecayDecay:0.5};window.gamursInfScroll={infScrollURL:"https://infinity-api.destructoid.com"};"use strict";console.log("Infinite scroll initialised");(function(){var J,W,F,V,Y,z,G,K;if(typeof window>"u")return;let o=window.gamursInfScrollCustomSiteConfig,A=window.gamursInfScroll,L=o&&(J=o.categories)!=null?J:"",q=o&&(W=o.tags)!=null?W:"",U=!(o&&o.useCategories===!1),T=!(o&&o.useTags===!1),M=!!(o&&o.sameCategory),N=!!(o&&o.timeDecay),B=o&&(F=o.timeDecayOffset)!=null?F:"",R=o&&(V=o.timeDecayScale)!=null?V:"",j=o&&(Y=o.timeDecayDecay)!=null?Y:"",$=A&&(z=A.infScrollURL)!=null?z:"",S=document.getElementsByClassName("gamurs-inf-scroll-post")[0].attributes["data-categories"].value,v=document.getElementsByClassName("gamurs-inf-scroll-post")[0].attributes["data-tags"].value,m=(G=document.getElementsByClassName("gamurs-inf-scroll-post")[0].attributes["data-experiments"])==null?void 0:G.value,X=window.location.href;window.gamurs_inf_scroll_data=window.gamurs_inf_scroll_data||{};let C=document.getElementsByClassName("gamurs-inf-scroll-post")[0].dataset.id,n=window.location.hostname.split(".")[window.location.hostname.split(".").length-2];n==="lndo"?n=window.location.hostname.split(".")[0]:n==="go-vip"&&(n=window.location.hostname.split(".")[0],n=n.split("-")[0],(n==="www"||n==="cms")&&(n=window.location.hostname.split(".")[0].split("-")[1])),window.gamurs_inf_scroll_data.nextUrl=`${$}/infscroll/${n}/${C}?categories=${S}&tags=${v}&useCategories=${U}&useTags=${T}&forceCategories=${L}&forceTags=${q}&sameCategory=${M}${N?`&timeDecayOffset=${B}&timeDecayScale=${R}&timeDecayDecay=${j}`:""}${m?`&experiments="${m}"`:""}`;let Z={root:document.querySelector("#scroll-area"),rootMargin:"0px",threshold:.5},ee={rootMargin:"-50% 0% -50% 0%",threshold:0},te={rootMargin:"-50% 0% -10% 0%",threshold:0},ie={rootMargin:"-75% 0% -25% 0%",threshold:0},le={rootMargin:"-87.5% 0% -12.5% 0%",threshold:0};function P(e,l,s){let t;return s==="middle"?(t=new IntersectionObserver(l,ee),t=g(e,t,!1)):s==="middleofmiddle"?(t=new IntersectionObserver(l,te),t=g(e,t,!0)):s==="middlelower"?(t=new IntersectionObserver(l,le),t=g(e,t,!1)):(t=new IntersectionObserver(l,Z),t=g(e,t,!1)),t}function oe(e){if(typeof window.gamursInfScrollOnInfiniteScrollAppend=="function")try{window.gamursInfScrollOnInfiniteScrollAppend(e)}catch(l){console.log(l)}}function se(e,l){e[0].isIntersecting&&(b(),l.unobserve(e[0].target))}function g(e,l,s){let t;return s?(e.style.position="relative",t=document.createElement("div"),t.style.position="absolute",t.style.top="50%",t.style.width="100%",t.style.height="50%",t.style.pointerEvents="none",e.appendChild(t)):t=e,l.observe(t),l}let p=[],w=document.querySelector(".gamurs-inf-scroll-post");p[w&&(K=w.dataset.id)!=null?K:0]=document.URL;let k=!1;history.scrollRestoration="manual";let O=!0,_="down",E=0;document.addEventListener("scroll",function(){let e=window.pageYOffset||document.documentElement.scrollTop;e>E?_="down":e<E&&(_="up"),E=e<=0?0:e});function ne(e,l){e.forEach(s=>{if(s.isIntersecting&&window.location.href!==s.target.dataset.url){let t=p[s.target.dataset.id];if(_==="down"?document.getElementsByClassName("gamurs-inf-scroll-post")[0].dataset.id!==s.target.dataset.id&&history.pushState(null,"",t):window.location.href!==X&&(O=!1,history.back()),document.title=s.target.dataset.title,typeof window.gamursInfScrollOnUrlChange=="function")try{window.gamursInfScrollOnUrlChange(t)}catch(i){console.log(i)}let h=document.querySelector("link[rel='canonical']");h&&(h.href=t),window.snowplow&&window.snowplow("trackStructEvent",{category:"gamurs-infinite-scroll",action:"impression"})}}),Array.from(document.getElementsByClassName("gamurs-inf-scroll-post")).map(s=>l.observe(s))}addEventListener("popstate",e=>{try{O&&document.querySelector(`[data-url="${e.target.location.href.split("?")[0]}"]`).scrollIntoView()}catch(l){console.log(l)}O=!0});function b(){k?H(!1,p,D,x):(k=!0,H(!0,p,D,x))}async function H(e,l,s,t){let h=e?`${$}/campaign/${n}/${C}?categories=${S}&tags=${v}${m?`&experiments="${m}"`:""}`:window.gamurs_inf_scroll_data.nextUrl;await fetch(h).then(i=>{if(i.status!==200)throw e?"No Campaign":`request failed: ${i.text()}`;return i.json()}).then(function(y){let r=y;if(r.html!=null){l[r.id]=r.url,e||(window.gamurs_inf_scroll_data.nextUrl=r.nextUrl);let c=document.createElement("div");c.innerHTML=r.html;let u=c.firstElementChild,d=document.querySelector("#gamurs-inf-scroll-main");if(d&&u)d.appendChild(u);else throw"did not find #gamurs-inf-scroll-main";window.snowplow&&window.snowplow("trackStructEvent",{category:"gamurs-infinite-scroll",action:"append-article",label:r.id}),[c,u].forEach(Q=>{Array.from(Q.querySelectorAll("script")).forEach(f=>{try{if(f.src){let a=document.createElement("script");a.src=f.src,a.type=f.type,a.id=f.id,a.async=!0,u&&Q===u&&f.parentElement&&f.parentElement.removeChild(f),a.id?document.getElementById(a.id)||d==null||d.appendChild(a):d==null||d.appendChild(a)}else(0,eval)(f.innerText)}catch(a){console.log(a)}})}),oe(r.id),g(document.querySelectorAll(".gamurs-inf-scroll-post")[document.querySelectorAll(".gamurs-inf-scroll-post").length-1],s,!0),g(document.querySelectorAll(".gamurs-inf-scroll-post")[document.querySelectorAll(".gamurs-inf-scroll-post").length-1],t,!1),s.unobserve(document.querySelectorAll(".gamurs-inf-scroll-post")[document.querySelectorAll(".gamurs-inf-scroll-post").length-2].lastChild)}}).catch(i=>{if(e)console.log(i),i!=="did not find #gamurs-inf-scroll-main"&&b();else{let y=window.gamurs_inf_scroll_data.nextUrl.split("?")[1].split("&").filter(c=>c.slice(0,5)==="page="),r=y.length?parseInt(y[0].split("=")[1]):1;if(r<20){if(i.slice(0,15)==="request failed:"){let c=window.gamurs_inf_scroll_data.nextUrl.split("?");window.gamurs_inf_scroll_data.nextUrl=c[0]+"?page="+(r+1).toString()+"&"+c[1].split("&").filter(u=>u.slice(0,5)!=="page=").join("&")}i!=="did not find #gamurs-inf-scroll-main"&&b()}}})}let x,D;function I(){x=P(w,ne,"middlelower"),D=P(w,se,"middleofmiddle")}n==="dotesports"?fetch("/wp-json/gamurs/v1/infscroll/multisites").then(e=>e.json()).then(e=>{let l=new URL(window.location.href).pathname.split("/")[1];e.includes(l)&&(n=`${n}|${l}`,window.gamurs_inf_scroll_data.nextUrl=`${$}/infscroll/${n}/${C}?categories=${S}&tags=${v}&useCategories=${U}&useTags=${T}&forceCategories=${L}&forceTags=${q}&sameCategory=${M}${N?`&timeDecayOffset=${B}&timeDecayScale=${R}&timeDecayDecay=${j}`:""}${m?`&experiments="${m}"`:""}`),I()}).catch(e=>{console.log(e),I()}):I()})();
