import { WagonReadiness, type ScheduleTradeDirection } from '@edr/types';

/** @deprecated Replaced by yard-based fleet filtering via `currentYardId`. */
export function requiredWagonReadiness(
  direction: ScheduleTradeDirection | string | null | undefined,
): WagonReadiness | null {
  if (direction === 'IMPORT') return WagonReadiness.ImportReady;
  if (direction === 'EXPORT') return WagonReadiness.ExportReady;
  return null;
}

/** @deprecated Replaced by `wagon.currentYardId === originYardId` checks. */
export function wagonReadinessMatchesSchedule(
  wagonReadiness: WagonReadiness | string,
  direction: ScheduleTradeDirection | string | null | undefined,
): boolean {
  const required = requiredWagonReadiness(direction);
  if (!required) return true;
  return wagonReadiness === required;
}

/**
 * @deprecated Replaced by setting `currentYardId = schedule.destinationStationId` on arrival.
 */
export function flipReadiness(
  readiness: WagonReadiness | string,
): WagonReadiness {
  return readiness === WagonReadiness.ImportReady
    ? WagonReadiness.ExportReady
    : WagonReadiness.ImportReady;
}
