{"version":3,"file":"Animated_Counter.CSSG-C7k.mjs","names":["useRef","useState","useCallback","useMemo"],"sources":["https:/framerusercontent.com/modules/7FHEnd8WWm78xct1fI6Y/WZr6x0uIwV8beejCTYrE/Animated_Counter.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useState,useRef,useMemo,useCallback}from\"react\";import{addPropertyControls,ControlType}from\"framer\";import{motion}from\"framer-motion\";const DIGITS=[0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9];/**\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n * @framerDisableUnlink\n */export default function Counter(props){const{startNumber=0,endNumber=100,enablePrefix=false,prefix=\"\",enableSuffix=false,suffix=\"\",transition,decimals=0,font,groupThousands=true,thousandsSeparator=\",\",decimalSeparator=\".\",trigger=\"onAppear\",replay=false,digitStagger=.08,digitColor=\"#000000\",prefixFont,prefixColor=\"#000000\",suffixFont,suffixColor=\"#000000\",gap=6,digitGap=0}=props;const ref=useRef(null);const[hasAnimated,setHasAnimated]=useState(false);const[dimensions,setDimensions]=useState({digitWidth:48,lineHeight:88,digitWidths:{}});// Measure actual rendered font size and digit width with tabular nums\nuseEffect(()=>{if(!ref.current)return;const measureElement=document.createElement(\"span\");measureElement.style.cssText=`\n            position: absolute;\n            visibility: hidden;\n            white-space: nowrap;\n            font-family: ${font?.fontFamily||\"inherit\"};\n            font-size: ${font?.fontSize||\"80px\"};\n            font-weight: ${font?.fontWeight||\"normal\"};\n            font-variant-numeric: tabular-nums;\n            line-height: normal;\n        `;document.body.appendChild(measureElement);// Measure each digit individually for proportional spacing\nconst widths={};let maxWidth=0;for(let i=0;i<=9;i++){measureElement.textContent=String(i);const rect=measureElement.getBoundingClientRect();widths[String(i)]=rect.width;maxWidth=Math.max(maxWidth,rect.width);}measureElement.textContent=\"0\";const rect=measureElement.getBoundingClientRect();const lineHeight=rect.height;setDimensions({digitWidth:maxWidth,lineHeight,digitWidths:widths});document.body.removeChild(measureElement);},[font?.fontSize,font?.fontFamily,font?.fontWeight]);const digitWidth=dimensions.digitWidth;const computedLineHeight=dimensions.lineHeight;const digitWidths=dimensions.digitWidths;const letterSpacing=font?.letterSpacing?parseFloat(font.letterSpacing):0;useEffect(()=>{if(trigger===\"onAppear\"){setHasAnimated(true);return;}const observer=new IntersectionObserver(entries=>{for(const e of entries){if(e.isIntersecting)setHasAnimated(true);else if(replay)setHasAnimated(false);}},{threshold:.1});if(ref.current)observer.observe(ref.current);return()=>observer.disconnect();},[trigger,replay]);const formatNumber=useCallback(num=>{const absNum=Math.abs(num);const fixed=absNum.toFixed(decimals);let formatted=fixed;if(groupThousands){const[integer,decimal]=fixed.split(\".\");const grouped=integer.replace(/\\B(?=(\\d{3})+(?!\\d))/g,thousandsSeparator);formatted=decimal?`${grouped}${decimalSeparator}${decimal}`:grouped;}return num<0?`-${formatted}`:formatted;},[decimals,groupThousands,thousandsSeparator,decimalSeparator]);const{startChars,endChars}=useMemo(()=>{const startText=formatNumber(startNumber);const endText=formatNumber(endNumber);const startArr=startText.split(\"\");const endArr=endText.split(\"\");while(startArr.length<endArr.length)startArr.unshift(\"0\");while(endArr.length<startArr.length)endArr.unshift(\"0\");return{startChars:startArr,endChars:endArr};},[startNumber,endNumber,formatNumber]);const renderScrollingDigits=()=>{return endChars.map((char,index)=>{const isDigit=/\\d/.test(char);const startChar=startChars[index];const currentDigitGap=digitGap||0;const slotStyle={height:`${computedLineHeight}px`,display:\"inline-flex\",alignItems:\"center\",justifyContent:\"center\",...font,color:digitColor,fontVariantNumeric:\"tabular-nums\",whiteSpace:\"nowrap\"};if(!isDigit){const marginRight=index<endChars.length-1?`${letterSpacing+currentDigitGap}px`:\"0px\";return /*#__PURE__*/_jsx(\"div\",{style:{...slotStyle,marginRight},children:char},`p-${index}`);}const startDigit=parseInt(startChar,10)||0;const targetDigit=parseInt(char,10);const step=computedLineHeight;const yStart=-startDigit*step;const yEnd=-(10+targetDigit)*step;// Get actual width for current digit, with special handling for \"1\"\nconst currentDigitWidth=digitWidths[char]||digitWidth;const isOne=char===\"1\";// Adjust margin for digit \"1\" to make it closer to next digit\n// Using negative margin to make it really close\nconst adjustedMarginRight=index<endChars.length-1?`${isOne?-currentDigitWidth*.15:letterSpacing+currentDigitGap}px`:\"0px\";return /*#__PURE__*/_jsx(\"div\",{style:{...slotStyle,position:\"relative\",overflow:\"hidden\",width:`${isOne?currentDigitWidth:digitWidth}px`,alignItems:\"flex-start\",marginRight:adjustedMarginRight},children:/*#__PURE__*/_jsx(motion.div,{initial:false,animate:{translateY:hasAnimated?yEnd:yStart},transition:{...transition,delay:index*digitStagger},style:{display:\"flex\",flexDirection:\"column\",width:\"100%\"},children:DIGITS.map((digit,idx)=>/*#__PURE__*/_jsx(\"div\",{style:{height:`${computedLineHeight}px`,display:\"flex\",alignItems:\"center\",justifyContent:\"center\",width:\"100%\"},children:digit},idx))})},`d-${index}`);});};const isPrefixActive=enablePrefix&&prefix.length>0;const isSuffixActive=enableSuffix&&suffix.length>0;const currentGap=isPrefixActive||isSuffixActive?gap:0;return /*#__PURE__*/_jsxs(\"div\",{ref:ref,style:{display:\"inline-flex\",alignItems:\"baseline\",gap:currentGap,userSelect:\"none\",WebkitFontSmoothing:\"antialiased\",lineHeight:`${computedLineHeight}px`},children:[isPrefixActive&&/*#__PURE__*/_jsx(\"span\",{style:{...prefixFont,color:prefixColor},children:prefix}),/*#__PURE__*/_jsx(\"div\",{style:{display:\"inline-flex\",overflow:\"hidden\",height:`${computedLineHeight}px`,alignItems:\"flex-start\"},children:renderScrollingDigits()}),isSuffixActive&&/*#__PURE__*/_jsx(\"span\",{style:{...suffixFont,color:suffixColor},children:suffix})]});}Counter.displayName=\"Animated Counter\";addPropertyControls(Counter,{startNumber:{type:ControlType.Number,title:\"Start No\",defaultValue:0,displayStepper:true},endNumber:{type:ControlType.Number,title:\"End No\",defaultValue:100,displayStepper:true},decimals:{type:ControlType.Number,title:\"Decimals\",defaultValue:0,displayStepper:true},groupThousands:{type:ControlType.Boolean,title:\"Separator\",defaultValue:true},thousandsSeparator:{type:ControlType.String,title:\"Thousands\",defaultValue:\",\",hidden:props=>!props.groupThousands},decimalSeparator:{type:ControlType.String,title:\"Dec\",defaultValue:\".\",hidden:props=>props.decimals===0},enablePrefix:{type:ControlType.Boolean,title:\"Prefix\",defaultValue:false},prefix:{type:ControlType.String,title:\"Text\",defaultValue:\"$\",hidden:props=>!props.enablePrefix},prefixFont:{type:ControlType.Font,title:\"Prefix Font\",controls:\"extended\",defaultFontType:\"sans-serif\",displayFontSize:true,defaultValue:{fontSize:\"80px\",variant:\"Bold\",letterSpacing:\"0em\",lineHeight:\"1.1em\"},hidden:props=>!props.enablePrefix},prefixColor:{type:ControlType.Color,title:\"Prefix Color\",defaultValue:\"#ABFF84\",hidden:props=>!props.enablePrefix},enableSuffix:{type:ControlType.Boolean,title:\"Suffix\",defaultValue:true},suffix:{type:ControlType.String,title:\"Text\",defaultValue:\"+\",hidden:props=>!props.enableSuffix},suffixFont:{type:ControlType.Font,title:\"Suffix Font\",controls:\"extended\",defaultFontType:\"sans-serif\",displayFontSize:true,defaultValue:{fontSize:\"80px\",variant:\"Bold\",letterSpacing:\"0em\",lineHeight:\"1.1em\"},hidden:props=>!props.enableSuffix},suffixColor:{type:ControlType.Color,title:\"Suffix Color\",defaultValue:\"#ABFF84\",hidden:props=>!props.enableSuffix},gap:{type:ControlType.Number,title:\"Spacing\",defaultValue:0},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",displayFontSize:true,defaultValue:{fontSize:\"80px\",variant:\"Bold\",letterSpacing:\"0em\",lineHeight:\"1.1em\"}},digitGap:{type:ControlType.Number,title:\"Digit Gap\",defaultValue:0},digitColor:{type:ControlType.Color,title:\"Number Color\",defaultValue:\"#000000\"},trigger:{type:ControlType.Enum,title:\"Trigger\",options:[\"onAppear\",\"inView\"],defaultValue:\"onAppear\"},replay:{type:ControlType.Boolean,title:\"Replay\",defaultValue:false},transition:{type:ControlType.Transition,title:\"Transition\"},digitStagger:{type:ControlType.Number,title:\"Stagger\",defaultValue:.05,step:.01,displayStepper:true,description:\"See more component from [Iklil Najma M](https://framer.link/YR9Yat6)\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"Counter\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerDisableUnlink\":\"\",\"framerSupportedLayoutWidth\":\"auto\",\"framerSupportedLayoutHeight\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Animated_Counter.map"],"mappings":"8PAIG,SAAwB,EAAQ,EAAM,CAAC,GAAK,CAAC,cAAY,EAAE,YAAU,IAAI,eAAa,GAAM,SAAO,GAAG,eAAa,GAAM,SAAO,GAAG,aAAW,WAAS,EAAE,OAAK,iBAAe,GAAK,qBAAmB,IAAI,mBAAiB,IAAI,UAAQ,WAAW,SAAO,GAAM,eAAa,IAAI,aAAW,UAAU,aAAW,cAAY,UAAU,aAAW,cAAY,UAAU,MAAI,EAAE,WAAS,GAAG,EAAY,EAAIA,EAAO,KAAK,CAAM,CAAC,EAAY,GAAgBC,EAAS,GAAM,CAAM,CAAC,EAAW,GAAeA,EAAS,CAAC,WAAW,GAAG,WAAW,GAAG,YAAY,EAAE,CAAC,CAAC,CAChiB,MAAc,CAAC,GAAG,CAAC,EAAI,QAAQ,OAAO,IAAM,EAAe,SAAS,cAAc,OAAO,CAAC,EAAe,MAAM,QAAQ;;;;2BAI5F,GAAM,YAAY,UAAU;yBAC9B,GAAM,UAAU,OAAO;2BACrB,GAAM,YAAY,SAAS;;;UAG5C,SAAS,KAAK,YAAY,EAAe,CACnD,IAAM,EAAO,EAAE,CAAK,EAAS,EAAE,IAAI,IAAI,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC,EAAe,YAAY,OAAO,EAAE,CAAC,IAAM,EAAK,EAAe,uB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