{"version":3,"file":"Autoplay.CiFInx6b.mjs","names":["__legacyOverrideHOC_DataObserverContext","_jsx"],"sources":["https:/framerusercontent.com/modules/TcUoNfS6PrYDiIew9X5g/n0ECBGjFf7fKaG3PUT2c/Autoplay.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect}from\"react\";export function PlayWithSound(){useEffect(()=>{const video=document.querySelector(\"video\");if(!video)return;video.muted=false;video.loop=true;let playCount=0;const maxPlays=5;let lastTime=0;let timeUpdateHandler;let endedHandler;// Safe play attempt\nconst playPromise=video.play();if(playPromise!==undefined){playPromise.catch(err=>{console.warn(\"Playback failed:\",err);});}// Fallback: ended event\nendedHandler=()=>{playCount++;if(playCount>=maxPlays){stopAndCleanup();}};video.addEventListener(\"ended\",endedHandler);// More robust detection: detect when currentTime wraps back to near zero\ntimeUpdateHandler=()=>{const current=video.currentTime;// If currentTime is less than lastTime by a noticeable margin, the video looped\nif(current+.1<lastTime){playCount++;if(playCount>=maxPlays){stopAndCleanup();}}lastTime=current;};video.addEventListener(\"timeupdate\",timeUpdateHandler);function stopAndCleanup(){// Prevent further automatic restarts\nvideo.loop=false;// Pause and reset to start\ntry{video.pause();video.currentTime=0;}catch(err){// some browsers may throw if setting currentTime too early, ignore\n}// Remove listeners\nvideo.removeEventListener(\"timeupdate\",timeUpdateHandler);video.removeEventListener(\"ended\",endedHandler);}return()=>{video.removeEventListener(\"timeupdate\",timeUpdateHandler);video.removeEventListener(\"ended\",endedHandler);};},[]);return{};}import{useContext as __legacyOverrideHOC_useContext}from\"react\";import{DataObserverContext as __legacyOverrideHOC_DataObserverContext}from\"framer\";export function withPlayWithSound(C){return props=>{__legacyOverrideHOC_useContext(__legacyOverrideHOC_DataObserverContext);return _jsx(C,{...props,...PlayWithSound(props)});};}withPlayWithSound.displayName=\"PlayWithSound\";\nexport const __FramerMetadata__ = {\"exports\":{\"withPlayWithSound\":{\"type\":\"reactHoc\",\"name\":\"withPlayWithSound\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"PlayWithSound\":{\"type\":\"override\",\"name\":\"PlayWithSound\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Autoplay.map"],"mappings":"2KAAwE,SAAgB,GAAe,CAQiI,OARhI,MAAc,CAAC,IAAM,EAAM,SAAS,cAAc,QAAQ,CAAC,GAAG,CAAC,EAAM,OAAO,EAAM,MAAM,GAAM,EAAM,KAAK,GAAK,IAAI,EAAU,EAAuB,EAAS,EAAM,EAAsB,EAC1R,EAAY,EAAM,MAAM,CAAI,IAAc,IAAA,IAAW,EAAY,MAAM,GAAK,CAAC,QAAQ,KAAK,mBAAmB,EAAI,EAAG,CAC1H,MAAiB,CAAC,IAAe,GAAW,GAAU,GAAgB,EAAI,EAAM,iBAAiB,QAAQ,EAAa,CACtH,MAAsB,CAAC,IAAM,EAAQ,EAAM,YACxC,EAAQ,GAAG,IAAU,IAAe,GAAW,GAAU,GAAgB,EAAG,EAAS,GAAU,EAAM,iBAAiB,aAAa,EAAkB,CAAC,SAAS,GAAgB,CAClL,EAAM,KAAK,GACX,GAAG,CAAC,EAAM,OAAO,CAAC,EAAM,YAAY,OAAa,EAEjD,EAAM,oBAAoB,aAAa,EAAkB,CAAC,EAAM,oBAAoB,QAAQ,EAAa,CAAE,UAAU,CAAC,EAAM,oBAAoB,aAAa,EAAkB,CAAC,EAAM,oBAAoB,QAAQ,EAAa,GAAK,EAAE,CAAC,CAAO,EAAE,CAAqJ,SAAgB,EAAkB,EAAE,CAAC,MAAO,KAAQ,EAA+BA,EAAwC,CAAQC,EAAK,EAAE,CAAC,GAAG,EAAM,GAAG,EAAc,EAAM,CAAC,CAAC,mBARvgB,IAA6B,IAQ6T,CAAiL,EAAkB,YAAY"}