import config from './config' ; import { StitchwindInternalConfig } from '../stitches' ; type index = string | number ; type AnObject = { [ key in index ] : any ; } ; function refit_keys ( o , map ) { var build , key , destKey , value ; build = { } ; for ( key in o ) { destKey = map ( key ) || key ; value = o [ key ] ; if ( typeof value === "object" ) { value = refit_keys ( value , map ) ; } build [ destKey ] = value ; } return build ; } export function usePrefix < T extends StitchwindInternalConfig > ( prefix , config ) { return { ... config , tokens : refit_keys ( config . tokens , ( key ) => key . replace ( '$' , prefix ) ) } ; } type BreakpointSet < T extends StitchwindInternalConfig > = Record < keyof T [ 'breakpoints' ] , ( css : string ) => string > ; function prepConfig < T extends StitchwindInternalConfig > ( config ) { const breakpoints = config . breakpoints ; const breakpointFunctions = { } as BreakpointSet < T > ; for ( const size in breakpoints ) { breakpointFunctions [ size as keyof T [ 'breakpoints' ] ] = ( rule ) : string => `@media (min-width: ${ breakpoints [ size ] }) { ${ rule } }` ; } return { ... config , breakpoints : breakpointFunctions } ; } const stitchwindConfig = prepConfig ( config ) ; export default stitchwindConfig ;