{"version":3,"file":"Image_Carousel.DUnZcupB.mjs","names":["useState","element"],"sources":["https:/framerusercontent.com/modules/akSk2voSOVTsR2I6UUez/9aCIHwDIo8lhDCoQCJoB/Image_Carousel.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import*as React from\"react\";import{Frame,addPropertyControls,ControlType}from\"framer\";import{useEffect,useState}from\"react\";import{motion}from\"framer-motion\";export function ImageCarousel(props){const{richText,arrowImage=\"https://cdn-icons-png.freepik.com/512/1/1122.png\",imageSpacing,heightMode,transitionType,showFirstImageOnly,arrowSize}=props;const[imageSrcs,setImageSrcs]=useState([]);const[currentIndex,setCurrentIndex]=useState(0);useEffect(()=>{const extractImages=element=>{const images=[];const searchForImages=element=>{if(element.props&&element.props.children){React.Children.forEach(element.props.children,child=>{if(typeof child===\"object\"&&child.type===\"img\"){images.push(child.props.src);}else if(child.props&&child.props.children){searchForImages(child);}});}};searchForImages(element);return images;};if(richText&&richText.props&&Array.isArray(richText.props.children)){const images=extractImages(richText);setImageSrcs(images);}},[richText]);useEffect(()=>{if(imageSrcs.length&&currentIndex<0){setCurrentIndex(imageSrcs.length-1);}else if(imageSrcs.length&&currentIndex>=imageSrcs.length){setCurrentIndex(0);}},[currentIndex,imageSrcs.length]);const handleNext=()=>{if(!showFirstImageOnly){setCurrentIndex(prevIndex=>(prevIndex+1)%imageSrcs.length);}};const handlePrev=()=>{if(!showFirstImageOnly){setCurrentIndex(prevIndex=>(prevIndex-1+imageSrcs.length)%imageSrcs.length);}};const getImageStyle=()=>{switch(heightMode){case\"fit\":return{width:\"100%\",height:\"auto\",objectFit:\"contain\",backgroundColor:\"transparent\"};case\"fill\":return{width:\"100%\",height:\"100%\",objectFit:\"cover\",backgroundColor:\"transparent\"};case\"stretch\":return{width:\"100%\",height:\"100%\",objectFit:\"fill\",backgroundColor:\"transparent\"};default:return{width:\"100%\",height:\"auto\",objectFit:\"contain\",backgroundColor:\"transparent\"};}};const getTransition=()=>{switch(transitionType){case\"easeIn\":return{type:\"spring\",stiffness:100,damping:10};case\"easeOut\":return{type:\"tween\",ease:\"easeOut\",duration:.5};case\"linear\":return{type:\"tween\",ease:\"linear\",duration:.5};default:return{type:\"spring\",stiffness:100,damping:10};}};const displayedImages=showFirstImageOnly?[imageSrcs[0]]:imageSrcs;return /*#__PURE__*/_jsxs(Frame,{overflow:\"hidden\",position:\"relative\",style:{width:\"100%\",height:\"100%\",backgroundColor:\"transparent\"},children:[/*#__PURE__*/_jsx(motion.div,{style:{display:\"flex\",width:`${100*displayedImages.length}%`,height:\"100%\",flexDirection:\"row\",backgroundColor:\"transparent\",marginLeft:`-${imageSpacing/2}px`,marginRight:`-${imageSpacing/2}px`},animate:{x:`-${currentIndex*(100/displayedImages.length)}%`},transition:getTransition(),children:displayedImages.map((src,index)=>/*#__PURE__*/_jsx(\"div\",{style:{width:`calc(${100/displayedImages.length}% - ${imageSpacing}px)`,height:\"100%\",display:\"flex\",justifyContent:\"center\",alignItems:\"center\",backgroundColor:\"transparent\",paddingLeft:`${imageSpacing/2}px`,paddingRight:`${imageSpacing/2}px`},children:/*#__PURE__*/_jsx(\"img\",{src:src,style:getImageStyle()})},index))}),!showFirstImageOnly&&currentIndex!==0&&/*#__PURE__*/_jsx(Frame,{width:arrowSize,height:arrowSize,top:\"50%\",left:\"16px\",background:\"transparent\",style:{backgroundImage:`url(${arrowImage})`,transform:\"rotate(180deg)\",backgroundSize:\"contain\",backgroundRepeat:\"no-repeat\",backgroundPosition:\"center\",cursor:\"pointer\",backgroundColor:\"transparent\"},onTap:handlePrev}),!showFirstImageOnly&&currentIndex!==displayedImages.length-1&&/*#__PURE__*/_jsx(Frame,{width:arrowSize,height:arrowSize,top:\"50%\",right:\"16px\",background:\"transparent\",style:{backgroundImage:`url(${arrowImage})`,backgroundSize:\"contain\",backgroundRepeat:\"no-repeat\",backgroundPosition:\"center\",cursor:\"pointer\",backgroundColor:\"transparent\"},onTap:handleNext})]});}ImageCarousel.defaultProps={richText:{},arrowImage:\"https://cdn-icons-png.freepik.com/512/1/1122.png\",imageSpacing:0,heightMode:\"fit\",transitionType:\"easeIn\",showFirstImageOnly:false,arrowSize:\"50px\"};addPropertyControls(ImageCarousel,{richText:{title:\"Rich Text\",// @ts-expect-error – Internal\ntype:ControlType.RichText},arrowImage:{title:\"Arrow Image\",type:ControlType.Image,defaultValue:\"https://cdn-icons-png.freepik.com/512/1/1122.png\"},heightMode:{title:\"Height Mode\",type:ControlType.Enum,options:[\"fit\",\"fill\",\"stretch\"],optionTitles:[\"Fit\",\"Fill\",\"Stretch\"],defaultValue:\"fit\"},transitionType:{title:\"Transition\",type:ControlType.Enum,options:[\"easeIn\",\"easeOut\",\"linear\"],optionTitles:[\"Ease In\",\"Ease Out\",\"Linear\"],defaultValue:\"easeIn\"},showFirstImageOnly:{title:\"Show First Image Only\",type:ControlType.Boolean,defaultValue:false,enabledTitle:\"Yes\",disabledTitle:\"No\"},arrowSize:{title:\"Arrow Size\",type:ControlType.Number,defaultValue:50,min:10,max:100,unit:\"px\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"ImageCarousel\":{\"type\":\"reactComponent\",\"name\":\"ImageCarousel\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Image_Carousel.map"],"mappings":"mXAAuN,SAAgB,EAAc,EAAM,CAAC,GAAK,CAAC,WAAS,aAAW,mDAAmD,eAAa,aAAW,iBAAe,qBAAmB,aAAW,EAAW,CAAC,EAAU,GAAcA,EAAS,EAAE,CAAC,CAAM,CAAC,EAAa,GAAiBA,EAAS,EAAE,CAAC,MAAc,CAAC,IAAM,EAAc,GAAS,CAAC,IAAM,EAAO,EAAE,CAAO,EAAgB,GAAS,CAAIC,EAAQ,OAAOA,EAAQ,MAAM,UAAU,EAAe,QAAQA,EAAQ,MAAM,SAAS,GAAO,CAAI,OAAO,GAAQ,UAAU,EAAM,OAAO,MAAO,EAAO,KA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