// -----------------------------------------------------------------------------
// Error checks
// -----------------------------------------------------------------------------
// Table of contents:
// 1. Within
// 2. Outside

// -----------------------------------------------------------------------------
// 1. Within
// -----------------------------------------------------------------------------

/// Checks that it's being created within any of the passed $objs...
@function _should-be-called-within($objs...) {

    @each $obj in $objs {
        @if map-get($_bem-current-context, $obj) != null {
            @return true;
        }
    }

    @if $bem-throw-errors {
        @error 'It should be called within #{inspect($objs)}';
    }

    @return false;
}


// -----------------------------------------------------------------------------
// 2. Outside
// -----------------------------------------------------------------------------

/// Checks that it's being created outside all of the passed $objs...
@function _should-not-be-called-within($objs...) {

    @each $obj in $objs {
        @if map-get($_bem-current-context, $obj) != null {
            @if $bem-throw-errors {
                @error 'It should not be called within #{inspect($objs)}';
            }
            @return false;
        }
    }

    @return true;
}
