{"version":3,"file":"LottieOnceInView.C4KMxtft.mjs","names":["useRef","useState","useMemo","useCallback"],"sources":["https:/framerusercontent.com/modules/06vfRQH0XB7gNderyPOC/z2KDRRcrSY5L6AdcDqry/LottieOnceInView.js"],"sourcesContent":["// Instructions: Create a Framer component that plays a Lottie animation once every time it enters the viewport, pauses at the end, and replays once if it exits and re-enters.\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";import{useInView}from\"framer-motion\";import{startTransition,useCallback,useEffect,useMemo,useRef,useState}from\"react\";let lottieScriptPromise=null;function loadLottieWeb(){if(typeof window===\"undefined\")return Promise.reject(new Error(\"No window\"));const w=window;if(w.lottie)return Promise.resolve(w.lottie);if(lottieScriptPromise)return lottieScriptPromise;lottieScriptPromise=new Promise((resolve,reject)=>{const existing=document.querySelector('script[data-framer-lottie-web=\"true\"]');if(existing){const check=()=>{if(window.lottie)resolve(window.lottie);else setTimeout(check,30);};check();return;}const script=document.createElement(\"script\");script.src=\"https://cdnjs.cloudflare.com/ajax/libs/lottie-web/5.12.2/lottie.min.js\";script.async=true;script.setAttribute(\"data-framer-lottie-web\",\"true\");script.onload=()=>resolve(window.lottie);script.onerror=()=>reject(new Error(\"Failed to load lottie-web\"));document.head.appendChild(script);});return lottieScriptPromise;}/**\n * @framerIntrinsicWidth 240\n * @framerIntrinsicHeight 240\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function LottieOnceInView(props){const{lottieFile=\"https://assets10.lottiefiles.com/packages/lf20_jcikwtux.json\",renderer=\"svg\",loop=false,speed=1,direction=\"forward\",threshold=.25,rootMargin=\"0px\",backgroundColor=\"#FFFFFF\",placeholderText=\"Add a lottie.json file\",placeholderTextColor=\"#000000\",placeholderFont,style}=props;const isStatic=useIsStaticRenderer();const hostRef=useRef(null);const mountRef=useRef(null);const animRef=useRef(null);const[status,setStatus]=useState(\"idle\");const inView=useInView(hostRef,{amount:Math.max(0,Math.min(1,threshold)),margin:rootMargin,once:false});const canLoad=useMemo(()=>{return typeof window!==\"undefined\"&&!!lottieFile;},[lottieFile]);const destroyAnimation=useCallback(()=>{const anim=animRef.current;if(anim){try{anim.removeEventListener?.(\"complete\",anim.__framerOnComplete);}catch{}try{anim.destroy?.();}catch{}}animRef.current=null;if(mountRef.current)mountRef.current.innerHTML=\"\";},[]);const ensureAnimation=useCallback(async()=>{if(!canLoad)return;if(!mountRef.current)return;try{const lottie=await loadLottieWeb();if(!mountRef.current)return;destroyAnimation();const anim=lottie.loadAnimation({container:mountRef.current,renderer,loop,autoplay:false,path:lottieFile,rendererSettings:{preserveAspectRatio:\"xMidYMid meet\",clearCanvas:true,progressiveLoad:true,hideOnTransparent:true}});anim.setSpeed?.(Math.max(.05,speed));const dir=direction===\"reverse\"?-1:1;anim.setDirection?.(dir);const onComplete=()=>{try{const total=anim.getDuration?.(true);if(typeof total===\"number\"&&isFinite(total)){anim.goToAndStop?.(Math.max(0,total-1),true);}else{anim.pause?.();}}catch{try{anim.pause?.();}catch{}}};anim.__framerOnComplete=onComplete;anim.addEventListener?.(\"complete\",onComplete);animRef.current=anim;startTransition(()=>setStatus(\"ready\"));}catch{startTransition(()=>setStatus(\"error\"));}},[canLoad,destroyAnimation,direction,lottieFile,loop,renderer,speed]);useEffect(()=>{if(isStatic)return;if(typeof window===\"undefined\")return;if(!canLoad)return;ensureAnimation();return()=>{destroyAnimation();};// eslint-disable-next-line react-hooks/exhaustive-deps\n},[ensureAnimation,destroyAnimation,isStatic,canLoad]);useEffect(()=>{if(isStatic)return;const anim=animRef.current;if(!anim)return;// Play once every time it enters the viewport.\nif(inView){try{anim.stop?.();const dir=direction===\"reverse\"?-1:1;anim.setDirection?.(dir);anim.setSpeed?.(Math.max(.05,speed));anim.play?.();}catch{}}},[inView,direction,speed,isStatic]);// If no file, show placeholder (also useful in canvas/static render).\nconst showPlaceholder=isStatic||!lottieFile||status===\"error\";return /*#__PURE__*/_jsxs(\"div\",{ref:hostRef,style:{position:\"relative\",width:\"100%\",height:\"100%\",overflow:\"hidden\",backgroundColor,...style},\"aria-label\":\"Lottie animation\",role:\"img\",children:[/*#__PURE__*/_jsx(\"div\",{ref:mountRef,style:{position:\"absolute\",inset:0,width:\"100%\",height:\"100%\"},\"aria-hidden\":showPlaceholder?true:undefined}),showPlaceholder&&/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",inset:0,display:\"flex\",alignItems:\"center\",justifyContent:\"center\",padding:12,color:placeholderTextColor,textAlign:\"center\",...placeholderFont},children:/*#__PURE__*/_jsx(\"span\",{style:{width:\"max-content\"},children:placeholderText})})]});}addPropertyControls(LottieOnceInView,{lottieFile:{type:ControlType.File,title:\"Lottie JSON\",allowedFileTypes:[\"json\",\"lottie\"]},renderer:{type:ControlType.Enum,title:\"Renderer\",options:[\"svg\",\"canvas\"],optionTitles:[\"SVG\",\"Canvas\"],defaultValue:\"svg\",displaySegmentedControl:true},loop:{type:ControlType.Boolean,title:\"Loop\",defaultValue:false,enabledTitle:\"On\",disabledTitle:\"Off\"},speed:{type:ControlType.Number,title:\"Speed\",defaultValue:1,min:.1,max:4,step:.05},direction:{type:ControlType.Enum,title:\"Direction\",options:[\"forward\",\"reverse\"],optionTitles:[\"Forward\",\"Reverse\"],defaultValue:\"forward\",displaySegmentedControl:true},threshold:{type:ControlType.Number,title:\"InView %\",defaultValue:.25,min:0,max:1,step:.05},rootMargin:{type:ControlType.String,title:\"Root Margin\",defaultValue:\"0px\",placeholder:\"e.g. 0px 0px -10% 0px\"},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"#FFFFFF\"},placeholderText:{type:ControlType.String,title:\"Placeholder\",defaultValue:\"Add a lottie.json file\"},placeholderTextColor:{type:ControlType.Color,title:\"Placeholder Text\",defaultValue:\"#000000\"},placeholderFont:{type:ControlType.Font,title:\"Placeholder Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"14px\",variant:\"Medium\",letterSpacing:\"-0.01em\",lineHeight:\"1.3em\",textAlign:\"center\"}}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"LottieOnceInView\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerIntrinsicHeight\":\"240\",\"framerIntrinsicWidth\":\"240\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./LottieOnceInView.map"],"mappings":"2RACoR,SAAS,GAAe,CAAC,GAAU,IAAS,OAAY,OAAO,QAAQ,OAAW,MAAM,YAAY,CAAC,CAAC,IAAM,EAAE,EAAmrB,OAAzqB,EAAE,OAAc,QAAQ,QAAQ,EAAE,OAAO,CAAI,IAA+C,EAAoB,IAAI,SAAS,EAAQ,IAAS,CAAgF,GAAhE,SAAS,cAAc,wCAAwC,CAAa,CAAC,IAAM,MAAU,CAAI,EAAO,OAAO,EAAQ,EAAO,OAAO,CAAM,WAAW,EAAM,GAAG,EAAG,GAAO,CAAC,OAAQ,IAAM,EAAO,SAAS,cAAc,SAAS,CAAC,EAAO,IAAI,yEAAyE,EAAO,MAAM,GAAK,EAAO,aAAa,yBAAyB,OAAO,CAAC,EAAO,WAAW,EAAQ,EAAO,OAAO,CAAC,EAAO,YAAY,EAAW,MAAM,4BAA4B,CAAC,CAAC,SAAS,KAAK,YAAY,EAAO,EAAG,CAAQ,GAMzjC,SAAwB,EAAiB,EAAM,CAAC,GAAK,CAAC,aAAW,+DAA+D,WAAS,MAAM,OAAK,GAAM,QAAM,EAAE,YAAU,UAAU,YAAU,IAAI,aAAW,MAAM,kBAAgB,UAAU,kBAAgB,yBAAyB,uBAAqB,UAAU,kBAAgB,SAAO,EAAY,EAAS,GAAqB,CAAO,EAAQA,EAAO,KAAK,CAAO,EAASA,EAAO,KAAK,CAAO,EAAQA,EAAO,KAA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