{"version":3,"file":"CountUp.Cb9qO0DT.mjs","names":["useState","useRef","useMemo"],"sources":["https:/framerusercontent.com/modules/zsRasu14587hAO5MFCWo/AdTJg3C4hyPDcZFAFbJJ/CountUp.js"],"sourcesContent":["// Animated Counter with comma formatting, dynamic duration, customizable speed, fonts, and colors\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useRef,useState,useMemo,startTransition}from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";function formatNumber(n){return n.toLocaleString();}function getDuration(start,end,speed){// duration in ms, speed is a multiplier (1 = normal, 2 = 2x faster)\nconst diff=Math.abs(end-start);// 0.5s min, 2.5s max, scale with diff, speed is 1-5\nconst base=Math.min(2500,Math.max(500,diff*20));return base/speed;}/**\n * Animated Counter\n *\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n */export default function CountUp(props){const{value,startValue,speed,font,color,background,decimalPlaces,style}=props;const isStatic=useIsStaticRenderer();const[display,setDisplay]=useState(startValue);const raf=useRef(null);const prevValue=useRef(startValue);useEffect(()=>{if(isStatic){startTransition(()=>setDisplay(value));return;}if(value===prevValue.current)return;let start=prevValue.current;let end=value;let duration=getDuration(start,end,speed);let startTime=null;let cancelled=false;function animate(ts){if(cancelled)return;if(!startTime)startTime=ts;let progress=Math.min(1,(ts-startTime)/duration);// easeOutCubic\nlet eased=1-Math.pow(1-progress,3);let current=start+(end-start)*eased;if(decimalPlaces>0)current=parseFloat(current.toFixed(decimalPlaces));else current=Math.round(current);startTransition(()=>setDisplay(current));if(progress<1){raf.current=requestAnimationFrame(animate);}else{startTransition(()=>setDisplay(end));prevValue.current=end;}}raf.current&&cancelAnimationFrame(raf.current);raf.current=requestAnimationFrame(animate);return()=>{cancelled=true;raf.current&&cancelAnimationFrame(raf.current);};},[value,speed,decimalPlaces,isStatic]);const formatted=useMemo(()=>{if(decimalPlaces>0)return Number(display).toLocaleString(undefined,{minimumFractionDigits:decimalPlaces,maximumFractionDigits:decimalPlaces});return formatNumber(Math.round(display));},[display,decimalPlaces]);return /*#__PURE__*/_jsx(\"div\",{style:{...style,display:\"inline-block\",background,color,...font,minWidth:\"max-content\",borderRadius:8,textAlign:\"right\",transition:\"background 0.2s, color 0.2s\"},\"aria-live\":\"polite\",children:formatted});}addPropertyControls(CountUp,{value:{type:ControlType.Number,title:\"Value\",defaultValue:1e3,min:-1e6,max:1e6,displayStepper:true},startValue:{type:ControlType.Number,title:\"Start\",defaultValue:0,min:-1e6,max:1e6,displayStepper:true},decimalPlaces:{type:ControlType.Number,title:\"Decimals\",defaultValue:0,min:0,max:4,displayStepper:true},speed:{type:ControlType.Number,title:\"Speed\",defaultValue:1.5,min:.5,max:5,step:.1,unit:\"x\",displayStepper:true},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"40px\",variant:\"Bold\",letterSpacing:\"-0.04em\",lineHeight:\"1em\"}},color:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\"},background:{type:ControlType.Color,title:\"Background\",defaultValue:\"#FFFFFF\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CountUp\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"auto\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CountUp.map"],"mappings":"yMACwL,SAAS,EAAa,EAAE,CAAC,OAAO,EAAE,gBAAgB,CAAE,SAAS,EAAY,EAAM,EAAI,EAAM,CACjR,IAAM,EAAK,KAAK,IAAI,EAAI,EAAM,CACkB,OAArC,KAAK,IAAI,KAAK,KAAK,IAAI,IAAI,EAAK,GAAG,CAAC,CAAa,EAKzD,SAAwB,EAAQ,EAAM,CAAC,GAAK,CAAC,QAAM,aAAW,QAAM,OAAK,QAAM,aAAW,gBAAc,SAAO,EAAY,EAAS,GAAqB,CAAM,CA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