// =============================================================================
// =ALEKSI - DEPTH
// =============================================================================
////
//// @group aleksi-lists
//// @author [Yoannis Jamar](https://yoannis.com)
//// @author [Hugo Giraudel]((http://hugogiraudel.com)

@import "aleksi/lists/is-list";
@import "aleksi/maps/map-depth";

// =depth( $list )
// -----------------------------------------------------------------------------
/// Returns the depth level of a list. If a single value is passed, it will
/// return 1.
/// **Note**: also accepts maps, which delegates to `map-depth()`.
///
/// @param {list|map} $list - The list to analyze.
///
/// @return {number} - The depth of `$list`.
///
/// @example scss
///   $foo: depth(10 true 'foo' ('bar' 'baz') );
///     // => 2
///   $bar: depth(10 true 'foo');
///     // => 1
///   $baz: depth('foo');
///     // => 1
///
/// @access public
/// @since 0.1.0

@function depth( $list )
{
  @if type-of($list) == 'map' {
    @return map-depth($list);
  }

  $lvl: 1;

  @each $item in $list
  {
    @if is-list($item) {
      $lvl: max(depth($item) + 1, $lvl);
    }
  }

  @return $lvl;
}