{"version":3,"file":"Counter.CNNmo07N.mjs","names":["useState","useRef","useMemo"],"sources":["https:/framerusercontent.com/modules/r7gVIaC51WfFFqxG97ls/B7qhMGyQpp9Rt2J5NFmY/Counter.js"],"sourcesContent":["// Animated counter component that counts up from 0 to the target value\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useState,startTransition,useMemo}from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";import{motion,useInView}from\"framer-motion\";import{useRef}from\"react\";/**\n * Animated Counter Component\n * \n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n */export default function Counter(props){const{value=100,duration=2e3,delay=0,prefix=\"\",suffix=\"\",separator=\"\",decimals=0,font,color=\"#000000\",triggerOnView=true,resetOnComplete=false}=props;const[currentValue,setCurrentValue]=useState(0);const[isAnimating,setIsAnimating]=useState(false);const[hasAnimated,setHasAnimated]=useState(false);const ref=useRef(null);const isInView=useInView(ref,{once:!resetOnComplete});const isStatic=useIsStaticRenderer();const shouldAnimate=useMemo(()=>{if(isStatic)return false;return triggerOnView?isInView:true;},[isStatic,triggerOnView,isInView]);useEffect(()=>{if(!shouldAnimate||isAnimating||hasAnimated)return;const startTime=Date.now()+delay;const endValue=Math.max(0,value);startTransition(()=>setIsAnimating(true));const animate=()=>{const now=Date.now();const elapsed=now-startTime;if(elapsed<0){requestAnimationFrame(animate);return;}const progress=Math.min(elapsed/duration,1);const easeOutQuart=1-Math.pow(1-progress,4);const newValue=easeOutQuart*endValue;startTransition(()=>setCurrentValue(newValue));if(progress<1){requestAnimationFrame(animate);}else{startTransition(()=>{setIsAnimating(false);setHasAnimated(true);});}};requestAnimationFrame(animate);},[shouldAnimate,value,duration,delay,isAnimating,hasAnimated]);useEffect(()=>{if(resetOnComplete&&!isInView){startTransition(()=>{setCurrentValue(0);setIsAnimating(false);setHasAnimated(false);});}},[isInView,resetOnComplete]);const formatNumber=num=>{const rounded=decimals>0?num.toFixed(decimals):Math.floor(num).toString();if(separator&&separator!==\"\"){const parts=rounded.split(\".\");parts[0]=parts[0].replace(/\\B(?=(\\d{3})+(?!\\d))/g,separator);return parts.join(\".\");}return rounded;};const displayValue=isStatic?formatNumber(value):formatNumber(currentValue);const fullText=`${prefix}${displayValue}${suffix}`;const isFixedWidth=props?.style&&props.style.width===\"100%\";return /*#__PURE__*/_jsx(motion.div,{ref:ref,style:{...props.style,...isFixedWidth?{}:{width:\"max-content\"},display:\"inline-block\",color,...font},initial:false,children:fullText});}addPropertyControls(Counter,{value:{type:ControlType.Number,title:\"Target Value\",defaultValue:100,min:0,step:1},duration:{type:ControlType.Number,title:\"Duration\",defaultValue:2e3,min:100,max:1e4,step:100,unit:\"ms\"},delay:{type:ControlType.Number,title:\"Delay\",defaultValue:0,min:0,max:5e3,step:100,unit:\"ms\"},decimals:{type:ControlType.Number,title:\"Decimal Places\",defaultValue:0,min:0,max:3,step:1,displayStepper:true},prefix:{type:ControlType.String,title:\"Prefix\",defaultValue:\"\",placeholder:\"$, €, etc.\"},suffix:{type:ControlType.String,title:\"Suffix\",defaultValue:\"\",placeholder:\"%, K, M, etc.\"},separator:{type:ControlType.String,title:\"Thousands Separator\",defaultValue:\"\",placeholder:\", or .\"},triggerOnView:{type:ControlType.Boolean,title:\"Trigger on View\",defaultValue:true,enabledTitle:\"On Scroll\",disabledTitle:\"Immediate\"},resetOnComplete:{type:ControlType.Boolean,title:\"Reset Animation\",defaultValue:false,enabledTitle:\"Repeat\",disabledTitle:\"Once\",hidden:({triggerOnView})=>!triggerOnView},color:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\"},font:{type:ControlType.Font,title:\"Font\",defaultValue:{fontSize:\"32px\",variant:\"Bold\",letterSpacing:\"-0.03em\",lineHeight:\"1em\"},controls:\"extended\",defaultFontType:\"sans-serif\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"Counter\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"auto\",\"fram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