Theory of resonances in the electromagnetic scattering by macroscopic bodies