from typing import List
import random

def gen_random_color():
    red = random.randint(0, 255)
    green = random.randint(0, 255)
    blue = random.randint(0, 255)

    # combine the values into a hexadecimal color code
    color_code = "#{:02x}{:02x}{:02x}".format(red, green, blue)
    return color_code

def gen_raw_label(labels: List[str]):
    """gen raw label for cvat tool

    {
        "name": "no_key",
        "color": "#33ddff",
        "type": "any",
        "attributes": []
    },

    Args:
        labels (List[str]): _description_
    """
    raw_label = []
    for label in labels:
        item = {
            "name": label, 
            "color": gen_random_color(),
            "type": "any",
            "attributes": []
        }
        raw_label.append(item)

    return raw_label



if __name__ == "__main__":
    labels = [
        # id invoice
        'no_key',    # số hóa đơn
        'no_value', 
        'form_key',    # mẫu số hóa đơn
        'form_value', 
        'serial_key',     # số kí hiệu hoá đơn
        'serial_value', 
        'date', 

        # seller info
        'seller_company_name_key', 
        'seller_company_name_value', 
        'seller_tax_code_key', 
        'seller_tax_code_value', 
        'seller_address_value',
        'seller_address_key', 
        'seller_mobile_key', 
        'seller_mobile_value', 

        # Not yet support seller_bank_no, seller_bank_name
        # 'seller_name_key', 
        # 'seller_name_value', 
        # 'seller_company_name_value',   -> seller_name_value
        
        # buyer info
        'buyer_name_key',
        'buyer_name_value', 
        'buyer_company_name_value', 
        'buyer_company_name_key', 
        'buyer_tax_code_key', 
        'buyer_tax_code_value', 
        'buyer_address_key', 
        'buyer_address_value', 
        'buyer_mobile_key',
        'buyer_mobile_value',

        # money info
        'VAT_amount_key', 
        'VAT_amount_value', 
        'total_key', 
        'total_value', 
        'total_in_words_key', 
        'total_in_words_value',
        
        'other', 
    ]

    raw_label =  gen_raw_label(labels)
    print(raw_label)