{"version":3,"file":"Counter.BziAHTBi.mjs","names":["useState","useRef"],"sources":["https:/framerusercontent.com/modules/fDGKOcQA3wQo6eT2dLGP/yb7Tm7K73g3zhsd2VoHn/Counter.js"],"sourcesContent":["// Text counter that animates numbers counting up when the component appears in viewport\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useState,useRef,startTransition}from\"react\";import{addPropertyControls,ControlType,useInView}from\"framer\";/**\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n */export default function Counter(props){const{targetNumber=1e3,duration=2,prefix=\"\",suffix=\"\",decimals=0,separator=true,textColor=\"#000000\",font,style}=props;const[count,setCount]=useState(0);const ref=useRef(null);const isInView=useInView(ref,{once:true});const hasAnimated=useRef(false);useEffect(()=>{if(!isInView||hasAnimated.current)return;hasAnimated.current=true;const startTime=Date.now();const endTime=startTime+duration*1e3;const animate=()=>{const now=Date.now();const progress=Math.min((now-startTime)/(duration*1e3),1);// Easing function for smooth animation\nconst easeOutQuart=1-Math.pow(1-progress,4);const currentCount=easeOutQuart*targetNumber;startTransition(()=>{setCount(currentCount);});if(progress<1){requestAnimationFrame(animate);}else{startTransition(()=>{setCount(targetNumber);});}};requestAnimationFrame(animate);},[isInView,targetNumber,duration]);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(\".\");};return /*#__PURE__*/_jsx(\"div\",{ref:ref,style:{...style,position:\"relative\",width:\"max-content\",minWidth:\"max-content\"},children:/*#__PURE__*/_jsxs(\"span\",{style:{color:textColor,...font,whiteSpace:\"nowrap\"},children:[prefix,formatNumber(count),suffix]})});}addPropertyControls(Counter,{targetNumber:{type:ControlType.Number,title:\"Target Number\",defaultValue:1e3,min:0,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:{fontSize:\"40px\",variant:\"Bold\",letterSpacing:\"-0.04em\",lineHeight:\"1em\"}}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"Counter\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"auto\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Counter.map"],"mappings":"iPAIG,SAAwB,EAAQ,EAAM,CAAC,GAAK,CAAC,eAAa,IAAI,WAAS,EAAE,SAAO,GAAG,SAAO,GAAG,WAAS,EAAE,YAAU,GAAK,YAAU,UAAU,OAAK,SAAO,EAAW,CAAC,EAAM,GAAUA,EAAS,CAAC,EAAQ,EAAIC,EAAO,IAAI,EAAQ,EAAS,EAAU,EAAI,CAAC,KAAK,EAAI,CAAC,EAAQ,EAAYA,EAAO,EAAK,EAAE,MAAc,CAAC,GAAG,CAAC,GAAU,EAAY,QAAQ,OAAO,EAAY,QAAQ,GAAK,IAAM,EAAU,KAAK,IAAI,EAAgB,EAAU,EAAS,IAAI,IAAM,MAAY,CAAsB,IAAM,EAAS,KAAK,KAA/B,KAAK,IAAiC,EAAE,IAAY,EAAS,KAAK,CAAC,EACle,GAA/B,GAAW,EAAE,IAAS,GAAmC,EAAa,MAAoB,CAAC,EAAS,CAAY,CAAE,CAAC,EAAK,EAAS,EAAG,sBAAsB,CAAO,EAAQ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