import dayjs from "dayjs";
export var sliceDayIntoFiveMinutes = function sliceDayIntoFiveMinutes(slice) {
  var startTime = dayjs().startOf("day");
  var endTime = dayjs().endOf("day");
  var timeSlice = slice || 5; // 切片时间间隔（分钟）

  var timeSlices = [];
  var currentTime = startTime;
  while (currentTime.isBefore(endTime)) {
    var timeLabel = currentTime.format("HH:mm");
    var timeValue = currentTime.format("HH:mm");
    timeSlices.push({
      label: timeLabel,
      value: timeValue
    });
    var nextTime = currentTime.add(timeSlice, "minute");
    currentTime = nextTime;
  }
  return timeSlices;
};
export var findNextSlice = function findNextSlice(_ref) {
  var _ref$timeSlices = _ref.timeSlices,
    timeSlices = _ref$timeSlices === void 0 ? [] : _ref$timeSlices,
    _ref$index = _ref.index,
    index = _ref$index === void 0 ? 0 : _ref$index,
    _ref$date = _ref.date,
    date = _ref$date === void 0 ? '' : _ref$date;
  var currentTimeValue = date || dayjs().format('HH:mm');

  // 遍历时间切片数组，找到最接近的下一个切片时间
  for (var i = 0; i < timeSlices.length; i++) {
    // 排除掉当前时间
    if (timeSlices[i].value !== 'now') {
      if (timeSlices[i].value >= currentTimeValue) {
        return timeSlices[i].value;
      }
    }
  }

  // 如果没有找到比当前时间大的切片时间，则返回第一个切片时间作为下一个切片时间
  return timeSlices[index].value;
};