var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
import React from 'react';
import PropTypes from 'prop-types';
import { filterKeyCodes } from '../../utils/functions';
import { Card } from '../card';
import { CatalogPrice } from './CatalogPrice';
var CatalogGridItem = /** @class */ (function (_super) {
    __extends(CatalogGridItem, _super);
    function CatalogGridItem() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.handleKeyDown = filterKeyCodes(_this.props.onClick);
        return _this;
    }
    CatalogGridItem.prototype.renderDescription = function () {
        var _a = this.props, description = _a.description, price = _a.price;
        if (!description && !price) {
            return null;
        }
        if (price) {
            var pricePurchase = price.pricePurchase, priceAnnual = price.priceAnnual, priceMonthly = price.priceMonthly, isPriceFrom = price.isPriceFrom;
            return (React.createElement(Card.Content, { center: true },
                React.createElement(CatalogPrice, { isCentered: true, pricePurchase: pricePurchase, priceAnnual: priceAnnual, priceMonthly: priceMonthly, isPriceFrom: isPriceFrom })));
        }
        return (React.createElement(Card.Content, { center: true },
            React.createElement("div", { className: "rc-catalog-grid-item__desc", "data-test-automation-id": "description" }, description)));
    };
    CatalogGridItem.prototype.renderIcon = function () {
        return (React.createElement(Card.Content, { center: true, addTopOffset: true, addBottomOffset: true }, React.cloneElement(this.props.icon, { size: 90, isRound: true })));
    };
    CatalogGridItem.prototype.renderName = function () {
        var name = this.props.name;
        return (React.createElement(Card.Content, { center: true },
            React.createElement("div", { className: "rc-catalog-grid-item__name", "data-test-automation-id": "name" }, name)));
    };
    CatalogGridItem.prototype.render = function () {
        var _a = this.props, testAutomationId = _a.testAutomationId, category = _a.category, onClick = _a.onClick;
        return (React.createElement(Card, { secondary: category, testAutomationId: testAutomationId, onClick: onClick },
            this.renderIcon(),
            this.renderName(),
            this.renderDescription()));
    };
    CatalogGridItem.propTypes = {
        testAutomationId: PropTypes.string,
        category: PropTypes.bool,
        name: PropTypes.string.isRequired,
        description: PropTypes.string,
        icon: PropTypes.node.isRequired,
        color: PropTypes.string,
        onClick: PropTypes.func,
        price: PropTypes.shape({
            pricePurchase: PropTypes.object,
            priceAnnual: PropTypes.object,
            priceMonthly: PropTypes.object,
            isPriceFrom: PropTypes.bool
        })
    };
    CatalogGridItem.defaultProps = {
        testAutomationId: 'catalogGridItem',
        category: false,
        description: null,
        color: null,
        price: null,
        onClick: function () { }
    };
    return CatalogGridItem;
}(React.PureComponent));
export { CatalogGridItem };
//# sourceMappingURL=CatalogGridItem.js.map