What the fuck? Pokemon is not allowed to go this hard. This is straight up an episode from the original Twilight Zone.
I looked into who did the screenplay/script for this episode, and it turned out to be this guy, Masashi Sogo:
https://www.animenewsnetwork.com/encyclopedia/people.php?id=10424. Most of the episodes he's worked on for ADV were fillers, mostly May and Max focused, as well as the Pacifidlog and Saffron Contests (Harley-focused). Also he worked on the Trust and Betrayal OVA for Rurouni Kenshin, Gantz, the first couple hundred episodes of Bleach, and a bunch of other children's anime (Yugioh, Zoids Wilds, Tokyo Mew Mew). That's a hell of a pedigree. I'm glad the guy continues getting work. His episodes of Pokemon aren't super consistent or anything, but his May-centered ones tend to be among the best.