// @ts-nocheck
import { __assign, __rest } from "tslib";
import './CollapseGroup.css';
import React, { forwardRef } from 'react';
import { cn } from '../../utils/bem';
import { Collapse, collapsePropCloseDirectionIconDefault, collapsePropDirectionIconDefault, collapsePropIconPositionDefault, collapsePropSizeDefault, collapsePropViewDefault, } from '../Collapse/Collapse';
import { Typography } from '../Typography/Typography';
import { withDefaultGetters } from './helpers';
import { useChoice } from './useChoice';
var cnCollapseGroup = cn('CollapseGroup');
var CollapseGroupRender = function (props, ref) {
    var _a = withDefaultGetters(props), titleGroup = _a.titleGroup, items = _a.items, getItemLabel = _a.getItemLabel, getItemContent = _a.getItemContent, _b = _a.size, size = _b === void 0 ? collapsePropSizeDefault : _b, _c = _a.view, view = _c === void 0 ? 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 ? collapsePropIconPositionDefault : _d, _e = _a.directionIcon, directionIcon = _e === void 0 ? collapsePropDirectionIconDefault : _e, _f = _a.closeDirectionIcon, closeDirectionIcon = _f === void 0 ? collapsePropCloseDirectionIconDefault : _f, isOpenFirst = _a.isOpenFirst, showCounter = _a.showCounter, otherProps = __rest(_a, ["titleGroup", "items", "getItemLabel", "getItemContent", "size", "view", "hoverEffect", "divider", "icon", "closeIcon", "getItemRightSide", "horizontalSpace", "iconPosition", "directionIcon", "closeDirectionIcon", "isOpenFirst", "showCounter"]);
    var _g = useChoice(props), getChecked = _g.getChecked, getOnChange = _g.getOnChange;
    return (React.createElement("div", __assign({ className: cnCollapseGroup({ size: size, showCounter: showCounter }), ref: ref }, otherProps),
        titleGroup && (React.createElement("div", { className: cnCollapseGroup('Title') },
            React.createElement(Typography.Text, { size: "xs", weight: "bold", transform: "uppercase" }, titleGroup))),
        React.createElement("div", { className: cnCollapseGroup('Body') }, items.map(function (item, index) {
            return (React.createElement(Collapse, __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)));
        }))));
};
export var CollapseGroup = forwardRef(CollapseGroupRender);
export * from './helpers';
