/**
 * Location & Info Type Definitions
 * 
 * Centralized types for location, personal info, accessibility, and unit preferences.
 */

import type { UnitPreferences } from '@/lib/units';

/**
 * Accessibility options stored in user_preferences.accessibility_options
 */
export interface AccessibilityOptions {
  font_size: 'small' | 'medium' | 'large';
  high_contrast: boolean;
  reduced_motion: boolean;
}

/**
 * Profile location and personal information
 */
export interface ProfileLocationInfo {
  personal_location: string | null;
  home_park_id: string | null;
  timezone: string;
  preferred_language: string;
  preferred_pronouns: string | null;
}

/**
 * Combined form data for Location tab
 */
export interface LocationFormData extends ProfileLocationInfo {}

/**
 * Park data for home park selection
 */
export interface ParkOption {
  id: string;
  name: string;
  location?: {
    city?: string;
    state_province?: string;
    country: string;
  };
}

/**
 * Complete location & info settings
 */
export interface LocationInfoSettings {
  profile: ProfileLocationInfo;
  accessibility: AccessibilityOptions;
  unitPreferences: UnitPreferences;
}

/**
 * Location data structure
 */
export interface LocationData {
  country?: string;
  state_province?: string;
  city?: string;
  latitude?: number;
  longitude?: number;
}

/**
 * Type guard for location data
 */
export function isLocationData(data: unknown): data is LocationData {
  if (typeof data !== 'object' || data === null) return false;
  const loc = data as Record<string, unknown>;
  return (
    (loc.country === undefined || typeof loc.country === 'string') &&
    (loc.state_province === undefined || typeof loc.state_province === 'string') &&
    (loc.city === undefined || typeof loc.city === 'string') &&
    (loc.latitude === undefined || typeof loc.latitude === 'number') &&
    (loc.longitude === undefined || typeof loc.longitude === 'number')
  );
}
