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