/**
 * Service Type Enum - Shared between backend and frontend
 * 
 * This enum defines all possible service types for tours and recommendations.
 * It ensures consistency across the application and eliminates UI-side string matching.
 */

// Service type enum values
export const ServiceType = {
  // Daily tour packages
  DAILY_TOUR: 'daily_tour',
  
  // Private services
  PRIVATE_GUIDE: 'private_guide',
  DRIVER_CAR: 'driver_car',
  
  // Activity bundles
  ACTIVITY_BUNDLE: 'activity_bundle',
  
  // Specific activities (legacy support)
  HOT_AIR_BALLOON: 'hot_air_balloon',
  ATV: 'atv',
  HORSE_RIDING: 'horse_riding',
  
  // Tour categories
  GUIDED_TOUR: 'guided_tour',
  MUSEUM_TOUR: 'museum_tour',
  ADVENTURE: 'adventure',
  CULTURAL: 'cultural',
  NATURE: 'nature',
} as const;

// TypeScript type derived from the enum
export type ServiceTypeValue = typeof ServiceType[keyof typeof ServiceType];

// Service type metadata for display purposes
export interface ServiceTypeMetadata {
  value: ServiceTypeValue;
  label: string;
  description?: string;
  icon?: string;
  category: 'tour' | 'private' | 'activity' | 'specialized';
}

// Complete metadata mapping for all service types
export const SERVICE_TYPE_METADATA: Record<ServiceTypeValue, ServiceTypeMetadata> = {
  [ServiceType.DAILY_TOUR]: {
    value: ServiceType.DAILY_TOUR,
    label: 'Günlük Tur',
    description: 'Organized daily tours with fixed itineraries',
    icon: '🗓️',
    category: 'tour',
  },
  [ServiceType.PRIVATE_GUIDE]: {
    value: ServiceType.PRIVATE_GUIDE,
    label: 'Özel Rehber',
    description: 'Private guide service for personalized experience',
    icon: '👤',
    category: 'private',
  },
  [ServiceType.DRIVER_CAR]: {
    value: ServiceType.DRIVER_CAR,
    label: 'Şoförlü Araç',
    description: 'Private car with driver for comfortable transportation',
    icon: '🚗',
    category: 'private',
  },
  [ServiceType.ACTIVITY_BUNDLE]: {
    value: ServiceType.ACTIVITY_BUNDLE,
    label: 'Aktivite Paketi',
    description: 'Bundle of multiple activities at discounted price',
    icon: '🎯',
    category: 'activity',
  },
  [ServiceType.HOT_AIR_BALLOON]: {
    value: ServiceType.HOT_AIR_BALLOON,
    label: 'Sıcak Hava Balonu',
    description: 'Hot air balloon flight experience',
    icon: '🎈',
    category: 'specialized',
  },
  [ServiceType.ATV]: {
    value: ServiceType.ATV,
    label: 'ATV Safari',
    description: 'ATV adventure tour',
    icon: '🏍️',
    category: 'activity',
  },
  [ServiceType.HORSE_RIDING]: {
    value: ServiceType.HORSE_RIDING,
    label: 'At Safari',
    description: 'Horse riding tour',
    icon: '🐴',
    category: 'activity',
  },
  [ServiceType.GUIDED_TOUR]: {
    value: ServiceType.GUIDED_TOUR,
    label: 'Rehberli Tur',
    description: 'Guided tour with professional guide',
    icon: '🎫',
    category: 'tour',
  },
  [ServiceType.MUSEUM_TOUR]: {
    value: ServiceType.MUSEUM_TOUR,
    label: 'Müze Turu',
    description: 'Museum and historical site tour',
    icon: '🏛️',
    category: 'tour',
  },
  [ServiceType.ADVENTURE]: {
    value: ServiceType.ADVENTURE,
    label: 'Macera Turu',
    description: 'Adventure and outdoor activities',
    icon: '⛰️',
    category: 'activity',
  },
  [ServiceType.CULTURAL]: {
    value: ServiceType.CULTURAL,
    label: 'Kültür Turu',
    description: 'Cultural and heritage tour',
    icon: '🏺',
    category: 'tour',
  },
  [ServiceType.NATURE]: {
    value: ServiceType.NATURE,
    label: 'Doğa Turu',
    description: 'Nature and landscape tour',
    icon: '🌿',
    category: 'tour',
  },
};

// Helper function to get metadata for a service type
export function getServiceTypeMetadata(type: ServiceTypeValue): ServiceTypeMetadata {
  return SERVICE_TYPE_METADATA[type];
}

// Helper function to get label for a service type
export function getServiceTypeLabel(type: ServiceTypeValue): string {
  return SERVICE_TYPE_METADATA[type]?.label || type;
}

// Helper function to get all service types by category
export function getServiceTypesByCategory(category: ServiceTypeMetadata['category']): ServiceTypeMetadata[] {
  return Object.values(SERVICE_TYPE_METADATA).filter(meta => meta.category === category);
}

// Validation helper
export function isValidServiceType(type: string): type is ServiceTypeValue {
  return Object.values(ServiceType).includes(type as ServiceTypeValue);
}
