import type { TouristPersona, TouristPersonaType } from '@/types/lead';

// Persona Configurations
export const PERSONA_CONFIGS: Record<TouristPersonaType, Omit<TouristPersona, 'key_signals'>> = {
  romantic_couple: {
    type: 'romantic_couple',
    label: 'Romantik Çift',
    sales_label: 'High-Spend Romantic Lead',
    emoji: '💑',
    description: 'Gün doğumu balonu ve şarap tadımı gibi premium romantik deneyimler arayan çift.',
    spend_potential: 'very_high',
    recommended_services: ['private_balloon', 'sunset_dinner', 'wine_tasting', 'couple_spa']
  },
  luxury_traveler: {
    type: 'luxury_traveler',
    label: 'Lüks Gezgin',
    sales_label: 'Premium Luxury Traveler',
    emoji: '✨',
    description: 'Özel rehber, VIP transfer ve premium hizmet bekleyen yüksek bütçeli misafir.',
    spend_potential: 'very_high',
    recommended_services: ['private_guide', 'vip_transfer', 'private_balloon', 'fine_dining']
  },
  budget_backpacker: {
    type: 'budget_backpacker',
    label: 'Bütçe Gezgini',
    sales_label: 'Budget Group Traveler',
    emoji: '🎒',
    description: 'Grup turu ve uygun fiyatlı seçenekler arayan, deneyim odaklı gezgin.',
    spend_potential: 'low',
    recommended_services: ['group_tour', 'shared_transfer', 'budget_activities']
  },
  content_creator: {
    type: 'content_creator',
    label: 'İçerik Üreticisi',
    sales_label: 'Content Creator — Viral Potential',
    emoji: '📸',
    description: 'Drone, fotoğraf çekimi ve sosyal medya içeriği için premium lokasyon arayan gezgin.',
    spend_potential: 'high',
    recommended_services: ['drone_permit', 'photo_shoot_package', 'sunrise_balloon', 'panorama_tours']
  },
  family_explorer: {
    type: 'family_explorer',
    label: 'Aile Gezgini',
    sales_label: 'Family Package Lead',
    emoji: '👨‍👩‍👧‍👦',
    description: 'Çocuk dostu aktiviteler ve güvenli deneyimler arayan aile.',
    spend_potential: 'medium',
    recommended_services: ['family_tour', 'atv_family', 'museum_tour', 'safe_activities']
  },
  solo_adventurer: {
    type: 'solo_adventurer',
    label: 'Solo Maceracı',
    sales_label: 'Solo Adventure Seeker',
    emoji: '🧗',
    description: 'Yerel rehber ve güvenli macera deneyimleri arayan yalnız gezgin.',
    spend_potential: 'medium',
    recommended_services: ['local_guide', 'adventure_activities', 'horse_riding', 'hiking_tours']
  },
  group_tour: {
    type: 'group_tour',
    label: 'Grup Turu',
    sales_label: 'Large Group Booking Lead',
    emoji: '👥',
    description: 'Büyük grup için toplu rezervasyon ve organizasyon ihtiyacı olan müşteri.',
    spend_potential: 'high', // toplam spend yüksek
    recommended_services: ['group_tour', 'group_balloon', 'bus_transfer', 'group_dinner']
  }
};

// Signal weights and detection rules
const SIGNALS = {
  // Romantic Couple sinyalleri
  has_balloon: { type: 'romantic_couple', weight: 0.4 },
  has_wine_tasting: { type: 'romantic_couple', weight: 0.35 },
  has_sunset_viewpoint: { type: 'romantic_couple', weight: 0.25 },
  is_couple: { type: 'romantic_couple', weight: 0.3 },
  has_dawn_activities: { type: 'romantic_couple', weight: 0.2 },
  interest_romantic: { type: 'romantic_couple', weight: 0.3 },

  // Luxury Traveler sinyalleri
  has_private_balloon: { type: 'luxury_traveler', weight: 0.5 },
  interest_luxury: { type: 'luxury_traveler', weight: 0.4 },
  interest_gastronomy: { type: 'luxury_traveler', weight: 0.25 },
  has_private_tour: { type: 'luxury_traveler', weight: 0.35 },
  short_trip_many_activities: { type: 'luxury_traveler', weight: 0.2 },

  // Budget Backpacker sinyalleri
  interest_budget: { type: 'budget_backpacker', weight: 0.4 },
  has_group_tour: { type: 'budget_backpacker', weight: 0.3 },
  large_group: { type: 'budget_backpacker', weight: 0.25 },
  interest_hiking: { type: 'budget_backpacker', weight: 0.2 },
  long_trip_few_paid: { type: 'budget_backpacker', weight: 0.2 },

  // Content Creator sinyalleri
  interest_photography: { type: 'content_creator', weight: 0.45 },
  interest_drone: { type: 'content_creator', weight: 0.5 },
  has_sunrise_balloon: { type: 'content_creator', weight: 0.35 },
  interest_instagram: { type: 'content_creator', weight: 0.4 },
  many_viewpoints: { type: 'content_creator', weight: 0.3 },

  // Group Tour sinyalleri
  very_large_group: { type: 'group_tour', weight: 0.5 },
  has_group_activities: { type: 'group_tour', weight: 0.35 },
} as const;

// Get persona by type
export function getPersonaConfig(type: TouristPersonaType): Omit<TouristPersona, 'key_signals'> {
  return PERSONA_CONFIGS[type];
}

// Get all persona types
export function getAllPersonaTypes(): TouristPersonaType[] {
  return Object.keys(PERSONA_CONFIGS) as TouristPersonaType[];
}

// Get persona emoji
export function getPersonaEmoji(type: TouristPersonaType): string {
  return PERSONA_CONFIGS[type].emoji;
}

// Get persona label
export function getPersonaLabel(type: TouristPersonaType, language: 'tr' | 'en' = 'tr'): string {
  return language === 'tr' ? PERSONA_CONFIGS[type].label : PERSONA_CONFIGS[type].sales_label;
}

// Get spend potential color
export function getSpendPotentialColor(potential: 'low' | 'medium' | 'high' | 'very_high'): string {
  const colors = {
    low: 'text-gray-500',
    medium: 'text-blue-500',
    high: 'text-green-500',
    very_high: 'text-purple-500'
  };
  return colors[potential];
}

// Get spend potential label
export function getSpendPotentialLabel(potential: 'low' | 'medium' | 'high' | 'very_high', language: 'tr' | 'en' = 'tr'): string {
  const labels = {
    tr: {
      low: 'Düşük',
      medium: 'Orta',
      high: 'Yüksek',
      very_high: 'Çok Yüksek'
    },
    en: {
      low: 'Low',
      medium: 'Medium',
      high: 'High',
      very_high: 'Very High'
    }
  };
  return labels[language][potential];
}
