{"version":3,"file":"Counter.CMPjpG4f.mjs","names":["useState","useMemo","_Fragment","__esmMin","pe","init_npm_react_18_3_1","ce","init_jsx_runtime","c","p","_e","init_framer_motion_DhsWWWsN","motion","addPropertyControls","RenderTarget","init_framer_BisrWwwE","ControlType","Counter","formattedNumber","setFormattedNumber","number","yFrom","direction","generateData","format","renderItems","data","delay","current","rowIndex","isNumber","l","item","yTo","animate","isLastDigit","colIndex","transition","onCompleted","font","init_Counter","props"],"sources":["https:/framerusercontent.com/modules/W2xGE54Zay1aIfsNX1yk/sjiiZGNK9czycd8NT0Kg/Counter.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from\"react/jsx-runtime\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";import{motion}from\"framer-motion\";import{useEffect,useMemo,useState}from\"react\";/**\n * @framerDisableUnlink\n *\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n */export default function Counter({number,direction,format,font,color,transition,animate,onCompleted}){const[formattedNumber,setFormattedNumber]=useState(number);const yFrom=direction===\"up\"?100:-100;const generateData=length=>{return[...Array.from({length},()=>[...Array(10).keys()])];};useEffect(()=>{setFormattedNumber(new Intl.NumberFormat(format.locale||document.documentElement.lang,{useGrouping:format.grouping,minimumFractionDigits:format.fractionDigits}).format(number));},[number]);const renderItems=useMemo(()=>{const data=generateData(formattedNumber.length);let delay=0;return data.map((item,rowIndex)=>{const current=formattedNumber[rowIndex];const isNumber=Number.isInteger(parseInt(current,10));// delay = Math.max(0, (data.length - rowIndex) / data.length)\ndelay=(data.length-1-rowIndex)/(data.length-1)*.4;return /*#__PURE__*/_jsx(_Fragment,{children:isNumber&&RenderTarget.current()!==RenderTarget.canvas?/*#__PURE__*/_jsx(\"div\",{style:{position:\"relative\",overflowY:\"clip\"},children:item.map((item,colIndex)=>{delay+=.1;let yTo;if(animate){if(item===Number(current)){yTo=0;}else{if(item>Number(current)){yTo=yFrom;}else{yTo=yFrom*-1;}}}else{yTo=item===0?0:yFrom;}const isLastDigit=rowIndex===data.length-1&&item===Number(current);return /*#__PURE__*/_jsx(motion.div,{style:colIndex>0?{position:\"absolute\",top:0,y:`${yFrom}%`}:undefined,transition:{...transition,delay:delay+transition.delay},whileInView:animate?{y:`${yTo}%`}:undefined,onAnimationComplete:()=>{if(isLastDigit&&onCompleted){onCompleted();/*setTimeout(\n                                                    () => onCompleted(),\n                                                    transition.delay\n                                                )*/}},viewport:{once:true},children:colIndex},colIndex);})},rowIndex):current});});},[animate,formattedNumber]);return /*#__PURE__*/_jsxs(\"div\",{style:{display:\"flex\",fontFamily:font.fontFamily,fontWeight:font.fontWeight,fontStyle:font.fontStyle,fontSize:font.fontSize,lineHeight:font.lineHeight,letterSpacing:font.letterSpacing,fontVariant:\"tabular-nums\",color},children:[format.prefix&&/*#__PURE__*/_jsx(\"div\",{style:{whiteSpace:\"pre-wrap\"},children:format.prefix}),renderItems,format.suffix&&/*#__PURE__*/_jsx(\"div\",{style:{whiteSpace:\"pre-wrap\"},children:format.suffix})]});}addPropertyControls(Counter,{number:{type:ControlType.Number,displayStepper:true,defaultValue:99},direction:{type:ControlType.Enum,defaultValue:\"up\",options:[\"up\",\"down\"],optionTitles:[\"Up\",\"Down\"],displaySegmentedControl:true},format:{type:ControlType.Object,controls:{locale:{type:ControlType.String},fractionDigits:{type:ControlType.Number,defaultValue:0,min:0,max:20},grouping:{type:ControlType.Enum,defaultValue:\"auto\",segmentedControlDirection:\"vertical\",options:[\"auto\",\"always\",false],optionTitles:[\"Auto\",\"Always\",\"None\"]},prefix:{type:ControlType.String},suffix:{type:ControlType.String}}},font:{type:ControlType.Font,controls:\"extended\",displayFontSize:true,displayTextAlignment:false,defaultFontType:\"sans-serif\",defaultValue:{fontSize:16,lineHeight:1}},color:{type:ControlType.Color,defaultValue:\"#000\"},transition:{type:ControlType.Transition,defaultValue:{duration:.6,delay:0,ease:[.23,1,.32,1]},hidden(props){return!props.animate;}},animate:{type:ControlType.Boolean,enabledTitle:\"Yes\",disabledTitle:\"No\"},onCompleted:{type:ControlType.EventHandler}});Counter.displayName=\"002 Counter\";\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"Counter\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"any\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"any\",\"framerDisableUnlink\":\"*\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Counter.map"],"mappings":"A,gQAKG,SAAwBiB,EAAQ,CAAC,SAAO,YAAU,SAAO,OAAK,QAAM,aAAW,UAAQ,eAAa,CAAC,GAAK,CAACC,EAAgBC,GAAoBnB,EAASoB,CAAM,EAAQC,EAAMC,IAAY,KAAK,IAAI,KAAWC,EAAa,GAAe,CAAC,GAAG,MAAM,KAAK,CAAC,QAAM,MAAM,CAAC,GAAG,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAIjB,MAAc,CAACa,EAAmB,IAAI,KAAK,aAAaK,EAAO,QAAQ,SAAS,gBAAgB,KAAK,CAAC,YAAYA,EAAO,SAAS,sBAAsBA,EAAO,cAAc,CAAC,CAAC,CAAC,OAAOJ,CAAM,CAAC,CAAE,EAAE,CAACA,CAAM,CAAC,EAAE,IAAMK,EAAYxB,MAAY,CAAC,IAAMyB,EAAKH,EAAaL,EAAgB,MAAM,EAAMS,EAAM,EAAE,OAAOD,EAAK,KAAK,EAAK,IAAW,CAAC,IAAME,EAAQV,EAAgBW,GAAgBC,EAAS,OAAO,UAAU,SAASF,EAAQ,EAAE,CAAC,EACppB,MAAlD,IAAOF,EAAK,OAAO,EAAEG,IAAWH,EAAK,OAAO,GAAG,GAAuB,gBAAKxB,EAAU,CAAC,SAAS4B,GAAUhB,EAAa,QAAQ,IAAIA,EAAa,OAAoB,gBAAK,MAAM,CAAC,MAAM,CAAC,SAAS,WAAW,UAAU,MAAM,EAAE,SAASkB,EAAK,KAAK,EAAK,IA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