# Path: mgz/util.py
# def get_version(game_version, save_version, log_version):
#     """Get version based on version fields."""
#     if game_version == 'VER 9.3':
#         return Version.AOK
#     if game_version == 'VER 9.4':
#         if log_version == 3:
#             return Version.AOC10
#         if log_version == 5 or save_version >= 12.97:
#             return Version.DE
#         if save_version >= 12.36:
#             return Version.HD
#         if log_version == 4:
#             return Version.AOC10C
#         return Version.AOC
#     if game_version == 'VER 9.8':
#         return Version.USERPATCH12
#     if game_version == 'VER 9.9':
#         return Version.USERPATCH13
#     if game_version == 'VER 9.A':
#         return Version.USERPATCH14RC2
#     if game_version in ['VER 9.B', 'VER 9.C', 'VER 9.D']:
#         return Version.USERPATCH14
#     if game_version in ['VER 9.E', 'VER 9.F']:
#         return Version.USERPATCH15
#     if game_version == 'MCP 9.F':
#         return Version.MCP
#     if log_version is not None or game_version != 'VER 9.4':
#         raise ValueError('unsupported version: {}, {}, {}'.format(game_version, save_version, log_version))
# 
# class Version(Enum):
#     """Version enumeration.
# 
#     Using consts from https://github.com/goto-bus-stop/recanalyst/blob/master/src/Model/Version.php
#     for consistency.
#     """
#     AOK = 1
#     AOC = 4
#     AOC10 = 5
#     AOC10C = 8
#     USERPATCH12 = 12
#     USERPATCH13 = 13
#     USERPATCH14 = 11
#     USERPATCH15 = 20
#     DE = 21
#     USERPATCH14RC2 = 22
#     MCP = 30
#     HD = 19


import io
import hashlib
import re
import struct
import uuid
import zlib
from mgz.util import get_version, Version
    hd_string(data)
    data.read(8)
    guid = data.read(16)
    lobby = hd_string(data)
    mod = hd_string(data)
    data.read(8)
    hd_string(data)
    data.read(4)
    return dict(
        players=players,
        guid=str(uuid.UUID(bytes=guid)),
        lobby=lobby.decode('utf-8'),
        mod=mod.decode('utf-8'),
        map_id=map_id,
        difficulty_id=difficulty_id
    )


def decompress(data):
    """Decompress header bytes."""
    prefix_size = 8
    header_len, _ = unpack('<II', data)
    zlib_header = data.read(header_len - prefix_size)
    return io.BytesIO(zlib.decompress(zlib_header, wbits=ZLIB_WBITS))


def parse_version(header, data):
    """Parse and compute game version."""
    log = unpack('<I', data)
    game, save = unpack('<7sxf', header)

# Path: mgz/util.py
# def get_version(game_version, save_version, log_version):
#     """Get version based on version fields."""
#     if game_version == 'VER 9.3':
#         return Version.AOK
#     if game_version == 'VER 9.4':
#         if log_version == 3:
#             return Version.AOC10
#         if log_version == 5 or save_version >= 12.97:
#             return Version.DE
#         if save_version >= 12.36:
#             return Version.HD
#         if log_version == 4:
#             return Version.AOC10C
#         return Version.AOC
#     if game_version == 'VER 9.8':
#         return Version.USERPATCH12
#     if game_version == 'VER 9.9':
#         return Version.USERPATCH13
#     if game_version == 'VER 9.A':
#         return Version.USERPATCH14RC2
#     if game_version in ['VER 9.B', 'VER 9.C', 'VER 9.D']:
#         return Version.USERPATCH14
#     if game_version in ['VER 9.E', 'VER 9.F']:
#         return Version.USERPATCH15
#     if game_version == 'MCP 9.F':
#         return Version.MCP
#     if log_version is not None or game_version != 'VER 9.4':
#         raise ValueError('unsupported version: {}, {}, {}'.format(game_version, save_version, log_version))
# 
# class Version(Enum):
#     """Version enumeration.
# 
#     Using consts from https://github.com/goto-bus-stop/recanalyst/blob/master/src/Model/Version.php
#     for consistency.
#     """
#     AOK = 1
#     AOC = 4
#     AOC10 = 5
#     AOC10C = 8
#     USERPATCH12 = 12
#     USERPATCH13 = 13
#     USERPATCH14 = 11
#     USERPATCH15 = 20
#     DE = 21
#     USERPATCH14RC2 = 22
#     MCP = 30
#     HD = 19


# Path: mgz/fast/header.py
import io
import hashlib
import re
import struct
import uuid
import zlib
from mgz.util import get_version, Version

    hd_string(data)
    data.read(8)
    guid = data.read(16)
    lobby = hd_string(data)
    mod = hd_string(data)
    data.read(8)
    hd_string(data)
    data.read(4)
    return dict(
        players=players,
        guid=str(uuid.UUID(bytes=guid)),
        lobby=lobby.decode('utf-8'),
        mod=mod.decode('utf-8'),
        map_id=map_id,
        difficulty_id=difficulty_id
    )


def decompress(data):
    """Decompress header bytes."""
    prefix_size = 8
    header_len, _ = unpack('<II', data)
    zlib_header = data.read(header_len - prefix_size)
    return io.BytesIO(zlib.decompress(zlib_header, wbits=ZLIB_WBITS))


def parse_version(header, data):
    """Parse and compute game version."""
    log = unpack('<I', data)
    game, save = unpack('<7sxf', header)

    version = get_version(game.decode('ascii'), round(save, 2), log)