import { ApiClientEvents } from "../events/api-client-events.js";
import { eventBus } from "./eventEmitter.js";
import axios from "axios";
import { ApiV1AuthApi, Configuration } from "@loopstack/api-client";
function createApiClient(a) {
	let o = new Configuration({ baseOptions: {
		withCredentials: !0,
		headers: { "Content-Type": "application/json" }
	} }), s = axios.create();
	return s.interceptors.response.use((e) => e, (i) => ([401, 403].includes(i.response?.status) && eventBus.emit(ApiClientEvents.UNAUTHORIZED, a.id), i.code === "ERR_NETWORK" && eventBus.emit(ApiClientEvents.ERR_NETWORK, a.id), Promise.reject(i))), { auth: new ApiV1AuthApi(o, a.url, s) };
}
export { createApiClient };
