{"version":3,"file":"TimeCounter.BUnP9tsq.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/1SF7pZs1u5UVOIQABLrj/y0b2HnZkY3hMlpVtUXRr/TimeCounter.js"],"sourcesContent":["// Time counter component that counts up from zero or a specified start time\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useState,useEffect,startTransition}from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";/**\n * Time Counter\n * \n * @framerIntrinsicWidth 300\n * @framerIntrinsicHeight 100\n * \n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function TimeCounter(props){const{countUp=true,startTime=0,startFrom=0,showHours=true,showMilliseconds=false,autoStart=true,textColor=\"#000000\",backgroundColor=\"#FFFFFF\",font,padding=\"20px\",style}=props;const[time,setTime]=useState(startFrom*1e3);const[isRunning,setIsRunning]=useState(autoStart);const isStatic=useIsStaticRenderer();useEffect(()=>{if(isStatic||!isRunning)return;const interval=setInterval(()=>{startTransition(()=>{setTime(prevTime=>{if(countUp){return prevTime+(showMilliseconds?10:1e3);}else{const newTime=prevTime-(showMilliseconds?10:1e3);if(newTime<=0){setIsRunning(false);return 0;}return newTime;}});});},showMilliseconds?10:1e3);return()=>clearInterval(interval);},[isRunning,countUp,showMilliseconds,isStatic]);const formatTime=milliseconds=>{const totalSeconds=Math.floor(milliseconds/1e3);const hours=Math.floor(totalSeconds/3600);const minutes=Math.floor(totalSeconds%3600/60);const seconds=totalSeconds%60;const ms=Math.floor(milliseconds%1e3/10);let timeString=\"\";if(showHours){timeString+=`${hours.toString().padStart(2,\"0\")}:`;}timeString+=`${minutes.toString().padStart(2,\"0\")}:${seconds.toString().padStart(2,\"0\")}`;if(showMilliseconds){timeString+=`.${ms.toString().padStart(2,\"0\")}`;}return timeString;};const isFixedWidth=style?.width===\"100%\";return /*#__PURE__*/_jsx(\"div\",{style:{...style,position:\"relative\",display:\"flex\",flexDirection:\"column\",alignItems:\"center\",justifyContent:\"center\",gap:20,padding,backgroundColor,borderRadius:8,...isFixedWidth?{}:{minWidth:\"max-content\"}},children:/*#__PURE__*/_jsx(\"div\",{style:{...font,color:textColor,fontVariantNumeric:\"tabular-nums\"},children:formatTime(time)})});}addPropertyControls(TimeCounter,{startFrom:{type:ControlType.Number,title:\"Start From\",defaultValue:0,min:0,step:1,unit:\"s\",displayStepper:true},countUp:{type:ControlType.Boolean,title:\"Direction\",defaultValue:true,enabledTitle:\"Count Up\",disabledTitle:\"Count Down\"},startTime:{type:ControlType.Number,title:\"Start Time\",defaultValue:0,min:0,step:1e3,unit:\"ms\",displayStepper:true},autoStart:{type:ControlType.Boolean,title:\"Auto Start\",defaultValue:true,enabledTitle:\"Yes\",disabledTitle:\"No\"},showHours:{type:ControlType.Boolean,title:\"Show Hours\",defaultValue:true,enabledTitle:\"Show\",disabledTitle:\"Hide\"},showMilliseconds:{type:ControlType.Boolean,title:\"Milliseconds\",defaultValue:false,enabledTitle:\"Show\",disabledTitle:\"Hide\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\"},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"#FFFFFF\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"48px\",variant:\"Semibold\",letterSpacing:\"-0.02em\",lineHeight:\"1em\"}},padding:{type:ControlType.Padding,title:\"Padding\",defaultValue:\"20px\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TimeCounter\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerIntrinsicWidth\":\"300\",\"framerIntrinsicHeight\":\"100\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TimeCounter.map"],"mappings":"4LASG,SAAwB,EAAY,EAAM,CAAC,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