import * as parseSelector from "postcss-selector-parser" ; import { convertScopeToModuleName } from "./convertScopeToModuleName" ; export function convertSelectorForEmotion ( selector , scope , knownScopes ) { return parseSelector ( ( nodes ) => { nodes . first . walkClasses ( ( node ) => { if ( node . toString ( ) === scope ) { node . toString = ( ) => "&" ; } else if ( knownScopes . has ( node . toString ( ) ) ) { node . toString = ( ) => ".${" + convertScopeToModuleName ( node . value ) + "}" ; } } ) ; } ) . processSync ( selector ) ; }