"use strict";

function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
require("core-js/modules/es.array.concat.js");
var React = _interopRequireWildcard(require("react"));
var _uiHelpers = require("@megafon/ui-helpers");
var _setRelAttribute = require("../../../../helpers/setRelAttribute");
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
var ArrowRight = function ArrowRight(props) {
  return /*#__PURE__*/React.createElement("svg", (0, _extends2["default"])({
    viewBox: "0 0 32 32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M16.326 9.118a1.25 1.25 0 011.768-.004l5.618 5.592a1.825 1.825 0 010 2.588l-5.618 5.592a1.25 1.25 0 01-1.764-1.772l3.871-3.853H9a1.25 1.25 0 010-2.5h11.223l-3.893-3.875a1.25 1.25 0 01-.004-1.768z"
  }));
};
var cn = (0, _uiHelpers.cnCreate)('mfui-9-service-card');
var ServiceCard = function ServiceCard(_ref) {
  var title = _ref.title,
    subtitle = _ref.subtitle,
    value = _ref.value,
    _ref$background = _ref.background,
    background = _ref$background === void 0 ? 'shadow' : _ref$background,
    _ref$size = _ref.size,
    size = _ref$size === void 0 ? 'big' : _ref$size,
    imageSrc = _ref.imageSrc,
    imageSrc2x = _ref.imageSrc2x,
    _ref$imageAlt = _ref.imageAlt,
    imageAlt = _ref$imageAlt === void 0 ? 'image' : _ref$imageAlt,
    href = _ref.href,
    _ref$target = _ref.target,
    target = _ref$target === void 0 ? '_self' : _ref$target,
    rel = _ref.rel,
    classes = _ref.classes,
    dataAttrs = _ref.dataAttrs,
    onClick = _ref.onClick;
  var isSizeSmall = size === 'small';
  var currentRel = (0, _setRelAttribute.setRelAttribute)(rel, target);
  var imageSrcSet = imageSrc2x ? "".concat(imageSrc, ", ").concat(imageSrc2x, " 2x") : undefined;
  var footerElement = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
    className: cn('image-wrapper')
  }, /*#__PURE__*/React.createElement("img", {
    className: cn('image'),
    src: imageSrc,
    srcSet: imageSrcSet,
    alt: imageAlt
  })), /*#__PURE__*/React.createElement("div", {
    className: cn('price')
  }, /*#__PURE__*/React.createElement("div", {
    className: cn('circle')
  }, /*#__PURE__*/React.createElement(ArrowRight, {
    className: cn('arrow')
  })), /*#__PURE__*/React.createElement("div", {
    className: cn('value')
  }, value)));
  var renderFooter = function renderFooter() {
    if (isSizeSmall) {
      return /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({
        className: cn('footer')
      }, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.footer)), footerElement);
    }
    return footerElement;
  };
  return /*#__PURE__*/React.createElement("a", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root), {
    className: cn({
      background: background,
      size: size
    }, [classes === null || classes === void 0 ? void 0 : classes.root]),
    href: href,
    target: target,
    rel: currentRel,
    onClick: onClick
  }), /*#__PURE__*/React.createElement("div", {
    className: cn('header')
  }, /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.title), {
    className: cn('title', [classes === null || classes === void 0 ? void 0 : classes.title])
  }), typeof title === 'string' ? (0, _uiHelpers.convert)(title, _uiHelpers.titleConvertConfig) : title), subtitle && /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.subtitle), {
    className: cn('subtitle'),
    style: {
      WebkitBoxOrient: 'vertical'
    }
  }), typeof subtitle === 'string' ? (0, _uiHelpers.convert)(subtitle, _uiHelpers.textConvertConfig) : subtitle)), renderFooter());
};
var _default = exports["default"] = ServiceCard;