"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.Popper = void 0;

var _react = _interopRequireDefault(require("react"));

var _randomstring = _interopRequireDefault(require("randomstring"));

var _reactPopper = require("react-popper");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

var Popper = function Popper(_ref) {
  var reference = _ref.reference,
      placement = _ref.placement,
      children = _ref.children,
      isVisible = _ref.isVisible;
  var popperId = "popper-".concat(_randomstring["default"].generate(5));
  return /*#__PURE__*/_react["default"].createElement(_reactPopper.Manager, null, /*#__PURE__*/_react["default"].createElement(_reactPopper.Reference, null, function (_ref2) {
    var ref = _ref2.ref;
    return reference({
      ref: ref,
      referenceProps: {
        'aria-describedby': popperId
      }
    });
  }), /*#__PURE__*/_react["default"].createElement(_reactPopper.Popper, {
    placement: placement
  }, function (_ref3) {
    var ref = _ref3.ref,
        style = _ref3.style,
        popperPlacement = _ref3.placement,
        arrowProps = _ref3.arrowProps;
    return isVisible ? children({
      ref: ref,
      style: style,
      placement: popperPlacement,
      arrowProps: arrowProps,
      popperId: popperId
    }) : /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null);
  }));
};

exports.Popper = Popper;
Popper.displayName = 'Popper';