/* Made with love by @davi_mb */

//	Normal version
@mixin flexmix($direction:null, $wrap:null, $justify-content:null, $align-items:null, $align-content:null){
	// Setup the display property
	display: flex;

	//	$direction(flex-direction)
	@if $direction == r			{flex-direction: row;
	} @else if $direction == rr		{flex-direction: row-reverse;
	} @else if $direction == cl		{flex-direction: column;
	} @else if $direction == clr		{flex-direction: column-reverse;
	} @else if (
				($direction != null)						and
				($direction != r)								and
				($direction != row) 						and
				($direction != rr)							and
				($direction != row-reverse) 		and
				($direction != cl)							and
				($direction != column) 					and
				($direction != clr)							and
				($direction != column-reverse)
			){
				@error "Sorry, but `#{$direction}` is not a valid value or shortcut for flex-direction.";
			} @else if(
				($direction != null)						and
				($direction == row) 						or
				($direction == row-reverse) 		or
				($direction == column) 					or
				($direction == column-reverse)
			){
				flex-direction: $direction;
			};

	//	$wrap(flex-wrap)
	@if $wrap == w		{flex-wrap: wrap;
	} @else if $wrap == nw		{flex-wrap: nowrap;
	} @else if $wrap == wr		{flex-wrap: wrap-reverse;
	} @else if (
				($wrap != null)						and
				($wrap != w)							and
				($wrap != wrap) 					and
				($wrap != nw)							and
				($wrap != nowrap) 				and
				($wrap != wr)							and
				($wrap != wrap-reverse)
			){
				@error "Sorry, but `#{$wrap}` is not a valid value or shortcut for flex-wrap.";
			} @else if(
				($wrap != null)						and
				($wrap == wrap) 					or
				($wrap == nowrap) 				or
				($wrap == wrap-reverse)
			){
				flex-wrap: $wrap;
			};

	//	$justify-content(justify-content)
	@if $justify-content == fs 	{justify-content: flex-start
	} @else if $justify-content == fe 	{justify-content: flex-end
	} @else if $justify-content == c 	{justify-content: center
	} @else if $justify-content == sb 	{justify-content: space-between
	} @else if $justify-content == sa 	{justify-content: space-around
	} @else if (
			($justify-content != null)					and
			($justify-content != fs)						and
			($justify-content != flex-start) 		and
			($justify-content != fe)						and
			($justify-content != flex-end) 			and
			($justify-content != c)							and
			($justify-content != center) 				and
			($justify-content != sb)						and
			($justify-content != space-between)	and
			($justify-content != sa)						and
			($justify-content != space-around)
			){
				@error "Sorry, but `#{$justify-content}` is not a valid value or shortcut for justify-content";
			} @else if(
				($justify-content != null)					and
				($justify-content == flex-start) 		or
				($justify-content == flex-end) 			or
				($justify-content == center) 				or
				($justify-content == space-between)	or
				($justify-content == space-around)
			){
				justify-content: $justify-content;
			};

  //	$align-items (align-items)
	@if $align-items == fs	{align-items: flex-start;
	} @else if $align-items == fe	{align-items: flex-end;
	} @else if $align-items == c		{align-items: center;
	} @else if $align-items == bs		{align-items: baseline;
	} @else if $align-items == b		{align-items: baseline;
	} @else if $align-items == s		{align-items: stretch;
	} @else if (
			($align-items != null)				and
			($align-items != fs)					and
			($align-items != flex-start)	and
			($align-items != fe)					and
			($align-items != flex-end) 		and
			($align-items != c)						and
			($align-items != center)			and
			($align-items != b) 					and
			($align-items != bs) 					and
			($align-items != baseline)		and
			($align-items != s)						and
			($align-items != stretch)
			){
				@error "Sorry, but `#{$align-items}` is not a valid value or shortcut for align-items";
			} @else if(
				($align-items != null)				and
				($align-items == flex-start)	or
				($align-items == flex-end) 		or
				($align-items == center)			or
				($align-items == baseline)		or
				($align-items == stretch)
			){
				align-items: $align-items;
			};

  //	$align-content (align-content)
	@if $align-content == fs		{align-content: flex-start;
	} @else if $align-content == fe		{align-content: flex-end;
	} @else if $align-content == c			{align-content: center;
	} @else if $align-content == sb		{align-content: space-between;
	} @else if $align-content == sa		{align-content: space-around;
	} @else if $align-content == s			{align-content: stretch;
	} @else if (
			($align-content != null)					and
			($align-content != fs)						and
			($align-content != flex-start)		and
			($align-content != fe)						and
			($align-content != flex-end) 			and
			($align-content != c)							and
			($align-content != center)				and
			($align-content != sb) 						and
			($align-content != space-between)	and
			($align-content != sa)						and
			($align-content != space-around)	and
			($align-content != s)							and
			($align-content != stretch)
			){
				@error "Sorry, but `#{$align-content}` is not a valid value or shortcut for align-content";
			} @else if(
				($align-content != null)					and
				($align-content == flex-start)		or
				($align-content == flex-end) 			or
				($align-content == center)				or
				($align-content == space-between)	or
				($align-content == space-around)	or
				($align-content == stretch)
			){
				align-content: $align-content;
			};

};

// 	Redux version
@mixin flmx($direction:null, $wrap:null, $justify-content:null, $align-items:null, $align-content:null){
	// Setup the display property
	display: flex;

	//	$direction(flex-direction)
	@if $direction == r			{flex-direction: row;
	} @else if $direction == rr		{flex-direction: row-reverse;
	} @else if $direction == cl		{flex-direction: column;
	} @else if $direction == clr		{flex-direction: column-reverse;
	} @else if (
				($direction != null)						and
				($direction != r)								and
				($direction != row) 						and
				($direction != rr)							and
				($direction != row-reverse) 		and
				($direction != cl)							and
				($direction != column) 					and
				($direction != clr)							and
				($direction != column-reverse)
			){
				@error "Sorry, but `#{$direction}` is not a valid value or shortcut for flex-direction.";
			} @else if(
				($direction != null)						and
				($direction == row) 						or
				($direction == row-reverse) 		or
				($direction == column) 					or
				($direction == column-reverse)
			){
				flex-direction: $direction;
			};

	//	$wrap(flex-wrap)
	@if $wrap == w		{flex-wrap: wrap;
	} @else if $wrap == nw		{flex-wrap: nowrap;
	} @else if $wrap == wr		{flex-wrap: wrap-reverse;
	} @else if (
				($wrap != null)						and
				($wrap != w)							and
				($wrap != wrap) 					and
				($wrap != nw)							and
				($wrap != nowrap) 				and
				($wrap != wr)							and
				($wrap != wrap-reverse)
			){
				@error "Sorry, but `#{$wrap}` is not a valid value or shortcut for flex-wrap.";
			} @else if(
				($wrap != null)						and
				($wrap == wrap) 					or
				($wrap == nowrap) 				or
				($wrap == wrap-reverse)
			){
				flex-wrap: $wrap;
			};

	//	$justify-content(justify-content)
	@if $justify-content == fs 	{justify-content: flex-start
	} @else if $justify-content == fe 	{justify-content: flex-end
	} @else if $justify-content == c 	{justify-content: center
	} @else if $justify-content == sb 	{justify-content: space-between
	} @else if $justify-content == sa 	{justify-content: space-around
	} @else if (
			($justify-content != null)					and
			($justify-content != fs)						and
			($justify-content != flex-start) 		and
			($justify-content != fe)						and
			($justify-content != flex-end) 			and
			($justify-content != c)							and
			($justify-content != center) 				and
			($justify-content != sb)						and
			($justify-content != space-between)	and
			($justify-content != sa)						and
			($justify-content != space-around)
			){
				@error "Sorry, but `#{$justify-content}` is not a valid value or shortcut for justify-content";
			} @else if(
				($justify-content != null)					and
				($justify-content == flex-start) 		or
				($justify-content == flex-end) 			or
				($justify-content == center) 				or
				($justify-content == space-between)	or
				($justify-content == space-around)
			){
				justify-content: $justify-content;
			};

	//	$align-items (align-items)
	@if $align-items == fs	{align-items: flex-start;
	} @else if $align-items == fe	{align-items: flex-end;
	} @else if $align-items == c		{align-items: center;
	} @else if $align-items == bs		{align-items: baseline;
	} @else if $align-items == b		{align-items: baseline;
	} @else if $align-items == s		{align-items: stretch;
	} @else if (
			($align-items != null)				and
			($align-items != fs)					and
			($align-items != flex-start)	and
			($align-items != fe)					and
			($align-items != flex-end) 		and
			($align-items != c)						and
			($align-items != center)			and
			($align-items != b) 					and
			($align-items != bs) 					and
			($align-items != baseline)		and
			($align-items != s)						and
			($align-items != stretch)
			){
				@error "Sorry, but `#{$align-items}` is not a valid value or shortcut for align-items";
			} @else if(
				($align-items != null)				and
				($align-items == flex-start)	or
				($align-items == flex-end) 		or
				($align-items == center)			or
				($align-items == baseline)		or
				($align-items == stretch)
			){
				align-items: $align-items;
			};

	//	$align-content (align-content)
	@if $align-content == fs		{align-content: flex-start;
	} @else if $align-content == fe		{align-content: flex-end;
	} @else if $align-content == c			{align-content: center;
	} @else if $align-content == sb		{align-content: space-between;
	} @else if $align-content == sa		{align-content: space-around;
	} @else if $align-content == s			{align-content: stretch;
	} @else if (
			($align-content != null)					and
			($align-content != fs)						and
			($align-content != flex-start)		and
			($align-content != fe)						and
			($align-content != flex-end) 			and
			($align-content != c)							and
			($align-content != center)				and
			($align-content != sb) 						and
			($align-content != space-between)	and
			($align-content != sa)						and
			($align-content != space-around)	and
			($align-content != s)							and
			($align-content != stretch)
			){
				@error "Sorry, but `#{$align-content}` is not a valid value or shortcut for align-content";
			} @else if(
				($align-content != null)					and
				($align-content == flex-start)		or
				($align-content == flex-end) 			or
				($align-content == center)				or
				($align-content == space-between)	or
				($align-content == space-around)	or
				($align-content == stretch)
			){
				align-content: $align-content;
			};

};

//	Short version
@mixin fm($direction:null, $wrap:null, $justify-content:null, $align-items:null, $align-content:null){
	// Setup the display property
	display: flex;

	//	$direction(flex-direction)
	@if $direction == r			{flex-direction: row;
	} @else if $direction == rr		{flex-direction: row-reverse;
	} @else if $direction == cl		{flex-direction: column;
	} @else if $direction == clr		{flex-direction: column-reverse;
	} @else if (
				($direction != null)						and
				($direction != r)								and
				($direction != row) 						and
				($direction != rr)							and
				($direction != row-reverse) 		and
				($direction != cl)							and
				($direction != column) 					and
				($direction != clr)							and
				($direction != column-reverse)
			){
				@error "Sorry, but `#{$direction}` is not a valid value or shortcut for flex-direction.";
			} @else if(
				($direction != null)						and
				($direction == row) 						or
				($direction == row-reverse) 		or
				($direction == column) 					or
				($direction == column-reverse)
			){
				flex-direction: $direction;
			};

	//	$wrap(flex-wrap)
	@if $wrap == w		{flex-wrap: wrap;
	} @else if $wrap == nw		{flex-wrap: nowrap;
	} @else if $wrap == wr		{flex-wrap: wrap-reverse;
	} @else if (
				($wrap != null)						and
				($wrap != w)							and
				($wrap != wrap) 					and
				($wrap != nw)							and
				($wrap != nowrap) 				and
				($wrap != wr)							and
				($wrap != wrap-reverse)
			){
				@error "Sorry, but `#{$wrap}` is not a valid value or shortcut for flex-wrap.";
			} @else if(
				($wrap != null)						and
				($wrap == wrap) 					or
				($wrap == nowrap) 				or
				($wrap == wrap-reverse)
			){
				flex-wrap: $wrap;
			};

	//	$justify-content(justify-content)
	@if $justify-content == fs 	{justify-content: flex-start
	} @else if $justify-content == fe 	{justify-content: flex-end
	} @else if $justify-content == c 	{justify-content: center
	} @else if $justify-content == sb 	{justify-content: space-between
	} @else if $justify-content == sa 	{justify-content: space-around
	} @else if (
			($justify-content != null)					and
			($justify-content != fs)						and
			($justify-content != flex-start) 		and
			($justify-content != fe)						and
			($justify-content != flex-end) 			and
			($justify-content != c)							and
			($justify-content != center) 				and
			($justify-content != sb)						and
			($justify-content != space-between)	and
			($justify-content != sa)						and
			($justify-content != space-around)
			){
				@error "Sorry, but `#{$justify-content}` is not a valid value or shortcut for justify-content";
			} @else if(
				($justify-content != null)					and
				($justify-content == flex-start) 		or
				($justify-content == flex-end) 			or
				($justify-content == center) 				or
				($justify-content == space-between)	or
				($justify-content == space-around)
			){
				justify-content: $justify-content;
			};

  //	$align-items (align-items)
	@if $align-items == fs	{align-items: flex-start;
	} @else if $align-items == fe	{align-items: flex-end;
	} @else if $align-items == c		{align-items: center;
	} @else if $align-items == bs		{align-items: baseline;
	} @else if $align-items == b		{align-items: baseline;
	} @else if $align-items == s		{align-items: stretch;
	} @else if (
			($align-items != null)				and
			($align-items != fs)					and
			($align-items != flex-start)	and
			($align-items != fe)					and
			($align-items != flex-end) 		and
			($align-items != c)						and
			($align-items != center)			and
			($align-items != b) 					and
			($align-items != bs) 					and
			($align-items != baseline)		and
			($align-items != s)						and
			($align-items != stretch)
			){
				@error "Sorry, but `#{$align-items}` is not a valid value or shortcut for align-items";
			} @else if(
				($align-items != null)				and
				($align-items == flex-start)	or
				($align-items == flex-end) 		or
				($align-items == center)			or
				($align-items == baseline)		or
				($align-items == stretch)
			){
				align-items: $align-items;
			};

  //	$align-content (align-content)
	@if $align-content == fs		{align-content: flex-start;
	} @else if $align-content == fe		{align-content: flex-end;
	} @else if $align-content == c			{align-content: center;
	} @else if $align-content == sb		{align-content: space-between;
	} @else if $align-content == sa		{align-content: space-around;
	} @else if $align-content == s			{align-content: stretch;
	} @else if (
			($align-content != null)					and
			($align-content != fs)						and
			($align-content != flex-start)		and
			($align-content != fe)						and
			($align-content != flex-end) 			and
			($align-content != c)							and
			($align-content != center)				and
			($align-content != sb) 						and
			($align-content != space-between)	and
			($align-content != sa)						and
			($align-content != space-around)	and
			($align-content != s)							and
			($align-content != stretch)
			){
				@error "Sorry, but `#{$align-content}` is not a valid value or shortcut for align-content";
			} @else if(
				($align-content != null)					and
				($align-content == flex-start)		or
				($align-content == flex-end) 			or
				($align-content == center)				or
				($align-content == space-between)	or
				($align-content == space-around)	or
				($align-content == stretch)
			){
				align-content: $align-content;
			};

};
