{"version":3,"file":"VideoModule.CGTfKNNX.mjs","names":["useRef","__esmMin","c","init_jsx_runtime","ce","init_npm_react_18_3_1","de","RenderTarget","init_framer_CaDWdxiz","ControlType","addPropertyControls","VideoModule","props","videoRef","isCanvas","el","video","threshold","playAt","n","a","b","observer","entry","entries","p","wrapperStyle","radius","style","poster","init_VideoModule"],"sources":["https:/framerusercontent.com/modules/mE2lkZtPFIHMJRkrKOwu/yNTEkByyjdtljbKlnbSv/VideoModule.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useRef}from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";/**\n * Autoplay-on-scroll video. Plays when scrolled into view, pauses when it\n * leaves. Muted + looping + no controls. Drop your video into the \"Video\"\n * property. Designed around a 1200 x 1920 (portrait) source.\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n * @framerIntrinsicWidth 300\n * @framerIntrinsicHeight 480\n */export default function VideoModule(props){const{video,poster,objectFit,radius,playAt,loop,style}=props;const videoRef=useRef(null);const isCanvas=RenderTarget.current()===RenderTarget.canvas;// Ensure the muted attribute is actually set (React can miss it, and\n// browsers only allow autoplay on muted video).\nuseEffect(()=>{const el=videoRef.current;if(el)el.muted=true;},[video]);// Play when in view, pause when out. Skipped in the Framer editor so the\n// canvas stays calm.\nuseEffect(()=>{if(isCanvas)return;if(typeof IntersectionObserver===\"undefined\")return;const el=videoRef.current;if(!el)return;const threshold=Array.from(new Set([0,playAt,1].filter(n=>n>=0&&n<=1))).sort((a,b)=>a-b);const observer=new IntersectionObserver(entries=>{const entry=entries[0];if(!entry)return;if(entry.isIntersecting&&entry.intersectionRatio>=playAt){const p=el.play?.();if(p&&typeof p.catch===\"function\")p.catch(()=>{});}else{el.pause?.();}},{threshold});observer.observe(el);return()=>observer.disconnect();},[playAt,video,isCanvas]);const wrapperStyle={width:\"100%\",height:\"100%\",overflow:\"hidden\",borderRadius:radius,backgroundColor:\"transparent\",...style};const videoStyle={width:\"100%\",height:\"100%\",objectFit,display:\"block\"};if(!video){return /*#__PURE__*/_jsx(\"div\",{style:{...wrapperStyle,display:\"flex\",alignItems:\"center\",justifyContent:\"center\",backgroundColor:\"rgb(243, 243, 243)\",color:\"rgb(137, 137, 138)\",fontFamily:\"Inter, sans-serif\",fontSize:14,textAlign:\"center\",padding:16},children:\"Select this layer and add your video in the “Video” property.\"});}return /*#__PURE__*/_jsx(\"div\",{style:wrapperStyle,children:/*#__PURE__*/_jsx(\"video\",{ref:videoRef,src:video,poster:poster||undefined,muted:true,loop:loop,playsInline:true,autoPlay:!isCanvas,controls:false,preload:\"metadata\",style:videoStyle})});}VideoModule.displayName=\"Video Module\";addPropertyControls(VideoModule,{video:{type:ControlType.File,title:\"Video\",allowedFileTypes:[\"mp4\",\"webm\",\"mov\"]},poster:{type:ControlType.File,title:\"Poster\",allowedFileTypes:[\"jpg\",\"jpeg\",\"png\",\"webp\"]},objectFit:{type:ControlType.Enum,title:\"Fit\",options:[\"cover\",\"contain\",\"fill\"],optionTitles:[\"Cover\",\"Contain\",\"Fill\"],defaultValue:\"cover\"},radius:{type:ControlType.Number,title:\"Radius\",min:0,max:400,step:1,unit:\"px\",defaultValue:0},playAt:{type:ControlType.Number,title:\"Play At\",min:0,max:1,step:.05,defaultValue:.5,description:\"How much must be visible before it plays.\"},loop:{type:ControlType.Boolean,title:\"Loop\",enabledTitle:\"On\",disabledTitle:\"Off\",defaultValue:true}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"VideoModule\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerIntrinsicHeight\":\"480\",\"framerIntrinsicWidth\":\"300\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./VideoModule.map"],"mappings":"A,yLASG,SAAwB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