import _TimePicker from "@alifd/next/es/time-picker2";
import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
var _excluded = ["style", "defaultValue", "hasClear", "label", "popupTriggerType", "format", "hourStep", "minuteStep", "secondStep", "type", "size", "placeholder", "ranges", "disabled"];
import * as React from 'react';
import { useState } from 'react';
import dayjs from 'dayjs';
var TimePickerName = function TimePickerName(_ref) {
  var _ref$style = _ref.style,
    style = _ref$style === void 0 ? {} : _ref$style,
    defaultValue = _ref.defaultValue,
    hasClear = _ref.hasClear,
    label = _ref.label,
    popupTriggerType = _ref.popupTriggerType,
    format = _ref.format,
    hourStep = _ref.hourStep,
    minuteStep = _ref.minuteStep,
    secondStep = _ref.secondStep,
    type = _ref.type,
    size = _ref.size,
    placeholder = _ref.placeholder,
    ranges = _ref.ranges,
    disabled = _ref.disabled,
    otherProps = _objectWithoutPropertiesLoose(_ref, _excluded);
  var nowTime = dayjs(new Date());
  var currentHour = dayjs().hour(nowTime.hour()).minute(0).second(0);
  var nextHour = currentHour.hour(currentHour.hour() + 1);
  var preset = [{
    label: '此刻',
    value: function value() {
      return nowTime;
    }
  }];
  var presetRange = [{
    label: '此刻',
    value: [currentHour, nextHour]
  }];
  var _useState = useState(dayjs('12:00:00', 'HH:mm:ss', true)),
    value = _useState[0],
    onChange = _useState[1];
  var _style = style || {};
  var _otherProps = otherProps || {};
  _otherProps.style = _style;
  if (type == '基础用法') {
    return /*#__PURE__*/React.createElement(_TimePicker, _extends({
      prefix: "next-",
      defaultValue: defaultValue,
      size: size,
      hasClear: hasClear,
      minuteStep: minuteStep,
      secondStep: secondStep,
      value: value,
      format: format,
      hourStep: hourStep,
      placeholder: placeholder,
      disabled: disabled,
      popupAlign: "tl tl",
      popupTriggerType: popupTriggerType,
      preset: preset,
      onChange: onChange
    }, otherProps));
  }
  if (type == '时间区间') {
    return /*#__PURE__*/React.createElement(_TimePicker.RangePicker, _extends({
      className: style.TimePickerName,
      prefix: "next-",
      defaultValue: defaultValue,
      size: size,
      hasClear: hasClear,
      minuteStep: minuteStep,
      secondStep: secondStep,
      value: value,
      format: format,
      hourStep: hourStep,
      placeholder: placeholder,
      disabled: disabled,
      popupAlign: "tl tl",
      popupTriggerType: popupTriggerType,
      onChange: console.log,
      preset: presetRange
    }, otherProps));
  }
};
TimePickerName.displayName = 'TimePickerName';
export default TimePickerName;