// function to return a breakpoint value from the breakpoint map
// -----------------------------------------------------------------------------
@function bp($bp) {
  $match: nested-map-get($g-breakpoints, 1, $bp);
  @if $match {
    @return nth($match, 2);
  }
  // @warn "The breakpoint key '#{$bp}' is not in the map ’$g-breakpoints’";
  @return null;
}

// function to get the unit value of a number
// -----------------------------------------------------------------------------
@function getUnit($value) {
  @return str-slice($value * 0 + "", 2, -1);
}

// function to get a value by index from a nested map
// -----------------------------------------------------------------------------
@function nested-map-get($haystack, $target-index, $target-value) {
  $length: length($haystack);
  $match-found: false;
  $index: 1;

  @while (($index <= $length) and ($match-found != true)) {
    $match-found: $target-value == nth(nth($haystack, $index), $target-index);
    $index: $index + 1;
  }

  @if $match-found {
    @return nth($haystack, $index - 1);
  }

  // @warn "The nested key '#{$target-value}' was not found at index #{$target-index} inside of #{$haystack}.";
  @return false;
}
