import { useUser } from "./useUser.mjs";
import { c } from "react-compiler-runtime";
import { useLocation } from "react-router-dom";
import { useIsAuthenticated, useMsal } from "@azure/msal-react";
//#region src/utilities/auth/useAuthedUser.ts
/**
* Hook that provides a returnTo string for the current location
*/
function useCurrentPageReturnTo() {
	const $ = c(4);
	const { pathname, search, hash } = useLocation();
	const t0 = String(pathname);
	const t1 = String(search);
	const t2 = String(hash);
	let t3;
	if ($[0] !== t0 || $[1] !== t1 || $[2] !== t2) {
		t3 = {
			pathname: t0,
			search: t1,
			hash: t2
		};
		$[0] = t0;
		$[1] = t1;
		$[2] = t2;
		$[3] = t3;
	} else t3 = $[3];
	return t3;
}
const useIsAuthed = () => {
	return useIsAuthenticated();
};
/**
* Hook used on routes that require a logged in user to ensure that the user is logged in
* @see {@link useUser}
*/
const useAuthedUser = () => {
	const { inProgress } = useMsal();
	const isAuthenticated = useIsAuthed();
	const user = useUser();
	if (isAuthenticated || inProgress) return user;
	else return null;
};
//#endregion
export { useAuthedUser, useCurrentPageReturnTo, useIsAuthed };

//# sourceMappingURL=useAuthedUser.mjs.map