import _extends from "@babel/runtime/helpers/esm/extends";
import { __rest } from "tslib";
import StarFilled from "@ant-design/icons/es/icons/StarFilled";
import RcRate from 'rc-rate';
import * as React from 'react';
import { ConfigContext } from '../config-provider';
import Tooltip from '../tooltip';
var Rate = /*#__PURE__*/React.forwardRef(function (_a, ref) {
  var prefixCls = _a.prefixCls,
      tooltips = _a.tooltips,
      props = __rest(_a, ["prefixCls", "tooltips"]);

  var characterRender = function characterRender(node, _ref) {
    var index = _ref.index;
    if (!tooltips) return node;
    return /*#__PURE__*/React.createElement(Tooltip, {
      title: tooltips[index]
    }, node);
  };

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

  var ratePrefixCls = getPrefixCls('rate', prefixCls);
  return /*#__PURE__*/React.createElement(RcRate // @ts-ignore
  , _extends({
    // @ts-ignore
    ref: ref,
    characterRender: characterRender
  }, props, {
    prefixCls: ratePrefixCls,
    direction: direction
  }));
});

if (process.env.NODE_ENV !== 'production') {
  Rate.displayName = 'Rate';
}

Rate.defaultProps = {
  character: /*#__PURE__*/React.createElement(StarFilled, null)
};
export default Rate;