"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

exports.__esModule = true;
exports.PureListHighlight = void 0;

var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));

var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));

var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));

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

var _propTypes = _interopRequireDefault(require("prop-types"));

var _CommonListHighlight = require("./common/CommonListHighlight");

var _regexp = require("../../utils/regexp");

var PureListHighlight =
/*#__PURE__*/
function (_React$Component) {
  (0, _inheritsLoose2.default)(PureListHighlight, _React$Component);

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

  var _proto = PureListHighlight.prototype;

  _proto.getTextHighlightPattern = function getTextHighlightPattern() {
    var _this$props = this.props,
        textHighlightPattern = _this$props.textHighlightPattern,
        highlightedText = _this$props.highlightedText;
    return textHighlightPattern || (0, _regexp.getHighlightRegExp)(highlightedText);
  };

  _proto.getTextFilterPattern = function getTextFilterPattern() {
    var _this$props2 = this.props,
        textFilterPattern = _this$props2.textFilterPattern,
        highlightedText = _this$props2.highlightedText;
    return textFilterPattern || (0, _regexp.searchStringToRegExp)(highlightedText);
  };

  _proto.render = function render() {
    return _react.default.createElement(_CommonListHighlight.CommonListHighlight, (0, _extends2.default)({}, this.props, {
      textHighlightPattern: this.getTextHighlightPattern(),
      textFilterPattern: this.getTextFilterPattern()
    }));
  };

  return PureListHighlight;
}(_react.default.Component);

exports.PureListHighlight = PureListHighlight;
(0, _defineProperty2.default)(PureListHighlight, "propTypes", Object.assign({}, _CommonListHighlight.CommonListHighlight.propTypes, {
  highlightedText: _propTypes.default.string
}));
(0, _defineProperty2.default)(PureListHighlight, "defaultProps", Object.assign({}, _CommonListHighlight.CommonListHighlight.defaultProps, {
  highlightedText: ''
}));
(0, _defineProperty2.default)(PureListHighlight, "HIGHLIGHT_TYPE_BACKGROUND", _CommonListHighlight.CommonListHighlight.HIGHLIGHT_TYPE_BACKGROUND);
(0, _defineProperty2.default)(PureListHighlight, "HIGHLIGHT_TYPE_BOLD", _CommonListHighlight.CommonListHighlight.HIGHLIGHT_TYPE_BOLD);