1customElements.get("component-account-social-login")||customElements.define("component-account-social-login",class extends HTMLElement{constructor(){super(),this.loading=!1,this.isInvalid=!1}connectedCallback(){this.props={facebookAppId:this.getAttribute("facebook-app-id"),facebookApiVersion:this.getAttribute("facebook-api-version"),googleClientId:this.getAttribute("google-client-id"),socialLoginTag:this.getAttribute("social-login-tag"),facebookLoginTag:this.getAttribute("facebook-login-tag"),googleLoginTag:this.getAttribute("google-login-tag"),cryptoSecret:this.getAttribute("crypto-secret")};const googleLoginButton=this.querySelector("#google-login-btn");this.hasGoogleLogin()?googleLoginButton.addEventListener("click",e=>{e.preventDefault(),this.openGoogleLogin()}):googleLoginButton.style.display="none";const faceLoginButton=this.querySelector("#facebook-login-btn");this.hasFacebookLogin()?faceLoginButton.addEventListener("click",e=>{e.preventDefault(),this.openFacebookLogin()}):faceLoginButton.style.display="none";const loginErrorMessage=this.querySelector(".social-login__error");this.isInvalid?loginErrorMessage.style.display="block":loginErrorMessage.style.display="none"}hasGoogleLogin(){return!!window.google?.accounts}hasFacebookLogin(){return!!window.FB}openGoogleLogin(){if(!this.hasGoogleLogin()){this.invalidateLogin();return}this.loading=!0,window.google.accounts.oauth2.initTokenClient({client_id:this.props.googleClientId,scope:"https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email",ux_mode:"popup",callback:async tokenResponse=>{this.access_token=tokenResponse.access_token;const profile=await this.getUserProfileData(this.access_token);await this.checkDataAndSignIn(profile.email,profile.given_name,profile.family_name,this.props.googleLoginTag)}}).requestAccessToken()}async getUserProfileData(accessToken){const headers=new Headers;return headers.append("Authorization",`Bearer ${accessToken}`),await(await fetch("https://www.googleapis.com/oauth2/v3/userinfo",{headers})).json()}openFacebookLogin(){if(!this.hasFacebookLogin()){this.invalidateLogin();return}this.loading=!0,window.FB.init({appId:this.props.facebookAppId,cookie:!0,xfbml:!0,version:this.props.facebookApiVersion}),window.FB.login(response=>{response.status==="connected"?window.FB.api("/me?fields=email,first_name,last_name",async userData=>{await this.checkDataAndSignIn(userData.email,userData.first_name,userData.last_name,this.props.facebookLoginTag)}):response.status==="not_authorized"?this.invalidateLogin():this.enableLogin()},{scope:"email"})}enableLogin(){this.loading=!1}invalidateLogin(){this.isInvalid=!0,this.enableLogin()}async checkDataAndSignIn(email,firstName,lastName,signedInTag){email?(this.isInvalid=!1,await this.signInWithMultipass(email,firstName,lastName,signedInTag)):this.invalidateLogin()}async multipassSignIn(payload){const data=await getAuthData();if(!data)return!1;const headers={"Content-Type":"application/json","x-api-key":data.profileServiceKey};let result=null;try{const response=await fetch(data.baseUrl+data.multipassEndpoint,{method:"POST",headers,body:JSON.stringify(payload)});response.ok&&(result=await response.json())}catch(error){console.error("Error during multipass sign in:",error)}return result}async signInWithMultipass(email,firstName,lastName,signedInTag){const payload={email,firstName,lastName,tags:signedInTag,returnTo:`${window.location.origin}/account`,crossDomain:!0},result=await this.multipassSignIn(payload);result?(this.trackLoginEmail(email,signedInTag),this.multipassSuccess(result)):this.invalidateLogin()}trackLoginEmail(email,signedInTag){try{const cipherInstance=browserCrypto.createCipher("aes-256-cbc",this.props.cryptoSecret),finalEmailHash=cipherInstance.update(email,"utf8","hex")+cipherInstance.final("hex");window.sendGTMData&&window.sendGTMData({event:"login",email:finalEmailHash,source:signedInTag})}catch(err){console.error(err)}}multipassSuccess(response){const domain=window.location.host.includes("trythirdlove")?"trythirdlove.com":"thirdlove.com";jsCookie.set("_tl_is_customer",!0,{expires:540,domain});const params=window.getURLParams();let{url}=response,returnTo=params.return_to;params.checkout_url&&(returnTo="checkout"),returnTo&&(url=`${url}?return_to=${encodeURIComponent(returnTo)}`),document.location.replace(url)}}); 2//# sourceMappingURL=/cdn/shop/t/11121/assets/component-account-social-login.js.map?v=44766637616890286181790858326
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.