function oktaAutoSignIn(n,t,i,r){function o(){var n=localStorage.getItem("OktaSession");if(!n)return!0;try{var i=JSON.parse(n),t=i.lastRefreshTimeStamp,r=(new Date).getTime();return t&&r-t>6e4}catch(u){return localStorage.removeItem("OktaSession"),!0}}function e(){for(var r,n=[],t,u=window.location.href.slice(window.location.href.indexOf("?")+1).split("&"),i=0;i<u.length;i++)t=u[i].split("="),r=t[0].toLowerCase(),n.push(r),n[r]=t[1];return n}var u,f;i=i==="True";r=r==="True";u=new XMLHttpRequest;i?i&&o()&&("withCredentials"in u?(f=document.createEvent("Event"),f.initEvent("oktaSessionChanged",!0,!0),u.onerror=function(){},u.onload=function(){var n;if(this.status===404)localStorage.removeItem("OktaSession"),r&&(n=encodeURIComponent("/Site/Login?ReturnUrl="+window.location.pathname+window.location.search),window.location.href="/_layouts/CommerceServer/IM/Logout.aspx?ReturnUrl="+n);else{var t=JSON.parse(u.responseText),i={lastRefreshTimeStamp:(new Date).getTime(),expiresAtTimeStamp:new Date(t.expiresAt).getTime()},e=JSON.stringify(i);localStorage.setItem("OktaSession",e);document.dispatchEvent(f)}},u.open("POST",n+"/api/v1/sessions/me/lifecycle/refresh",!0),u.withCredentials=!0,u.send()):console.log("CORS is not supported by this browser!")):"withCredentials"in u?(u.onload=function(i){i.srcElement.status===200&&(u.onload=function(){var i=JSON.parse(this.responseText),r=i.find(function(n){return n.appInstanceId===t}),n;r&&(n=e().returnurl?e().returnurl:encodeURIComponent(window.location.pathname+window.location.search),window.location.href="/Site/Login/IdpLogin?ReturnUrl="+n)},u.open("GET",n+"/api/v1/users/me/appLinks",!0),u.withCredentials=!0,u.send())},u.open("GET",n+"/api/v1/sessions/me",!0),u.withCredentials=!0,u.send()):console.log("CORS is not supported by this browser!"),function(){Array.prototype.find||(Array.prototype.find=function(n){var t;if(this===null)throw new TypeError("Array.prototype.find called on null or undefined");if(typeof n!="function")throw new TypeError("predicate must be a function");var i=Object(this),u=i.length>>>0,f=arguments[1],r;for(t=0;t<u;t++)if(r=i[t],n.call(f,r,t,i))return r;return undefined})}()}