{"version":3,"file":"BlogRichTextLightbox.CTH8WlFv.mjs","names":["useState","useRef","useMemo","useCallback","_Fragment","__esmMin","ne","init_ssg_sandbox_shims","init_npm_react_18_3_1","te","window","pe","_e","Ha","de","init_jsx_runtime","J","init_npm_react_dom_18_3_1","c","p","ce","init_framer_BisrWwwE","useIsStaticRenderer","BlogRichTextLightbox","isStaticRenderer","lightbox","setLightbox","hoveredImageRef","hoveredImagePreviousCursorRef","portalTarget","closeLightbox","getEligibleImage","node","target","image","clearHoveredImageCursor","handleClickCapture","props","event","src","rawAlt","alt","handleMouseMoveCapture","handleMouseLeaveCapture","previousOverflow","body","onKeyDown","overlay","l","Component","init_BlogRichTextLightbox"],"sources":["https:/framerusercontent.com/modules/CWRsSKteGwysgS7Kjrc3/V9uMinnLCmyemXmWvN1a/BlogRichTextLightbox.js"],"sourcesContent":["// Create a code override export named BlogRichTextLightbox for the existing CMS-bound blog article RichText layer. It must preserve the layer's existing rich-text rendering and styling while adding delegated click support for images rendered inside it: clicking an image should open an accessible full-screen lightbox with a dimmed backdrop and an enlarged version of that exact image. Support Escape, clicking the backdrop, and a visible close button. Prevent page scrolling while open and restore it on close. Use a portal or fixed overlay that does not interfere with Framer editor/canvas mode; provide a safe non-interactive canvas fallback. No property controls are necessary because this will be applied as an override to an existing layer. Do not add external dependencies. Ensure images with an empty alt use a sensible generic accessible label.\nimport{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from\"react/jsx-runtime\";import{useCallback,useEffect,useMemo,useRef,useState,startTransition,forwardRef}from\"react\";import{useIsStaticRenderer}from\"framer\";import{createPortal}from\"react-dom\";export function BlogRichTextLightbox(Component){return /*#__PURE__*/forwardRef(function BlogRichTextLightboxOverride(props,ref){const isStaticRenderer=useIsStaticRenderer();const[lightbox,setLightbox]=useState(null);const hoveredImageRef=useRef(null);const hoveredImagePreviousCursorRef=useRef(\"\");const portalTarget=useMemo(()=>{if(typeof document===\"undefined\")return null;return document.body;},[]);const closeLightbox=useCallback(()=>{startTransition(()=>{setLightbox(null);});},[]);const getEligibleImage=useCallback(target=>{const node=target;if(!node)return null;const image=node.closest?.(\"img\");if(!image)return null;if(image.closest(\"a, button, [role='button']\"))return null;return image;},[]);const clearHoveredImageCursor=useCallback(()=>{if(!hoveredImageRef.current)return;hoveredImageRef.current.style.cursor=hoveredImagePreviousCursorRef.current;hoveredImageRef.current=null;hoveredImagePreviousCursorRef.current=\"\";},[]);const handleClickCapture=useCallback(event=>{if(typeof props.onClickCapture===\"function\"){props.onClickCapture(event);}if(isStaticRenderer)return;if(event.defaultPrevented)return;const image=getEligibleImage(event.target);if(!image)return;const src=image.currentSrc||image.src;if(!src)return;const rawAlt=(image.getAttribute(\"alt\")||\"\").trim();const alt=rawAlt.length>0?rawAlt:\"Blog article image\";event.preventDefault();event.stopPropagation();startTransition(()=>{setLightbox({src,alt});});},[getEligibleImage,isStaticRenderer,props]);const handleMouseMoveCapture=useCallback(event=>{if(typeof props.onMouseMoveCapture===\"function\"){props.onMouseMoveCapture(event);}if(isStaticRenderer)return;const image=getEligibleImage(event.target);if(!image){clearHoveredImageCursor();return;}if(hoveredImageRef.current===image)return;clearHoveredImageCursor();hoveredImageRef.current=image;hoveredImagePreviousCursorRef.current=image.style.cursor;image.style.cursor=\"zoom-in\";},[clearHoveredImageCursor,getEligibleImage,isStaticRenderer,props]);const handleMouseLeaveCapture=useCallback(event=>{if(typeof props.onMouseLeaveCapture===\"function\"){props.onMouseLeaveCapture(event);}clearHoveredImageCursor();},[clearHoveredImageCursor,props]);useEffect(()=>{if(typeof window===\"undefined\"||typeof document===\"undefined\")return;if(isStaticRenderer||!lightbox)return;const{body}=document;const previousOverflow=body.style.overflow;body.style.overflow=\"hidden\";return()=>{body.style.overflow=previousOverflow;};},[isStaticRenderer,lightbox]);useEffect(()=>{if(typeof window===\"undefined\")return;if(isStaticRenderer||!lightbox)return;const onKeyDown=event=>{if(event.key===\"Escape\"){closeLightbox();}};window.addEventListener(\"keydown\",onKeyDown);return()=>{window.removeEventListener(\"keydown\",onKeyDown);};},[closeLightbox,isStaticRenderer,lightbox]);useEffect(()=>{return()=>{clearHoveredImageCursor();};},[clearHoveredImageCursor]);const overlay=!isStaticRenderer&&lightbox&&portalTarget?/*#__PURE__*/createPortal(/*#__PURE__*/_jsxs(\"div\",{role:\"dialog\",\"aria-modal\":\"true\",\"aria-label\":lightbox.alt,onClick:event=>{if(event.target===event.currentTarget){closeLightbox();}},style:{position:\"fixed\",inset:0,zIndex:2147483647,background:\"rgba(0, 0, 0, 0.82)\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",padding:\"32px\"},children:[/*#__PURE__*/_jsx(\"button\",{type:\"button\",\"aria-label\":\"Close image lightbox\",onClick:closeLightbox,style:{position:\"absolute\",top:16,right:16,border:\"none\",borderRadius:999,width:40,height:40,background:\"rgba(255,255,255,0.2)\",color:\"#fff\",cursor:\"pointer\",fontSize:24,lineHeight:1},children:\"\\xd7\"}),/*#__PURE__*/_jsx(\"img\",{src:lightbox.src,alt:lightbox.alt,style:{maxWidth:\"100%\",maxHeight:\"100%\",width:\"auto\",height:\"auto\",objectFit:\"contain\",borderRadius:8}})]}),portalTarget):null;return /*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx(Component,{ref:ref,...props,onClickCapture:handleClickCapture,onMouseMoveCapture:handleMouseMoveCapture,onMouseLeaveCapture:handleMouseLeaveCapture}),overlay]});});}\nexport const __FramerMetadata__ = {\"exports\":{\"BlogRichTextLightbox\":{\"type\":\"reactHoc\",\"name\":\"BlogRichTextLightbox\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./BlogRichTextLightbox.map"],"mappings":"A,wPACuP,SAAgBuB,EAAqB,EAAU,CAAC,MAAoB,gBAAW,SAAsC,EAAM,EAAI,CAAC,IAAMC,EAAiBF,EAAoB,EAAO,CAACG,EAASC,GAAa1B,EAAS,IAAI,EAAQ2B,EAAgB1B,EAAO,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