{"version":3,"file":"PageLoad.CSAsLGgj.mjs","names":["useRef"],"sources":["https:/framerusercontent.com/modules/WA2UKyINvJBL7mZx0itK/am0fM5ue8oyymibamaJl/PageLoad.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useRef}from\"react\";import{createStore}from\"https://framer.com/m/framer/store.js@^1.0.0\";const useStore=createStore({randomNumber:null,loadState:0});export function handleImageLoading(ref,setStore){if(ref.current){document.body.style.overflow=\"hidden\";const images=ref.current.querySelectorAll(\"img\");let loadedCount=0;const totalImages=images.length;const handleLoad=()=>{loadedCount+=1;if(loadedCount===totalImages||totalImages===0){setTimeout(()=>{document.body.style.overflow=\"scroll\";setStore({loadState:1});},300);}};const handleError=()=>{loadedCount+=1;if(loadedCount===totalImages||totalImages===0){setTimeout(()=>{document.body.style.overflow=\"scroll\";setStore({loadState:1});},300);}};if(totalImages===0){handleLoad();}else{images.forEach(img=>{if(img.complete){handleLoad();}else{img.onload=handleLoad;img.onerror=handleError;}});}// Cleanup function to remove event listeners\nreturn()=>{document.body.style.overflow=\"scroll\";images.forEach(img=>{img.onload=null;img.onerror=null;});};}}export function withSetLoadComplete(Component){return props=>{const[store]=useStore();const loadComplete=store.loadState===1||store.loadState===2;return /*#__PURE__*/_jsx(Component,{...props,loadComplete:loadComplete});};}export function withSetLoader(Component){return props=>{const[store,setStore]=useStore();const loadComplete=store.loadState===1||store.loadState===2;useEffect(()=>{setStore({loadState:0});return()=>{setStore({loadState:0});};},[]);return /*#__PURE__*/_jsx(Component,{...props,variant:loadComplete?\"Complete\":\"Loading\"});};}export function withSetLoaderState(Component){return props=>{const[store,setStore]=useStore();const loadComplete=store.loadState===1||store.loadState===2;useEffect(()=>{setTimeout(()=>{setStore({loadState:1});},300);},[]);return /*#__PURE__*/_jsx(Component,{...props,variant:loadComplete?\"Complete\":\"Loading\"});};}export function withShuffleHeroImage(Component){return props=>{const[store,setStore]=useStore();const componentRef=useRef(null);useEffect(()=>{const randomNumber=Math.floor(Math.random()*5)+1// Generates a random number between 1 and 5\n;setStore({randomNumber});setTimeout(()=>{handleImageLoading(componentRef,setStore);},1);},[componentRef,setStore]);const loadComplete=store.loadState===1||store.loadState===2;return /*#__PURE__*/_jsx(Component,{...props,ref:componentRef,heroVisible:loadComplete,bgImgPrimaryVisible:!loadComplete||store.randomNumber===1,bgImg2Visible:!loadComplete||store.randomNumber===2,bgImg3Visible:!loadComplete||store.randomNumber===3,bgImg4Visible:!loadComplete||store.randomNumber===4,bgImg5Visible:!loadComplete||store.randomNumber===5});};}export function withAnimateHero(Component){return props=>{const[store,setStore]=useStore();const componentRef=useRef(null);useEffect(()=>{handleImageLoading(componentRef,setStore);},[componentRef,setStore]);return /*#__PURE__*/_jsx(Component,{...props,ref:componentRef,heroVisible:store.loadState===1||store.loadState===2});};}\nexport const __FramerMetadata__ = {\"exports\":{\"withSetLoader\":{\"type\":\"reactHoc\",\"name\":\"withSetLoader\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withSetLoadComplete\":{\"type\":\"reactHoc\",\"name\":\"withSetLoadComplete\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withAnimateHero\":{\"type\":\"reactHoc\",\"name\":\"withAnimateHero\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"handleImageLoading\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withShuffleHeroImage\":{\"type\":\"reactHoc\",\"name\":\"withShuffleHeroImage\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withSetLoaderState\":{\"type\":\"reactHoc\",\"name\":\"withSetLoaderState\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./PageLoad.map"],"mappings":"iLAAgN,SAAgB,EAAmB,EAAI,EAAS,CAAC,GAAG,EAAI,QAAQ,CAAC,SAAS,KAAK,MAAM,SAAS,SAAS,IAAM,EAAO,EAAI,QAAQ,iBAAiB,MAAM,CAAK,EAAY,EAAQ,EAAY,EAAO,OAAa,MAAe,CAAC,GAAa,GAAK,IAAc,GAAa,IAAc,IAAG,eAAe,CAAC,SAAS,KAAK,MAAM,SAAS,SAAS,EAAS,CAAC,UAAU,EAAE,CAAC,EAAG,IAAI,EAAU,MAAgB,CAAC,GAAa,GAAK,IAAc,GAAa,IAAc,IAAG,eAAe,CAAC,SAAS,KAAK,MAAM,SAAS,SAAS,EAAS,CAAC,UAAU,EAAE,CAAC,EAAG,IAAI,EAC/uB,OADsvB,IAAc,EAAG,GAAY,CAAO,EAAO,QAAQ,GAAK,CAAI,EAAI,SAAU,GAAY,EAAO,EAAI,OAAO,EAAW,EAAI,QAAQ,IAAe,KAC13B,CAAC,SAAS,KAAK,MAAM,SAAS,SAAS,EAAO,QAAQ,GAAK,CAAC,EAAI,OAAO,KAAK,EAAI,QAAQ,MAAO,GAC6a,SAAgB,EAAgB,EAAU,CAAC,MAAO,IAAO,CAAC,GAAK,CAAC,EAAM,GAAU,GAAU,CAAO,EAAaA,EAAO,KAAK,CAAqF,OAApF,MAAc,CAAC,EAAmB,EAAa,EAAS,EAAG,CAAC,EAAa,EAAS,CAAC,CAAqB,EAAK,EAAU,CAAC,GAAG,EAAM,IAAI,EAAa,YAAY,EAAM,YAAY,GAAG,EAAM,YAAY,EAAE,CAAC,qBAF9yB,IAAoC,IAAqE,CAAM,EAAS,EAAY,CAAC,aAAa,KAAK,UAAU,EAAE,CAAC"}