import React__default, { useState, useEffect } from 'react';
import { messages } from '../../messages/en.mjs';
import { readB2CInternals } from '../../utils/internal.mjs';
import { I18nProviderWrapper } from '../components/atoms/I18nProviderWrapper.mjs';
import { usePresentationWithDefault, PresentationContext } from '../components/PresentationConfig.mjs';
import AppContainer$1 from './Container.mjs';
import { GlobalContextProvider } from './GlobalContextProvider.mjs';
import { RUN_IN_DEV } from '../../../../core/src/utils/dev.mjs';
import { logger } from '../../../../core/src/utils/logger.mjs';

const AppContainer = ({ client, config, presentation, callbacks, strings, styles })=>{
    // Read the watermark out of sync storage, then read it out of async storage
    const [displayWatermark, setDisplayWatermark] = useState(()=>{
        const { displayWatermark } = readB2CInternals(client).bootstrap.getSync();
        return displayWatermark;
    });
    useEffect(()=>{
        readB2CInternals(client).bootstrap.getAsync().then((data)=>{
            readB2CInternals(client).networkClient.logEvent({
                name: 'render_login_screen',
                details: {
                    options: config,
                    bootstrap: data
                }
            });
            setDisplayWatermark(data.displayWatermark);
        });
    // eslint-disable-next-line react-hooks/exhaustive-deps -- SDK-1354
    }, [
        client
    ]);
    RUN_IN_DEV(()=>{
        if (styles) {
            logger.error('styles is deprecated and has no effect. Use the presentation prop instead.\n' + 'See https://stytch.com/docs/api-reference/consumer/frontend-sdks/react/upgrade-guide#step-by-step-guide');
        }
    });
    const presentationValue = usePresentationWithDefault(presentation, displayWatermark, config, 'Products');
    return /*#__PURE__*/ React__default.createElement(GlobalContextProvider, {
        client: client,
        config: config,
        callbacks: callbacks
    }, /*#__PURE__*/ React__default.createElement(PresentationContext.Provider, {
        value: presentationValue
    }, /*#__PURE__*/ React__default.createElement(I18nProviderWrapper, {
        messages: messages,
        overrides: strings
    }, /*#__PURE__*/ React__default.createElement(AppContainer$1, null))));
};

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