import _extends from "@babel/runtime/helpers/extends";
import _DatePicker from "@alifd/next/es/date-picker2";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
var _excluded = ["type", "section", "label", "state", "placeholder", "value", "format", "size", "disabled", "hasClear", "showTime", "style"];
/* eslint-disable @typescript-eslint/no-shadow */
import * as React from 'react';
import dayjs from 'dayjs';
import "./index.scss";
var MyDatePicker = function MyDatePicker(_ref) {
  var type = _ref.type,
    section = _ref.section,
    label = _ref.label,
    state = _ref.state,
    placeholder = _ref.placeholder,
    value = _ref.value,
    format = _ref.format,
    size = _ref.size,
    disabled = _ref.disabled,
    hasClear = _ref.hasClear,
    showTime = _ref.showTime,
    _ref$style = _ref.style,
    style = _ref$style === void 0 ? {} : _ref$style,
    otherProps = _objectWithoutPropertiesLoose(_ref, _excluded);
  var _style = style || {};
  var _otherProps = otherProps || {};
  _otherProps.style = _style;
  var MonthPicker = _DatePicker.MonthPicker,
    YearPicker = _DatePicker.YearPicker,
    WeekPicker = _DatePicker.WeekPicker,
    QuarterPicker = _DatePicker.QuarterPicker,
    RangePicker = _DatePicker.RangePicker;
  var RangePreset = {
    今天: [dayjs(), dayjs()],
    本月: [dayjs().startOf("month"), dayjs().endOf("month")]
  };
  var nian = function nian() {
    return section === '关闭' ? /*#__PURE__*/React.createElement(YearPicker, _extends({
      popupClassName: "nianName",
      label: label,
      state: state,
      placeholder: placeholder,
      defaultValue: value,
      value: value,
      format: format,
      size: size,
      disabled: disabled,
      hasClear: hasClear
    }, _otherProps)) : /*#__PURE__*/React.createElement(RangePicker, _extends({
      popupClassName: "nianNameQj",
      placeholder: ["开始年", "结束年"],
      mode: "year",
      label: label,
      state: state,
      value: value,
      format: format,
      size: size,
      disabled: disabled,
      hasClear: hasClear
    }, _otherProps));
  };
  var yue = function yue() {
    return section === '关闭' ? /*#__PURE__*/React.createElement(MonthPicker, _extends({
      popupClassName: "yueName",
      label: label,
      state: state,
      placeholder: placeholder,
      value: value,
      format: format,
      size: size,
      disabled: disabled,
      hasClear: hasClear
    }, _otherProps)) : /*#__PURE__*/React.createElement(RangePicker, _extends({
      popupClassName: "yueNameQj",
      placeholder: ["开始月", "结束月"],
      mode: "month",
      label: label,
      state: state
      // placeholder={placeholder}
      ,
      value: value,
      format: format,
      size: size,
      disabled: disabled,
      hasClear: hasClear
    }, _otherProps));
  };
  var riqi = function riqi() {
    return section === '关闭' ? /*#__PURE__*/React.createElement(_DatePicker, _extends({
      popupClassName: "riqiName",
      label: label,
      state: state,
      placeholder: placeholder,
      value: value,
      format: format,
      size: size,
      disabled: disabled,
      hasClear: hasClear
    }, _otherProps)) : /*#__PURE__*/React.createElement(RangePicker, _extends({
      popupClassName: "riqiNameQj",
      label: label,
      preset: RangePreset,
      state: state
      // placeholder={placeholder}
      ,
      value: value,
      format: format,
      size: size,
      disabled: disabled,
      hasClear: hasClear
    }, _otherProps));
  };
  var shijian = function shijian() {
    return section === '关闭' ? /*#__PURE__*/React.createElement(_DatePicker, _extends({
      popupClassName: "shijianName",
      showTime: true,
      format: "YYYY/MM/DD HH:mm:ss",
      label: label,
      state: state,
      placeholder: placeholder,
      value: value,
      size: size,
      disabled: disabled,
      hasClear: hasClear
    }, _otherProps)) : /*#__PURE__*/React.createElement(RangePicker, _extends({
      popupClassName: "shijianNameQj",
      format: "YYYY/MM/DD HH:mm:ss",
      showTime: true,
      label: label,
      state: state,
      preset: RangePreset
      // placeholder={placeholder}
      ,
      value: value,
      size: size,
      disabled: disabled,
      hasClear: hasClear
    }, _otherProps));
  };
  return function () {
    switch (type) {
      case "年":
        return nian();
        break;
      case "月":
        return yue();
        break;
      case "日":
        return riqi();
        break;
      case "时间":
        return shijian();
        break;
      default:
        return null;
    }
  }();
};
export default MyDatePicker;