"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = exports.transitionStyle = void 0;

var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));

var _ThemeProvider = require("../ThemeProvider");

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }

var transitionStyle = function transitionStyle(_ref, theme) {
  var _ref$finalHeight = _ref.finalHeight,
      finalHeight = _ref$finalHeight === void 0 ? 'auto' : _ref$finalHeight,
      finalWidth = _ref.finalWidth;
  return {
    style: {//
    },
    slide: {
      root: {
        duration: 250
      },
      placements: {
        bottom: {
          maxWidth: '100vw',
          height: finalHeight,
          bottom: 0,
          left: 0,
          right: 0
        },
        top: {
          maxWidth: '100vw',
          height: finalHeight,
          top: 0,
          left: 0,
          right: 0
        },
        left: _objectSpread(_objectSpread({}, finalWidth && {
          maxWidth: finalWidth
        }), {}, {
          height: '100vh',
          left: 0,
          top: 0
        }),
        right: _objectSpread(_objectSpread({}, finalWidth && {
          maxWidth: finalWidth
        }), {}, {
          right: 0,
          top: 0,
          height: '100vh'
        })
      },
      transitionOptions: {
        bottom: {
          offset: '100%',
          transform: function transform(y) {
            return "translateY(".concat(y, ")");
          }
        },
        top: {
          offset: '-100%',
          transform: function transform(y) {
            return "translateY(".concat(y, ")");
          }
        },
        left: {
          offset: '-100%',
          transform: function transform(x) {
            return "translateX(".concat(x, ")");
          }
        },
        right: {
          offset: '100%',
          transform: function transform(x) {
            return "translateX(".concat(x, ")");
          }
        }
      }
    },
    scale: {
      initialScale: 0.97,
      duration: 150
    },
    slideIn: {
      duration: 150,
      offset: '10px'
    }
  };
};

exports.transitionStyle = transitionStyle;

var useTransitionStyle = function useTransitionStyle(props) {
  var theme = (0, _ThemeProvider.useTheme)();
  var styles = theme['styles'].transition ? theme['styles'].transition(props, theme) : transitionStyle(props, theme);
  return {
    // base style
    root: styles.style,
    // variant style
    slide: {
      root: styles.slide.root,
      placement: styles.slide.placements[props.from],
      transitionOption: styles.slide.transitionOptions[props.from]
    },
    scale: styles.scale,
    slideIn: styles.slideIn
  };
};

var _default = useTransitionStyle;
exports["default"] = _default;
//# sourceMappingURL=styles.js.map