{"version":3,"file":"CaseStudyMotion.dpXh8oNJ.mjs","names":["useRef","useState","__esmMin","init_npm_react_18_3_1","init_ssg_sandbox_shims","window","_e","c","init_jsx_runtime","ce","de","init_framer_CKT6jEEQ","addPropertyControls","ControlType","CaseStudyMotion","frame","video","mode","setMode","reducedMotion","setReducedMotion","inView","setInView","visibleEnough","setVisibleEnough","loaded","setLoaded","failed","setFailed","media","update","observer","entry","active","source","player","waiting","togglePlayback","title","event","style","poster","init_CaseStudyMotion"],"sources":["https:/framerusercontent.com/modules/SjQIh9tZyGmzELpPdAKq/x6zyVQ0z6VuC6PcF783Y/CaseStudyMotion.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useRef,useState}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n */export default function CaseStudyMotion({title,source,poster,style}){const frame=useRef(null);const video=useRef(null);const[mode,setMode]=useState(\"auto\");const[reducedMotion,setReducedMotion]=useState(true);const[inView,setInView]=useState(false);const[visibleEnough,setVisibleEnough]=useState(false);const[loaded,setLoaded]=useState(false);const[failed,setFailed]=useState(false);useEffect(()=>{const media=window.matchMedia(\"(prefers-reduced-motion: reduce)\");const update=()=>setReducedMotion(media.matches);update();media.addEventListener(\"change\",update);return()=>media.removeEventListener(\"change\",update);},[]);useEffect(()=>{if(!frame.current||typeof IntersectionObserver===\"undefined\")return;const observer=new IntersectionObserver(([entry])=>{setInView(entry.isIntersecting);setVisibleEnough(entry.isIntersecting&&entry.intersectionRatio>=.35);},{threshold:[0,.35]});observer.observe(frame.current);return()=>observer.disconnect();},[]);const active=Boolean(source)&&!failed&&(mode===\"manual\"&&inView||mode===\"auto\"&&visibleEnough&&!reducedMotion);useEffect(()=>{if(active)setLoaded(true);},[active]);useEffect(()=>{const player=video.current;if(!player)return;if(!active){player.pause();return;}let waiting=true;player.play().catch(()=>{if(waiting)setFailed(true);});return()=>{waiting=false;};},[active,loaded,source]);function togglePlayback(){if(!source)return;if(active){setMode(\"still\");return;}setInView(true);setMode(\"manual\");setFailed(false);setLoaded(true);}return /*#__PURE__*/_jsx(\"div\",{ref:frame,role:source?\"button\":undefined,tabIndex:source?0:undefined,\"aria-label\":source?`${active?\"Pause\":failed?\"Retry\":\"Play\"} ${title}`:undefined,onClick:togglePlayback,onKeyDown:event=>{if(event.key===\"Enter\"||event.key===\" \"){event.preventDefault();togglePlayback();}},style:{...style,position:\"relative\",width:\"100%\",height:\"100%\",overflow:\"hidden\",cursor:source?\"pointer\":undefined},children:loaded&&!failed&&source&&/*#__PURE__*/_jsx(\"video\",{ref:video,\"aria-hidden\":\"true\",src:source,poster:poster||undefined,muted:true,loop:true,playsInline:true,preload:\"none\",onError:()=>setFailed(true),style:{display:active?\"block\":\"none\",width:\"100%\",height:\"100%\",objectFit:\"contain\",pointerEvents:\"none\"}})});}addPropertyControls(CaseStudyMotion,{title:{type:ControlType.String,title:\"Title\",defaultValue:\"Motion preview\"},source:{type:ControlType.String,title:\"MP4 URL\"},poster:{type:ControlType.String,title:\"Poster URL\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CaseStudyMotion\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"any\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"any\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CaseStudyMotion.map"],"mappings":"A,sMAGG,SAAwBc,EAAgB,CAAC,QAAM,SAAO,SAAO,SAAO,CAAC,IAAMC,EAAMf,EAAO,IAAI,EAAQgB,EAAMhB,EAAO,IAAI,EAAO,CAACiB,EAAKC,GAASjB,EAAS,MAAM,EAAO,CAACkB,EAAcC,GAAkBnB,EAAS,EAAI,EAAO,CAACoB,EAAOC,GAAWrB,EAAS,EAAK,EAAO,CAACsB,EAAcC,GAAkBvB,EAAS,EAAK,EAAO,CAACwB,EAAOC,GAAWzB,EA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