export const TRAVEL_THEMES = ['亲子', '情侣', '朋友', '银发', '研学'] as const
export const TRAVEL_INTERESTS = ['自然风光', '文化场馆', '生态科普', '美食', '摄影'] as const
export const TRAVEL_DURATIONS = ['half_day', 'full_day'] as const
export const TRAVEL_PACES = ['relaxed', 'moderate', 'compact'] as const
export const TRAVEL_TRANSPORTS = ['walking', 'driving', 'public_transport'] as const
export const TRAVEL_BUDGET_LEVELS = ['economy', 'standard', 'quality'] as const

export type Theme = typeof TRAVEL_THEMES[number]
export type Interest = typeof TRAVEL_INTERESTS[number]
export type Duration = typeof TRAVEL_DURATIONS[number]
export type Pace = typeof TRAVEL_PACES[number]
export type Transport = typeof TRAVEL_TRANSPORTS[number]
export type BudgetLevel = typeof TRAVEL_BUDGET_LEVELS[number]
export type TravelAssistantSource = 'local_poc' | 'remote_mock' | 'remote_ai'
export type PlanningMode = 'quick' | 'custom'
export type DurationFitStatus = 'fits' | 'underfilled' | 'overflow'

export interface PlanningOrigin {
  longitude: number
  latitude: number
  coordinateSystem: 'GCJ02'
}

export interface TravelPreferences {
  destination: '深圳市光明区'
  themes: Theme[]
  duration: Duration
  pace: Pace
  interests: Interest[]
  adults: number
  children: number
  childAges: number[]
  transport: Transport
  budgetLevel: BudgetLevel
  extraRequirements: string
}

export interface PlanningRequest {
  mode: PlanningMode
  preferences: TravelPreferences
  durationMinutes: number
  selectedPoiIds: string[]
  origin?: PlanningOrigin
}

export interface PlanningRecommendation {
  poiId: string
  reason: string
}

export interface ItineraryItem {
  startTime: string
  endTime: string
  /** Always a canonical ID resolvable by the current PoiRepository. */
  placeId: string
  placeName: string
  activity: string
  reason: string
  transferFromPreviousMinutes: number | null
  tips: string[]
}

export interface ItinerarySource {
  /** Always a canonical ID resolvable by the current PoiRepository. */
  placeId: string
  sourceName: string
  sourceUrl: string
  updatedAt: string
}

export interface Itinerary {
  title: string
  summary: string
  totalMinutes: number
  planningMode: PlanningMode
  requestedMinutes: number
  durationFitStatus: DurationFitStatus
  startsFromCurrentLocation: boolean
  estimatedCostText: string
  items: ItineraryItem[]
  notes: string[]
  sources: ItinerarySource[]
}

export interface PlanResponse {
  conversationId: string
  assistantMessage: string
  itinerary: Itinerary
  changeSummary?: string | null
  source: TravelAssistantSource
}

export interface LocalPlanAdjustment {
  preferences: TravelPreferences
  plan: PlanResponse
  request: PlanningRequest
}
