{"version":3,"file":"CounterUp.BEBMzq12.mjs","names":["useState","useRef"],"sources":["https:/framerusercontent.com/modules/8Lgjftuijeo80bUSO0tq/7VrXkBNPrSHcxjHFZwju/CounterUp.js"],"sourcesContent":["// Counter Up component with prefix/suffix controls, editable number, and typography controls\nimport{jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useState,useRef,startTransition}from\"react\";import{addPropertyControls,ControlType}from\"framer\";import{useInView}from\"framer-motion\";/**\n * Counter Up\n *\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n */export default function CounterUp(props){const{value,duration,prefixEnabled,prefix,suffixEnabled,suffix,font,style}=props;const[count,setCount]=useState(0);const[hasAnimated,setHasAnimated]=useState(false);const ref=useRef(null);const inView=useInView(ref,{once:true,margin:\"-10% 0px -10% 0px\"});useEffect(()=>{if(!inView||hasAnimated)return;let start=0;let startTimestamp=null;let req;function step(timestamp){if(!startTimestamp)startTimestamp=timestamp;const progress=Math.min((timestamp-startTimestamp)/(duration*1e3),1);const current=Math.floor(progress*(value-start)+start);startTransition(()=>setCount(current));if(progress<1){req=requestAnimationFrame(step);}else{startTransition(()=>setCount(value));startTransition(()=>setHasAnimated(true));}}req=requestAnimationFrame(step);return()=>cancelAnimationFrame(req);},[inView,value,duration,hasAnimated]);useEffect(()=>{if(!inView){startTransition(()=>setCount(0));startTransition(()=>setHasAnimated(false));}},[inView]);return /*#__PURE__*/_jsxs(\"span\",{ref:ref,style:{display:\"inline-block\",width:\"max-content\",...font,...style},children:[prefixEnabled&&prefix,count,suffixEnabled&&suffix]});}addPropertyControls(CounterUp,{value:{type:ControlType.Number,title:\"Number\",defaultValue:100,min:0,max:1e6,step:1,displayStepper:true},duration:{type:ControlType.Number,title:\"Duration (s)\",defaultValue:2,min:.1,max:10,step:.1},prefixEnabled:{type:ControlType.Boolean,title:\"Prefix\",defaultValue:false,enabledTitle:\"Show\",disabledTitle:\"Hide\"},prefix:{type:ControlType.String,title:\"Prefix Value\",defaultValue:\"$\",hidden:({prefixEnabled})=>!prefixEnabled},suffixEnabled:{type:ControlType.Boolean,title:\"Suffix\",defaultValue:false,enabledTitle:\"Show\",disabledTitle:\"Hide\"},suffix:{type:ControlType.String,title:\"Suffix Value\",defaultValue:\"+\",hidden:({suffixEnabled})=>!suffixEnabled},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\":\"CounterUp\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"auto\",\"framerSupportedLayoutWidth\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CounterUp.map"],"mappings":"gPAMG,SAAwB,EAAU,EAAM,CAAC,GAAK,CAAC,QAAM,WAAS,gBAAc,SAAO,gBAAc,SAAO,OAAK,SAAO,EAAW,CAAC,EAAM,GAAUA,EAAS,EAAE,CAAM,CAAC,EAAY,GAAgBA,EAAS,GAAM,CAAO,EAAIC,EAAO,KAAK,CAAO,EAAO,EAAU,EAAI,CAAC,KAAK,GAAK,OAAO,oBAAoB,CAAC,CAAwqB,OAAvqB,MAAc,CAAC,GAAG,CAAC,GAAQ,EAAY,OAAO,IAAgB,EAAe,KAAS,EAAI,SAAS,EAAK,EAAU,CAAC,AAAmB,IAAe,EAAU,IAAM,EAAS,KAAK,KAAK,EAAU,IAAiB,EAAS,KAAK,EAAE,CAAO,EAAQ,KAAK,MAAM,GAAU,EAAM,GAAO,EAAM,CAAC,MAAoB,EAAS,EAAQ,CAAC,CAAI,EAAS,EAAG,EAAI,sBAAsB,EAAK,EAAO,MAAoB,EAAS,EAAM,CAAC,CAAC,MAAoB,EAAe,GAAK,CAAC,EAAmC,MAAhC,GAAI,sBAAsB,EAAK,KAAW,qBAAqB,EAAI,E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