import _defineProperty from '@babel/runtime/helpers/defineProperty';
import { capitalize } from '@bigbinary/neeto-cist';
import useTimer from '@bigbinary/neeto-commons-frontend/react-utils/useTimer';
import { timeFormat } from '@bigbinary/neeto-commons-frontend/utils/datetime';
import Tooltip from '@bigbinary/neetoui/Tooltip';
import Typography from '@bigbinary/neetoui/Typography';
import { fromPairs, keys } from 'ramda';
import { jsx } from 'react/jsx-runtime';

function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var DateFormat = fromPairs(keys(timeFormat).map(function (key) {
  return [capitalize(key), function (_ref) {
    var date = _ref.date,
      _ref$timerInterval = _ref.timerInterval,
      timerInterval = _ref$timerInterval === void 0 ? 60 : _ref$timerInterval,
      _ref$tooltipProps = _ref.tooltipProps,
      tooltipProps = _ref$tooltipProps === void 0 ? {} : _ref$tooltipProps,
      _ref$typographyProps = _ref.typographyProps,
      typographyProps = _ref$typographyProps === void 0 ? {} : _ref$typographyProps,
      _ref$tooltipDateForma = _ref.tooltipDateFormat,
      tooltipDateFormat = _ref$tooltipDateForma === void 0 ? "extended" : _ref$tooltipDateForma;
    useTimer(timerInterval);
    return /*#__PURE__*/jsx(Tooltip, _objectSpread(_objectSpread({
      interactive: true,
      appendTo: function appendTo() {
        return document.body;
      },
      content: timeFormat[tooltipDateFormat](date),
      disabled: key === tooltipDateFormat,
      position: "top",
      touch: ["hold", 500]
    }, tooltipProps), {}, {
      children: /*#__PURE__*/jsx(Typography, _objectSpread(_objectSpread({
        component: "span",
        style: "body2"
      }, typographyProps), {}, {
        children: timeFormat[key](date)
      }))
    }));
  }];
}));

export { DateFormat as default };
//# sourceMappingURL=DateFormat.js.map
