/**
 * Blink store — global blink state for status dots.
 *
 * StatusDot reads this directly. No component receives blink as a prop,
 * preventing cascading re-renders of entire ProjectCard trees every 500ms.
 */

let _visible = $state(true);
let _intervalId: ReturnType<typeof setInterval> | undefined;

export function getBlinkVisible(): boolean {
  return _visible;
}

export function startBlink(): void {
  if (_intervalId) return;
  _intervalId = setInterval(() => {
    _visible = !_visible;
  }, 500);
}

export function stopBlink(): void {
  if (_intervalId) {
    clearInterval(_intervalId);
    _intervalId = undefined;
  }
  _visible = true;
}
