const require_fetcher = require('../fetcher.cjs');
const require_built = require('../config/dist/esm/built.cjs');

//#region ../@intlayer/webpack/dist/esm/chokidar/dist/esm/api/dist/esm/getIntlayerAPI/user.mjs
const getUserAPI = (authAPIOptions = {}, intlayerConfig) => {
	const backendURL = intlayerConfig?.editor?.backendURL ?? require_built.built_default?.editor?.backendURL;
	if (!backendURL) throw new Error("Backend URL is not defined in the Intlayer configuration.");
	const USER_API_ROUTE = `${backendURL}/api/user`;
	/**
	* Retrieves a list of users based on filters and pagination.
	* @param filters - Filters and pagination options.
	* @returns List of users.
	*/
	const getUsers = async (filters, otherOptions = {}) => await require_fetcher.fetcher(USER_API_ROUTE, authAPIOptions, otherOptions, {
		cache: "no-store",
		params: filters
	});
	/**
	* Retrieves a user by ID.
	* @param userId - User ID.
	* @returns User object.
	*/
	const getUserById = async (userId, otherOptions = {}) => await require_fetcher.fetcher(`${USER_API_ROUTE}/${userId}`, authAPIOptions, otherOptions, { cache: "no-store" });
	/**
	* Retrieves a user by email.
	* @param email - User email.
	* @returns User object.
	*/
	const getUserByEmail = async (email, otherOptions = {}) => await require_fetcher.fetcher(`${USER_API_ROUTE}/email/${email}`, authAPIOptions, otherOptions, { cache: "no-store" });
	/**
	* Retrieves a user by account.
	* @param providerAccountId - The provider account ID.
	* @param provider - The provider of the account.
	*/
	const getUserByAccount = async (providerAccountId, provider, otherOptions = {}) => await require_fetcher.fetcher(`${USER_API_ROUTE}/account/${provider}/${providerAccountId}`, authAPIOptions, otherOptions, { cache: "no-store" });
	/**
	* Creates a new user.
	* @param user - User credentials.
	* @returns User object.
	*/
	const createUser = async (user, otherOptions = {}) => await require_fetcher.fetcher(`${USER_API_ROUTE}/`, authAPIOptions, otherOptions, {
		method: "POST",
		body: user
	});
	/**
	* Updates the user with the provided data.
	* @param user - Updated user data.
	* @returns User object.
	*/
	const updateUser = async (user, otherOptions = {}) => await require_fetcher.fetcher(`${USER_API_ROUTE}`, authAPIOptions, otherOptions, {
		method: "PUT",
		body: user
	});
	/**
	* Deletes a user with the provided ID.
	* @param userId - User ID.
	* @returns User object.
	*/
	const deleteUser = async (userId, otherOptions = {}) => await require_fetcher.fetcher(`${USER_API_ROUTE}/${userId}`, authAPIOptions, otherOptions, { method: "DELETE" });
	/**
	* Gets the verify email status URL to use in the SSE.
	* @param userId - User ID.
	* @returns The verify email status URL.
	*/
	const getVerifyEmailStatusURL = (userId) => `${USER_API_ROUTE}/verify-email-status/${String(userId)}`;
	return {
		createUser,
		getUsers,
		getUserById,
		getUserByAccount,
		getUserByEmail,
		updateUser,
		deleteUser,
		getVerifyEmailStatusURL
	};
};

//#endregion
exports.getUserAPI = getUserAPI;
//# sourceMappingURL=user.cjs.map