@use 'generator' as *;

@mixin setup(
    $label,
    $class,
    $bpConfig
) {
    $styles: ();
    $directions: false;
    $increments: false;
    $multiples: false;
    $negatives: false;
    $pseudos: false;
    $dives: false;
    $breakpoints: false;

    @each $property, $value in $class {
        @each $configProperty, $configValue in $class { 
            @if $configProperty == styles {
                $styles: $configValue;
            } @else if $configProperty == breakpoints and $bpConfig {
                $breakpoints: $configValue;
            } @else if $configProperty == multiples {
                $multiples: $configValue;
            } @else if $configProperty == increments {
                $increments: $configValue;
            } @else if $configProperty == negatives {
                $negatives: $configValue;
            } @else if $configProperty == pseudos {
                $pseudos: $configValue;
            } @else if $configProperty == dives {
                $dives: $configValue;
            } @else if $configProperty == directions {
                $directions: $configValue;
            } @else if $configProperty != styles and $configProperty != breakpoints
                and $configProperty != multiples and $configProperty != increments
                and $configProperty != negatives and $configProperty != pseudos
                and $configProperty != dives and $configProperty != directions {
                @error 'Incorrect property #{$configProperty} in config for \'#{$label}\' utility';
            }
        }
    }

    @each $property, $value in $styles {
        @include generator(
            $label,
            $property,
            $value,
            $negatives,
            $directions,
            $increments,
            $dives,
            $pseudos,
            $multiples,
        );
    }
}
