var CscopeInfo=window.CscopeInfo||{};try{var isClient="undefined"!=typeof window&&window.document}catch(o){isClient=!1}try{var isLambda="undefined"!=typeof process&&!!process.env.LAMBDA_TASK_ROOT}catch(o){isLambda=!1}try{var isWebview="undefined"!=typeof Ti}catch(o){isWebview=!1}if(isWebview)log={logInfo:function(o){Ti.API.info("CScope Info: "+o)},logError:function(o){Ti.API.error("CScope Error: "+o)},logWarn:function(o){Ti.API.warn("CScope Warn: "+o)}};else var log={logInfo:function(o){console.log("CScope Info:",o)},logError:function(o){console.log("CScope Error:",o)},logWarn:function(o){console.log("CScope Warn:",o)}};!function(t){var r=environmentVariables.envVariables().environment;"prod"==r&&(console.log=function(){}),log.logInfo("Env "+r);var i,l,c=!1,o={},e=window.location.search,n=new URLSearchParams(e);log.logInfo("URLParams: "+n);var a=n.get("ref");function s(){log.logInfo("Eula update callback - Choice ? "+o.choice+" Params : "+o.params),window.location.href=o.choice?"/invite.html"+o.params:-1==["index.html","team.html","upload.html","pie.html","alert.html","certificate.html","invite.html","changePassword.html"].indexOf(o.params)?"/index.html":"/"+o.params}a&&null!=a&&log.logInfo("Is this an Invite? "+a.includes("invite.html")+" ["+a+"]"),"invite.html"==a?(o.choice=!0,o.params="?paramKey=invite",o.params+="&team="+n.get("team"),o.params+="&subTeam="+n.get("subTeam"),o.params+="&user="+n.get("user"),o.params+="&key="+n.get("key")):(o.choice=!1,o.params=n.has("ref")?n.get("ref"):"index.html"),log.logInfo("ReturnParams: "+JSON.stringify(o.params)),log.logInfo("Pathname "+window.location.pathname),"/signin.html"==window.location.pathname?CscopeInfo.authToken.then(function(o){o?(i=new CscopeUser(o,r)).checkIfIsAdmin(function(){log.logInfo("Eula user (eula) "+JSON.stringify(i)),l=o}):log.logInfo("No token (eula)")}).catch(function(o){log.logInfo(o),"undefined"!=typeof cscopereport&&cscopereport.closeSocket(),fireClose(),log.logInfo("Token error (eula) "+o),window.location.href="./signin.html"}):window.location.pathname,t(window).on("load",function(){log.logInfo("Cookies ready"),t("#eula").load("eula.html",function(){t("#acceptButton").click(function(){var o,e,n,a;log.logInfo("Has just accepted"),(c=!0)?(e=new CustomEvent("enableSignInButton",{detail:{data:o}}),document.getElementById("eula").dispatchEvent(e)):log.logInfo("Has not accepted"),n=c,a=s,t.ajax({method:"POST",url:_config[r].api.invokeUrl+"/roles",headers:{Authorization:l},data:JSON.stringify({user:i.user,eulaStateToSet:n,operation:"updateEulaState"}),contentType:"application/json",dataType:"text",success:a,error:function(o,e,n){log.logError("Error getting preCanned data "+e+", Details: "+n),console.error("Response preCanned Data: ",o.responseText),"Endpoint request timed out"==JSON.parse(o.responseText).Error&&log.logInfo("backoff"),JSON.parse(o.responseText).Error}})}),function(){log.logInfo("eulaBoxReady fired");var o=new CustomEvent("eulaBoxReady",{detail:{name:"John"}});document.getElementById("eula").dispatchEvent(o)}()})})}(jQuery);