{"version":3,"file":"WeeklyNudgeFooterPlacement.TaJS9kTH.mjs","names":["React.useRef","React.useState","React.useId","React.useMemo","React.useCallback","__esmMin","ie","init_ssg_sandbox_shims","te","ne","_e","Ha","pe","c","init_jsx_runtime","ce","init_npm_react_18_3_1","de","window","init_framer_DcGZRLrs","addPropertyControls","RenderTarget","ControlType","init_WeeklyNudge","WeeklyNudge","WeeklyNudgeFooterPlacement","props","rootRef","hostRef","observerRef","hiddenControlsRef","portalHost","setPortalHost","portalBare","setPortalBare","id","ownerId","isCanvas","isVisible","element","node","styles","rect","cleanupCurrentPlacement","snapshot","findOwningScope","root","cursor","visibleFooter","footer","hidePanelFormControls","controls","panel","hidden","el","ensurePlacement","enabled","owning","existingOwnedHost","scope","HOST_ATTR","OWNER_ATTR","host","hostOwner","ownerRoot","ROOT_ATTR","headingCandidates","hostParent","insertBefore","nextBare","newsletterPanel","firstElement","frame","schedule","observer","onResize","style","init_WeeklyNudgeFooterPlacement","init_npm_react_dom_18_3_1"],"sources":["https:/framerusercontent.com/modules/w11GlLfhZJO3CjhKebFT/97VvcTrBusGzGgYxxeNR/WeeklyNudgeFooterPlacement.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import*as React from\"react\";// @ts-ignore\nimport{createPortal}from\"react-dom\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";import WeeklyNudge from\"https://framerusercontent.com/modules/3VxYj1a4M53jKpDzc7do/u0KT6a8yPLFaTivuFltG/WeeklyNudge.js\";const HOST_ATTR=\"data-weekly-nudge-placement-host\";const OWNER_ATTR=\"data-weekly-nudge-placement-owner\";const ROOT_ATTR=\"data-weekly-nudge-placement-root\";/**\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight auto\n */export default function WeeklyNudgeFooterPlacement(props={}){const{enabled=true,style}=props;const rootRef=React.useRef(null);const hostRef=React.useRef(null);const observerRef=React.useRef(null);const hiddenControlsRef=React.useRef([]);const[portalHost,setPortalHost]=React.useState(null);const[portalBare,setPortalBare]=React.useState(false);const id=React.useId();const ownerId=React.useMemo(()=>`weekly-nudge-placement-${id.replace(/:/g,\"\")}`,[id]);const isCanvas=RenderTarget.current()===RenderTarget.canvas;const isVisible=React.useCallback(element=>{if(!element||typeof window===\"undefined\")return false;const node=element;const styles=window.getComputedStyle(node);if(styles.display===\"none\"||styles.visibility===\"hidden\")return false;const rect=node.getBoundingClientRect();return rect.width>0&&rect.height>0;},[]);const cleanupCurrentPlacement=React.useCallback(()=>{hiddenControlsRef.current.forEach(snapshot=>{snapshot.element.style.visibility=snapshot.visibility;});hiddenControlsRef.current=[];if(hostRef.current&&hostRef.current.parentNode){hostRef.current.parentNode.removeChild(hostRef.current);}hostRef.current=null;React.startTransition(()=>{setPortalHost(null);setPortalBare(false);});},[]);const findOwningScope=React.useCallback(()=>{const root=rootRef.current;if(!root)return null;let cursor=root.parentElement;while(cursor){const footers=Array.from(cursor.querySelectorAll(\".od-footer, .ox-footer, footer\"));const visibleFooter=footers.find(footer=>isVisible(footer));if(visibleFooter){return{scope:cursor,footer:visibleFooter};}cursor=cursor.parentElement;}return null;},[isVisible]);const hidePanelFormControls=React.useCallback(panel=>{const controls=panel.querySelectorAll(\"form, input, button, select, textarea\");const hidden=[];controls.forEach(node=>{const el=node;const inLeadMagnet=!!el.closest(\"[data-framer-name*='Lead'], [class*='lead-magnet'], [id*='lead']\");if(inLeadMagnet)return;hidden.push({element:el,visibility:el.style.visibility});el.style.visibility=\"hidden\";});hiddenControlsRef.current=hidden;},[]);const ensurePlacement=React.useCallback(()=>{if(typeof window===\"undefined\")return;if(!enabled){cleanupCurrentPlacement();return;}if(!isVisible(rootRef.current))return;const owning=findOwningScope();if(!owning||!isVisible(owning.scope))return;const{scope,footer}=owning;const existingOwnedHost=scope.querySelector(`[${HOST_ATTR}=\"true\"][${OWNER_ATTR}=\"${ownerId}\"]`);if(existingOwnedHost){hostRef.current=existingOwnedHost;React.startTransition(()=>setPortalHost(existingOwnedHost));return;}const hasOtherVisiblePlacement=Array.from(scope.querySelectorAll(`[${HOST_ATTR}=\"true\"]`)).some(node=>{const host=node;const hostOwner=host.getAttribute(OWNER_ATTR);if(!hostOwner||hostOwner===ownerId||!host.isConnected)return false;const ownerRoot=document.querySelector(`[${ROOT_ATTR}=\"${hostOwner}\"]`);return isVisible(ownerRoot);});if(hasOtherVisiblePlacement)return;const headingCandidates=Array.from(scope.querySelectorAll(\"h1, h2, h3, p, span\")).filter(node=>!node.closest(`[${HOST_ATTR}=\"true\"]`)&&(node.textContent||\"\").trim()===\"Big Inbox Energy\"&&isVisible(node));let hostParent=footer.parentElement||scope;let insertBefore=footer;let nextBare=false;const newsletterPanel=scope.querySelector('section[aria-label=\"Newsletter signup\"]');if(newsletterPanel&&isVisible(newsletterPanel)){const firstElement=newsletterPanel.firstElementChild;hostParent=newsletterPanel;insertBefore=firstElement?.nextSibling||null;nextBare=true;hidePanelFormControls(newsletterPanel);}else if(headingCandidates.length>0){const panel=headingCandidates[0].closest(\"section, article\")||headingCandidates[0].closest(\"div\");if(panel&&isVisible(panel)){const firstElement=panel.firstElementChild;hostParent=panel;insertBefore=firstElement?.nextSibling||null;nextBare=true;hidePanelFormControls(panel);}}const host=document.createElement(\"div\");host.setAttribute(HOST_ATTR,\"true\");host.setAttribute(OWNER_ATTR,ownerId);host.style.position=\"relative\";host.style.width=\"100%\";hostParent.insertBefore(host,insertBefore);hostRef.current=host;React.startTransition(()=>{setPortalBare(nextBare);setPortalHost(host);});},[cleanupCurrentPlacement,enabled,findOwningScope,hidePanelFormControls,isVisible,ownerId]);React.useEffect(()=>{if(typeof window===\"undefined\")return;if(isCanvas)return;let frame=0;const schedule=()=>{if(frame)return;frame=window.requestAnimationFrame(()=>{frame=0;ensurePlacement();});};schedule();const owning=findOwningScope();const scope=owning?.scope||rootRef.current?.parentElement||document.body;if(scope){const observer=new MutationObserver(()=>schedule());observer.observe(scope,{childList:true,subtree:true});observerRef.current=observer;}const onResize=()=>schedule();window.addEventListener(\"resize\",onResize);return()=>{if(frame)window.cancelAnimationFrame(frame);window.removeEventListener(\"resize\",onResize);if(observerRef.current)observerRef.current.disconnect();observerRef.current=null;cleanupCurrentPlacement();};},[cleanupCurrentPlacement,ensurePlacement,findOwningScope,isCanvas]);React.useEffect(()=>{if(!enabled)cleanupCurrentPlacement();},[cleanupCurrentPlacement,enabled]);return /*#__PURE__*/_jsxs(\"div\",{ref:rootRef,\"data-weekly-nudge-placement-root\":ownerId,style:{position:\"relative\",width:\"100%\",minHeight:1,...style},children:[/*#__PURE__*/_jsx(\"style\",{children:'section[aria-label=\"Newsletter signup\"]{background:#fff!important;color:#203b47!important}section[aria-label=\"Newsletter signup\"] h2{display:none!important}'}),!isCanvas&&enabled&&portalHost?/*#__PURE__*/createPortal(/*#__PURE__*/_jsx(WeeklyNudge,{bare:portalBare}),portalHost):null]});}addPropertyControls(WeeklyNudgeFooterPlacement,{enabled:{type:ControlType.Boolean,title:\"Enabled\",defaultValue:true,enabledTitle:\"On\",disabledTitle:\"Off\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"WeeklyNudgeFooterPlacement\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}"],"mappings":"A,6SAIG,SAAwByB,EAA2B,EAAM,CAAC,EAAE,CAAC,GAAK,CAAC,UAAQ,GAAK,SAAOC,EAAYC,EAAQ3B,EAAa,IAAI,EAAQ4B,EAAQ5B,EAAa,IAAI,EAAQ6B,EAAY7B,EAAa,IAAI,EAAQ8B,EAAkB9B,EAAa,CAAC,CAAC,EAAO,CAAC+B,EAAWC,GAAe/B,EAAe,IAAI,EAAO,CAACgC,EAAWC,GAAejC,EAAe,EAAK,EAAQkC,EAAGjC,EAAY,EAAQkC,EAAQjC,MAAkB,0BAA0BgC,EAAG,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