/*
 |--------------------------------------------------------------------------
 |  Map Deep Get Function
 |--------------------------------------------------------------------------
 */

@function map-deep-get($map, $keys...) {
  @each $key in $keys {
    $map: map-get($map, $key);
  }
  @return $map;
}


/*
 |--------------------------------------------------------------------------
 |  Map Deep Get Function
 |--------------------------------------------------------------------------
 */

@function recursive-map-merge($map1, $map2) {
  @if ((type-of($map1) == map or type-of($map1) == list) and (type-of($map2) == map or type-of($map2) == list)) {
    $result: $map1;
    @each $key, $value in $map2 {
      @if (type-of(map-get($result, $key)) == map and type-of($value) == map) {
        $result: map-merge($result, ($key: recursive-map-merge(map-get($result, $key), $value)));
      }
      @else {
        $result: map-merge($result, ($key: $value));
      }
    }
    @return $result;
  }
  @else {
    @warn 'recursive-map-merge() expects it\'s parameters to be map types!';
    @return null;
  }
}


/*
 |--------------------------------------------------------------------------
 |  Strip Unit Function
 |--------------------------------------------------------------------------
 */

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


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

/// Replace `$search` with `$replace` in `$string`
/// @author Hugo Giraudel
/// @param {String} $string - Initial string
/// @param {String} $search - Substring to replace
/// @param {String} $replace ('') - New value
/// @return {String} - Updated string
@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;
}
