@function __assign-defaults($map-value, $source-value, $args...) {
    @return if(
      __is-undefined($map-value) or __is-null($map-value),
      $source-value,
      $map-value);
}

@function __defaults($map: null, $args...) {
    @if $map == null {
        @return $map;
    }

    $arguments: ($map,);

    @each $arg in $args {
      $arguments: append($arguments, $arg);
    }

    $arguments: append($arguments, '__assign-defaults');

    @return __assign($arguments...);
}


/// Assigns own enumerable properties of source map(s) to the destination
/// map for all undefined destination properties. Once a
/// property is set, additional defaults of the same property are ignored.
///
///
/// @access public
/// @group Map
/// @param {Map} $map The destination map.
/// @param {Map...} $source... The source maps.
/// @returns {Map} Returns `$map` with defaults.
/// @example scss
/// $foo: _defaults(( 'user': 'barney' ), ( 'age': 36 ), ( 'user': 'fred' ));
/// // => ( 'user': 'barney', 'age': 36 )

@function _defaults($args...) {
    @return call(get-function('__defaults'), $args...);
}
