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