{
  "version": 3,
  "sources": ["../../src/providers/helpers/restoreProvider.ts"],
  "sourcesContent": ["import { isMobileWebview } from 'lib/sdkWebviewProvider';\nimport {\n  ProviderBaseType,\n  ProviderTypeEnum\n} from 'providers/types/providerFactory.types';\nimport { providerTypeSelector } from 'store/selectors/loginInfoSelectors';\nimport { getState } from 'store/store';\nimport { getIsInIframe } from 'utils/window/getIsInIframe';\nimport { setAccountProvider } from './accountProvider';\nimport { ProviderFactory } from '../ProviderFactory';\n\nexport async function restoreProvider() {\n  const isMobileView = isMobileWebview();\n  const isInIframe = getIsInIframe();\n  const providerType = providerTypeSelector(getState());\n\n  let type =\n    isInIframe || isMobileView ? ProviderTypeEnum.webview : providerType;\n\n  const isBaseProvider = Object.values(ProviderTypeEnum).includes(\n    providerType as ProviderBaseType\n  );\n  // Check if provider exist and is not base\n  const isCustomProvider = providerType && !isBaseProvider;\n\n  // Prioritize customProvider if it serves as a provider inside an iframe\n  if (isCustomProvider) {\n    type = providerType;\n  }\n\n  if (!type) {\n    return;\n  }\n\n  const provider = await ProviderFactory.create({\n    type\n  });\n\n  if (!provider) {\n    throw new Error('Provider not found');\n  }\n\n  /*\n    Check if the app is running in webview and the provider is already initialized.\n    - true: the app is embedded within another dApp (e.g., inside an iframe) and perform login using the provider.\n    - false: the parent is not a dApp and proceed with initializing the current app as a standalone iframe.\n  */\n  const shouldStartWebviewLogin =\n    isMobileView ||\n    (type === ProviderTypeEnum.webview && provider.isInitialized());\n\n  if (shouldStartWebviewLogin) {\n    try {\n      await provider.login();\n    } catch (error) {\n      console.warn('Failed to login with provider', provider.getType(), error);\n    }\n  }\n\n  setAccountProvider(provider);\n}\n"],
  "mappings": "+RAWA,eAAsBA,GAAkB,CACtC,IAAMC,EAAeC,EAAgB,EAC/BC,EAAaC,EAAc,EAC3BC,EAAeC,EAAqBC,EAAS,CAAC,EAEhDC,EACFL,GAAcF,EAAeQ,EAAiB,QAAUJ,EAEpDK,EAAiB,OAAO,OAAOD,CAAgB,EAAE,SACrDJ,CACF,EASA,GAPyBA,GAAgB,CAACK,IAIxCF,EAAOH,GAGL,CAACG,EACH,OAGF,IAAMG,EAAW,MAAMC,EAAgB,OAAO,CAC5C,KAAAJ,CACF,CAAC,EAED,GAAI,CAACG,EACH,MAAM,IAAI,MAAM,oBAAoB,EAYtC,GAHEV,GACCO,IAASC,EAAiB,SAAWE,EAAS,cAAc,EAG7D,GAAI,CACF,MAAMA,EAAS,MAAM,CACvB,OAASE,EAAO,CACd,QAAQ,KAAK,gCAAiCF,EAAS,QAAQ,EAAGE,CAAK,CACzE,CAGFC,EAAmBH,CAAQ,CAC7B",
  "names": ["restoreProvider", "isMobileView", "isMobileWebview", "isInIframe", "getIsInIframe", "providerType", "providerTypeSelector", "getState", "type", "ProviderTypeEnum", "isBaseProvider", "provider", "ProviderFactory", "error", "setAccountProvider"]
}
