# Path: esteid/constants.py
# MOBILE_ID_DEMO_URL = "https://tsp.demo.sk.ee/mid-api"
# MOBILE_ID_LIVE_URL = "https://mid.sk.ee/mid-api"
# MOBILE_ID_DEMO_SERVICE_NAME = "DEMO"
# MOBILE_ID_DEMO_SERVICE_UUID = "00000000-0000-0000-0000-000000000000"
# SMART_ID_DEMO_URL = "https://sid.demo.sk.ee/smart-id-rp/v1"
# SMART_ID_LIVE_URL = "https://rp-api.smart-id.com/v1"
# SMART_ID_DEMO_SERVICE_NAME = MOBILE_ID_DEMO_SERVICE_NAME
# SMART_ID_DEMO_SERVICE_UUID = MOBILE_ID_DEMO_SERVICE_UUID
# OCSP_DEMO_URL = "http://demo.sk.ee/ocsp"
# OCSP_LIVE_URL = "http://ocsp.sk.ee/"
# TSA_DEMO_URL = "http://demo.sk.ee/tsa/"
# TSA_LIVE_URL = "http://tsa.sk.ee"
# HASH_SHA256 = "SHA256"
# HASH_SHA384 = "SHA384"
# HASH_SHA512 = "SHA512"
# HASH_ALGORITHMS = {
#     HASH_SHA256,
#     HASH_SHA384,
#     HASH_SHA512,
# }
#     ESTONIA = "EE"
#     LATVIA = "LV"
#     LITHUANIA = "LT"
#     ALL = (ESTONIA, LATVIA, LITHUANIA)
#     ENG = "ENG"
#     EST = "EST"
#     LIT = "LIT"
#     RUS = "RUS"
#     ALL = (ENG, EST, LIT, RUS)
#     _MAP_ISO_639_1_TO_MID = {
#         "en": ENG,
#         "et": EST,
#         "lt": LIT,
#         "ru": RUS,
#     }
# class Countries:
# class Languages:
#     def identify_language(cls, language_code):
# 
# Path: esteid/constants.py
# class Countries:
#     """Mainly used by SmartID, also phone code"""
# 
#     ESTONIA = "EE"
#     LATVIA = "LV"
#     LITHUANIA = "LT"
# 
#     ALL = (ESTONIA, LATVIA, LITHUANIA)
# 
# class Languages:
#     """Used by MobileID"""
# 
#     ENG = "ENG"
#     EST = "EST"
#     LIT = "LIT"
#     RUS = "RUS"
# 
#     ALL = (ENG, EST, LIT, RUS)
# 
#     # also allow ISO 639-1 (or alpha-2) codes
#     _MAP_ISO_639_1_TO_MID = {
#         "en": ENG,
#         "et": EST,
#         "lt": LIT,
#         "ru": RUS,
#     }
# 
#     @classmethod
#     def identify_language(cls, language_code):
#         all_langs = {**cls._MAP_ISO_639_1_TO_MID, **{c.lower(): c for c in cls.ALL}}
#         try:
#             language_code_lower = language_code.lower()
#             return all_langs[language_code_lower]
#         except (AttributeError, KeyError) as e:
#             raise ImproperlyConfigured(f"Language should be one of {','.join(all_langs)}, got `{language_code}`") from e


import re
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from esteid import constants
from esteid.constants import Countries, Languages
        MOBILE_ID_API_ROOT = constants.MOBILE_ID_DEMO_URL
else:
    if not MOBILE_ID_API_ROOT:
        MOBILE_ID_API_ROOT = constants.MOBILE_ID_LIVE_URL


# *** Smart ID ***

SMART_ID_ENABLED = getattr(settings, "SMART_ID_ENABLED", False)
# Whether to use demo services and credentials for Smart ID. Default to global demo mode
SMART_ID_TEST_MODE = getattr(settings, "SMART_ID_TEST_MODE", ESTEID_DEMO)
# SmartID Relying party name and UUID, for DEMO they are always the same so no need to explicitly set them
SMART_ID_SERVICE_NAME = getattr(settings, "SMART_ID_SERVICE_NAME", None)
SMART_ID_SERVICE_UUID = getattr(settings, "SMART_ID_SERVICE_UUID", None)

SMART_ID_API_ROOT = getattr(settings, "SMART_ID_API_ROOT", None)

if SMART_ID_TEST_MODE:
    if not SMART_ID_SERVICE_NAME:
        SMART_ID_SERVICE_NAME = constants.SMART_ID_DEMO_SERVICE_NAME
    if not SMART_ID_SERVICE_UUID:
        SMART_ID_SERVICE_UUID = constants.SMART_ID_DEMO_SERVICE_UUID
    if not SMART_ID_API_ROOT:
        SMART_ID_API_ROOT = constants.SMART_ID_DEMO_URL
else:
    if not SMART_ID_API_ROOT:
        SMART_ID_API_ROOT = constants.SMART_ID_LIVE_URL


# The default country (mostly for SmartID)

# Path: esteid/constants.py
# MOBILE_ID_DEMO_URL = "https://tsp.demo.sk.ee/mid-api"
# MOBILE_ID_LIVE_URL = "https://mid.sk.ee/mid-api"
# MOBILE_ID_DEMO_SERVICE_NAME = "DEMO"
# MOBILE_ID_DEMO_SERVICE_UUID = "00000000-0000-0000-0000-000000000000"
# SMART_ID_DEMO_URL = "https://sid.demo.sk.ee/smart-id-rp/v1"
# SMART_ID_LIVE_URL = "https://rp-api.smart-id.com/v1"
# SMART_ID_DEMO_SERVICE_NAME = MOBILE_ID_DEMO_SERVICE_NAME
# SMART_ID_DEMO_SERVICE_UUID = MOBILE_ID_DEMO_SERVICE_UUID
# OCSP_DEMO_URL = "http://demo.sk.ee/ocsp"
# OCSP_LIVE_URL = "http://ocsp.sk.ee/"
# TSA_DEMO_URL = "http://demo.sk.ee/tsa/"
# TSA_LIVE_URL = "http://tsa.sk.ee"
# HASH_SHA256 = "SHA256"
# HASH_SHA384 = "SHA384"
# HASH_SHA512 = "SHA512"
# HASH_ALGORITHMS = {
#     HASH_SHA256,
#     HASH_SHA384,
#     HASH_SHA512,
# }
#     ESTONIA = "EE"
#     LATVIA = "LV"
#     LITHUANIA = "LT"
#     ALL = (ESTONIA, LATVIA, LITHUANIA)
#     ENG = "ENG"
#     EST = "EST"
#     LIT = "LIT"
#     RUS = "RUS"
#     ALL = (ENG, EST, LIT, RUS)
#     _MAP_ISO_639_1_TO_MID = {
#         "en": ENG,
#         "et": EST,
#         "lt": LIT,
#         "ru": RUS,
#     }
# class Countries:
# class Languages:
#     def identify_language(cls, language_code):
# 
# Path: esteid/constants.py
# class Countries:
#     """Mainly used by SmartID, also phone code"""
# 
#     ESTONIA = "EE"
#     LATVIA = "LV"
#     LITHUANIA = "LT"
# 
#     ALL = (ESTONIA, LATVIA, LITHUANIA)
# 
# class Languages:
#     """Used by MobileID"""
# 
#     ENG = "ENG"
#     EST = "EST"
#     LIT = "LIT"
#     RUS = "RUS"
# 
#     ALL = (ENG, EST, LIT, RUS)
# 
#     # also allow ISO 639-1 (or alpha-2) codes
#     _MAP_ISO_639_1_TO_MID = {
#         "en": ENG,
#         "et": EST,
#         "lt": LIT,
#         "ru": RUS,
#     }
# 
#     @classmethod
#     def identify_language(cls, language_code):
#         all_langs = {**cls._MAP_ISO_639_1_TO_MID, **{c.lower(): c for c in cls.ALL}}
#         try:
#             language_code_lower = language_code.lower()
#             return all_langs[language_code_lower]
#         except (AttributeError, KeyError) as e:
#             raise ImproperlyConfigured(f"Language should be one of {','.join(all_langs)}, got `{language_code}`") from e


# Path: esteid/settings.py
import re
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from esteid import constants
from esteid.constants import Countries, Languages

        MOBILE_ID_API_ROOT = constants.MOBILE_ID_DEMO_URL
else:
    if not MOBILE_ID_API_ROOT:
        MOBILE_ID_API_ROOT = constants.MOBILE_ID_LIVE_URL


# *** Smart ID ***

SMART_ID_ENABLED = getattr(settings, "SMART_ID_ENABLED", False)
# Whether to use demo services and credentials for Smart ID. Default to global demo mode
SMART_ID_TEST_MODE = getattr(settings, "SMART_ID_TEST_MODE", ESTEID_DEMO)
# SmartID Relying party name and UUID, for DEMO they are always the same so no need to explicitly set them
SMART_ID_SERVICE_NAME = getattr(settings, "SMART_ID_SERVICE_NAME", None)
SMART_ID_SERVICE_UUID = getattr(settings, "SMART_ID_SERVICE_UUID", None)

SMART_ID_API_ROOT = getattr(settings, "SMART_ID_API_ROOT", None)

if SMART_ID_TEST_MODE:
    if not SMART_ID_SERVICE_NAME:
        SMART_ID_SERVICE_NAME = constants.SMART_ID_DEMO_SERVICE_NAME
    if not SMART_ID_SERVICE_UUID:
        SMART_ID_SERVICE_UUID = constants.SMART_ID_DEMO_SERVICE_UUID
    if not SMART_ID_API_ROOT:
        SMART_ID_API_ROOT = constants.SMART_ID_DEMO_URL
else:
    if not SMART_ID_API_ROOT:
        SMART_ID_API_ROOT = constants.SMART_ID_LIVE_URL


# The default country (mostly for SmartID)

ESTEID_COUNTRY = getattr(settings, "ESTEID_COUNTRY", Countries.ESTONIA)