import path from "path";
import { viteID } from "../util.js";
const STYLE_EXTENSIONS = new Set([".css", ".pcss", ".postcss", ".scss", ".sass", ".styl", ".stylus", ".less"]);
function getStylesForURL(filePath, viteServer) {
  const css = new Set();
  function crawlCSS(id, scanned = new Set()) {
    const moduleName = viteServer.moduleGraph.idToModuleMap.get(id);
    if (!moduleName || !moduleName.id)
      return;
    scanned.add(moduleName.id);
    for (const importedModule of moduleName.importedModules) {
      if (!importedModule.id || scanned.has(importedModule.id))
        continue;
      const ext = path.extname(importedModule.url.toLowerCase());
      if (STYLE_EXTENSIONS.has(ext)) {
        css.add(importedModule.url);
      }
      crawlCSS(importedModule.id, scanned);
    }
  }
  crawlCSS(viteID(filePath));
  return css;
}
export {
  STYLE_EXTENSIONS,
  getStylesForURL
};
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vLi4vLi4vc3JjL2NvcmUvc3NyL2Nzcy50cyJdLAogICJtYXBwaW5ncyI6ICJBQUVBO0FBQ0E7QUFHTyxNQUFNLG1CQUFtQixJQUFJLElBQUksQ0FBQyxRQUFRLFNBQVMsWUFBWSxTQUFTLFNBQVMsU0FBUyxXQUFXO0FBTXJHLHlCQUF5QixVQUFlLFlBQTZDO0FBQzNGLFFBQU0sTUFBTSxJQUFJO0FBR2hCLG9CQUFrQixJQUFZLFVBQVUsSUFBSSxPQUFlO0FBRzFELFVBQU0sYUFBYSxXQUFXLFlBQVksY0FBYyxJQUFJO0FBQzVELFFBQUksQ0FBQyxjQUFjLENBQUMsV0FBVztBQUFJO0FBRW5DLFlBQVEsSUFBSSxXQUFXO0FBR3ZCLGVBQVcsa0JBQWtCLFdBQVcsaUJBQWlCO0FBQ3hELFVBQUksQ0FBQyxlQUFlLE1BQU0sUUFBUSxJQUFJLGVBQWU7QUFBSztBQUMxRCxZQUFNLE1BQU0sS0FBSyxRQUFRLGVBQWUsSUFBSTtBQUM1QyxVQUFJLGlCQUFpQixJQUFJLE1BQU07QUFDOUIsWUFBSSxJQUFJLGVBQWU7QUFBQTtBQUV4QixlQUFTLGVBQWUsSUFBSTtBQUFBO0FBQUE7QUFJOUIsV0FBUyxPQUFPO0FBRWhCLFNBQU87QUFBQTsiLAogICJuYW1lcyI6IFtdCn0K
