{"version":3,"file":"authStore.BUtiZioj.mjs","names":[],"sources":["https:/framerusercontent.com/modules/i6cGQhGmocvvyCytdqzg/epPhjHjkgTE3HcKe1B46/authStore.js"],"sourcesContent":["// authStore.js\nimport{supabase}from\"https://framerusercontent.com/modules/yLdgArc50Dfg8CWd0t9v/s4iAglIMjOGozqwS50X6/supabase.js\";import{getUserByEmail}from\"https://framerusercontent.com/modules/yLdgArc50Dfg8CWd0t9v/s4iAglIMjOGozqwS50X6/supabase.js\";let cachedUser=null;// ⛳️ Ophalen uit geheugen\nexport const getUser=()=>cachedUser;// 🏷️ In geheugen + localStorage zetten\nexport const setUser=user=>{cachedUser=user;try{localStorage.setItem(\"cachedUser\",JSON.stringify(user));}catch(e){console.warn(\"Kon user niet in localStorage opslaan\",e);}};// 🧹 Wissen uit geheugen + localStorage\nexport const clearUser=()=>{cachedUser=null;localStorage.removeItem(\"cachedUser\");};// 🔁 Ophalen uit localStorage bij app-start\nexport const loadUserFromStorage=()=>{try{const raw=localStorage.getItem(\"cachedUser\");if(raw){cachedUser=JSON.parse(raw);}}catch(e){console.warn(\"Kon cached user niet laden uit localStorage\",e);}};// 🧠 Supabase raadplegen en user object bijwerken\nexport const fetchAndCacheUser=async()=>{try{const{data:authData,error}=await supabase.auth.getUser();const email=authData?.user?.email;if(error||!email){clearUser();return null;}const profile=await getUserByEmail(email);if(profile){setUser(profile);return profile;}else{clearUser();return null;}}catch(e){console.error(\"Fout bij ophalen Supabase user:\",e);clearUser();return null;}};\nexport const __FramerMetadata__ = {\"exports\":{\"setUser\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"clearUser\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"getUser\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"loadUserFromStorage\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"fetchAndCacheUser\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}"],"mappings":"wIACkH,CAErG,EAAQ,GAAM,CAAiB,GAAG,CAAC,aAAa,QAAQ,aAAa,KAAK,UAAU,EAAK,CAAC,OAAQ,EAAE,CAAC,QAAQ,KAAK,wCAAwC,EAAE,GAC5J,MAAc,CAAiB,aAAa,WAAW,aAAa"}