{"version":3,"file":"NumberCounter.CVFBTsMA.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/vMmSDjOZCHZ0v1SklV6L/9zdteqOGG3n18GoQj6qi/NumberCounter.js"],"sourcesContent":["// NumberCounter component with animated number transitions, customizable start/end values, and prefix/suffix options\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useState,useRef,startTransition}from\"react\";import{addPropertyControls,ControlType}from\"framer\";import{motion,useInView,useMotionValue,useSpring}from\"framer-motion\";/**\n * Animated NumberCounter\n * \n * @framerIntrinsicWidth 200\n * @framerIntrinsicHeight 60\n * \n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n */export default function NumberCounter(props){const{startNumber=0,endNumber=100,duration=2,prefix=\"\",suffix=\"\",decimals=0,separator=true,font,textColor=\"#000000\",style}=props;const ref=useRef(null);const isInView=useInView(ref,{once:true,margin:\"-100px\"});const motionValue=useMotionValue(startNumber);const springValue=useSpring(motionValue,{duration:duration*1e3,bounce:0});const[displayValue,setDisplayValue]=useState(startNumber);useEffect(()=>{if(isInView){motionValue.set(endNumber);}},[isInView,endNumber,motionValue]);useEffect(()=>{const unsubscribe=springValue.on(\"change\",latest=>{startTransition(()=>{setDisplayValue(latest);});});return()=>unsubscribe();},[springValue]);const formatNumber=num=>{const fixed=num.toFixed(decimals);if(!separator)return fixed;const parts=fixed.split(\".\");parts[0]=parts[0].replace(/\\B(?=(\\d{3})+(?!\\d))/g,\",\");return parts.join(\".\");};const formattedValue=formatNumber(displayValue);return /*#__PURE__*/_jsx(\"div\",{ref:ref,style:{...style,position:\"relative\",display:\"inline-flex\",alignItems:\"center\",justifyContent:\"center\",width:\"max-content\"},children:/*#__PURE__*/_jsxs(motion.span,{style:{...font,color:textColor,whiteSpace:\"nowrap\"},children:[prefix,formattedValue,suffix]})});}addPropertyControls(NumberCounter,{startNumber:{type:ControlType.Number,title:\"Start Number\",defaultValue:0,step:1,displayStepper:true},endNumber:{type:ControlType.Number,title:\"End Number\",defaultValue:100,step:1,displayStepper:true},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,displayStepper:true},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:\"%\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"40px\",variant:\"Bold\",letterSpacing:\"-0.04em\",lineHeight:\"1em\"}},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"NumberCounter\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"auto\",\"framerIntrinsicHeight\":\"60\",\"framerSupportedLayoutWidth\":\"auto\",\"framerIntrinsicWidth\":\"200\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./NumberCounter.map"],"mappings":"4QASG,SAAwB,EAAc,EAAM,CAAC,GAAK,CAAC,cAAY,EAAE,YAAU,IAAI,WAAS,EAAE,SAAO,GAAG,SAAO,GAAG,WAAS,EAAE,YAAU,GAAK,OAAK,YAAU,UAAU,SAAO,EAAY,EAAIA,EAAO,KAAK,CAAO,EAAS,EAAU,EAAI,CAAC,KAAK,GAAK,OAAO,SAAS,CAAC,CAAO,EAAY,EAAe,EAAY,CAAO,EAAY,EAAU,EAAY,CAAC,SAAS,EAAS,IAAI,OAAO,EAAE,CAAC,CAAM,CAAC,EAAa,GAAiBC,EAAS,EAAY,CAAC,MAAc,CAAI,GAAU,EAAY,IAAI,EAAU,EAAI,CAAC,EA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