{"version":3,"file":"SmartVideo.C4oClW6e.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/yABLwtwkrrA7h3a1fERM/yXirlSQ3Zhtw6BNYqmmp/SmartVideo.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useState}from\"react\";// --- SETTINGS ---\nconst PAUSE_WHEN_IDLE=true;const IDLE_TIMEOUT=30// Set to 30 seconds\n;export function withSmartPause(Component){return props=>{const[isVisible,setIsVisible]=useState(true);const[isActive,setIsActive]=useState(true);useEffect(()=>{// 1. Tab Switching\nconst handleVisibility=()=>{setIsVisible(document.visibilityState===\"visible\");};// 2. Idle Timer\nlet timeout;const goIdle=()=>{console.log(\"[SmartVideo] Timeout reached: Pausing video\");setIsActive(false);};const resetIdleTimer=()=>{if(!PAUSE_WHEN_IDLE)return;// If we were paused, log that we are resuming\nif(!isActive)console.log(\"[SmartVideo] Activity detected: Resuming\");setIsActive(true);clearTimeout(timeout);timeout=setTimeout(goIdle,IDLE_TIMEOUT*1e3);};// Listeners\ndocument.addEventListener(\"visibilitychange\",handleVisibility);if(PAUSE_WHEN_IDLE){// We use 'window' to catch events anywhere on the page\nwindow.addEventListener(\"mousemove\",resetIdleTimer);window.addEventListener(\"keydown\",resetIdleTimer);window.addEventListener(\"scroll\",resetIdleTimer);window.addEventListener(\"click\",resetIdleTimer);window.addEventListener(\"touchstart\",resetIdleTimer);resetIdleTimer()// Start timer immediately on load\n;}return()=>{document.removeEventListener(\"visibilitychange\",handleVisibility);window.removeEventListener(\"mousemove\",resetIdleTimer);window.removeEventListener(\"keydown\",resetIdleTimer);window.removeEventListener(\"scroll\",resetIdleTimer);window.removeEventListener(\"click\",resetIdleTimer);window.removeEventListener(\"touchstart\",resetIdleTimer);clearTimeout(timeout);};},[])// Empty dependency array ensures this runs once\n;// Logic: Video plays ONLY if all conditions are met\nconst shouldPlay=props.playing!==false&&isVisible&&isActive;// We force autoPlay to match shouldPlay to prevent the component from auto-restarting\nreturn /*#__PURE__*/_jsx(Component,{...props,playing:shouldPlay,autoPlay:shouldPlay});};}\nexport const __FramerMetadata__ = {\"exports\":{\"withSmartPause\":{\"type\":\"reactHoc\",\"name\":\"withSmartPause\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./SmartVideo.map"],"mappings":"kIAEC,SAAgB,EAAe,EAAU,CAAC,MAAO,IAAO,CAAC,GAAK,CAAC,EAAU,GAAcA,EAAS,GAAK,CAAM,CAAC,EAAS,GAAaA,EAAS,GAAK,CAAC,MAAc,CAChK,IAAM,MAAqB,CAAC,EAAa,SAAS,kBAAkB,UAAU,EAC1E,EAAc,MAAW,CAAC,QAAQ,IAAI,8CAA8C,CAAC,EAAY,GAAM,EAAS,MAAmB,CACnI,GAAS,QAAQ,IAAI,2CAA2C,CAAC,EAAY,GAAK,CAAC,aAAa,EAAQ,CAAC,EAAQ,WAAW,EAAO,EAAa,IAAI,EAGtJ,OAFF,SAAS,iBAAiB,mBAAmB,EAAiB,CAC9D,EAAO,iBAAiB,YAAY,EAAe,CAAC,EAAO,iBAAiB,UAAU,EAAe,CAAC,EAAO,iBAAiB,SAAS,EAAe,CAAC,EAAO,iBAAiB,QAAQ,EAAe,CAAC,EAAO,iBAAiB,aAAa,EAAe,CAAC,GAAgB,KAChQ,CAAC,SAAS,oBAAoB,mBAAmB,EAAiB,CAAC,EAAO,oBAAoB,YAAY,EAAe,CAAC,EAAO,oBAAoB,UAAU,EAAe,CAAC,EAAO,oBAAoB,SAAS,EAAe,CAAC,EAAO,oBAAoB,QAAQ,EAAe,CAAC,EAAO,oBAAoB,aAAa,EAAe,CAAC,aAAa,EAAQ,GAAK,EAAE,CAAC,CAEvX,IAAM,EAAW,EAAM,UAAU,IAAO,GAAW,EACnD,OAAoB,EAAK,EAAU,CAAC,GAAG,EAAM,QAAQ,EAAW,SAAS,EAAW,CAAC,yBAX1C,IAAsC,CAChD,EAAa"}