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/editor.mjs
const getEditorAPI = (authAPIOptions = {}, intlayerConfig) => {
	const editorURL = intlayerConfig?.editor?.editorURL ?? require_built.built_default?.editor?.editorURL;
	if (!editorURL) throw new Error("Editor URL is not defined in the Intlayer configuration.");
	const EDITOR_API_ROUTE = `${editorURL}/api`;
	/**
	* Get the Intlayer configuration
	*/
	const getConfiguration = async (otherOptions = {}) => {
		return (await require_fetcher.fetcher(`${EDITOR_API_ROUTE}/config`, authAPIOptions, otherOptions)).data;
	};
	/**
	* Get the Intlayer configuration
	*/
	const getDictionaries = async (otherOptions = {}) => {
		return (await require_fetcher.fetcher(`${EDITOR_API_ROUTE}/dictionary`, authAPIOptions, otherOptions)).data;
	};
	/**
	* Adds a new dictionary to the database.
	* @param dictionary - Dictionary data.
	*/
	const writeDictionary = async (body, otherOptions = {}) => await require_fetcher.fetcher(`${EDITOR_API_ROUTE}/dictionary`, authAPIOptions, otherOptions, {
		method: "POST",
		body
	});
	return {
		getDictionaries,
		getConfiguration,
		writeDictionary
	};
};

//#endregion
exports.getEditorAPI = getEditorAPI;
//# sourceMappingURL=editor.cjs.map