import _TimePicker from "antd/es/time-picker";
import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
var _excluded = ["bordered", "value", "format", "style", "none", "suffixIcon"];
import * as React from 'react';
import { useState, useEffect } from 'react';
import moment from 'moment';
import { LocalFormat } from "./localHelper";
import * as icons from '@ant-design/icons/es/index';
import "./index.less";
var antTimePicker = function antTimePicker(_ref) {
  var bordered = _ref.bordered,
    value = _ref.value,
    format = _ref.format,
    style = _ref.style,
    none = _ref.none,
    suffixIcon = _ref.suffixIcon,
    otherProps = _objectWithoutPropertiesLoose(_ref, _excluded);
  var _style = {
    width: style === null || style === void 0 ? void 0 : style.width,
    marginTop: style === null || style === void 0 ? void 0 : style.marginTop,
    marginLeft: style === null || style === void 0 ? void 0 : style.marginLeft,
    marginRight: style === null || style === void 0 ? void 0 : style.marginRight,
    marginBottom: style === null || style === void 0 ? void 0 : style.marginBottom
  };
  var _useState = useState(''),
    ID = _useState[0],
    setID = _useState[1];
  useEffect(function () {
    setID("antTimePicker_" + uuid());
  }, []);
  useEffect(function () {
    var antPicker = document.getElementById(ID);
    if (style) {
      if (style.color) {
        var _antPicker$getElement, _antPicker$getElement2, _antPicker$getElement3;
        antPicker === null || antPicker === void 0 ? void 0 : (_antPicker$getElement = antPicker.getElementsByTagName('input')[0]) === null || _antPicker$getElement === void 0 ? void 0 : _antPicker$getElement.style.setProperty('--placeholder-color', style.color);
        antPicker === null || antPicker === void 0 ? void 0 : (_antPicker$getElement2 = antPicker.getElementsByTagName('input')[0]) === null || _antPicker$getElement2 === void 0 ? void 0 : _antPicker$getElement2.style.setProperty('color', style.color, 'important');
        antPicker === null || antPicker === void 0 ? void 0 : (_antPicker$getElement3 = antPicker.getElementsByClassName('ant-picker-suffix')[0]) === null || _antPicker$getElement3 === void 0 ? void 0 : _antPicker$getElement3.style.setProperty('color', style.color, 'important');
      } else {
        var _antPicker$getElement4, _antPicker$getElement5, _antPicker$getElement6;
        antPicker === null || antPicker === void 0 ? void 0 : (_antPicker$getElement4 = antPicker.getElementsByTagName('input')[0]) === null || _antPicker$getElement4 === void 0 ? void 0 : _antPicker$getElement4.style.removeProperty('--placeholder-color');
        antPicker === null || antPicker === void 0 ? void 0 : (_antPicker$getElement5 = antPicker.getElementsByTagName('input')[0]) === null || _antPicker$getElement5 === void 0 ? void 0 : _antPicker$getElement5.style.removeProperty('color');
        antPicker === null || antPicker === void 0 ? void 0 : (_antPicker$getElement6 = antPicker.getElementsByClassName('ant-picker-suffix')[0]) === null || _antPicker$getElement6 === void 0 ? void 0 : _antPicker$getElement6.style.removeProperty('color');
      }
      if (style.fontSize) {
        var _antPicker$getElement7;
        antPicker === null || antPicker === void 0 ? void 0 : (_antPicker$getElement7 = antPicker.getElementsByTagName('input')[0]) === null || _antPicker$getElement7 === void 0 ? void 0 : _antPicker$getElement7.style.setProperty('font-size', style.fontSize, 'important');
      } else {
        var _antPicker$getElement8;
        antPicker === null || antPicker === void 0 ? void 0 : (_antPicker$getElement8 = antPicker.getElementsByTagName('input')[0]) === null || _antPicker$getElement8 === void 0 ? void 0 : _antPicker$getElement8.style.removeProperty('font-size');
      }
      if (style.fontWeight) {
        var _antPicker$getElement9;
        antPicker === null || antPicker === void 0 ? void 0 : (_antPicker$getElement9 = antPicker.getElementsByTagName('input')[0]) === null || _antPicker$getElement9 === void 0 ? void 0 : _antPicker$getElement9.style.setProperty('font-weight', style.fontWeight, 'important');
      } else {
        var _antPicker$getElement10;
        antPicker === null || antPicker === void 0 ? void 0 : (_antPicker$getElement10 = antPicker.getElementsByTagName('input')[0]) === null || _antPicker$getElement10 === void 0 ? void 0 : _antPicker$getElement10.style.removeProperty('font-weight');
      }
      if (style.lineHeight) {
        var _antPicker$getElement11;
        antPicker === null || antPicker === void 0 ? void 0 : (_antPicker$getElement11 = antPicker.getElementsByTagName('input')[0]) === null || _antPicker$getElement11 === void 0 ? void 0 : _antPicker$getElement11.style.setProperty('font-height', style.lineHeight, 'important');
      } else {
        var _antPicker$getElement12;
        antPicker === null || antPicker === void 0 ? void 0 : (_antPicker$getElement12 = antPicker.getElementsByTagName('input')[0]) === null || _antPicker$getElement12 === void 0 ? void 0 : _antPicker$getElement12.style.removeProperty('font-height');
      }
    }
  }, [style, ID]);
  var Icons = (icons || {})[suffixIcon || 'ClockCircleOutlined'];
  return /*#__PURE__*/React.createElement("div", {
    className: "ant-time-picker",
    id: ID,
    style: _extends({
      display: none ? 'none' : 'inline-block'
    }, _style)
  }, /*#__PURE__*/React.createElement(_TimePicker, _extends({
    inputReadOnly: true,
    style: style,
    format: format,
    locale: LocalFormat.getDefinedChineseLocal(),
    value: value ? moment(value, format) : undefined,
    bordered: !bordered,
    suffixIcon: /*#__PURE__*/React.createElement(Icons, null)
  }, otherProps)));
};
antTimePicker.displayName = 'antTimePicker';
export default antTimePicker;
export function uuid() {
  return (Math.random() * 1e6 >> 0).toString(36);
}