/*!
 * React Native Globalize
 *
 * Copyright 2015-2020 Josh Swan
 * Released under the MIT license
 * https://github.com/joshswan/react-native-globalize/blob/master/LICENSE
 */
import React from 'react';
import { Text } from 'react-native';
import { useGlobalize } from '../hooks';
import { createPropFilter } from './utils';
const filterProps = createPropFilter(({ type, value, }) => [value, { type }]);
export const FormattedPlural = ({ children, ...props }) => {
    const { formatPlural } = useGlobalize();
    const [args, textProps] = filterProps(props);
    const plural = formatPlural(...args);
    const { [plural]: formatted, other } = props;
    return (React.createElement(Text, Object.assign({}, textProps),
        formatted || other,
        children));
};
