function RenderMedia({ mobile, tablet, desktop, hd })
{
	if(typeof window !== "undefined")
	{
		const variants = { mobile, tablet, desktop, hd };
		const keys = ["hd", "desktop", "tablet", "mobile"];

		if(window.matchMedia('(min-width: 1281px)').matches)
		{
			for(let i in keys)
			{
				if(variants[keys[i]] !== undefined && variants[keys[i]] !== null)
				{
					return variants[keys[i]];
				}
			}
		}

		if(window.matchMedia('(min-width: 1079px)').matches)
		{
			let k = keys.slice(1, keys.length);
			for(let i in k)
			{
				if(variants[k[i]] !== undefined && variants[k[i]] !== null)
				{
					return variants[k[i]];
				}
			}
		}

		if(window.matchMedia('(min-width: 737px)').matches)
		{
			let k = keys.slice(2, keys.length);
			for(let i in k)
			{
				if(variants[k[i]] !== undefined && variants[k[i]] !== null)
				{
					return variants[k[i]];
				}
			}
		}

		if(window.matchMedia('(max-width: 736px)').matches)
		{
			let k = keys.slice(3, keys.length);
			for(let i in k)
			{
				if(variants[k[i]] !== undefined && variants[k[i]] !== null)
				{
					return variants[k[i]];
				}
			}
		}
	}

	return null;
}

function MatchMedia()
{
	if(typeof window !== "undefined")
	{
		if(window.matchMedia('(min-width: 1281px)').matches)
		{ return "hd"; }

		if(window.matchMedia('(min-width: 961px)').matches)
		{ return "desktop"; }

		if(window.matchMedia('(min-width: 769px)').matches)
		{ return "tablet"; }

		if(window.matchMedia('(max-width: 768px)').matches)
		{ return "mobile"; }
	}

	return null;
}

export { RenderMedia, MatchMedia };