Nonlocal theory of material media