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