'use client';

import { useConfiguration } from "@intlayer/editor-react";
import { useQuery } from "@tanstack/react-query";
import { getOAuthAPI } from "@intlayer/api";
import configuration$1 from "@intlayer/config/built";

//#region src/hooks/useAuth/useOAuth2.ts
const useOAuth2 = (intlayerConfiguration) => {
	const configuration = useConfiguration();
	const config = intlayerConfiguration ?? configuration ?? configuration$1;
	const { data } = useQuery({
		queryKey: ["oAuth2AccessToken"],
		queryFn: getOAuthAPI(config).getOAuth2AccessToken,
		enabled: !!(config.editor.clientId && config.editor.clientSecret),
		staleTime: 0,
		gcTime: 0,
		refetchOnWindowFocus: false,
		refetchOnMount: false,
		refetchOnReconnect: false,
		refetchInterval: false,
		refetchIntervalInBackground: false
	});
	return { oAuth2AccessToken: data?.data };
};

//#endregion
export { useOAuth2 };
//# sourceMappingURL=useOAuth2.mjs.map