import * as React from 'react';
const RecursiveTranslation = ({ elements, translationString })=>{
    const regex = /(<[^>]+>.*?<\/[^>]+>)/g;
    const sections = translationString.split(regex);
    return /*#__PURE__*/ React.createElement("span", null, sections.map((section, index)=>{
        const Element = elements?.[index.toString()];
        if (Element) {
            const regex = new RegExp(`<${index}>(.*?)<\/${index}>`, 'g');
            const children = section.replace(regex, (_, group)=>group);
            return /*#__PURE__*/ React.createElement(Element, {
                key: index
            }, /*#__PURE__*/ React.createElement(RecursiveTranslation, {
                translationString: children
            }));
        }
        return section;
    }));
};
export const Translation = ({ elements, i18nKey, t, variables })=>{
    const stringWithVariables = t(i18nKey, variables || {});
    if (!elements) {
        return stringWithVariables;
    }
    return /*#__PURE__*/ React.createElement(RecursiveTranslation, {
        elements: elements,
        translationString: stringWithVariables
    });
};

//# sourceMappingURL=index.js.map