"use strict";
// @ts-nocheck
exports.__esModule = true;
exports.CollapseGroup = void 0;
var tslib_1 = require("tslib");
require("./CollapseGroup.css");
var react_1 = (0, tslib_1.__importStar)(require("react"));
var bem_1 = require("../../utils/bem");
var Collapse_1 = require("../Collapse/Collapse");
var Typography_1 = require("../Typography/Typography");
var helpers_1 = require("./helpers");
var useChoice_1 = require("./useChoice");
var cnCollapseGroup = (0, bem_1.cn)('CollapseGroup');
var CollapseGroupRender = function (props, ref) {
    var _a = (0, helpers_1.withDefaultGetters)(props), titleGroup = _a.titleGroup, items = _a.items, getItemLabel = _a.getItemLabel, getItemContent = _a.getItemContent, _b = _a.size, size = _b === void 0 ? Collapse_1.collapsePropSizeDefault : _b, _c = _a.view, view = _c === void 0 ? Collapse_1.collapsePropViewDefault : _c, hoverEffect = _a.hoverEffect, divider = _a.divider, icon = _a.icon, closeIcon = _a.closeIcon, getItemRightSide = _a.getItemRightSide, horizontalSpace = _a.horizontalSpace, _d = _a.iconPosition, iconPosition = _d === void 0 ? Collapse_1.collapsePropIconPositionDefault : _d, _e = _a.directionIcon, directionIcon = _e === void 0 ? Collapse_1.collapsePropDirectionIconDefault : _e, _f = _a.closeDirectionIcon, closeDirectionIcon = _f === void 0 ? Collapse_1.collapsePropCloseDirectionIconDefault : _f, isOpenFirst = _a.isOpenFirst, showCounter = _a.showCounter, otherProps = (0, tslib_1.__rest)(_a, ["titleGroup", "items", "getItemLabel", "getItemContent", "size", "view", "hoverEffect", "divider", "icon", "closeIcon", "getItemRightSide", "horizontalSpace", "iconPosition", "directionIcon", "closeDirectionIcon", "isOpenFirst", "showCounter"]);
    var _g = (0, useChoice_1.useChoice)(props), getChecked = _g.getChecked, getOnChange = _g.getOnChange;
    return (react_1["default"].createElement("div", (0, tslib_1.__assign)({ className: cnCollapseGroup({ size: size, showCounter: showCounter }), ref: ref }, otherProps),
        titleGroup && (react_1["default"].createElement("div", { className: cnCollapseGroup('Title') },
            react_1["default"].createElement(Typography_1.Typography.Text, { size: "xs", weight: "bold", transform: "uppercase" }, titleGroup))),
        react_1["default"].createElement("div", { className: cnCollapseGroup('Body') }, items.map(function (item, index) {
            return (react_1["default"].createElement(Collapse_1.Collapse, (0, tslib_1.__assign)({ label: getItemLabel(item), key: index, size: size, view: view, horizontalSpace: horizontalSpace, position: item.position, icon: icon, hoverEffect: hoverEffect, divider: divider, isOpen: getChecked(index), onClick: getOnChange(index) }, (iconPosition === 'left'
                ? {
                    iconPosition: iconPosition,
                    rightSide: getItemRightSide(item)
                }
                : { iconPosition: iconPosition }), (closeIcon
                ? { closeIcon: closeIcon }
                : {
                    directionIcon: directionIcon,
                    closeDirectionIcon: closeDirectionIcon
                })), getItemContent(item)));
        }))));
};
exports.CollapseGroup = (0, react_1.forwardRef)(CollapseGroupRender);
(0, tslib_1.__exportStar)(require("./helpers"), exports);
