{"version":3,"file":"SmoothImageLoad.DgwexajP.mjs","names":["forwardRef","useRef"],"sources":["https:/framerusercontent.com/modules/FG1M0BxIYLpJUXVXfw7B/W30XF3gDOBmk09fj4l0l/SmoothImageLoad.js"],"sourcesContent":["// User request: Create a code override export withSmoothImageLoad for existing canvas image-fill Frames on Moonfrost page with runtime decode-aware smooth opacity reveal, preserving refs/styling/children/links and handling cached/lazy/source changes with proper cleanup.\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{forwardRef,useEffect,useRef}from\"react\";import{RenderTarget}from\"framer\";function setComposedRef(ref,value){if(typeof ref===\"function\"){ref(value);}else if(ref&&\"current\"in ref){ref.current=value;}}function canAnimate(){if(typeof window===\"undefined\")return false;if(typeof window.matchMedia!==\"function\")return true;return!window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;}function isImgRenderable(img){return img.complete&&img.naturalWidth>0;}function waitForImageReady(img){return new Promise(resolve=>{const done=()=>resolve();if(isImgRenderable(img)){if(typeof img.decode===\"function\"){img.decode().then(done).catch(done);}else{done();}return;}const onLoad=()=>{if(typeof img.decode===\"function\"){img.decode().then(done).catch(done);}else{done();}};const onError=()=>done();img.addEventListener(\"load\",onLoad,{once:true});img.addEventListener(\"error\",onError,{once:true});});}export function withSmoothImageLoad(Component){const Wrapped=/*#__PURE__*/forwardRef(function WithSmoothImageLoad(props,forwardedRef){const rootRef=useRef(null);const runIdRef=useRef(0);const observerRef=useRef(null);const rafRef=useRef(null);useEffect(()=>{const root=rootRef.current;if(!root)return;const isStaticTarget=RenderTarget.current()===RenderTarget.canvas||RenderTarget.current()===RenderTarget.export||RenderTarget.current()===RenderTarget.thumbnail;const animate=!isStaticTarget&&canAnimate();const transitionValue=animate?\"opacity 450ms ease-out\":\"opacity 0ms linear\";let cancelled=false;const setVisible=()=>{if(cancelled)return;const imgs=root.querySelectorAll(\"img\");if(imgs.length===0)return;imgs.forEach(img=>{const image=img;image.style.transition=transitionValue;image.style.opacity=\"1\";});};const setHidden=()=>{const imgs=root.querySelectorAll(\"img\");imgs.forEach(img=>{const image=img;image.style.transition=transitionValue;image.style.opacity=\"0\";});};const revealWhenReady=()=>{runIdRef.current+=1;const runId=runIdRef.current;const images=Array.from(root.querySelectorAll(\"img\"));if(images.length===0){return;}if(isStaticTarget){images.forEach(img=>{img.style.opacity=\"1\";img.style.transition=\"opacity 0ms linear\";});return;}setHidden();Promise.all(images.map(img=>waitForImageReady(img))).then(()=>{if(cancelled||runIdRef.current!==runId)return;setVisible();});};const scheduleReveal=()=>{if(rafRef.current!==null&&typeof window!==\"undefined\"){window.cancelAnimationFrame(rafRef.current);}if(typeof window!==\"undefined\"){rafRef.current=window.requestAnimationFrame(()=>{rafRef.current=null;revealWhenReady();});}else{revealWhenReady();}};revealWhenReady();if(typeof MutationObserver!==\"undefined\"){observerRef.current?.disconnect();observerRef.current=new MutationObserver(mutations=>{const relevant=mutations.some(mutation=>{if(mutation.type===\"childList\"){return true;}if(mutation.type===\"attributes\"){const target=mutation.target;return target.tagName===\"IMG\"&&(mutation.attributeName===\"src\"||mutation.attributeName===\"srcset\"||mutation.attributeName===\"sizes\"||mutation.attributeName===\"loading\");}return false;});if(relevant)scheduleReveal();});observerRef.current.observe(root,{subtree:true,childList:true,attributes:true,attributeFilter:[\"src\",\"srcset\",\"sizes\",\"loading\"]});}return()=>{cancelled=true;runIdRef.current+=1;observerRef.current?.disconnect();observerRef.current=null;if(rafRef.current!==null&&typeof window!==\"undefined\"){window.cancelAnimationFrame(rafRef.current);rafRef.current=null;}setVisible();};},[props]);return /*#__PURE__*/_jsx(Component,{ref:node=>{rootRef.current=node;setComposedRef(forwardedRef,node);},...props});});return Wrapped;}\nexport const __FramerMetadata__ = {\"exports\":{\"withSmoothImageLoad\":{\"type\":\"reactHoc\",\"name\":\"withSmoothImageLoad\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./SmoothImageLoad.map"],"mappings":"+LAC2H,SAA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