@use 'sass:string';
@use 'sass:map';
@use '../config' as *;

/// Declare CSS custom properties through Spruce to add the prefix.
/// @param {map} $vars - The CSS custom properties.
/// @return {null}
/// @throws {error} - If the CSS custom property name is invalid.
@mixin set-css-variable($vars) {
  @each $name, $value in $vars {
    @if string.index($name, --) != 1 {
      @error 'It seems that this is not a valid CSS custom property name.';
    }

    #{string.insert($name, '#{$internal-prefix}', 3)}: #{$value};
  }
}
