export type MenuVariant =
  | 'default'
  | 'awq'
  | 'meta'
  | 'kitchensink'
  | 'worldburner'
  | 'chainbreaker';

export type GridPosition =
  | 'area_1'
  | 'area_2'
  | 'area_3'
  | 'area_4'
  | 'area_5'
  | '';

export interface SubNavigationItem {
  readonly name: string;
  readonly path: string;
}

export interface Subtitle {
  readonly content: string;
  readonly divider:
    | { readonly discriminant: true; readonly value: string }
    | { readonly discriminant: false };
}

export interface NavigationItem {
  readonly name: string;
  readonly path: string;
  readonly gridPosition: GridPosition;
  readonly variant: MenuVariant;
  readonly background: string | null;
  readonly sublinks:
    | { readonly discriminant: false }
    | {
        readonly discriminant: true;
        readonly value: readonly SubNavigationItem[];
      };
  readonly subtitle:
    | { readonly discriminant: false }
    | { readonly discriminant: true; readonly value: Subtitle };
}

export interface Navigation {
  readonly items: readonly NavigationItem[];
}

// Type guards for conditional fields
export function hasSublinks(item: NavigationItem): item is NavigationItem & {
  readonly sublinks: {
    readonly discriminant: true;
    readonly value: readonly SubNavigationItem[];
  };
} {
  return item.sublinks.discriminant === true;
}

export function hasSubtitle(item: NavigationItem): item is NavigationItem & {
  readonly subtitle: { readonly discriminant: true; readonly value: Subtitle };
} {
  return item.subtitle.discriminant === true;
}

export function hasDivider(subtitle: Subtitle): subtitle is Subtitle & {
  readonly divider: { readonly discriminant: true; readonly value: string };
} {
  return subtitle.divider.discriminant === true;
}
