import { useMutation, } from '@tanstack/react-query';
import { NullSeamClientError, useSeamClient } from '../../lib/seam/use-seam-client.js';
export function useSeamMutation(endpointPath, options = {}) {
    const { endpointClient: client } = useSeamClient();
    return useMutation({
        ...options,
        mutationFn: async (variables) => {
            if (client === null)
                throw new NullSeamClientError();
            // Using @ts-expect-error over any is preferred, but not possible here because TypeScript will run out of memory.
            // Type assertion is needed here for performance reasons. The types are correct at runtime.
            const endpoint = client[endpointPath];
            return await endpoint(variables, options);
        },
    });
}
//# sourceMappingURL=use-seam-mutation.js.map