{"version":3,"file":"SystemCore.TNK3YwIn.mjs","names":["useState","React","useState"],"sources":["https:/framerusercontent.com/modules/vj7bFUjvEQFgEzNBkdoG/vf3CKm378wlVcBk7IhSU/createStore.js","https:/framer.com/m/framer/store.js@^1.0.0","https:/framerusercontent.com/modules/ht9wSyJJK3sK3Oj0FIVm/TCQZ8DIU0BjarunMrVFQ/SystemCore.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","/*\n * createStore (framer/store@1.0.1)\n *\n * Learn More: https://www.framer.com/asset-urls\n */\n\nexport * from \"https://framerusercontent.com/modules/vj7bFUjvEQFgEzNBkdoG/vf3CKm378wlVcBk7IhSU/createStore.js\"\n","import{jsx as _jsx}from\"react/jsx-runtime\";import{forwardRef,useEffect,useState}from\"react\";import React from\"react\";import{createStore}from\"https://framer.com/m/framer/store.js@^1.0.0\";export const useSystemStore=createStore({systemReady:false,user:\"UNSET\"});let systemCorePromise=null;export function initializeSystemCore(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const[,setStore]=useSystemStore();useEffect(()=>{const sys=window?.systemCore;// 1) Hard reset to a known baseline on mount\nsetStore(prev=>({...prev,user:null,systemReady:false,responseReceived:false}));// 2) Set initial user (even if null)\nconst current=sys?.getCurrentUser?.()??null;setStore(prev=>({...prev,user:current,// If you consider this a \"response\", set to !!current\n    responseReceived:!!current,systemReady:!!sys}));// 3) Subscribe to changes\nconst unsub=sys?.onAuthStateChanged?.(user=>{setStore(prev=>({...prev,user,responseReceived:true}));});return()=>{unsub?.();};},[setStore]);return /*#__PURE__*/_jsx(Component,{ref:ref,...props});});}export function withLoginButton(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const[store,setStore]=useSystemStore();const variant=store.user?\"LoggedIn\":\"NotLoggedIn\";//const content = store.user ? store.user.email : \"Log in\"\n//const content = store.user ? \"Account\" : \"Log in\"\nvar newProps={...props,variant};const handleClick=()=>{if(store.user===\"UNSET\"||!store.user){window.dispatchEvent(new CustomEvent(\"show:authwindow\"));}};return /*#__PURE__*/_jsx(Component,{ref:ref,...newProps,onClick:handleClick});});}export function withUserEmail(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const[store,setStore]=useSystemStore();return /*#__PURE__*/_jsx(Component,{ref:ref,...props,text:store.user?store.user.email:\"\"});});}export function withLogoutButton(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const[store,setStore]=useSystemStore();const logOut=async()=>{try{const result=await window?.systemCore?.logout?.();if(result?.success){setStore({user:null});}}catch(err){console.error(\"Logout failed:\",err);}};const handleClick=async e=>{if(store.user){await logOut();}};return /*#__PURE__*/_jsx(Component,{ref:ref,...props,onClick:handleClick});});}export function withLoginStatus(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const[store]=useSystemStore();const newProps={...props};if(store.user===\"UNSET\"){newProps.variant=\"Unset\";}else if(store.user){if(window?.systemCore?.isEmailVerified()){newProps.variant=\"LoggedIn\";}else{newProps.variant=\"LoggedInNoEmail\";}}else{newProps.variant=\"NotLoggedIn\";}return /*#__PURE__*/_jsx(Component,{ref:ref,...newProps});});}export function withShowIfLoggedIn(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const[store]=useSystemStore();if(store.user===\"UNSET\"||!store?.user){return null;}return /*#__PURE__*/_jsx(Component,{ref:ref,...props});});}export function withShowIfNotLoggedIn(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const[store]=useSystemStore();if(store?.user){return null;}return /*#__PURE__*/_jsx(Component,{ref:ref,...props});});}export function withResendEmailButton(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const[store]=useSystemStore();const[variant,setVariant]=React.useState(\"Default\");const handleClick=async e=>{try{setVariant(\"Loading\");await window?.systemCore?.resendVerificationEmail?.();console.log(\"Verification email resent.\");}catch(err){console.error(\"Failed to resend verification email:\",err);}finally{setVariant(\"Success\");}};const newProps={...props,onClick:handleClick,variant,disabled:variant!==\"Default\"||props.disabled};return /*#__PURE__*/_jsx(Component,{ref:ref,...newProps});});}export function withResetPasswordButton(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const[store]=useSystemStore();// the variant we pass to the component\nconst[variant,setVariant]=useState(\"Default\");const isEligible=!!store?.user&&window?.systemCore?.isEmailVerified?.();// Update eligibility variant whenever auth state changes\nuseEffect(()=>{if(!isEligible)setVariant(\"Disabled\");else setVariant(\"Default\");},[isEligible]);const handleClick=async()=>{if(!isEligible)return;try{setVariant(\"Loading\");const email=store.user.email;const result=await window.systemCore.resetPassword(email);if(result?.success){setVariant(\"Success\");}else{console.error(\"Reset password failed:\",result?.error);setVariant(\"Error\");}}catch(err){console.error(\"Reset password exception:\",err);setVariant(\"Error\");}};return /*#__PURE__*/_jsx(Component,{ref:ref,...props,onClick:handleClick,variant:variant,disabled:variant===\"Disabled\"||variant===\"Loading\"});});}\nexport const __FramerMetadata__ = {\"exports\":{\"withUserEmail\":{\"type\":\"reactHoc\",\"name\":\"withUserEmail\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withResendEmailButton\":{\"type\":\"reactHoc\",\"name\":\"withResendEmailButton\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"useSystemStore\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withLogoutButton\":{\"type\":\"reactHoc\",\"name\":\"withLogoutButton\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withLoginButton\":{\"type\":\"reactHoc\",\"name\":\"withLoginButton\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withShowIfLoggedIn\":{\"type\":\"reactHoc\",\"name\":\"withShowIfLoggedIn\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withResetPasswordButton\":{\"type\":\"reactHoc\",\"name\":\"withResetPasswordButton\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"initializeSystemCore\":{\"type\":\"reactHoc\",\"name\":\"initializeSystemCore\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withLoginStatus\":{\"type\":\"reactHoc\",\"name\":\"withLoginStatus\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withShowIfNotLoggedIn\":{\"type\":\"reactHoc\",\"name\":\"withShowIfNotLoggedIn\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./SystemCore.map"],"mappings":"yMAA8E,SAAgB,EAAY,EAAO,CACjH,IAAM,EAAU,EAAK,CAAC,MAAM,OAAO,OAAO,CAAC,GAAG,EAAO,CAAC,CAAC,CAAC,CAClD,EAAa,GAAU,CAC1B,OAAO,GAAW,aAAY,EAAS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