@function mapping($map, $key, $parse: false) {
    @if not map-has-key($map, $key) {
        @return $key;
    }

    @if not $parse {
        @return map-get($map, $key);
    }
    @else {
        @return #{map-get($map, $key)};
    }
}

@function strip-unit($value) {
    @return $value / ($value * 0 + 1);
}

@function str-replace($string, $search, $replace: '') {
    $index: str-index($string, $search);

    @if $index {
        @return str-slice($string, 1, $index - 1) + $replace + str-replace(str-slice($string, $index + str-length($search)), $search, $replace);
    }

    @return $string;
}

@function color($pallete, $key: 'default', $opacity: 1) {
    @return rgba(mapping($pallete, $key), $opacity);
}

@function font-size($key: 'default') {
    @return mapping($font-sizes, $key);
}

@function font-weight($key: 'normal') {
    @return mapping($font-weights, $key);
}

@function font-family($key: 'normal') {
    @return mapping($font-families, $key, true);
}

@function z-index($key: 'above') {
    @return mapping($z-indexes, $key);
}

@function border-radius($key: 'm') {
    @return mapping($border-radius, $key);
}

@function margins($key: 'default') {
    @return mapping($margins, $key);
}

@function module($key) {
    @return mapping($module, $key);
}
