{"version":3,"file":"AnimatedCounter.C0SYOr6I.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/k3nE0X6fKDTRkmcyclND/57jupE3x5qs7fjovjfhu/AnimatedCounter.js"],"sourcesContent":["// Animated number counter with start/end values, viewport trigger, customizable font/color, and prefix/suffix support\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useState,useRef,startTransition}from\"react\";import{addPropertyControls,ControlType}from\"framer\";import{useInView,motion,useSpring}from\"framer-motion\";/**\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n */export default function AnimatedCounter(props){const{startNumber=0,endNumber=100,duration=2,prefix=\"\",suffix=\"\",textColor=\"#000000\",font,decimals=0,separator=true}=props;const ref=useRef(null);const isInView=useInView(ref,{once:true,amount:.5});const[hasAnimated,setHasAnimated]=useState(false);const[displayValue,setDisplayValue]=useState(\"\");const springValue=useSpring(startNumber,{duration:duration*1e3,bounce:0});useEffect(()=>{const unsubscribe=springValue.on(\"change\",latest=>{const formatted=latest.toFixed(decimals);if(separator){const parts=formatted.split(\".\");parts[0]=parts[0].replace(/\\B(?=(\\d{3})+(?!\\d))/g,\",\");setDisplayValue(parts.join(\".\"));}else{setDisplayValue(formatted);}});return unsubscribe;},[springValue,decimals,separator]);useEffect(()=>{if(isInView&&!hasAnimated){startTransition(()=>{springValue.set(endNumber);setHasAnimated(true);});}},[isInView,hasAnimated,endNumber,springValue]);return /*#__PURE__*/_jsx(\"div\",{ref:ref,style:{display:\"inline-flex\",alignItems:\"center\",justifyContent:\"center\",width:\"max-content\",minWidth:\"max-content\"},children:/*#__PURE__*/_jsxs(motion.span,{style:{color:textColor,...font,whiteSpace:\"nowrap\"},children:[prefix,displayValue,suffix]})});}addPropertyControls(AnimatedCounter,{startNumber:{type:ControlType.Number,title:\"Start Number\",defaultValue:0,step:1},endNumber:{type:ControlType.Number,title:\"End Number\",defaultValue:100,step:1},duration:{type:ControlType.Number,title:\"Duration\",defaultValue:2,min:.1,max:10,step:.1,unit:\"s\"},decimals:{type:ControlType.Number,title:\"Decimals\",defaultValue:0,min:0,max:4,step:1},separator:{type:ControlType.Boolean,title:\"Separator\",defaultValue:true,enabledTitle:\"On\",disabledTitle:\"Off\"},prefix:{type:ControlType.String,title:\"Prefix\",defaultValue:\"\",placeholder:\"$\"},suffix:{type:ControlType.String,title:\"Suffix\",defaultValue:\"\",placeholder:\"%\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{variant:\"Bold\",letterSpacing:\"-0.04em\",lineHeight:\"1em\"}}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"AnimatedCounter\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"auto\",\"framerSupportedLayoutWidth\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./AnimatedCounter.map"],"mappings":"qQAIG,SAAwB,EAAgB,EAAM,CAAC,GAAK,CAAC,cAAY,EAAE,YAAU,IAAI,WAAS,EAAE,SAAO,GAAG,SAAO,GAAG,YAAU,UAAU,OAAK,WAAS,EAAE,YAAU,IAAM,EAAY,EAAIA,EAAO,IAAI,EAAQ,EAAS,EAAU,EAAI,CAAC,KAAK,GAAK,OAAO,EAAE,CAAC,EAAO,CAAC,EAAY,GAAgBC,EAAS,EAAK,EAAO,CAAC,EAAa,GAAiBA,EAAS,EAAE,EAAQ,EAAY,EAAU,EAAY,CAAC,SAAS,EAAS,IAAI,OAAO,CAAC,CAAC,EAAmf,OAAjf,MAAiC,EAAY,GAAG,SAAS,GAAQ,CAAC,IAAM,EAAU,EAAO,QAAQ,CAAQ,EAAE,GAAG,EAAU,CAAC,IAAM,EAAM,EAAU,MAAM,GAAG,EAAE,EAAM,GAAG,EAAM,EAAE,CAAC,QAAQ,wBA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