"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TreeListItemContextProvider = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = require("react");
const InfiniteTreeListContext_1 = require("../../../InfiniteTreeListContext");
const TreeListItemContext_1 = require("../TreeListItemContext");
const TreeListItemContextProvider = ({ item, children, onToggle, }) => {
    const [disabledReason, setDisabledReason] = (0, react_1.useState)();
    const { disabledIdList } = (0, react_1.useContext)(InfiniteTreeListContext_1.InfiniteTreeListContext);
    const isDisabled = (0, react_1.useMemo)(() => {
        return item.meta.path.some((id) => disabledIdList.has(id));
    }, [item.path, disabledIdList]);
    return ((0, jsx_runtime_1.jsx)(TreeListItemContext_1.TreeListItemContext.Provider, { value: {
            item,
            onToggle,
            isDisabled,
            disabledReason,
            setDisabledReason,
        }, children: children }));
};
exports.TreeListItemContextProvider = TreeListItemContextProvider;
