{"version":3,"file":"AnimatedCounter.CLLkMu3y.mjs","names":["useState","useRef","_Fragment"],"sources":["https:/framerusercontent.com/modules/JwaTQqmUwjirnma6n7jM/8YNLZXzWTDLFB0O9nvNZ/AnimatedCounter.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from\"react/jsx-runtime\";import{useEffect,useState,startTransition,useRef}from\"react\";import{addPropertyControls,ControlType}from\"framer\";import{motion,useSpring,useTransform,useMotionValue,useInView}from\"framer-motion\";/**\n * Animated Counter\n *\n * An animated number counter that counts up from 0 to the target value.\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight auto\n */export default function AnimatedCounter(props){const{targetValue=100,duration=2,font,color=\"#000000\",prefix=\"\",suffix=\"\",decimals=0,children,trigger}=props;const motionValue=useMotionValue(0);const springValue=useSpring(motionValue,{damping:30,stiffness:100,duration:duration*1e3});const rounded=useTransform(springValue,latest=>latest.toFixed(decimals));const[displayValue,setDisplayValue]=useState(\"0\");const[hasStarted,setHasStarted]=useState(false);const triggerRef=useRef(null);const isTriggerInView=useInView(triggerRef,{once:true,amount:.3});useEffect(()=>{const unsubscribe=rounded.on(\"change\",latest=>{startTransition(()=>setDisplayValue(latest));});return()=>unsubscribe();},[rounded]);useEffect(()=>{if(isTriggerInView&&!hasStarted){startTransition(()=>setHasStarted(true));motionValue.set(targetValue);}},[isTriggerInView,hasStarted,targetValue,motionValue]);// If trigger is provided, wrap it in a ref container\nif(trigger){return /*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx(\"div\",{ref:triggerRef,style:{position:\"absolute\",width:\"100%\",height:\"100%\",pointerEvents:\"none\"},children:trigger}),children?/*#__PURE__*/_jsxs(\"span\",{style:{...font,color},children:[children,/*#__PURE__*/_jsxs(motion.span,{style:{display:\"inline\",color:color},children:[prefix,displayValue,suffix]})]}):/*#__PURE__*/_jsxs(motion.span,{style:{display:\"inline-block\",color:color,...font},children:[prefix,displayValue,suffix]})]});}// If children (like an H2) are provided, render the number inside them\nif(children){return /*#__PURE__*/_jsxs(\"span\",{style:{...font,color},children:[children,/*#__PURE__*/_jsxs(motion.span,{style:{display:\"inline\",color:color},children:[prefix,displayValue,suffix]})]});}return /*#__PURE__*/_jsxs(motion.span,{style:{display:\"inline-block\",color:color,...font},children:[prefix,displayValue,suffix]});}addPropertyControls(AnimatedCounter,{targetValue:{type:ControlType.Number,title:\"Target Value\",defaultValue:100,min:0,max:1e6,step:1,displayStepper:true},duration:{type:ControlType.Number,title:\"Duration (seconds)\",defaultValue:2,min:.1,max:10,step:.1,unit:\"s\"},decimals:{type:ControlType.Number,title:\"Decimals\",defaultValue:0,min:0,max:4,step:1},prefix:{type:ControlType.String,title:\"Prefix\",defaultValue:\"\",placeholder:\"z.B. €\"},suffix:{type:ControlType.String,title:\"Suffix\",defaultValue:\"\",placeholder:\"z.B. %\"},color:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"48px\",variant:\"Bold\",letterSpacing:\"-0.02em\",lineHeight:\"1em\"}},children:{type:ControlType.Slot,title:\"Container\",maxCount:1},trigger:{type:ControlType.Slot,title:\"Trigger\",maxCount:1}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"AnimatedCounter\",\"slots\":[\"children\",\"trigger\"],\"annotations\":{\"framerSupportedLayoutHeight\":\"auto\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./AnimatedCounter.map"],"mappings":"2RAOG,SAAwB,EAAgB,EAAM,CAAC,GAAK,CAAC,cAAY,IAAI,WAAS,EAAE,OAAK,QAAM,UAAU,SAAO,GAAG,SAAO,GAAG,WAAS,EAAE,WAAS,WAAS,EAAY,EAAY,EAAe,EAAE,CAAiG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