import type { VariantHandler } from '@unocss/core' ; import { escapeRegExp } from '@unocss/core' ; export const variantMatcher = ( name , selector ? ) => { const re = new RegExp ( `^${ escapeRegExp ( name ) }[:-]` ) ; return ( input ) : VariantHandler | undefined => { const match = input . match ( re ) ; if ( match ) { return { matcher : input . slice ( match [ 0 ] . length ) , selector , } ; } } ; } ; export const variantParentMatcher = ( name , parent ) => { const re = new RegExp ( `^${ escapeRegExp ( name ) }[:-]` ) ; return ( input ) : VariantHandler | undefined => { const match = input . match ( re ) ; if ( match ) { return { matcher : input . slice ( match [ 0 ] . length ) , parent , } ; } } ; } ;