function changeContinue(){$(".initial").hide(),$(".view").hide(),$(".reset").show();var e=window.location.pathname.substr(1)||"main";return cognitoUser?($("#verification_message").addClass("hidden"),$(".loggedin").show(),$(".loggedout").hide(),$("#logout_trigger").text("Log Out "+cognitoUser.username),$("#logout_trigger_2").text("Log Out "+cognitoUser.username)):($(".loggedin").hide(),$(".loggedout").show()),loadView(e,cognitoUser),!0}function loadView(e,o){if(0===$("#"+e).length)$("#main").show();else if(o&&$("#"+e).hasClass("refreshattributes")){captains.includes(o.username)?$(".captain").show():$(".captain").hide();var r=!1;colors.forEach(function(e){r=r||teams[e].includes(o.username)}),r?($(".notplayer").hide(),$(".player").show(),$("#"+e).show()):($(".player").hide(),$(".notplayer").show(),$("#loading").show(),loadAttributeView(e,o))}else"playerlist"===e?loadPlayerList(e):$("#"+e).show()}function loadPlayerList(e){$("#loading").show(),$.getJSON("https://api.recroomleague.com/v1/leagueRegistrations",function(o){var r="";o.draft.users.sort(function(e,o){return e.toLowerCase()"+e+"")}),document.getElementById("dr_list").innerHTML=r,$("#loading").hide(),$("#"+e).show()})}function loadTeams(e){colors.forEach(function(e){var o="";teams[e].slice(1).forEach(function(e){o+=''+e+""}),document.getElementById("team_"+e).innerHTML=o}),$("#"+e).show()}function loadAttributeView(e,o){o.getUserAttributes(function(o,r){if($("#loading").hide(),o)return void $("#wrong").show();$("select[class*='attribute_']").prop("selectedIndex",0),$(".aansdefault").show(),r.forEach(function(e){value=e.getValue();var o=parseInt(value);isNaN(o)||(value=o);var r=e.getName().replace("custom:","custom_");$(".attribute_"+r).val(value),$("*[class*='aans_"+r+"_']").hide(),$(".aans_"+r+"_"+(value+"").replace(/[^A-Za-z0-9_]/g,"_")).show()}),$("#"+e).show()})}function checkPasswordMatch(){$("#register_password").val()!==$("#register_confirm").val()?$("#register_confirm").css("background-color","#f7c9cc"):$("#register_confirm").css("background-color","#f7f9fc")}function checkPasswordMatchF(){$("#forgot_password").val()!==$("#forgot_confirm").val()?$("#forgot_confirm").css("background-color","#f7c9cc"):$("#forgot_confirm").css("background-color","#f7f9fc")}function checkPasswordMatchC(){$("#changepassword_password").val()!==$("#changepassword_confirm").val()?$("#changepassword_confirm").css("background-color","#f7c9cc"):$("#changepassword_confirm").css("background-color","#f7f9fc")}function tryRegister(){var e=!1;if($("#register_password").val().length<8&&(e="Password not long enough"),$("#register_password").val()!==$("#register_confirm").val()&&(e="Passwords do not match"),$("#register_email").val().length<1&&(e="Email required"),$("#register_username").val().length<1&&(e="Username required"),e)return $("#register_error").show(),void $("#register_error").text(e);$("#register_error").hide(),$("#register_progress").show(),$("#register_trigger").hide(),cognitoUserPool.signUp($("#register_username").val(),$("#register_password").val(),[{Name:"email",Value:$("#register_email").val()},{Name:"custom:oa",Value:"0"},{Name:"custom:dr",Value:"0"},{Name:"custom:cl",Value:"0"}],null,registerFinish)}function registerFinish(e,o){if($("#register_progress").hide(),$("#register_trigger").show(),e)$("#register_error").show(),e.message=e.message.split(":").pop(),console.log(e.message)," [\\p{L}\\p{M}\\p{S}\\p{N}\\p{P}]+"==e.message?e.message="Username should be letters, numbers, and underscores only.":" [\\S]+"===e.message&&(e.message="Password cannot contain spaces."),$("#register_error").text(e.message);else{var r={Username:$("#register_username").val(),Pool:cognitoUserPool};unverifiedUser=new AmazonCognitoIdentity.CognitoUser(r),$("#verification_message").removeClass("hidden"),changeView("/login")}}function tryForgotV(){var e=!1;if($("#forgot_username").val().length<1&&(e="Username required"),e)return $("#forgot_error").show(),void $("#forgot_error").text(e);$("#forgot_error").hide(),$("#forgotv_progress").show(),$("#forgotv_trigger").hide();var o={Username:$("#forgot_username").val(),Pool:cognitoUserPool};new AmazonCognitoIdentity.CognitoUser(o).forgotPassword({inputVerificationCode:function(e){$("#forgot_error").text("Verification code sent to "+e.CodeDeliveryDetails.Destination),$("#forgot_error").show(),$("#forgotv_progress").hide(),$("#forgotv_trigger").show()},onFailure:function(e){e.message=e.message.split(":").pop()," [\\p{L}\\p{M}\\p{S}\\p{N}\\p{P}]+"===e.message&&(e.message="Invalid characters in username."),$("#forgot_error").text(e.message),$("#forgot_error").show(),$("#forgotv_progress").hide(),$("#forgotv_trigger").show(),console.log(e)}})}function tryForgot(){var e=!1;if($("#forgot_password").val().length<8&&(e="Password not long enough"),$("#forgot_password").val()!==$("#forgot_confirm").val()&&(e="Passwords do not match"),$("#forgot_code").val().length<1&&(e="Verification Code Required"),$("#forgot_username").val().length<1&&(e="Username required"),e)return $("#forgot_error").show(),void $("#forgot_error").text(e);$("#forgot_error").hide(),$("#forgot_progress").show(),$("#forgot_trigger").hide();var o={Username:$("#forgot_username").val(),Pool:cognitoUserPool};new AmazonCognitoIdentity.CognitoUser(o).confirmPassword($("#forgot_code").val(),$("#forgot_password").val(),{onFailure:function(e){e.message=e.message.split(":").pop()," [\\p{L}\\p{M}\\p{S}\\p{N}\\p{P}]+"===e.message?e.message="Invalid characters in username.":" [\\S]+"===e.message&&(e.message="Password cannot contain spaces."),$("#forgot_error").text(e.message),$("#forgot_error").show(),$("#forgot_progress").hide(),$("#forgot_trigger").show(),console.log(e)},onSuccess:function(){changeView("/login")}})}function changePassword(){var e=!1;if($("#changepassword_password").val().length<8&&(e="New Password not long enough"),$("#changepassword_password").val()!==$("#changepassword_confirm").val()&&(e="New Passwords do not match"),$("#changepassword_oldpassword").val().length<8&&(e="Old password is at least 8 characters"),e)return $("#changepassword_error").show(),void $("#changepassword_error").text(e.split(":").pop());$("#changepassword_error").hide(),$("#changepassword_progress").show(),$("#changepassword_trigger").hide(),cognitoUser.changePassword($("#changepassword_oldpassword").val(),$("#changepassword_password").val(),function(e,o){e?(e=e.toString().split(":").pop()," [\\S]+"===e&&(e="Password cannot contain spaces."),$("#changepassword_error").text(e)):($("#changepassword_error").text("Password successfully changed!"),$(".passdone").hide()),$("#changepassword_error").show(),$("#changepassword_progress").hide(),$("#changepassword_trigger").show()})}function tryLogin(){$("#login_error").hide(),$("#login_progress").show(),$("#login_trigger").hide();var e={Username:$("#login_username").val(),Password:$("#login_password").val()},o=new AmazonCognitoIdentity.AuthenticationDetails(e),r={Username:$("#login_username").val(),Pool:cognitoUserPool};cognitoUser=new AmazonCognitoIdentity.CognitoUser(r),cognitoUser.authenticateUser(o,{onSuccess:loginSuccess,onFailure:loginFailure})}function loginFailure(e){if($("#login_progress").hide(),$("#login_trigger").show(),$("#login_error").show(),e.message=e.message.split(":").pop()," [\\p{L}\\p{M}\\p{S}\\p{N}\\p{P}]+"===e.message&&(e.message="Invalid characters in username."),$("#login_error").text(e.message),"User is not confirmed."===e.message){var o={Username:$("#login_username").val(),Pool:cognitoUserPool};unverifiedUser=new AmazonCognitoIdentity.CognitoUser(o),$("#verification_message").removeClass("hidden")}}function loginSuccess(e){$("#login_progress").hide(),$("#login_trigger").show(),$("#verification_message").addClass("hidden"),changeView("/")}function resendVerification(){resend=Math.abs(resend-1),$(".resender").hide(),$("#vcode_progress").show(),unverifiedUser?unverifiedUser.resendConfirmationCode(function(e,o){if($("#vcode_progress").hide(),e)return console.log(e),void $("#resender_error").show();$("#resender_"+resend).show()}):$("#verification_message").addClass("hidden")}function logOut(){cognitoUser.signOut(),cognitoUser=!1,window.onhashchange()}function changeView(e){history.pushState({},"",e),window.onhashchange()}const cognitoPoolData={UserPoolId:"us-east-1_WOgMf58RA",ClientId:"3nbv2fm3f37bc33jkds6lvem5n"},cognitoUserPool=new AmazonCognitoIdentity.CognitoUserPool(cognitoPoolData),captains=["nullnull"],colors=["teal","yellow","pink","green","black","orange","purple","white"],teamNames={teal:"Teal Team Six",yellow:"Yellow Jackets",pink:"Pink Stink",green:"Greenbacks",black:"Paint it Black",orange:"Orange Crush",purple:"Purple Rain",white:"White Ford Broncos"};var teams={teal:[],yellow:[],pink:[],green:[],black:[],orange:[],purple:[],white:[]},cognitoUser=cognitoUserPool.getCurrentUser(),unverifiedUser=!1,attributes={},resend=0,lastuser=!1,changeme=function(){cognitoUser||(cognitoUser=cognitoUserPool.getCurrentUser()),cognitoUser?cognitoUser.getSession(function(e,o){!e&&o.isValid()||(cognitoUser.signOut(),cognitoUser=!1),changeContinue()}):changeContinue()};window.onhashchange=changeme,window.onload=window.onhashchange,window.onpopstate=window.onhashchange,$(function(){$("a").click(function(e){if("_blank"!==$(this).attr("target"))return history.pushState({},"",$(this).attr("href")),window.onhashchange(),!1})}),$(document).ready(function(){$("#register_password, #register_confirm").keyup(checkPasswordMatch),$("#forgot_password, #forgot_confirm").keyup(checkPasswordMatchF),$("#changepassword_password, #changepassword_confirm").keyup(checkPasswordMatchC)}),$(".resender").on("click",function(){resendVerification()}),$("#register_trigger").on("click",function(){tryRegister()}),$(".register_input").keyup(function(e){13==e.keyCode&&$("#register_trigger").click()}),$("#login_trigger").on("click",function(){tryLogin()}),$("#forgotv_trigger").on("click",function(){tryForgotV()}),$("#forgot_trigger").on("click",function(){tryForgot()}),$(".login_input").keyup(function(e){13==e.keyCode&&$("#login_trigger").click()}),$(".forgotv_input").keyup(function(e){13==e.keyCode&&$("#forgotv_trigger").click()}),$(".forgot_input").keyup(function(e){13==e.keyCode&&$("#forgot_trigger").click()}),$(".changepassword_input").keyup(function(e){13==e.keyCode&&$("#changepassword_trigger").click()}),$("#logout_trigger").on("click",function(){logOut()}),$("#logout_trigger_2").on("click",function(){logOut()}),$("#changepassword_trigger").on("click",function(){changePassword()}),$("*[class*='attribute_']").change(function(){var e=$(this).attr("class").replace(/^.*attribute_([^ ]*).*$/,"$1");e=e.replace("custom_","custom:");var o=$(this).val(),r=[],s={Name:e,Value:o},s=new AmazonCognitoIdentity.CognitoUserAttribute(s);r.push(s),$(".view").hide(),$("#loading").show(),cognitoUser.updateAttributes(r,function(e,o){if(e)return $(".view").hide(),void $("#wrong").show();window.onhashchange()})});