{"version":3,"file":"DynamicViewportHeight.CoAtCQQb.mjs","names":["useState","useCallback","useMemo"],"sources":["https:/framerusercontent.com/modules/cjXihN5m5coJIwS957j3/USTYdyBwaHItfEWZH9qF/DynamicViewportHeight.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{forwardRef,startTransition,useCallback,useEffect,useMemo,useState}from\"react\";/**\n * @framerDisableUnlink\n */export function withDynamicViewportHeight(Component){return props=>{const[dvh,setDvh]=useState(\"100vh\");useEffect(()=>{const updateDvh=()=>{const vh=window.innerHeight*.01;document.documentElement.style.setProperty(\"--dvh\",`${vh}px`);setDvh(`${window.innerHeight}px`);};updateDvh();window.addEventListener(\"resize\",updateDvh);return()=>window.removeEventListener(\"resize\",updateDvh);},[]);return /*#__PURE__*/_jsx(Component,{...props,style:{...props.style,height:dvh}});};}export function withSmallViewportHeight(Component){return props=>{const[svh,setSvh]=useState(\"100vh\");useEffect(()=>{const setInitialSvh=()=>{const vh=window.innerHeight*.01;document.documentElement.style.setProperty(\"--svh\",`${vh}px`);setSvh(`${window.innerHeight}px`);};setInitialSvh();// We're not adding any resize listeners to keep it static\n},[]);return /*#__PURE__*/_jsx(Component,{...props,style:{...props.style,height:svh}});};}export function withBackToTopAfterFourthStory(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const[isVisible,setIsVisible]=useState(false);const updateVisibility=useCallback(()=>{if(typeof window===\"undefined\"||typeof document===\"undefined\"){return;}const grid=document.getElementById(\"news-story-grid\");if(!grid){startTransition(()=>setIsVisible(false));return;}const articles=grid.querySelectorAll(\"article\");if(articles.length<4){startTransition(()=>setIsVisible(false));return;}const fourthArticle=articles[3];const shouldShow=fourthArticle.getBoundingClientRect().top<=0;startTransition(()=>{setIsVisible(previous=>previous===shouldShow?previous:shouldShow);});},[]);useEffect(()=>{if(typeof window===\"undefined\"||typeof document===\"undefined\"){return;}updateVisibility();window.addEventListener(\"scroll\",updateVisibility,{passive:true});window.addEventListener(\"resize\",updateVisibility);return()=>{window.removeEventListener(\"scroll\",updateVisibility);window.removeEventListener(\"resize\",updateVisibility);};},[updateVisibility]);const mergedStyle=useMemo(()=>({...props.style,opacity:isVisible?1:0,translate:isVisible?\"0 0\":\"0 8px\",transition:\"opacity 0.2s ease, translate 0.2s ease\",pointerEvents:isVisible?props.style?.pointerEvents??\"auto\":\"none\"}),[isVisible,props.style]);return /*#__PURE__*/_jsx(Component,{ref:ref,...props,\"aria-hidden\":!isVisible,tabIndex:isVisible?props.tabIndex:-1,style:mergedStyle});});}\nexport const __FramerMetadata__ = {\"exports\":{\"withSmallViewportHeight\":{\"type\":\"reactHoc\",\"name\":\"withSmallViewportHeight\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withBackToTopAfterFourthStory\":{\"type\":\"reactHoc\",\"name\":\"withBackToTopAfterFourthStory\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withDynamicViewportHeight\":{\"type\":\"reactHoc\",\"name\":\"withDynamicViewportHeight\",\"annotations\":{\"framerContractVersion\":\"1\",\"framerDisableUnlink\":\"\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./DynamicViewportHeight.map"],"mappings":"mKAE4d,SAAgB,EAAwB,EAAU,CAAC,MAAO,IAAO,CAAC,GAAK,CAAC,EAAI,GAAQA,EAAS,OAAO,EAC1jB,OAD4jB,MAAc,MAAyB,CAAC,IAAM,EAAG,EAAO,YAAY,IAAI,SAAS,gBAAgB,MAAM,YAAY,QAAQ,GAAG,EAAG,GAAG,EAAE,EAAO,GAAG,EAAO,YAAY,GAAG,CAAE,EAAE,CAAc,CAC1vB,EAAE,CAAC,CAAC,EAAsB,EAAK,EAAU,CAAC,GAAG,EAAM,MAAM,CAAC,GAAG,EAAM,MAAM,OAAO,CAAG,CAAC,CAAC,CAAE,CAAE,CAAC,SAAgB,EAA8B,EAAU,CAAC,OAAoB,GAAY,EAAM,IAAM,CAAC,GAAK,CAAC,EAAU,GAAcA,EAAS,EAAK,EAAQ,EAAiB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