"""Constants from the Cabrillo specification.

Based on the Cabrillo specification available at:
    https://wwrof.org/cabrillo/

All values below should remain upper case.
"""

import collections

CATEGORY_ASSISTED = ['ASSISTED', 'NON-ASSISTED']
CATEGORY_BAND = ['ALL', '160M', '80M', '40M', '20M', '15M', '10M', '6M', '4M',
                 '2M', '222', '432', '902', '1.2G', '2.3G', '3.4G', '5.7G',
                 '10G', '24G', '47G', '75G', '122G', '123G', '134G', '241G', 'LIGHT',
                 'VHF-3-BAND', 'VHF-FM-ONLY']
CATEGORY_MODE = ['SSB', 'CW', 'RTTY', 'FM', 'MIXED', 'DIGI']
CATEGORY_OPERATOR = ['SINGLE-OP', 'MULTI-OP', 'CHECKLOG']
CATEGORY_POWER = ['HIGH', 'LOW', 'QRP']
CATEGORY_STATION = ['FIXED', 'MOBILE', 'PORTABLE', 'ROVER', 'ROVER-LIMITED',
                    'ROVER-UNLIMITED', 'EXPEDITION', 'HQ', 'SCHOOL', 'EXPLORER',
                    'DISTRIBUTED']
CATEGORY_TIME = ['6-HOURS', '8-HOURS', '12-HOURS', '24-HOURS']
CATEGORY_TRANSMITTER = ['ONE', 'TWO', 'LIMITED', 'UNLIMITED', 'SWL']
CATEGORY_OVERLAY = [
    'CLASSIC', 'ROOKIE', 'TB-WIRES', 'YOUTH', 'NOVICE-TECH', 'OVER-50',
    'YL', 'YOUTH'
]

CONTEST = [
    '10-10-SPRINT',
    '10-10-FALL-CW',
    '10-10-FALL-DIGITAL',
    '10-10-OPEN-SEASON',
    '10-10-SPRING-CW',
    '10-10-SPRING-DIGITAL',
    '10-10-SUMMER-PHONE',
    '10-10-WINTER-PHONE',
    '7QP',
    'A1CLUB-AWT',
    'AGCW-QRP',
    'AL-QSO-PARTY',
    'ALL-AFRICA',
    'AADX-CW',
    'AADX-SSB',
    'ANZAC',
    '40-80',
    'ARI-DX',
    'AZ-QSO-PARTY',
    'AR-QSO-PARTY',
    'ARRL-10-GHZ',
    'ARRL-10',
    'ARRL-160',
    'ARRL-222',
    'ARRL-EME',
    'ARRL-FD',
    'ARRL-DIGI',
    'ARRL-DX-CW',
    'ARRL-DX-SSB',
    'ARRL-VHF-JAN',
    'ARRL-VHF-JUN',
    'ARRL-RR-CW',
    'ARRL-RR-DIG',
    'ARRL-RR-PH',
    'ARRL-RTTY',
    'ARRL-SCR',
    'ARRL-VHF-SEP',
    'ARRL-SS-CW',
    'ARRL-SS-SSB',
    'AP-SPRINT',
    'WIA-AUSTRALIADAY',
    'BALKAN-HF',
    'BALTIC-CONTEST',
    'BARTG-RTTY',
    'BARTG-SPRINT',
    'BATAVIA',
    'BC-QSO-PARTY',
    'BUCURESTI-DIGITAL',
    'CA-QSO-PARTY',
    'CP-QSO-PARTY',
    'CQP',
    'COQP',
    'STAYHOME',
    'CQ-160-CW',
    'CQ-160-SSB',
    'CQ-WW-CW',
    'CQ-WW-RTTY',
    'CQ-WW-SSB',
    'CQ-VHF',
    'CQ-WPX-RTTY',
    'CQ-WPX-CW',
    'CQ-WPX-SSB',
    'CQ-M',
    'CQMMDX',
    '9A-CW',
    'CVA-DX-CW',
    'CVA-DX-SSB',
    'CW-OPEN',
    'CW-OPS',
    'DARC-10',
    'XMAS',
    'DE-QSO-PARTY',
    'DIG-QSO-PARTY',
    'DL-DX-RTTY',
    'DRCG-WW-RTTY',
    'PACC',
    'PACCDIGI',
    'EA-PSK',
    'EARTTY',
    'EANET-SPRINT',
    'EU-PSK-DX',
    'EU-SPRINT-SSB',
    'EUCW-160',
    'EURASIA-CHAMP',
    'EUHFC',
    'EUDXC',
    'F9AA-CW',
    'F9AA-DIGI',
    'F9AA-SSB',
    'FIRAC-CONTEST',
    'FCG-FQP',
    'FT8-RU',
    'WWSA',
    'GA-QSO-PARTY',
    'GUNUNGJATI',
    'HA3NS-SPRINT',
    'HAM-SPIRIT-CW',
    'HAM-SPIRIT-SSB',
    'HI-QSO-PARTY',
    'HELVETIA',
    'ARRL-HPM-150',
    'EA-MAJESTAD-CW',
    'EA-MAJESTAD-SSB',
    'HOLYLAND',
    'HA-DX',
    'IARU-HF',
    'ICWC-MST',
    'ID-QSO-PARTY',
    'IG-WW-RY',
    'IL-QSO-PARTY',
    'IN-QSO-PARTY',
    'IAQP',
    'JARTS-WW-RTTY',
    'JIDX-CW',
    'JIDX-SSB',
    'KALBAR CONTEST',
    'KANHAM',
    'KS-QSO-PARTY',
    'KCJ-TOPBAND',
    'KYQP',
    'LA-QSO-PARTY',
    'LZ-DX',
    'MAIDENHEAD-MAYHEM',
    'ME-QSO-PARTY',
    'MAKROTHEN-RTTY',
    'MYDX-SSB-CONTEST',
    'MCD-QSO-PARTY',
    'MMC-HF-CW',
    'MDC-QSO-PARTY',
    'XE-RTTY',
    'MI-QSO-PARTY',
    'MINITEST-40',
    'MINITEST-80',
    'MN-QSO-PARTY',
    'MS-QSO-PARTY',
    'MO-QSO-PARTY',
    'NCCC-SPRINT-RTTY',
    'NCCC-SPRINT-CW',
    'NE-QSO-PARTY',
    'NV-QSO-PARTY',
    'NEQP',
    'NH-QSO-PARTY',
    'NJQP',
    'NM-QSO-PARTY',
    'NY-QSO-PARTY',
    'VHF-NAMSS',
    'NAQP-CW',
    'NAQP-RTTY',
    'NAQP-SSB',
    'NA-SPRINT-CW',
    'NA-SPRINT-RTTY',
    'NA-SPRINT-SSB',
    'NC-QSO-PARTY',
    'ND-QSO-PARTY',
    'NRAU-10',
    'NRRL-MGM',
    'MEMORIAL-CONTEST',
    'OCEANIA-DX-CW',
    'OCEANIA-DX-SSB',
    'MRRC-OHQP',
    'OK-DX-RTTY',
    'OK-OM-DX',
    'OK-QSO-PARTY',
    'ON-QSO-PARTY',
    'UKR-CHAMP-RTTY',
    'PBDX-CONTEST',
    'PA-QSO-PARTY',
    'POC',
    'PORTUGAL-DAY',
    'TBD',
    'QC-QSO-PARTY',
    'CANADA-DAY',
    'CANADA-WINTER',
    'RAEM',
    'RCC-CUP',
    'REF-CW',
    'REF-SSB',
    'RSGB-160',
    'RSGB-80M-AUT',
    'RSGB-80M-CC',
    'RSGB-AFS-CW',
    'RSGB-COMMONWEALTH',
    'RSGB-DX',
    'RSGB-FT4',
    'RSGB-HQP',
    'RSGB-LOW-POWER',
    'RSGB-IOTA',
    'RSGB-NFD',
    'RSGB-ROLO',
    'RSGB-NFD',
    'RTTYOPS-WEEKEND-SPRINT',
    'RTTYOPS-WEEKSPRINT',
    'RTTYOPS-WW-RTTY',
    'RADIO-160',
    'RDAC',
    'RDXC',
    'RUS-WW-PSK',
    'RADIO-WW-RTTY',
    'RUS-WW-DIGI',
    'RUS-WW-MM',
    'SARL-HF-CW',
    'SARL-HF-DIGI',
    'SARL-HF-SSB',
    'SARTG-NY-RTTY',
    'SARTG-RTTY',
    'SAC-CW',
    'SAC-SSB',
    'SA10M',
    'SACW',
    'SC-QSO-PARTY',
    'SDQSOP',
    'SPDX',
    'STEW-PERRY',
    'TN-QSO-PARTY',
    'TNPOTA',
    'TESLA-HF',
    'TXQP',
    'TSPOTA',
    'TISZACUP',
    'TRC-DIGI',
    'ALRS-UA1DZ-CUP',
    'UBA-DX-CW',
    'UBA-DX-SSB',
    'UBA-ON-2M',
    'UBA-ON-6M',
    'UBA-ON-CW',
    'UBA-ON-SSB',
    'UBA-PSK63-PREFIX',
    'UBA-SPRING-CONTEST',
    'UFT-QRP',
    'UKEI-DX',
    'UKEICC-80M',
    'UR-DX-RTTY',
    'UKRAINIAN-DX',
    'UR-DX-DIGI',
    'UN-DX',
    'VT-QSO-PARTY',
    'VA-QSO-PARTY',
    'VKSHIRES',
    'VOLTA-RTTY',
    'ISLAND-QSO-PARTY',
    'DARC-WAEDC-CW',
    'DARC-WAEDC-RTTY',
    'DARC-WAEDC-SSB',
    'WA-SALMON-RUN',
    'WVQP',
    'WFD',
    'WIQP',
    'WAG',
    'WAPC-DX',
    'WW-DIGI',
    'WWSAC',
    'WW-PMC',
    'YARC-QSO-PARTY',
    'YB DX CONTEST',
    'YB-DX-CONTEST',
    'YL-OM',
    'YO-DX-HF',
    'YOTA',
    'YUDX',
    'GC',
    'ARRL-',
    'ARRL-10-G',
    'ARRL-1',
    'ARRL-DI',
    'ARRL-DX-',
    'ARRL-DX-S',
    'ARRL-E',
    'ARRL-SS-',
    'ARRL-SS-S',
    'BARTG-RT',
    'CQ-160-',
    'CQ-160-S',
    'CQ-WPX-',
    'CQ-WPX-RT',
    'CQ-WPX-S',
    'CQ-V',
    'CQ-WW-',
    'CQ-WW-RT',
    'CQ-WW-S',
    'IARU-',
    'NAQP-',
    'NAQP-S',
    'NAQP-RT',
    'RD',
    'RSGB-IO',
    'SPD',
    'SPDXC-RT',
    'TARA-RT',
    'W',
    'WW-DI'
]

MODES = ['CW', 'PH', 'FM', 'RY', 'DG']

# Fields that will be output in the sequence given here.
# Does not include START-OF-LOG nor QSO nor X-QSO,
# which will be treated specifically.
OUTPUT_KEYWORD_MAP = collections.OrderedDict()

OUTPUT_KEYWORD_MAP['callsign'] = 'CALLSIGN'
OUTPUT_KEYWORD_MAP['operators'] = 'OPERATORS'
OUTPUT_KEYWORD_MAP['contest'] = 'CONTEST'
OUTPUT_KEYWORD_MAP['claimed_score'] = 'CLAIMED-SCORE'
OUTPUT_KEYWORD_MAP['certificate'] = 'CERTIFICATE'
OUTPUT_KEYWORD_MAP['category_operator'] = 'CATEGORY-OPERATOR'
OUTPUT_KEYWORD_MAP['category_assisted'] = 'CATEGORY-ASSISTED'
OUTPUT_KEYWORD_MAP['category_band'] = 'CATEGORY-BAND'
OUTPUT_KEYWORD_MAP['category_power'] = 'CATEGORY-POWER'
OUTPUT_KEYWORD_MAP['category_mode'] = 'CATEGORY-MODE'
OUTPUT_KEYWORD_MAP['category_station'] = 'CATEGORY-STATION'
OUTPUT_KEYWORD_MAP['category_time'] = 'CATEGORY-TIME'
OUTPUT_KEYWORD_MAP['category_transmitter'] = 'CATEGORY-TRANSMITTER'
OUTPUT_KEYWORD_MAP['category_overlay'] = 'CATEGORY-OVERLAY'
OUTPUT_KEYWORD_MAP['offtime'] = 'OFFTIME'
OUTPUT_KEYWORD_MAP['club'] = 'CLUB'
OUTPUT_KEYWORD_MAP['name'] = 'NAME'
OUTPUT_KEYWORD_MAP['email'] = 'EMAIL'
OUTPUT_KEYWORD_MAP['location'] = 'LOCATION'
OUTPUT_KEYWORD_MAP['grid_locator'] = 'GRID-LOCATOR'
OUTPUT_KEYWORD_MAP['address'] = 'ADDRESS'
OUTPUT_KEYWORD_MAP['address_city'] = 'ADDRESS-CITY'
OUTPUT_KEYWORD_MAP['address_state_province'] = 'ADDRESS-STATE-PROVINCE'
OUTPUT_KEYWORD_MAP['address_postalcode'] = 'ADDRESS-POSTALCODE'
OUTPUT_KEYWORD_MAP['address_country'] = 'ADDRESS-COUNTRY'
OUTPUT_KEYWORD_MAP['created_by'] = 'CREATED-BY'
OUTPUT_KEYWORD_MAP['soapbox'] = 'SOAPBOX'

# Keywords we accept on input.
KEYWORD_MAP = dict(OUTPUT_KEYWORD_MAP, version='START-OF-LOG',
                   qso='QSO', x_qso='X-QSO')

VALID_CATEGORIES_MAP = dict(category_assisted=CATEGORY_ASSISTED,
                            category_band=CATEGORY_BAND,
                            category_mode=CATEGORY_MODE,
                            category_operator=CATEGORY_OPERATOR,
                            category_power=CATEGORY_POWER,
                            category_station=CATEGORY_STATION,
                            category_time=CATEGORY_TIME,
                            category_transmitter=CATEGORY_TRANSMITTER,
                            category_overlay=CATEGORY_OVERLAY)
VALID_QSO_CATEGORIES = ['1800', '3500', '7000', '14000', '21000', '28000',
                        '50', '70', '144', '222', '432', '902', '1.2G', '2.3G',
                        '3.4G', '5.7G', '10G', '24G', '47G', '75G', '122G',
                        '123G', '134G', '241G', 'LIGHT']
FREQ_RANGES = {'1800': (1800, 2000),
               '3500': (3500, 4000),
               '7000': (7000, 7300),
               '14000': (14000, 14350),
               '21000': (21000, 21450),
               '28000': (28000, 29700)}
