{"version":3,"file":"Image_carousel.BpK_VGvi.mjs","names":["useState","useEffect","_jsxs","_jsx","ReactDOM","__esmMin","j","init_npm_react_18_3_1","_e","init_jsx_runtime","Ba","p","ce","addPropertyControls","init_framer_B3LLf74D","Frame","ControlType","motion","init_framer_motion_1EwlFBEG","RichTextCarousel","props","richText","arrowImage","imageSpacing","heightMode","transitionType","showFirstImageOnly","arrowSize","enableLightbox","imageSrcs","setImageSrcs","currentIndex","setCurrentIndex","lightboxSrc","setLightboxSrc","extractImages","element","images","searchForImages","child","handleNext","prevIndex","handlePrev","getImageStyle","getTransition","displayedImages","c","src","index","Lightbox","init_Image_carousel","init_npm_react_dom_18_3_1","onClose"],"sources":["https:/framerusercontent.com/modules/6SFQOOr7pyMlZBzgKSs8/m2QVSRgfdp6eWmcFy5IG/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\";import ReactDOM from\"react-dom\";const Lightbox=({src,onClose})=>{useEffect(()=>{document.body.style.overflow=\"hidden\";return()=>{document.body.style.overflow=\"unset\";};},[]);return /*#__PURE__*/ReactDOM.createPortal(/*#__PURE__*/_jsx(\"div\",{style:{position:\"fixed\",top:0,left:0,width:\"100%\",height:\"100%\",backgroundColor:\"rgba(0, 0, 0, 0.8)\",zIndex:9999999,display:\"flex\",justifyContent:\"center\",alignItems:\"center\"},onClick:onClose,children:/*#__PURE__*/_jsx(\"img\",{src:src,style:{maxWidth:\"90%\",maxHeight:\"90%\",objectFit:\"contain\"},onClick:e=>e.stopPropagation()})}),document.body);};/**\n * @framerDisableUnlink\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n * @framerIntrinsicWidth 600\n * @framerIntrinsicHeight 600\n */export default function RichTextCarousel(props){const{richText,arrowImage=\"https://cdn-icons-png.freepik.com/512/1/1122.png\",imageSpacing,heightMode,transitionType,showFirstImageOnly,arrowSize,enableLightbox}=props;const[imageSrcs,setImageSrcs]=useState([]);const[currentIndex,setCurrentIndex]=useState(0);const[lightboxSrc,setLightboxSrc]=useState(null);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(),cursor:enableLightbox?\"pointer\":\"default\"},onClick:()=>{if(enableLightbox){setLightboxSrc(src);}}})},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}),enableLightbox&&lightboxSrc&&/*#__PURE__*/_jsx(Lightbox,{src:lightboxSrc,onClose:()=>setLightboxSrc(null)})]});}RichTextCarousel.defaultProps={richText:{},arrowImage:\"https://cdn-icons-png.freepik.com/512/1/1122.png\",imageSpacing:0,heightMode:\"fit\",transitionType:\"easeIn\",showFirstImageOnly:false,arrowSize:50,enableLightbox:true};addPropertyControls(RichTextCarousel,{richText:{title:\"Rich Text\",type: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\"},enableLightbox:{title:\"Lightbox\",type:ControlType.Boolean,defaultValue:true,enabledTitle:\"Yes\",disabledTitle:\"No\"},arrowSize:{title:\"Arrow Size\",type:ControlType.Number,defaultValue:50,min:10,max:100,unit:\"px\",description:\"v1.3 \\n [via SegmentUI](https://www.segmentUI.com)\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"RichTextCarousel\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerIntrinsicWidth\":\"600\",\"framerIntrinsicHeight\":\"600\",\"framerDisableUnlink\":\"*\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Image_carousel.map"],"mappings":"A,2PAOG,SAAwBmB,EAAiBC,EAAM,CAAC,GAAK,CAACC,WAASC,aAAW,mDAAmDC,eAAaC,aAAWC,iBAAeC,qBAAmBC,YAAUC,kBAAgBR,EAAW,CAACS,EAAUC,GAAc9B,EAAS,CAAC,CAAC,EAAO,CAAC+B,EAAaC,GAAiBhC,EAAS,CAAC,EAAO,CAACiC,EAAYC,GAAgBlC,EAAS,IAAI,EAAEC,MAAc,CAAC,IAAMkC,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