{"version":3,"file":"PopupFrequency.BitbrBuD.mjs","names":["useState","useRef"],"sources":["https:/framerusercontent.com/modules/tc3H5306nKWv3CKjWTsQ/OyfCwNYDtEFtPNr25XKg/PopupFrequency.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useRef,useState}from\"react\";/* ============================================================\n   CONFIG — edit these to change behavior (this replaces the\n   \"property control\" panel, since overrides can't expose one)\n   ============================================================\n\n   mode:\n     \"once\"    → allow the popup one time ever, per browser\n     \"daily\"   → allow once per 24-hour period\n     \"session\" → allow once per browser tab session\n     \"always\"  → allow on every single page load, no gating\n\n   delayMs: how long to wait after mount, if eligible, before\n            the popup is allowed to actually appear/be clickable\n\n   storageKey: unique key so this doesn't collide with other\n               storage usage on the site\n\n   This override does NOT need your \"visible\" Variable to\n   default to true anymore. It now fully drives the \"visible\"\n   prop itself every render:\n   1. Frequency — whether this visit is eligible at all.\n   2. Delay — even if eligible, stays false for delayMs after\n      mount.\n   3. Close — the native close callback is intercepted, so once\n      the user closes it, it stays closed for the rest of this\n      visit (won't re-open itself), while still calling through\n      to whatever your close button normally does.\n   4. Click-blocking — since this layer has a fixed full-screen\n      size on canvas, we merge pointer-events: none into its\n      style whenever it isn't currently visible, so the empty\n      box never blocks clicks on the page underneath.\n\n   You can set the Variable's default to false (or leave it —\n   it no longer matters, since this always overrides it).\n\n   Important: eligibility is only checked AFTER mount (inside an\n   effect), never during the initial render. Framer pre-renders\n   pages on the server, where localStorage/sessionStorage don't\n   exist — checking them during render causes a server/client\n   mismatch (React error #418) that breaks hydration and makes\n   the whole popup unresponsive. Both the server and the client's\n   first paint now render the same safe \"undecided\" default;\n   the real check only happens once safely in the browser.\n\n   Because the override now owns the delay, you should remove\n   or zero-out any delay set on your native Page Load trigger —\n   otherwise you'd effectively have two delays stacked.\n============================================================ */const CONFIG={mode:\"once\",delayMs:3e3,storageKey:\"ymca_popup_main\"};// ---- storage helpers ----\nfunction getStorage(mode){return mode===\"session\"?sessionStorage:localStorage;}function canShow(){if(CONFIG.mode===\"always\")return true;try{const storage=getStorage(CONFIG.mode);const raw=storage.getItem(CONFIG.storageKey);if(!raw)return true;if(CONFIG.mode===\"once\"||CONFIG.mode===\"session\"){// presence of the key at all means it's already been shown\nreturn false;}if(CONFIG.mode===\"daily\"){const lastShown=parseInt(raw,10);if(isNaN(lastShown))return true;const dayInMs=24*60*60*1e3;return Date.now()-lastShown>=dayInMs;}return true;}catch(e){// storage blocked (e.g. private browsing edge cases) — fail safe, don't show\nreturn false;}}function markShown(){if(CONFIG.mode===\"always\")return;try{const storage=getStorage(CONFIG.mode);storage.setItem(CONFIG.storageKey,Date.now().toString());}catch(e){// ignore\n}}// ---- the override ----\nexport function withPopupFrequency(Component){return props=>{// Start as null (\"undecided\") so the server render and the\n// client's very first render match exactly — storage can only\n// be safely read after mount, inside an effect.\nconst[eligible,setEligible]=useState(null);const[revealed,setRevealed]=useState(false);const[userClosed,setUserClosed]=useState(false);useEffect(()=>{setEligible(canShow());},[]);useEffect(()=>{if(eligible!==true)return;const timer=setTimeout(()=>setRevealed(true),CONFIG.delayMs);return()=>clearTimeout(timer);},[eligible]);useEffect(()=>{if(revealed)markShown();},[revealed]);// We now fully drive \"visible\" ourselves each render — the\n// Variable's default in Framer no longer matters, since this\n// always overrides it. The only way effectiveVisible goes\n// false again after opening is the user actually closing it.\nconst effectiveVisible=eligible===true&&revealed&&!userClosed;// Intercept the native close callback so we know to stay\n// closed for the rest of this visit, then pass the call\n// through so whatever the close button normally does still\n// happens.\nconst handleClose=async(...args)=>{setUserClosed(true);const originalClose=props.close;if(typeof originalClose===\"function\"){return originalClose(...args);}};// Framer generates its own full-screen, fixed-position wrapper\n// div around this layer (from its canvas position/size\n// settings) with a compiled CSS class — not an inline style.\n// That wrapper sits ABOVE the component we render, so no\n// props/style we pass to Component can ever reach it. The\n// only way to control it is to find it directly in the DOM\n// and toggle its pointer-events imperatively.\nconst anchorRef=useRef(null);useEffect(()=>{const node=anchorRef.current;if(!node)return;let parent=node.parentElement;while(parent){if(window.getComputedStyle(parent).position===\"fixed\"){parent.style.pointerEvents=effectiveVisible?\"\":\"none\";break;}parent=parent.parentElement;}},[effectiveVisible]);return /*#__PURE__*/_jsx(\"div\",{ref:anchorRef,style:{display:\"contents\"},children:/*#__PURE__*/_jsx(Component,{...props,visible:effectiveVisible,close:handleClose,style:{...props.style,pointerEvents:effectiveVisible?undefined:\"none\"}})});};}\nexport const __FramerMetadata__ = {\"exports\":{\"withPopupFrequency\":{\"type\":\"reactHoc\",\"name\":\"withPopupFrequency\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./PopupFrequency.map"],"mappings":"8IAgDA,SAAS,EAAW,EAAK,CAAC,OAAO,IAAO,UAAU,eAAe,aAAc,SAAS,GAAS,CAAC,GAAG,EAAO,OAAO,SAAS,MAAO,GAAK,GAAG,CAAuC,IAAM,EAA9B,EAAW,EAAO,KAAK,CAAmB,QAAQ,EAAO,WAAW,CAAC,GAAG,CAAC,EAAI,MAAO,GAAK,GAAG,EAAO,OAAO,QAAQ,EAAO,OAAO,UAC1R,MAAO,GAAO,GAAG,EAAO,OAAO,QAAQ,CAAC,IAAM,EAAU,SAAS,EAAI,GAAG,CAA4D,OAAxD,MAAM,EAAU,CAAQ,GAAuC,KAAK,KAAK,CAAC,GAA/B,KAAM,GAAG,IAA0C,MAAO,QAAc,CAC/L,MAAO,IAAQ,SAAS,GAAW,CAAI,KAAO,OAAO,SAAgB,GAAG,CAAe,EAAW,EAAO,KAAK,CAAS,QAAQ,EAAO,WAAW,KAAK,KAAK,CAAC,UAAU,CAAC,MAAU,GAEjL,SAAgB,EAAmB,EAAU,CAAC,MAAO,IAAO,CAG5D,GAAK,CAAC,EAAS,GAAaA,EAAS,KAAK,CAAM,CAAC,EAAS,GAAaA,EAAS,GAAM,CAAM,CAAC,EAAW,GAAeA,EAAS,GAAM,CAAC,MAAc,CAAC,EAAY,GA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