import { mergeDeep } from 'unocss' ; import { DEFAULT } from './default' ; function getCSS ( selectorProse , className , preflights ) { let css = '' ; for ( const selector in preflights ) { const cssDeclarationBlock = preflights [ selector ] ; const pseudoCSSMatchArray = selector . split ( ',' ) . map ( ( s ) => { const match = s . match ( /::?(?:[\(\)\:\-\d\w]+)$/g ) ; if ( match ) { const matchStr = match [ 0 ] ; s = s . replace ( matchStr , '' ) ; return `${ selectorProse } :where(${ s }):not(.not-${ className })${ matchStr }` ; } } ) . filter ( ( v ) => v ) ; if ( pseudoCSSMatchArray . length ) { css += pseudoCSSMatchArray . join ( ',' ) ; } else { css += `${ selectorProse } :where(${ selector }):not(.not-${ className })` ; } css += '{' ; for ( const k in cssDeclarationBlock ) { const v = cssDeclarationBlock [ k ] ; css += `${ k }:${ v };` ; } css += '}' ; } return css ; } export function getPreflights ( selectorProse , className , cssExtend ? ) { if ( ! selectorProse . startsWith ( '[' ) ) { selectorProse = '.' + selectorProse ; } if ( cssExtend ) { return getCSS ( selectorProse , className , mergeDeep ( DEFAULT , cssExtend ) ) ; } return getCSS ( selectorProse , className , DEFAULT ) ; }