"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = _interopRequireDefault(require("react"));
var _box = _interopRequireDefault(require("../box/box"));
var _moti = require("moti");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
/**
 * Slide is a component that provides an view with a sliding transition.
 */
const Slide = /*#__PURE__*/_react.default.memo( /*#__PURE__*/_react.default.forwardRef(({
  children,
  show,
  direction = "right",
  transition = {},
  exitTransition = {},
  ...rest
}, ref) => {
  const from = _react.default.useMemo(() => {
    switch (direction) {
      case "bottom":
        return {
          translateY: -500
        };
      case "top":
        return {
          translateY: 500
        };
      case "right":
        return {
          translateX: -500
        };
      case "left":
        return {
          translateX: 500
        };
      default:
        return {};
    }
  }, [direction]);
  const animate = _react.default.useMemo(() => {
    switch (direction) {
      case "bottom":
      case "top":
        return {
          translateY: 0
        };
      case "right":
      case "left":
        return {
          translateX: 0
        };
      default:
        return {};
    }
  }, [direction]);
  const exit = _react.default.useMemo(() => {
    switch (direction) {
      case "bottom":
        return {
          translateY: -500
        };
      case "top":
        return {
          translateY: 500
        };
      case "right":
        return {
          translateX: -500
        };
      case "left":
        return {
          translateX: 500
        };
      default:
        return {};
    }
  }, [direction]);
  return /*#__PURE__*/_react.default.createElement(_moti.AnimatePresence, null, show && /*#__PURE__*/_react.default.createElement(_box.default, _extends({
    ref: ref
  }, rest, {
    from: from,
    animate: animate,
    exit: exit,
    transition: {
      dampingRatio: 1,
      duration: 200,
      type: "spring",
      ...transition
    },
    exitTransition: {
      dampingRatio: 1,
      duration: 200,
      type: "spring",
      ...exitTransition
    }
  }), children));
}));
Slide.displayName = "Slide";
var _default = exports.default = Slide;
//# sourceMappingURL=slide.js.map