{"version":3,"file":"NewCounter.R3hRWQ2o.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/XV2aBbWlem9qyX8HacJb/UlwEibQLkwPBWDvOwUJ2/NewCounter.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{animate,motion,useMotionValue,useTransform}from\"framer-motion\";import{addPropertyControls,ControlType}from\"framer\";import{useEffect,useRef,useState}from\"react\";/**\n * @framerDisableUnlink\n */export default function AnimatedCounter(props){const{from,to,duration,font,color,decimalPlaces,prefix,suffix,useCommas}=props;const count=useMotionValue(from);const rounded=useTransform(()=>{const value=count.get();let formattedValue;if(decimalPlaces>0){formattedValue=parseFloat(value.toFixed(decimalPlaces));}else{formattedValue=Math.round(value);}// Add comma formatting if enabled\nlet displayValue=formattedValue.toString();if(useCommas){const parts=displayValue.split(\".\");parts[0]=parts[0].replace(/\\B(?=(\\d{3})+(?!\\d))/g,\",\");displayValue=parts.join(\".\");}// Add prefix and suffix\nreturn`${prefix||\"\"}${displayValue}${suffix||\"\"}`;});const ref=useRef(null);const[isInView,setIsInView]=useState(false);const fontStyle={fontFamily:font?.fontFamily,fontSize:font?.fontSize,fontWeight:font?.fontWeight,lineHeight:font?.lineHeight,letterSpacing:font?.letterSpacing,color};useEffect(()=>{const observer=new IntersectionObserver(([entry])=>{if(entry.isIntersecting&&!isInView){setIsInView(true);}},{threshold:.1,rootMargin:\"0px 0px -50px 0px\"});if(ref.current){observer.observe(ref.current);}return()=>observer.disconnect();},[isInView]);useEffect(()=>{if(isInView){const controls=animate(count,to,{duration});return()=>controls.stop();}},[isInView,count]);return /*#__PURE__*/_jsx(motion.pre,{ref:ref,style:{...fontStyle,margin:0},children:rounded});}AnimatedCounter.defaultProps={from:0,to:100,duration:2,decimalPlaces:0,prefix:\"\",suffix:\"\",useCommas:false};addPropertyControls(AnimatedCounter,{from:{type:ControlType.Number},to:{type:ControlType.Number},duration:{type:ControlType.Number},decimalPlaces:{type:ControlType.Number,defaultValue:0,min:0,max:10,step:1,title:\"Decimal Places\"},prefix:{type:ControlType.String,defaultValue:\"\",title:\"Prefix\",placeholder:\"e.g., $, €, #\"},suffix:{type:ControlType.String,defaultValue:\"\",title:\"Suffix\",placeholder:\"e.g., %, k, M\"},useCommas:{type:ControlType.Boolean,defaultValue:false,title:\"Use Commas\"},font:{type:ControlType.Font,controls:\"extended\"},color:{type:ControlType.Color,defaultValue:\"#000\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"AnimatedCounter\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerDisableUnlink\":\"\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./NewCounter.map"],"mappings":"+PAEG,SAAwB,EAAgB,EAAM,CAAC,GAAK,CAAC,OAAK,KAAG,WAAS,OAAK,QAAM,gBAAc,SAAO,SAAO,aAAW,EAAY,EAAM,EAAe,CAAI,EAAQ,EAAQ,MAAiB,CAAC,IAAM,EAAM,EAAM,IAAI,EAAM,EAAe,AAAkF,EAA/E,EAAc,EAAkB,WAAW,EAAM,QAAQ,CAAa,CAAC,EAAuB,KAAK,MAAM,CAAK,EAC9V,IAAI,EAAa,EAAe,SAAS,EAAE,GAAG,EAAU,CAAC,IAAM,EAAM,EAAa,MAAM,GAAG,EAAE,EAAM,GAAG,EAAM,EAAE,CAAC,QAAQ,wBAAwB,GAAG,EAAE,EAAa,EAAM,KAAK,GAAG,CAAE,CACjL,MAAM,GAAG,GAAQ,KAAK,IAAe,GAAQ,IAAK,CAAC,EAAQ,EAAIA,EAAO,IAAI,EAAO,CAAC,EAAS,GAAaC,EAAS,EAAK,EAAQ,EAAU,CAAC,WAAW,GAAM,WAAW,SAAS,GAAM,SAAS,WAAW,GAAM,WAAW,WAAW,GAAM,WAAW,cAAc,GAAM,cAAc,OAAK,EAAiY,OAA/X,MAAc,CAAC,IAAM,EAAS,IAAI,sBAAsB,CAAC,KAAS,CAAI,EAAM,gBA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