import { jsx as _jsx } from "@emotion/react/jsx-runtime";
import { useTranslation, I18nextProvider } from 'react-i18next';
import { schemaRegistry } from '../../../../../decorators/schema-registry';
import { NAMESPACE_EXTENSION } from '../../../../providers/schemas-provider/consts';
import { Widget } from '../widget';
import { CustomWidget } from '../custom-widget';
export const BehaviorWidget = ({ name, path, context, systemName, }) => {
    const { i18n } = useTranslation();
    const schema = schemaRegistry.getWidget(systemName ? `behavior.${systemName}` : 'behavior', name);
    if (!schema) {
        return null;
    }
    if (schema.view) {
        return (_jsx(CustomWidget, { fields: schema.fields, path: path, component: schema.view, namespace: NAMESPACE_EXTENSION }));
    }
    return (_jsx(I18nextProvider, { i18n: i18n, defaultNS: NAMESPACE_EXTENSION, children: _jsx(Widget, { fields: schema.fields, path: path, context: context }) }));
};
