/**
 * Geo location registry.
 *
 * Each entry is a place we want to surface people/threads for via the holistic
 * unified search. `aliases` are the literal search terms the Geo tab fans out
 * over — city names, area codes, airport codes, state, nicknames. They double
 * as the quick-filter chips, so order them most-useful-first; `aliases[0]` is
 * used as the default query when the location is selected.
 *
 * Adding a city is a pure data change — append an entry here, nothing else.
 */
export interface GeoLocation {
  /** Stable id, used for selection state and as a React key. */
  id: string;
  /** Human-readable label shown in the location selector. */
  label: string;
  /** Search terms / quick-filter chips. `aliases[0]` is the default query. */
  aliases: string[];
}

export const GEO_LOCATIONS: readonly GeoLocation[] = [
  {
    id: 'austin',
    label: 'Austin',
    aliases: ['austin', '512', 'ATX', 'austin tx', 'texas', 'AUS'],
  },
  {
    id: 'houston',
    label: 'Houston',
    aliases: ['houston', '713', '281', '832', 'HTX', 'houston tx', 'texas', 'IAH', 'HOU'],
  },
];

/** Look up a location by id, falling back to the first registered location. */
export function resolveLocation(id: string | undefined): GeoLocation {
  return GEO_LOCATIONS.find((l) => l.id === id) ?? GEO_LOCATIONS[0];
}
