{"version":3,"file":"AuthStore.MoHwgwFN.mjs","names":["useState","React.useState","__legacyOverrideHOC_DataObserverContext","_jsx"],"sources":["https:/framerusercontent.com/modules/vj7bFUjvEQFgEzNBkdoG/vf3CKm378wlVcBk7IhSU/createStore.js","https:/framer.com/m/framer/store.js","https:/framerusercontent.com/modules/Dg1LQFroae2DnvOVU7lx/RqWuGarHNPYJVjhZEBni/AuthStore.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{createStore}from\"https://framer.com/m/framer/store.js\";import*as React from\"react\";const AUTH_KEY=\"DS_IS_LOGGED_IN\";// typeof window 체크 추가\nfunction readAuthStamp(){try{if(typeof window===\"undefined\")return false;return localStorage.getItem(AUTH_KEY)===\"true\";}catch{return false;}}export const useAuthStore=createStore({isLoggedIn:readAuthStamp()});// ────────────────────────────────────────────\n// 공통 훅: localStorage 직접 읽기 + 이벤트 리스닝\n// ────────────────────────────────────────────\nfunction useAuthState(){const[isLoggedIn,setIsLoggedIn]=React.useState(()=>readAuthStamp());React.useEffect(()=>{// 마운트 즉시 강제 읽기 (캐시 우회)\nsetIsLoggedIn(readAuthStamp());const onCustom=e=>{setIsLoggedIn(e.detail.isLoggedIn);};const onStorage=e=>{if(e.key===AUTH_KEY)setIsLoggedIn(readAuthStamp());};window.addEventListener(\"authStateChanged\",onCustom);window.addEventListener(\"storage\",onStorage);return()=>{window.removeEventListener(\"authStateChanged\",onCustom);window.removeEventListener(\"storage\",onStorage);};},[]);return isLoggedIn;}// ────────────────────────────────────────────\n// 공통 레이아웃/네비게이션 바에 붙이기\n// 페이지가 바뀔 때마다 현재 URL을 자동 저장\n// ────────────────────────────────────────────\nexport function trackCurrentPage(){React.useEffect(()=>{const save=()=>{const here=window.location.pathname;if(!here.startsWith(\"/login\")){sessionStorage.setItem(\"redirectAfterLogin\",here);}};save();window.addEventListener(\"popstate\",save);const origPush=history.pushState.bind(history);const origReplace=history.replaceState.bind(history);history.pushState=(...args)=>{origPush(...args);save();};history.replaceState=(...args)=>{origReplace(...args);save();};return()=>{window.removeEventListener(\"popstate\",save);history.pushState=origPush;history.replaceState=origReplace;};},[]);return{};}// ────────────────────────────────────────────\n// 로그인 유저만 보이기\n// ────────────────────────────────────────────\nexport function showWhenAuthed(){const isLoggedIn=useAuthState();return{visible:isLoggedIn,style:{display:isLoggedIn?\"flex\":\"none\",pointerEvents:isLoggedIn?undefined:\"none\"}};}// ────────────────────────────────────────────\n// 비로그인 유저만 보이기\n// ────────────────────────────────────────────\nexport function showWhenGuest(){const isLoggedIn=useAuthState();return{visible:!isLoggedIn,style:{display:!isLoggedIn?\"flex\":\"none\",pointerEvents:!isLoggedIn?undefined:\"none\"}};}// ────────────────────────────────────────────\n// 로그아웃 후 /login으로 이동\n// ────────────────────────────────────────────\nexport function logoutAndGoLogin(){return{onTap(){try{localStorage.removeItem(AUTH_KEY);sessionStorage.removeItem(\"redirectAfterLogin\");}catch{}window.dispatchEvent(new CustomEvent(\"authStateChanged\",{detail:{isLoggedIn:false}}));window.location.href=\"/login\";}};}// ────────────────────────────────────────────\n// 로그인 유저만 보이기 + 탭하면 로그아웃 후 새로고침\n// ────────────────────────────────────────────\nexport function showAuthedAndLogout(){const isLoggedIn=useAuthState();return{visible:isLoggedIn,style:{display:isLoggedIn?\"flex\":\"none\",pointerEvents:isLoggedIn?undefined:\"none\"},onTap(){try{localStorage.removeItem(AUTH_KEY);sessionStorage.removeItem(\"redirectAfterLogin\");}catch{}window.dispatchEvent(new CustomEvent(\"authStateChanged\",{detail:{isLoggedIn:false}}));window.location.reload();}};}import{useContext as __legacyOverrideHOC_useContext}from\"react\";import{DataObserverContext as __legacyOverrideHOC_DataObserverContext}from\"framer\";export function withtrackCurrentPage(C){return props=>{__legacyOverrideHOC_useContext(__legacyOverrideHOC_DataObserverContext);return _jsx(C,{...props,...trackCurrentPage(props)});};}withtrackCurrentPage.displayName=\"trackCurrentPage\";export function withshowWhenAuthed(C){return props=>{__legacyOverrideHOC_useContext(__legacyOverrideHOC_DataObserverContext);return _jsx(C,{...props,...showWhenAuthed(props)});};}withshowWhenAuthed.displayName=\"showWhenAuthed\";export function withshowWhenGuest(C){return props=>{__legacyOverrideHOC_useContext(__legacyOverrideHOC_DataObserverContext);return _jsx(C,{...props,...showWhenGuest(props)});};}withshowWhenGuest.displayName=\"showWhenGuest\";export function withlogoutAndGoLogin(C){return props=>{__legacyOverrideHOC_useContext(__legacyOverrideHOC_DataObserverContext);return _jsx(C,{...props,...logoutAndGoLogin(props)});};}withlogoutAndGoLogin.displayName=\"logoutAndGoLogin\";export function withshowAuthedAndLogout(C){return props=>{__legacyOverrideHOC_useContext(__legacyOverrideHOC_DataObserverContext);return _jsx(C,{...props,...showAuthedAndLogout(props)});};}withshowAuthedAndLogout.displayName=\"showAuthedAndLogout\";\nexport const __FramerMetadata__ = {\"exports\":{\"withshowWhenAuthed\":{\"type\":\"reactHoc\",\"name\":\"withshowWhenAuthed\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"useAuthStore\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withlogoutAndGoLogin\":{\"type\":\"reactHoc\",\"name\":\"withlogoutAndGoLogin\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"showWhenGuest\":{\"type\":\"override\",\"name\":\"showWhenGuest\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withshowAuthedAndLogout\":{\"type\":\"reactHoc\",\"name\":\"withshowAuthedAndLogout\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"showAuthedAndLogout\":{\"type\":\"override\",\"name\":\"showAuthedAndLogout\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"logoutAndGoLogin\":{\"type\":\"override\",\"name\":\"logoutAndGoLogin\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"trackCurrentPage\":{\"type\":\"override\",\"name\":\"trackCurrentPage\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"showWhenAuthed\":{\"type\":\"override\",\"name\":\"showWhenAuthed\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withshowWhenGuest\":{\"type\":\"reactHoc\",\"name\":\"withshowWhenGuest\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withtrackCurrentPage\":{\"type\":\"reactHoc\",\"name\":\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