import { getHealthCacheKey as e, getMeCacheKey as t } from "./query-keys.js";
import { useApiClient as n } from "./useApi.js";
import { useMutation as r, useQuery as i, useQueryClient as a } from "@tanstack/react-query";
//#region src/hooks/useAuth.ts
function o(e = !0) {
	let { envKey: r, api: a } = n();
	return i({
		queryKey: t(r),
		queryFn: () => a.auth.me(),
		retry: !1,
		staleTime: 300 * 1e3,
		enabled: e
	});
}
function s(t = !0) {
	let { envKey: r, api: a } = n();
	return i({
		queryKey: e(r),
		queryFn: () => a.auth.getInfo(),
		staleTime: 300 * 1e3,
		enabled: t
	});
}
function c() {
	let { envKey: i, api: o } = n(), s = a();
	return r({
		mutationFn: (e) => o.auth.hubLogin(e),
		onSuccess: () => {
			s.invalidateQueries({ queryKey: t(i) }), s.invalidateQueries({ queryKey: e(i) });
		}
	});
}
function l() {
	let { envKey: i, api: o } = n(), s = a();
	return r({
		mutationFn: () => o.auth.refresh(),
		onSuccess: () => {
			s.invalidateQueries({ queryKey: t(i) }), s.invalidateQueries({ queryKey: e(i) });
		}
	});
}
//#endregion
export { s as useGetHealthInfo, o as useMe, c as useWorkerAuth, l as useWorkerAuthTokenRefresh };
