capacitor and resistor combination
Keyword is capacitive reactance. Capacitor is used instead of an actual resistor to avoid heat loss. 1M resistor is only to discharge capacitor when not under power (safety measure).

Your circuit is overly complicated, but in essence to power a led from mains input you need to drop most of the voltage on something that acts like a resistor but does not get hot.