All the logics of Template:Flags are handled here. This module works together with Module:Flags/MasterData and Module:Flags/LocaleData, where the flags data is maintained.