{"version":3,"file":"CounterUp.VISpoxMO.mjs","names":["useState","useRef"],"sources":["https:/framerusercontent.com/modules/9T2JHJil2w1H1Zixe6kg/vzt2RXDWuOrtTqQR1WsU/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":"4WAMG,SAAwB,EAAU,EAAM,CAAC,GAAK,CAAC,QAAM,WAAS,gBAAc,SAAO,gBAAc,SAAO,OAAK,QAAM,CAAC,EAAW,CAAC,EAAM,EAAS,CAACA,EAAS,GAAQ,CAAC,EAAY,EAAe,CAACA,EAAS,IAAa,EAAIC,EAAO,MAAY,EAAO,EAAU,EAAI,CAAC,KAAK,GAAK,OAAO,oBAAoB,EAAyqB,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,GAAS,EAAQ,KAAK,MAAM,GAAU,EAAM,GAAO,GAAO,MAAoB,EAAS,IAAa,EAAS,EAAG,EAAI,sBAAsB,IAAY,MAAoB,EAAS,IAAQ,MAAoB,EAAe,KAAS,CAAgC,SAA5B,sBAAsB,OAAgB,qBAAqB,EAAM,EAAC,CAAC,EAAO,EAAM,EAAS,EAAY,EAAE,MAAc,CAAK,IAAQ,MAAo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