{
  "version": 3,
  "sources": ["ssg:https://framerusercontent.com/modules/oOWgPPFYYBrU0LY0533F/sQ611WMb0sIjidFNLK5N/Timer.js"],
  "sourcesContent": ["/**\n * @framerDisableUnlink\n * @framerIntrinsicWidth 200\n * @framerIntrinsicHeight 50\n */import{jsx as _jsx}from\"react/jsx-runtime\";import{useState,useEffect}from\"react\";import{addPropertyControls,ControlType}from\"framer\";// --------------------------------------------------------------------\n// Shared Timer Singleton Logic\n// --------------------------------------------------------------------\n// We'll store a global list of \"subscribers\" that each get updated\n// whenever the countdown changes. This way, multiple instances of\n// the component can share the same timer and remain in sync.\nlet timerSubscribers=[];let timerInterval=null;/**\n * Calculate the number of seconds from now until midnight (00:00).\n */function getSecondsUntilMidnight(){const now=new Date;const midnight=new Date;midnight.setHours(24,0,0,0)// 24:00 of the current day\n;const diff=midnight.getTime()-now.getTime();return Math.max(0,Math.floor(diff/1e3));}/**\n * Start a shared interval that updates all subscribers once per second.\n * If the interval is already running, we do nothing.\n */function startSharedTimer(){if(!timerInterval){timerInterval=setInterval(()=>{const secondsLeft=getSecondsUntilMidnight();// Update each subscriber (each component instance)\ntimerSubscribers.forEach(callback=>callback(secondsLeft));},1e3);}}/**\n * Subscribe a callback to the shared timer.\n * Returns an unsubscribe function.\n */function subscribeToTimer(callback){timerSubscribers.push(callback);// Immediately invoke with current seconds left\ncallback(getSecondsUntilMidnight());// Start the shared timer if not already started\nstartSharedTimer();// Unsubscribe logic\nreturn()=>{timerSubscribers=timerSubscribers.filter(cb=>cb!==callback);// If no one is left subscribed, clear the interval\nif(timerSubscribers.length===0&&timerInterval){clearInterval(timerInterval);timerInterval=null;}};}/**\n * Helper to format seconds as HH:MM:SS.\n */function formatTime(seconds){const hours=Math.floor(seconds/3600);const minutes=Math.floor(seconds%3600/60);const secs=seconds%60;return[String(hours).padStart(2,\"0\"),String(minutes).padStart(2,\"0\"),String(secs).padStart(2,\"0\")].join(\":\");}/**\n * TimerComponent:\n * - Displays the time remaining until midnight.\n * - Multiple instances on the same page stay in sync automatically.\n */export default function TimerComponent(props){const{fontSize,fontColor,fontFamily,style}=props;// Local state that stores the current countdown value\nconst[secondsLeft,setSecondsLeft]=useState(getSecondsUntilMidnight());// Subscribe to the shared timer when the component mounts\nuseEffect(()=>{const unsubscribe=subscribeToTimer(setSecondsLeft);return unsubscribe;},[]);return /*#__PURE__*/_jsx(\"div\",{style:{fontSize,color:fontColor,fontFamily,...style},children:formatTime(secondsLeft)});}// --------------------------------------------------------------------\n// Default Props & Property Controls\n// --------------------------------------------------------------------\nTimerComponent.defaultProps={fontSize:24,fontColor:\"#000000\",fontFamily:\"Arial\",style:{}};addPropertyControls(TimerComponent,{fontSize:{type:ControlType.Number,title:\"Font Size\",defaultValue:24,min:10,max:100,unit:\"px\",displayStepper:true},fontColor:{type:ControlType.Color,title:\"Font Color\",defaultValue:\"#000000\"},fontFamily:{type:ControlType.String,title:\"Font Family\",defaultValue:\"Arial\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TimerComponent\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Timer.map"],
  "mappings": "uGAUA,IAAIA,EAAiB,CAAC,EAAMC,EAAc,KAEvC,SAASC,GAAyB,CAAC,IAAMC,EAAI,IAAI,KAAWC,EAAS,IAAI,KAAKA,EAAS,SAAS,GAAG,EAAE,EAAE,CAAC,EAC1G,IAAMC,EAAKD,EAAS,QAAQ,EAAED,EAAI,QAAQ,EAAE,OAAO,KAAK,IAAI,EAAE,KAAK,MAAME,EAAK,GAAG,CAAC,CAAE,CAGlF,SAASC,GAAkB,CAAKL,IAAeA,EAAc,YAAY,IAAI,CAAC,IAAMM,EAAYL,EAAwB,EAC3HF,EAAiB,QAAQQ,GAAUA,EAASD,CAAW,CAAC,CAAE,EAAE,GAAG,EAAG,CAG/D,SAASE,EAAiBD,EAAS,CAAC,OAAAR,E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", "timerInterval", "getSecondsUntilMidnight", "now", "midnight", "diff", "startSharedTimer", "secondsLeft", "callback", "subscribeToTimer", "cb", "formatTime", "seconds", "hours", "minutes", "secs", "TimerComponent", "props", "fontSize", "fontColor", "fontFamily", "style", "setSecondsLeft", "ye", "ue", "p", "addPropertyControls", "ControlType"]
}
