"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
exports.uuid = uuid;
var _timePicker = _interopRequireDefault(require("antd/lib/time-picker"));
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var React = _interopRequireWildcard(require("react"));
var _moment = _interopRequireDefault(require("moment"));
var _localHelper = require("./localHelper");
var icons = _interopRequireWildcard(require("@ant-design/icons/es/index"));
require("./index.less");
var _excluded = ["bordered", "value", "format", "style", "none", "suffixIcon"];
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
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 = (0, _objectWithoutPropertiesLoose2["default"])(_ref, _excluded);
  var _useState = (0, React.useState)(''),
    ID = _useState[0],
    setID = _useState[1];
  (0, React.useEffect)(function () {
    setID("antTimePicker_" + uuid());
  }, []);
  (0, React.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');
        console.log(antPicker === null || antPicker === void 0 ? void 0 : antPicker.getElementsByClassName('ant-picker-suffix')[0]);
        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: {
      display: none ? 'none' : 'inline-block'
    }
  }, /*#__PURE__*/React.createElement(_timePicker["default"], (0, _extends2["default"])({
    inputReadOnly: true,
    style: style,
    format: format,
    locale: _localHelper.LocalFormat.getDefinedChineseLocal(),
    value: value ? (0, _moment["default"])(value, format) : undefined,
    bordered: !bordered,
    suffixIcon: /*#__PURE__*/React.createElement(Icons, null)
  }, otherProps)));
};
antTimePicker.displayName = 'antTimePicker';
var _default = antTimePicker;
exports["default"] = _default;
function uuid() {
  return (Math.random() * 1e6 >> 0).toString(36);
}