{
  "version": 3,
  "sources": ["ssg:https://framer.com/m/framer/store.js@^1.0.0", "ssg:https://framerusercontent.com/modules/3br70AnY64qwIfXM1dI2/mkkkSHQqKUf55SKyUpM7/ProfileOverrides.js"],
  "sourcesContent": ["import{useState,useEffect}from\"react\";import{Data,useObserveData}from\"framer\";export function createStore(state1){// Use Data so that a Preview reload resets the state\nconst dataStore=Data({state:Object.freeze({...state1})});// Create a set function that updates the state\nconst setDataStore=newState=>{// If the state is an object, make sure we copy it\nif(typeof newState===\"function\"){newState=newState(dataStore.state);}dataStore.state=Object.freeze({...dataStore.state,...newState});};// Store the initial state, copy the object if it's an object\nlet storeState=typeof state1===\"object\"?Object.freeze({...state1}):state1;// Keep a list of all the listeners, in the form of React hook setters\nconst storeSetters=new Set();// Create a set function that updates all the listeners / setters\nconst setStoreState=newState=>{// If the state is an object, make sure we copy it\nif(typeof newState===\"function\"){newState=newState(storeState);}storeState=typeof newState===\"object\"?Object.freeze({...storeState,...newState}):newState;// Update all the listeners / setters with the new value\nstoreSetters.forEach(setter=>setter(storeState));};// Create the actual hook based on everything above\nfunction useStore(){// Create the hook we are going to use as a listener\nconst[state,setState]=useState(storeState);// If we unmount the component using this hook, we need to remove the listener\n// @ts-ignore\nuseEffect(()=>{// But right now, we need to add the listener\nstoreSetters.add(setState);return()=>storeSetters.delete(setState);},[]);// If Data context exists, use Data, otherwise use vanilla React state\nif(useObserveData()===true){useObserveData();return[dataStore.state,setDataStore];}else{// Return the state and a function to update the central store\nreturn[state,setStoreState];}}return useStore;}\nexport const __FramerMetadata__ = {\"exports\":{\"createStore\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./createStore.map", "import{jsx as _jsx}from\"react/jsx-runtime\";import{createStore}from\"https://framer.com/m/framer/store.js@^1.0.0\";import{getAuth,signInWithRedirect,getRedirectResult,GoogleAuthProvider}from\"firebase/auth\";import*as React from\"react\";import{getApi}from\"https://framerusercontent.com/modules/5h1yV1XR5wt66CEqaP16/ZCQkhg4r7bhT6vcu0ouV/API.js\";import{useRouter}from\"framer\";const useStore=createStore({profile:undefined,updateProfile:false});export function profileController(Component){return props=>{const[store,setStore]=useStore();React.useEffect(()=>{setStore({profile:store.profile,updateProfile:true});},[]);if(store.updateProfile){getAuth().onAuthStateChanged(user=>{if(user){console.log(\"Fetching profile...\");getApi().then(api=>{return api.getProfile();}).then(profile=>{console.log(\"User loaded: \"+JSON.stringify(profile));setStore({profile:profile.playerId?profile:null,updateProfile:false});}).catch(error=>{console.log(\"Error: \"+error);setStore({profile:undefined,updateProfile:false});});// user.getIdToken(true).then(RetrieveProfile)\n}else{setStore({profile:undefined,updateProfile:false});}});}return /*#__PURE__*/_jsx(Component,{...props});function RetrieveProfile(token){console.log(\"Fetching profile...\");// fetch(\n//     \"https://api-gateway-web-8o5dlr0q.uc.gateway.dev/profile/get\",\n//     {\n//         method: \"POST\",\n//         headers: {\n//             Authorization: `Bearer ${token}`,\n//             \"Content-Type\": \"application/json\",\n//         },\n//     }\n// )\n//     .then((response) => {\n//         if (!response.ok) {\n//             return response.text().then((text) => {\n//                 throw new Error(text)\n//             })\n//         } else {\n//             return response.json()\n//         }\n//     })\n//     .then((loadedProfile) => {\n//         console.log(\"User loaded: \" + JSON.stringify(loadedProfile))\n//         setStore({\n//             profile: loadedProfile.playerId ? loadedProfile : null,\n//             updateProfile: false,\n//         })\n//     })\n//     .catch((error) => {\n//         console.log(\"Error: \" + error)\n//         setStore({ profile: undefined, updateProfile: false })\n//     })\n}};}export function withProfile(Component){return props=>{const[store]=useStore();return store.profile?/*#__PURE__*/_jsx(Component,{...props}):null;};}export function withProfileLoading(Component){return props=>{const[store]=useStore();return store.profile===undefined?/*#__PURE__*/_jsx(Component,{...props}):null;};}export function withNotCreatedProfile(Component){return props=>{const[store]=useStore();return store.profile===null?/*#__PURE__*/_jsx(Component,{...props}):null;};}export function withOculusAccessLink(Component){return props=>{const[store]=useStore();return store.profile?.oculusAccessLink?/*#__PURE__*/_jsx(Component,{...props}):null;};}export function withOculusLinked(Component){return props=>{const[store]=useStore();return store.profile?.oculusLinked?/*#__PURE__*/_jsx(Component,{...props}):null;};}export function withOculusNotLinked(Component){return props=>{const[store]=useStore();return store.profile?.oculusLinked?null:/*#__PURE__*/_jsx(Component,{...props});};}export function withStravaLinked(Component){return props=>{const[store]=useStore();return store.profile?.stravaLinked?/*#__PURE__*/_jsx(Component,{...props}):null;};}export function withStravaNotLinked(Component){return props=>{const[store]=useStore();return store.profile?.stravaLinked?null:/*#__PURE__*/_jsx(Component,{...props});};}export function assignLinkOculusRedirect(Component){return props=>{function open(){let redirect=window.location.protocol+\"//\"+window.location.host+\"/auth/oculus\";let url=`https://auth.oculus.com/sso/?redirect_uri=${redirect}&organization_id=1592291138231669`;window.open(url,\"_self\");}return /*#__PURE__*/_jsx(Component,{...props,onTap:open});};}export function assignLinkStravaRedirect(Component){return props=>{function open(){let redirect=window.location.protocol+\"//\"+window.location.host+\"/auth/strava\";let url=`https://www.strava.com/oauth/mobile/authorize?client_id=58627&redirect_uri=${redirect}&response_type=code&approval_prompt=force&scope=activity:write,profile:read_all`;window.open(url,\"_self\");}return /*#__PURE__*/_jsx(Component,{...props,onTap:open});};}export function assignUnlinkStravaAction(Component){return props=>{const[store,setStore]=useStore();function sendUnlink(){getApi().then(api=>{return api.unlinkStrava();}).then(()=>{console.log(\"User unlinked for strava\");setStore({profile:store.profile,updateProfile:true});}).catch(error=>{console.log(\"Error: \"+error);});// fetch(\n//     \"https://api-gateway-web-8o5dlr0q.uc.gateway.dev/unlink/strava\",\n//     {\n//         method: \"POST\",\n//         headers: {\n//             Authorization: `Bearer ${token}`,\n//             \"Content-Type\": \"application/json\",\n//         },\n//     }\n// )\n//     .then((response) => {\n//         if (!response.ok) {\n//             return response.text().then((text) => {\n//                 throw new Error(text)\n//             })\n//         } else {\n//             return response.json()\n//         }\n//     })\n//     .then(() => {\n//         console.log(\"User unlinked for strava\")\n//         setStore({\n//             profile: store.profile,\n//             updateProfile: true,\n//         })\n//     })\n//     .catch((error) => {\n//         console.log(\"Error: \" + error)\n//     })\n// })\n}return /*#__PURE__*/_jsx(Component,{...props,onTap:sendUnlink});};}export function assignRequestOculusAppAccessRedirect(Component){return props=>{const[store]=useStore();function open(){window.open(store.profile.oculusAccessLink,\"_blank\").focus();}return /*#__PURE__*/_jsx(Component,{...props,onTap:open});};}export function login(Component){function getRouteId(allRoute,path){for(const[key,value]of Object.entries(allRoute)){if(value?.path===path){return key;}}return\"\";}return props=>{const{navigate,routes}=useRouter();const auth=getAuth();function Authorize(){// For some reason on phones signInWithRedirect doesn't work\n// But after adding reverse proxy it might work...\nlet signInMethod=signInWithRedirect///*isPhone ? signInWithPopup :*/ signInWithRedirect\n;signInMethod(auth,new GoogleAuthProvider).then(result=>{console.log(\"Successful sign in\");navigate(getRouteId(routes,\"/account\"));}).catch(error=>{console.log(\"Error during signing in\"+error.message);navigate(getRouteId(routes,\"/\"));});}React.useEffect(()=>{auth.onAuthStateChanged(user=>{console.log(\"onAuthStateChanged: \"+!!user);// setAuthenticated(!!user)\n});getRedirectResult(auth).then(result=>{if(result&&result.user){navigate(getRouteId(routes,\"/account\"));}else{console.log(\"getRedirectResult: \"+JSON.stringify(result));}}).catch(error=>{console.log(\"Error during signing in\"+error.message);navigate(getRouteId(routes,\"/\"));});},[]);return /*#__PURE__*/_jsx(Component,{...props,onTap:Authorize});};}\nexport const __FramerMetadata__ = {\"exports\":{\"withStravaLinked\":{\"type\":\"reactHoc\",\"name\":\"withStravaLinked\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"assignUnlinkStravaAction\":{\"type\":\"reactHoc\",\"name\":\"assignUnlinkStravaAction\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withProfile\":{\"type\":\"reactHoc\",\"name\":\"withProfile\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withNotCreatedProfile\":{\"type\":\"reactHoc\",\"name\":\"withNotCreatedProfile\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withOculusAccessLink\":{\"type\":\"reactHoc\",\"name\":\"withOculusAccessLink\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withOculusLinked\":{\"type\":\"reactHoc\",\"name\":\"withOculusLinked\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"login\":{\"type\":\"reactHoc\",\"name\":\"login\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"assignRequestOculusAppAccessRedirect\":{\"type\":\"reactHoc\",\"name\":\"assignRequestOculusAppAccessRedirect\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withProfileLoading\":{\"type\":\"reactHoc\",\"name\":\"withProfileLoading\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"assignLinkOculusRedirect\":{\"type\":\"reactHoc\",\"name\":\"assignLinkOculusRedirect\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"assignLinkStravaRedirect\":{\"type\":\"reactHoc\",\"name\":\"assignLinkStravaRedirect\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"profileController\":{\"type\":\"reactHoc\",\"name\":\"profileController\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withOculusNotLinked\":{\"type\":\"reactHoc\",\"name\":\"withOculusNotLinked\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withStravaNotLinked\":{\"type\":\"reactHoc\",\"name\":\"withStravaNotLinked\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ProfileOverrides.map"],
  "mappings": "yPAAqF,SAASA,EAAYC,EAAO,CACjH,IAAMC,EAAUC,EAAK,CAAC,MAAM,OAAO,OAAO,CAAC,GAAGF,CAAM,CAAC,CAAC,CAAC,EACjDG,EAAaC,GAAU,CAC1B,OAAOA,GAAW,aAAYA,EAASA,EAASH,EAAU,KAAK,GAAGA,EAAU,MAAM,OAAO,OAAO,CAAC,GAAGA,EAAU,MAAM,GAAGG,CAAQ,CAAC,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AAK,IAAI,OAAO,QAAQH,CAAQ,EAAG,GAAGG,GAAO,OAAOF,EAAM,OAAOC,EAAM,MAAM,EAAG,CAAC,OAAOlB,GAAO,CAAC,GAAK,CAAC,SAAAoB,EAAS,OAAAC,CAAM,EAAEC,EAAU,EAAQC,EAAKC,EAAQ,EAAE,SAASC,GAAW,CAEniBC,EACHH,EAAK,IAAII,CAAkB,EAAE,KAAKC,GAAQ,CAAC,QAAQ,IAAI,oBAAoB,EAAER,EAASL,EAAWM,EAAO,UAAU,CAAC,CAAE,CAAC,EAAE,MAAMT,GAAO,CAAC,QAAQ,IAAI,0BAA0BA,EAAM,OAAO,EAAEQ,EAASL,EAAWM,EAAO,GAAG,CAAC,CAAE,CAAC,CAAE,CAAC,OAAMQ,EAAU,IAAI,CAACN,EAAK,mBAAmBO,GAAM,CAAC,QAAQ,IAAI,uBAAuB,CAAC,CAACA,CAAI,CAC3U,CAAC,EAAEC,EAAkBR,CAAI,EAAE,KAAKK,GAAQ,CAAIA,GAAQA,EAAO,KAAMR,EAASL,EAAWM,EAAO,UAAU,CAAC,EAAQ,QAAQ,IAAI,sBAAsB,KAAK,UAAUO,CAAM,CAAC,CAAG,CAAC,EAAE,MAAMhB,GAAO,CAAC,QAAQ,IAAI,0BAA0BA,EAAM,OAAO,EAAEQ,EAASL,EAAWM,EAAO,GAAG,CAAC,CAAE,CAAC,CAAE,EAAE,CAAC,CAAC,EAAsBjB,EAAKL,EAAU,CAAC,GAAGC,EAAM,MAAMyB,CAAS,CAAC,CAAE,CAAE",
  "names": ["createStore", "state1", "dataStore", "Data", "setDataStore", "newState", "storeState", "storeSetters", "setStoreState", "setter", "useStore", "state", "setState", "ye", "ue", "useObserveData", "useStore", "createStore", "profileController", "Component", "props", "store", "setStore", "ue", "getAuth", "user", "getApi", "api", "profile", "error", "p", "RetrieveProfile", "token", "withProfile", "withProfileLoading", "withOculusAccessLink", "Component", "props", "store", "useStore", "p", "withOculusLinked", "withOculusNotLinked", "withStravaLinked", "withStravaNotLinked", "assignLinkStravaRedirect", "Component", "props", "open", "url", "window", "p", "assignUnlinkStravaAction", "store", "setStore", "useStore", "sendUnlink", "getApi", "api", "error", "assignRequestOculusAppAccessRedirect", "login", "getRouteId", "allRoute", "path", "key", "value", "navigate", "routes", "useRouter", "auth", "getAuth", "Authorize", "signInWithRedirect", "GoogleAuthProvider", "result", "ue", "user", "getRedirectResult"]
}
