import _extends from "@babel/runtime/helpers/extends";
import "core-js/modules/es.array.is-array.js";
import "core-js/modules/es.array.map.js";
import * as React from 'react';
import { cnCreate, convert, filterDataAttrs, textConvertConfig } from '@megafon/ui-helpers';
import "./TextWithIconItem.css";
var testIdPrefix = 'TextWithIconItem';
var cn = cnCreate('mfui-9-text-with-icon-item');
var TextWithIconItem = function TextWithIconItem(_ref) {
  var className = _ref.className,
    _ref$classes = _ref.classes,
    classes = _ref$classes === void 0 ? {} : _ref$classes,
    text = _ref.text,
    icon = _ref.icon,
    _ref$iconBackground = _ref.iconBackground,
    iconBackground = _ref$iconBackground === void 0 ? 'no' : _ref$iconBackground,
    rootRef = _ref.rootRef,
    dataAttrs = _ref.dataAttrs;
  var renderText = React.useMemo(function () {
    if (Array.isArray(text)) {
      return text.map(function (item) {
        return convert(item, textConvertConfig);
      });
    }
    return convert(text, textConvertConfig);
  }, [text]);
  return /*#__PURE__*/React.createElement("div", _extends({
    className: cn({
      'icon-background': iconBackground
    }, [className]),
    ref: rootRef
  }, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root)), /*#__PURE__*/React.createElement("div", {
    className: cn('svg-icon', [classes.icon]),
    "data-testid": "".concat(testIdPrefix, "-icon")
  }, icon), /*#__PURE__*/React.createElement("div", {
    className: cn('text', [classes.text]),
    "data-testid": "".concat(testIdPrefix, "-text")
  }, renderText));
};
export default TextWithIconItem;