{"version":3,"file":"Countdown_IMC.DObazr-R.mjs","names":["React.useState","React.useRef","React.Fragment"],"sources":["https:/framerusercontent.com/modules/blzqcL9SZ0PSQ8IdF9oK/M1gvQuejEMQPidETYGiZ/Countdown_IMC.js"],"sourcesContent":["// Countdown timer component with customizable colors and date target\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n */export default function Countdown(props){const{targetDate,boxColor,strokeColor,textColor,daysColor,colonColor,font,scale:userScale}=props;function calculateTimeLeft(){const target=new Date(targetDate);const now=new Date;if(isNaN(target.getTime())){return{days:0,hours:0,minutes:0,seconds:0};}const difference=+target-+now;if(difference>0){return{days:Math.floor(difference/(1e3*60*60*24)),hours:Math.floor(difference/(1e3*60*60)%24),minutes:Math.floor(difference/1e3/60%60),seconds:Math.floor(difference/1e3%60)};}return{days:0,hours:0,minutes:0,seconds:0};}const[timeLeft,setTimeLeft]=React.useState(()=>calculateTimeLeft());const[scale,setScale]=React.useState(1);const containerRef=React.useRef(null);const contentRef=React.useRef(null);React.useEffect(()=>{const timer=setInterval(()=>{React.startTransition(()=>{setTimeLeft(calculateTimeLeft());});},1e3);return()=>clearInterval(timer);},[targetDate]);React.useEffect(()=>{const updateScale=()=>{if(containerRef.current&&contentRef.current){const containerWidth=containerRef.current.offsetWidth;const contentWidth=contentRef.current.offsetWidth;if(contentWidth>0){const newScale=Math.min(1,containerWidth/contentWidth);React.startTransition(()=>{setScale(newScale);});}}};updateScale();const resizeObserver=new ResizeObserver(updateScale);if(containerRef.current){resizeObserver.observe(containerRef.current);}return()=>{resizeObserver.disconnect();};},[]);const formatTime=time=>time<10?`0${time}`:time;const outerContainerStyle={width:\"100%\",height:\"100%\",display:\"flex\",justifyContent:\"center\",alignItems:\"center\",overflow:\"hidden\"};const containerStyle={display:\"flex\",alignItems:\"center\",width:\"max-content\",transform:`scale(${scale*userScale})`,transformOrigin:\"center center\"};const boxStyle={display:\"flex\",justifyContent:\"center\",alignItems:\"center\",width:\"64px\",height:\"64px\",backgroundColor:boxColor,border:`1.5px solid ${strokeColor}`,borderRadius:\"8px\",boxSizing:\"border-box\"};const numberBaseStyle={...font};const colonStyle={...font,margin:\"0 6px\",display:\"flex\",alignItems:\"center\",height:\"64px\",color:colonColor};const timeUnits=[timeLeft.days,timeLeft.hours,timeLeft.minutes,timeLeft.seconds];return /*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:outerContainerStyle,children:/*#__PURE__*/_jsx(\"div\",{ref:contentRef,style:containerStyle,children:timeUnits.map((value,index)=>{const customColor=index===0?daysColor:textColor;return /*#__PURE__*/_jsxs(React.Fragment,{children:[/*#__PURE__*/_jsx(\"div\",{style:boxStyle,children:/*#__PURE__*/_jsx(\"span\",{style:{...numberBaseStyle,color:customColor},children:formatTime(value||0)})}),index<timeUnits.length-1&&/*#__PURE__*/_jsx(\"span\",{style:colonStyle,children:\":\"})]},index);})})});}addPropertyControls(Countdown,{targetDate:{type:ControlType.String,title:\"Target Date\",defaultValue:\"2025-12-31T00:00:00\",placeholder:\"YYYY-MM-DDTHH:MM:SS\"},scale:{type:ControlType.Number,title:\"Scale\",defaultValue:.9,min:.1,max:2,step:.1},boxColor:{type:ControlType.Color,title:\"Box Background\",defaultValue:\"#FFFFFF\"},strokeColor:{type:ControlType.Color,title:\"Border Color\",defaultValue:\"#000000\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\"},daysColor:{type:ControlType.Color,title:\"Days Color\",defaultValue:\"#FA0030\"},colonColor:{type:ControlType.Color,title:\"Colon Color\",defaultValue:\"#000000\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"24px\",variant:\"Semibold\",letterSpacing:\"-0.01em\",lineHeight:\"1em\"}}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"Countdown\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"any\",\"framerSupportedLayoutWidth\":\"any\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Countdown_IMC.map"],"mappings":"wMAIG,SAAwB,EAAU,EAAM,CAAC,GAAK,CAAC,aAAW,WAAS,cAAY,YAAU,YAAU,aAAW,OAAK,MAAM,GAAW,EAAM,SAAS,GAAmB,CAAC,IAAM,EAAO,IAAI,KAAK,EAAW,CAAO,EAAI,IAAI,KAAK,GAAG,MAAM,EAAO,SAAS,CAAC,CAAE,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAE,IAAM,EAAY,EAAO,CAAC,EAAoM,OAA7L,EAAW,EAAS,CAAC,KAAK,KAAK,MAAM,GAAY,IAAI,GAAG,GAAG,IAAI,CAAC,MAAM,KAAK,MAAM,GAAY,IAAI,GAAG,IAAI,GAAG,CAAC,QAAQ,KAAK,MAAM,EAAW,IAAI,GAAG,GAAG,CAAC,QAAQ,KAAK,MAAM,EAAW,IAAI,GAAG,CAAC,CAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAE,GAAK,CAAC,EAAS,GAAaA,MAAmB,GAAmB,CAAC,CAAM,CAAC,EAAM,GAAUA,EAAe,EAAE,CAAO,EAAaC,EAAa,KAAK,CAAO,EAAWA,EAAa,KAAK,CAAC,MAAoB,CAAC,IAAM,EAAM,gBAAgB,CAAC,MAA0B,CAAC,EAAY,GAAmB,CAAC,EAAG,EAAG,IAAI,CAAC,UAAU,cAAc,EAAM,EAAG,CAAC,EAAW,CAAC,CAAC,MAAoB,CAAC,IAAM,MAAgB,CAAC,GAAG,EAAa,SAAS,EAAW,QAAQ,CAAC,IAAM,EAAe,EAAa,QAAQ,YAAkB,EAAa,EAAW,QAAQ,YAAY,GAAG,EAAa,EAAE,CAAC,IAAM,EAA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