@import '@financial-times/math';
@import '@financial-times/o-brand/main';
@import '@financial-times/o-private-foundation/main';

@import 'src/scss/colors';
@import 'src/scss/brand';
@import 'src/scss/variables';
@import 'src/scss/placeholders';
@import 'src/scss/mixins';

/// Outputs all available features and styles for labels.
///
/// @param {Map} $opts ['sizes': ('big', 'small'), 'states': ( ... )] - Label options including sizes and states to output styles for.
/// @output The output includes the `.o-labels` class definition as well as class definitions for every variant.
/// @example scss - All label styles
///   @include oLabels();
/// @example scss - Standard label styles including big size and gold tier state variants
///   @include oLabels($opts: ('sizes': ('big'), 'states': ('tier-gold'));
/// @example scss - Indicator label styles including live and new variants
///   @include oLabels($opts: ('indicators': ('status': ('live', 'new')));
/// @example scss - Indicator label styles with inverse modifier class
///   @include oLabels($opts: ('indicators': ('status': ('live', 'new'), 'inverse': true));
/// @example scss - Timestamp label with inverse modifier class
///   @include oLabels($opts: ('timestamp': ('inverse': true));
/// @access public
@mixin oLabels($opts: ('sizes': $_o-labels-standard-sizes,
		'states': $_o-labels-standard-states,
		'indicators': ('status': $_o-labels-indicator-status,
			'inverse': true,
		),
		'timestamp': ('inverse': true,
		),
	)) {
	// Get standard labels to include
	$standard-label-sizes: map-get($opts, 'sizes');
	$standard-label-states: map-get($opts, 'states');
	// Get indicator labels to include
	$indicator-label-opts: map-get($opts, 'indicators');
	$indicator-label-opts: if(type-of($indicator-label-opts)=='map',
			$indicator-label-opts,
			());
	$indicator-label-status: map-get($indicator-label-opts, 'status');
	$indicator-label-inverse: map-get($indicator-label-opts, 'inverse');
	// Get whether to include the timestamp label
	$timestamp-label: map-get($opts, 'timestamp');
	$timestamp-label-inverse: if(type-of($timestamp-label)=='map',
			map-get($timestamp-label, 'inverse'),
			$timestamp-label);

	// Base standard label styles
	.o-labels {
		@include _oLabelsBaseContent();
	}

	// Standard label size variants
	@each $size in $_o-labels-standard-sizes {
		@if index($standard-label-sizes, $size) and _oLabelsSupports($size) {
			@include _oLabelsSize($size);
		}
	}

	// Standard label state variants
	@each $state in $_o-labels-standard-states {
		@if index($standard-label-states, $state) and _oLabelsSupports($state) {
			@include oLabelsAddState($state);
		}
	}

	// Timestamp label styles
	@if $indicator-label-status and _oLabelsSupports('timestamps') {
		.o-labels-timestamp {
			@include oLabelsTimestampContent();
		}

		@if $timestamp-label-inverse {
			.o-labels-timestamp--inverse {
				@extend %_o-labels-timestamp--inverse;
			}
		}
	}

	// Indicator label styles
	@if $indicator-label-status and _oLabelsSupports('indicators') {
		.o-labels-indicator {
			@include oLabelsIndicatorContent($opts: ('block': true,
				));
		}

		.o-labels-indicator__status {
			@include oLabelsIndicatorContent($opts: ('element': 'status',
				));
		}

		@each $indicator-status in $indicator-label-status {
			.o-labels-indicator--#{$indicator-status} {
				@include oLabelsIndicatorContent($opts: ('block': true,
						'modifier': $indicator-status,
					));
			}
		}

		@if $indicator-label-inverse {
			.o-labels-indicator--inverse {
				@extend %_o-labels-timestamp--inverse;
			}
		}

		.o-labels-indicator.o-labels-indicator--badge {
			padding: oPrivateSpacingByName('s1') oPrivateSpacingByName('s2');
			font-weight: oFontsWeight('bold');
			color: oPrivateFoundationGet('o3-color-palette-white');
			border-radius: div(2, 16) * 1rem;

			&.o-labels-indicator--live {
				// This needs to use the correct label tokens in the Design System
				background: oPrivateFoundationGet('o3-color-palette-crimson');
				line-height: oPrivateFoundationGet('o3-type-label-line-height');
				font-family: oPrivateFoundationGet('o3-type-label-font-family');
				font-size: oPrivateFoundationGet('o3-type-label-font-size');
				font-weight: oPrivateFoundationGet('o3-type-label-font-weight');
				text-transform: oPrivateFoundationGet('o3-type-label-text-case');
			}

			&.o-labels-indicator--closed {
				background: oPrivateFoundationGet('o3-color-palette-black-60');
			}
		}

		.o-labels-indicator.o-labels-indicator--badge.o-labels-indicator--inverse {

			&.o-labels-indicator--live,
			&.o-labels-indicator--closed {
				background: transparent;
			}
		}
	}
}

@if ($o-labels-is-silent ==false) {
	@include oLabels();

	// Set module to silent again
	$o-labels-is-silent: true !global;
}
