{"version":3,"file":"Cl_Video.D3vmhTHP.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/4OThSu0JIzhR5DkaAVBJ/4YXZS3mpAX9Shdx59BaD/Cl_Video.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useInView}from\"framer-motion\";import{addPropertyControls,ControlType}from\"framer\";import{useEffect,useRef,useState}from\"react\";/**\n * @framerIntrinsicWidth 300\n * @framerIntrinsicHeight 200\n * @framerDisableUnlink\n */export default function VideoPlayOnView(props){const{videoSrc,playTrigger,delay,playbackRate,loop,smoothness,autoPlay,overlayColor,overlayBlur,...rest}=props;const ref=useRef(null);const[isPlaying,setIsPlaying]=useState(false);const[showControls,setShowControls]=useState(!autoPlay);const isInView=useInView(ref,{once:true,amount:playTrigger===\"entering\"?0:parseInt(playTrigger)/100});useEffect(()=>{const videoElement=ref.current;// Handle video autoplay and smooth looping logic\nconst handleManualLoop=()=>{if(loop&&smoothness>0&&videoElement){const endBufferTime=videoElement.duration*(smoothness/100);const loopThreshold=videoElement.duration-endBufferTime;const onTimeUpdate=()=>{if(videoElement.currentTime>=loopThreshold){videoElement.currentTime=0;videoElement.play();}};videoElement.addEventListener(\"timeupdate\",onTimeUpdate);return()=>videoElement.removeEventListener(\"timeupdate\",onTimeUpdate);}};if(autoPlay&&isInView&&videoElement){setTimeout(()=>{videoElement.play();videoElement.playbackRate=playbackRate;setIsPlaying(true);handleManualLoop();},delay);}return()=>{if(videoElement){videoElement.pause();videoElement.currentTime=0;}};},[isInView,delay,playbackRate,playTrigger,loop,smoothness,autoPlay]);const handleManualPlay=()=>{const videoElement=ref.current;if(videoElement){if(!isPlaying){videoElement.play();setIsPlaying(true);}else{videoElement.pause();setIsPlaying(false);}}};// Toggle visibility of the play/pause controls on click\nconst toggleControls=()=>{if(!autoPlay){setShowControls(true);}};return /*#__PURE__*/_jsxs(\"div\",{style:{position:\"relative\",width:\"100%\",height:\"100%\"},onClick:toggleControls,children:[/*#__PURE__*/_jsx(\"video\",{ref:ref,src:videoSrc,muted:true,loop:false,style:{width:\"100%\",height:\"100%\",objectFit:\"cover\",cursor:\"pointer\"},...rest}),!autoPlay&&!isPlaying&&showControls&&/*#__PURE__*/_jsx(\"div\",{onClick:handleManualPlay,style:{position:\"absolute\",top:\"50%\",left:\"50%\",transform:\"translate(-50%, -50%)\",width:\"80px\",height:\"80px\",backgroundColor:overlayColor,backdropFilter:`blur(${overlayBlur}px)`,borderRadius:\"50%\",display:\"flex\",justifyContent:\"center\",alignItems:\"center\",cursor:\"pointer\",zIndex:10},children:/*#__PURE__*/_jsx(\"svg\",{xmlns:\"http://www.w3.org/2000/svg\",viewBox:\"0 0 24 24\",fill:\"white\",width:\"50px\",height:\"50px\",children:/*#__PURE__*/_jsx(\"path\",{d:isPlaying?\"M8 5h3v14H8zm5 0h3v14h-3z\":\"M8 5v14l11-7z\"})})})]});}VideoPlayOnView.defaultProps={videoSrc:\"\",playTrigger:\"entering\",delay:0,playbackRate:1,loop:false,smoothness:0,autoPlay:true,overlayColor:\"rgba(0, 0, 0, 0.5)\",overlayBlur:5};addPropertyControls(VideoPlayOnView,{videoSrc:{type:ControlType.File,allowedFileTypes:[\"mp4\",\"webm\",\"ogg\"],title:\"Video Source\"},playTrigger:{type:ControlType.Enum,title:\"Play Trigger\",options:[\"entering\",\"10\",\"20\",\"30\",\"40\",\"50\",\"60\",\"70\",\"80\",\"90\"],optionTitles:[\"Entering\",\"10%\",\"20%\",\"30%\",\"40%\",\"50%\",\"60%\",\"70%\",\"80%\",\"90%\"],defaultValue:\"entering\"},delay:{type:ControlType.Number,title:\"Delay (ms)\",defaultValue:0,min:0,max:5e3,step:100},playbackRate:{type:ControlType.Number,title:\"Playback Speed\",defaultValue:1,min:.1,max:2,step:.1},loop:{type:ControlType.Boolean,title:\"Loop Video\",defaultValue:false},smoothness:{type:ControlType.Number,title:\"Loop Smoothness (%)\",defaultValue:0,min:0,max:100,step:1},autoPlay:{type:ControlType.Boolean,title:\"Autoplay Video\",defaultValue:true},overlayColor:{type:ControlType.Color,title:\"Overlay Color\",defaultValue:\"rgba(0, 0, 0, 0.5)\"},overlayBlur:{type:ControlType.Number,title:\"Overlay Blur\",defaultValue:5,min:0,max:20,step:1}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"VideoPlayOnView\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerIntrinsicWidth\":\"300\",\"framerDisableUnlink\":\"\",\"framerIntrinsicHeight\":\"200\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Cl_Video.map"],"mappings":"4OAIG,SAAwB,EAAgB,EAAM,CAAC,GAAK,CAAC,WAAS,cAAY,QAAM,eAAa,OAAK,aAAW,WAAS,eAAa,cAAY,GAAG,GAAM,EAAY,EAAIA,EAAO,KAAK,CAAM,CAAC,EAAU,GAAcC,EAAS,GAAM,CAAM,CAAC,EAAa,GAAiBA,EAAS,CAAC,EAAS,CAAO,EAAS,EAAU,EAAI,CAAC,KAAK,GAAK,OAAO,IAAc,WAAW,EAAE,SAAS,EAAY,CAAC,IAAI,CAAC,CAAC,MAAc,CAAC,IAAM,EAAa,EAAI,QACpa,MAAqB,CAAC,GAAG,GAAM,EAAW,GAAG,EAAa,CAAC,IAAM,EAAc,EAAa,UAAU,EAAW,KAAW,EAAc,EAAa,SAAS,EAAoB,MAAiB,CAAI,EAAa,aAAa,IAAe,EAAa,YAAY,EAAE,EAAa,MAAM,GAA6D,OAAzD,EAAa,iBAAiB,aAAa,EAAa,KAAW,EAAa,oBAAoB,aAAa,EAAa,GAAoK,OAA7J,GAAU,GAAU,GAAc,eAAe,CAAC,EAAa,MAAM,CAAC,EAAa,aAAa,EAAa,EAAa,GAAK,CAAC,GAAkB,EAAG,EAAM,KAAY,CAAI,IAAc,EAAa,OAAO,CAAC,EAAa,YAAY,KAAO,CAAC,EAAS,EAAM,EAAa,EAAY,EAAK,EAAW,E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