{"version":3,"file":"CountdownTimer_1.CFjGoebS.mjs","names":["useState","startTransition","useMemo"],"sources":["https:/framerusercontent.com/modules/W7r1E2mzrCONTmFbmJoL/OpBPdPK1okWiJajZhzvi/CountdownTimer_1.js"],"sourcesContent":["// CountdownTimer Timer with Full Date & Time from CMS\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useState,useMemo,startTransition}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * CountdownTimer Timer (Full Date-Time)\n *\n * @framerIntrinsicWidth 320\n * @framerIntrinsicHeight 80\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight fixed\n */export default function CountdownTimer(props){const{dateTime,label,background,color,font,borderRadius,style}=props;const[now,setNow]=useState(Date.now());useEffect(()=>{const timer=setInterval(()=>startTransition(()=>setNow(Date.now())),1e3);return()=>clearInterval(timer);},[]);// Use UTC now for diff\nconst diff=useMemo(()=>{const targetUTC=Date.parse(dateTime);// Determine user's timezone offset in ms at now\nconst userOffsetMs=new Date(now).getTimezoneOffset()*6e4;// Convert \"now\" to the user's local timezone equivalent of the UTC target\nconst userNow=now-userOffsetMs;return Math.max(0,Math.floor((targetUTC-userNow)/1e3));},[dateTime,now]);const timeParts=useMemo(()=>{const days=Math.floor(diff/86400);const hours=Math.floor(diff%86400/3600);const minutes=Math.floor(diff%3600/60);const seconds=diff%60;return{days,hours,minutes,seconds};},[diff]);const showDays=timeParts.days>0;// Format as 00:00:00:00 (days:hours:minutes:seconds) even if days is 0\nconst formatted=[String(timeParts.days).padStart(2,\"0\"),String(timeParts.hours).padStart(2,\"0\"),String(timeParts.minutes).padStart(2,\"0\"),String(timeParts.seconds).padStart(2,\"0\")].join(\":\");return /*#__PURE__*/_jsxs(\"div\",{style:{...style,color,display:\"flex\",alignItems:\"center\",gap:18,padding:0,minWidth:undefined,minHeight:undefined,background:undefined,borderRadius:undefined,width:\"max-content\",height:\"max-content\",justifyContent:\"flex-start\",...font},children:[/*#__PURE__*/_jsx(\"span\",{children:label}),/*#__PURE__*/_jsx(\"span\",{style:{fontVariantNumeric:\"tabular-nums\",padding:0,margin:0,paddingLeft:0,marginLeft:0},children:formatted})]});}addPropertyControls(CountdownTimer,{dateTime:{type:ControlType.String,title:\"Date-Time (ISO)\",placeholder:\"2024-06-07T18:29:00Z\",defaultValue:new Date(Date.now()+864e5).toISOString(),displayTextArea:false},label:{type:ControlType.String,title:\"Label\",defaultValue:\"Time left:\"},background:{type:ControlType.Color,title:\"Background\",defaultValue:\"#FFFFFF\"},color:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"22px\",variant:\"Semibold\",letterSpacing:\"-0.01em\",lineHeight:\"1.2em\"}},borderRadius:{type:ControlType.Number,title:\"Radius\",defaultValue:8,min:0,max:32,step:1}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CountdownTimer\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"fixed\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\",\"framerIntrinsicHeight\":\"80\",\"framerIntrinsicWidth\":\"320\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CountdownTimer_1.map"],"mappings":"gSASG,SAAwB,EAAe,EAAM,CAAC,GAAK,CAAC,WAAS,QAAM,aAAW,QAAM,OAAK,eAAa,SAAO,EAAW,CAAC,EAAI,GAAQA,EAAS,KAAK,KAAK,CAAC,CAAC,MAAc,CAAC,IAAM,EAAM,gBAAgBC,MAAoB,EAAO,KAAK,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,cAAc,EAAM,EAAG,EAAE,CAAC,CACzR,IAAM,EAAKC,MAAY,CAAC,IAAM,EAAU,KAAK,MAAM,EAAS,CACtD,EAAa,IAAI,KAAK,EAA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