import _extends from "@babel/runtime/helpers/extends";
import * as React from 'react';
import { Header } from '@megafon/ui-core';
import { cnCreate, filterDataAttrs } from '@megafon/ui-helpers';
import "./style/BenefitsIconsTile.css";
var testIdPrefix = 'BenefitsIconsTile';
var cn = cnCreate('mfui-benefits-icons-tile');
var BenefitsIconsTile = function BenefitsIconsTile(_ref) {
  var dataAttrs = _ref.dataAttrs,
    _ref$classes = _ref.classes,
    classes = _ref$classes === void 0 ? {} : _ref$classes,
    title = _ref.title,
    text = _ref.text,
    icon = _ref.icon,
    iconPosition = _ref.iconPosition,
    background = _ref.background,
    alt = _ref.alt,
    className = _ref.className;
  var renderIcon = function renderIcon() {
    if (typeof icon === 'string') {
      return /*#__PURE__*/React.createElement("img", {
        className: cn('img-icon', [classes.icon]),
        src: icon,
        alt: alt,
        "data-testid": "".concat(testIdPrefix, "-img")
      });
    }
    return /*#__PURE__*/React.createElement("div", {
      className: cn('svg-icon', [classes.icon]),
      "data-testid": "".concat(testIdPrefix, "-svg")
    }, icon);
  };
  return /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root), {
    className: cn({
      'icon-position': iconPosition,
      background: background,
      image: typeof icon === 'string'
    }, [className, classes.root]),
    "data-testid": "".concat(testIdPrefix, "-root")
  }), /*#__PURE__*/React.createElement("div", {
    className: cn('inner')
  }, renderIcon(), /*#__PURE__*/React.createElement("div", {
    className: cn('content-wrapper', [classes.contentWrapper])
  }, title && /*#__PURE__*/React.createElement(Header, {
    className: cn('title', [classes.title]),
    as: "h5"
  }, title), text && /*#__PURE__*/React.createElement("div", {
    className: cn('content', [classes.text])
  }, text))));
};
export default BenefitsIconsTile;