{"version":3,"file":"ProjectVideoLoop.UPkKKjxk.mjs","names":["React.useRef","__esmMin","de","c","init_jsx_runtime","init_npm_react_18_3_1","ce","ProjectVideoLoop","ref","root","bound","inView","tryPlay","v","restart","event","io","entry","entries","sync","onVisibility","mo","style","init_ProjectVideoLoop"],"sources":["https:/framerusercontent.com/modules/QqLF4FPbptfFGkOuPKlJ/FPHGZw8dZAHDVqk6N2Lu/ProjectVideoLoop.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import*as React from\"react\";/** @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any */export default function ProjectVideoLoop({style}){const ref=React.useRef(null);React.useEffect(()=>{const root=ref.current?.parentElement;if(!root)return;const bound=new Set;const inView=new WeakMap;const tryPlay=v=>{if(document.visibilityState!==\"visible\")return;if(!inView.get(v))return;v.muted=true;void v.play().catch(()=>{});};const restart=event=>{const v=event.currentTarget;if(document.visibilityState!==\"visible\"||!v.getClientRects().length)return;v.currentTime=0;tryPlay(v);};const io=new IntersectionObserver(entries=>{for(const entry of entries){const v=entry.target;inView.set(v,entry.isIntersecting);if(entry.isIntersecting){if(v.readyState===0){v.preload=\"auto\";v.setAttribute(\"preload\",\"auto\");v.load();}tryPlay(v);}else{v.pause();}}},{threshold:.1});const sync=()=>{root.querySelectorAll(\"video\").forEach(v=>{v.loop=true;v.muted=true;v.playsInline=true;v.setAttribute(\"playsinline\",\"\");v.setAttribute(\"webkit-playsinline\",\"\");if(!bound.has(v)){bound.add(v);v.autoplay=false;v.removeAttribute(\"autoplay\");v.preload=\"none\";v.setAttribute(\"preload\",\"none\");v.addEventListener(\"ended\",restart);io.observe(v);}});};const onVisibility=()=>{bound.forEach(v=>{if(document.visibilityState===\"visible\")tryPlay(v);else v.pause();});};sync();const mo=new MutationObserver(sync);mo.observe(root,{childList:true,subtree:true});document.addEventListener(\"visibilitychange\",onVisibility);return()=>{mo.disconnect();io.disconnect();document.removeEventListener(\"visibilitychange\",onVisibility);bound.forEach(v=>v.removeEventListener(\"ended\",restart));};},[]);return /*#__PURE__*/_jsx(\"span\",{ref:ref,\"aria-hidden\":\"true\",style:{...style,width:1,height:1,pointerEvents:\"none\"}});}\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ProjectVideoLoop\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"\",\"framerSupportedLayoutWidth\":\"any\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ProjectVideoLoop.map"],"mappings":"A,yHACsC,SAAwBO,EAAiB,CAAC,SAAO,CAAC,IAAMC,EAAIR,EAAa,IAAI,EAA08C,OAAx8CM,MAAoB,CAAC,IAAMG,EAAKD,EAAI,SAAS,cAAc,GAAG,CAACC,EAAK,OAAO,IAAMC,kBAAM,IAAI,IAAUC,kBAAO,IAAI,QAAcC,EAAQ,GAAG,CAAI,SAAS,kBAAkB,WAAqBD,EAAO,IAAIE,CAAC,IAAS,EAAE,MAAM,GAAKA,EAAO,KAAK,CAAC,CAAC,UAAU,CAAC,CAAC,EAAE,EAAQC,EAAQ,GAAO,CAAC,IAAMD,EAAEE,EAAM,cAAiB,SAAS,kBAAkB,WAAYF,EAAE,eAAe,CAAC,CAAC,SAAc,EAAE,YAAY,EAAED,EAAQC,CAAC,EAAE,EAAQG,EAAG,IAAI,qBAAqB,GAAS,CAAC,IAAI,IAAMC,KAASC,EAAQ,CAAC,IAAML,EAAEI,EAAM,OAAON,EAAO,IAAIE,EAAEI,EAAM,cAAc,EAAKA,EAAM,gBAAmBJ,EAAE,aAAa,IAAG,EAAE,QAAQ,OAAOA,EAAE,aAAa,UAAU,MAAM,EAAEA,EAAE,KAAK,GAAGD,EAAQC,CAAC,GAAQA,EAAE,MAAM,CAAG,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,EAAQM,MAAS,CAACV,EAAK,iBAAiB,OAAO,CAAC,CAAC,QAAQ,GAAG,CAAC,EAA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