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 from './Container.mjs';
import { DEFAULT_STATE, GlobalContextProvider, AppScreens } from './GlobalContextProvider.mjs';
import { passkeyRegistration } from './Products.mjs';
import { addProduct } from './utils.mjs';

const PasskeyRegistrationContainer = ({ client, config: rawConfig, presentation, callbacks, strings, styles })=>{
    const config = addProduct(rawConfig, passkeyRegistration);
    /**
   * 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(({ displayWatermark })=>{
            setDisplayWatermark(displayWatermark);
        });
    }, [
        client
    ]);
    const initialState = {
        ...DEFAULT_STATE,
        screen: AppScreens.PasskeyRegistrationStart,
        formState: {
            ...DEFAULT_STATE.formState
        }
    };
    const presentationValue = usePresentationWithDefault(presentation, displayWatermark, config);
    return /*#__PURE__*/ React__default.createElement(GlobalContextProvider, {
        client: client,
        config: config,
        callbacks: callbacks,
        initialState: initialState
    }, /*#__PURE__*/ React__default.createElement(PresentationContext.Provider, {
        value: presentationValue
    }, /*#__PURE__*/ React__default.createElement(I18nProviderWrapper, {
        messages: messages,
        overrides: strings
    }, /*#__PURE__*/ React__default.createElement(AppContainer, null))));
};

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