"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Container = void 0;
const react_1 = __importStar(require("react"));
const icons_1 = require("../../icons");
const inlines_1 = require("inlines");
const Styled_1 = require("../Styled");
const Text_1 = require("../Text");
const varsUtilities_1 = require("../../varsUtilities");
const Container = ({ color = 'default', children, style, divider, expandable, isExpanded, icon, onExpand, afterIcon, label, description, onClick, }) => {
    const [isExpandedState, setExpanded] = (0, react_1.useState)(false);
    if (isExpanded === undefined) {
        isExpanded = isExpandedState;
    }
    const contentColor = color === 'default' ? 'default' : 'inverted';
    const hasHeader = icon || label || description;
    return (react_1.default.createElement(inlines_1.styled.div, { style: {
            color: contentColor,
            display: 'flex',
            flexDirection: 'column',
            flexGrow: 1,
            borderRadius: 8,
            backgroundColor: (0, varsUtilities_1.color)('background', color, 'subtle'),
            border: (0, varsUtilities_1.border)(1),
            width: '100%',
            cursor: onClick ? 'pointer' : null,
            '@media (hover: hover)': {
                '&:hover': onClick
                    ? {
                        backgroundColor: (0, varsUtilities_1.color)('action', 'system', 'subtleHover'),
                    }
                    : null,
            },
            ...style,
        }, onClick: onClick },
        hasHeader ? (react_1.default.createElement(Styled_1.RowSpaced, { style: {
                cursor: !onClick && expandable ? 'pointer' : null,
                paddingLeft: 16,
                paddingRight: 16,
                paddingTop: 16,
                paddingBottom: divider || (label && !description) ? 16 : 4,
                position: 'relative',
                '@media (hover: hover)': {
                    '&:hover': !onClick && expandable
                        ? {
                            backgroundColor: (0, varsUtilities_1.color)('action', 'system', 'subtleHover'),
                        }
                        : null,
                },
                borderBottom: divider && !(expandable && !isExpanded) ? (0, varsUtilities_1.border)(1) : undefined,
            }, onClick: !onClick
                ? () => {
                    setExpanded(!isExpanded);
                    if (onExpand) {
                        onExpand(!isExpanded);
                    }
                }
                : null },
            react_1.default.createElement(Styled_1.Row, { style: {
                    gap: 12,
                    marginRight: 12,
                } },
                expandable ? (react_1.default.createElement(icons_1.IconChevronRight, { onClick: () => {
                        setExpanded(!isExpanded);
                        if (onExpand) {
                            onExpand(!isExpanded);
                        }
                    }, style: {
                        transition: 'transform 0.15s',
                        transform: isExpanded ? 'rotate(90deg)' : 'rotate(0deg)',
                    } })) : null,
                icon ? react_1.default.createElement(inlines_1.styled.div, null, icon) : null,
                react_1.default.createElement(Styled_1.Column, null,
                    react_1.default.createElement(Text_1.Text, { selectable: "none", weight: "strong", style: { marginBottom: description ? -6 : 0 } }, label),
                    react_1.default.createElement(Text_1.Text, { weight: "normal", light: true }, description))),
            react_1.default.createElement(Styled_1.Row, { style: {
                    gap: 12,
                    marginLeft: 12,
                } }, afterIcon ? afterIcon : null))) : null,
        !(expandable && !isExpanded) && children ? (react_1.default.createElement(inlines_1.styled.div, { style: {
                paddingLeft: 16,
                paddingRight: 16,
                paddingBottom: 16,
                marginTop: icon || description || divider ? 12 : hasHeader ? 4 : 16,
                flexGrow: 1,
            } }, children)) : null));
};
exports.Container = Container;
//# sourceMappingURL=index.js.map