{"version":3,"file":"CountdownTimer.C7B2dvym.mjs","names":["useState","useMemo","React"],"sources":["https:/framerusercontent.com/modules/Miq5HMuwGWkaAHes5gwq/EGpLTikkkTC0TDIIAeob/CountdownTimer.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";import React,{useEffect,useMemo,useState,startTransition}from\"react\";/**\n * @framerIntrinsicWidth 720\n * @framerIntrinsicHeight 160\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function CountdownTimer(props){const{targetDate,daysLabel,hoursLabel,minutesLabel,secondsLabel,endMessage,numbersFont,labelsFont,numbersColor,labelsColor,wrapperBackground,blockBackground,blockRadius,gap,blockPadding,separator,style}=props;const isStatic=useIsStaticRenderer();const[nowMs,setNowMs]=useState(()=>{if(typeof Date!==\"undefined\")return Date.now();return 0;});const targetMs=useMemo(()=>{const t=new Date(targetDate).getTime();return Number.isFinite(t)?t:NaN;},[targetDate]);const parts=useMemo(()=>{if(!Number.isFinite(targetMs)){return{days:0,hours:0,minutes:0,seconds:0,isEnded:false};}const diff=targetMs-nowMs;if(diff<=0){return{days:0,hours:0,minutes:0,seconds:0,isEnded:true};}const totalSeconds=Math.floor(diff/1e3);const days=Math.floor(totalSeconds/86400);const rem1=totalSeconds%86400;const hours=Math.floor(rem1/3600);const rem2=rem1%3600;const minutes=Math.floor(rem2/60);const seconds=rem2%60;return{days,hours,minutes,seconds,isEnded:false};},[nowMs,targetMs]);useEffect(()=>{if(isStatic)return;if(!Number.isFinite(targetMs))return;if(typeof window===\"undefined\")return;if(parts.isEnded)return;const id=window.setInterval(()=>{startTransition(()=>setNowMs(Date.now()));},1e3);return()=>{window.clearInterval(id);};},[isStatic,targetMs,parts.isEnded]);const blocks=useMemo(()=>{const pad2=n=>String(n).padStart(2,\"0\");return[{key:\"days\",value:String(parts.days),label:daysLabel},{key:\"hours\",value:pad2(parts.hours),label:hoursLabel},{key:\"minutes\",value:pad2(parts.minutes),label:minutesLabel},{key:\"seconds\",value:pad2(parts.seconds),label:secondsLabel}];},[parts.days,parts.hours,parts.minutes,parts.seconds,daysLabel,hoursLabel,minutesLabel,secondsLabel]);const showSeparator=(separator??\"\").length>0;if(parts.isEnded){return /*#__PURE__*/_jsx(\"div\",{style:{...style,position:\"relative\",width:\"100%\",height:\"100%\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",background:wrapperBackground,color:labelsColor,overflow:\"hidden\"},role:\"status\",\"aria-live\":\"polite\",children:/*#__PURE__*/_jsx(\"span\",{style:{...labelsFont,color:labelsColor,textAlign:\"center\",padding:\"8px 12px\"},children:endMessage})});}return /*#__PURE__*/_jsx(\"div\",{style:{...style,position:\"relative\",width:\"100%\",height:\"100%\",display:\"flex\",alignItems:\"stretch\",justifyContent:\"space-between\",gap,background:wrapperBackground,overflow:\"hidden\",boxSizing:\"border-box\"},role:\"group\",\"aria-label\":\"Countdown timer\",children:blocks.map((b,idx)=>{const block=/*#__PURE__*/_jsx(\"div\",{style:{flex:\"1 1 0%\",minWidth:0,display:\"flex\",flexDirection:\"column\",alignItems:\"center\",justifyContent:\"center\",gap:6,boxSizing:\"border-box\",padding:blockPadding,borderRadius:blockRadius,background:blockBackground},\"aria-label\":`${b.label}: ${b.value}`,children:/*#__PURE__*/_jsxs(\"div\",{style:{width:\"100%\",display:\"flex\",alignItems:\"baseline\",justifyContent:\"center\",gap:6,whiteSpace:\"nowrap\"},children:[/*#__PURE__*/_jsx(\"span\",{style:{...numbersFont,color:numbersColor,lineHeight:(numbersFont?.lineHeight)??\"1em\",fontVariantNumeric:\"tabular-nums\"},children:b.value}),/*#__PURE__*/_jsx(\"span\",{style:{...labelsFont,color:labelsColor,lineHeight:(labelsFont?.lineHeight)??\"1.2em\",opacity:.9},children:b.label})]})},b.key);if(!showSeparator||idx===blocks.length-1)return block;return /*#__PURE__*/_jsxs(React.Fragment,{children:[block,/*#__PURE__*/_jsx(\"div\",{\"aria-hidden\":\"true\",style:{alignSelf:\"center\",flex:\"0 0 auto\",color:labelsColor,...labelsFont,fontVariantNumeric:\"tabular-nums\",lineHeight:\"1em\",paddingInline:Math.max(2,Math.floor(gap/4)),userSelect:\"none\",whiteSpace:\"pre\"},children:separator})]},b.key);})});}addPropertyControls(CountdownTimer,{targetDate:{type:ControlType.Date,title:\"Target Date\",displayTime:true,defaultValue:new Date(Date.now()+7*24*60*60*1e3).toJSON()},daysLabel:{type:ControlType.String,title:\"Days Label\",defaultValue:\"Days\"},hoursLabel:{type:ControlType.String,title:\"Hours Label\",defaultValue:\"Hours\"},minutesLabel:{type:ControlType.String,title:\"Minutes Label\",defaultValue:\"Minutes\"},secondsLabel:{type:ControlType.String,title:\"Seconds Label\",defaultValue:\"Seconds\"},endMessage:{type:ControlType.String,title:\"End Message\",defaultValue:\"Countdown finished\",displayTextArea:true},numbersFont:{type:ControlType.Font,title:\"Numbers Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"40px\",variant:\"Bold\",letterSpacing:\"-0.04em\",lineHeight:\"1em\"}},labelsFont:{type:ControlType.Font,title:\"Labels Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"14px\",variant:\"Medium\",letterSpacing:\"-0.01em\",lineHeight:\"1.2em\"}},numbersColor:{type:ControlType.Color,title:\"Numbers Color\",defaultValue:\"#000000\"},labelsColor:{type:ControlType.Color,title:\"Labels Color\",defaultValue:\"#000000\"},wrapperBackground:{type:ControlType.Color,title:\"Wrapper BG\",defaultValue:\"rgba(0, 0, 0, 0)\"},blockBackground:{type:ControlType.Color,title:\"Block BG\",defaultValue:\"#F5F5F5\"},blockRadius:{type:ControlType.BorderRadius,title:\"Block Radius\",defaultValue:\"12px\"},gap:{type:ControlType.Number,title:\"Gap\",defaultValue:12,min:0,max:120,step:1,unit:\"px\"},blockPadding:{type:ControlType.Padding,title:\"Block Padding\",defaultValue:\"12px\"},separator:{type:ControlType.String,title:\"Separator\",defaultValue:\"\",placeholder:\"e.g. :\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CountdownTimer\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerIntrinsicHeight\":\"160\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerIntrinsicWidth\":\"720\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CountdownTimer.map"],"mappings":"8NAMG,SAAwB,EAAe,EAAM,CAAC,GAAK,CAAC,aAAW,YAAU,aAAW,eAAa,eAAa,aAAW,cAAY,aAAW,eAAa,cAAY,oBAAkB,kBAAgB,cAAY,MAAI,eAAa,YAAU,SAAO,EAAY,EAAS,GAAqB,CAAM,CAAC,EAAM,GAAUA,MAAiB,OAAO,KAAO,IAAmB,KAAK,KAAK,CAAQ,EAAI,CAAO,EAASC,MAAY,CAAC,IAAM,EAAE,IAAI,KAAK,EAAW,CAAC,SAAS,CAAC,OAAO,OAAO,SAAS,EAAE,CAAC,EAAE,KAAM,CAAC,EAAW,CAAC,CAAO,EAAMA,MAAY,CAAC,GAAG,CAAC,OAAO,SAAS,EAAS,CAAE,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,GAAM,CAAE,IAAM,EAAK,EAAS,EAAM,GAAG,GAAM,EAAG,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,GAAK,CAAE,IAAM,EAAa,KAAK,MAAM,EAAK,IAAI,CAAO,EAAK,KAAK,MAAM,EAAa,MAAM,CAAO,EAAK,EAAa,MAAY,EAAM,KAAK,MAAM,EAAK,KAAK,CAAO,EAAK,EAAK,KAA6D,MAAM,CAAC,OAAK,QAAM,QAA5D,KAAK,MAAM,EAAK,GAAG,CAAiD,QAAlC,EA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