{"version":3,"file":"App.mjs","sources":["../../../../../../../../web/src/ui/b2b/App.tsx"],"sourcesContent":["import { logger, RUN_IN_DEV } from '@stytch/core';\nimport { StytchProjectConfigurationInput } from '@stytch/core/public';\nimport React, { useEffect } from 'react';\n\nimport { messages } from '../../messages/b2b/en';\nimport { B2BIDPSDKConfig, B2BSDKConfig, DeprecatedSDKConfig, StytchB2BExtendedLoginConfig } from '../../types';\nimport { readB2BInternals } from '../../utils/internal';\nimport { I18nProviderWrapper } from '../components/atoms/I18nProviderWrapper';\nimport { IDPContextProvider } from '../components/organisms/IDPContextProvider';\nimport { PresentationContext, usePresentationWithDefault } from '../components/PresentationConfig';\nimport * as B2BProducts from './B2BProducts';\nimport { DEFAULT_STATE, GlobalContextProvider } from './GlobalContextProvider';\nimport { InternalAppContainer } from './InternalAppContainer';\nimport { IDPConsentScreen } from './screens/IDPConsent';\n\n/**\n * Wrapper to add default organizationProducts value. This is done to preserve the ability for a future\n * component that doesn't do this, allowing B2B products to be properly tree-shaken (which is also why this is currently\n * in a completely different file)\n */\nexport const AppContainer = ({\n  config,\n  styles,\n  ...props\n}: B2BSDKConfig<StytchProjectConfigurationInput> & DeprecatedSDKConfig) => {\n  RUN_IN_DEV(() => {\n    if (styles) {\n      logger.error(\n        'styles is deprecated and has no effect. Use the presentation prop instead.\\n' +\n          'See https://staging.stytch.com/docs/api-reference/b2b/frontend-sdks/react/upgrade-guide',\n      );\n    }\n  });\n\n  const internalConfig = {\n    ...config,\n    organizationProducts: Object.values(B2BProducts),\n  };\n\n  return <InternalAppContainer config={internalConfig} {...props}></InternalAppContainer>;\n};\n\nexport const B2BIDPContainer = <TProjectConfiguration extends StytchProjectConfigurationInput>({\n  client,\n  presentation,\n  callbacks,\n  strings,\n  getIDPConsentManifest,\n  trustedAuthTokenParams,\n  styles,\n}: B2BIDPSDKConfig<TProjectConfiguration> & DeprecatedSDKConfig) => {\n  const presentationValue = usePresentationWithDefault(presentation, false, { products: [] });\n\n  useEffect(() => {\n    readB2BInternals(client)\n      .bootstrap.getAsync()\n      .then((data) => {\n        readB2BInternals(client).networkClient.logEvent({\n          name: 'render_b2b_idp_screen',\n          details: { bootstrap: data },\n        });\n      });\n  }, [client]);\n\n  RUN_IN_DEV(() => {\n    if (styles) {\n      logger.error(\n        'styles is deprecated and has no effect. Use the presentation prop instead.\\n' +\n          'See https://staging.stytch.com/docs/api-reference/b2b/frontend-sdks/react/upgrade-guide',\n      );\n    }\n  });\n\n  return (\n    <GlobalContextProvider\n      client={client}\n      config={{} as StytchB2BExtendedLoginConfig}\n      callbacks={callbacks}\n      initialState={DEFAULT_STATE}\n    >\n      <IDPContextProvider consentManifestGenerator={getIDPConsentManifest} authTokenParams={trustedAuthTokenParams}>\n        <PresentationContext.Provider value={presentationValue}>\n          <I18nProviderWrapper messages={messages} overrides={strings}>\n            <IDPConsentScreen />\n          </I18nProviderWrapper>\n        </PresentationContext.Provider>\n      </IDPContextProvider>\n    </GlobalContextProvider>\n  );\n};\n"],"names":["AppContainer","config","styles","props","RUN_IN_DEV","logger","error","internalConfig","organizationProducts","Object","values","B2BProducts","React","InternalAppContainer","B2BIDPContainer","client","presentation","callbacks","strings","getIDPConsentManifest","trustedAuthTokenParams","presentationValue","usePresentationWithDefault","products","useEffect","readB2BInternals","bootstrap","getAsync","then","data","networkClient","logEvent","name","details","GlobalContextProvider","initialState","DEFAULT_STATE","IDPContextProvider","consentManifestGenerator","authTokenParams","PresentationContext","Provider","value","I18nProviderWrapper","messages","overrides","IDPConsentScreen"],"mappings":";;;;;;;;;;;;;;AAeA;;;;IAKO,MAAMA,YAAAA,GAAe,CAAC,EAC3BC,MAAM,EACNC,MAAM,EACN,GAAGC,KAAAA,EACiE,GAAA;IACpEC,UAAAA,CAAW,IAAA;AACT,QAAA,IAAIF,MAAAA,EAAQ;YACVG,MAAAA,CAAOC,KAAK,CACV,8EAAA,GACE,yFAAA,CAAA;AAEN,QAAA;AACF,IAAA,CAAA,CAAA;AAEA,IAAA,MAAMC,cAA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