"""EconDB Helpers."""
import asyncio
import json
from importlib.resources import files
from io import StringIO
from typing import Dict, List, Optional, Tuple, Union
from aiohttp_client_cache import SQLiteBackend
from aiohttp_client_cache.session import CachedSession
from openbb_core.app.model.abstract.error import OpenBBError
from openbb_core.app.utils import get_user_cache_directory
from openbb_core.provider.utils.helpers import amake_request, amake_requests
from pandas import DataFrame, concat, read_csv
COUNTRY_MAP = {
"albania": "AL",
"argentina": "AR",
"australia": "AU",
"austria": "AT",
"azerbaijan": "AZ",
"bangladesh": "BD",
"belarus": "BY",
"belgium": "BE",
"bosnia_and_herzegovina": "BA",
"brazil": "BR",
"bulgaria": "BG",
"cambodia": "KH",
"canada": "CA",
"chile": "CL",
"china": "CN",
"colombia": "CO",
"costa rica": "CR",
"croatia": "HR",
"cyprus": "CY",
"czechia": "CZ",
"denmark": "DK",
"dominican republic": "DO",
"egypt": "EG",
"estonia": "EE",
"european_union": "EU",
"euro_area": "EA",
"finland": "FI",
"france": "FR",
"germany": "DE",
"greece": "GR",
"honduras": "HN",
"hong_kong": "HK",
"hungary": "HU",
"india": "IN",
"indonesia": "ID",
"iran": "IR",
"ireland": "IE",
"israel": "IL",
"italy": "IT",
"japan": "JP",
"jordan": "JO",
"kazakhstan": "KZ",
"laos": "LA",
"latvia": "LV",
"lithuania": "LT",
"luxembourg": "LU",
"macao": "MO",
"malaysia": "MY",
"mexico": "MX",
"mongolia": "MN",
"morocco": "MA",
"netherlands": "NL",
"new_zealand": "NZ",
"nigeria": "NG",
"norway": "NO",
"oman": "OM",
"pakistan": "PK",
"panama": "PA",
"peru": "PE",
"philippines": "PH",
"poland": "PL",
"portugal": "PT",
"romania": "RO",
"russia": "RU",
"saudi_arabia": "SA",
"serbia": "RS",
"singapore": "SG",
"slovakia": "SK",
"slovenia": "SI",
"south_africa": "ZA",
"south_korea": "KR",
"spain": "ES",
"sweden": "SE",
"switzerland": "CH",
"taiwan": "TW",
"thailand": "TH",
"tunisia": "TN",
"turkey": "TR",
"ukraine": "UA",
"united_arab_emirates": "AE",
"united_kingdom": "UK",
"united_states": "US",
"uzbekistan": "UZ",
"vietnam": "VN",
"world": "W00",
}
THREE_LETTER_ISO_MAP = {
"ALB": "AL",
"ARG": "AR",
"AUS": "AU",
"AUT": "AT",
"AZE": "AZ",
"BGD": "BD",
"BLR": "BY",
"BEL": "BE",
"BIH": "BA",
"BRA": "BR",
"BGR": "BG",
"KHM": "KH",
"CAN": "CA",
"CHL": "CL",
"CHN": "CN",
"COL": "CO",
"CRI": "CR",
"HRV": "HR",
"CYP": "CY",
"CZE": "CZ",
"DNK": "DK",
"DOM": "DO",
"EGY": "EG",
"EST": "EE",
"FIN": "FI",
"FRA": "FR",
"DEU": "DE",
"GRC": "GR",
"HND": "HN",
"HKG": "HK",
"HUN": "HU",
"IND": "IN",
"IDN": "ID",
"IRN": "IR",
"IRL": "IE",
"ISR": "IL",
"ITA": "IT",
"JPN": "JP",
"JOR": "JO",
"KAZ": "KZ",
"LAO": "LA",
"LVA": "LV",
"LTU": "LT",
"LUX": "LU",
"MAC": "MO",
"MYS": "MY",
"MEX": "MX",