{"version":3,"file":"LoadingLogic.C33sOAl1.mjs","names":["useMemo","useCallback","useState"],"sources":["https:/framerusercontent.com/modules/VwE5AjqU5WDoLYjLA3Wc/ZEnocTDruUnTCzC2XCxM/LoadingLogic.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{forwardRef,startTransition,useCallback,useEffect,useMemo,useState}from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";const LOADER_CANONICAL_KEY=\"hasSeenLoader\";const PREVIOUS_PAGE_KEY=\"previousPage\";const LOADER_DECISION_EVENT=\"nutriveo-loading-logic\";const LOADER_COMPLETE_EVENT=\"nutriveo-loading-complete\";const LOADER_DURATION_MS=6800;const NAVBAR_ENTRANCE_DELAY_MS=150;const NAVBAR_ENTRANCE_DURATION_MS=480;function safeSetWindowLoaderFlag(shouldShow){if(typeof window===\"undefined\")return;window.__nutriveoShouldShowLoader=shouldShow;}function safeReadLocalStorage(key){if(typeof window===\"undefined\")return null;try{return window.localStorage.getItem(key);}catch(error){return null;}}function safeWriteLocalStorage(key,value){if(typeof window===\"undefined\")return false;try{window.localStorage.setItem(key,value);return true;}catch(error){return false;}}function resolveOneTimeLoaderDecision(storageKey){if(typeof window===\"undefined\")return false;try{const currentPage=`${window.location.pathname}${window.location.search}`;try{window.sessionStorage.getItem(PREVIOUS_PAGE_KEY);window.sessionStorage.setItem(PREVIOUS_PAGE_KEY,currentPage);}catch(error){// Ignore sessionStorage failures.\n}const hasSeenLoader=!!safeReadLocalStorage(storageKey);const shouldShow=!hasSeenLoader;safeSetWindowLoaderFlag(shouldShow);return shouldShow;}catch(error){// Fail open: if storage/navigation checks fail, show loader.\nsafeSetWindowLoaderFlag(true);return true;}}function resolveInitialHeroReleasedState(){if(typeof window===\"undefined\")return false;try{const loaderFlag=window.__nutriveoShouldShowLoader;if(loaderFlag===true)return false;if(loaderFlag===false)return true;return!!safeReadLocalStorage(LOADER_CANONICAL_KEY);}catch(error){return false;}}function adjustDelayNumber(delay){if(delay<5)return delay;return Math.max(0,delay-5.3);}function adjustTransitionValue(value){if(!value)return value;if(typeof value===\"object\"){if(typeof value.delay===\"number\"){return{...value,delay:adjustDelayNumber(value.delay)};}return value;}if(typeof value!==\"string\")return value;const trimmed=value.trim();const maybeJson=trimmed.startsWith(\"{\")||trimmed.startsWith(\"[\");if(maybeJson){try{const parsed=JSON.parse(trimmed);const adjusted=adjustTransitionValue(parsed);return JSON.stringify(adjusted);}catch(error){// Fall through to string replacement logic.\n}}const secondsRegex=/(\\d*\\.?\\d+)s(?![\\s\\S]*(\\d*\\.?\\d+)s)/;const match=value.match(secondsRegex);if(!match)return value;const lastSeconds=Number.parseFloat(match[1]);if(!Number.isFinite(lastSeconds)||lastSeconds<5)return value;const nextSeconds=adjustDelayNumber(lastSeconds);return value.replace(secondsRegex,`${nextSeconds}s`);}/**\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight fixed\n */export default function LoadingLogic(props){const resolvedStorageKey=useMemo(()=>props.storageKey||LOADER_CANONICAL_KEY,[props.storageKey]);const dispatchDecision=useCallback(shouldShow=>{if(typeof window===\"undefined\")return;window.dispatchEvent(new CustomEvent(LOADER_DECISION_EVENT,{detail:{shouldShow}}));},[]);useEffect(()=>{if(typeof window===\"undefined\")return;try{if(props.resetInPreview&&(RenderTarget.current()===RenderTarget.preview||RenderTarget.current()===RenderTarget.canvas)){try{window.localStorage.removeItem(resolvedStorageKey);}catch(error){// Ignore clear failures.\n}}const seen=safeReadLocalStorage(resolvedStorageKey);const shouldShow=!seen;safeSetWindowLoaderFlag(shouldShow);dispatchDecision(shouldShow);}catch(error){safeSetWindowLoaderFlag(true);dispatchDecision(true);}},[dispatchDecision,props.resetInPreview,resolvedStorageKey]);return /*#__PURE__*/_jsx(\"div\",{\"aria-hidden\":\"true\",style:{position:\"fixed\",width:0,height:0,opacity:0,overflow:\"hidden\",pointerEvents:\"none\",top:0,left:0}});}export function withOneTimeLoader(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const[shouldRender,setShouldRender]=useState(false);useEffect(()=>{if(typeof window===\"undefined\")return;let completeTimer=null;const shouldShow=resolveOneTimeLoaderDecision(LOADER_CANONICAL_KEY);safeSetWindowLoaderFlag(shouldShow);window.dispatchEvent(new CustomEvent(LOADER_DECISION_EVENT,{detail:{shouldShow}}));if(shouldShow){setShouldRender(true);completeTimer=window.setTimeout(()=>{safeWriteLocalStorage(LOADER_CANONICAL_KEY,\"true\");safeSetWindowLoaderFlag(false);window.dispatchEvent(new CustomEvent(LOADER_COMPLETE_EVENT));startTransition(()=>{setShouldRender(false);});},LOADER_DURATION_MS);}else{window.dispatchEvent(new CustomEvent(LOADER_COMPLETE_EVENT));}return()=>{if(completeTimer!==null){window.clearTimeout(completeTimer);}};},[]);if(!shouldRender){return null;}return /*#__PURE__*/_jsx(Component,{ref:ref,...props});});}export function withLoaderAwareHeroDelay(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const[released,setReleased]=useState(false);useEffect(()=>{if(typeof window===\"undefined\")return;const loaderFlag=window.__nutriveoShouldShowLoader;const hasSeenLoader=!!safeReadLocalStorage(LOADER_CANONICAL_KEY);const shouldWaitForLoader=loaderFlag===true||loaderFlag!==false&&!hasSeenLoader;if(!shouldWaitForLoader){setReleased(true);return;}const mountTimer=window.setTimeout(()=>{setReleased(true);},LOADER_DURATION_MS-2e3);return()=>{window.clearTimeout(mountTimer);};},[]);if(!released){return /*#__PURE__*/_jsx(\"div\",{\"aria-hidden\":\"true\",className:props.className,style:{...props.style||{},width:\"100%\",height:\"100%\",visibility:\"hidden\",pointerEvents:\"none\"}});}return /*#__PURE__*/_jsx(Component,{ref:ref,...props});});}export function withSkipLoaderDelay(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const nextProps={...props};if(\"transition\"in nextProps){nextProps.transition=adjustTransitionValue(nextProps.transition);}if(\"$control__transition\"in nextProps){nextProps.$control__transition=adjustTransitionValue(nextProps.$control__transition);}return /*#__PURE__*/_jsx(Component,{ref:ref,...nextProps});});}export function withLoaderAwareNavbarEntrance(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const[isVisible,setIsVisible]=useState(false);useEffect(()=>{if(typeof window===\"undefined\")return;let entranceTimer=null;let fallbackTimer=null;let shouldWaitForCompletion=false;let released=false;const revealWithSmallDelay=()=>{if(released)return;released=true;if(entranceTimer!==null){window.clearTimeout(entranceTimer);}entranceTimer=window.setTimeout(()=>{startTransition(()=>{setIsVisible(true);});},NAVBAR_ENTRANCE_DELAY_MS);};const onDecision=event=>{const customEvent=event;shouldWaitForCompletion=!!customEvent.detail?.shouldShow;if(!shouldWaitForCompletion){revealWithSmallDelay();}};const onComplete=()=>{if(shouldWaitForCompletion){revealWithSmallDelay();}};window.addEventListener(LOADER_DECISION_EVENT,onDecision);window.addEventListener(LOADER_COMPLETE_EVENT,onComplete);const initialFlag=window.__nutriveoShouldShowLoader;if(typeof initialFlag===\"boolean\"){shouldWaitForCompletion=initialFlag;if(!shouldWaitForCompletion){revealWithSmallDelay();}}else{fallbackTimer=window.setTimeout(()=>{if(released)return;const hasSeenLoader=!!safeReadLocalStorage(LOADER_CANONICAL_KEY);if(hasSeenLoader){revealWithSmallDelay();}},80);}return()=>{window.removeEventListener(LOADER_DECISION_EVENT,onDecision);window.removeEventListener(LOADER_COMPLETE_EVENT,onComplete);if(entranceTimer!==null){window.clearTimeout(entranceTimer);}if(fallbackTimer!==null){window.clearTimeout(fallbackTimer);}};},[]);const mergedStyle={...props.style,opacity:isVisible?1:0,transform:isVisible?`${props.style?.transform??\"\"}`.trim()||\"translate3d(0px, 0px, 0px)\":`${props.style?.transform??\"\"} translate3d(0px, -18px, 0px)`.trim(),transition:`${props.style?.transition?`${props.style.transition}, `:\"\"}opacity ${NAVBAR_ENTRANCE_DURATION_MS}ms ease, transform ${NAVBAR_ENTRANCE_DURATION_MS}ms ease`,pointerEvents:isVisible?props.style?.pointerEvents??\"auto\":\"none\",willChange:\"opacity, transform\"};return /*#__PURE__*/_jsx(Component,{ref:ref,...props,style:mergedStyle});});}addPropertyControls(LoadingLogic,{storageKey:{type:ControlType.String,title:\"Storage Key\",defaultValue:\"hasSeenLoader\"},resetInPreview:{type:ControlType.Boolean,title:\"Reset Preview\",defaultValue:false,enabledTitle:\"Yes\",disabledTitle:\"No\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"withOneTimeLoader\":{\"type\":\"reactHoc\",\"name\":\"withOneTimeLoader\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withSkipLoaderDelay\":{\"type\":\"reactHoc\",\"name\":\"withSkipLoaderDelay\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withLoaderAwareNavbarEntrance\":{\"type\":\"reactHoc\",\"name\":\"withLoaderAwareNavbarEntrance\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"default\":{\"type\":\"reactComponent\",\"name\":\"LoadingLogic\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"fixed\",\"framerSupportedLayoutHeight\":\"fixed\",\"framerContractVersion\":\"1\"}},\"withLoaderAwareHeroDelay\":{\"type\":\"reactHoc\",\"name\":\"withLoaderAwareHeroDelay\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./LoadingLogic.map"],"mappings":"kOAAue,SAAS,EAAwB,EAAW,CAAW,IAAS,SAAmB,EAAO,2BAA2B,EAAW,CAAC,SAAS,EAAqB,EAAI,CAAC,GAAU,IAAS,OAAY,OAAO,KAAK,GAAG,CAAC,OAAO,EAAO,aAAa,QAAQ,CAAG,CAAE,MAAa,CAAC,OAAO,IAAK,CAAC,CAAC,SAAS,EAAsB,EAAI,EAAM,CAAC,GAAU,IAAS,OAAY,MAAO,GAAM,GAAG,CAAwC,OAAvC,EAAO,aAAa,QAAQ,EAAI,CAAK,EAAS,EAAK,MAAa,CAAC,MAAO,EAAM,CAAC,CAAC,SAAS,EAA6B,EAAW,CAAC,GAAU,IAAS,OAAY,MAAO,GAAM,GAAG,CAAC,IA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