{"version":3,"file":"ForceVideoAutoplay.CxCFIVeF.mjs","names":["useRef","useCallback","__esmMin","window","init_ssg_sandbox_shims","init_npm_react_18_3_1","de","ne","J","init_jsx_runtime","ce","init_framer_DJ_0WPVq","RenderTarget","forceVideoAutoplay","rootRef","WrappedComponent","Component","setWrappedRef","ref","node","root","disposed","retryId","configureAndPlay","playPromise","video","applyToVideos","videos","onVisibilityChange","observer","rest","props","style","forceHeaderVideoAutoplay","bindRef","forwardedRef","managed","delays","visible","r","play","state","reset","promise","delay","intersection","entry","entries","discover","ready","pause","playing","resume","mutation","init_ForceVideoAutoplay"],"sources":["https:/framerusercontent.com/modules/Qc2bcerFNKKdakztbYSW/AtM58CO6lsgvprXzqQeh/ForceVideoAutoplay.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{RenderTarget}from\"framer\";import{forwardRef,useCallback,useEffect,useRef}from\"react\";export function forceVideoAutoplay(Component){return /*#__PURE__*/forwardRef(function ForceVideoAutoplay(props,ref){const rootRef=useRef(null);const WrappedComponent=Component;const setWrappedRef=useCallback(node=>{if(typeof ref===\"function\"){ref(node);}else if(ref&&\"current\"in ref){ref.current=node;}},[ref]);useEffect(()=>{if(typeof window===\"undefined\")return;const root=rootRef.current;if(!root)return;let disposed=false;let retryId;const configureAndPlay=video=>{if(disposed)return;video.muted=true;video.defaultMuted=true;video.autoplay=true;video.playsInline=true;video.loop=true;video.preload=\"auto\";const playPromise=video.play();if(playPromise&&typeof playPromise.catch===\"function\"){playPromise.catch(()=>{if(!disposed){window.clearTimeout(retryId);retryId=window.setTimeout(()=>{if(!disposed)configureAndPlay(video);},300);}});}};const applyToVideos=()=>{if(disposed)return;const videos=Array.from(root.querySelectorAll(\"video\"));for(const video of videos){configureAndPlay(video);}};const onVisibilityChange=()=>{if(document.visibilityState===\"visible\")applyToVideos();};applyToVideos();const observer=new MutationObserver(applyToVideos);observer.observe(root,{childList:true,subtree:true});root.addEventListener(\"loadedmetadata\",applyToVideos,true);root.addEventListener(\"canplay\",applyToVideos,true);root.addEventListener(\"pause\",applyToVideos,true);document.addEventListener(\"visibilitychange\",onVisibilityChange);window.addEventListener(\"pageshow\",applyToVideos);window.addEventListener(\"focus\",applyToVideos);return()=>{disposed=true;window.clearTimeout(retryId);observer.disconnect();root.removeEventListener(\"loadedmetadata\",applyToVideos,true);root.removeEventListener(\"canplay\",applyToVideos,true);root.removeEventListener(\"pause\",applyToVideos,true);document.removeEventListener(\"visibilitychange\",onVisibilityChange);window.removeEventListener(\"pageshow\",applyToVideos);window.removeEventListener(\"focus\",applyToVideos);};},[]);const{style,...rest}=props;return /*#__PURE__*/_jsx(\"div\",{ref:rootRef,style:{...style,width:\"100%\",height:\"100%\",position:\"relative\"},children:/*#__PURE__*/_jsx(WrappedComponent,{...rest,ref:setWrappedRef})});});}// Opt-in background playback, scoped to the existing header layer.\nexport function forceHeaderVideoAutoplay(Component){return /*#__PURE__*/forwardRef(function HeaderVideoAutoplay(props,forwardedRef){const rootRef=useRef(null);const bindRef=useCallback(node=>{rootRef.current=node instanceof HTMLElement?node:null;if(typeof forwardedRef===\"function\")forwardedRef(node);else if(forwardedRef)forwardedRef.current=node;},[forwardedRef]);useEffect(()=>{if(RenderTarget.current()===RenderTarget.canvas)return;const root=rootRef.current;if(!root)return;let disposed=false;const managed=new Map;const delays=[250,750,1500,3e3,5e3];function visible(video){if(document.visibilityState===\"hidden\"||!video.isConnected)return false;const r=video.getBoundingClientRect();return r.width>0&&r.height>0&&r.bottom>0&&r.top<window.innerHeight&&r.right>0&&r.left<window.innerWidth;}function play(video,reset=false){const state=managed.get(video);if(disposed||!state||!visible(video))return;if(reset)state.attempts=0;if(state.pending||state.attempts>=delays.length+1)return;clearTimeout(state.timer);video.muted=true;video.defaultMuted=true;video.volume=0;video.autoplay=true;video.playsInline=true;video.loop=true;video.preload=\"auto\";video.setAttribute(\"muted\",\"\");video.setAttribute(\"autoplay\",\"\");video.setAttribute(\"playsinline\",\"\");if(!video.paused&&!video.ended&&video.readyState>=2)return;state.pending=true;state.attempts++;const promise=video.play();if(!promise){state.pending=false;return;}promise.then(()=>{state.pending=false;state.attempts=0;}).catch(()=>{state.pending=false;if(disposed||!visible(video)||video.error?.code===4)return;const delay=delays[state.attempts-1];if(delay!==undefined)state.timer=window.setTimeout(()=>play(video),delay);});}const intersection=typeof IntersectionObserver!==\"undefined\"?new IntersectionObserver(entries=>{for(const entry of entries)if(entry.isIntersecting)play(entry.target,true);},{threshold:.01}):null;function discover(){const videos=root instanceof HTMLVideoElement?[root]:Array.from(root.querySelectorAll(\"video\"));for(const video of videos){if(managed.has(video))continue;const ready=()=>play(video,true);const pause=()=>{const state=managed.get(video);if(state&&visible(video)){clearTimeout(state.timer);state.timer=window.setTimeout(()=>play(video),120);}};const playing=()=>{const state=managed.get(video);if(state){clearTimeout(state.timer);state.attempts=0;state.pending=false;}};managed.set(video,{attempts:0,timer:0,pending:false,cleanup:()=>{video.removeEventListener(\"loadeddata\",ready);video.removeEventListener(\"canplay\",ready);video.removeEventListener(\"pause\",pause);video.removeEventListener(\"playing\",playing);}});video.addEventListener(\"loadeddata\",ready);video.addEventListener(\"canplay\",ready);video.addEventListener(\"pause\",pause);video.addEventListener(\"playing\",playing);intersection?.observe(video);play(video);}}const resume=()=>{discover();for(const video of managed.keys())play(video,true);};const mutation=new MutationObserver(discover);mutation.observe(root,{childList:true,subtree:true});document.addEventListener(\"visibilitychange\",resume);document.addEventListener(\"pointerdown\",resume,{passive:true});document.addEventListener(\"keydown\",resume);window.addEventListener(\"pageshow\",resume);window.addEventListener(\"focus\",resume);discover();return()=>{disposed=true;mutation.disconnect();intersection?.disconnect();document.removeEventListener(\"visibilitychange\",resume);document.removeEventListener(\"pointerdown\",resume);document.removeEventListener(\"keydown\",resume);window.removeEventListener(\"pageshow\",resume);window.removeEventListener(\"focus\",resume);for(const state of managed.values()){clearTimeout(state.timer);state.cleanup();}managed.clear();};},[]);return /*#__PURE__*/_jsx(Component,{...props,ref:bindRef});});}\nexport const __FramerMetadata__ = {\"exports\":{\"forceVideoAutoplay\":{\"type\":\"reactHoc\",\"name\":\"forceVideoAutoplay\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"forceHeaderVideoAutoplay\":{\"type\":\"reactHoc\",\"name\":\"forceHeaderVideoAutoplay\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ForceVideoAutoplay.map"],"mappings":"A,kMAAuI,SAAgBa,EAAmB,EAAU,CAAC,MAAoB,gBAAW,SAA4B,EAAM,EAAI,CAAC,IAAMC,EAAQd,EAAO,IAAI,EAAQe,EAAiBC,EAAgBC,EAAchB,EAAY,GAAM,CAAI,OAAOiB,GAAM,WAAYA,EAAIC,CAAI,EAAWD,GAAK,YAAYA,IAAK,EAAI,QAAQC,EAAM,EAAE,CAACD,CAAG,CAAC,EAAER,MAAc,CAAC,GAAUP,IAAS,OAAY,OAAO,IAAMiB,EAAKN,EAAQ,QAAQ,GAAG,CAACM,EAAK,OAAO,IAAIC,EAAS,GAAUC,EAAcC,EAAiB,GAAO,CAAC,GAAGF,EAAS,OAAO,EAAM,MAAM,GAAK,EAAM,aAAa,GAAK,EAAM,SAAS,GAAK,EAAM,YAAY,GAAK,EAAM,KAAK,GAAK,EAAM,QAAQ,OAAO,IAAMG,EAAYC,EAAM,KAAK,EAAKD,GAAa,OAAOA,EAAY,OAAQ,YAAYA,EAAY,UAAU,CAAKH,IAAUlB,EAAO,aAAamB,CAAO,EAAE,EAAQnB,EAAO,eAAe,CAAKkB,GAASE,EAAiBE,CAAK,CAAE,EAAE,GAAG,EAAG,CAAC,CAAG,EAAQC,MAAkB,CAAC,GAAGL,EAAS,OAAO,IAAMM,EAAO,MAAM,KAAKP,EAAK,iBAAiB,OAAO,CAAC,EAAE,IAAI,IAAMK,KAASE,EAAQJ,EAAiBE,CAAK,CAAG,EAAQG,MAAuB,CAAI,SAAS,kBAAkB,WAAUF,EAAc,CAAE,EAAEA,EA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