import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
import { createBEM } from '@zarm-design/bem';
import React, { forwardRef, useImperativeHandle, useRef } from 'react';
import { ConfigContext } from '../config-provider';
import Popper from '../popper';
var Tooltip = /*#__PURE__*/forwardRef(function (props, ref) {
  var children = props.children,
      content = props.content,
      className = props.className,
      others = _objectWithoutProperties(props, ["children", "content", "className"]);

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

  var bem = createBEM('tooltip', {
    prefixCls: prefixCls
  });
  var cls = bem([className]);
  var poperRef = useRef(null);
  useImperativeHandle(ref, function () {
    return {
      update: function update() {
        var _poperRef$current;

        return (_poperRef$current = poperRef.current) === null || _poperRef$current === void 0 ? void 0 : _poperRef$current.update();
      }
    };
  });
  return /*#__PURE__*/React.createElement(Popper, _extends({
    content: content,
    className: cls
  }, others, {
    ref: poperRef
  }), children);
});
Tooltip.defaultProps = {
  direction: 'top',
  hasArrow: true,
  onVisibleChange: function onVisibleChange() {}
};
export default Tooltip;