{"version":3,"file":"LoopStill.CEEecZ48.mjs","names":["React.useState","React.useRef","__esmMin","_e","de","init_jsx_runtime","c","init_npm_react_18_3_1","ce","addPropertyControls","RenderTarget","init_framer_DDfsYcI0","ControlType","LoopStill","ready","setReady","near","setNear","ref","isCanvas","v","on","src","play","io","entries","e","style","init_LoopStill"],"sources":["https:/framerusercontent.com/modules/N3STMjsQQXKLhdpnhmCa/CflhUlUR5lLDvQcl0t7F/LoopStill.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";/**\n * A loop video covering its parent. Paused on its first frame by default;\n * with Play on it loops silently while it is on screen (off screen it pauses\n * to save battery). Renders nothing without a loop, so the parent image shows.\n *\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight fixed\n */export default function LoopStill({src,play,style}){const[ready,setReady]=React.useState(false);// Don't fetch anything until the tile is close to the screen (the Work strip\n// repeats every loop, so loading them all at once cost ~30 MB).\nconst[near,setNear]=React.useState(false);const ref=React.useRef(null);const isCanvas=RenderTarget.current()===RenderTarget.canvas||RenderTarget.current()===RenderTarget.thumbnail;// The video can finish loading before the page is interactive, so the\n// loadeddata event is missed and it would stay invisible. Check directly too.\nReact.useEffect(()=>{const v=ref.current;if(!v)return;if(v.readyState>=2){setReady(true);return;}const on=()=>setReady(true);v.addEventListener(\"loadeddata\",on);v.addEventListener(\"canplay\",on);return()=>{v.removeEventListener(\"loadeddata\",on);v.removeEventListener(\"canplay\",on);};},[src,play]);React.useEffect(()=>{const v=ref.current;if(!v||near)return;if(typeof IntersectionObserver===\"undefined\"){setNear(true);return;}const io=new IntersectionObserver(entries=>{if(entries.some(e=>e.isIntersecting)){setNear(true);io.disconnect();}},{rootMargin:\"300px 600px\"});io.observe(v);return()=>io.disconnect();},[src,near]);React.useEffect(()=>{const v=ref.current;if(!v||!play||!near||typeof IntersectionObserver===\"undefined\")return;const io=new IntersectionObserver(entries=>{for(const e of entries){if(e.isIntersecting)v.play().catch(()=>{});else v.pause();}},{threshold:.05});io.observe(v);return()=>io.disconnect();},[play,src,near]);if(!src||isCanvas)return null;return /*#__PURE__*/_jsx(\"video\",{ref:ref,src:near?play?src:src+\"#t=0.04\":undefined,muted:true,loop:play,playsInline:true,preload:near?play?\"auto\":\"metadata\":\"none\",\"aria-hidden\":\"true\",onLoadedData:()=>setReady(true),style:{...style,width:\"100%\",height:\"100%\",objectFit:\"cover\",display:\"block\",pointerEvents:\"none\",opacity:ready?1:0,transition:\"opacity 0.2s ease\"}});}LoopStill.defaultProps={src:\"\",play:false};addPropertyControls(LoopStill,{src:{type:ControlType.String,title:\"Loop URL\"},play:{type:ControlType.Boolean,title:\"Play\",defaultValue:false,description:\"Loop while on screen instead of showing the first frame.\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"LoopStill\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"fixed\",\"framerSupportedLayoutHeight\":\"fixed\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./LoopStill.map"],"mappings":"A,gMAOG,SAAwBa,EAAU,CAAC,MAAI,OAAK,SAAO,CAAC,GAAK,CAACC,EAAMC,GAAUf,EAAe,EAAK,EAE5F,CAACgB,EAAKC,GAASjB,EAAe,EAAK,EAAQkB,EAAIjB,EAAa,IAAI,EAAQkB,EAAST,EAAa,QAAQ,IAAIA,EAAa,QAAQA,EAAa,QAAQ,IAAIA,EAAa,UAE6xB,OAAv8BF,MAAoB,CAAC,IAAMY,EAAEF,EAAI,QAAQ,GAAG,CAACE,EAAE,OAAO,GAAGA,EAAE,YAAY,EAAE,CAACL,EAAS,EAAI,EAAE,MAAO,CAAC,IAAMM,MAAON,EAAS,EAAI,EAAuE,OAArEK,EAAE,iBAAiB,aAAaC,CAAE,EAAED,EAAE,iBAAiB,UAAUC,CAAE,MAAY,CAACD,EAAE,oBAA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