{"version":3,"file":"LottiePlayer.D1nSWNMr.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/6QKcDaEyTJp47XSHNQ77/uJ5JEKwXylhDULy6y9wq/LottiePlayer.js"],"sourcesContent":["// Lottie player component with play on appear option\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useRef,useState}from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";/**\n * Lottie Player (Mobile CPU Optimized)\n * * Changes from previous:\n * 1. Removed 'fetchpriority' (was choking mobile bandwidth).\n * 2. Added requestAnimationFrame checks to yield to the main thread (improves TBT).\n * 3. Keeps lottie_light.min.js for small size.\n */export default function LottiePlayer(props){const{file=\"\",autoplay=true,playOnAppear=false,delay=0,loop=false}=props;const containerRef=useRef(null);const animationRef=useRef(null);const hasPlayedRef=useRef(false);// State: Controls when to inject the script\nconst[shouldLoad,setShouldLoad]=useState(false);// State: Confirm script is ready\nconst[lottieLoaded,setLottieLoaded]=useState(false);// Detect reduced motion preference\nconst prefersReducedMotionRef=useRef(false);useEffect(()=>{if(typeof window===\"undefined\")return;const mediaQuery=window.matchMedia(\"(prefers-reduced-motion: reduce)\");prefersReducedMotionRef.current=mediaQuery.matches;const handleChange=e=>{prefersReducedMotionRef.current=e.matches;};mediaQuery.addEventListener(\"change\",handleChange);return()=>mediaQuery.removeEventListener(\"change\",handleChange);},[]);// --- 1. Non-Blocking Trigger Logic ---\nuseEffect(()=>{if(!containerRef.current||typeof window===\"undefined\")return;// A. Framer Canvas / No Observer -> Load\nif(RenderTarget.current()===RenderTarget.canvas||!(\"IntersectionObserver\"in window)){setShouldLoad(true);return;}// B. Position Check (Mobile Optimization: Yield to Paint)\n// We use requestAnimationFrame to ensure the initial HTML paint happens BEFORE we request the script.\nconst checkPosition=()=>{if(!containerRef.current)return;const rect=containerRef.current.getBoundingClientRect();// Threshold: 1.25x viewport height (Balanced)\nif(rect.top<window.innerHeight*1.25){setShouldLoad(true);}else{// C. Lazy Load for off-screen elements\nstartObserver();}};const startObserver=()=>{const observer=new IntersectionObserver(entries=>{entries.forEach(entry=>{if(entry.isIntersecting){setShouldLoad(true);observer.disconnect();}});},{rootMargin:\"200px\"});if(containerRef.current)observer.observe(containerRef.current);};// Run check after next repaint to reduce Total Blocking Time\nrequestAnimationFrame(checkPosition);},[]);// --- 2. Dynamic Script Loading (lottie_light) ---\nuseEffect(()=>{if(typeof window===\"undefined\"||!shouldLoad)return;if(window.lottie){setLottieLoaded(true);return;}const existingScript=document.querySelector('script[src*=\"lottie\"]');if(existingScript){const check=()=>{if(window.lottie)setLottieLoaded(true);};existingScript.addEventListener(\"load\",check);if(window.lottie)setLottieLoaded(true);return()=>existingScript.removeEventListener(\"load\",check);}const script=document.createElement(\"script\");// Keeping lottie_light for size\nscript.src=\"https://cdnjs.cloudflare.com/ajax/libs/lottie-web/5.12.2/lottie_light.min.js\";script.async=true;// NOTE: Removed fetchpriority=\"high\" to prevent bandwidth contention on mobile\nscript.onload=()=>{if(window.lottie)setLottieLoaded(true);};document.head.appendChild(script);},[shouldLoad]);// --- 3. Animation Initialization (CPU Deferral) ---\nuseEffect(()=>{if(!containerRef.current||!lottieLoaded||!file||!window.lottie)return;const lottie=window.lottie;// Clean up previous\nif(animationRef.current){animationRef.current.destroy();animationRef.current=null;}// OPTIMIZATION: Wrap initialization in requestAnimationFrame\n// This prevents the heavy \"JSON parsing\" from freezing the main thread immediately.\nconst initAnimation=()=>{if(!containerRef.current)return;try{containerRef.current.innerHTML=\"\";animationRef.current=lottie.loadAnimation({container:containerRef.current,renderer:\"svg\",loop:loop,autoplay:playOnAppear?false:autoplay,path:file,rendererSettings:{preserveAspectRatio:\"xMidYMid meet\",clearCanvas:true,progressiveLoad:true,hideOnTransparent:true}});animationRef.current.setSpeed(1);animationRef.current.setDirection(1);// Handle Reduced Motion\nif(prefersReducedMotionRef.current){animationRef.current.addEventListener(\"DOMLoaded\",()=>{if(animationRef.current)animationRef.current.goToAndStop(animationRef.current.totalFrames-1,true);});}else if(!playOnAppear&&autoplay){animationRef.current.play();}hasPlayedRef.current=false;}catch(e){console.error(\"Lottie load error\",e);}};// Execute initialization in the next frame\nrequestAnimationFrame(initAnimation);return()=>{if(animationRef.current){animationRef.current.destroy();animationRef.current=null;}};},[file,autoplay,playOnAppear,lottieLoaded,loop]);// --- 4. Play On Appear Logic ---\nuseEffect(()=>{if(!playOnAppear||!containerRef.current)return;const observer=new IntersectionObserver(entries=>{entries.forEach(entry=>{if(entry.isIntersecting&&!hasPlayedRef.current){// Check if animationRef is ready inside the callback\nif(animationRef.current){hasPlayedRef.current=true;observer.disconnect();setTimeout(()=>{if(animationRef.current&&!prefersReducedMotionRef.current){animationRef.current.goToAndPlay(0,true);}},delay*1e3);}}});},{threshold:.1});observer.observe(containerRef.current);return()=>observer.disconnect();},[playOnAppear,delay,lottieLoaded]);return /*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:{width:\"100%\",height:\"100%\",minWidth:5,minHeight:5,position:\"relative\",...props.style}});}addPropertyControls(LottiePlayer,{file:{type:ControlType.File,title:\"Lottie File\",allowedFileTypes:[\"json\"]},playOnAppear:{type:ControlType.Boolean,title:\"Play on Appear\",defaultValue:false,enabledTitle:\"On\",disabledTitle:\"Off\"},delay:{type:ControlType.Number,title:\"Delay\",defaultValue:0,min:0,max:10,step:.1,unit:\"s\",hidden:({playOnAppear})=>playOnAppear},autoplay:{type:ControlType.Boolean,title:\"Autoplay\",defaultValue:true,enabledTitle:\"On\",disabledTitle:\"Off\",hidden:({playOnAppear})=>playOnAppear},loop:{type:ControlType.Boolean,title:\"Loop\",defaultValue:false,enabledTitle:\"On\",disabledTitle:\"Off\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"LottiePlayer\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./LottiePlayer.map"],"mappings":"6MAOG,SAAwB,EAAa,EAAM,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