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