{"version":3,"file":"NumberAnimation.BPCt2PE7.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/KSNsWNr17rXS1xTNFuXe/Jzt4b7MTeVEnDturb0yq/NumberAnimation.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useState,useRef,startTransition}from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";import{useInView,useMotionValue,useSpring}from\"framer-motion\";/**\n * Number Animation\n *\n * @framerIntrinsicWidth 200\n * @framerIntrinsicHeight 100\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function NumberAnimation(props){const{targetNumber=1e3,prefix=\"\",suffix=\"%\",duration=2,delay=0,decimals=0,separator=true,label=\"Improved research quality\",superscript=\"1\",numberColor=\"#000000\",labelColor=\"#555555\",numberFont,labelFont,alignment=\"center\",animateOnce=true,easingType=\"easeOut\",springStiffness=100,springDamping=30}=props;const isStatic=useIsStaticRenderer();const containerRef=useRef(null);const isInView=useInView(containerRef,{once:animateOnce,amount:.5});const motionValue=useMotionValue(0);const springConfig=easingType===\"spring\"?{stiffness:springStiffness,damping:springDamping}:{duration:duration*1e3,ease:easingType};const springValue=useSpring(motionValue,springConfig);const[displayValue,setDisplayValue]=useState(\"0\");useEffect(()=>{if(isStatic){setDisplayValue(formatNumber(targetNumber));return;}if(isInView){const timeout=setTimeout(()=>{motionValue.set(targetNumber);},delay*1e3);return()=>clearTimeout(timeout);}else{if(!animateOnce){motionValue.set(0);}}},[isInView,targetNumber,delay,motionValue,isStatic,animateOnce]);useEffect(()=>{if(isStatic)return;const unsubscribe=springValue.on(\"change\",latest=>{startTransition(()=>{const clampedValue=Math.min(latest,targetNumber);setDisplayValue(formatNumber(clampedValue));});});return()=>unsubscribe();},[springValue,decimals,separator,isStatic,targetNumber]);function formatNumber(value){const fixed=value.toFixed(decimals);if(!separator)return fixed;const parts=fixed.split(\".\");parts[0]=parts[0].replace(/\\B(?=(\\d{3})+(?!\\d))/g,\",\");return parts.join(\".\");}const isFixedWidth=props?.style&&props.style.width===\"100%\";const isFixedHeight=props?.style&&props.style.height===\"100%\";return /*#__PURE__*/_jsxs(\"div\",{ref:containerRef,style:{...props.style,position:\"relative\",display:\"flex\",flexDirection:\"column\",justifyContent:\"center\",alignItems:alignment===\"left\"?\"flex-start\":alignment===\"right\"?\"flex-end\":\"center\",gap:8,...isFixedWidth?{}:{width:\"max-content\"},...isFixedHeight?{}:{height:\"max-content\"}},children:[/*#__PURE__*/_jsxs(\"div\",{style:{display:\"flex\",alignItems:\"baseline\",gap:4,color:numberColor,...numberFont},children:[prefix&&/*#__PURE__*/_jsx(\"span\",{style:{opacity:1},children:prefix}),/*#__PURE__*/_jsx(\"span\",{children:displayValue}),suffix&&/*#__PURE__*/_jsx(\"span\",{style:{opacity:1},children:suffix})]}),label&&/*#__PURE__*/_jsxs(\"div\",{style:{position:\"relative\",color:labelColor,...labelFont,textAlign:alignment},children:[label,superscript&&/*#__PURE__*/_jsx(\"sup\",{style:{fontSize:\"0.6em\",marginLeft:\"2px\",verticalAlign:\"super\",opacity:.8},children:superscript})]})]});}addPropertyControls(NumberAnimation,{targetNumber:{type:ControlType.Number,title:\"Target\",defaultValue:100,min:0,step:1},prefix:{type:ControlType.String,title:\"Prefix\",defaultValue:\"\"},suffix:{type:ControlType.String,title:\"Suffix\",defaultValue:\"%\"},label:{type:ControlType.String,title:\"Label\",defaultValue:\"Improved research quality\"},superscript:{type:ControlType.String,title:\"Exponent\",defaultValue:\"1\",description:\"Petit chiffre ou texte \\xe0 la fin du label\"},decimals:{type:ControlType.Number,title:\"Decimals\",defaultValue:0,min:0,max:4,step:1},separator:{type:ControlType.Boolean,title:\"Separator\",defaultValue:true},duration:{type:ControlType.Number,title:\"Duration\",defaultValue:2,min:.1,max:10,step:.1,unit:\"s\"},delay:{type:ControlType.Number,title:\"Delay\",defaultValue:0,min:0,max:5,step:.1,unit:\"s\"},easingType:{type:ControlType.Enum,title:\"Easing\",options:[\"linear\",\"easeIn\",\"easeOut\",\"easeInOut\",\"spring\"],optionTitles:[\"Linear\",\"Ease In\",\"Ease Out\",\"Ease In Out\",\"Spring\"],defaultValue:\"easeOut\"},springStiffness:{type:ControlType.Number,title:\"Stiffness\",defaultValue:100,hidden:({easingType})=>easingType!==\"spring\"},springDamping:{type:ControlType.Number,title:\"Damping\",defaultValue:30,hidden:({easingType})=>easingType!==\"spring\"},animateOnce:{type:ControlType.Boolean,title:\"Once\",defaultValue:true},alignment:{type:ControlType.Enum,title:\"Align\",options:[\"left\",\"center\",\"right\"],defaultValue:\"center\",displaySegmentedControl:true},numberColor:{type:ControlType.Color,title:\"Num Color\",defaultValue:\"#1a1a1a\"},labelColor:{type:ControlType.Color,title:\"Lbl Color\",defaultValue:\"#556f7e\"},numberFont:{type:ControlType.Font,title:\"Num Font\",controls:\"extended\",defaultValue:{fontSize:\"80px\",variant:\"Bold\",letterSpacing:\"-0.02em\",lineHeight:\"1em\"}},labelFont:{type:ControlType.Font,title:\"Lbl Font\",controls:\"extended\",defaultValue:{fontSize:\"24px\",variant:\"Medium\",letterSpacing:\"0em\",lineHeight:\"1.2em\"}}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"NumberAnimation\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerIntrinsicHeight\":\"100\",\"framerIntrinsicWidth\":\"200\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./NumberAnimation.map"],"mappings":"wQAQG,SAAwB,EAAgB,EAAM,CAAC,GAAK,CAAC,eAAa,IAAI,SAAO,GAAG,SAAO,IAAI,WAAS,EAAE,QAAM,EAAE,WAAS,EAAE,YAAU,GAAK,QAAM,4BAA4B,cAAY,IAAI,cAAY,UAAU,aAAW,UAAU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