{"version":3,"file":"AnimatedCounter.BaugbXK0.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/7HtMLHUp4fJijz7V89ms/AFix24pAeTXU9oWiKd2z/AnimatedCounter.js"],"sourcesContent":["// Animated Number Counter\n// Counts from 0 to a target number with optional symbol (e.g. +, %, etc). Animation starts when visible, supports delay and ease-in. Multiple counters can be placed on one page.\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useRef,useState,startTransition}from\"react\";import{addPropertyControls,ControlType,useInView}from\"framer\";/**\n * Animated Number Counter\n *\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n */export default function AnimatedCounter(props){const{number=\"100+\",duration=1.2,delay=0,font,color,style}=props;const ref=useRef(null);const isInView=useInView(ref,{amount:.5,once:true});const[display,setDisplay]=useState(\"0\");const[hasAnimated,setHasAnimated]=useState(false);// Parse number and symbol\nconst match=number.match(/^(\\d+)(.*)$/);const target=match?parseInt(match[1],10):0;const symbol=match?match[2]:\"\";useEffect(()=>{if(!isInView||hasAnimated)return;let timeout;let frame;let start=null;function animate(ts){if(start===null)start=ts;const elapsed=(ts-start)/1e3;const t=Math.min(1,elapsed/duration);// ease-in-out cubic\nconst eased=t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2;const val=Math.round(target*eased);startTransition(()=>setDisplay(val.toLocaleString()+symbol));if(t<1){frame=requestAnimationFrame(animate);}else{startTransition(()=>setDisplay(target.toLocaleString()+symbol));setHasAnimated(true);}}timeout=window.setTimeout(()=>{frame=requestAnimationFrame(animate);},delay*1e3);return()=>{if(timeout)clearTimeout(timeout);if(frame)cancelAnimationFrame(frame);};},[isInView,hasAnimated,target,symbol,duration,delay]);return /*#__PURE__*/_jsx(\"div\",{ref:ref,style:{...style,color,...font,width:\"max-content\",minWidth:1,minHeight:1,display:\"inline-block\",position:\"relative\",userSelect:\"none\"},\"aria-live\":\"polite\",children:display});}addPropertyControls(AnimatedCounter,{number:{type:ControlType.String,title:\"Number\",defaultValue:\"100+\",placeholder:\"e.g. 100+ or 50%\"},duration:{type:ControlType.Number,title:\"Duration\",defaultValue:1.2,min:.2,max:10,step:.1,unit:\"s\"},delay:{type:ControlType.Number,title:\"Delay\",defaultValue:0,min:0,max:5,step:.1,unit:\"s\"},font:{type:ControlType.Font,title:\"Text Style\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"40px\",variant:\"Bold\",letterSpacing:\"-0.04em\",lineHeight:\"1em\"}},color:{type:ControlType.Color,title:\"Color\",defaultValue:\"#000000\"}});\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":"kPAOG,SAAwB,EAAgB,EAAM,CAAC,GAAK,CAAC,SAAO,OAAO,WAAS,IAAI,QAAM,EAAE,OAAK,QAAM,SAAO,EAAY,EAAIA,EAAO,IAAI,EAAQ,EAAS,EAAU,EAAI,CAAC,OAAO,GAAG,KAAK,EAAI,CAAC,EAAO,CAAC,EAAQ,GAAYC,EAAS,GAAG,EAAO,CAAC,EAAY,GAAgBA,EAAS,EAAK,EAChR,EAAM,EAAO,MAAM,aAAa,EAAQ,EAAO,EAAM,SAAS,EAAM,GAAG,EAAE,EAAE,EAAQ,EAAO,EAAM,EAAM,GAAG,GACsY,OADnY,MAAc,CAAC,GAAG,CAAC,GAAU,EAAY,OAAO,IAAI,EAAY,EAAU,EAAM,KAAK,SAAS,EAAQ,EAAG,CAAI,IAAQ,OAAK,EAAM,GAAG,IAAM,GAAS,EAAG,GAAO,IAAU,EAAE,KAAK,IAAI,EAAE,EAAQ,CAAQ,EAC/S,EAAM,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,GAAW,GAAG,EAAE,IAA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