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