{"version":3,"file":"Countdown.CevzUERK.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/P8brkvd3kojjaENqj6Hu/NHSyxzEQ4kyGvLsp3Bnw/Countdown.js"],"sourcesContent":["// Simple countdown component that syncs to a CMS date and time\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useState,startTransition}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function Countdown(props){const{targetDate,showDays,showHours,showMinutes,showSeconds,backgroundColor,textColor,labelColor,font,labelFont,gap,padding,borderRadius}=props;const[timeLeft,setTimeLeft]=useState({days:0,hours:0,minutes:0,seconds:0});const[isExpired,setIsExpired]=useState(false);useEffect(()=>{if(typeof window===\"undefined\")return;const calculateTimeLeft=()=>{const difference=new Date(targetDate).getTime()-new Date().getTime();if(difference<=0){startTransition(()=>{setIsExpired(true);setTimeLeft({days:0,hours:0,minutes:0,seconds:0});});return;}const days=Math.floor(difference/(1e3*60*60*24));const hours=Math.floor(difference/(1e3*60*60)%24);const minutes=Math.floor(difference/1e3/60%60);const seconds=Math.floor(difference/1e3%60);startTransition(()=>{setTimeLeft({days,hours,minutes,seconds});setIsExpired(false);});};calculateTimeLeft();const timer=setInterval(calculateTimeLeft,1e3);return()=>clearInterval(timer);},[targetDate]);const isFixedWidth=props?.style&&props.style.width===\"100%\";const timeUnits=[{value:timeLeft.days,label:\"Days\",show:showDays},{value:timeLeft.hours,label:\"Hours\",show:showHours},{value:timeLeft.minutes,label:\"Minutes\",show:showMinutes},{value:timeLeft.seconds,label:\"Seconds\",show:showSeconds}].filter(unit=>unit.show);return /*#__PURE__*/_jsx(\"div\",{style:{...props.style,position:\"relative\",...isFixedWidth?{...props?.style}:{minWidth:\"max-content\"},display:\"flex\",gap:gap,padding:padding,backgroundColor:backgroundColor,borderRadius:borderRadius},children:isExpired?/*#__PURE__*/_jsx(\"div\",{style:{...font,color:textColor,textAlign:\"center\",width:\"100%\"},children:\"Expired\"}):timeUnits.map((unit,index)=>/*#__PURE__*/_jsxs(\"div\",{style:{display:\"flex\",flexDirection:\"column\",alignItems:\"center\",gap:4},children:[/*#__PURE__*/_jsx(\"div\",{style:{...font,color:textColor,minWidth:\"max-content\"},children:String(unit.value).padStart(2,\"0\")}),/*#__PURE__*/_jsx(\"div\",{style:{...labelFont,color:labelColor,minWidth:\"max-content\"},children:unit.label})]},unit.label))});}addPropertyControls(Countdown,{targetDate:{type:ControlType.Date,title:\"Target Date\",displayTime:true},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\"},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"#FFFFFF\"},textColor:{type:ControlType.Color,title:\"Number Color\",defaultValue:\"#000000\"},labelColor:{type:ControlType.Color,title:\"Label Color\",defaultValue:\"#CCCCCC\"},font:{type:ControlType.Font,title:\"Number Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"40px\",variant:\"Bold\",letterSpacing:\"-0.04em\",lineHeight:\"1em\"}},labelFont:{type:ControlType.Font,title:\"Label Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"14px\",variant:\"Medium\",letterSpacing:\"-0.01em\",lineHeight:\"1em\"}},gap:{type:ControlType.Number,title:\"Gap\",defaultValue:20,min:0,max:100,step:1,unit:\"px\"},padding:{type:ControlType.Number,title:\"Padding\",defaultValue:20,min:0,max:100,step:1,unit:\"px\"},borderRadius:{type:ControlType.Number,title:\"Radius\",defaultValue:8,min:0,max:50,step:1,unit:\"px\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"Countdown\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Countdown.map"],"mappings":"wMAIG,SAAwB,EAAU,EAAM,CAAC,GAAK,CAAC,aAAW,WAAS,YAAU,cAAY,cAAY,kBAAgB,YAAU,aAAW,OAAK,YAAU,MAAI,UAAQ,gBAAc,EAAW,CAAC,EAAS,GAAaA,EAAS,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAM,CAAC,EAAU,GAAcA,EAAS,GAAM,CAAC,MAAc,CAAC,GAAU,IAAS,OAAY,OAAO,IAAM,MAAsB,CAAC,IAAM,EAAW,IAAI,KAAK,EAAW,CAAC,SAAS,CAAC,IAAI,MAAM,CAAC,SAAS,CAAC,GAAG,GAAY,EAAE,CAAC,MAAoB,CAAC,EAAa,GAAK,CAAC,EAAY,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,EAAG,CAAC,OAAQ,IAAM,EAAK,KAAK,MAAM,GAAY,IAAI,GAAG,GAAG,IAAI,CAAO,EAAM,KAAK,MAAM,GAAY,IAAI,GAAG,IAAI,GAAG,CAAO,EAAQ,KAAK,MAAM,EAAW,IAAI,GAAG,GAAG,CAAO,EAAQ,KAAK,MAAM,EAAW,IAAI,GAAG,CAAC,MAAoB,CAAC,EAAY,CAAC,OAAK,QAAM,UAAQ,UAAQ,CAAC,CAAC,EAAa,GAAM,EAAG,EAAG,GAAmB,CAAC,IAAM,EAAM,YAAY,EAAkB,IAAI,CAAC,UAAU,cAAc,EAAM,EAAG,CAAC,EAAW,CAAC,CAAC,IAA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