{
  "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": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAgC,kCAChCC,EAGO,iDACPC,EAAqC,8CACrCC,EAAyB,uBACzBC,EAA8B,sCAC9BC,EAAmC,6BACnCC,EAAgC,8BAEhC,eAAsBR,GAAkB,CACtC,MAAMS,KAAe,mBAAgB,EAC/BC,KAAa,iBAAc,EAC3BC,KAAe,2BAAqB,YAAS,CAAC,EAEpD,IAAIC,EACFF,GAAcD,EAAe,mBAAiB,QAAUE,EAE1D,MAAME,EAAiB,OAAO,OAAO,kBAAgB,EAAE,SACrDF,CACF,EASA,GAPyBA,GAAgB,CAACE,IAIxCD,EAAOD,GAGL,CAACC,EACH,OAGF,MAAME,EAAW,MAAM,kBAAgB,OAAO,CAC5C,KAAAF,CACF,CAAC,EAED,GAAI,CAACE,EACH,MAAM,IAAI,MAAM,oBAAoB,EAYtC,GAHEL,GACCG,IAAS,mBAAiB,SAAWE,EAAS,cAAc,EAG7D,GAAI,CACF,MAAMA,EAAS,MAAM,CACvB,OAASC,EAAO,CACd,QAAQ,KAAK,gCAAiCD,EAAS,QAAQ,EAAGC,CAAK,CACzE,IAGF,sBAAmBD,CAAQ,CAC7B",
  "names": ["restoreProvider_exports", "__export", "restoreProvider", "__toCommonJS", "import_sdkWebviewProvider", "import_providerFactory", "import_loginInfoSelectors", "import_store", "import_getIsInIframe", "import_accountProvider", "import_ProviderFactory", "isMobileView", "isInIframe", "providerType", "type", "isBaseProvider", "provider", "error"]
}
