type Index < TValue = string > = Record < string , TValue > ; export type InjectorIndexes = [ getIndex : ( selector ? : string | undefined , condition ? : string | undefined ) => Index < string > , keyframesIndex : Index , fontFaceIndex : string [ ] , clone : ( ) => InjectorIndexes , plainIndex : Index , plainSupportsIndex : Index < Index > , selectorIndex : Index < Index > , selectorSupportsIndex : Index < Index < Index > > ] ; export function createInjectorIndexes ( plainIndex = { } , plainSupportsIndex = { } , selectorIndex = { } , selectorSupportsIndex = { } , keyframesIndex = { } , fontFaceIndex = [ ] ) { return [ ( selector ? , condition ? ) => { let index = plainIndex ; if ( condition ) { if ( selector ) { selectorSupportsIndex [ condition ] ??= { } ; selectorSupportsIndex [ condition ] [ selector ] ??= { } ; index = selectorSupportsIndex [ condition ] [ selector ] ; } else { plainSupportsIndex [ condition ] ??= { } ; index = plainSupportsIndex [ condition ] ; } } else if ( selector ) { selectorIndex [ selector ] ??= { } ; index = selectorIndex [ selector ] ; } return index ; } , keyframesIndex , fontFaceIndex , ( ) => createInjectorIndexes ( clone ( plainIndex ) , clone ( plainSupportsIndex ) , clone ( selectorIndex ) , clone ( selectorSupportsIndex ) , clone ( keyframesIndex ) , fontFaceIndex . slice ( 0 ) ) , plainIndex , plainSupportsIndex , selectorIndex , selectorSupportsIndex , ] ; } function clone < TIndex extends Index < string | Index | Index < Index > > > ( index ) { const copy = { } ; for ( const key in index ) { const value = index [ key ] ; if ( typeof value === 'string' ) { copy [ key ] = value ; } else { copy [ key ] = clone ( value ) ; } } return copy as TIndex ; }