{
  "version": 3,
  "sources": ["ssg:https://framer.com/m/framer/store.js@^1.0.0", "ssg:https://framerusercontent.com/modules/ptxhEe4cXIGj6bbi7LPT/htOpVEtLT5iZwNpx6E7W/FramerAuth.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{useRouter,inferInitialRouteFromPath}from\"framer\";import{auth}from\"https://cdn.framerauth.com/scripts/framerauth-sdk@beta.js\";const useStore=createStore({user:null,isAuthenticated:false,isLoaded:false});export function withStore(Component){return props=>{const[store,setStore]=useStore();return /*#__PURE__*/_jsx(Component,{...props,store:store});};}export function withSignOut(Component){const handleClick=()=>{auth.signOut(\"/\");};return props=>{const[store,setStore]=useStore();if(!store.user)return null;return /*#__PURE__*/_jsx(Component,{...props,onClick:handleClick});};}export function withEmail(Component){return props=>{const[store,setStore]=useStore();if(!store.user)return null;return /*#__PURE__*/_jsx(Component,{...props,text:store.user.email});};}export function withFirstName(Component){return props=>{const[store,setStore]=useStore();if(!store.user)return null;return /*#__PURE__*/_jsx(Component,{...props,text:store.user.first_name});};}export function withLoggedIn(Component){return props=>{const[store,setStore]=useStore();if(!store.user)return null;return /*#__PURE__*/_jsx(Component,{...props});};}export function withLoggedOut(Component){return props=>{const[store]=useStore();if(store.user)return null;let className=props.className||\"\";if(!store.isLoaded){className+=\" fa-cloak\";}return /*#__PURE__*/_jsx(Component,{...props,className:className.trim()});};}export function withActiveLicense(Component){return props=>{var _store_user;const[store]=useStore();const hasActiveLicense=(_store_user=store.user)===null||_store_user===void 0?void 0:_store_user.licenses.some(license=>license.status===\"active\");if(!hasActiveLicense)return null;return /*#__PURE__*/_jsx(Component,{...props});};}export function withNoActiveLicense(Component){return props=>{var _store_user;const[store]=useStore();const hasActiveLicense=(_store_user=store.user)===null||_store_user===void 0?void 0:_store_user.licenses.some(license=>license.status===\"active\");if(hasActiveLicense)return null;return /*#__PURE__*/_jsx(Component,{...props});};}export function withVariant(Component){return props=>{const[store]=useStore();const variant=store.user?null:props===null||props===void 0?void 0:props.variant;return /*#__PURE__*/_jsx(Component,{...props,variant:variant});};}export function withVariantActiveLicense(Component){return props=>{var _store_user;const[store]=useStore();const hasActiveLicense=(_store_user=store.user)===null||_store_user===void 0?void 0:_store_user.licenses.some(license=>license.status===\"active\");const variant=hasActiveLicense?null:props===null||props===void 0?void 0:props.variant;return /*#__PURE__*/_jsx(Component,{...props,variant:variant});};}export function withIsLessonComplete(Component){return props=>{var _store_user_data,_store_user;const[store,setStore]=useStore();// Do not display the component if the user is logged out\nif(!store.user)return null;const key=`course:status:${props===null||props===void 0?void 0:props.slug}`;const isCompleted=((_store_user=store.user)===null||_store_user===void 0?void 0:(_store_user_data=_store_user.data)===null||_store_user_data===void 0?void 0:_store_user_data[key])===\"completed\";if(!isCompleted)return null;return /*#__PURE__*/_jsx(Component,{...props});};}export function withActionCompleteLesson(Component){return props=>{var _store_user_data,_store_user;const router=useRouter();const[store,setStore]=useStore();const key=`course:status:${props===null||props===void 0?void 0:props.slug}`;let isCompleted=((_store_user=store.user)===null||_store_user===void 0?void 0:(_store_user_data=_store_user.data)===null||_store_user_data===void 0?void 0:_store_user_data[key])===\"completed\";// Do not display the component if the user is logged out\nif(!store.user)return null;// Define an async function handleClick to handle the click event.\nconst handleClick=async event=>{try{// If the lesson has been completed exit the function\nif(isCompleted)return;// Update the components local state (for instant UI update)\nisCompleted=true;// Call the FramerAuth API to update the user data, marking the course as completed.\nconst{data,error}=await auth.patchUserData({[key]:\"completed\"});// If there is an error throw it.\nif(error){throw new Error(\"Error updating course status.\");}// If there is no error, update the user data in the store with the updated data.\nconst updatedUser={...store.user,data};setStore({user:updatedUser});// If there is a link, redirect the user.\nif(props===null||props===void 0?void 0:props.link){const[path,hash]=props.link.split(\"#\");const{routeId,pathVariables}=inferInitialRouteFromPath(router.routes,path);if(routeId){router.navigate(routeId,hash,pathVariables);}}}catch(error){console.error(error);isCompleted=false;}};// Set the variant based on the completed state\nconst variant=isCompleted?props===null||props===void 0?void 0:props.variant:null;// Render the original component with the modified props and onClick handler.\nreturn /*#__PURE__*/_jsx(Component,{...props,variant:variant,onClick:handleClick});};}\nexport const __FramerMetadata__ = {\"exports\":{\"withSignOut\":{\"type\":\"reactHoc\",\"name\":\"withSignOut\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withLoggedIn\":{\"type\":\"reactHoc\",\"name\":\"withLoggedIn\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withEmail\":{\"type\":\"reactHoc\",\"name\":\"withEmail\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withStore\":{\"type\":\"reactHoc\",\"name\":\"withStore\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withActionCompleteLesson\":{\"type\":\"reactHoc\",\"name\":\"withActionCompleteLesson\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withActiveLicense\":{\"type\":\"reactHoc\",\"name\":\"withActiveLicense\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withLoggedOut\":{\"type\":\"reactHoc\",\"name\":\"withLoggedOut\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withFirstName\":{\"type\":\"reactHoc\",\"name\":\"withFirstName\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withVariantActiveLicense\":{\"type\":\"reactHoc\",\"name\":\"withVariantActiveLicense\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withNoActiveLicense\":{\"type\":\"reactHoc\",\"name\":\"withNoActiveLicense\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withIsLessonComplete\":{\"type\":\"reactHoc\",\"name\":\"withIsLessonComplete\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withVariant\":{\"type\":\"reactHoc\",\"name\":\"withVariant\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./FramerAuth.map"],
  "mappings": "gJAAqF,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,CAAE,EACjIC,EAAW,OAAOL,GAAS,SAAS,OAAO,OAAO,CAAC,GAAGA,CAAM,CAAC,EA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,EAA7E,IAA+E,CAAE,CAAqkC,SAASM,EAAYC,EAAU,CAAC,OAAOC,GAAO,CAAC,GAAK,CAACC,CAAK,EAAEC,EAAS,EAAQC,EAAQF,EAAM,KAAK,KAAyCD,GAAM,QAAQ,OAAoBI,EAAKL,EAAU,CAAC,GAAGC,EAAM,QAAQG,CAAO,CAAC,CAAE,CAAE",
  "names": ["createStore", "state1", "dataStore", "Data", "setDataStore", "newState", "storeState", "storeSetters", "setStoreState", "setter", "useStore", "state", "setState", "ye", "ue", "useObserveData", "useStore", "createStore", "withSignOut", "Component", "handleClick", "B", "props", "store", "setStore", "useStore", "p", "withEmail", "withFirstName", "withVariant", "Component", "props", "store", "useStore", "variant", "p"]
}
