import { capitalize } from "lodash-es";
/**
 *
 * @param languageCode
 * @param sessionLanguage
 */
export function getLanguageTitle(languageCode, sessionLanguage) {
    if (languageCode.length === 0 || sessionLanguage.length === 0) {
        return '';
    }
    languageCode = languageCode === 'en_us' ? 'en-US' : languageCode;
    sessionLanguage = sessionLanguage === 'en_us' ? 'en-US' : sessionLanguage;
    const longLanguageNames = new Intl.DisplayNames(sessionLanguage, {
        type: 'language',
    });
    const languageName = longLanguageNames.of(languageCode) || '';
    const languageNameParts = languageName.split(' ');
    languageNameParts[0] = capitalize(languageNameParts[0]);
    return languageNameParts.join(' ');
}
/**
 *
 * @param http
 */
export async function getAllLanguages(http) {
    const languages = await http.get('api/v1/admin/settings/languages');
    const result = [];
    if (languages === null || languages === void 0 ? void 0 : languages.active) {
        result.push(...languages.active);
    }
    if (languages === null || languages === void 0 ? void 0 : languages.inactive) {
        result.push(...languages.inactive);
    }
    return result;
}
