/**
 * Function generates string representation of the given list accordingly to localization rules of given locale.
 * @param list list of strings to format
 * @param t translation function used internally
 * @param locale locale tag to get the localization rules for
 * @param options formatting options
 * @returns
 */
const formatListToLocaleString = (list, t, locale, { count = list.length, separator } = {}) => {
    const formattedList = count > 3 ? list.slice(0, 2) : list;
    const remainder = formattedList.length ? count - formattedList.length : 0;
    const toFormat = remainder > 0
        ? [...formattedList, t('more_count', [remainder], { count: remainder })]
        : formattedList;
    if (separator || !('ListFormat' in Intl))
        return toFormat.join(separator ?? ', ');
    return new Intl.ListFormat(locale, { style: 'long' }).format(toFormat);
};
export default formatListToLocaleString;
//# sourceMappingURL=formatListToLocaleString.js.map