{"version":3,"file":"Smoothcounter.DBv97FIF.mjs","names":["React.useState","React.useRef"],"sources":["https:/framerusercontent.com/modules/pztmAAX1SQ57Lrk4XXUt/paP7RjOiDInNJWlKm4Ta/Smoothcounter.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import*as React from\"react\";import{motion}from\"framer-motion\";import{addPropertyControls,ControlType}from\"framer\";// Code component provided by Eleveight Supply. All rights reserved 2024.\n/**\n * @framerDisableUnlink\n *\n * @framerSupportedLayoutWidth 100%\n * @framerSupportedLayoutHeight 100%\n */export default function SmoothCounter(props){const{start,end,font,fontProps,trigger,lineHeight,transition,label,labelPosition,loop,loopDelay,padding,useMask}=props;const{Color,Size,letterSpacing,verticalSpacing}=fontProps;const computedLineHeight=lineHeight||(verticalSpacing===0?Size*.9:Size);const computedDigitWidth=Size*.65;const formatNumber=value=>value.toString().split(\"\");const[displayNumber,setDisplayNumber]=React.useState(formatNumber(start));const[hasAnimated,setHasAnimated]=React.useState(false);const numberRef=React.useRef(null);const memoizedDigits=React.useMemo(()=>formatNumber(start),[start]);React.useEffect(()=>{if(trigger===\"inView\"){const observer=new IntersectionObserver(entries=>{entries.forEach(entry=>{if(entry.isIntersecting&&!hasAnimated){setDisplayNumber(formatNumber(end));setHasAnimated(true);}});},{threshold:.1});if(numberRef.current){observer.observe(numberRef.current);}return()=>{if(numberRef.current){observer.unobserve(numberRef.current);}};}else{setDisplayNumber(formatNumber(end));}},[end,hasAnimated,trigger]);const renderScrollingDigits=targetChars=>{const computedPunctuationWidth=computedDigitWidth*.65;return targetChars.map((char,index)=>{// Compute margins as before.\nconst marginRight=index<targetChars.length-1?`${letterSpacing}px`:\"0px\";const marginLeft=letterSpacing<0&&index>0?`${letterSpacing}px`:\"0px\";if(/\\d/.test(char)){const targetDigit=parseInt(char,10);return /*#__PURE__*/_jsx(\"div\",{style:{position:\"relative\",height:`${computedLineHeight}px`,overflow:\"visible\",width:`${computedDigitWidth}px`,display:\"inline-flex\",justifyContent:\"center\",marginRight,marginLeft,willChange:\"transform\",letterSpacing:\"0px\"},children:/*#__PURE__*/_jsx(motion.div,{initial:{translateY:0},animate:{translateY:`-${targetDigit*(computedLineHeight+verticalSpacing)}px`},transition:{...transition,repeat:loop?Infinity:0,repeatType:\"mirror\",repeatDelay:loopDelay},style:{display:\"flex\",flexDirection:\"column\",willChange:\"transform\"},children:Array.from({length:10}).map((_,i)=>/*#__PURE__*/_jsx(\"div\",{style:{height:`${computedLineHeight}px`,display:\"flex\",alignItems:\"center\",justifyContent:\"center\",fontSize:`${Size}px`,lineHeight:`${computedLineHeight}px`,color:Color,...font,marginBottom:verticalSpacing>0?`${verticalSpacing}px`:\"0px\",letterSpacing:\"0px\"},children:i},i))},`${index}-${targetDigit}`)},index);}else{return /*#__PURE__*/_jsx(\"div\",{style:{height:`${computedLineHeight}px`,width:`${computedPunctuationWidth}px`,display:\"inline-flex\",alignItems:\"center\",justifyContent:\"center\",fontSize:`${Size}px`,lineHeight:`${computedLineHeight}px`,color:Color,...font,marginRight,marginLeft,letterSpacing:\"0px\"},children:char},index);}});};const dynamicStyle={fontSize:`${Size}px`,fontFeatureSettings:\"'tnum'\",fontVariantNumeric:\"lining-nums\",display:\"inline-flex\",flexDirection:\"row\",lineHeight:`${computedLineHeight}px`,color:Color,...font,userSelect:\"none\",letterSpacing:\"px\"};const outerContainerStyle={position:\"relative\",display:\"inline-block\",overflow:\"hidden\",paddingTop:useMask?`${padding}px`:\"0px\",paddingBottom:useMask?`${padding}px`:\"0px\",...useMask&&{WebkitMaskImage:`linear-gradient(to bottom, transparent 5%, black 25%, black 75%, transparent 95%)`,maskImage:`linear-gradient(to bottom, transparent 5%, black 25%, black 75%, transparent 95%)`}};return /*#__PURE__*/_jsx(\"div\",{style:outerContainerStyle,children:/*#__PURE__*/_jsxs(\"div\",{ref:numberRef,style:dynamicStyle,children:[labelPosition===\"Before\"&&label,renderScrollingDigits(displayNumber),labelPosition===\"After\"&&label]})});}SmoothCounter.defaultProps={start:\"00\",end:\"1,234\",font:{family:\"Inter\",weight:400,style:\"normal\",fontSize:40},fontProps:{Color:\"#929292\",Size:40,letterSpacing:-2,verticalSpacing:0},trigger:\"onAppear\",transition:{type:\"tween\",ease:[.5,.02,.16,.99],duration:3.2},label:\"\",labelPosition:\"After\",loop:false,loopDelay:0,padding:7,useMask:false};addPropertyControls(SmoothCounter,{font:{type:ControlType.Font,title:\"Font\",defaultValue:\"Inter\"},fontProps:{type:ControlType.Object,title:\"Font Props\",controls:{Color:{type:ControlType.Color,title:\"Color\",defaultValue:\"#929292\"},Size:{type:ControlType.Number,title:\"Size\",defaultValue:40,min:8,max:500,step:1,displayStepper:true},letterSpacing:{type:ControlType.Number,title:\"Letter\",defaultValue:-2,min:-50,max:100,step:1,displayStepper:true},verticalSpacing:{type:ControlType.Number,title:\"Line\",defaultValue:0,min:0,max:50,step:1,displayStepper:true}}},start:{type:ControlType.String,title:\"Start\",defaultValue:SmoothCounter.defaultProps.start},end:{type:ControlType.String,title:\"End\",defaultValue:SmoothCounter.defaultProps.end},trigger:{type:ControlType.Enum,title:\"Trigger\",options:[\"onAppear\",\"inView\"],optionTitles:[\"On Appear\",\"In View\"],defaultValue:\"onAppear\",displaySegmentedControl:true,segmentedControlDirection:\"vertical\"},transition:{type:ControlType.Transition,title:\"Transition\",defaultValue:{type:\"tween\",ease:[.5,.02,.16,.99],duration:3.2}},label:{type:ControlType.String,title:\"Label\",defaultValue:\"\",placeholder:\"ex: %,+,etc...\"},labelPosition:{type:ControlType.SegmentedEnum,title:\"Label\",options:[\"Before\",\"After\"],optionTitles:[\"Before\",\"After\"],defaultValue:\"After\"},loop:{type:ControlType.Boolean,title:\"Loop\",defaultValue:false,enabledTitle:\"Yes\",disabledTitle:\"No\"},loopDelay:{type:ControlType.Number,title:\"Delay\",defaultValue:0,min:0,max:10,step:.1,unit:\"s\",hidden:({loop})=>!loop},useMask:{type:ControlType.Boolean,title:\"Gradient\",defaultValue:SmoothCounter.defaultProps.useMask,enabledTitle:\"Yes\",disabledTitle:\"No\"},padding:{type:ControlType.Number,title:\"Cut-off\",defaultValue:SmoothCounter.defaultProps.padding,min:0,max:100,step:1,displayStepper:true,hidden:({useMask})=>!useMask}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"SmoothCounter\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"100%\",\"framerSupportedLayoutWidth\":\"100%\",\"framerDisableUnlink\":\"*\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Smoothcounter.map"],"mappings":"mPAMG,SAAwB,EAAc,EAAM,CAAC,GAAK,CAAC,QAAM,MAAI,OAAK,YAAU,UAAQ,aAAW,aAAW,QAAM,gBAAc,OAAK,YAAU,UAAQ,WAAS,EAAW,CAAC,QAAM,OAAK,gBAAc,mBAAiB,EAAgB,EAAmB,IAAa,IAAkB,EAAE,EAAK,GAAG,GAAY,EAAmB,EAAK,IAAU,EAAa,GAAO,EAAM,UAAU,CAAC,MAAM,GAAG,CAAM,CAAC,EAAc,GAAkBA,EAAe,EAAa,EAAM,CAAC,CAAM,CAAC,EAAY,GAAgBA,EAAe,GAAM,CAAO,EAAUC,EAAa,KAAK,CAAsB,MAAkB,EAAa,EAAM,CAAC,CAAC,EAAM,CAAC,CAAC,MAAoB,CAAC,GAAG,IAAU,SAAS,CAAC,IAAM,EAAS,IAAI,qBAAqB,GAAS,CAAC,EAAQ,QAAQ,GAAO,CAAI,EAAM,gBAAgB,CAAC,IAAa,EAAiB,EAAa,EAAI,CAAC,CAAC,EAAe,GAAK,GAAI,EAAG,CAAC,UAAU,GAAG,CAAC,CAA4D,OAAxD,EAAU,SAAS,EAAS,QAAQ,EAAU,QAAQ,KAAY,CAAI,EAAU,SAAS,EAAS,UAAU,EAAU,QAAQ,OAAU,EAAiB,EAAa,EAAI,CAAC,EAAI,CAAC,EAAI,EAAY,EAAQ,CAAC,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