const CURRENT_COMPLEX_SLUG_KEY = 'current-complex-slug';
export const COMPLEX_CHANGE_EVENT = 'complex-change';

export function getCurrentComplexSlug(): string | null {
  if (typeof window === 'undefined') return null;
  return window.localStorage.getItem(CURRENT_COMPLEX_SLUG_KEY);
}

export function setCurrentComplexSlug(complexSlug: string) {
  if (typeof window === 'undefined') return;
  window.localStorage.setItem(CURRENT_COMPLEX_SLUG_KEY, complexSlug);
  window.dispatchEvent(new Event(COMPLEX_CHANGE_EVENT));
}
