{"version":3,"file":"NumberCounter.HjpdLAPC.mjs","names":["useState","useRef","useMemo","__esmMin","pe","te","init_npm_react_18_3_1","de","init_jsx_runtime","c","ce","_e","useInView","init_framer_motion_DhsWWWsN","addPropertyControls","useIsStaticRenderer","ControlType","init_framer_BWFVvmND","Counter","props","currentValue","setCurrentValue","startValue","hasStartedRef","animationRef","loopTimeoutRef","startTimeRef","containerRef","isStatic","isInView","resetOnReEntry","formatNumber","fixed","value","decimals","separator","parts","easeValue","x1","y1","x2","y2","easingMap","easing","t","animate","tick","timestamp","delay","elapsed","progress","duration","easedProgress","newValue","endValue","loop","shouldRun","autoStart","interrupted","fullText","prefix","suffix","fontSize","font","init_NumberCounter"],"sources":["https:/framerusercontent.com/modules/kz7xSJufPMaAkUq4YIWF/o24u9P51h27HeU5bUlNN/NumberCounter.js"],"sourcesContent":["// Number Counter component that animates from start to end value with customizable options\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useState,useEffect,useRef,useMemo,startTransition}from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";import{useInView}from\"framer-motion\";const easingMap={linear:[0,0,1,1],easeIn:[.4,0,1,1],easeOut:[0,0,.2,1],easeInOut:[.4,0,.2,1],bounce:[.68,-.55,.265,1.55]};/**\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n */export default function Counter(props){const{startValue=0,endValue=100,duration=2,delay=0,decimals=0,easing=\"easeOut\",font,fontSize=32,textAlign=\"left\",color=\"#000000\",autoStart=true,loop=false,resetOnReEntry=false,prefix=\"\",suffix=\"\",separator=\",\"}=props;const[currentValue,setCurrentValue]=useState(startValue);// A ref, not state: toggling it must not re-run the start effect.\n// (As state, an off-screen counter with autoStart + resetOnReEntry\n// flipped it true/false forever and froze the page.)\nconst hasStartedRef=useRef(false);const animationRef=useRef();const loopTimeoutRef=useRef();const startTimeRef=useRef();const containerRef=useRef(null);const isStatic=useIsStaticRenderer();const isInView=useInView(containerRef,{once:!resetOnReEntry,margin:\"0px 0px -10% 0px\"});const formatNumber=useMemo(()=>{return value=>{const fixed=value.toFixed(decimals);if(separator&&Math.abs(value)>=1e3){const parts=fixed.split(\".\");parts[0]=parts[0].replace(/\\B(?=(\\d{3})+(?!\\d))/g,separator);return parts.join(\".\");}return fixed;};},[decimals,separator]);const easeValue=useMemo(()=>{return t=>{const[x1,y1,x2,y2]=easingMap[easing];if(easing===\"linear\")return t;if(easing===\"bounce\"){if(t<1/2.75){return 7.5625*t*t;}else if(t<2/2.75){return 7.5625*(t-=1.5/2.75)*t+.75;}else if(t<2.5/2.75){return 7.5625*(t-=2.25/2.75)*t+.9375;}else{return 7.5625*(t-=2.625/2.75)*t+.984375;}}// Cubic bezier approximation\nreturn 3*(1-t)*(1-t)*t*y1+3*(1-t)*t*t*y2+t*t*t;};},[easing]);const animate=useMemo(()=>{const tick=timestamp=>{if(startTimeRef.current===undefined){startTimeRef.current=timestamp+delay*1e3;}const elapsed=timestamp-startTimeRef.current;const progress=Math.min(elapsed/(duration*1e3),1);if(progress>=0){const easedProgress=easeValue(progress);const newValue=startValue+(endValue-startValue)*easedProgress;startTransition(()=>{setCurrentValue(newValue);});if(progress>=1){animationRef.current=undefined;if(loop){// Hold the end value briefly, then restart. The timeout is\n// tracked so cleanup can cancel it.\nloopTimeoutRef.current=setTimeout(()=>{loopTimeoutRef.current=undefined;startTimeRef.current=undefined;startTransition(()=>{setCurrentValue(startValue);});animationRef.current=requestAnimationFrame(tick);},100);}return;}}animationRef.current=requestAnimationFrame(tick);};return tick;},[startValue,endValue,duration,delay,loop,easeValue]);// With resetOnReEntry the counter replays each time it scrolls into view;\n// otherwise it runs once, on mount (autoStart) or on first view.\nconst shouldRun=resetOnReEntry?isInView:autoStart||isInView;useEffect(()=>{if(isStatic){setCurrentValue(endValue);return;}if(!shouldRun){if(resetOnReEntry&&hasStartedRef.current){hasStartedRef.current=false;startTimeRef.current=undefined;startTransition(()=>{setCurrentValue(startValue);});}return;}if(hasStartedRef.current)return;hasStartedRef.current=true;startTimeRef.current=undefined;startTransition(()=>{setCurrentValue(startValue);});animationRef.current=requestAnimationFrame(animate);return()=>{const interrupted=animationRef.current!==undefined||loopTimeoutRef.current!==undefined;if(animationRef.current!==undefined){cancelAnimationFrame(animationRef.current);animationRef.current=undefined;}if(loopTimeoutRef.current!==undefined){clearTimeout(loopTimeoutRef.current);loopTimeoutRef.current=undefined;}// Let the next run restart an animation that was cut short.\nif(interrupted)hasStartedRef.current=false;};},[shouldRun,resetOnReEntry,isStatic,startValue,endValue,animate]);const displayValue=formatNumber(currentValue);const fullText=`${prefix}${displayValue}${suffix}`;return /*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:{position:\"relative\",width:\"max-content\",minWidth:\"max-content\",...props.style},children:/*#__PURE__*/_jsx(\"span\",{style:{display:\"block\",textAlign,color,width:\"max-content\",fontSize:`${fontSize}px`,...font},children:fullText})});}addPropertyControls(Counter,{startValue:{type:ControlType.Number,title:\"Start Value\",defaultValue:0,step:.1},endValue:{type:ControlType.Number,title:\"End Value\",defaultValue:100,step:.1},duration:{type:ControlType.Number,title:\"Duration\",defaultValue:2,min:.1,max:10,step:.1,unit:\"s\"},delay:{type:ControlType.Number,title:\"Delay\",defaultValue:0,min:0,max:5,step:.1,unit:\"s\"},decimals:{type:ControlType.Number,title:\"Decimals\",defaultValue:0,min:0,max:4,step:1,displayStepper:true},easing:{type:ControlType.Enum,title:\"Easing\",options:[\"linear\",\"easeIn\",\"easeOut\",\"easeInOut\",\"bounce\"],optionTitles:[\"Linear\",\"Ease In\",\"Ease Out\",\"Ease In Out\",\"Bounce\"],defaultValue:\"easeOut\"},font:{type:ControlType.Font,title:\"Font\",defaultValue:{fontSize:\"32px\",variant:\"Bold\",letterSpacing:\"-0.03em\",lineHeight:\"1em\"},controls:\"extended\",defaultFontType:\"sans-serif\"},fontSize:{type:ControlType.Number,title:\"Font Size\",defaultValue:32,min:8,max:200,step:1,unit:\"px\"},textAlign:{type:ControlType.Enum,title:\"Text Align\",options:[\"left\",\"center\",\"right\"],optionTitles:[\"Left\",\"Center\",\"Right\"],defaultValue:\"left\",displaySegmentedControl:true},color:{type:ControlType.Color,title:\"Color\",defaultValue:\"#000000\"},autoStart:{type:ControlType.Boolean,title:\"Auto Start\",defaultValue:true,enabledTitle:\"On\",disabledTitle:\"Off\"},loop:{type:ControlType.Boolean,title:\"Loop\",defaultValue:false,enabledTitle:\"On\",disabledTitle:\"Off\"},resetOnReEntry:{type:ControlType.Boolean,title:\"Reset on Re-entry\",defaultValue:false,enabledTitle:\"On\",disabledTitle:\"Off\"},prefix:{type:ControlType.String,title:\"Prefix\",defaultValue:\"\",placeholder:\"$\"},suffix:{type:ControlType.String,title:\"Suffix\",defaultValue:\"\",placeholder:\"%\"},separator:{type:ControlType.String,title:\"Thousands Separator\",defaultValue:\",\",placeholder:\",\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"Counter\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"auto\",\"framerSupportedLayoutWidth\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./NumberCounter.map"],"mappings":"A,iQAIG,SAAwBkB,EAAQ,EAAM,CAAC,GAAK,CAAC,aAAW,EAAE,WAAS,IAAI,WAAS,EAAE,QAAM,EAAE,WAAS,EAAE,SAAO,UAAU,OAAK,WAAS,GAAG,YAAU,OAAO,QAAM,UAAU,YAAU,GAAK,OAAK,GAAM,iBAAe,GAAM,SAAO,GAAG,SAAO,GAAG,YAAU,KAAKC,EAAW,CAACC,EAAaC,GAAiBrB,EAASsB,CAAU,EAGpTC,EAActB,EAAO,EAAK,EAAQuB,EAAavB,EAAO,EAAQwB,EAAexB,EAAO,EAAQyB,EAAazB,EAAO,EAAQ0B,EAAa1B,EAAO,IAAI,EAAQ2B,EAASb,EAAoB,EAAQc,EAASjB,EAAUe,EAAa,CAAC,KAAK,CAACG,EAAe,OA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