// =============================================================================
// =ALEKSI - MAP-EXTEND
// =============================================================================
////
//// @group aleksi-maps
//// @author [Yoannis Jamar](https://yoannis.com)

@import "aleksi/general/throw";
@import "aleksi/lists/slice";

// =map-extend( $maps... )
// -----------------------------------------------------------------------------
/// Merges the given maps successively. Allows to merge more then two maps
/// at once.
///
/// @param {$map} $maps... - maps to merge
///
/// @return {map}
///
/// @access public
/// @since 0.6.0

@function map-extend( $maps... )
{
  @if length($maps) < 2 {
    $e: throw-warning('map-extend():: trying to extend one map only. Returning the map as is.');
    @return $nth($maps, 1);
  }

  $res: nth($maps, 1);
  @each $map in slice($maps, 2) {
    $res: map-merge($res, $map);
  }

  @return $res;
}
