{"version":3,"file":"Counter.7H5Org0F.mjs","names":["React.useRef","React.useState","__esmMin","_e","de","p","c","init_jsx_runtime","init_npm_react_18_3_1","ce","useInView","animate","init_framer_motion_DhsWWWsN","addPropertyControls","init_framer_Duogf4LG","RenderTarget","ControlType","Counter","props","ref","rt","isStatic","inView","value","setValue","to","from","once","controls","v","duration","delay","format","int","dec","decimals","grouped","separator","font","align","prefix","suffix","suffixColor","color","suffixScale","init_Counter"],"sources":["https:/framerusercontent.com/modules/mWkaHl4CZyBXXAv16uMn/pqQyyNj7qyV1BVNZR31O/Counter.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";import{useInView,animate}from\"framer-motion\";/**\n * Counter\n * Counts up from \"From\" to \"To\" when it scrolls into view.\n * Every part is editable: value, decimals, prefix, suffix, separator,\n * timing, font and colour.\n *\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n */export default function Counter(props){const{from,to,decimals,prefix,suffix,separator,duration,delay,once,font,color,suffixColor,suffixScale,align}=props;const ref=React.useRef(null);const rt=RenderTarget.current();const isStatic=rt===RenderTarget.canvas||rt===RenderTarget.export||rt===RenderTarget.thumbnail;const inView=useInView(ref,{once,amount:.6});const[value,setValue]=React.useState(isStatic?to:from);React.useEffect(()=>{if(isStatic){setValue(to);return;}if(!inView){if(!once)setValue(from);return;}const controls=animate(from,to,{duration,delay,ease:[.16,1,.3,1],onUpdate:v=>setValue(v)});return()=>controls.stop();},[inView,from,to,duration,delay,once,isStatic]);const format=v=>{const fixed=Math.abs(v).toFixed(decimals);const[int,dec]=fixed.split(\".\");const grouped=separator?int.replace(/\\B(?=(\\d{3})+(?!\\d))/g,separator):int;return(v<0?\"−\":\"\")+grouped+(dec?\".\"+dec:\"\");};return /*#__PURE__*/_jsxs(\"span\",{ref:ref,style:{...font,color,display:\"inline-flex\",alignItems:\"baseline\",justifyContent:align,whiteSpace:\"nowrap\",margin:0},children:[prefix&&/*#__PURE__*/_jsx(\"span\",{style:{whiteSpace:\"pre\"},children:prefix}),/*#__PURE__*/_jsx(\"span\",{children:format(value)}),suffix&&/*#__PURE__*/_jsx(\"span\",{style:{whiteSpace:\"pre\",color:suffixColor||color,fontSize:suffixScale!==1?suffixScale+\"em\":undefined},children:suffix})]});}Counter.displayName=\"Counter\";addPropertyControls(Counter,{from:{type:ControlType.Number,title:\"From\",defaultValue:0,step:.1},to:{type:ControlType.Number,title:\"To\",defaultValue:70,step:.1},decimals:{type:ControlType.Number,title:\"Decimals\",defaultValue:0,min:0,max:4,step:1,displayStepper:true},prefix:{type:ControlType.String,title:\"Prefix\",defaultValue:\"\"},suffix:{type:ControlType.String,title:\"Suffix\",defaultValue:\"%\"},separator:{type:ControlType.String,title:\"Separator\",defaultValue:\",\"},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:.05,unit:\"s\"},once:{type:ControlType.Boolean,title:\"Play Once\",defaultValue:true},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"30px\",letterSpacing:\"-0.03em\",lineHeight:\"1.2em\"}},color:{type:ControlType.Color,title:\"Color\",defaultValue:\"#0E0E14\"},suffixColor:{type:ControlType.Color,title:\"Suffix Color\",optional:true},suffixScale:{type:ControlType.Number,title:\"Suffix Size\",defaultValue:1,min:.3,max:1,step:.05},align:{type:ControlType.Enum,title:\"Align\",options:[\"flex-start\",\"center\",\"flex-end\"],optionTitles:[\"Left\",\"Center\",\"Right\"],defaultValue:\"flex-start\",displaySegmentedControl:true}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"Counter\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"auto\",\"framerSupportedLayoutHeight\":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