"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DepartureGroupRefiner = void 0;
class DepartureGroupRefiner {
    static filterDeparturesByRouteShortNames(departureGroup, routeShortNames) {
        if (!routeShortNames) {
            return departureGroup;
        }
        return departureGroup.filter((departure) => routeShortNames.includes(departure.route.short_name));
    }
    static sortDeparturesByPredictedTimestamp(departureGroup) {
        return departureGroup.sort((a, b) => new Date(a.departure.timestamp_predicted).getTime() - new Date(b.departure.timestamp_predicted).getTime());
    }
    static removeDeparturesOutsideTimeRange(departureGroup, minutesBefore, minutesAfter) {
        const now = new Date();
        const timeRangeStart = new Date(now.getTime() - minutesBefore * 60 * 1000);
        const timeRangeEnd = new Date(now.getTime() + minutesAfter * 60 * 1000);
        departureGroup = departureGroup.filter((departure) => new Date(departure.departure.timestamp_predicted) >= timeRangeStart &&
            new Date(departure.departure.timestamp_predicted) <= timeRangeEnd);
        return departureGroup;
    }
}
exports.DepartureGroupRefiner = DepartureGroupRefiner;
//# sourceMappingURL=DepartureGroupRefiner.js.map