import React__default, { useEffect } from 'react';
import { messages } from '../../messages/b2b/en.mjs';
import { readB2BInternals } from '../../utils/internal.mjs';
import { I18nProviderWrapper } from '../components/atoms/I18nProviderWrapper.mjs';
import { IDPContextProvider } from '../components/organisms/IDPContextProvider.mjs';
import { usePresentationWithDefault, PresentationContext } from '../components/PresentationConfig.mjs';
import * as B2BProducts from './B2BProducts.mjs';
import { GlobalContextProvider, DEFAULT_STATE } from './GlobalContextProvider.mjs';
import { InternalAppContainer } from './InternalAppContainer.mjs';
import { IDPConsentScreen } from './screens/IDPConsent.mjs';
import { RUN_IN_DEV } from '../../../../core/src/utils/dev.mjs';
import { logger } from '../../../../core/src/utils/logger.mjs';

/**
 * Wrapper to add default organizationProducts value. This is done to preserve the ability for a future
 * component that doesn't do this, allowing B2B products to be properly tree-shaken (which is also why this is currently
 * in a completely different file)
 */ const AppContainer = ({ config, styles, ...props })=>{
    RUN_IN_DEV(()=>{
        if (styles) {
            logger.error('styles is deprecated and has no effect. Use the presentation prop instead.\n' + 'See https://staging.stytch.com/docs/api-reference/b2b/frontend-sdks/react/upgrade-guide');
        }
    });
    const internalConfig = {
        ...config,
        organizationProducts: Object.values(B2BProducts)
    };
    return /*#__PURE__*/ React__default.createElement(InternalAppContainer, {
        config: internalConfig,
        ...props
    });
};
const B2BIDPContainer = ({ client, presentation, callbacks, strings, getIDPConsentManifest, trustedAuthTokenParams, styles })=>{
    const presentationValue = usePresentationWithDefault(presentation, false, {
        products: []
    });
    useEffect(()=>{
        readB2BInternals(client).bootstrap.getAsync().then((data)=>{
            readB2BInternals(client).networkClient.logEvent({
                name: 'render_b2b_idp_screen',
                details: {
                    bootstrap: data
                }
            });
        });
    }, [
        client
    ]);
    RUN_IN_DEV(()=>{
        if (styles) {
            logger.error('styles is deprecated and has no effect. Use the presentation prop instead.\n' + 'See https://staging.stytch.com/docs/api-reference/b2b/frontend-sdks/react/upgrade-guide');
        }
    });
    return /*#__PURE__*/ React__default.createElement(GlobalContextProvider, {
        client: client,
        config: {},
        callbacks: callbacks,
        initialState: DEFAULT_STATE
    }, /*#__PURE__*/ React__default.createElement(IDPContextProvider, {
        consentManifestGenerator: getIDPConsentManifest,
        authTokenParams: trustedAuthTokenParams
    }, /*#__PURE__*/ React__default.createElement(PresentationContext.Provider, {
        value: presentationValue
    }, /*#__PURE__*/ React__default.createElement(I18nProviderWrapper, {
        messages: messages,
        overrides: strings
    }, /*#__PURE__*/ React__default.createElement(IDPConsentScreen, null)))));
};

export { AppContainer, B2BIDPContainer };
//# sourceMappingURL=App.mjs.map
