{"version":3,"file":"CountdownTimer.CSgWiLLO.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/MwDGY1L5V0LngtCroS7e/pioGp2GDgAJiCr3HLoEf/CountdownTimer.js"],"sourcesContent":["// CountdownTimer timer component that counts down to a specific date\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useState,startTransition}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * CountdownTimer Timer\n *\n * @framerIntrinsicWidth 400\n * @framerIntrinsicHeight 120\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function CountdownTimer(props){const{targetDate,showDays=true,showHours=true,showMinutes=true,showSeconds=true,backgroundColor,textColor,labelColor,font,labelFont,separator,gap=20,alignment=\"center\",textElement=\"div\"}=props;const[timeRemaining,setTimeRemaining]=useState({days:0,hours:0,minutes:0,seconds:0,isExpired:false});useEffect(()=>{if(typeof window===\"undefined\")return;const calculateTimeRemaining=()=>{const now=new Date().getTime();const target=new Date(targetDate).getTime();const difference=target-now;if(difference<=0){startTransition(()=>setTimeRemaining({days:0,hours:0,minutes:0,seconds:0,isExpired:true}));return;}const days=Math.floor(difference/(1e3*60*60*24));const hours=Math.floor(difference%(1e3*60*60*24)/(1e3*60*60));const minutes=Math.floor(difference%(1e3*60*60)/(1e3*60));const seconds=Math.floor(difference%(1e3*60)/1e3);startTransition(()=>setTimeRemaining({days,hours,minutes,seconds,isExpired:false}));};calculateTimeRemaining();const interval=setInterval(calculateTimeRemaining,1e3);return()=>clearInterval(interval);},[targetDate]);const formatNumber=num=>{return num.toString().padStart(2,\"0\");};const timeUnits=[{value:timeRemaining.days,label:\"Days\",show:showDays},{value:timeRemaining.hours,label:\"Hours\",show:showHours},{value:timeRemaining.minutes,label:\"Minutes\",show:showMinutes},{value:timeRemaining.seconds,label:\"Seconds\",show:showSeconds}].filter(unit=>unit.show);const isFixedWidth=props?.style&&props.style.width===\"100%\";const alignmentMap={left:\"flex-start\",center:\"center\",right:\"flex-end\"};const NumberElement=textElement;const LabelElement=textElement;return /*#__PURE__*/_jsx(\"div\",{style:{...props.style,position:\"relative\",...isFixedWidth?{...props?.style}:{minWidth:\"max-content\"},backgroundColor,display:\"flex\",alignItems:\"center\",justifyContent:alignmentMap[alignment],gap,padding:20,borderRadius:8},children:timeRemaining.isExpired?/*#__PURE__*/_jsx(NumberElement,{style:{...font,color:textColor,margin:0},children:\"Time's up!\"}):timeUnits.map((unit,index)=>/*#__PURE__*/_jsxs(\"div\",{style:{display:\"flex\",alignItems:\"center\",gap},children:[/*#__PURE__*/_jsxs(\"div\",{style:{display:\"flex\",alignItems:\"center\",gap:gap/2},children:[/*#__PURE__*/_jsx(NumberElement,{style:{...font,color:textColor,margin:0},children:formatNumber(unit.value)}),/*#__PURE__*/_jsx(LabelElement,{style:{...labelFont,color:labelColor,margin:0},children:unit.label})]}),index<timeUnits.length-1&&/*#__PURE__*/_jsx(NumberElement,{style:{...font,color:textColor,margin:0},children:separator})]},unit.label))});}addPropertyControls(CountdownTimer,{targetDate:{type:ControlType.Date,title:\"Target Date\",displayTime:true},textElement:{type:ControlType.Enum,title:\"Text Element\",options:[\"p\",\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\",\"span\",\"div\"],optionTitles:[\"P\",\"H1\",\"H2\",\"H3\",\"H4\",\"H5\",\"H6\",\"Span\",\"Div\"],defaultValue:\"div\",displaySegmentedControl:false},alignment:{type:ControlType.Enum,title:\"Alignment\",options:[\"left\",\"center\",\"right\"],optionTitles:[\"Left\",\"Center\",\"Right\"],defaultValue:\"center\",displaySegmentedControl:true},gap:{type:ControlType.Number,title:\"Gap\",defaultValue:20,min:0,max:100,step:1,unit:\"px\"},showDays:{type:ControlType.Boolean,title:\"Show Days\",defaultValue:true,enabledTitle:\"Show\",disabledTitle:\"Hide\"},showHours:{type:ControlType.Boolean,title:\"Show Hours\",defaultValue:true,enabledTitle:\"Show\",disabledTitle:\"Hide\"},showMinutes:{type:ControlType.Boolean,title:\"Show Minutes\",defaultValue:true,enabledTitle:\"Show\",disabledTitle:\"Hide\"},showSeconds:{type:ControlType.Boolean,title:\"Show Seconds\",defaultValue:true,enabledTitle:\"Show\",disabledTitle:\"Hide\"},separator:{type:ControlType.String,title:\"Separator\",defaultValue:\":\"},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"#FFFFFF\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\"},labelColor:{type:ControlType.Color,title:\"Label Color\",defaultValue:\"#CCCCCC\"},font:{type:ControlType.Font,title:\"Number Font\",defaultValue:{fontSize:\"40px\",variant:\"Bold\",letterSpacing:\"-0.04em\",lineHeight:\"1em\"},controls:\"extended\",defaultFontType:\"sans-serif\"},labelFont:{type:ControlType.Font,title:\"Label Font\",defaultValue:{fontSize:\"14px\",variant:\"Medium\",letterSpacing:\"-0.01em\",lineHeight:\"1em\"},controls:\"extended\",defaultFontType:\"sans-serif\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CountdownTimer\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerIntrinsicHeight\":\"120\",\"framerIntrinsicWidth\":\"400\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CountdownTimer.map"],"mappings":"6MASG,SAAwB,EAAe,EAAM,CAAC,GAAK,CAAC,aAAW,WAAS,GAAK,YAAU,GAAK,cAAY,GAAK,cAAY,GAAK,kBAAgB,YAAU,aAAW,OAAK,YAAU,YAAU,MAAI,GAAG,YAAU,SAAS,cAAY,OAAO,EAAW,CAAC,EAAc,GAAkBA,EAAS,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAK,CAAC,EAAE,MAAc,CAAC,GAAU,IAAS,OAAY,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