import { normalizePath } from "vite";
import { runHookServerSetup } from "../integrations/index.js";
function astroIntegrationsContainerPlugin({
  settings,
  logging
}) {
  return {
    name: "astro:integration-container",
    configureServer(server) {
      runHookServerSetup({ config: settings.config, server, logging });
    },
    async buildStart() {
      settings.resolvedInjectedRoutes = await Promise.all(
        settings.injectedRoutes.map((route) => resolveEntryPoint.call(this, route))
      );
    }
  };
}
async function resolveEntryPoint(route) {
  const resolvedId = await this.resolve(route.entryPoint).then((res) => res == null ? void 0 : res.id).catch(() => void 0);
  if (!resolvedId)
    return route;
  const resolvedEntryPoint = new URL(`file://${normalizePath(resolvedId)}`);
  return { ...route, resolvedEntryPoint };
}
export {
  astroIntegrationsContainerPlugin as default
};
