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, { Component } from 'react';
import PropTypes from 'prop-types';
import { isFunction } from 'lodash';
import classnames from 'classnames';
import { Icon } from '../Icon';
import { BreadCrumb } from './BreadCrumb';
var BreadCrumbs = /** @class */ (function (_super) {
    __extends(BreadCrumbs, _super);
    function BreadCrumbs() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.renderCrumb = function (item, index) {
            if (index === void 0) { index = 0; }
            var _a = _this.props, items = _a.items, onSelect = _a.onSelect;
            var id = item.id, name = item.name;
            var isFirst = index <= 0;
            var isLast = index >= items.length - 1;
            return (React.createElement(BreadCrumb, { key: id, id: id, name: name, isFirst: isFirst, isLast: isLast, onSelect: onSelect, index: index }));
        };
        return _this;
    }
    BreadCrumbs.prototype.render = function () {
        var _a = this.props, iconName = _a.iconName, items = _a.items, style = _a.style, onSelect = _a.onSelect, testAutomationId = _a.testAutomationId;
        var className = classnames('rc-breadcrumbs', {
            'rc-breadcrumbs-no-handler': !isFunction(onSelect)
        });
        var icon = null;
        if (iconName) {
            icon = React.createElement(Icon, { name: iconName, className: "rc-breadcrumbs-icon" });
        }
        return (React.createElement("div", { style: style, className: className, "data-test-automation-id": testAutomationId },
            icon,
            items.map(this.renderCrumb)));
    };
    BreadCrumbs.propTypes = {
        iconName: PropTypes.string,
        items: PropTypes.arrayOf(PropTypes.shape({
            id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
            name: PropTypes.string
        })),
        onSelect: PropTypes.func,
        testAutomationId: PropTypes.string,
        style: PropTypes.object
    };
    BreadCrumbs.defaultProps = {
        iconName: null,
        items: [],
        onSelect: null,
        testAutomationId: 'breadcrumbs',
        style: null,
        breadcrumbMaxWidth: 240
    };
    return BreadCrumbs;
}(Component));
export { BreadCrumbs };
//# sourceMappingURL=BreadCrumbs.js.map