import { useCallback } from 'react';
import { useSyncCollectionOnEntityReturn } from './useSyncCollectionOnEntityReturn';
export function useSyncCollectionOnEntityCreate(cachedState, getCollectionsToUpdate) {
    const updateCollection = useCallback((collection, entity) => {
        collection.addItem(entity);
    }, []);
    const checkIfViewSynced = useCallback(async (collection, entity) => {
        const updatedData = await collection.fetchData({
            ...collection.query.asComputed,
            page: 1,
            cursor: null,
            offset: 0,
        });
        return (collection.itemKey(updatedData.items[0]) === collection.itemKey(entity));
    }, [cachedState]);
    useSyncCollectionOnEntityReturn({
        cachedState,
        updateCollection,
        checkIfViewSynced,
        getEntityFromRouterState: (state) => state._createdEntity,
        getCollectionsToUpdate,
    });
}
//# sourceMappingURL=useSyncCollectionOnEntityCreate.js.map