import { useLoginToken } from "@contember/react-client";
import { useMemo } from "react";
import { GQLVariable } from "../../lib/variables.js";
import { useSingleTenantMutation } from "../../lib/useSingleTenantMutation.js";
const LOGIN_MUTATION = `
		signIn(email: $email, password: $password, expiration: $expiration, otpToken: $otpToken) {
			ok
			error {
				code
				endUserMessage
			}
			result {
				token
				person {
					id
					email
				}
			}
		}
`;
const loginVariables = {
  email: GQLVariable.Required(GQLVariable.String),
  password: GQLVariable.Required(GQLVariable.String),
  expiration: GQLVariable.Int,
  otpToken: GQLVariable.String
};
const useSignIn = () => {
  const loginToken = useLoginToken();
  return useSingleTenantMutation(LOGIN_MUTATION, loginVariables, useMemo(() => ({
    apiTokenOverride: loginToken,
    headers: {
      "X-Contember-Token-Path": "data.result.result.token"
    }
  }), [loginToken]));
};
const useLogin = useSignIn;
export {
  useLogin,
  useSignIn
};
//# sourceMappingURL=signIn.js.map
