import { type TimeBlock } from '@/lib/time-blocks';
import { type BasePlace } from '@/types/route';

export interface PlacePosition {
  lat: number;
  lng: number;
}

export interface TripPlace extends BasePlace {
  tripPlaceId: string;
  type: string;
  duration: string;
  img?: string;
  position: PlacePosition;
  timeOfDay?: string;
  notes?: string;
  order_index: number;
}

export interface TripDay {
  id: string;
  dayNumber: number;
  date: string;
  dayName: string;
  places: TripPlace[];
  suggested_tour_slug?: string;
}

export interface Trip {
  id: string;
  title: string;
  destination: string;
  startDate: string;
  endDate: string;
  travelers: number;
  coverImage: string;
  days: TripDay[];
  has_balloon?: boolean;
  balloon_day_id?: string;
  start_lat?: number;
  start_lng?: number;
  start_location_name?: string;
  start_location_type?: 'balloon' | 'hotel' | 'custom' | 'place' | 'city_center';
  interests?: string[];
  number_of_travelers?: number;
  start_date?: string; // Alias for startDate (for compatibility)
  end_date?: string; // Alias for endDate (for compatibility)
  created_at: string;
  updated_at: string;
}

// Map marker interface
export interface MapMarker {
  id: string;
  lat: number;
  lng: number;
  dayId: string;
  dayIndex: number;
  orderIndex: number;
  title: string;
  isStartPoint?: boolean;
}

// Timeline block interface
export interface TimelineBlock {
  timeBlock: TimeBlock;
  places: TripPlace[];
}

// Raw database types (for API responses)
export interface TripDataRaw {
  id: string;
  user_id?: string;
  title: string;
  description?: string;
  destination?: string;
  start_date?: string;
  end_date?: string;
  cover_image?: string;
  is_public?: boolean;
  interests?: string[];
  public_slug?: string;
  start_location_type?: 'balloon' | 'hotel' | 'custom' | 'place' | 'city_center';
  start_location_name?: string;
  start_lat?: number;
  start_lng?: number;
  has_balloon?: boolean;
  balloon_day_id?: string;
  number_of_travelers?: number;
  anonymous_token?: string; // Anonim geziler için token
  created_at: string;
  updated_at: string;
  trip_days?: TripDayRaw[];
}

export interface TripDayRaw {
  id: string;
  trip_id: string;
  day_number: number;
  date?: string;
  title?: string;
  notes?: string;
  suggested_tour_slug?: string;
  created_at: string;
  updated_at: string;
  trip_places?: TripPlaceRaw[];
}

export interface TripPlaceRaw {
  id: string;
  trip_day_id: string;
  place_id: string;
  order_index: number;
  duration?: string;
  notes?: string;
  time_of_day?: string;
  time_block?: 'morning' | 'afternoon' | 'evening';
  created_at: string;
  updated_at: string;
  place?: {
    id: string;
    name: string;
    type?: string;
    duration?: string;
    image_url?: string;
    latitude?: number;
    longitude?: number;
    rating?: number;
    description?: string;
  };
  places?: {
    id: string;
    name: string;
    type?: string;
    duration?: string;
    image_url?: string;
    latitude?: number;
    longitude?: number;
    rating?: number;
    description?: string;
  };
}
