{"version":3,"file":"SmartCounter.BA6Q79iy.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/g7uxAVK9kxukiolXnKLG/KJG6UImKoZvGIZ90s30D/SmartCounter.js"],"sourcesContent":["// Smart counter with prefix/suffix text, customizable styling, and accessibility features\nimport{jsx as _jsx}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 * Smart Counter\n * \n * An animated counter component with customizable prefix/suffix text,\n * number formatting, and accessibility features.\n *\n * @framerIntrinsicWidth 200\n * @framerIntrinsicHeight 60\n *\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n */export default function SmartCounter(props){const{startValue=0,endValue=100,duration=2,prefix=\"\",suffix=\"\",decimals=0,separator=true,animateOnView=true,textColor=\"#000000\",font,style}=props;const ref=useRef(null);const isInView=useInView(ref,{once:true,amount:.5});const motionValue=useMotionValue(startValue);const springValue=useSpring(motionValue,{duration:duration*1e3,bounce:0});const[displayValue,setDisplayValue]=useState(startValue);useEffect(()=>{if(!animateOnView||isInView){motionValue.set(endValue);}},[isInView,animateOnView,endValue,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[integer,decimal]=fixed.split(\".\");const formattedInteger=integer.replace(/\\B(?=(\\d{3})+(?!\\d))/g,\",\");return decimal!==undefined?`${formattedInteger}.${decimal}`:formattedInteger;};const formattedValue=formatNumber(displayValue);const fullText=`${prefix}${formattedValue}${suffix}`;return /*#__PURE__*/_jsx(\"div\",{ref:ref,style:{...style,position:\"relative\",width:\"max-content\",minWidth:\"max-content\"},children:/*#__PURE__*/_jsx(motion.span,{style:{color:textColor,...font,display:\"inline-block\",whiteSpace:\"nowrap\"},role:\"status\",\"aria-live\":\"polite\",\"aria-atomic\":\"true\",\"aria-label\":`Counter: ${fullText}`,children:fullText})});}addPropertyControls(SmartCounter,{startValue:{type:ControlType.Number,title:\"Start Value\",defaultValue:0,step:1,displayStepper:true},endValue:{type:ControlType.Number,title:\"End Value\",defaultValue:100,step:1,displayStepper:true},duration:{type:ControlType.Number,title:\"Duration\",defaultValue:2,min:.1,max:10,step:.1,unit:\"s\"},prefix:{type:ControlType.String,title:\"Prefix\",defaultValue:\"\",placeholder:\"e.g., $\"},suffix:{type:ControlType.String,title:\"Suffix\",defaultValue:\"\",placeholder:\"e.g., %\"},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\"},animateOnView:{type:ControlType.Boolean,title:\"Animate\",defaultValue:true,enabledTitle:\"On View\",disabledTitle:\"Always\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"40px\",variant:\"Bold\",letterSpacing:\"-0.04em\",lineHeight:\"1em\"}}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"SmartCounter\",\"slots\":[],\"annotations\":{\"framerIntrinsicWidth\":\"200\",\"framerSupportedLayoutHeight\":\"auto\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"auto\",\"framerIntrinsicHeight\":\"60\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./SmartCounter.map"],"mappings":"iQAYG,SAAwB,EAAa,EAAM,CAAC,GAAK,CAAC,aAAW,EAAE,WAAS,IAAI,WAAS,EAAE,SAAO,GAAG,SAAO,GAAG,WAAS,EAAE,YAAU,GAAK,gBAAc,GAAK,YAAU,UAAU,OAAK,SAAO,EAAY,EAAIA,EAAO,KAAK,CAAO,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