{"version":3,"file":"SingleSlideVideoCarousel.CDXbXkW0.mjs","names":["React.useMemo","React.useState","React.useRef","React.useCallback"],"sources":["https:/framerusercontent.com/modules/sScDLPvprP6hGDa2wd3k/aFuD4IpYhg5T4IB6g9K4/SingleSlideVideoCarousel.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";/**\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight auto\n */export default function SingleSlideVideoCarousel(props){const{video1=\"\",video2=\"\",backgroundColor=\"rgba(0, 0, 0, 0)\",startMuted=true,fit=\"Cover\",style}=props;const isStaticRenderer=useIsStaticRenderer();const fallbackAspectRatio=React.useMemo(()=>16/9,[]);const[activeIndex,setActiveIndex]=React.useState(0);const[isMuted,setIsMuted]=React.useState(startMuted);const[stageAspectRatio,setStageAspectRatio]=React.useState(fallbackAspectRatio);const startXRef=React.useRef(null);const videoRefs=React.useRef([null,null]);const slides=React.useMemo(()=>[video1,video2],[video1,video2]);const uploadedIndices=React.useMemo(()=>slides.reduce((acc,src,index)=>{if(typeof src===\"string\"&&src.trim().length>0)acc.push(index);return acc;},[]),[slides]);const uploadedCount=uploadedIndices.length;const canNavigate=uploadedCount===2;const firstUploadedIndex=uploadedIndices[0]??-1;const hasAnyVideo=React.useMemo(()=>slides.some(src=>typeof src===\"string\"&&src.trim().length>0),[slides]);React.useEffect(()=>{React.startTransition(()=>setIsMuted(startMuted));},[startMuted]);const goToSlide=React.useCallback(nextIndex=>{if(!canNavigate)return;const clamped=Math.max(0,Math.min(1,nextIndex));const outgoing=videoRefs.current[activeIndex];if(outgoing&&!outgoing.paused)outgoing.pause();React.startTransition(()=>setActiveIndex(clamped));},[activeIndex,canNavigate]);const goNext=React.useCallback(()=>{goToSlide(activeIndex===1?0:1);},[activeIndex,goToSlide]);const goPrev=React.useCallback(()=>{goToSlide(activeIndex===0?1:0);},[activeIndex,goToSlide]);const onPointerDown=React.useCallback(event=>{startXRef.current=event.clientX;},[]);const onPointerUp=React.useCallback(event=>{if(!canNavigate)return;if(startXRef.current===null)return;const delta=event.clientX-startXRef.current;startXRef.current=null;if(Math.abs(delta)<40)return;if(delta<0){goNext();}else{goPrev();}},[canNavigate,goNext,goPrev]);const onPointerCancel=React.useCallback(()=>{startXRef.current=null;},[]);const activeSlideIndex=canNavigate?activeIndex:firstUploadedIndex;const activeVideoSrc=activeSlideIndex>=0?slides[activeSlideIndex]:\"\";React.useEffect(()=>{videoRefs.current.forEach((video,index)=>{if(!video)return;if(index!==activeSlideIndex){if(!video.paused)video.pause();return;}if(!isStaticRenderer){const playPromise=video.play();if(playPromise&&typeof playPromise.catch===\"function\"){playPromise.catch(()=>{});}}});},[activeSlideIndex,isStaticRenderer]);React.useEffect(()=>{videoRefs.current.forEach(video=>{if(!video)return;video.muted=isMuted;});},[isMuted]);const toggleMute=React.useCallback(()=>{React.startTransition(()=>setIsMuted(prev=>!prev));},[]);React.useEffect(()=>{if(canNavigate||firstUploadedIndex<0||activeIndex===firstUploadedIndex){return;}React.startTransition(()=>setActiveIndex(firstUploadedIndex));},[activeIndex,canNavigate,firstUploadedIndex]);React.useEffect(()=>{React.startTransition(()=>setStageAspectRatio(fallbackAspectRatio));},[activeVideoSrc,fallbackAspectRatio]);const handleLoadedMetadata=React.useCallback(event=>{const videoElement=event.currentTarget;const{videoWidth,videoHeight}=videoElement;if(videoWidth>0&&videoHeight>0){React.startTransition(()=>setStageAspectRatio(videoWidth/videoHeight));}},[]);return /*#__PURE__*/_jsxs(\"div\",{onPointerDown:onPointerDown,onPointerUp:onPointerUp,onPointerCancel:onPointerCancel,style:{position:\"relative\",width:\"100%\",height:\"auto\",aspectRatio:`${stageAspectRatio}`,backgroundColor,overflow:\"hidden\",touchAction:\"pan-y\",margin:0,padding:0,border:\"none\",boxSizing:\"border-box\",...style},children:[activeVideoSrc?/*#__PURE__*/_jsx(\"video\",{ref:node=>{videoRefs.current[activeSlideIndex]=node;},src:activeVideoSrc,autoPlay:!isStaticRenderer,loop:true,playsInline:true,muted:isMuted,controls:false,preload:\"metadata\",onLoadedMetadata:handleLoadedMetadata,style:{width:\"100%\",height:\"100%\",objectFit:fit===\"Contain\"?\"contain\":\"cover\",display:\"block\",backgroundColor:\"transparent\",margin:0,padding:0,border:\"none\"}}):/*#__PURE__*/_jsx(\"div\",{\"aria-hidden\":\"true\",style:{width:\"100%\",height:\"100%\",backgroundColor:hasAnyVideo?\"transparent\":backgroundColor,margin:0,padding:0,border:\"none\"}}),canNavigate&&/*#__PURE__*/_jsx(\"button\",{type:\"button\",\"aria-label\":\"Previous slide\",onClick:goPrev,style:{position:\"absolute\",left:12,top:\"50%\",transform:\"translateY(-50%)\",width:34,height:34,border:\"none\",borderRadius:999,background:\"rgba(0, 0, 0, 0.45)\",color:\"#FFFFFF\",cursor:\"pointer\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",padding:0},children:/*#__PURE__*/_jsx(\"span\",{\"aria-hidden\":\"true\",children:\"‹\"})}),canNavigate&&/*#__PURE__*/_jsx(\"button\",{type:\"button\",\"aria-label\":\"Next slide\",onClick:goNext,style:{position:\"absolute\",right:12,top:\"50%\",transform:\"translateY(-50%)\",width:34,height:34,border:\"none\",borderRadius:999,background:\"rgba(0, 0, 0, 0.45)\",color:\"#FFFFFF\",cursor:\"pointer\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",padding:0},children:/*#__PURE__*/_jsx(\"span\",{\"aria-hidden\":\"true\",children:\"›\"})}),canNavigate&&/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",left:\"50%\",bottom:12,transform:\"translateX(-50%)\",display:\"flex\",gap:8,alignItems:\"center\"},children:[0,1].map(index=>{const active=activeIndex===index;return /*#__PURE__*/_jsx(\"button\",{type:\"button\",\"aria-label\":`Go to slide ${index+1}`,\"aria-pressed\":active,onClick:()=>goToSlide(index),style:{width:8,height:8,borderRadius:\"50%\",border:\"none\",padding:0,cursor:\"pointer\",background:active?\"#FFFFFF\":\"rgba(255, 255, 255, 0.35)\"}},index);})}),/*#__PURE__*/_jsx(\"button\",{type:\"button\",\"aria-label\":isMuted?\"Unmute video\":\"Mute video\",\"aria-pressed\":!isMuted,onClick:toggleMute,style:{position:\"absolute\",right:12,bottom:12,width:34,height:34,border:\"none\",borderRadius:999,background:\"rgba(0, 0, 0, 0.45)\",color:\"#FFFFFF\",cursor:\"pointer\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",padding:0},children:/*#__PURE__*/_jsxs(\"svg\",{width:\"16\",height:\"16\",viewBox:\"0 0 24 24\",fill:\"none\",\"aria-hidden\":\"true\",children:[/*#__PURE__*/_jsx(\"path\",{d:\"M4 10V14H8L13 19V5L8 10H4Z\",fill:\"currentColor\"}),isMuted?/*#__PURE__*/_jsx(\"path\",{d:\"M16 8L22 16M22 8L16 16\",stroke:\"currentColor\",strokeWidth:\"2\",strokeLinecap:\"round\"}):/*#__PURE__*/_jsx(\"path\",{d:\"M16 9C17.3 10.3 17.3 13.7 16 15M18.5 6.5C21.2 9.2 21.2 14.8 18.5 17.5\",stroke:\"currentColor\",strokeWidth:\"2\",strokeLinecap:\"round\"})]})})]});}addPropertyControls(SingleSlideVideoCarousel,{video1:{type:ControlType.File,title:\"Video 1\",allowedFileTypes:[\"mp4\",\"webm\"]},video2:{type:ControlType.File,title:\"Video 2\",allowedFileTypes:[\"mp4\",\"webm\"]},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"rgba(0, 0, 0, 0)\"},startMuted:{type:ControlType.Boolean,title:\"Start Muted\",defaultValue:true,enabledTitle:\"On\",disabledTitle:\"Off\"},fit:{type:ControlType.Enum,title:\"Fit\",options:[\"Cover\",\"Contain\"],defaultValue:\"Cover\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"SingleSlideVideoCarousel\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"auto\",\"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