export type TourStepKey = 'event' | 'qr' | 'photos' | 'push';

export const TOUR_STORAGE_KEY = 'admin-mobile-tour-v1';

export function resolveTourStepKeys(hasEvents: boolean): TourStepKey[] {
  if (hasEvents) {
    return ['qr', 'photos', 'push'];
  }

  return ['event', 'qr', 'photos', 'push'];
}

export function getTourSeen(): boolean {
  if (typeof window === 'undefined') {
    return false;
  }

  try {
    return window.localStorage.getItem(TOUR_STORAGE_KEY) === 'seen';
  } catch {
    return false;
  }
}

export function setTourSeen(seen: boolean): void {
  if (typeof window === 'undefined') {
    return;
  }

  try {
    if (seen) {
      window.localStorage.setItem(TOUR_STORAGE_KEY, 'seen');
    } else {
      window.localStorage.removeItem(TOUR_STORAGE_KEY);
    }
  } catch {
    // Ignore storage errors.
  }
}
