import { createAppState } from "../app-state.js";
import { useCommandPaletteState } from "../../command-palette/hooks/use-command-palette-state.js";
import App_default from "../App.vue.js";
import { ROUTES } from "./routes.js";
import { createApp } from "vue";
import { createRouter, createWebHashHistory, createWebHistory } from "vue-router";
//#region src/v2/features/app/helpers/create-api-client-app.ts
/**
* Creates the appropriate router with the appropriate routes based on the layout
*/
var createAppRouter = (layout) => {
	if (layout === "web") return createRouter({
		history: createWebHistory(),
		routes: ROUTES
	});
	return createRouter({
		history: createWebHashHistory(),
		routes: ROUTES
	});
};
/**
* Create the API Client with router and passes in the workspace store as a prop
*/
var createApiClientApp = async (el, { layout = "desktop", plugins, customThemes, fallbackThemeSlug, fetchRegistryDocument, telemetry = true }) => {
	const router = createAppRouter(layout);
	const state = await createAppState({
		router,
		customThemes,
		fallbackThemeSlug,
		telemetryDefault: telemetry
	});
	const commandPaletteState = useCommandPaletteState();
	const app = createApp(App_default, {
		layout,
		plugins,
		getAppState: () => state,
		getCommandPaletteState: () => commandPaletteState,
		fetchRegistryDocument
	});
	app.use(router);
	if (!el) {
		console.error("[@scalar/api-client-modal] Could not create the API client.", "Invalid HTML element provided.", "Read more: https://github.com/scalar/scalar/tree/main/packages/api-client");
		return;
	}
	app.mount(el);
	return {
		app,
		state
	};
};
//#endregion
export { createApiClientApp, createAppRouter };

//# sourceMappingURL=create-api-client-app.js.map