import { createApp as u } from "vue";
import { createRouter as p, createWebHistory as d, createWebHashHistory as f } from "vue-router";
import A from "../App.vue.js";
/* empty css          */
import { createAppState as h } from "../app-state.js";
import { ROUTES as c } from "./routes.js";
import { useCommandPaletteState as S } from "../../command-palette/hooks/use-command-palette-state.js";
const b = (t) => t === "web" ? p({ history: d(), routes: c }) : p({ history: f(), routes: c }), v = async (t, { layout: r = "desktop", plugins: i, customThemes: m, fallbackThemeSlug: n, fetchRegistryDocument: s }) => {
  const o = b(r), a = await h({
    router: o,
    customThemes: m,
    fallbackThemeSlug: n
  }), l = S(), e = u(A, {
    layout: r,
    plugins: i,
    getAppState: () => a,
    getCommandPaletteState: () => l,
    fetchRegistryDocument: s
  });
  if (e.use(o), !t) {
    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;
  }
  return e.mount(t), {
    app: e,
    state: a
  };
};
export {
  v as createApiClientApp,
  b as createAppRouter
};
