'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var React = require('react');
var reactTransitionGroup = require('react-transition-group');
var classNames = require('clsx');
var Portal = require('@prom-ui/core/Portal');
var BodyScrollLock = require('@prom-ui/core/BodyScrollLock');

function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }

function _interopNamespaceCompat(e) {
  if (e && typeof e === 'object' && 'default' in e) return e;
  var n = Object.create(null);
  if (e) {
    Object.keys(e).forEach(function (k) {
      if (k !== 'default') {
        var d = Object.getOwnPropertyDescriptor(e, k);
        Object.defineProperty(n, k, d.get ? d : {
          enumerable: true,
          get: function () { return e[k]; }
        });
      }
    });
  }
  n.default = e;
  return Object.freeze(n);
}

var React__namespace = /*#__PURE__*/_interopNamespaceCompat(React);
var classNames__default = /*#__PURE__*/_interopDefaultCompat(classNames);

function ownKeys(object, enumerableOnly) {
  var keys = Object.keys(object);
  if (Object.getOwnPropertySymbols) {
    var symbols = Object.getOwnPropertySymbols(object);
    enumerableOnly && (symbols = symbols.filter(function (sym) {
      return Object.getOwnPropertyDescriptor(object, sym).enumerable;
    })), keys.push.apply(keys, symbols);
  }
  return keys;
}
function _objectSpread2(target) {
  for (var i = 1; i < arguments.length; i++) {
    var source = null != arguments[i] ? arguments[i] : {};
    i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
      _defineProperty(target, key, source[key]);
    }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
      Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
    });
  }
  return target;
}
function _defineProperty(obj, key, value) {
  key = _toPropertyKey(key);
  if (key in obj) {
    Object.defineProperty(obj, key, {
      value: value,
      enumerable: true,
      configurable: true,
      writable: true
    });
  } else {
    obj[key] = value;
  }
  return 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);
}
function _objectWithoutPropertiesLoose(source, excluded) {
  if (source == null) return {};
  var target = {};
  var sourceKeys = Object.keys(source);
  var key, i;
  for (i = 0; i < sourceKeys.length; i++) {
    key = sourceKeys[i];
    if (excluded.indexOf(key) >= 0) continue;
    target[key] = source[key];
  }
  return target;
}
function _objectWithoutProperties(source, excluded) {
  if (source == null) return {};
  var target = _objectWithoutPropertiesLoose(source, excluded);
  var key, i;
  if (Object.getOwnPropertySymbols) {
    var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
    for (i = 0; i < sourceSymbolKeys.length; i++) {
      key = sourceSymbolKeys[i];
      if (excluded.indexOf(key) >= 0) continue;
      if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
      target[key] = source[key];
    }
  }
  return target;
}
function _toPrimitive(input, hint) {
  if (typeof input !== "object" || input === null) return input;
  var prim = input[Symbol.toPrimitive];
  if (prim !== undefined) {
    var res = prim.call(input, hint || "default");
    if (typeof res !== "object") return res;
    throw new TypeError("@@toPrimitive must return a primitive value.");
  }
  return (hint === "string" ? String : Number)(input);
}
function _toPropertyKey(arg) {
  var key = _toPrimitive(arg, "string");
  return typeof key === "symbol" ? key : String(key);
}

var css = {"root":"Backdrop__root___p-RA9","backdrop":"Backdrop__backdrop___XNSpt","enterActive":"Backdrop__enterActive___ATDSq","exitActive":"Backdrop__exitActive___bnta5","enter":"Backdrop__enter___NmGm7","exit":"Backdrop__exit___sD9v-"};

var _excluded = ["isOpen", "isRenderPortal", "isAnimated", "isBodyScrollLock", "style", "zIndex", "children", "className", "onClick"];
/**
 * Компонент служит для создания темного фона, который может использоваться в качестве
 * подложки для модальных окон или других всплывающих элементов интерфейса.
 * Он занимает всю доступную область экрана.
 */
var Backdrop = /*#__PURE__*/React__namespace.forwardRef(function (_ref, ref) {
  var _ref$isOpen = _ref.isOpen,
    isOpen = _ref$isOpen === void 0 ? false : _ref$isOpen,
    _ref$isRenderPortal = _ref.isRenderPortal,
    isRenderPortal = _ref$isRenderPortal === void 0 ? true : _ref$isRenderPortal,
    _ref$isAnimated = _ref.isAnimated,
    isAnimated = _ref$isAnimated === void 0 ? true : _ref$isAnimated,
    _ref$isBodyScrollLock = _ref.isBodyScrollLock,
    isBodyScrollLock = _ref$isBodyScrollLock === void 0 ? false : _ref$isBodyScrollLock,
    _ref$style = _ref.style,
    style = _ref$style === void 0 ? {} : _ref$style,
    _ref$zIndex = _ref.zIndex,
    zIndex = _ref$zIndex === void 0 ? 1000 : _ref$zIndex,
    children = _ref.children,
    className = _ref.className,
    onClick = _ref.onClick,
    props = _objectWithoutProperties(_ref, _excluded);
  return /*#__PURE__*/React__namespace.createElement(reactTransitionGroup.CSSTransition, {
    "in": isOpen,
    timeout: isAnimated ? 225 : 0,
    classNames: css,
    unmountOnExit: true
  }, /*#__PURE__*/React__namespace.createElement(Portal.Portal, {
    isActive: isRenderPortal
  }, /*#__PURE__*/React__namespace.createElement(BodyScrollLock.BodyScrollLock, {
    isActive: isBodyScrollLock
  }), /*#__PURE__*/React__namespace.createElement("div", _extends({
    ref: ref,
    className: classNames__default.default(css.root, className),
    style: _objectSpread2({
      zIndex: zIndex
    }, style),
    "aria-hidden": true,
    "data-testid": "backdrop",
    "data-qaid": "backdrop"
  }, props), /*#__PURE__*/React__namespace.createElement("div", {
    className: css.backdrop,
    onClick: onClick
  }), children)));
});
Backdrop.displayName = 'Backdrop';

exports.Backdrop = Backdrop;

require('./style.development.v2.css');
