import { useWixPatternsContainer, useWixPatternsContainerOverrides, useCreateCollection, useCreateOptimisticActions, } from '@wix/bex-core/react';
import { LayoutSwitchState, } from '../state/LayoutSwitchState';
import { useOptionalCachedState } from './useOptionalCachedState';
export const useLayoutSwitchCollection = (config) => {
    const container = useWixPatternsContainer();
    const containerOverrides = useWixPatternsContainerOverrides();
    const createCollection = useCreateCollection();
    const createOptimisticActions = useCreateOptimisticActions();
    const state = useOptionalCachedState(() => {
        const collection = createCollection(config);
        const spreadsheet = config.spreadsheet
            ? {
                ...config.spreadsheet,
                createOptimisticActions: (c) => createOptimisticActions(c),
            }
            : undefined;
        return new LayoutSwitchState({
            collection,
            container,
            containerOverrides,
            table: config.table,
            grid: config.grid,
            spreadsheet,
        });
    });
    return state;
};
//# sourceMappingURL=useLayoutSwitchCollection.js.map