import struct


def color_byte_chunk(color: dict) -> bytes:
    """
    Build up a byte-chunk for a color in the correct
    format required for an Adobe ASE file.

    credit: https://github.com/nsfmc/swatch

    :returns: byte-chunk for a color
    """
    title = color["name"] + "\0"
    title_length = len(title)
    # Big-Endian Unsigned Short == len(color_name)
    chunk = struct.pack(">H", title_length)
    # UTF-16BE Encoded color_name terminated with '\0'
    chunk += title.encode("utf-16be")
    # grab the color information
    mode = color["data"]["mode"].encode()
    values = color["data"]["values"]
    # encode the color mode
    padded_mode = mode.decode().ljust(4).encode()
    # the color mode
    chunk += struct.pack("!4s", padded_mode)
    # the color values
    chunk += struct.pack("!fff", *values)
    # encode the color type `Process`
    chunk += struct.pack(">h", 2)
    # prepend the chunk size
    chunk = struct.pack(">I", len(chunk)) + chunk
    # retrun the swatch color header + swatch bytes
    return b"\x00\x01" + chunk