{"version":3,"file":"VideoSwap.enPM65pc.mjs","names":["useState","useRef"],"sources":["https:/framerusercontent.com/modules/AVmzUgtD4c9KT8lr9nF0/Hy0afDWMUpCPJXewdkOr/VideoSwap.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{forwardRef}from\"react\";import{createStore}from\"https://framer.com/m/framer/store.js@^1.0.0\";import{useEffect,useRef,useState}from\"react\";// Learn more: https://www.framer.com/developers/overrides/\n// Shared store between all components and the video\nexport const useVideoStore=createStore({currentVideoUrl:null,targetVideoUrl:null,isTransitioning:false});export function withSetBackgroundVideo(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const filepath=props.videoFile;const[store,setStore]=useVideoStore();const handleMouseEnter=()=>{if(filepath&&store.targetVideoUrl!==filepath){console.log(\"SETTOMG\",filepath);// Tell the video component to change to this video\nsetStore({targetVideoUrl:filepath});}};return /*#__PURE__*/_jsx(Component,{ref:ref,...props,whileHover:handleMouseEnter});});}// Learn more: https://www.framer.com/developers/overrides/\nexport function withVideoTransitions(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const[store,setStore]=useVideoStore();console.log(\"Video Component Props:\",props);console.log(\"Current Store State:\",store);const fadeTime=0// Fade duration in milliseconds\n;// Use state to track the current video URL\nconst[currentSrc,setCurrentSrc]=useState(props.srcFile??props.srcUrl);// Track if we're transitioning\nconst isTransitioning=useRef(false);// Setup a unique ID for our video\nconst videoId=\"framer-video-player\";// Function to get the video element\nconst getVideoElement=()=>{return document.querySelector(\"video\")||document.getElementById(videoId);};// Setup once on mount\nuseEffect(()=>{// Find our video element\nconst videoElement=getVideoElement();if(videoElement){console.log(\"Found video element:\",videoElement);// Add ID to video for easier finding\nif(!videoElement.id){videoElement.id=videoId;}// Setup fade transition\nif(!videoElement.style.transition){videoElement.style.transition=`opacity ${fadeTime}ms ease`;}}else{console.warn(\"Could not find video element on initial mount\");}},[]);// Watch for target URL changes\nuseEffect(()=>{console.log(\"Store changed, target URL:\",store.targetVideoUrl);// Get the video element\nconst video=getVideoElement();if(!video){console.warn(\"Could not find video element\");return;}console.log(store.targetVideoUrl,currentSrc,isTransitioning.current);// If there's a target URL and we're not transitioning\nif(store.targetVideoUrl&&store.targetVideoUrl!==currentSrc){console.log(\"Starting transition to:\",store.targetVideoUrl);isTransitioning.current=true;// Save video state\nconst wasPlaying=!video.paused;const currentVolume=video.volume;const playbackRate=video.playbackRate;// Fade out\n// video.style.opacity = \"0\"\n// Wait for fade out to complete\nsetTimeout(()=>{// Update our source state\nsetCurrentSrc(store.targetVideoUrl);// Clear target URL\nsetStore({...store,targetVideoUrl:null});// The srcUrl will be updated via props, then:\n// Wait for video to load new source\nconst onLoadedData=()=>{// Restore playback settings\nvideo.volume=currentVolume;video.playbackRate=playbackRate;// Play if it was playing before\nif(wasPlaying){video.play().catch(e=>console.log(\"Auto-play prevented:\",e));}// Fade back in\n// video.style.opacity = \"1\"\n// Clear transition flag\n// setTimeout(() => {\n//     isTransitioning.current = false\n//     console.log(\"Transition complete\")\n// }, fadeTime)\n// Remove event listener\nvideo.removeEventListener(\"loadeddata\",onLoadedData);};// Listen for the video to load\nvideo.addEventListener(\"loadeddata\",onLoadedData);},fadeTime);}else{console.log(\"burhs\");}},[store.targetVideoUrl]);console.log(props);// Return component with updated src\nreturn /*#__PURE__*/_jsx(Component,{id:videoId,ref:ref,...props,srcUrl:currentSrc,srcFile:currentSrc});});}\nexport const __FramerMetadata__ = {\"exports\":{\"useVideoStore\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withSetBackgroundVideo\":{\"type\":\"reactHoc\",\"name\":\"withSetBackgroundVideo\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withVideoTransitions\":{\"type\":\"reactHoc\",\"name\":\"withVideoTransitions\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./VideoSwap.map"],"mappings":"+LAEyG,SAAgB,EAAuB,EAAU,CAAC,OAA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