{"version":3,"file":"AnimatedCounter.DV74LOFX.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/dxOBLMV03qXkI45ywbD9/mfjCFy8ZyEp05IH4MWV8/AnimatedCounter.js"],"sourcesContent":["import{jsxs as _jsxs}from\"react/jsx-runtime\";import{useState,useEffect,useRef}from\"react\";import{addPropertyControls,ControlType}from\"framer\";import{useScroll,useTransform,useSpring,useInView,animate}from\"framer-motion\";/**\n * @framerIntrinsicWidth 400\n * @framerIntrinsicHeight 100\n */export default function AnimatedCounter(props){const{start,end,duration,delay,replay,decimals,commas,font,fontSize,lineHeight,letterSpacing,textAlign,color,prefix,suffix,tag:Tag,monospace,userSelect,balance,shadows,animationType,decoration}=props;const ref=useRef(null);const isInView=useInView(ref,{once:!replay,amount:.4});const{scrollYProgress}=useScroll();const[count,setCount]=useState(start);// 1. Scroll-based Logic (Direct mapping to Page Scroll)\nconst scrollValue=useTransform(scrollYProgress,[0,1],[start,end]);const smoothScroll=useSpring(scrollValue,{stiffness:70,damping:20});// 2. View-based Logic (Tween with Duration & Replay)\nuseEffect(()=>{if(animationType===\"view\"){if(isInView){const controls=animate(start,end,{duration:duration,delay:delay,ease:\"easeOut\",onUpdate:value=>setCount(value)});return()=>controls.stop();}else if(replay){// Reset to start when scrolled out of view if Replay is ON\nsetCount(start);}}},[isInView,animationType,start,end,duration,delay,replay]);// 3. Sync Scroll Value to State\nuseEffect(()=>{if(animationType===\"scroll\"){return smoothScroll.onChange(v=>setCount(v));}},[animationType,smoothScroll]);// Shadow Mapping\nconst textShadow=(shadows??[]).map(s=>`${s.x}px ${s.y}px ${s.blur}px ${s.color}`).join(\", \");const formatNumber=num=>{let fixed=num.toFixed(decimals);if(commas){const parts=fixed.split(\".\");parts[0]=parts[0].replace(/\\B(?=(\\d{3})+(?!\\d))/g,\",\");return parts.join(\".\");}return fixed;};const style={fontFamily:font?.fontFamily||\"Inter\",fontWeight:font?.fontWeight||600,fontSize:fontSize,lineHeight:lineHeight,letterSpacing:`${letterSpacing}em`,textAlign:textAlign,color:color,textShadow:textShadow,display:\"flex\",alignItems:\"center\",justifyContent:textAlign===\"left\"?\"flex-start\":textAlign===\"right\"?\"flex-end\":\"center\",width:\"100%\",height:\"100%\",fontVariantNumeric:monospace?\"tabular-nums\":\"normal\",userSelect:userSelect?\"auto\":\"none\",textWrap:balance?\"balance\":\"wrap\",textDecoration:decoration,margin:0};return /*#__PURE__*/_jsxs(Tag,{ref:ref,style:style,children:[prefix,formatNumber(count),suffix]});}AnimatedCounter.defaultProps={start:0,end:2e6,duration:2,delay:0,replay:true,decimals:0,commas:true,animationType:\"view\",fontSize:64,lineHeight:1.2,letterSpacing:0,textAlign:\"center\",color:\"#FF0016\",shadows:[]};addPropertyControls(AnimatedCounter,{start:{type:ControlType.Number,title:\"Start\"},end:{type:ControlType.Number,title:\"End\"},animationType:{type:ControlType.Enum,title:\"Animation\",options:[\"view\",\"scroll\"],optionTitles:[\"Layer in View\",\"Scroll Path\"]},duration:{type:ControlType.Number,title:\"Duration\",min:0,max:10,step:.1,unit:\"s\",hidden:props=>props.animationType===\"scroll\"},delay:{type:ControlType.Number,title:\"Delay\",min:0,max:5,step:.1,unit:\"s\",hidden:props=>props.animationType===\"scroll\"},replay:{type:ControlType.Boolean,title:\"Replay\",enabledTitle:\"Yes\",disabledTitle:\"Once\",hidden:props=>props.animationType===\"scroll\"},decimals:{type:ControlType.Enum,title:\"Decimals\",options:[0,1,2,3],optionTitles:[\"Off\",\"1\",\"2\",\"3\"]},commas:{type:ControlType.Boolean,title:\"Commas\"},// --- Typography Standalone ---\nfont:{type:ControlType.Font,title:\"Font Family\"},fontSize:{type:ControlType.Number,title:\"Size\",min:0,max:500,unit:\"px\"},lineHeight:{type:ControlType.Number,title:\"Line\",min:0,max:5,step:.1},letterSpacing:{type:ControlType.Number,title:\"Letter\",min:-.5,max:1,step:.01},textAlign:{type:ControlType.SegmentedEnum,title:\"Align\",options:[\"left\",\"center\",\"right\"]},color:{type:ControlType.Color,title:\"Color\"},prefix:{type:ControlType.String,title:\"Prefix\"},suffix:{type:ControlType.String,title:\"Suffix\"},decoration:{type:ControlType.Enum,title:\"Decoration\",options:[\"none\",\"underline\",\"line-through\"]},balance:{type:ControlType.Boolean,title:\"Balance\"},userSelect:{type:ControlType.Boolean,title:\"User Select\"},tag:{type:ControlType.Enum,title:\"Tag\",options:[\"h1\",\"h2\",\"h3\",\"p\",\"div\"]},monospace:{type:ControlType.Boolean,title:\"Monospace\"},shadows:{type:ControlType.Array,title:\"Drop Shadows\",control:{type:ControlType.Object,controls:{x:{type:ControlType.Number,title:\"X\",defaultValue:0},y:{type:ControlType.Number,title:\"Y\",defaultValue:2},blur:{type:ControlType.Number,title:\"Blur\",defaultValue:4},color:{type:ControlType.Color,title:\"Color\",defaultValue:\"rgba(0,0,0,0.2)\"}}}}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"AnimatedCounter\",\"slots\":[],\"annotations\":{\"framerIntrinsicHeight\":\"100\",\"framerIntrinsicWidth\":\"400\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./AnimatedCounter.map"],"mappings":"sQAGG,SAAwB,EAAgB,EAAM,CAAC,GAAK,CAAC,QAAM,MAAI,WAAS,QAAM,SAAO,WAAS,SAAO,OAAK,WAAS,aAAW,gBAAc,YAAU,QAAM,SAAO,SAAO,IAAI,EAAI,YAAU,aAAW,UAAQ,UAAQ,gBAAc,cAAY,EAAY,EAAIA,EAAO,IAAI,EAAQ,EAAS,EAAU,EAAI,CAAC,KAAK,CAAC,EAAO,OAAO,EAAE,CAAC,EAAO,CAAC,mBAAiB,EAAU,EAAO,CAAC,EAAM,GAAUC,EAAS,CAAK,EACvU,EAAa,EAAnE,EAAa,EAAgB,CAAC,EAAE,CAAC,EAAE,CAAC,EAAM,CAAG,CAA0C,EAAE,CAAC,UAAU,GAAG,QAAQ,EAAE,CAAC,EACpI,MA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