{"version":3,"file":"AccountMenu.CwP3-mDv.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/pjmE628CdrLWdmDoa5sF/BWVhsXFGmF0uTv8qiIYb/AccountMenu.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{forwardRef,useEffect,useState}from\"react\";import{useIsStaticRenderer}from\"framer\";// Account state for the site header. The BookingKoala account frame on /login reports\n// whether the customer is logged in (see BookingEmbed); the last report is kept here\n// for 30 days so every page's header can show \"Your Account\" instead of \"Login / Sign Up\".\n// A stale \"logged in\" only sends people to /login, where the frame shows the login form\n// and reports the real state.\nconst KEY=\"hhcAccount\";const EVENT=\"hhc-account\";const MAX_AGE=30*24*60*60*1e3;function readLoggedIn(){if(typeof window===\"undefined\")return false;try{const saved=JSON.parse(window.localStorage.getItem(KEY)||\"null\");return!!saved&&saved.in===true&&Date.now()-saved.at<MAX_AGE;}catch{return false;}}function forgetLogin(){try{window.localStorage.removeItem(KEY);}catch{}window.dispatchEvent(new CustomEvent(EVENT));}function useLoggedIn(){// Starts logged out to match the prerendered page, then reads the saved state\nconst[loggedIn,setLoggedIn]=useState(false);useEffect(()=>{const update=()=>setLoggedIn(readLoggedIn());update();window.addEventListener(EVENT,update);window.addEventListener(\"storage\",update);return()=>{window.removeEventListener(EVENT,update);window.removeEventListener(\"storage\",update);};},[]);return loggedIn;}// Overrides pass Framer's ref through (forwardRef): the \"Your Account\" dropdown is a\n// relative overlay that anchors to the trigger through that ref.\n// Shown only to logged-out visitors (\"Login / Sign Up\"). Both states show on the canvas.\nexport function withLoggedOut(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const isStatic=useIsStaticRenderer();const loggedIn=useLoggedIn();if(!isStatic&&loggedIn)return null;return /*#__PURE__*/_jsx(Component,{...props,ref:ref});});}// Shown only to logged-in customers (the \"Your Account\" menu)\nexport function withLoggedIn(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const isStatic=useIsStaticRenderer();const loggedIn=useLoggedIn();if(!isStatic&&!loggedIn)return null;return /*#__PURE__*/_jsx(Component,{...props,ref:ref});});}// Account links: open /login with the matching BookingKoala page in its frame.\n// Logged-in only, so they can also be used as plain rows in the phone drawer.\nfunction accountLink(page){return Component=>/*#__PURE__*/forwardRef((props,ref)=>{const isStatic=useIsStaticRenderer();const loggedIn=useLoggedIn();if(!isStatic&&!loggedIn)return null;const go=()=>{if(page===\"logout\")forgetLogin();window.location.href=`/login?account=${page}`;};return /*#__PURE__*/_jsx(Component,{...props,ref:ref,role:\"link\",tabIndex:0,onClick:e=>{props.onClick?.(e);go();},onKeyDown:e=>{if(e.key===\"Enter\"||e.key===\" \"){e.preventDefault();go();}},style:{...props.style,cursor:\"pointer\"}});});}export function withAccountDashboard(Component){return accountLink(\"dashboard\")(Component);}export function withAccountInfo(Component){return accountLink(\"info\")(Component);}export function withAccountNotifications(Component){return accountLink(\"notifications\")(Component);}export function withAccountLogout(Component){return accountLink(\"logout\")(Component);}\nexport const __FramerMetadata__ = {\"exports\":{\"withAccountDashboard\":{\"type\":\"reactHoc\",\"name\":\"withAccountDashboard\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withAccountNotifications\":{\"type\":\"reactHoc\",\"name\":\"withAccountNotifications\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withAccountLogout\":{\"type\":\"reactHoc\",\"name\":\"withAccountLogout\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withAccountInfo\":{\"type\":\"reactHoc\",\"name\":\"withAccountInfo\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withLoggedOut\":{\"type\":\"reactHoc\",\"name\":\"withLoggedOut\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withLoggedIn\":{\"type\":\"reactHoc\",\"name\":\"withLoggedIn\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./AccountMenu.map"],"mappings":"gMAK+E,SAAS,GAAc,CAAC,GAAU,IAAS,OAAY,MAAO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