"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");
require("./index.less");
var _excluded = ["bordered", "value", "format", "style"];
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,
    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) {
      var _antPicker$getElement, _antPicker$getElement2, _antPicker$getElement3, _antPicker$getElement4, _antPicker$getElement5;
      antPicker === null || antPicker === void 0 ? void 0 : (_antPicker$getElement = antPicker.getElementsByTagName('input')[0]) === null || _antPicker$getElement === void 0 ? void 0 : _antPicker$getElement.style.setProperty('--bg-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.getElementsByTagName('input')[0]) === null || _antPicker$getElement3 === void 0 ? void 0 : _antPicker$getElement3.style.setProperty('font-size', style.fontSize, 'important');
      antPicker === null || antPicker === void 0 ? void 0 : (_antPicker$getElement4 = antPicker.getElementsByTagName('input')[0]) === null || _antPicker$getElement4 === void 0 ? void 0 : _antPicker$getElement4.style.setProperty('font-weight', style.fontWeight, 'important');
      antPicker === null || antPicker === void 0 ? void 0 : (_antPicker$getElement5 = antPicker.getElementsByTagName('input')[0]) === null || _antPicker$getElement5 === void 0 ? void 0 : _antPicker$getElement5.style.setProperty('line-height', style.lineHeight, 'important');
    }
  }, [style, ID]);
  return /*#__PURE__*/React.createElement("div", {
    className: "ant-time-picker",
    id: ID,
    style: {
      display: 'inline-block'
    }
  }, /*#__PURE__*/React.createElement(_timePicker["default"], (0, _extends2["default"])({
    style: style,
    format: format,
    locale: _localHelper.LocalFormat.getDefinedChineseLocal(),
    value: value ? (0, _moment["default"])(value, format) : undefined,
    bordered: !bordered
  }, otherProps)));
};
antTimePicker.displayName = 'antTimePicker';
var _default = antTimePicker;
exports["default"] = _default;
function uuid() {
  return (Math.random() * 1e6 >> 0).toString(36);
}