'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

function findCurrentStage(list, now) {
  if (!(list === null || list === void 0 ? void 0 : list.length)) {
    return {};
  }
  if (now < list[0].start_time) {
    return list[0];
  }
  if (now > list[list.length - 1].end_time) {
    return list[list.length - 1];
  }
  for (var i = 0; i < list.length; i++) {
    var stage = list[i];
    if (now > stage.start_time && now < stage.end_time) {
      return stage;
    }
    if (list[i + 1] && now > stage.end_time && now < list[i + 1].start_time) {
      return list[i + 1];
    }
  }
  return list[list.length - 1];
}

exports.findCurrentStage = findCurrentStage;
