import { fetcher } from "../fetcher.mjs";
import { built_default } from "../config/dist/esm/built.mjs";

//#region ../@intlayer/cli/dist/esm/api/dist/esm/getIntlayerAPI/editor.mjs
const getEditorAPI = (authAPIOptions = {}, intlayerConfig) => {
	const editorURL = intlayerConfig?.editor?.editorURL ?? 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 fetcher(`${EDITOR_API_ROUTE}/config`, authAPIOptions, otherOptions)).data;
	};
	/**
	* Get the Intlayer configuration
	*/
	const getDictionaries = async (otherOptions = {}) => {
		return (await 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 fetcher(`${EDITOR_API_ROUTE}/dictionary`, authAPIOptions, otherOptions, {
		method: "POST",
		body
	});
	return {
		getDictionaries,
		getConfiguration,
		writeDictionary
	};
};

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