import _extends from "@babel/runtime/helpers/esm/extends";
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
import * as React from 'react';
import classNames from 'classnames';
import { Popup } from 'rc-tooltip';
import { ConfigContext } from '../config-provider';
import useStyle from './style';
import { getRenderPropValue } from '../_util/getRenderPropValue';
export var getOverlay = function getOverlay(prefixCls, title, content) {
  if (!title && !content) return undefined;
  return /*#__PURE__*/React.createElement(React.Fragment, null, title && /*#__PURE__*/React.createElement("div", {
    className: "".concat(prefixCls, "-title")
  }, getRenderPropValue(title)), /*#__PURE__*/React.createElement("div", {
    className: "".concat(prefixCls, "-inner-content")
  }, getRenderPropValue(content)));
};
export default function PurePanel(props) {
  var customizePrefixCls = props.prefixCls,
      className = props.className,
      _props$placement = props.placement,
      placement = _props$placement === void 0 ? 'top' : _props$placement,
      title = props.title,
      content = props.content,
      children = props.children;

  var _React$useContext = React.useContext(ConfigContext),
      getPrefixCls = _React$useContext.getPrefixCls;

  var prefixCls = getPrefixCls('popover', customizePrefixCls);

  var _useStyle = useStyle(prefixCls),
      _useStyle2 = _slicedToArray(_useStyle, 2),
      wrapSSR = _useStyle2[0],
      hashId = _useStyle2[1];

  return wrapSSR( /*#__PURE__*/React.createElement("div", {
    className: classNames(hashId, prefixCls, "".concat(prefixCls, "-pure"), "".concat(prefixCls, "-placement-").concat(placement), className)
  }, /*#__PURE__*/React.createElement(Popup, _extends({}, props, {
    className: hashId,
    prefixCls: prefixCls
  }), children || getOverlay(prefixCls, title, content))));
}