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

//#region ../@intlayer/cli/dist/esm/chokidar/dist/esm/api/dist/esm/getIntlayerAPI/tag.mjs
const getTagAPI = (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 PROJECT_API_ROUTE = `${backendURL}/api/tag`;
	/**
	* Retrieves a list of tags based on filters and pagination.
	* @param filters - Filters and pagination options.
	*/
	const getTags = async (filters, otherOptions = {}) => await require_fetcher.fetcher(PROJECT_API_ROUTE, authAPIOptions, otherOptions, {
		cache: "no-store",
		params: filters
	});
	/**
	* Adds a new tag to the database.
	* @param tag - Tag data.
	*/
	const addTag = async (tag, otherOptions = {}) => await require_fetcher.fetcher(`${PROJECT_API_ROUTE}`, authAPIOptions, otherOptions, {
		method: "POST",
		body: tag
	});
	/**
	* Updates an existing tag in the database.
	* @param tag - Updated tag data.
	*/
	const updateTag = async (tagId, tag, otherOptions = {}) => await require_fetcher.fetcher(`${PROJECT_API_ROUTE}/${tagId}`, authAPIOptions, otherOptions, {
		method: "PUT",
		body: tag
	});
	/**
	* Deletes a tag from the database by its ID.
	* @param tagId - Tag ID.
	*/
	const deleteTag = async (tagId, otherOptions = {}) => await require_fetcher.fetcher(`${PROJECT_API_ROUTE}/${tagId}`, authAPIOptions, otherOptions, { method: "DELETE" });
	return {
		getTags,
		addTag,
		updateTag,
		deleteTag
	};
};

//#endregion
exports.getTagAPI = getTagAPI;
//# sourceMappingURL=tag.cjs.map