//
// These are functions that can be used by anyone.
//
@use "sass:map";
@use "sass:list";
@use "sass:meta";
@use "sass:color";
@use "contrast";

// Tint a color: mix a color with white
@function tint-color($color, $weight) {
	@return mix(white, $color, $weight);
}

// Shade a color: mix a color with black
@function shade-color($color, $weight) {
	@return mix(black, $color, $weight);
}

// Create a complement of the given color
@function complement-color($color, $weight) {
	@return color.complement($color);
}

// Get the given key from the map or the default value
@function get-or-default($map, $key, $default) {
	@return if(map.has-key($map, $key), map.get($map, $key), $default);
}

// Get a theme property var
@function themePropertyVar($variable_type, $variant, $component: false) {

	// Return the var like `--color-t-current-light-bg`
	// if the $variant is `light-bg`
	// and $variable_type is `color`
	$result: var(--#{$variable_type}-t-current-#{$variant});

	// If there is a component, prefer that!
	@if $component {
		$result: var(--#{$variable_type}-c-#{$component}-#{$variant}, $result);
	}

	@return $result;
}