(function (factory) {
    if (typeof module === "object" && typeof module.exports === "object") {
        var v = factory(require, exports);
        if (v !== undefined) module.exports = v;
    }
    else if (typeof define === "function" && define.amd) {
        define(["require", "exports", "tslib", "react", "@greenatom/icons", "../../../typography/H", "../../../hooks/useStateProps", "../../../Avatar", "./styles"], factory);
    }
})(function (require, exports) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var tslib_1 = require("tslib");
    var react_1 = (0, tslib_1.__importStar)(require("react"));
    var icons_1 = require("@greenatom/icons");
    var H_1 = (0, tslib_1.__importDefault)(require("../../../typography/H"));
    var useStateProps_1 = require("../../../hooks/useStateProps");
    var Avatar_1 = require("../../../Avatar");
    var styles_1 = require("./styles");
    var ListHeader = (0, react_1.forwardRef)(function (_a, ref) {
        var children = _a.children, _b = _a.isSelectedDefault, isSelectedDefault = _b === void 0 ? false : _b, isDisabled = _a.isDisabled, leadIcon = _a.leadIcon, trailIcon = _a.trailIcon, className = _a.className, style = _a.style, onClick = _a.onClick, _c = _a.viewType, viewType = _c === void 0 ? "basic" : _c, avatar = _a.avatar, _d = _a.size, size = _d === void 0 ? "l" : _d, props = (0, tslib_1.__rest)(_a, ["children", "isSelectedDefault", "isDisabled", "leadIcon", "trailIcon", "className", "style", "onClick", "viewType", "avatar", "size"]);
        var _e = (0, tslib_1.__read)((0, useStateProps_1.useStateProps)(isSelectedDefault), 2), isSelected = _e[0], setIsSelected = _e[1];
        var handleClick = function (event) {
            if (!isDisabled) {
                setIsSelected(!isSelected);
                onClick === null || onClick === void 0 ? void 0 : onClick(event);
            }
        };
        var trailContent = (0, react_1.useMemo)(function () {
            if (viewType === "collapse") {
                return (react_1.default.createElement(styles_1.IconWrapper, { className: "list-header__collapse-icon-wpapper" },
                    react_1.default.createElement(icons_1.IconBrokenArrowDown2, { className: "list-header__collapse-icon", width: 12, height: 12 })));
            }
            if (viewType === "arrow") {
                return (react_1.default.createElement(styles_1.IconWrapper, { className: "list-header__trail-content" },
                    react_1.default.createElement(icons_1.IconBrokenArrowRight, { width: 16, height: 16 })));
            }
            if (trailIcon) {
                return (react_1.default.createElement(styles_1.IconWrapper, { className: "list-header__trail-content" }, trailIcon));
            }
            return null;
        }, [viewType, trailIcon]);
        return (react_1.default.createElement(styles_1.ListHeaderStyled, (0, tslib_1.__assign)({ as: "div", isSelected: viewType === "basic" ? false : isSelected, isDisabled: isDisabled, className: className, style: style, size: size !== "s" ? size : "m", onClick: handleClick, ref: ref }, props),
            react_1.default.createElement(react_1.default.Fragment, null,
                !avatar && leadIcon && react_1.default.createElement(styles_1.IconWrapper, null, leadIcon),
                avatar && react_1.default.createElement(Avatar_1.Avatar, (0, tslib_1.__assign)({}, avatar, { isDisabled: isDisabled, size: "m" })),
                typeof children === "string" ? (react_1.default.createElement(H_1.default, { type: "capricornus", as: "h6" }, children)) : ({ children: children }),
                trailContent)));
    });
    ListHeader.displayName = "ListHeader";
    exports.default = ListHeader;
});
