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AK,WACHA,EAAQ,WACR,MACF,IAAK,aACHA,EAAQ,aACR,MACF,QACE,MAAM,IAAIqC,MAAM,0EAEpB,OAAOtC,EAAqBC,EAAM,sBAAsB,EA6GxDwC,wBAnG+BC,IAC/BA,EAAgBA,EAActC,cAEvBV,EAAKuC,QAAOnB,GAAWA,EAAQ6B,UACnCC,MAAM,KACNpC,SAASkC,MA+FZG,uBAnF6B,CAACC,EAASC,KACvC,IAAIC,EAKJ,OAHAF,EAAUA,EAAQ1C,cAClB2C,EAAWA,EAAS3C,cAEZ0C,GACN,IAAK,UACHE,EAAO,UACP,MACF,IAAK,UACHA,EAAO,UACP,MACF,IAAK,UACHA,EAAO,UACP,MACF,QACE,MAAM,IAAIV,MAAM,qDAGpB,OAAO5C,EAAKuC,QAAOnB,GAAWA,EAAQmC,IAAID,KAAUD,GAAS,EAgE7DG,kBAtDyBC,IACzBA,EAAUA,EAAQ/C,cAEXV,EAAKuC,QAAOnB,GAAWA,EAAQsC,IACnCR,MAAM,KACNpC,SAAS2C,MAkDZE,iCAvCwCC,IACxC,MAAMC,EAAS7D,EAAKuC,QAAQnB,GACnBA,EAAQ0C,oBAAoBhD,SAAS8C,KAG9C,IAAKC,EAAOxD,OACV,MAAM,IAAIuC,MACR,+IAKJ,OAAOiB,CAAM,EA4BbE,uBAnB8BC,GACvBhE,EAAKuC,QAAQnB,GAAWA,EAAQ6C,gBAAkBD,I","sources":["webpack://bravely/./node_modules/world-countries-capitals/index.js"],"sourcesContent":["let data = require(\"./data/data.json\");\n\nconst randomNum = () => {\n return Math.floor(Math.random() * data.length);\n};\n\n/**\n * Returns the name of a random country from the list of\n * countries in the dataset\n * @returns {string} The name of a country picked at random\n */\nconst getRandomCountry = () => {\n let randNum = randomNum();\n return data[randNum].country;\n};\n\n/**\n * Returns an array having `count` number of different random country objects,\n * each object containing `country`, `capital`, `currency`, `native_language`,\n * `famous_for`, and `phone_code`.\n * @param {integer} count Number of country objects in the array to be returned\n * @returns {Array} An array having `count` number of country objects\n */\nconst getNRandomCountriesData = (count) => {\n let randomCountriesSet = new Set(); // to prevent duplicate countries\n while (randomCountriesSet.size < count) {\n let country = data[randomNum()];\n randomCountriesSet.add(country); // adds a country to the Array\n }\n return Array.from(randomCountriesSet); // Returns the Array\n};\n\n// Helper function\nconst getCountriesByObject = (value, obj) => {\n let resultArray = [];\n value = value.toLowerCase();\n object = obj;\n data.forEach((item) => {\n item[object] = item[object];\n if (item[object] && item[object].includes(value)) {\n resultArray.push(item);\n }\n });\n\n return resultArray;\n};\n\n/**\n * Returns an array of objects, each containing `country`, `capital`,\n * `currency` and `native_language` filtered by `capital` .\n * @param {string} capital The name (not case-sensitive) of the capital of the country\n * @returns {Array} An array of country objects\n */\nconst getCountryDetailsByCapital = (capital) => {\n return getCountriesByObject(capital, \"capital\");\n};\n\n/**\n * Returns an array of objects, each containing `country`, `capital`,\n * `currency` and `native_language` filtered by `country` .\n * @param {string} country The name (not case-sensitive) of the country\n * @returns {Array} An array of country objects\n */\nconst getCountryDetailsByName = (country) => {\n return getCountriesByObject(country, \"country\");\n};\n\n/**\n * Returns an array of objects, each containing `country`, `capital`,\n * `currency` and `native_language` filtered by the `languageSpoken` .\n * @param {string} languageSpoken The language spoken (not case-sensitive) by the country\n * @returns {Array} An array of country objects\n */\nconst getCountriesByLanguage = (languageSpoken) => {\n return getCountriesByObject(languageSpoken, \"native_language\");\n};\n\n/**\n * Returns an array of objects, each containing `country`, `capital`,\n * `currency` and `native_language` filtered by the `languageSpoken` .\n * @param {'left' | 'right'} direction The driving direction followed by the country\n * @returns {Array} An array of country objects\n */\nconst getCountriesByDriveDirection = (direction) => {\n let value;\n switch (direction) {\n case \"left\":\n value = \"left\";\n break;\n case \"right\":\n value = \"right\";\n break;\n default:\n throw new Error('direction must be \"left\" or \"right\"');\n }\n return getCountriesByObject(value, \"drive_direction\");\n};\n\n/**\n * Returns an array of objects containing all countries, each containing `country`, `capital`,\n * `currency`, `native_language`, `famous_for`, and `phone_code`\n * @returns {Array} An array of country objects\n */\nconst getAllCountryDetails = () => {\n return data;\n};\n\n/**\n * Returns an array containing the name of all the countries in the dataset\n * @returns {Array} An array of country objects\n */\nconst getAllCountries = () => {\n return data.map(({ country }) => country);\n};\n\n/**\n * Returns an array of objects containing all countries, each containing `country`, `capital`,\n * `currency`, `native_language`, `famous_for`, and `phone_code`, filtered by `famousThing`\n * @param {string} famousThing What the country is famous for\n * @returns {Array} An array of country objects\n */\nconst getCountriesByFamousFor = (famousThing) => {\n return data.filter(\n (country) => country.famous_for.search(\"\\\\b\" + famousThing + \"\\\\b\") != -1\n );\n};\n\nconst getCountriesByAlcoholProhibition = (prohibitionType) =>{\n let value;\n switch (prohibitionType) {\n case \"none\":\n value = \"none\";\n break;\n case \"limited\":\n value = \"limited\";\n break;\n case \"regional\":\n value = \"regional\";\n break;\n case \"nationwide\":\n value = \"nationwide\";\n break;\n default:\n throw new Error('Prohibition type must be \"none\", \"limited\", \"regional\" or \"nationwide\"');\n }\n return getCountriesByObject(value,\"alcohol_prohibition\");\n}\n\n/**\n * Returns an array of objects, each containing `country`, `capital`, `currency`, `native_language`,\n * `famous_for`, `phone_code`, `flag`, `drive_direction`, `continent`, `iso` and `tld`\n * filtered by `continentCode`\n * @param {string} continentCode The continent 2-letter code (not case-sensitive)\n * @returns {Array} An array of country objects\n */\nconst getCountriesByContinent = (continentCode) => {\n continentCode = continentCode.toLowerCase();\n\n return data.filter(country => country.continent\n .split(\"/\")\n .includes(continentCode)\n );\n};\n\n/**\n * Returns an array with object containing `country`, `capital`, `currency`, `native_language`,\n * `famous_for`, `phone_code`, `flag`, `drive_direction`, `continent`, `iso` and `tld`\n * filtered by specific `iso`\n * @param {'numeric' | 'alpha_2' | 'alpha_3'} isoType The code of the country (ISO 3166-1 standard)\n * @param {string} isoValue The ISO code value (not case-sensitive) of the country\n * @returns {Array} An array with country object\n */\nconst getCountryDetailsByISO = (isoType, isoValue) => {\n let type;\n\n isoType = isoType.toLowerCase();\n isoValue = isoValue.toLowerCase();\n\n switch (isoType) {\n case \"numeric\":\n type = \"numeric\";\n break;\n case \"alpha_2\":\n type = \"alpha_2\";\n break;\n case \"alpha_3\":\n type = \"alpha_3\";\n break;\n default:\n throw new Error(\"isoType must be 'numeric', 'alpha_2' or 'alpha_3'\");\n }\n\n return data.filter(country => country.iso[type] === isoValue);\n};\n\n/**\n * Returns an array of objects containing `country`, `capital`, `currency`, `native_language`,\n * `famous_for`, `phone_code`, `flag`, `drive_direction`, `continent`, `iso` and `tld`\n * filtered by `tld`\n * @param {string} tldName The name (not case-sensitive) of the country code top-level domain\n * @returns {Array} An array of country objects\n */\nconst getCountriesByTLD = (tldName) => {\n tldName = tldName.toLowerCase();\n\n return data.filter(country => country.tld\n .split(\"/\")\n .includes(tldName)\n );\n};\n\n/**\n * Returns an array of objects containing all countries, each containing `country`, `capital`,\n * `currency`, `native_language`, `famous_for`, and `phone_code`, `flag`, `drive_direction`\n * and `constitutional_form` filtered by `constitutional_form`\n * @param {string} constitutionalFormName Name of country constitutional form\n * @returns {Array} An array of country objects\n */\nconst getCountriesByConstitutionalForm = (constitutionalFormName) => {\n const result = data.filter((country) => {\n return country.constitutional_form.includes(constitutionalFormName)\n });\n\n if (!result.length) {\n throw new Error(\n `No country was found! Available constitutional forms are:\n 'republic', 'constitutional monarchy', 'absolute monarchy' and 'n/a'\n `);\n }\n\n return result;\n}\n\n/** \n * Returns an array of objects containing all countries, each containing `country`, `capital`,\n * `currency`, `native_language`, `famous_for`, `phone_code`, `flag` and `drive_direction` filtered by `is_landlocked`\n * @param { Boolean } isLandLocked Country that is surrounded by one or more countries\n * @returns {Array} An array of country objects\n*/\nconst getCountriesByLandLock = (isLandLocked) => {\n return data.filter( country => country.is_landlocked === isLandLocked);\n};\n\nmodule.exports = {\n getRandomCountry,\n getNRandomCountriesData,\n getCountryDetailsByCapital,\n getCountryDetailsByName,\n getAllCountryDetails,\n getAllCountries,\n getCountriesByLanguage,\n getCountriesByFamousFor,\n getCountriesByDriveDirection,\n getCountriesByAlcoholProhibition,\n getCountriesByContinent,\n getCountryDetailsByISO,\n getCountriesByTLD,\n getCountriesByConstitutionalForm,\n getCountriesByLandLock,\n};\n"],"names":["data","randomNum","Math","floor","random","length","getCountriesByObject","value","obj","resultArray","toLowerCase","object","forEach","item","includes","push","module","exports","getRandomCountry","randNum","country","getNRandomCountriesData","count","randomCountriesSet","Set","size","add","Array","from","getCountryDetailsByCapital","capital","getCountryDetailsByName","getAllCountryDetails","getAllCountries","map","getCountriesByLanguage","languageSpoken","getCountriesByFamousFor","famousThing","filter","famous_for","search","getCountriesByDriveDirection","direction","Error","getCountriesByAlcoholProhibition","prohibitionType","getCountriesByContinent","continentCode","continent","split","getCountryDetailsByISO","isoType","isoValue","type","iso","getCountriesByTLD","tldName","tld","getCountriesByConstitutionalForm","constitutionalFormName","result","constitutional_form","getCountriesByLandLock","isLandLocked","is_landlocked"],"sourceRoot":""}