"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.CustomNavBarElement = void 0;
var _react = _interopRequireWildcard(require("react"));
var _dateFns = require("date-fns");
var _NavBarElement = require("../Pickers/NavBarElement");
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
var CustomNavBarElement = exports.CustomNavBarElement = function CustomNavBarElement(_ref) {
  var month = _ref.month,
    _ref$showMonthPicker = _ref.showMonthPicker,
    showMonthPicker = _ref$showMonthPicker === void 0 ? false : _ref$showMonthPicker,
    onChangeDirection = _ref.onChangeDirection,
    onMonthChange = _ref.onMonthChange;
  var nextMonth = showMonthPicker ? (0, _dateFns.addMonths)(month, 12) : (0, _dateFns.addMonths)(month, 1);
  var previousMonth = showMonthPicker ? (0, _dateFns.addMonths)(month, -12) : (0, _dateFns.addMonths)(month, -1);
  var onNextClick = (0, _react.useCallback)(function () {
    if (onChangeDirection) {
      onChangeDirection(true);
    }
    if (onMonthChange) {
      onMonthChange(nextMonth);
    }
  }, [nextMonth, onChangeDirection, onMonthChange]);
  var onPreviousClick = (0, _react.useCallback)(function () {
    if (onChangeDirection) {
      onChangeDirection(false);
    }
    if (onMonthChange) {
      onMonthChange(previousMonth);
    }
  }, [onChangeDirection, onMonthChange, previousMonth]);
  return /*#__PURE__*/_react.default.createElement(_NavBarElement.NavBarElement, {
    onNextClick: onNextClick,
    onPreviousClick: onPreviousClick
  });
};
//# sourceMappingURL=CustomNavBarElement.js.map