var _excluded = ["locale", "slice", "timeObjChange", "selectProps"];
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
import { Select } from "antd";
import React, { useCallback, useEffect, useMemo } from "react";
import { sliceDayIntoFiveMinutes } from "../../utils";
var StartTime = function StartTime(props) {
  var _props$locale = props.locale,
    locale = _props$locale === void 0 ? "en" : _props$locale,
    _props$slice = props.slice,
    slice = _props$slice === void 0 ? 5 : _props$slice,
    timeObjChange = props.timeObjChange,
    selectProps = props.selectProps,
    resetProps = _objectWithoutProperties(props, _excluded);

  /**
   * @title: 时间切片
   * @description:
   * @return {*}
   * @Author: zhiwei.Wang
   * @Date: 2024-01-09 13:37
   */
  var timeObj = useMemo(function () {
    return sliceDayIntoFiveMinutes(slice, locale);
  }, [slice, locale]);
  useEffect(function () {
    timeObjChange === null || timeObjChange === void 0 || timeObjChange(timeObj);
  }, [timeObj]);
  var renderOptions = useCallback(function (array) {
    var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "value";
    var label = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "label";
    return array.map(function (d) {
      return /*#__PURE__*/React.createElement(Select.Option, {
        value: d[value],
        key: d[value]
      }, d[label]);
    });
  }, []);
  return /*#__PURE__*/React.createElement(Select, _extends({}, selectProps, resetProps), renderOptions(timeObj === null || timeObj === void 0 ? void 0 : timeObj.timeSlices));
};
export default StartTime;