"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = _interopRequireDefault(require("react"));
var _reactIntl = require("react-intl");
var _styledComponents = _interopRequireDefault(require("styled-components"));
var _utils = require("../../common/utils");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var dateTimeOptions = {
  year: 'numeric',
  month: 'numeric',
  day: 'numeric',
  hour12: false,
  hour: 'numeric',
  minute: 'numeric'
};
var dateOptions = {
  year: 'numeric',
  month: 'numeric',
  day: 'numeric'
};
var StyledSpan = _styledComponents.default.span.withConfig({
  displayName: "DateTime__StyledSpan",
  componentId: "sc-xstd26-0"
})(["color:", ";"], function (p) {
  return p.theme.color.text;
});
var DateTime = function DateTime(_ref) {
  var value = _ref.value,
    onlyDate = _ref.onlyDate,
    options = _ref.options,
    _ref$invalidValue = _ref.invalidValue,
    invalidValue = _ref$invalidValue === void 0 ? '-' : _ref$invalidValue;
  var intl = (0, _reactIntl.useIntl)();
  if ((0, _utils.isValidDateTimeNumber)(value)) {
    var formatOptions = options || (onlyDate ? dateOptions : dateTimeOptions);
    return _react.default.createElement(StyledSpan, null, _react.default.createElement("time", null, intl.formatDate(value, formatOptions)));
  }
  return _react.default.createElement(StyledSpan, null, invalidValue);
};
var _default = exports.default = DateTime;