/// Define component configuration for a brand.
///
/// @access public
/// @param {string} $component
/// @param {string} $brand
/// @param {map} $config
@mixin oBrandDefine($component, $brand, $config) {
	// @deprecated, map the deprecated "master" brand name to the core brand.
	@if $brand == 'master' {
		$brand: 'core';
	}
	// Validate brand name.
	$validated-brand-name: _oBrandValidateName('Brand', $brand, 'Cannot define brand "#{$brand}" for component "#{$component}"');
	// Validate component name.
	$validated-component-name: _oBrandValidateName('Component', $component, 'Cannot define brand "#{$brand}" for component "#{$component}"');
	// Validate config.
	$validated-config: _oBrandValidateConfig($component, $brand, $config);
	// Update config.
	$_o-brands: _oBrandRecursiveMapMerge($_o-brands, ($component: ($brand: $config))) !global;
}

/// Customise the brand variables for the current brand.
///
/// @access public
/// @param {string} $component
/// @param {map} $variables
@mixin oBrandCustomize($component, $variables) {
	@if $o-brand-debug {
		@debug 'Customising the "#{_oBrandGetCurrentValidBrand()}" brand version of the "#{$component}" component.'; // stylelint-disable-line at-rule-blacklist
	}
	// Validate component.
	$validated-component-name: _oBrandValidateName('Component', $component, 'Cannot customise component "#{$component}"');
	$existing-brand-config: _oBrandGetConfig($component, _oBrandGetCurrentValidBrand());
	@if type-of($existing-brand-config) != 'map' {
		@error 'Could not customise brand "#{_oBrandGetCurrentValidBrand()}" of the "#{$component}" component. Make sure that component supports the "#{_oBrandGetCurrentValidBrand()}" brand.';
	}
	// Variables.
	@if type-of($variables) != 'map' {
		@error 'Could not customise "#{$component}". oBrandCustomize expects variables of type map but found "#{type-of($variables)}".';
	}
	@if map-get($variables, 'supports-variants') {
		@error 'Could not customise "#{$component}". oBrandCustomize expects a map of brand variables to customise variants. It is not possible to add or remove support for variants.';
	}
	// Update config.
	$_o-brands: _oBrandRecursiveMapMerge($_o-brands, ($component: (_oBrandGetCurrentValidBrand(): ('variables': $variables)))) !global;
}
