"use strict";
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
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 __());
    };
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.List = void 0;
var react_1 = __importDefault(require("react"));
var bem_react_classname_1 = require("bem-react-classname");
var cn_1 = require("../cn");
var performance_1 = __importDefault(require("../performance"));
/**
 * Компонент списка.
 */
var List = /** @class */ (function (_super) {
    __extends(List, _super);
    function List() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.cn = bem_react_classname_1.createCn('list');
        return _this;
    }
    List_1 = List;
    List.prototype.render = function () {
        var _this = this;
        var _a = this.props, items = _a.items, type = _a.type;
        var listElement = type === 'ordered' ? 'ol' : 'ul';
        var listContent = (items || []).map(function (_a) {
            var key = _a.key, value = _a.value, list = _a.list;
            return (react_1.default.createElement("li", { key: "item-" + key, className: _this.cn('item') },
                value,
                list && Array.isArray(list)
                    ? react_1.default.createElement(List_1, { items: list, type: type })
                    : ''));
        });
        var listProps = {
            className: this.cn({ type: type }),
            id: this.props.id,
            'data-test-id': this.props['data-test-id'],
        };
        return react_1.default.createElement(listElement, listProps, listContent);
    };
    var List_1;
    List = List_1 = __decorate([
        performance_1.default(true)
    ], List);
    return List;
}(react_1.default.Component));
exports.List = List;
exports.default = cn_1.withTheme(List);

//# sourceMappingURL=list.js.map
