from enum import IntEnum, unique
from typing import Union

from . import zint


@unique
class Barcode(IntEnum):
    # Tbarcode 7 codes
    CODE11 = zint.BARCODE_CODE11 = 1
    C25MATRIX = zint.BARCODE_C25MATRIX = 2
    C25INTER = zint.BARCODE_C25INTER = 3
    C25IATA = zint.BARCODE_C25IATA = 4
    C25LOGIC = zint.BARCODE_C25LOGIC = 6
    C25IND = zint.BARCODE_C25IND = 7
    CODE39 = zint.BARCODE_CODE39 = 8
    EXCODE39 = zint.BARCODE_EXCODE39 = 9
    EANX = zint.BARCODE_EANX = 13
    EANX_CHK = zint.BARCODE_EANX_CHK = 14
    EAN128 = zint.BARCODE_EAN128 = 16
    CODABAR = zint.BARCODE_CODABAR = 18
    CODE128 = zint.BARCODE_CODE128 = 20
    DPLEIT = zint.BARCODE_DPLEIT = 21
    DPIDENT = zint.BARCODE_DPIDENT = 22
    CODE16K = zint.BARCODE_CODE16K = 23
    CODE49 = zint.BARCODE_CODE49 = 24
    CODE93 = zint.BARCODE_CODE93 = 25
    FLAT = zint.BARCODE_FLAT = 28
    RSS14 = zint.BARCODE_RSS14 = 29
    RSS_LTD = zint.BARCODE_RSS_LTD = 30
    RSS_EXP = zint.BARCODE_RSS_EXP = 31
    TELEPEN = zint.BARCODE_TELEPEN = 32
    UPCA = zint.BARCODE_UPCA = 34
    UPCA_CHK = zint.BARCODE_UPCA_CHK = 35
    UPCE = zint.BARCODE_UPCE = 37
    UPCE_CHK = zint.BARCODE_UPCE_CHK = 38
    POSTNET = zint.BARCODE_POSTNET = 40
    MSI_PLESSEY = zint.BARCODE_MSI_PLESSEY = 47
    FIM = zint.BARCODE_FIM = 49
    LOGMARS = zint.BARCODE_LOGMARS = 50
    PHARMA = zint.BARCODE_PHARMA = 51
    PZN = zint.BARCODE_PZN = 52
    PHARMA_TWO = zint.BARCODE_PHARMA_TWO = 53
    PDF417 = zint.BARCODE_PDF417 = 55
    PDF417TRUNC = zint.BARCODE_PDF417TRUNC = 56
    MAXICODE = zint.BARCODE_MAXICODE = 57
    QRCODE = zint.BARCODE_QRCODE = 58
    CODE128B = zint.BARCODE_CODE128B = 60
    AUSPOST = zint.BARCODE_AUSPOST = 63
    AUSREPLY = zint.BARCODE_AUSREPLY = 66
    AUSROUTE = zint.BARCODE_AUSROUTE = 67
    AUSREDIRECT = zint.BARCODE_AUSREDIRECT = 68
    ISBNX = zint.BARCODE_ISBNX = 69
    RM4SCC = zint.BARCODE_RM4SCC = 70
    DATAMATRIX = zint.BARCODE_DATAMATRIX = 71
    EAN14 = zint.BARCODE_EAN14 = 72
    VIN = zint.BARCODE_VIN = 73
    CODABLOCKF = zint.BARCODE_CODABLOCKF = 74
    NVE18 = zint.BARCODE_NVE18 = 75
    JAPANPOST = zint.BARCODE_JAPANPOST = 76
    KOREAPOST = zint.BARCODE_KOREAPOST = 77
    RSS14STACK = zint.BARCODE_RSS14STACK = 79
    RSS14STACK_OMNI = zint.BARCODE_RSS14STACK_OMNI = 80
    RSS_EXPSTACK = zint.BARCODE_RSS_EXPSTACK = 81
    PLANET = zint.BARCODE_PLANET = 82
    MICROPDF417 = zint.BARCODE_MICROPDF417 = 84
    ONECODE = zint.BARCODE_ONECODE = 85
    PLESSEY = zint.BARCODE_PLESSEY = 86

    # Tbarcode 8 codes
    TELEPEN_NUM = zint.BARCODE_TELEPEN_NUM = 87
    ITF14 = zint.BARCODE_ITF14 = 89
    KIX = zint.BARCODE_KIX = 90
    AZTEC = zint.BARCODE_AZTEC = 92
    DAFT = zint.BARCODE_DAFT = 93
    MICROQR = zint.BARCODE_MICROQR = 97

    # Tbarcode 9 codes
    HIBC_128 = zint.BARCODE_HIBC_128 = 98
    HIBC_39 = zint.BARCODE_HIBC_39 = 99
    HIBC_DM = zint.BARCODE_HIBC_DM = 102
    HIBC_QR = zint.BARCODE_HIBC_QR = 104
    HIBC_PDF = zint.BARCODE_HIBC_PDF = 106
    HIBC_MICPDF = zint.BARCODE_HIBC_MICPDF = 108
    HIBC_BLOCKF = zint.BARCODE_HIBC_BLOCKF = 110
    HIBC_AZTEC = zint.BARCODE_HIBC_AZTEC = 112

    # Tbarcode 10 codes
    DOTCODE = zint.BARCODE_DOTCODE = 115
    HANXIN = zint.BARCODE_HANXIN = 116

    # Tbarcode 11 codes
    MAILMARK = zint.BARCODE_MAILMARK = 121

    # Zint specific
    AZRUNE = zint.BARCODE_AZRUNE = 128
    CODE32 = zint.BARCODE_CODE32 = 129
    EANX_CC = zint.BARCODE_EANX_CC = 130
    EAN128_CC = zint.BARCODE_EAN128_CC = 131
    RSS14_CC = zint.BARCODE_RSS14_CC = 132
    RSS_LTD_CC = zint.BARCODE_RSS_LTD_CC = 133
    RSS_EXP_CC = zint.BARCODE_RSS_EXP_CC = 134
    UPCA_CC = zint.BARCODE_UPCA_CC = 135
    UPCE_CC = zint.BARCODE_UPCE_CC = 136
    RSS14STACK_CC = zint.BARCODE_RSS14STACK_CC = 137
    RSS14_OMNI_CC = zint.BARCODE_RSS14_OMNI_CC = 138
    RSS_EXPSTACK_CC = zint.BARCODE_RSS_EXPSTACK_CC = 139
    CHANNEL = zint.BARCODE_CHANNEL = 140
    CODEONE = zint.BARCODE_CODEONE = 141
    GRIDMATRIX = zint.BARCODE_GRIDMATRIX = 142
    UPNQR = zint.BARCODE_UPNQR = 143
    ULTRA = zint.BARCODE_ULTRA = 144
    RMQR = zint.BARCODE_RMQR = 145

    def __call__(self, data: Union[str, bytes], *args, **kwargs) -> zint.Zint:
        return zint.Zint(data, self.value, *args, **kwargs)


__all__ = [
    Barcode,
]
