"use strict";
var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Accordion = exports.AccordionBase = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = require("react");
const core_1 = require("../core");
const list_1 = __importDefault(require("../list"));
const utils_1 = require("../utils");
const accordionItem_1 = __importDefault(require("./accordionItem"));
const accordionItemHorizontal_1 = __importDefault(require("./accordionItemHorizontal"));
const context_1 = require("./context");
exports.AccordionBase = core_1.styled.divBox `
  display: flex;
  min-width: 0;
  transition-duration: normal;
`;
/** Allows to show and hide sections of related content on a page. */
exports.Accordion = (0, core_1.vui)((props, ref) => {
    var _a, _b;
    const { children, className, items, orientation = 'vertical', iconPosition = 'end', size, variant } = props, rest = __rest(props, ["children", "className", "items", "orientation", "iconPosition", "size", "variant"]);
    const styles = (0, core_1.useStyleConfig)('Accordion', props);
    const context = (0, react_1.useMemo)(() => (0, utils_1.filterUndefined)({ size, variant }), [size, variant]);
    const aliasedProps = (0, utils_1.filterUndefined)({});
    const isVertical = orientation === 'vertical';
    return ((0, jsx_runtime_1.jsx)(context_1.AccordionProvider, { value: context, children: (0, jsx_runtime_1.jsx)(exports.AccordionBase, Object.assign({ borderLeft: isVertical
                ? undefined
                : `1px solid transparent
        `, borderTop: isVertical ? `1px solid transparent` : undefined, className: (0, utils_1.cs)('vui-accordion', className), ref: ref, w: "100%" }, styles.container, aliasedProps, rest, { children: isVertical ? ((0, jsx_runtime_1.jsx)(list_1.default, { w: "100%", children: items
                    ? (_a = items === null || items === void 0 ? void 0 : items.map) === null || _a === void 0 ? void 0 : _a.call(items, (item, key) => ((0, jsx_runtime_1.jsx)(accordionItem_1.default, Object.assign({ iconPosition: iconPosition }, item), key)))
                    : children })) : items ? ((_b = items === null || items === void 0 ? void 0 : items.map) === null || _b === void 0 ? void 0 : _b.call(items, (item, key) => (0, jsx_runtime_1.jsx)(accordionItemHorizontal_1.default, Object.assign({}, item), key))) : (children) })) }));
});
exports.Accordion.Item = accordionItem_1.default;
exports.Accordion.ItemHorizontal = accordionItemHorizontal_1.default;
exports.Accordion.displayName = 'Accordion';
exports.default = exports.Accordion;
//# sourceMappingURL=accordion.js.map