{"version":3,"file":"Counter1.DTi5Xz5U.mjs","names":[],"sources":["https:/framerusercontent.com/modules/IApQAjnzkcrXGF0LjLx1/tk2Z2BupHtcu55XuX6PR/Counter1.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useState,useEffect,useRef}from\"react\";import{motion}from\"framer-motion\";import{addPropertyControls,ControlType}from\"framer\";const CounterStyles={container:{display:\"flex\",justifyContent:\"center\",alignItems:\"center\"}};export function Counter(props){const{start,end,speed,gapSize,prefixText,suffixText,prefixFont,suffixFont,prefixColor,suffixColor,loop,decimalSeparatorType,textSize,selectedFont,textColor,startOnViewport,restartOnViewport,incrementType}=props;const[count,setCount]=useState(start);const[isVisible,setIsVisible]=useState(false);const containerRef=useRef(null);useEffect(()=>{const observer=new IntersectionObserver(entries=>{const entry=entries[0];setIsVisible(entry.isIntersecting);});if(containerRef.current){observer.observe(containerRef.current);}return()=>{if(containerRef.current){observer.unobserve(containerRef.current);}};},[]);useEffect(()=>{const updateCount=()=>{const increment=incrementType===\"integer\"?1:.1;setCount(prevCount=>{const nextCount=parseFloat((prevCount+increment).toFixed(2));return nextCount>=end?end:nextCount;});};if(isVisible||!startOnViewport&&start!==end){const intervalId=setInterval(updateCount,speed);return()=>{clearInterval(intervalId);};}else if(startOnViewport&&isVisible){setCount(start);}},[count,start,end,loop,isVisible,speed,startOnViewport,incrementType]);useEffect(()=>{if(restartOnViewport&&isVisible){setCount(start)// Restart the animation when re-entering the viewport\n;}},[isVisible,restartOnViewport,start]);const formatNumber=number=>{if(decimalSeparatorType===\"comma\"){return number.toLocaleString(\"en-US\");}else if(decimalSeparatorType===\"period\"){return number.toLocaleString(\"en-US\").replace(/,/g,\".\");}else{return number.toFixed(incrementType===\"integer\"?0:1);}};return /*#__PURE__*/_jsxs(motion.div,{ref:containerRef,style:{...CounterStyles.container,gap:`${gapSize}px`,flexDirection:\"row\",alignItems:\"center\",fontSize:`${textSize}px`,fontFamily:selectedFont.fontFamily,fontWeight:selectedFont.fontWeight,color:textColor},children:[/*#__PURE__*/_jsx(\"span\",{style:{fontFamily:prefixFont.fontFamily,fontWeight:prefixFont.fontWeight,color:prefixColor},children:prefixText}),/*#__PURE__*/_jsx(\"span\",{children:formatNumber(count)}),/*#__PURE__*/_jsx(\"span\",{style:{fontFamily:suffixFont.fontFamily,fontWeight:suffixFont.fontWeight,color:suffixColor},children:suffixText})]});}Counter.defaultProps={start:0,end:100,speed:100,prefixText:\"\",suffixText:\"\",loop:false,decimalSeparatorType:\"comma\",textSize:36,selectedFont:{fontFamily:\"Inter\",fontWeight:800,systemFont:true},textColor:\"#D3D3D3\",startOnViewport:false,incrementType:\"integer\"};addPropertyControls(Counter,{startOnViewport:{type:ControlType.Boolean,title:\"Viewport\",defaultValue:false,enabledTitle:\"On\",disabledTitle:\"Off\"},restartOnViewport:{type:ControlType.Boolean,title:\"Replay\",defaultValue:false,enabledTitle:\"Yes\",disabledTitle:\"No\"},selectedFont:{title:\"Font\",type:ControlType.Font,defaultValue:{fontFamily:\"Inter\",fontWeight:800,systemFont:true}},textSize:{title:\"Font Size\",type:ControlType.Number,min:8,max:240,step:1},textColor:{type:ControlType.Color,title:\"Font Color\"},start:{type:ControlType.Number,title:\"Start Number\",defaultValue:0,displayStepper:true},end:{type:ControlType.Number,title:\"End Number\",defaultValue:10,displayStepper:true},decimalSeparatorType:{type:ControlType.Enum,title:\"Separator\",defaultValue:\"comma\",options:[\"comma\",\"period\",\"none\"],optionTitles:[\"Comma (1,000)\",\"Decimal (1.000)\",\"None\"]},incrementType:{type:ControlType.Enum,title:\"Increment Type\",defaultValue:\"integer\",options:[\"integer\",\"decimal\"],optionTitles:[\"Integer\",\"Decimal\"]},prefixText:{type:ControlType.String,title:\"Prefix\",defaultValue:\"\"},prefixFont:{title:\"Prefix Font\",type:ControlType.Font,defaultValue:{fontFamily:\"Inter\",fontWeight:800,systemFont:true}},prefixColor:{type:ControlType.Color,title:\"Prefix Color\"},suffixText:{type:ControlType.String,title:\"Suffix\",defaultValue:\"\"},suffixFont:{title:\"Suffix Font\",type:ControlType.Font,defaultValue:{fontFamily:\"Inter\",fontWeight:800,systemFont:true}},suffixColor:{type:ControlType.Color,title:\"Suffix Color\"},gapSize:{type:ControlType.Number,title:\"Gap Size\",defaultValue:4,min:0,max:100,step:4},speed:{type:ControlType.Number,title:\"Speed (ms)\",defaultValue:100,min:0,max:2e3,step:10},loop:{type:ControlType.Boolean,title:\"Loop Animation\",defaultValue:false,enabledTitle:\"On\",disabledTitle:\"Off\",description:\"[Built by Aditya]\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"Counter\":{\"type\":\"reactComponent\",\"name\":\"Counter\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Counter1.map"],"mappings":"yWAAyR,SAAgB,EAAQ,EAAM,CAAC,GAAK,CAAC,QAAM,MAAI,QAAM,UAAQ,aAAW,aAAW,aAAW,aAAW,cAAY,cAAY,OAAK,uBAAqB,WAAS,eAAa,YAAU,kBAAgB,oBAAkB,gBAAc,CAAC,EAAW,CAAC,EAAM,EAAS,CAAC,EAAS,EAAM,CAAM,CAAC,EAAU,EAAa,CAAC,GAAS,EAAM,CAAO,EAAa,EAAO,KAAK,CAAwuB,AAAvuB,EAAU,IAAI,CAAC,IAAM,EAAS,IAAI,qBAAqB,GAAS,CAAC,IAAM,EAAM,EAAQ,GAAG,EAAa,EAAM,eAAe,AAAE,GAAmE,OAA9D,EAAa,SAAS,EAAS,QAAQ,EAAa,QAAQ,CAAQ,IAAI,CAAC,AAAG,EAAa,SAAS,EAAS,UAAU,EAAa,QAAQ,AAAG,CAAE,EAAC,CAAE,EAAC,CAAC,EAAU,IAAI,CAAC,IAAM,EAAY,IAAI,CAAC,IAAM,EAAU,IAAgB,UAAU,EAAE,GAAG,EAAS,GAAW,CAAC,IAAM,EAAU,WAAW,CAAC,EAAU,GAAW,QAAQ,EAAE,CAAC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