/// Returns the value of one or more specific keys in a map, even if the key is nested
//// @group Map
/// @param {variable} $map [none] - map
/// @param {key} $keys [none] - key(s) from the map
@function map-deep-get($map, $keys...) {
  @each $key in $keys {
    $map: map-get($map, $key);
  }

  @return $map;
}

/// Sets the value for a specific key in a map, even if the key is nested
//// @group Map
/// @param {variable} $map [none] - map
/// @param {key} $keys [none] - keys from the map
@function map-deep-set($map, $keys...) {
  $map-list: ($map);
  $result: null;

  @if length($keys) == 2 {
    @return map-merge($map, (nth($keys, 1): nth($keys, -1)));
  }

  @for $i from 1 through length($keys) - 2 {
    $map-list: append($map-list, map-get(nth($map-list, -1), nth($keys, $i)));
  }

  @for $i from length($map-list) through 1 {
    $result: map-merge(nth($map-list, $i), (nth($keys, $i): if($i == length($map-list), nth($keys, -1), $result)));
  }

  @return $result;
}
