Pattern switcher source code