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;
};
import React, { useCallback, useState } from 'react';
import { QuickViewCard } from '../UI/surfaces/cards/QuickViewCard';
/**
 * `useItemSubCard` hook
 */
export const useItemSubCard = (subCardsList) => {
    const [subCardType, setSubCardType] = useState('');
    const getSubCardInfo = useCallback((subCardTypeStr) => {
        const subCardInfo = subCardsList === null || subCardsList === void 0 ? void 0 : subCardsList[subCardTypeStr];
        if (!subCardInfo) {
            return {
                defaultColor: null,
                textColor: null,
                backgroundColor: null,
                icon: () => null
            };
        }
        return {
            defaultColor: subCardInfo.defaultColor,
            textColor: subCardInfo.textColor,
            backgroundColor: subCardInfo.backgroundColor,
            icon: subCardInfo.icon
        };
    }, [subCardsList]);
    const SubCard = useCallback((_a, child) => {
        var _b;
        var { cardInfo } = _a, rest = __rest(_a, ["cardInfo"]);
        return (React.createElement(QuickViewCard, null, (_b = subCardsList === null || subCardsList === void 0 ? void 0 : subCardsList[subCardType]) === null || _b === void 0 ? void 0 : _b.component(Object.assign({ cardInfo }, rest))));
    }, [subCardType, subCardsList]);
    return {
        SubCard,
        closeSubCard: () => setSubCardType(false),
        setSubCardType: (cardType) => setSubCardType(cardType),
        subCardType,
        getSubCardInfo
    };
};
//# sourceMappingURL=useItemSubCard.js.map