import VariablesExtractor from '../variables-extractor' ; import { EOL } from '../../util/regexp' ; import VariableStrategy from './__strategy-base' ; export const REGEXP = new RegExp ( `(var\\((--(?:[a-z]+[\-_a-z\\d]*))\\))(?!:)${ EOL }` , 'gi' ) ; export const REGEXP_ONE = new RegExp ( `^(var\\((--(?:[a-z]+[\-_a-z\\d]*))\\))(?!:)${ EOL }` , 'i' ) ; export const DECLARATION_REGEXP = new RegExp ( `(?:(--(?:[a-z]+[\\-_a-z\\d]*)\\s*):)${ EOL }` , 'gi' ) ; const RegexpExtractor = { getVariableNameFromDeclaration ( match ) { return ( match [ 1 ] || match [ 2 ] ) . trim ( ) ; } , getVariableNameFromUses ( match ) { return [ match [ 2 ] . trim ( ) , match [ 1 ] . trim ( ) ] ; } , getVariableNameFromUse ( match ) { return match [ 2 ] . trim ( ) ; } } ; const CssExtractor = new VariableStrategy ( 'CSS' , DECLARATION_REGEXP , REGEXP , REGEXP_ONE , RegexpExtractor ) ; VariablesExtractor . registerStrategy ( CssExtractor ) ; export default CssExtractor ;