{"version":3,"file":"ResponsiveImageWithLightbox.Unt7Mhtd.mjs","names":["useState","useRef","_Fragment"],"sources":["https:/framerusercontent.com/modules/EgwwqOSDiwgaoHIWoewi/jlL5YFwJDvoHO3p0tWKu/ResponsiveImageWithLightbox.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from\"react/jsx-runtime\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";import{useState,useEffect,useRef}from\"react\";// Create a shared state for all instances of the component\n// This will store all images on the page and the currently open image\nconst sharedState={allImages:[],currentLightboxImage:null,isLightboxOpen:false,listeners:new Set,// Method to register a new image\nregisterImage(id,image,alt){// Check if image already exists (by image URL if id is not provided)\nconst lookupKey=id||image;const existingIndex=this.allImages.findIndex(item=>id&&item.id===id||!id&&item.image===image);if(existingIndex>=0){// Update existing image\nthis.allImages[existingIndex]={id:id||this.allImages[existingIndex].id,image,alt};}else{// Add new image with generated ID if none provided\nthis.allImages.push({id:id||`img_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,image,alt});}// Notify all listeners\nthis.notifyListeners();// Return the ID that was used (either provided or generated)\nreturn existingIndex>=0?this.allImages[existingIndex].id:this.allImages[this.allImages.length-1].id;},// Method to unregister an image (when component unmounts)\nunregisterImage(identifier){// Can unregister by id or by image URL\nthis.allImages=this.allImages.filter(item=>item.id!==identifier&&item.image!==identifier);this.notifyListeners();},// Method to open the lightbox with a specific image\nopenLightbox(identifier){// Find the image by id or URL\nconst image=this.allImages.find(item=>item.id===identifier||item.image===identifier);if(image){this.currentLightboxImage=image.id;this.isLightboxOpen=true;this.notifyListeners();}},// Method to close the lightbox\ncloseLightbox(){this.isLightboxOpen=false;this.notifyListeners();},// Method to navigate to the next image\nnextImage(){const currentIndex=this.allImages.findIndex(item=>item.id===this.currentLightboxImage);const nextIndex=(currentIndex+1)%this.allImages.length;this.currentLightboxImage=this.allImages[nextIndex].id;this.notifyListeners();},// Method to navigate to the previous image\nprevImage(){const currentIndex=this.allImages.findIndex(item=>item.id===this.currentLightboxImage);const prevIndex=(currentIndex-1+this.allImages.length)%this.allImages.length;this.currentLightboxImage=this.allImages[prevIndex].id;this.notifyListeners();},// Method to add a listener\naddListener(listener){this.listeners.add(listener);},// Method to remove a listener\nremoveListener(listener){this.listeners.delete(listener);},// Method to notify all listeners\nnotifyListeners(){this.listeners.forEach(listener=>listener());}};export function ResponsiveImageWithLightbox(props){const{image,alt,maintainAspectRatio,lightboxEnabled,lightboxBackgroundColor,lightboxTextColor}=props;// State to force re-render when shared state changes\nconst[,setUpdateCounter]=useState(0);// Ref to store the ID assigned to this image\nconst imageIdRef=useRef(null);// Determine if we're in the Framer editor or preview/published site\nconst isInEditor=RenderTarget.current()===RenderTarget.canvas;// Register this image with the shared state\nuseEffect(()=>{if(image){// Register the image and store the ID\nconst id=sharedState.registerImage(imageIdRef.current,image,alt);imageIdRef.current=id;}// Create a listener to update this component when shared state changes\nconst updateComponent=()=>{setUpdateCounter(count=>count+1);};// Add the listener\nsharedState.addListener(updateComponent);// Clean up when component unmounts\nreturn()=>{if(image){sharedState.unregisterImage(imageIdRef.current||image);}sharedState.removeListener(updateComponent);};},[image,alt]);// Handle opening the lightbox\nconst handleImageClick=()=>{if(lightboxEnabled&&!isInEditor&&image){sharedState.openLightbox(imageIdRef.current||image);}};// Get the current image for the lightbox\nconst currentLightboxImageId=sharedState.currentLightboxImage;const currentLightboxImage=sharedState.allImages.find(item=>item.id===currentLightboxImageId);// Check if this is the current lightbox image\nconst isCurrentLightboxImage=currentLightboxImageId===imageIdRef.current;// Check if lightbox is open\nconst isLightboxOpen=sharedState.isLightboxOpen;// Get the total number of images\nconst totalImages=sharedState.allImages.length;// Get the current image index\nconst currentImageIndex=sharedState.allImages.findIndex(item=>item.id===currentLightboxImageId);return /*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\",height:\"100%\",overflow:\"hidden\",cursor:lightboxEnabled&&!isInEditor&&image?\"pointer\":\"default\"},onClick:handleImageClick,children:image?/*#__PURE__*/_jsx(\"img\",{src:image||\"/placeholder.svg\",alt:alt,style:{width:\"100%\",height:\"100%\",objectFit:maintainAspectRatio?\"contain\":\"cover\"}}):/*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\",height:\"100%\",backgroundColor:\"#F0F0F0\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",color:\"#888888\",fontFamily:\"sans-serif\"},children:\"No image selected\"})}),isLightboxOpen&&!isInEditor&&isCurrentLightboxImage&&currentLightboxImage&&/*#__PURE__*/_jsxs(\"div\",{style:{position:\"fixed\",top:0,left:0,width:\"100%\",height:\"100%\",backgroundColor:lightboxBackgroundColor,display:\"flex\",flexDirection:\"column\",justifyContent:\"center\",alignItems:\"center\",zIndex:9999},onClick:()=>sharedState.closeLightbox(),children:[/*#__PURE__*/_jsx(\"button\",{style:{position:\"absolute\",top:\"20px\",right:\"20px\",background:\"transparent\",border:\"none\",color:lightboxTextColor,fontSize:\"30px\",cursor:\"pointer\",zIndex:1e4},onClick:()=>sharedState.closeLightbox(),children:\"\\xd7\"}),/*#__PURE__*/_jsxs(\"div\",{style:{position:\"relative\",width:\"80%\",height:\"80%\",display:\"flex\",justifyContent:\"center\",alignItems:\"center\"},onClick:e=>e.stopPropagation(),children:[totalImages>1&&/*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx(\"button\",{style:{position:\"absolute\",left:\"10px\",background:\"transparent\",border:\"none\",color:lightboxTextColor,fontSize:\"30px\",cursor:\"pointer\",zIndex:1e4,padding:\"10px\"},onClick:e=>{e.stopPropagation();sharedState.prevImage();},children:\"‹\"}),/*#__PURE__*/_jsx(\"button\",{style:{position:\"absolute\",right:\"10px\",background:\"transparent\",border:\"none\",color:lightboxTextColor,fontSize:\"30px\",cursor:\"pointer\",zIndex:1e4,padding:\"10px\"},onClick:e=>{e.stopPropagation();sharedState.nextImage();},children:\"›\"})]}),/*#__PURE__*/_jsx(\"img\",{src:currentLightboxImage.image||\"/placeholder.svg\",alt:currentLightboxImage.alt,style:{maxWidth:\"100%\",maxHeight:\"100%\",objectFit:\"contain\"}})]}),totalImages>1&&/*#__PURE__*/_jsxs(\"div\",{style:{color:lightboxTextColor,marginTop:\"20px\",fontFamily:\"sans-serif\"},children:[currentImageIndex+1,\" / \",totalImages]})]})]});}// Set default properties\nResponsiveImageWithLightbox.defaultProps={image:null,alt:\"Responsive image\",maintainAspectRatio:true,lightboxEnabled:true,lightboxBackgroundColor:\"rgba(0, 0, 0, 0.9)\",lightboxTextColor:\"#FFFFFF\"};// Add property controls for Framer\naddPropertyControls(ResponsiveImageWithLightbox,{image:{type:ControlType.Image,title:\"Image\"},alt:{type:ControlType.String,title:\"Alt Text\"},maintainAspectRatio:{type:ControlType.Boolean,title:\"Maintain Aspect Ratio\",defaultValue:true},lightboxEnabled:{type:ControlType.Boolean,title:\"Enable Lightbox\",defaultValue:true},lightboxBackgroundColor:{type:ControlType.Color,title:\"Lightbox Background\",defaultValue:\"rgba(0, 0, 0, 0.9)\"},lightboxTextColor:{type:ControlType.Color,title:\"Lightbox Text Color\",defaultValue:\"#FFFFFF\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"ResponsiveImageWithLightbox\":{\"type\":\"reactComponent\",\"name\":\"ResponsiveImageWithLightbox\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ResponsiveImageWithLightbox.map"],"mappings":"mMAkBkE,SAAgB,EAA4B,EAAM,CAAC,GAAK,CAAC,QAAM,MAAI,sBAAoB,kBAAgB,0BAAwB,qBAAmB,EAC/M,EAAE,GAAkBA,EAAS,CAAC,EAC7B,EAAWC,EAAO,IAAI,EACtB,EAAW,EAAa,QAAQ,IAAI,EAAa,OACvD,MAAc,CAAC,GAAG,EAAM,CACxB,IAAM,EAAG,EAAY,cAAc,EAAW,QAAQ,EAAM,CAAG,EAAE,EAAW,QAAQ,CAAG,CACvF,IA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