{
  "version": 3,
  "sources": ["ssg:https://framerusercontent.com/modules/HI8qSfzyrKLDo3SM9Hqu/EIi6bKt4HGOZDSS2SqJP/GoogleAuth.js"],
  "sourcesContent": ["import{jsx as _jsx}from\"react/jsx-runtime\";import{useLayoutEffect,useCallback}from\"react\";const setToken=token=>{const expiration=new Date;expiration.setFullYear(2030);const domain=\"brain.fm\";document.cookie=`token=${token}; expires=${expiration.toUTCString()}; domain=${domain}`;try{if(window.amplitude){document.cookie=`deviceId=${window.amplitude.getDeviceId()}; expires=${expiration.toUTCString()}; domain=${domain}`;}}catch(error){console.error(\"setToken(): could not set device id\");}window.location.href=\"https://my.brain.fm/welcome\";};const trackEventWithProperties=async(event,properties)=>{if(!window.amplitude)return;try{await window.amplitude.track(event,properties).promise;}catch(error){console.error(\"logEventWithProperties(): failed to log in amplitude\");}};/**\n * These annotations control how your component sizes\n * Learn more: https://www.framer.com/developers/#code-components-auto-sizing\n *\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n */ export default function GoogleAuth(props){// This is a React component containing an Example component\n// - Replace <Example /> with your own code\n// - Find inspiration: https://www.framer.com/developers/\nconst handleGoogleSignUp=useCallback(async data=>{if(data.credential){try{const responseRaw=await fetch(`https://api.brain.fm/v2/auth/google-signup`,{method:\"POST\",body:JSON.stringify({accessToken:data.credential}),headers:{\"Content-Type\":\"application/json\"}});const response=await responseRaw.json();if(response.status===200){const meRaw=await fetch(`https://api.brain.fm/v2/users/me`,{method:\"GET\",headers:{Authorization:`Bearer ${response.result}`}});const me=await meRaw.json();try{window.amplitude.setUserId(me.result.user.id);window.amplitude.identify(new window.amplitude.Identify().set(\"email\",me.result.user.email));}catch(error){console.error(\"trackSignUpEvent(): failed to sign up in amplitude\");}await trackEventWithProperties(\"core_sign_up_success\",{core_sign_up_method:\"google\",core_sign_up_location:\"go.brain.fm\"});setToken(response.result);}else{var ref;if(((response===null||response===void 0?void 0:(ref=response.messages)===null||ref===void 0?void 0:ref[0])||\"\").includes(\"Account already exists\")){window.location.href=\"https://my.brain.fm\";}}}catch(error1){await trackEventWithProperties(\"core_sign_up_error\",{core_sign_up_method:\"google\",core_sign_up_location:\"go.brain.fm\"});if(((error1===null||error1===void 0?void 0:error1.message)||\"\").includes(\"Account already exists\")){window.location.href=\"https://my.brain.fm\";}}}else{console.error(\"An error occurred while authorizing with Google\");await trackEventWithProperties(\"core_sign_up_error\",{core_sign_up_method:\"google\",core_sign_up_location:\"go.brain.fm\"});}},[]);useLayoutEffect(()=>{const googleBtn=document.getElementById(\"google-button\");if(!googleBtn||!window.google)return;window.google.accounts.id.initialize({client_id:\"557603022520-l5ok0ij6ppub9h4ds94snd3ojphav69j.apps.googleusercontent.com\",callback:handleGoogleSignUp,context:\"signup\"});window.google.accounts.id.renderButton(googleBtn,{theme:\"filled_blue\",shape:\"pill\",size:\"large\",logo_alignment:\"left\"});},[]);return /*#__PURE__*/ _jsx(\"div\",{style:containerStyle,children:/*#__PURE__*/ _jsx(\"div\",{id:\"google-button\",style:buttonStyle})});};const containerStyle={};const buttonStyle={height:\"44px\"};\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"GoogleAuth\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"auto\",\"framerSupportedLayoutHeight\":\"auto\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./GoogleAuth.map"],
  "mappings": "gGAA0F,IAAMA,EAASC,GAAO,CAAC,IAAMC,EAAW,IAAI,KAAKA,EAAW,YAAY,IAAI,EAAE,IAAMC,EAAO,WAAW,SAAS,OAAO,SAASF,CAAK,aAAaC,EAAW,YAAY,CAAC,YAAYC,CAAM,GAAG,GAAG,CAAIC,EAAO,YAAW,SAAS,OAAO,YAAYA,EAAO,UAAU,YAAY,CAAC,aAAaF,EAAW,YAAY,CAAC,YAAYC,CAAM,GAAI,MAAa,CAAC,QAAQ,MAAM,qCAAqC,CAA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SAAS,wBAAwB,IAAGZ,EAAO,SAAS,KAAK,sBAAuB,MAAO,QAAQ,MAAM,iDAAiD,EAAE,MAAMC,EAAyB,qBAAqB,CAAC,oBAAoB,SAAS,sBAAsB,aAAa,CAAC,CAAG,EAAE,CAAC,CAAC,EAAE,OAAAY,EAAgB,IAAI,CAAC,IAAMC,EAAU,SAAS,eAAe,eAAe,EAAK,CAACA,GAAW,CAACd,EAAO,SAAcA,EAAO,OAAO,SAAS,GAAG,WAAW,CAAC,UAAU,2EAA2E,SAASM,EAAmB,QAAQ,QAAQ,CAAC,EAAEN,EAAO,OAAO,SAAS,GAAG,aAAac,EAAU,CAAC,MAAM,cAAc,MAAM,OAAO,KAAK,QAAQ,eAAe,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC,EAAuBC,EAAK,MAAM,CAAC,MAAMC,EAAe,SAAuBD,EAAK,MAAM,CAAC,GAAG,gBAAgB,MAAME,CAAW,CAAC,CAAC,CAAC,CAAE,CAAE,IAAMD,EAAe,CAAC,EAAQC,EAAY,CAAC,OAAO,MAAM",
  "names": ["setToken", "token", "expiration", "domain", "window", "trackEventWithProperties", "event", "properties", "GoogleAuth", "props", "handleGoogleSignUp", "te", "data", "response", "me", "ref", "error1", "fe", "googleBtn", "p", "containerStyle", "buttonStyle"]
}
