@charset 'utf-8';

/*  ========================================================================
    JUICE -> UTILITIES -> FUNCTIONS -> MAPS
    ========================================================================  */

/**
 * A map get wrapper for simplifying variable extraction from maps.
 * @param  {string}  $map  The map.
 * @param  {string}  $key  The map key.
 * @return {mixed}
 */
@function map($map, $key) {
    // Check if the key exists in the map
    @if map-has-key($map, $key) {
        // Return the key value
        @return map-get($map, $key);
    } @else {
        // Display a warning and return null
        @warn 'Unknown map key "#{$key}"';
        @return null;
    }
}

/**
 * Get a color from the base color palette.
 * @param  {string}  $name  The base color name.
 * @return {mixed}          The base color value, null otherwise.
 */
@function base-color($name) {
    // Return the base color value
    @return map($base-color-palette, $name);
}

/**
 * Get a color from the feedback color palette.
 * @param  {string}  $name  The feedback color name.
 * @return {mixed}          The feedback color value, null otherwise.
 */
@function feedback-color($name) {
    // Return the feedback color value
    @return map($feedback-color-palette, $name);
}

/**
 * Get a color from the font color palette.
 * @param  {string}  $name  The font color name.
 * @return {mixed}          The font color value, null otherwise.
 */
@function font-color($name: 'default') {
    // Return the font color value
    @return map($font-color-palette, $name);
}

/**
 * Get a z-index from the stack indexes.
 * @param  {string}  $stack  The z-index stack name.
 * @return {mixed}           The z-index stack value, null otherwise.
 */
@function stack-index($stack) {
    // Return the z-index stack value
    @return map($stack-indexes, $stack);
}

/**
 * Get a easing cubic bezier value from the easing types.
 * @param  {string}  $type  The easing type name.
 * @return {mixed}          The easing cubic bezier value, null otherwise.
 */
@function easing($type) {
    // Return the easing cubic bezier value
    @return map($easings, $type);
}
