This is a pigment called rhodopsin; it is actually the same pigment you use when you adjust to the dark. Mantids are used to study several visual systems in humans. the rhodopsin molecule in mantids is more similar to human rhodopsin than other known insects (flies).
Basically, when a light photon hits the center of the pigment molecule, it folds in half. This change in shape makes it easier to see in bright light. In the dark, it takes more time to return it to its original shape, and that is why it takes longer for your eyes to adjust to the dark than to the light.
In mantids, you can see the natural purple color of the rhodopsin in the eyes in the dark, and when you put them in bright light it will very rapidly disappear, leaving the eyes green. You'll notice the change back to purple takes longer, probably a couple of hours, in the dark.
Next time you go to the movies and have to adjust to the dark, think of your mantis and rhodopsin!
Next time you see a politician talking about "wasteful" spending on basic research on stuff like "what a bug sees," think about voting for someone else
Here is a wikipedia article with the full details of how it works. It uses lots of fancy words:
https://en.wikipedia.org/wiki/Visual_phototransduction