import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
import React from 'react';
import PropTypes from 'prop-types';
import { highlight } from '../../list/utils';
import { Highlighter, HIGHLIGHT_TYPE } from '../../Highlighter';
export var CommonListHighlight =
/*#__PURE__*/
function (_React$Component) {
  _inheritsLoose(CommonListHighlight, _React$Component);

  function CommonListHighlight() {
    return _React$Component.apply(this, arguments) || this;
  }

  var _proto = CommonListHighlight.prototype;

  _proto.render = function render() {
    var _this$props = this.props,
        listHighlightType = _this$props.listHighlightType,
        containsRichText = _this$props.containsRichText,
        title = _this$props.title,
        textHighlightPattern = _this$props.textHighlightPattern,
        textFilterPattern = _this$props.textFilterPattern;

    if (containsRichText || listHighlightType === HIGHLIGHT_TYPE.BACKGROUND) {
      return React.createElement(Highlighter, {
        title: title,
        listHighlightType: listHighlightType,
        highlightRegexp: textHighlightPattern,
        filterRegexp: textFilterPattern
      }, this.props.children);
    }

    return highlight(textFilterPattern, this.props.children, title);
  };

  return CommonListHighlight;
}(React.Component);

_defineProperty(CommonListHighlight, "HIGHLIGHT_TYPE_BACKGROUND", HIGHLIGHT_TYPE.BACKGROUND);

_defineProperty(CommonListHighlight, "HIGHLIGHT_TYPE_BOLD", HIGHLIGHT_TYPE.BOLD);

_defineProperty(CommonListHighlight, "propTypes", {
  children: PropTypes.node,
  title: PropTypes.string,
  textHighlightPattern: PropTypes.object,
  textFilterPattern: PropTypes.object,
  listHighlightType: PropTypes.oneOf([HIGHLIGHT_TYPE.BACKGROUND, HIGHLIGHT_TYPE.BOLD]),
  containsRichText: PropTypes.bool
});

_defineProperty(CommonListHighlight, "defaultProps", {
  children: null,
  title: null,
  textHighlightPattern: null,
  textFilterPattern: null,
  listHighlightType: HIGHLIGHT_TYPE.BOLD,
  containsRichText: false
});