"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;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.FacetContainer = exports.RecommendedIconWithTooltip = void 0;
var react_1 = __importStar(require("react"));
var ui_i18n_1 = __importDefault(require("ui-i18n"));
var classnames_1 = __importDefault(require("classnames"));
var Close_1 = __importDefault(require("@mui/icons-material/Close"));
var CollapseButton_1 = require("../CollapseButton");
var SmallIconButton_1 = require("../SmallIconButton");
var withTooltip_1 = require("../HOCs/withTooltip");
var FacetTitle_1 = __importDefault(require("./components/FacetTitle/FacetTitle"));
var Recommended_1 = __importDefault(require("../icons/Recommended"));
var FacetContainer_module_css_1 = __importDefault(require("./FacetContainer.module.css"));
exports.RecommendedIconWithTooltip = (0, withTooltip_1.withTooltip)(Recommended_1.default);
var FacetContainer = function (_a) {
    var _b;
    var children = _a.children, title = _a.title, chipLabel = _a.chipLabel, pathToTitle = _a.pathToTitle, _c = _a.isOpenByDefault, isOpenByDefault = _c === void 0 ? true : _c, _d = _a.isHighlighted, isHighlighted = _d === void 0 ? false : _d, _e = _a.isRecommended, isRecommended = _e === void 0 ? false : _e, onDeleteChip = _a.onDeleteChip, onClose = _a.onClose;
    var _f = (0, react_1.useState)(isOpenByDefault), open = _f[0], setOpen = _f[1];
    var toggleOpen = function () {
        setOpen(!open);
    };
    return (react_1.default.createElement("div", { className: (0, classnames_1.default)(FacetContainer_module_css_1.default.facetContainer, (_b = {},
            _b[FacetContainer_module_css_1.default.openedFacetContainer] = open,
            _b[FacetContainer_module_css_1.default.closedFacetContainer] = !open,
            _b[FacetContainer_module_css_1.default.highlighted] = isHighlighted,
            _b)), "data-reltio-id": "search-facet-container-".concat(title) },
        react_1.default.createElement("div", { className: FacetContainer_module_css_1.default.titleContainer },
            react_1.default.createElement(SmallIconButton_1.SmallIconButtonWithTooltip, { tooltipTitle: ui_i18n_1.default.text('Remove'), icon: Close_1.default, onClick: onClose, className: FacetContainer_module_css_1.default.iconButton, size: "XXS" }),
            isRecommended && (react_1.default.createElement(exports.RecommendedIconWithTooltip, { className: FacetContainer_module_css_1.default.recommendedIcon, tooltipTitle: ui_i18n_1.default.text('Recommended'), showForDisabled: true })),
            react_1.default.createElement(FacetTitle_1.default, { title: title, pathToTitle: pathToTitle, chipLabel: chipLabel, onDelete: onDeleteChip, onClick: toggleOpen }),
            react_1.default.createElement(CollapseButton_1.CollapseButton, { onClick: toggleOpen, isOpen: open, className: FacetContainer_module_css_1.default.iconButton, size: "S", tooltipTitle: open ? ui_i18n_1.default.text('Collapse attribute') : ui_i18n_1.default.text('Expand attribute'), tooltipPlacement: "bottom-end" })),
        open ? children : null));
};
exports.FacetContainer = FacetContainer;
