{"version":3,"file":"StaggeredCountdown.CsJjs8eL.mjs","names":["useRef","useState","__esmMin","init_npm_react_18_3_1","init_ssg_sandbox_shims","te","window","_e","p","c","init_jsx_runtime","ce","de","useInView","animate","init_framer_motion_DhsWWWsN","addPropertyControls","init_framer_D6uXRwWs","ControlType","useIsStaticRenderer","StaggeredCountdown","props","isStatic","ref","isInView","hasAnimated","targetChars","targetNumber","digitIndices","digitCounter","ch","digitCount","animatedDigits","setAnimatedDigits","finalDigits","digitIndex","charIndex","parsed","timeouts","targetDigit","digitChar","staggerDelay","digitDuration","duration","timeoutId","easing","newDigits","prev","value","id","isFixedWidth","font","prefix","prefixColor","spacing","animatedValue","currentDigit","progress","nextDigit","direction","suffix","suffixColor","init_StaggeredCountdown"],"sources":["https:/framerusercontent.com/modules/c86UF2wgcWJ2bVn8rY2Y/he6cv9KZryjqBubsh60W/StaggeredCountdown.js"],"sourcesContent":["// Animated countdown component with staggered digit animations sliding up from bottom\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useState,useEffect,startTransition,useRef}from\"react\";import{animate,useInView}from\"framer-motion\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";/**\n * Animated Countdown Number with Staggered Animation\n *\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n */export default function StaggeredCountdown(props){const{targetNumber=\"1234\",duration=2,font,color=\"#000000\",prefix=\"\",suffix=\"\",prefixColor=\"#000000\",suffixColor=\"#000000\",easing=\"easeInOut\",spacing=0,direction=\"up\"}=props;const isStatic=useIsStaticRenderer();const ref=useRef(null);const isInView=useInView(ref,{amount:.5});const hasAnimated=useRef(false);// Ensure targetNumber is treated as a string to avoid type errors\nconst targetString=(targetNumber??\"\").toString();const targetChars=targetString.split(\"\");const digitIndices=[];let digitCounter=0;for(const ch of targetChars){if(ch>=\"0\"&&ch<=\"9\"){digitIndices.push(digitCounter);digitCounter+=1;}else{digitIndices.push(-1);}}const digitCount=digitCounter;// State to hold current animated values for each digit\nconst[animatedDigits,setAnimatedDigits]=useState(Array(digitCount).fill(0));// Start animations when component mounts / enters view\nuseEffect(()=>{// In static or server environments, skip animation and jump to final value\nif(isStatic||typeof window===\"undefined\"){const finalDigits=Array(digitCount).fill(0);targetChars.forEach((ch,charIndex)=>{const digitIndex=digitIndices[charIndex];if(digitIndex===-1)return;const parsed=parseInt(ch,10);finalDigits[digitIndex]=isNaN(parsed)?0:parsed;});startTransition(()=>{setAnimatedDigits(finalDigits);});return;}if(!isInView||hasAnimated.current)return;hasAnimated.current=true;// Reset to 0 before animating\nstartTransition(()=>{setAnimatedDigits(Array(digitCount).fill(0));});const timeouts=[];// Animate each digit with stagger\ntargetChars.forEach((digitChar,charIndex)=>{const digitIndex=digitIndices[charIndex];if(digitIndex===-1)return;const targetDigit=parseInt(digitChar,10);const staggerDelay=digitIndex*.1// 100ms stagger\n;const digitDuration=duration*.8// Slightly shorter than total duration\n;const timeoutId=window.setTimeout(()=>{animate(0,targetDigit,{duration:digitDuration,ease:easing,onUpdate:value=>{startTransition(()=>{setAnimatedDigits(prev=>{const newDigits=[...prev];newDigits[digitIndex]=Math.max(0,Math.min(9,value));return newDigits;});});}});},staggerDelay*1e3);timeouts.push(timeoutId);});return()=>{timeouts.forEach(id=>window.clearTimeout(id));};},[isStatic,isInView,targetChars.join(\"\"),duration,easing]);const isFixedWidth=props?.style&&props.style.width===\"100%\";return /*#__PURE__*/_jsxs(\"div\",{ref:ref,style:{...props.style,position:\"relative\",display:\"inline-flex\",alignItems:\"center\",justifyContent:\"center\",overflow:\"visible\",...isFixedWidth?{}:{width:\"max-content\"},...font,color},children:[prefix&&/*#__PURE__*/_jsx(\"span\",{style:{...font,color:prefixColor},children:prefix}),/*#__PURE__*/_jsx(\"div\",{style:{position:\"relative\",overflow:\"hidden\",height:\"1.2em\",display:\"inline-flex\",alignItems:\"center\",minWidth:\"max-content\",gap:`${spacing}px`,...font},children:targetChars.map((ch,charIndex)=>{const digitIndex=digitIndices[charIndex];if(digitIndex===-1){return /*#__PURE__*/_jsx(\"span\",{style:{...font,color,display:\"inline-block\",lineHeight:1,textAlign:\"center\",minWidth:\"0.3em\"},children:ch},charIndex);}const animatedValue=animatedDigits[digitIndex]??0;const currentDigit=Math.floor(animatedValue);const progress=animatedValue-currentDigit;const nextDigit=currentDigit+1;return /*#__PURE__*/_jsxs(\"div\",{style:{position:\"relative\",overflow:\"hidden\",height:\"1.2em\",display:\"inline-flex\",alignItems:\"center\",minWidth:\"0.6em\",justifyContent:\"center\",...font},children:[/*#__PURE__*/_jsx(\"div\",{style:{...font,color,fontVariantNumeric:\"tabular-nums\",display:\"inline-block\",lineHeight:1,textAlign:\"center\",width:\"100%\",position:\"absolute\",transform:direction===\"up\"?`translateY(${progress*-100}%)`:`translateY(${progress*100}%)`},children:currentDigit}),progress>0&&nextDigit<=9&&/*#__PURE__*/_jsx(\"div\",{style:{...font,color,fontVariantNumeric:\"tabular-nums\",display:\"inline-block\",lineHeight:1,textAlign:\"center\",width:\"100%\",position:\"absolute\",transform:direction===\"up\"?`translateY(${(1-progress)*100}%)`:`translateY(${(1-progress)*-100}%)`},children:nextDigit})]},charIndex);})}),suffix&&/*#__PURE__*/_jsx(\"span\",{style:{...font,color:suffixColor},children:suffix})]});}addPropertyControls(StaggeredCountdown,{targetNumber:{type:ControlType.String,title:\"Target Number\",defaultValue:\"1234\",placeholder:\"e.g. 99.9\"},duration:{type:ControlType.Number,title:\"Duration\",defaultValue:2,min:.5,max:10,step:.1,unit:\"s\"},prefix:{type:ControlType.String,title:\"Prefix\",defaultValue:\"\",placeholder:\"$, #, etc.\"},prefixColor:{type:ControlType.Color,title:\"Prefix Color\",defaultValue:\"#000000\"},suffix:{type:ControlType.String,title:\"Suffix\",defaultValue:\"\",placeholder:\"%, +, etc.\"},suffixColor:{type:ControlType.Color,title:\"Suffix Color\",defaultValue:\"#000000\"},color:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\"},easing:{type:ControlType.Enum,title:\"Easing\",defaultValue:\"easeInOut\",options:[\"linear\",\"easeIn\",\"easeOut\",\"easeInOut\",\"circIn\",\"circOut\",\"circInOut\",\"backIn\",\"backOut\",\"backInOut\"],optionTitles:[\"Linear\",\"Ease In\",\"Ease Out\",\"Ease In Out\",\"Circ In\",\"Circ Out\",\"Circ In Out\",\"Back In\",\"Back Out\",\"Back In Out\"]},spacing:{type:ControlType.Number,title:\"Spacing\",defaultValue:0,min:0,max:20,step:.1,unit:\"px\"},font:{type:ControlType.Font,title:\"Font\",defaultValue:{fontSize:\"48px\",variant:\"Bold\",letterSpacing:\"-0.02em\",lineHeight:\"1em\"},controls:\"extended\",defaultFontType:\"sans-serif\"},direction:{type:ControlType.Enum,title:\"Direction\",defaultValue:\"up\",options:[\"up\",\"down\"],optionTitles:[\"Up\",\"Down\"],displaySegmentedControl:true}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"StaggeredCountdown\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"auto\",\"framerSupportedLayoutWidth\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./StaggeredCountdown.map"],"mappings":"A,oRAMG,SAAwBoB,EAAmB,EAAM,CAAC,GAAK,CAAC,eAAa,OAAO,WAAS,EAAE,OAAK,QAAM,UAAU,SAAO,GAAG,SAAO,GAAG,cAAY,UAAU,cAAY,UAAU,SAAO,YAAY,UAAQ,EAAE,YAAU,MAAMC,EAAYC,EAASH,EAAoB,EAAQI,EAAIvB,EAAO,IAAI,EAAQwB,EAASX,EAAUU,EAAI,CAAC,OAAO,EAAE,CAAC,EAAQE,EAAYzB,EAAO,EAAK,EAC/S0B,GAAnCC,GAAc,GAAA,CAAI,SAAwC,CAAC,CAAC,MAAM,EAAE,EAAQC,EAAa,CAAC,EAAMC,EAAa,EAAE,IAAI,IAAMC,KAAMJ,EAAgBI,GAAI,KAAKA,GAAI,KAAKF,E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