@dcl/auth-site 4.11.1 → 4.11.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/assets/{ConstantsUtil-D3z0Ivcf.js → ConstantsUtil-DbCWIe_n.js} +1 -1
  2. package/assets/{ContentfulRichText-CwpvNDfp.js → ContentfulRichText-CFOPzhvA.js} +1 -1
  3. package/assets/{ExchangeController-CTLvTe3M.js → ExchangeController-6HrRP9wr.js} +1 -1
  4. package/assets/{HelpersUtil-DH_bWYgR.js → HelpersUtil-CNkTVf39.js} +1 -1
  5. package/assets/{NetworkUtil-CvUeN6SC.js → NetworkUtil-4FWh3O9t.js} +1 -1
  6. package/assets/{SwapController-VNxvM-ru.js → SwapController-DLNlx1vu.js} +1 -1
  7. package/assets/{biconomy-uWrBqu14.js → biconomy-OKf-gxxI.js} +1 -1
  8. package/assets/{ccip-Ck0vdRb6.js → ccip-pB0fNC8b.js} +1 -1
  9. package/assets/{data-capture-DxdkC-zs.js → data-capture-BpTW780T.js} +1 -1
  10. package/assets/{email-m-hvq9yR.js → email-CXq9SEfI.js} +1 -1
  11. package/assets/{embedded-wallet-DXYZl8dW.js → embedded-wallet-CUGRlD4x.js} +1 -1
  12. package/assets/{engine-BP9MbTaa.js → engine-B8rwkNvc.js} +1 -1
  13. package/assets/{extractIPFS-BlR9XZBt.js → extractIPFS-CjjPk57q.js} +1 -1
  14. package/assets/{features-DjfnSO5o.js → features-CzeXbp-E.js} +1 -1
  15. package/assets/{fortmatic-D4w5-MB9.js → fortmatic-DXizOoHO.js} +1 -1
  16. package/assets/{getInstalledModules-BA7RCafO.js → getInstalledModules-CTJnKzC8.js} +1 -1
  17. package/assets/{if-defined-c44XlOr2.js → if-defined-DvK9S6YG.js} +1 -1
  18. package/assets/{in-app-wallet-calls-DWwXEW-I.js → in-app-wallet-calls-lumGtJli.js} +1 -1
  19. package/assets/{index-ByvTWpYB.js → index-0JGHFl0b.js} +1 -1
  20. package/assets/{index-z_PZPv2z.js → index-1VjbKjzJ.js} +1 -1
  21. package/assets/{index-C5HCss9t.js → index-B3RwNM75.js} +1 -1
  22. package/assets/{index-CkBzHXTa.js → index-BCftKuCG.js} +1 -1
  23. package/assets/{index-Du-zsiof.js → index-BD8bjuSM.js} +1 -1
  24. package/assets/{index-DrzZEjxU.js → index-BEbkHcHD.js} +2 -2
  25. package/assets/index-BKOttcwv.js +1 -0
  26. package/assets/{index-B8V_Gua3.js → index-BRZ2mAco.js} +1 -1
  27. package/assets/{index-BK4EaQoQ.js → index-BWHhohcT.js} +1 -1
  28. package/assets/{index-LXq3A1tO.js → index-Bclo1orD.js} +1 -1
  29. package/assets/{index-CZXXMblS.js → index-Bdd5QjRv.js} +1 -1
  30. package/assets/{index-B_hPWAv-.js → index-BmC-88Ta.js} +3 -3
  31. package/assets/{index-CWtZsUgg.js → index-BqMC2qTI.js} +1 -1
  32. package/assets/{index-CQ3wP0_P.js → index-C1NNqLYz.js} +1 -1
  33. package/assets/{index-Db4gjeSL.js → index-CDkhfRid.js} +1 -1
  34. package/assets/{index-B7S3qNGA.js → index-CDrhJg_-.js} +1 -1
  35. package/assets/{index-COGXVD6s.js → index-CLs2JU0m.js} +1 -1
  36. package/assets/{index-DgLFkUD1.js → index-CWr-Bdjc.js} +1 -1
  37. package/assets/{index-C5UHmImP.js → index-C_7wT4-U.js} +1 -1
  38. package/assets/{index-DtxEqR9I.js → index-Ca4D7a_a.js} +1 -1
  39. package/assets/{index-DJBFB3mB.js → index-CaLVX2Mc.js} +1 -1
  40. package/assets/{index-CjVg1Y56.js → index-CaQYfnaC.js} +1 -1
  41. package/assets/{index-CY-fRScv.css → index-Caf6hxBL.css} +1 -1
  42. package/assets/{index-ooAMiJ4y.js → index-CcM_mG89.js} +1 -1
  43. package/assets/{index-DXxU6Q6U.js → index-CcwnclZr.js} +1 -1
  44. package/assets/{index-DxwRNqgX.js → index-CnSzTO9Y.js} +1 -1
  45. package/assets/{index-rUP73pzB.js → index-Cv55CQzJ.js} +180 -176
  46. package/assets/{index-Dg3K1Vw3.js → index-D135KeMk.js} +4 -4
  47. package/assets/{index-Bn3JX8yK.js → index-D3A5b5cR.js} +1 -1
  48. package/assets/{index-BTpLgKXg.js → index-D8hdZvc3.js} +1 -1
  49. package/assets/{index-CI9qYMNa.js → index-DAYw9_bK.js} +1 -1
  50. package/assets/{index-BHPGJDn1.js → index-DIcSLnsm.js} +1 -1
  51. package/assets/{index-BfOpfRfr.js → index-DNTdadAd.js} +1 -1
  52. package/assets/{index-DXE0HB_s.js → index-DQGscWOJ.js} +1 -1
  53. package/assets/{index-B4r2T0V7.js → index-DS6c0LhG.js} +1 -1
  54. package/assets/{index-BpA6Si5_.js → index-Dj8iTG2A.js} +1 -1
  55. package/assets/{index-lGPNwbxe.js → index-Dm4Ub8Ng.js} +1 -1
  56. package/assets/{index-BSDoeqBk.js → index-DyVujfJO.js} +1 -1
  57. package/assets/{index-CMByj6EO.js → index-NsOP5EeB.js} +1 -1
  58. package/assets/{index-hv8BmCVq.js → index-gS4R6X96.js} +1 -1
  59. package/assets/{index-BkHQ3jRF.js → index-lm3H8ZqV.js} +1 -1
  60. package/assets/{networks-D_o5yDwd.js → networks-l1N0r1ca.js} +1 -1
  61. package/assets/{onramp-IF4ngNfj.js → onramp-C6VeIxRX.js} +1 -1
  62. package/assets/{openzeppelin-Dx6i2B2r.js → openzeppelin-PYqssIwJ.js} +1 -1
  63. package/assets/{parse-typed-data-DFH4Wadf.js → parse-typed-data-Bjqw4h8C.js} +1 -1
  64. package/assets/{passkeys-B7dJQJDN.js → passkeys-D0W4dAEq.js} +1 -1
  65. package/assets/{pay-with-exchange-e-xM6cxq.js → pay-with-exchange-DyIsm6M5.js} +1 -1
  66. package/assets/{receive-DcGe3k64.js → receive-Cr569auA.js} +1 -1
  67. package/assets/{ref-tRykIzet.js → ref-rrv5E-Qp.js} +1 -1
  68. package/assets/{resolveImplementation-CY2AZ4BU.js → resolveImplementation-Cfk4DWIw.js} +1 -1
  69. package/assets/{secp256k1-BNq3uWuW.js → secp256k1-mcaETN1J.js} +1 -1
  70. package/assets/{send-WJTqnbjw.js → send-BjW-mxWP.js} +1 -1
  71. package/assets/{send-eip712-transaction-CwY5vZTA.js → send-eip712-transaction-CCdsZHgb.js} +1 -1
  72. package/assets/{send-gasless-transaction-Hnb2WBcO.js → send-gasless-transaction-C6dJuYqB.js} +2 -2
  73. package/assets/{socials-BQk98Z9K.js → socials-CLeePNo5.js} +1 -1
  74. package/assets/{swaps-DyVYpdw2.js → swaps-DwfYQ1UG.js} +1 -1
  75. package/assets/{thirdweb-D6clKR4w.js → thirdweb-DJ2OLvBE.js} +3 -3
  76. package/assets/{transactions-Bl3b8qIX.js → transactions-XzU_vC_a.js} +1 -1
  77. package/assets/{ui-byNMPSE1.css → ui-DkpUgtr0.css} +3 -3
  78. package/assets/{ui-DNHWrHSH.js → ui-Dy6xokVk.js} +5 -5
  79. package/assets/{vendor-BgiNx-Ph.js → vendor-Co_R173r.js} +1 -1
  80. package/assets/{verifyHash-B-nU7EV3.js → verifyHash-0_zj-9ie.js} +3 -3
  81. package/assets/{w3m-modal-B205prEk.js → w3m-modal-CHA0-x_-.js} +1 -1
  82. package/assets/{web-connector-BKWKHTzg.js → web-connector-BMxyQb5O.js} +3 -3
  83. package/index.html +6 -6
  84. package/package.json +3 -3
  85. package/assets/index-B6Hui9GU.js +0 -5
  86. package/assets/index-BEPqkRql.js +0 -1
  87. package/assets/index-dCX8yVbC.js +0 -1
@@ -1,9 +1,9 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/in-app-wallet-calls-DWwXEW-I.js","assets/thirdweb-D6clKR4w.js","assets/passkeys-B7dJQJDN.js","assets/index-rUP73pzB.js","assets/ui-DNHWrHSH.js","assets/vendor-BgiNx-Ph.js","assets/ui-byNMPSE1.css","assets/index-CY-fRScv.css"])))=>i.map(i=>d[i]);
2
- import{K as w,ai as p,i as g,r as X,T as b,m as y,_ as I,aj as Z,b as P,A as M,ad as z,y as W,j as ee,ak as v,al as $,am as te}from"./thirdweb-D6clKR4w.js";import{a as ae}from"./types-DC0Zmj1B.js";import{p as G}from"./parse-typed-data-DFH4Wadf.js";const x={async getItem(a){try{if(typeof window<"u"&&window.localStorage)return localStorage.getItem(a)}catch{}return null},async removeItem(a){typeof window<"u"&&window.localStorage&&localStorage.removeItem(a)},async setItem(a,e){try{typeof window<"u"&&window.localStorage&&localStorage.setItem(a,e)}catch{}}},ne="/sdk/2022-08-12/embedded-wallet",A=a=>`thirdwebEwsWalletUserId-${a}`,ie="walletToken",T=a=>`${ie}-${a}`,j=a=>`passkey-credential-id-${a}`,re="a",E=(a,e)=>`${re}-${a}-${e}`,D=a=>`walletConnectSessions-${a}`,U=a=>`thirdweb_guest_session_id_${a}`,F=new Map;class V{constructor({storage:e,clientId:t,ecosystem:n}){Object.defineProperty(this,"key",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"storage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ecosystem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.storage=e,this.key=se(t,n==null?void 0:n.id),this.ecosystem=n}async getItem(e){return this.storage?this.storage.getItem(e):F.get(e)??null}async setItem(e,t){if(this.storage)return this.storage.setItem(e,t);F.set(e,t)}async removeItem(e){const t=await this.getItem(e);return this.storage&&t?(this.storage.removeItem(e),!0):!1}async getWalletConnectSessions(){return this.getItem(D(this.key))}async saveWalletConnectSessions(e){await this.setItem(D(this.key),e)}async savePasskeyCredentialId(e){await this.setItem(j(this.key),e)}async getPasskeyCredentialId(){return this.getItem(j(this.key))}async saveAuthCookie(e){await this.setItem(T(this.key),e)}async getAuthCookie(){return this.getItem(T(this.key))}async removeAuthCookie(){return this.removeItem(T(this.key))}async saveDeviceShare(e,t){await this.saveWalletUserId(t),await this.setItem(E(this.key,t),e)}async getDeviceShare(){const e=await this.getWalletUserId();return e?this.getItem(E(this.key,e)):null}async removeDeviceShare(){const e=await this.getWalletUserId();return e?this.removeItem(E(this.key,e)):!1}async getWalletUserId(){return this.getItem(A(this.key))}async saveWalletUserId(e){await this.setItem(A(this.key),e)}async removeWalletUserId(){return this.removeItem(A(this.key))}async getGuestSessionId(){return this.getItem(U(this.key))}async saveGuestSessionId(e){await this.setItem(U(this.key),e)}}const se=(a,e)=>`${a}${e?`-${e}`:""}`,S=new Map,oe={getItem:async a=>S.get(a)??null,removeItem:async a=>{S.delete(a)},setItem:async(a,e)=>{S.set(a,e)}};async function O({authToken:a,client:e,ecosystem:t}){const r=await w(e,t)(`${p("inAppWallet")}/api/2024-05-05/accounts`,{headers:{Authorization:`Bearer embedded-wallet-token:${a}`,"Content-Type":"application/json"},method:"GET"});if(!r.ok){const l=await r.text().catch(()=>"Unknown error");throw new Error(`Failed to get user info: ${l}`)}return await r.json()}const ce=p("inAppWallet"),le=`${ce}/`,H=`${le}api/2023-10-20`,ue=`${H}/embedded-wallet/validate-custom-jwt`,de=`${H}/embedded-wallet/validate-custom-auth-endpoint`,q=(a,e)=>e instanceof Error?`${a}: ${e.message}`:`${a}: ${g(e)}`;async function he(a){const t=await w(a.client,a.ecosystem)(de,{body:g({developerClientId:a.client.clientId,payload:a.payload}),headers:{"Content-Type":"application/json"},method:"POST"});if(!t.ok){const n=await t.json();throw new Error(`Custom auth endpoint authentication error: ${n.message}`)}try{const{verifiedToken:n}=await t.json();return{storedToken:n}}catch(n){throw new Error(q("Malformed response from post auth_endpoint authentication",n))}}const Q=a=>{if(!ae.includes(a))throw new Error(`Unknown auth option ${a}`);switch(a){case"wallet":return"siwe";default:return a}},k=({authOption:a,client:e,ecosystem:t,mode:n="popup",redirectUrl:r})=>{if(n==="popup"&&r)throw new Error("Redirect URL is not supported for popup mode");if(n==="window"&&!r)throw new Error("Redirect URL is required for window mode");const l=Q(a);let o=`${p("inAppWallet")}/api/2024-05-05/login/${l}?clientId=${e.clientId}`;if(t!=null&&t.partnerId?o=`${o}&ecosystemId=${t.id}&ecosystemPartnerId=${t.partnerId}`:t&&(o=`${o}&ecosystemId=${t.id}`),n!=="popup"){const i=new URL(r||window.location.href);i.searchParams.set("walletId",(t==null?void 0:t.id)||"inApp"),i.searchParams.set("authProvider",a),o=`${o}&redirectUrl=${encodeURIComponent(i.toString())}`}return o},C=({authOption:a,client:e,ecosystem:t})=>{const n=Q(a);let r=`${p("inAppWallet")}/api/2024-05-05/login/${n}/callback?clientId=${e.clientId}`;return t!=null&&t.partnerId?r=`${r}&ecosystemId=${t.id}&ecosystemPartnerId=${t.partnerId}`:t&&(r=`${r}&ecosystemId=${t.id}`),r};async function we(a){const e=w(a.client,a.ecosystem),t=k({authOption:"backend",client:a.client,ecosystem:a.ecosystem}),n=await e(`${t}`,{body:g({walletSecret:a.walletSecret}),headers:{"Content-Type":"application/json"},method:"POST"});if(!n.ok){const r=await n.text();throw new Error(`Failed to generate backend account: ${r}`)}return await n.json()}async function pe(a){let e=await a.storage.getGuestSessionId();e||(e=X(32),a.storage.saveGuestSessionId(e));const t=w(a.client,a.ecosystem),n=C({authOption:"guest",client:a.client,ecosystem:a.ecosystem}),r=await t(`${n}`,{body:g({sessionId:e}),headers:{"Content-Type":"application/json"},method:"POST"});if(!r.ok){const l=await r.text();throw new Error(`Failed to generate guest account: ${r.status} ${r.statusText} ${l}`)}return await r.json()}async function ge(a){const t=await w(a.client,a.ecosystem)(ue,{body:g({developerClientId:a.client.clientId,jwt:a.jwt}),headers:{"Content-Type":"application/json"},method:"POST"});if(!t.ok){const n=await t.json();throw new Error(`JWT authentication error: ${n.message}`)}try{const{verifiedToken:n}=await t.json();return{storedToken:n}}catch(n){throw new Error(q("Malformed response from post jwt authentication",n))}}async function me({client:a,ecosystem:e,tokenToLink:t,storage:n}){const r=w(a,e),l=p("inAppWallet"),o=await n.getAuthCookie();if(!o)throw new Error("Failed to link account, no user logged in");const i={Authorization:`Bearer iaw-auth-token:${o}`,"Content-Type":"application/json"},c=await r(`${l}/api/2024-05-05/account/connect`,{body:g({accountAuthTokenToConnect:t}),headers:i,method:"POST"});if(!c.ok){const u=await c.json();throw new Error(u.message||"Failed to link account.")}const{linkedAccounts:s}=await c.json();return s??[]}async function fe({client:a,ecosystem:e,profileToUnlink:t,allowAccountDeletion:n=!1,storage:r}){const l=w(a,e),o=p("inAppWallet"),i=await r.getAuthCookie();if(!i)throw new Error("Failed to unlink account, no user logged in");const c={Authorization:`Bearer iaw-auth-token:${i}`,"Content-Type":"application/json"},s=await l(`${o}/api/2024-05-05/account/disconnect`,{body:g({allowAccountDeletion:n,details:t.details,type:t.type}),headers:c,method:"POST"});if(!s.ok){const d=await s.json();throw new Error(d.message||"Failed to unlink account.")}const{linkedAccounts:u}=await s.json();return u??[]}async function ye({client:a,ecosystem:e,storage:t}){const n=w(a,e),r=p("inAppWallet"),l=await t.getAuthCookie();if(!l)throw new Error("Failed to get linked accounts, no user logged in");const o={Authorization:`Bearer iaw-auth-token:${l}`,"Content-Type":"application/json"},i=await n(`${r}/api/2024-05-05/accounts`,{headers:o,method:"GET"});if(!i.ok){const s=await i.json();throw new Error(s.message||"Failed to get linked accounts.")}const{linkedAccounts:c}=await i.json();return c??[]}function J(){return`${p("inAppWallet")}/api/2024-05-05/login/passkey/callback`}function K(a,e){return`${p("inAppWallet")}/api/2024-05-05/login/passkey?type=${a}${e?`&username=${e}`:""}`}async function Ie(a){var u,d,h;if(!a.passkeyClient.isAvailable())throw new Error("Passkeys are not available on this device");const e=w(a.client,a.ecosystem),t=a.username??ke(a.ecosystem),r=await(await e(K("sign-up",t))).json();if(!r.challenge)throw new Error("No challenge received");const l=r.challenge,o=await a.passkeyClient.register({challenge:l,name:t,rp:a.rp}),i={};(u=a.ecosystem)!=null&&u.partnerId&&(i["x-ecosystem-partner-id"]=a.ecosystem.partnerId),(d=a.ecosystem)!=null&&d.id&&(i["x-ecosystem-id"]=a.ecosystem.id);const s=await(await e(J(),{body:g({authenticatorData:o.authenticatorData,clientData:o.clientData,credential:{algorithm:o.credential.algorithm,publicKey:o.credential.publicKey},credentialId:o.credentialId,origin:o.origin,rpId:a.rp.id,serverVerificationId:r.serverVerificationId,type:"sign-up",username:t}),headers:{"Content-Type":"application/json",...i},method:"POST"})).json();if(!s||!s.storedToken)throw new Error(`Error verifying passkey: ${s.message??"unknown error"}`);return await((h=a.storage)==null?void 0:h.savePasskeyCredentialId(o.credentialId)),s}async function be(a){var s,u,d,h;if(!a.passkeyClient.isAvailable())throw new Error("Passkeys are not available on this device");const e=w(a.client,a.ecosystem),[t,n]=await Promise.all([e(K("sign-in")).then(f=>f.json()),(s=a.storage)==null?void 0:s.getPasskeyCredentialId()]);if(!t.challenge)throw new Error("No challenge received");const r=t.challenge,l=await a.passkeyClient.authenticate({challenge:r,credentialId:n??void 0,rp:a.rp}),o={};(u=a.ecosystem)!=null&&u.partnerId&&(o["x-ecosystem-partner-id"]=a.ecosystem.partnerId),(d=a.ecosystem)!=null&&d.id&&(o["x-ecosystem-id"]=a.ecosystem.id);const c=await(await e(J(),{body:g({authenticatorData:l.authenticatorData,clientData:l.clientData,credentialId:l.credentialId,origin:l.origin,rpId:a.rp.id,serverVerificationId:t.serverVerificationId,signature:l.signature,type:"sign-in"}),headers:{"Content-Type":"application/json",...o},method:"POST"})).json();if(!c||!c.storedToken)throw new Error(`Error verifying passkey: ${c.message??"unknown error"}`);return await((h=a.storage)==null?void 0:h.savePasskeyCredentialId(l.credentialId)),c}function ke(a){return`${(a==null?void 0:a.id)??"wallet"}-${new Date().toISOString()}`}function ve(a){let n=[`${a.domain} wants you to sign in with your Ethereum account:`,a.address].join(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/in-app-wallet-calls-lumGtJli.js","assets/thirdweb-DJ2OLvBE.js","assets/passkeys-D0W4dAEq.js","assets/index-Cv55CQzJ.js","assets/ui-Dy6xokVk.js","assets/vendor-Co_R173r.js","assets/ui-DkpUgtr0.css","assets/index-Caf6hxBL.css"])))=>i.map(i=>d[i]);
2
+ import{K as w,ai as p,i as g,r as X,T as b,m as y,_ as I,aj as Z,b as P,A as M,ad as z,y as W,j as ee,ak as v,al as $,am as te}from"./thirdweb-DJ2OLvBE.js";import{a as ae}from"./types-DC0Zmj1B.js";import{p as G}from"./parse-typed-data-Bjqw4h8C.js";const x={async getItem(a){try{if(typeof window<"u"&&window.localStorage)return localStorage.getItem(a)}catch{}return null},async removeItem(a){typeof window<"u"&&window.localStorage&&localStorage.removeItem(a)},async setItem(a,e){try{typeof window<"u"&&window.localStorage&&localStorage.setItem(a,e)}catch{}}},ne="/sdk/2022-08-12/embedded-wallet",A=a=>`thirdwebEwsWalletUserId-${a}`,ie="walletToken",T=a=>`${ie}-${a}`,j=a=>`passkey-credential-id-${a}`,re="a",E=(a,e)=>`${re}-${a}-${e}`,D=a=>`walletConnectSessions-${a}`,U=a=>`thirdweb_guest_session_id_${a}`,F=new Map;class V{constructor({storage:e,clientId:t,ecosystem:n}){Object.defineProperty(this,"key",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"storage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ecosystem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.storage=e,this.key=se(t,n==null?void 0:n.id),this.ecosystem=n}async getItem(e){return this.storage?this.storage.getItem(e):F.get(e)??null}async setItem(e,t){if(this.storage)return this.storage.setItem(e,t);F.set(e,t)}async removeItem(e){const t=await this.getItem(e);return this.storage&&t?(this.storage.removeItem(e),!0):!1}async getWalletConnectSessions(){return this.getItem(D(this.key))}async saveWalletConnectSessions(e){await this.setItem(D(this.key),e)}async savePasskeyCredentialId(e){await this.setItem(j(this.key),e)}async getPasskeyCredentialId(){return this.getItem(j(this.key))}async saveAuthCookie(e){await this.setItem(T(this.key),e)}async getAuthCookie(){return this.getItem(T(this.key))}async removeAuthCookie(){return this.removeItem(T(this.key))}async saveDeviceShare(e,t){await this.saveWalletUserId(t),await this.setItem(E(this.key,t),e)}async getDeviceShare(){const e=await this.getWalletUserId();return e?this.getItem(E(this.key,e)):null}async removeDeviceShare(){const e=await this.getWalletUserId();return e?this.removeItem(E(this.key,e)):!1}async getWalletUserId(){return this.getItem(A(this.key))}async saveWalletUserId(e){await this.setItem(A(this.key),e)}async removeWalletUserId(){return this.removeItem(A(this.key))}async getGuestSessionId(){return this.getItem(U(this.key))}async saveGuestSessionId(e){await this.setItem(U(this.key),e)}}const se=(a,e)=>`${a}${e?`-${e}`:""}`,S=new Map,oe={getItem:async a=>S.get(a)??null,removeItem:async a=>{S.delete(a)},setItem:async(a,e)=>{S.set(a,e)}};async function O({authToken:a,client:e,ecosystem:t}){const r=await w(e,t)(`${p("inAppWallet")}/api/2024-05-05/accounts`,{headers:{Authorization:`Bearer embedded-wallet-token:${a}`,"Content-Type":"application/json"},method:"GET"});if(!r.ok){const l=await r.text().catch(()=>"Unknown error");throw new Error(`Failed to get user info: ${l}`)}return await r.json()}const ce=p("inAppWallet"),le=`${ce}/`,H=`${le}api/2023-10-20`,ue=`${H}/embedded-wallet/validate-custom-jwt`,de=`${H}/embedded-wallet/validate-custom-auth-endpoint`,q=(a,e)=>e instanceof Error?`${a}: ${e.message}`:`${a}: ${g(e)}`;async function he(a){const t=await w(a.client,a.ecosystem)(de,{body:g({developerClientId:a.client.clientId,payload:a.payload}),headers:{"Content-Type":"application/json"},method:"POST"});if(!t.ok){const n=await t.json();throw new Error(`Custom auth endpoint authentication error: ${n.message}`)}try{const{verifiedToken:n}=await t.json();return{storedToken:n}}catch(n){throw new Error(q("Malformed response from post auth_endpoint authentication",n))}}const Q=a=>{if(!ae.includes(a))throw new Error(`Unknown auth option ${a}`);switch(a){case"wallet":return"siwe";default:return a}},k=({authOption:a,client:e,ecosystem:t,mode:n="popup",redirectUrl:r})=>{if(n==="popup"&&r)throw new Error("Redirect URL is not supported for popup mode");if(n==="window"&&!r)throw new Error("Redirect URL is required for window mode");const l=Q(a);let o=`${p("inAppWallet")}/api/2024-05-05/login/${l}?clientId=${e.clientId}`;if(t!=null&&t.partnerId?o=`${o}&ecosystemId=${t.id}&ecosystemPartnerId=${t.partnerId}`:t&&(o=`${o}&ecosystemId=${t.id}`),n!=="popup"){const i=new URL(r||window.location.href);i.searchParams.set("walletId",(t==null?void 0:t.id)||"inApp"),i.searchParams.set("authProvider",a),o=`${o}&redirectUrl=${encodeURIComponent(i.toString())}`}return o},C=({authOption:a,client:e,ecosystem:t})=>{const n=Q(a);let r=`${p("inAppWallet")}/api/2024-05-05/login/${n}/callback?clientId=${e.clientId}`;return t!=null&&t.partnerId?r=`${r}&ecosystemId=${t.id}&ecosystemPartnerId=${t.partnerId}`:t&&(r=`${r}&ecosystemId=${t.id}`),r};async function we(a){const e=w(a.client,a.ecosystem),t=k({authOption:"backend",client:a.client,ecosystem:a.ecosystem}),n=await e(`${t}`,{body:g({walletSecret:a.walletSecret}),headers:{"Content-Type":"application/json"},method:"POST"});if(!n.ok){const r=await n.text();throw new Error(`Failed to generate backend account: ${r}`)}return await n.json()}async function pe(a){let e=await a.storage.getGuestSessionId();e||(e=X(32),a.storage.saveGuestSessionId(e));const t=w(a.client,a.ecosystem),n=C({authOption:"guest",client:a.client,ecosystem:a.ecosystem}),r=await t(`${n}`,{body:g({sessionId:e}),headers:{"Content-Type":"application/json"},method:"POST"});if(!r.ok){const l=await r.text();throw new Error(`Failed to generate guest account: ${r.status} ${r.statusText} ${l}`)}return await r.json()}async function ge(a){const t=await w(a.client,a.ecosystem)(ue,{body:g({developerClientId:a.client.clientId,jwt:a.jwt}),headers:{"Content-Type":"application/json"},method:"POST"});if(!t.ok){const n=await t.json();throw new Error(`JWT authentication error: ${n.message}`)}try{const{verifiedToken:n}=await t.json();return{storedToken:n}}catch(n){throw new Error(q("Malformed response from post jwt authentication",n))}}async function me({client:a,ecosystem:e,tokenToLink:t,storage:n}){const r=w(a,e),l=p("inAppWallet"),o=await n.getAuthCookie();if(!o)throw new Error("Failed to link account, no user logged in");const i={Authorization:`Bearer iaw-auth-token:${o}`,"Content-Type":"application/json"},c=await r(`${l}/api/2024-05-05/account/connect`,{body:g({accountAuthTokenToConnect:t}),headers:i,method:"POST"});if(!c.ok){const u=await c.json();throw new Error(u.message||"Failed to link account.")}const{linkedAccounts:s}=await c.json();return s??[]}async function fe({client:a,ecosystem:e,profileToUnlink:t,allowAccountDeletion:n=!1,storage:r}){const l=w(a,e),o=p("inAppWallet"),i=await r.getAuthCookie();if(!i)throw new Error("Failed to unlink account, no user logged in");const c={Authorization:`Bearer iaw-auth-token:${i}`,"Content-Type":"application/json"},s=await l(`${o}/api/2024-05-05/account/disconnect`,{body:g({allowAccountDeletion:n,details:t.details,type:t.type}),headers:c,method:"POST"});if(!s.ok){const d=await s.json();throw new Error(d.message||"Failed to unlink account.")}const{linkedAccounts:u}=await s.json();return u??[]}async function ye({client:a,ecosystem:e,storage:t}){const n=w(a,e),r=p("inAppWallet"),l=await t.getAuthCookie();if(!l)throw new Error("Failed to get linked accounts, no user logged in");const o={Authorization:`Bearer iaw-auth-token:${l}`,"Content-Type":"application/json"},i=await n(`${r}/api/2024-05-05/accounts`,{headers:o,method:"GET"});if(!i.ok){const s=await i.json();throw new Error(s.message||"Failed to get linked accounts.")}const{linkedAccounts:c}=await i.json();return c??[]}function J(){return`${p("inAppWallet")}/api/2024-05-05/login/passkey/callback`}function K(a,e){return`${p("inAppWallet")}/api/2024-05-05/login/passkey?type=${a}${e?`&username=${e}`:""}`}async function Ie(a){var u,d,h;if(!a.passkeyClient.isAvailable())throw new Error("Passkeys are not available on this device");const e=w(a.client,a.ecosystem),t=a.username??ke(a.ecosystem),r=await(await e(K("sign-up",t))).json();if(!r.challenge)throw new Error("No challenge received");const l=r.challenge,o=await a.passkeyClient.register({challenge:l,name:t,rp:a.rp}),i={};(u=a.ecosystem)!=null&&u.partnerId&&(i["x-ecosystem-partner-id"]=a.ecosystem.partnerId),(d=a.ecosystem)!=null&&d.id&&(i["x-ecosystem-id"]=a.ecosystem.id);const s=await(await e(J(),{body:g({authenticatorData:o.authenticatorData,clientData:o.clientData,credential:{algorithm:o.credential.algorithm,publicKey:o.credential.publicKey},credentialId:o.credentialId,origin:o.origin,rpId:a.rp.id,serverVerificationId:r.serverVerificationId,type:"sign-up",username:t}),headers:{"Content-Type":"application/json",...i},method:"POST"})).json();if(!s||!s.storedToken)throw new Error(`Error verifying passkey: ${s.message??"unknown error"}`);return await((h=a.storage)==null?void 0:h.savePasskeyCredentialId(o.credentialId)),s}async function be(a){var s,u,d,h;if(!a.passkeyClient.isAvailable())throw new Error("Passkeys are not available on this device");const e=w(a.client,a.ecosystem),[t,n]=await Promise.all([e(K("sign-in")).then(f=>f.json()),(s=a.storage)==null?void 0:s.getPasskeyCredentialId()]);if(!t.challenge)throw new Error("No challenge received");const r=t.challenge,l=await a.passkeyClient.authenticate({challenge:r,credentialId:n??void 0,rp:a.rp}),o={};(u=a.ecosystem)!=null&&u.partnerId&&(o["x-ecosystem-partner-id"]=a.ecosystem.partnerId),(d=a.ecosystem)!=null&&d.id&&(o["x-ecosystem-id"]=a.ecosystem.id);const c=await(await e(J(),{body:g({authenticatorData:l.authenticatorData,clientData:l.clientData,credentialId:l.credentialId,origin:l.origin,rpId:a.rp.id,serverVerificationId:t.serverVerificationId,signature:l.signature,type:"sign-in"}),headers:{"Content-Type":"application/json",...o},method:"POST"})).json();if(!c||!c.storedToken)throw new Error(`Error verifying passkey: ${c.message??"unknown error"}`);return await((h=a.storage)==null?void 0:h.savePasskeyCredentialId(l.credentialId)),c}function ke(a){return`${(a==null?void 0:a.id)??"wallet"}-${new Date().toISOString()}`}function ve(a){let n=[`${a.domain} wants you to sign in with your Ethereum account:`,a.address].join(`
3
3
  `);n=[n,a.statement].join(`
4
4
 
5
5
  `),a.statement&&(n+=`
6
6
  `);const r=[];if(a.uri){const u=`URI: ${a.uri}`;r.push(u)}const l=`Version: ${a.version}`;if(r.push(l),a.chain_id){const u=`Chain ID: ${a.chain_id}`||"1";r.push(u)}const o=`Nonce: ${a.nonce}`;r.push(o);const i=`Issued At: ${a.issued_at}`;r.push(i);const c=`Expiration Time: ${a.expiration_time}`;if(r.push(c),a.invalid_before){const u=`Not Before: ${a.invalid_before}`;r.push(u)}a.resources&&r.push(["Resources:",...a.resources.map(u=>`- ${u}`)].join(`
7
7
  `));const s=r.join(`
8
8
  `);return[n,s].join(`
9
- `)}async function Ae(a){const{payload:e,account:t}=a,n=await t.signMessage({message:ve(e)});return{payload:e,signature:n}}const Te=["xyz.abs"];async function Ee(a){const{wallet:e,client:t,ecosystem:n,chain:r}=a,l=Te.includes(e.id)?r||b(1):b(1),o=e.getAccount()||await e.connect({chain:l,client:t}),i=w(t,n),c=await(async()=>{const d=k({authOption:"wallet",client:a.client,ecosystem:a.ecosystem}),h=await i(`${d}&address=${o.address}&chainId=${l.id}`);if(!h.ok)throw new Error("Failed to generate SIWE login payload");return await h.json()})(),{signature:s}=await Ae({account:o,payload:c});return await(async()=>{const d=C({authOption:"wallet",client:a.client,ecosystem:a.ecosystem}),h=await i(`${d}&signature=${s}&payload=${encodeURIComponent(c)}`,{body:g({payload:c,signature:s}),headers:{"Content-Type":"application/json"},method:"POST"});if(!h.ok)throw new Error("Failed to verify SIWE signature");return await h.json()})()}async function Se({client:a,payload:e,storage:t}){const n=await t.getAuthCookie(),r=t.ecosystem,l=w(a,r);if(!n)throw new Error("No auth token found when signing message");const o={address:e.address,chainId:e.chainId,nonce:Number(e.nonce)},i=await l(`${p("inAppWallet")}/api/v1/enclave-wallet/sign-authorization`,{body:g(o),headers:{Authorization:`Bearer embedded-wallet-token:${n}`,"Content-Type":"application/json","x-thirdweb-client-id":a.clientId},method:"POST"});if(!i.ok)throw new Error(`Failed to sign message - ${i.status} ${i.statusText}`);return await i.json()}async function Le({client:a,payload:{message:e,isRaw:t,originalMessage:n,chainId:r},storage:l}){const o=await l.getAuthCookie(),i=l.ecosystem,c=w(a,i);if(!o)throw new Error("No auth token found when signing message");const s=await c(`${p("inAppWallet")}/api/v1/enclave-wallet/sign-message`,{body:g({messagePayload:{chainId:r,isRaw:t,message:e,originalMessage:n}}),headers:{Authorization:`Bearer embedded-wallet-token:${o}`,"Content-Type":"application/json","x-thirdweb-client-id":a.clientId},method:"POST"});if(!s.ok)throw new Error(`Failed to sign message - ${s.status} ${s.statusText}`);return await s.json()}async function Pe({client:a,payload:e,storage:t}){const n=await t.getAuthCookie(),r=t.ecosystem,l=w(a,r);if(!n)throw new Error("No auth token found when signing transaction");const o=await l(`${p("inAppWallet")}/api/v1/enclave-wallet/sign-transaction`,{body:g({transactionPayload:e}),headers:{Authorization:`Bearer embedded-wallet-token:${n}`,"Content-Type":"application/json","x-thirdweb-client-id":a.clientId},method:"POST"});if(!o.ok)throw new Error(`Failed to sign transaction - ${o.status} ${o.statusText}`);return(await o.json()).signature}async function We({client:a,payload:e,storage:t}){const n=await t.getAuthCookie(),r=t.ecosystem,l=w(a,r);if(!n)throw new Error("No auth token found when signing typed data");const o=await l(`${p("inAppWallet")}/api/v1/enclave-wallet/sign-typed-data`,{body:g({...e}),headers:{Authorization:`Bearer embedded-wallet-token:${n}`,"Content-Type":"application/json","x-thirdweb-client-id":a.clientId},method:"POST"});if(!o.ok)throw new Error(`Failed to sign typed data - ${o.status} ${o.statusText}`);return await o.json()}class Oe{constructor({client:e,ecosystem:t,address:n,storage:r}){Object.defineProperty(this,"client",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ecosystem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"address",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"localStorage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.client=e,this.ecosystem=t,this.address=n,this.localStorage=r}async postWalletSetUp(e){await this.localStorage.saveAuthCookie(e.storedToken.cookieString)}async getUserWalletStatus(){var l,o;const e=await this.localStorage.getAuthCookie();if(!e)return{status:"Logged Out"};const t=await O({authToken:e,client:this.client,ecosystem:this.ecosystem});if(!t)return{status:"Logged Out"};const n=t.wallets[0],r={email:(l=t.linkedAccounts.find(i=>i.details.email!==void 0))==null?void 0:l.details.email,phoneNumber:(o=t.linkedAccounts.find(i=>i.details.phone!==void 0))==null?void 0:o.details.phone,recoveryShareManagement:"ENCLAVE",userWalletId:t.id||""};return n?{account:await this.getAccount(),authDetails:r,status:"Logged In, Wallet Initialized",walletAddress:n.address}:{authDetails:r,status:"Logged In, Wallet Uninitialized"}}async getAccount(){const e=this.client,t=this.localStorage,n=this.address,r=this.ecosystem,l=async i=>{const c=P({chain:b(i.chainId),client:e}),s={chainId:W(i.chainId),data:i.data,gas:m(i.gas),nonce:m(i.nonce)||W(await I(async()=>{const{eth_getTransactionCount:u}=await import("./thirdweb-D6clKR4w.js").then(d=>d.ax);return{eth_getTransactionCount:u}},[]).then(({eth_getTransactionCount:u})=>u(c,{address:y(this.address),blockTag:"pending"}))),to:i.to?y(i.to):void 0,value:m(i.value)};return i.authorizationList&&i.authorizationList.length>0?(s.type=4,s.authorizationList=i.authorizationList,s.maxFeePerGas=m(i.maxFeePerGas),s.maxPriorityFeePerGas=m(i.maxPriorityFeePerGas)):m(i.maxFeePerGas)?(s.maxFeePerGas=m(i.maxFeePerGas),s.maxPriorityFeePerGas=m(i.maxPriorityFeePerGas),s.type=2):(s.gasPrice=m(i.gasPrice),s.type=0),Pe({client:e,payload:s,storage:t})},o={address:y(n),async sendTransaction(i){const c=P({chain:b(i.chainId),client:e}),s=await l(i),u=await M(c,s);return z({chainId:i.chainId,client:e,contractAddress:i.to??void 0,ecosystem:r,gasPrice:i.gasPrice,transactionHash:u,walletAddress:n,walletType:"inApp"}),{transactionHash:u}},async signAuthorization(i){const c=await Se({client:e,payload:i,storage:t});return{address:y(c.address),chainId:Number.parseInt(c.chainId),nonce:BigInt(c.nonce),r:BigInt(c.r),s:BigInt(c.s),yParity:Number.parseInt(c.yParity)}},async signMessage({message:i,originalMessage:c,chainId:s}){const u=typeof i=="string"?{chainId:s,isRaw:!1,message:i,originalMessage:c}:{chainId:s,isRaw:!0,message:typeof i.raw=="string"?i.raw:Z(i.raw),originalMessage:c},{signature:d}=await Le({client:e,payload:u,storage:t});return d},async signTransaction(i){if(!i.chainId)throw new Error("chainId required in tx to sign");return l({chainId:i.chainId,...i})},async signTypedData(i){const c=G(i),{signature:s}=await We({client:e,payload:c,storage:t});return s},sendCalls:async i=>{const{inAppWalletSendCalls:c}=await I(async()=>{const{inAppWalletSendCalls:f}=await import("./in-app-wallet-calls-DWwXEW-I.js");return{inAppWalletSendCalls:f}},__vite__mapDeps([0,1])),s=i.calls[0];if(!s)throw new Error("No calls to send");const u=s.client,d=s.chain||i.chain,h=await c({account:o,calls:i.calls,chain:d});return{chain:d,client:u,id:h}},getCallsStatus:async i=>{const{inAppWalletGetCallsStatus:c}=await I(async()=>{const{inAppWalletGetCallsStatus:s}=await import("./in-app-wallet-calls-DWwXEW-I.js");return{inAppWalletGetCallsStatus:s}},__vite__mapDeps([0,1]));return c(i)},getCallsStatusRaw:async i=>{const{inAppWalletGetCallsStatusRaw:c}=await I(async()=>{const{inAppWalletGetCallsStatusRaw:s}=await import("./in-app-wallet-calls-DWwXEW-I.js");return{inAppWalletGetCallsStatusRaw:s}},__vite__mapDeps([0,1]));return c(i)},getCapabilities:async i=>({[i.chainId??1]:{atomic:{status:"unsupported"},paymasterService:{supported:!1}}})};return o}}function m(a){return a===void 0||ee(a)?a:W(a)}const Ce={backgroundColor:"transparent",border:"none",colorScheme:"light",display:"none",height:"100%",pointerEvents:"all",position:"fixed",right:"0px",top:"0px",width:"100%",zIndex:"2147483646"},L=new Map;class _e{constructor({link:e,baseUrl:t,iframeId:n,container:r,onIframeInitialize:l,localStorage:o,clientId:i,ecosystem:c}){if(Object.defineProperty(this,"iframe",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"POLLING_INTERVAL_SECONDS",{enumerable:!0,configurable:!0,writable:!0,value:1.4}),Object.defineProperty(this,"iframeBaseUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"localStorage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"clientId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ecosystem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.localStorage=o,this.clientId=i,this.ecosystem=c,this.iframeBaseUrl=t,typeof document>"u")return;r=r??document.body;let s=document.getElementById(n);const u=new URL(e);if(!s||s.src!==u.href){s=document.createElement("iframe");const d={...Ce};Object.assign(s.style,d),s.setAttribute("id",n),s.setAttribute("fetchpriority","high"),r.appendChild(s),s.src=u.href;const h=f=>{if(f.data.eventType==="ewsIframeLoaded"){if(window.removeEventListener("message",h),!s){console.warn("thirdweb iFrame not found");return}this.onIframeLoadHandler(s,l)()}};window.addEventListener("message",h)}this.iframe=s}async onIframeLoadedInitVariables(){var e,t;return{authCookie:await this.localStorage.getAuthCookie(),clientId:this.clientId,deviceShareStored:await this.localStorage.getDeviceShare(),ecosystemId:(e=this.ecosystem)==null?void 0:e.id,partnerId:(t=this.ecosystem)==null?void 0:t.partnerId,walletUserId:await this.localStorage.getWalletUserId()}}onIframeLoadHandler(e,t){return async()=>{var l;const n=new MessageChannel,r=new Promise((o,i)=>{n.port1.onmessage=c=>{const{data:s}=c;n.port1.close(),s.success||i(new Error(s.error)),L.set(e.src,!0),t&&t(),o(!0)}});(l=e==null?void 0:e.contentWindow)==null||l.postMessage({data:await this.onIframeLoadedInitVariables(),eventType:"initIframe"},this.iframeBaseUrl,[n.port2]),await r}}async call({procedureName:e,params:t,showIframe:n=!1}){var o;if(!this.iframe)throw new Error("Iframe not found. You are likely calling this from the backend where the DOM is not available.");for(;!L.get(this.iframe.src);)await v(this.POLLING_INTERVAL_SECONDS*1e3);n&&(this.iframe.style.display="block",await v(.005*1e3));const r=new MessageChannel,l=new Promise((i,c)=>{r.port1.onmessage=async s=>{const{data:u}=s;r.port1.close(),n&&(await v(.1*1e3),this.iframe&&(this.iframe.style.display="none")),u.success?i(u.data):c(new Error(u.error))}});return(o=this.iframe.contentWindow)==null||o.postMessage({data:{...t,...await this.onIframeLoadedInitVariables()},eventType:e},this.iframeBaseUrl,[r.port2]),l}destroy(){this.iframe&&L.delete(this.iframe.src)}}class $e extends _e{constructor({clientId:e,baseUrl:t,ecosystem:n}){super({baseUrl:t,clientId:e,container:typeof document>"u"?void 0:document.body,ecosystem:n,iframeId:De+((n==null?void 0:n.id)||""),link:je({baseUrl:t,clientId:e,ecosystem:n,path:ne}).href,localStorage:new V({clientId:e,ecosystem:n,storage:x})}),this.clientId=e,this.ecosystem=n}}function je({clientId:a,baseUrl:e,path:t,ecosystem:n,queryParams:r}){var o;const l=new URL(`${t}`,e);if(r)for(const i of Object.keys(r))l.searchParams.set(i,((o=r[i])==null?void 0:o.toString())||"");return l.searchParams.set("clientId",a),(n==null?void 0:n.partnerId)!==void 0&&l.searchParams.set("partnerId",n.partnerId),(n==null?void 0:n.id)!==void 0&&l.searchParams.set("ecosystemId",n.id),l}const De="thirdweb-in-app-wallet-iframe";async function Ue({client:a,ecosystem:e,authToken:t}){const r=await w(a,e)(`${p("inAppWallet")}/api/v1/enclave-wallet/generate`,{headers:{Authorization:`Bearer embedded-wallet-token:${t}`,"Content-Type":"application/json","x-thirdweb-client-id":a.clientId},method:"POST"});if(!r.ok)throw new Error(`Failed to generate wallet - ${r.status} ${r.statusText}`);const{wallet:l}=await r.json();return l}class Fe{constructor({baseUrl:e,querier:t,preLogin:n,postLogin:r,client:l,ecosystem:o}){Object.defineProperty(this,"LoginQuerier",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"preLogin",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"postLogin",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"client",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"baseUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ecosystem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.baseUrl=e,this.LoginQuerier=t,this.preLogin=n,this.postLogin=r,this.client=l,this.ecosystem=o}async sendEmailLoginOtp({email:e}){return await this.LoginQuerier.call({params:{email:e},procedureName:"sendThirdwebEmailLoginOtp"})}async sendSmsLoginOtp({phoneNumber:e}){return await this.LoginQuerier.call({params:{phoneNumber:e},procedureName:"sendThirdwebSmsLoginOtp"})}}class Ne extends Fe{async authenticateWithModal(){return this.LoginQuerier.call({params:void 0,procedureName:"loginWithThirdwebModal",showIframe:!0})}async loginWithModal(){await this.preLogin();const e=await this.authenticateWithModal();return this.postLogin(e)}async authenticateWithIframe({email:e}){return this.LoginQuerier.call({params:{email:e},procedureName:"loginWithThirdwebModal",showIframe:!0})}async loginWithIframe({email:e}){await this.preLogin();const t=await this.authenticateWithIframe({email:e});return this.postLogin(t)}async authenticateWithCustomJwt({encryptionKey:e,jwt:t}){if(!e||e.length===0)throw new Error("Encryption key is required for custom jwt auth");return this.LoginQuerier.call({params:{encryptionKey:e,jwt:t},procedureName:"loginWithCustomJwt"})}async loginWithCustomJwt({encryptionKey:e,jwt:t}){if(!e||e.length===0)throw new Error("Encryption key is required for custom jwt auth");await this.preLogin();const n=await this.authenticateWithCustomJwt({encryptionKey:e,jwt:t});return this.postLogin(n)}async authenticateWithCustomAuthEndpoint({encryptionKey:e,payload:t}){return this.LoginQuerier.call({params:{encryptionKey:e,payload:t},procedureName:"loginWithCustomAuthEndpoint"})}async loginWithCustomAuthEndpoint({encryptionKey:e,payload:t}){if(!e||e.length===0)throw new Error("Encryption key is required for custom auth");await this.preLogin();const n=await this.authenticateWithCustomAuthEndpoint({encryptionKey:e,payload:t});return this.postLogin(n)}async authenticateWithEmailOtp({email:e,otp:t,recoveryCode:n}){return this.LoginQuerier.call({params:{email:e,otp:t,recoveryCode:n},procedureName:"verifyThirdwebEmailLoginOtp"})}async loginWithEmailOtp({email:e,otp:t,recoveryCode:n}){const r=await this.authenticateWithEmailOtp({email:e,otp:t,recoveryCode:n});return this.postLogin(r)}async authenticateWithSmsOtp({phoneNumber:e,otp:t,recoveryCode:n}){return this.LoginQuerier.call({params:{otp:t,phoneNumber:e,recoveryCode:n},procedureName:"verifyThirdwebSmsLoginOtp"})}async loginWithSmsOtp({phoneNumber:e,otp:t,recoveryCode:n}){const r=await this.authenticateWithSmsOtp({otp:t,phoneNumber:e,recoveryCode:n});return this.postLogin(r)}}class Re{constructor({client:e,querier:t,onAuthSuccess:n,ecosystem:r,baseUrl:l,localStorage:o}){Object.defineProperty(this,"client",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ecosystem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"AuthQuerier",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"localStorage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onAuthSuccess",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"BaseLogin",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.client=e,this.ecosystem=r,this.AuthQuerier=t,this.localStorage=o,this.onAuthSuccess=n,this.BaseLogin=new Ne({baseUrl:l,client:e,ecosystem:r,postLogin:async i=>this.postLogin(i),preLogin:async()=>{await this.preLogin()},querier:t})}async preLogin(){await this.logout()}async postLogin({storedToken:e,walletDetails:t}){return e.shouldStoreCookieString&&await this.localStorage.saveAuthCookie(e.cookieString),await this.onAuthSuccess({storedToken:e,walletDetails:t})}async loginWithAuthToken(e,t){var l;e.storedToken.authProvider!=="Backend"&&await this.preLogin();const n=await O({authToken:e.storedToken.cookieString,client:this.client,ecosystem:this.ecosystem});if(!n)throw new Error("Cannot login, no user found for auth token");if(n.wallets.length>0&&((l=n.wallets[0])==null?void 0:l.type)==="enclave")return this.postLogin({storedToken:e.storedToken,walletDetails:{walletAddress:n.wallets[0].address}});if(n.wallets.length===0){const o=await Ue({authToken:e.storedToken.cookieString,client:this.client,ecosystem:this.ecosystem});return this.postLogin({storedToken:e.storedToken,walletDetails:{walletAddress:o.address}})}const r=await this.AuthQuerier.call({params:{recoveryCode:t,storedToken:e.storedToken},procedureName:"loginWithStoredTokenDetails"});return this.postLogin(r)}async loginWithModal(){return this.BaseLogin.loginWithModal()}async authenticateWithModal(){return this.BaseLogin.authenticateWithModal()}async loginWithIframe(e){return this.BaseLogin.loginWithIframe(e)}async authenticateWithIframe(e){return this.BaseLogin.authenticateWithIframe(e)}async loginWithCustomJwt(e){return this.BaseLogin.loginWithCustomJwt(e)}async authenticateWithCustomJwt(e){return this.BaseLogin.authenticateWithCustomJwt(e)}async loginWithCustomAuthEndpoint(e){return this.BaseLogin.loginWithCustomAuthEndpoint(e)}async authenticateWithCustomAuthEndpoint(e){return this.BaseLogin.authenticateWithCustomAuthEndpoint(e)}async sendEmailLoginOtp({email:e}){return this.BaseLogin.sendEmailLoginOtp({email:e})}async sendSmsLoginOtp({phoneNumber:e}){return this.BaseLogin.sendSmsLoginOtp({phoneNumber:e})}async loginWithEmailOtp(e){return await this.preLogin(),this.BaseLogin.loginWithEmailOtp(e)}async authenticateWithEmailOtp(e){return this.BaseLogin.authenticateWithEmailOtp(e)}async loginWithSmsOtp(e){return await this.preLogin(),this.BaseLogin.loginWithSmsOtp(e)}async authenticateWithSmsOtp(e){return this.BaseLogin.authenticateWithSmsOtp(e)}async logout(){const e=await this.localStorage.removeAuthCookie(),t=await this.localStorage.removeWalletUserId();return{success:e||t}}}const Be="width=350, height=500",N=({isWindowOpenedByFn:a,win:e,closeOpenedWindow:t})=>{a?e==null||e.close():e&&t?t(e):e&&e.close()};async function Me(a){const e=k({...a,mode:a.mode||"redirect"});a.mode==="redirect"?window.location.href=e:window.open(e),await new Promise(t=>setTimeout(t,5e3))}const ze=async a=>{let e=a.openedWindow,t=!1;if(e||(e=window.open(k({...a,mode:"popup"}),`Login to ${a.authOption}`,Be),t=!0),!e)throw new Error("Something went wrong opening pop-up");return await new Promise((r,l)=>{const o=window.setInterval(async()=>{e.closed&&(clearInterval(o),window.removeEventListener("message",i),l(new Error("User closed login window")))},1e3),i=async c=>{if(c.origin===p("inAppWallet")){if(typeof c.data!="object"){l(new Error("Invalid event data"));return}switch(c.data.eventType){case"oauthSuccessResult":{window.removeEventListener("message",i),clearInterval(o),N({closeOpenedWindow:a.closeOpenedWindow,isWindowOpenedByFn:t,win:e}),c.data.authResult&&r(c.data.authResult);break}case"oauthFailureResult":{window.removeEventListener("message",i),clearInterval(o),N({closeOpenedWindow:a.closeOpenedWindow,isWindowOpenedByFn:t,win:e}),l(new Error(c.data.errorString));break}}}};window.addEventListener("message",i)})},Ge=async a=>{const{client:e,ecosystem:t}=a,n=k({authOption:a.strategy,client:e,ecosystem:t}),r={"Content-Type":"application/json","x-client-id":e.clientId};t!=null&&t.id&&(r["x-ecosystem-id"]=t.id),t!=null&&t.partnerId&&(r["x-ecosystem-partner-id"]=t.partnerId);const l=(()=>{switch(a.strategy){case"email":return{email:a.email};case"phone":return{phone:a.phoneNumber}}})(),o=await fetch(n,{body:g(l),headers:r,method:"POST"});if(!o.ok){const i=await o.text();let c;try{const s=JSON.parse(i);s&&typeof s.message=="string"&&(c=s.message)}catch{}throw new Error(c||"Failed to send verification code")}return await o.json()},R=async a=>{const{client:e,ecosystem:t}=a,n=C({authOption:a.strategy,client:a.client,ecosystem:a.ecosystem}),r={"Content-Type":"application/json","x-client-id":e.clientId};t!=null&&t.id&&(r["x-ecosystem-id"]=t.id),t!=null&&t.partnerId&&(r["x-ecosystem-partner-id"]=t.partnerId);const l=(()=>{switch(a.strategy){case"email":return{code:a.verificationCode,email:a.email};case"phone":return{code:a.verificationCode,phone:a.phoneNumber}}})(),o=await fetch(n,{body:g(l),headers:r,method:"POST"});if(!o.ok)throw new Error("Failed to verify verification code");return await o.json()};class B{constructor({client:e,ecosystem:t,querier:n,localStorage:r}){Object.defineProperty(this,"client",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ecosystem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"walletManagerQuerier",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"localStorage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.client=e,this.ecosystem=t,this.walletManagerQuerier=n,this.localStorage=r}async postWalletSetUp(e){e.deviceShareStored&&await this.localStorage.saveDeviceShare(e.deviceShareStored,e.storedToken.authDetails.userWalletId)}async getUserWalletStatus(){const e=await this.walletManagerQuerier.call({params:void 0,procedureName:"getUserStatus"});return e.status==="Logged In, Wallet Initialized"?{status:"Logged In, Wallet Initialized",...e.user,account:await this.getAccount()}:e.status==="Logged In, New Device"?{status:"Logged In, New Device",...e.user}:e.status==="Logged In, Wallet Uninitialized"?{status:"Logged In, Wallet Uninitialized",...e.user}:{status:e.status}}async getAccount(){var o;const e=this.walletManagerQuerier,t=this.client,n=(o=this.ecosystem)==null?void 0:o.partnerId,{address:r}=await e.call({params:void 0,procedureName:"getAddress"}),l=async i=>{const c={chainId:i.chainId,data:i.data,gasLimit:i.gas,nonce:i.nonce,to:i.to??void 0,value:i.value};i.maxFeePerGas?(c.accessList=i.accessList,c.maxFeePerGas=i.maxFeePerGas,c.maxPriorityFeePerGas=i.maxPriorityFeePerGas,c.type=2):(c.gasPrice=i.gasPrice,c.type=0);const s=$().rpc,{signedTransaction:u}=await e.call({params:{chainId:i.chainId,partnerId:n,rpcEndpoint:`https://${i.chainId}.${s}`,transaction:c},procedureName:"signTransaction"});return u};return{address:y(r),async sendTransaction(i){const c=P({chain:b(i.chainId),client:t}),s=await l(i),u=await M(c,s);return z({chainId:i.chainId,client:t,contractAddress:i.to??void 0,gasPrice:i.gasPrice,transactionHash:u,walletAddress:r,walletType:"inApp"}),{transactionHash:u}},async signMessage({message:i}){const c=typeof i=="string"?i:i.raw instanceof Uint8Array?i.raw:te(i.raw),{signedMessage:s}=await e.call({params:{chainId:1,message:c,partnerId:n},procedureName:"signMessage"});return s},async signTransaction(i){if(!i.chainId)throw new Error("chainId required in tx to sign");return l({...i,chainId:i.chainId})},async signTypedData(i){var _;const c=G(i);(_=c.types)!=null&&_.EIP712Domain&&(c.types.EIP712Domain=void 0);const s=c.domain,u=s==null?void 0:s.chainId,h={...s!=null&&s.verifyingContract?{verifyingContract:s==null?void 0:s.verifyingContract}:{},name:s==null?void 0:s.name,version:s==null?void 0:s.version};u&&(h.chainId=u);const f=$().rpc,{signedTypedData:Y}=await e.call({params:{chainId:Number.parseInt(BigInt(u||1).toString()),domain:h,message:c.message,partnerId:n,rpcEndpoint:`https://${u}.${f}`,types:c.types},procedureName:"signTypedDataV4"});return Y}}}}class Je{isClientIdLegacyPaper(e){return e.indexOf("-")>0&&e.length===36}constructor({client:e,onAuthSuccess:t,ecosystem:n,passkeyDomain:r,storage:l}){if(Object.defineProperty(this,"client",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ecosystem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"querier",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"storage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"wallet",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"auth",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"passkeyDomain",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.isClientIdLegacyPaper(e.clientId))throw new Error("You are using a legacy clientId. Please use the clientId found on the thirdweb dashboard settings page");const o=p("inAppWallet");this.client=e,this.ecosystem=n,this.passkeyDomain=r,this.storage=new V({clientId:e.clientId,ecosystem:n,storage:l??Ve()}),this.querier=new $e({baseUrl:o,clientId:e.clientId,ecosystem:n}),this.auth=new Re({baseUrl:o,client:e,ecosystem:n,localStorage:this.storage,onAuthSuccess:async i=>{if(t==null||t(i),i.storedToken.authDetails.walletType==="sharded"&&(await this.querier.call({params:{storedToken:i.storedToken},procedureName:"migrateFromShardToEnclave"})||console.warn("Failed to migrate from sharded to enclave wallet, continuing with sharded wallet")),this.wallet=await this.initializeWallet(i.storedToken.cookieString),!this.wallet)throw new Error("Failed to initialize wallet");const c="deviceShareStored"in i.walletDetails?i.walletDetails.deviceShareStored:void 0;return await this.wallet.postWalletSetUp({deviceShareStored:c,storedToken:i.storedToken}),this.wallet instanceof B&&await this.querier.call({params:{authCookie:i.storedToken.cookieString,clientId:this.client.clientId,deviceShareStored:"deviceShareStored"in i.walletDetails?i.walletDetails.deviceShareStored:null,ecosystemId:n==null?void 0:n.id,partnerId:n==null?void 0:n.partnerId,walletUserId:i.storedToken.authDetails.userWalletId},procedureName:"initIframe"}),{user:{account:await this.wallet.getAccount(),authDetails:i.storedToken.authDetails,status:"Logged In, Wallet Initialized",walletAddress:i.walletDetails.walletAddress}}},querier:this.querier})}async initializeWallet(e){var r;const t=await this.storage.getAuthCookie();if(!e&&t===null)throw new Error("No auth token provided and no stored auth token found to initialize the wallet");const n=await O({authToken:e||t,client:this.client,ecosystem:this.ecosystem});if(!n)throw new Error("Cannot initialize wallet, no user logged in");if(n.wallets.length===0)throw new Error("Cannot initialize wallet, this user does not have a wallet generated yet");return((r=n.wallets[0])==null?void 0:r.type)==="enclave"?new Oe({address:n.wallets[0].address,client:this.client,ecosystem:this.ecosystem,storage:this.storage}):new B({client:this.client,ecosystem:this.ecosystem,localStorage:this.storage,querier:this.querier})}async getUser(){if(!this.wallet){const e=await this.storage.getAuthCookie();if(!e)return{status:"Logged Out"};this.wallet=await this.initializeWallet(e)}if(!this.wallet)throw new Error("Wallet not initialized");return await this.wallet.getUserWalletStatus()}getAccount(){if(!this.wallet)throw new Error("Wallet not initialized");return this.wallet.getAccount()}async preAuthenticate(e){return Ge({...e,client:this.client,ecosystem:this.ecosystem})}async authenticateWithRedirect(e,t,n){return Me({authOption:e,client:this.client,ecosystem:this.ecosystem,mode:t,redirectUrl:n})}async loginWithAuthToken(e,t){return this.auth.loginWithAuthToken(e,t)}async authenticate(e){const t=e.strategy;switch(t){case"email":return R({...e,client:this.client,ecosystem:this.ecosystem});case"phone":return R({...e,client:this.client,ecosystem:this.ecosystem});case"auth_endpoint":return he({client:this.client,ecosystem:this.ecosystem,payload:e.payload});case"jwt":return ge({client:this.client,ecosystem:this.ecosystem,jwt:e.jwt});case"passkey":return this.passkeyAuth(e);case"iframe_email_verification":return this.auth.authenticateWithIframe({email:e.email});case"iframe":return this.auth.authenticateWithModal();case"apple":case"facebook":case"google":case"telegram":case"github":case"twitch":case"farcaster":case"line":case"x":case"tiktok":case"epic":case"steam":case"coinbase":case"discord":return ze({authOption:t,client:this.client,closeOpenedWindow:e.closeOpenedWindow,ecosystem:this.ecosystem,openedWindow:e.openedWindow});case"guest":return pe({client:this.client,ecosystem:this.ecosystem,storage:this.storage});case"backend":return we({client:this.client,ecosystem:this.ecosystem,walletSecret:e.walletSecret});case"wallet":return Ee({client:this.client,ecosystem:this.ecosystem,wallet:e.wallet,chain:e.chain})}}async connect(e){const t=e.strategy;switch(t){case"auth_endpoint":case"jwt":{const n=await this.authenticate(e);return await this.loginWithAuthToken(n,e.encryptionKey)}case"iframe_email_verification":return this.auth.loginWithIframe({email:e.email});case"iframe":return this.auth.loginWithModal();case"passkey":{const n=await this.passkeyAuth(e);return this.loginWithAuthToken(n)}case"backend":case"phone":case"email":case"wallet":case"apple":case"facebook":case"google":case"farcaster":case"telegram":case"github":case"line":case"x":case"tiktok":case"epic":case"guest":case"coinbase":case"twitch":case"steam":case"discord":{const n=await this.authenticate(e);return await this.auth.loginWithAuthToken(n)}default:xe(t)}}async logout(){return await this.auth.logout()}async passkeyAuth(e){const{PasskeyWebClient:t}=await I(async()=>{const{PasskeyWebClient:i}=await import("./passkeys-B7dJQJDN.js");return{PasskeyWebClient:i}},__vite__mapDeps([2,3,1,4,5,6,7])),{passkeyName:n,storeLastUsedPasskey:r=!0}=e,l=new t,o=this.storage;return e.type==="sign-up"?Ie({client:this.client,ecosystem:this.ecosystem,passkeyClient:l,rp:{id:this.passkeyDomain??window.location.hostname,name:this.passkeyDomain??window.document.title},storage:r?o:void 0,username:n}):be({client:this.client,ecosystem:this.ecosystem,passkeyClient:l,rp:{id:this.passkeyDomain??window.location.hostname,name:this.passkeyDomain??window.document.title},storage:r?o:void 0})}async linkProfile(e){const{storedToken:t}=await this.authenticate(e);return await me({client:e.client,ecosystem:e.ecosystem||this.ecosystem,storage:this.storage,tokenToLink:t.cookieString})}async unlinkProfile(e,t){return await fe({allowAccountDeletion:t,client:this.client,ecosystem:this.ecosystem,profileToUnlink:e,storage:this.storage})}async getProfiles(){return ye({client:this.client,ecosystem:this.ecosystem,storage:this.storage})}}function xe(a,e){throw new Error(`Invalid param: ${a}`)}function Ve(){return typeof window<"u"&&window.localStorage?x:oe}export{Je as InAppWebConnector};
9
+ `)}async function Ae(a){const{payload:e,account:t}=a,n=await t.signMessage({message:ve(e)});return{payload:e,signature:n}}const Te=["xyz.abs"];async function Ee(a){const{wallet:e,client:t,ecosystem:n,chain:r}=a,l=Te.includes(e.id)?r||b(1):b(1),o=e.getAccount()||await e.connect({chain:l,client:t}),i=w(t,n),c=await(async()=>{const d=k({authOption:"wallet",client:a.client,ecosystem:a.ecosystem}),h=await i(`${d}&address=${o.address}&chainId=${l.id}`);if(!h.ok)throw new Error("Failed to generate SIWE login payload");return await h.json()})(),{signature:s}=await Ae({account:o,payload:c});return await(async()=>{const d=C({authOption:"wallet",client:a.client,ecosystem:a.ecosystem}),h=await i(`${d}&signature=${s}&payload=${encodeURIComponent(c)}`,{body:g({payload:c,signature:s}),headers:{"Content-Type":"application/json"},method:"POST"});if(!h.ok)throw new Error("Failed to verify SIWE signature");return await h.json()})()}async function Se({client:a,payload:e,storage:t}){const n=await t.getAuthCookie(),r=t.ecosystem,l=w(a,r);if(!n)throw new Error("No auth token found when signing message");const o={address:e.address,chainId:e.chainId,nonce:Number(e.nonce)},i=await l(`${p("inAppWallet")}/api/v1/enclave-wallet/sign-authorization`,{body:g(o),headers:{Authorization:`Bearer embedded-wallet-token:${n}`,"Content-Type":"application/json","x-thirdweb-client-id":a.clientId},method:"POST"});if(!i.ok)throw new Error(`Failed to sign message - ${i.status} ${i.statusText}`);return await i.json()}async function Le({client:a,payload:{message:e,isRaw:t,originalMessage:n,chainId:r},storage:l}){const o=await l.getAuthCookie(),i=l.ecosystem,c=w(a,i);if(!o)throw new Error("No auth token found when signing message");const s=await c(`${p("inAppWallet")}/api/v1/enclave-wallet/sign-message`,{body:g({messagePayload:{chainId:r,isRaw:t,message:e,originalMessage:n}}),headers:{Authorization:`Bearer embedded-wallet-token:${o}`,"Content-Type":"application/json","x-thirdweb-client-id":a.clientId},method:"POST"});if(!s.ok)throw new Error(`Failed to sign message - ${s.status} ${s.statusText}`);return await s.json()}async function Pe({client:a,payload:e,storage:t}){const n=await t.getAuthCookie(),r=t.ecosystem,l=w(a,r);if(!n)throw new Error("No auth token found when signing transaction");const o=await l(`${p("inAppWallet")}/api/v1/enclave-wallet/sign-transaction`,{body:g({transactionPayload:e}),headers:{Authorization:`Bearer embedded-wallet-token:${n}`,"Content-Type":"application/json","x-thirdweb-client-id":a.clientId},method:"POST"});if(!o.ok)throw new Error(`Failed to sign transaction - ${o.status} ${o.statusText}`);return(await o.json()).signature}async function We({client:a,payload:e,storage:t}){const n=await t.getAuthCookie(),r=t.ecosystem,l=w(a,r);if(!n)throw new Error("No auth token found when signing typed data");const o=await l(`${p("inAppWallet")}/api/v1/enclave-wallet/sign-typed-data`,{body:g({...e}),headers:{Authorization:`Bearer embedded-wallet-token:${n}`,"Content-Type":"application/json","x-thirdweb-client-id":a.clientId},method:"POST"});if(!o.ok)throw new Error(`Failed to sign typed data - ${o.status} ${o.statusText}`);return await o.json()}class Oe{constructor({client:e,ecosystem:t,address:n,storage:r}){Object.defineProperty(this,"client",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ecosystem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"address",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"localStorage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.client=e,this.ecosystem=t,this.address=n,this.localStorage=r}async postWalletSetUp(e){await this.localStorage.saveAuthCookie(e.storedToken.cookieString)}async getUserWalletStatus(){var l,o;const e=await this.localStorage.getAuthCookie();if(!e)return{status:"Logged Out"};const t=await O({authToken:e,client:this.client,ecosystem:this.ecosystem});if(!t)return{status:"Logged Out"};const n=t.wallets[0],r={email:(l=t.linkedAccounts.find(i=>i.details.email!==void 0))==null?void 0:l.details.email,phoneNumber:(o=t.linkedAccounts.find(i=>i.details.phone!==void 0))==null?void 0:o.details.phone,recoveryShareManagement:"ENCLAVE",userWalletId:t.id||""};return n?{account:await this.getAccount(),authDetails:r,status:"Logged In, Wallet Initialized",walletAddress:n.address}:{authDetails:r,status:"Logged In, Wallet Uninitialized"}}async getAccount(){const e=this.client,t=this.localStorage,n=this.address,r=this.ecosystem,l=async i=>{const c=P({chain:b(i.chainId),client:e}),s={chainId:W(i.chainId),data:i.data,gas:m(i.gas),nonce:m(i.nonce)||W(await I(async()=>{const{eth_getTransactionCount:u}=await import("./thirdweb-DJ2OLvBE.js").then(d=>d.ax);return{eth_getTransactionCount:u}},[]).then(({eth_getTransactionCount:u})=>u(c,{address:y(this.address),blockTag:"pending"}))),to:i.to?y(i.to):void 0,value:m(i.value)};return i.authorizationList&&i.authorizationList.length>0?(s.type=4,s.authorizationList=i.authorizationList,s.maxFeePerGas=m(i.maxFeePerGas),s.maxPriorityFeePerGas=m(i.maxPriorityFeePerGas)):m(i.maxFeePerGas)?(s.maxFeePerGas=m(i.maxFeePerGas),s.maxPriorityFeePerGas=m(i.maxPriorityFeePerGas),s.type=2):(s.gasPrice=m(i.gasPrice),s.type=0),Pe({client:e,payload:s,storage:t})},o={address:y(n),async sendTransaction(i){const c=P({chain:b(i.chainId),client:e}),s=await l(i),u=await M(c,s);return z({chainId:i.chainId,client:e,contractAddress:i.to??void 0,ecosystem:r,gasPrice:i.gasPrice,transactionHash:u,walletAddress:n,walletType:"inApp"}),{transactionHash:u}},async signAuthorization(i){const c=await Se({client:e,payload:i,storage:t});return{address:y(c.address),chainId:Number.parseInt(c.chainId),nonce:BigInt(c.nonce),r:BigInt(c.r),s:BigInt(c.s),yParity:Number.parseInt(c.yParity)}},async signMessage({message:i,originalMessage:c,chainId:s}){const u=typeof i=="string"?{chainId:s,isRaw:!1,message:i,originalMessage:c}:{chainId:s,isRaw:!0,message:typeof i.raw=="string"?i.raw:Z(i.raw),originalMessage:c},{signature:d}=await Le({client:e,payload:u,storage:t});return d},async signTransaction(i){if(!i.chainId)throw new Error("chainId required in tx to sign");return l({chainId:i.chainId,...i})},async signTypedData(i){const c=G(i),{signature:s}=await We({client:e,payload:c,storage:t});return s},sendCalls:async i=>{const{inAppWalletSendCalls:c}=await I(async()=>{const{inAppWalletSendCalls:f}=await import("./in-app-wallet-calls-lumGtJli.js");return{inAppWalletSendCalls:f}},__vite__mapDeps([0,1])),s=i.calls[0];if(!s)throw new Error("No calls to send");const u=s.client,d=s.chain||i.chain,h=await c({account:o,calls:i.calls,chain:d});return{chain:d,client:u,id:h}},getCallsStatus:async i=>{const{inAppWalletGetCallsStatus:c}=await I(async()=>{const{inAppWalletGetCallsStatus:s}=await import("./in-app-wallet-calls-lumGtJli.js");return{inAppWalletGetCallsStatus:s}},__vite__mapDeps([0,1]));return c(i)},getCallsStatusRaw:async i=>{const{inAppWalletGetCallsStatusRaw:c}=await I(async()=>{const{inAppWalletGetCallsStatusRaw:s}=await import("./in-app-wallet-calls-lumGtJli.js");return{inAppWalletGetCallsStatusRaw:s}},__vite__mapDeps([0,1]));return c(i)},getCapabilities:async i=>({[i.chainId??1]:{atomic:{status:"unsupported"},paymasterService:{supported:!1}}})};return o}}function m(a){return a===void 0||ee(a)?a:W(a)}const Ce={backgroundColor:"transparent",border:"none",colorScheme:"light",display:"none",height:"100%",pointerEvents:"all",position:"fixed",right:"0px",top:"0px",width:"100%",zIndex:"2147483646"},L=new Map;class _e{constructor({link:e,baseUrl:t,iframeId:n,container:r,onIframeInitialize:l,localStorage:o,clientId:i,ecosystem:c}){if(Object.defineProperty(this,"iframe",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"POLLING_INTERVAL_SECONDS",{enumerable:!0,configurable:!0,writable:!0,value:1.4}),Object.defineProperty(this,"iframeBaseUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"localStorage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"clientId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ecosystem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.localStorage=o,this.clientId=i,this.ecosystem=c,this.iframeBaseUrl=t,typeof document>"u")return;r=r??document.body;let s=document.getElementById(n);const u=new URL(e);if(!s||s.src!==u.href){s=document.createElement("iframe");const d={...Ce};Object.assign(s.style,d),s.setAttribute("id",n),s.setAttribute("fetchpriority","high"),r.appendChild(s),s.src=u.href;const h=f=>{if(f.data.eventType==="ewsIframeLoaded"){if(window.removeEventListener("message",h),!s){console.warn("thirdweb iFrame not found");return}this.onIframeLoadHandler(s,l)()}};window.addEventListener("message",h)}this.iframe=s}async onIframeLoadedInitVariables(){var e,t;return{authCookie:await this.localStorage.getAuthCookie(),clientId:this.clientId,deviceShareStored:await this.localStorage.getDeviceShare(),ecosystemId:(e=this.ecosystem)==null?void 0:e.id,partnerId:(t=this.ecosystem)==null?void 0:t.partnerId,walletUserId:await this.localStorage.getWalletUserId()}}onIframeLoadHandler(e,t){return async()=>{var l;const n=new MessageChannel,r=new Promise((o,i)=>{n.port1.onmessage=c=>{const{data:s}=c;n.port1.close(),s.success||i(new Error(s.error)),L.set(e.src,!0),t&&t(),o(!0)}});(l=e==null?void 0:e.contentWindow)==null||l.postMessage({data:await this.onIframeLoadedInitVariables(),eventType:"initIframe"},this.iframeBaseUrl,[n.port2]),await r}}async call({procedureName:e,params:t,showIframe:n=!1}){var o;if(!this.iframe)throw new Error("Iframe not found. You are likely calling this from the backend where the DOM is not available.");for(;!L.get(this.iframe.src);)await v(this.POLLING_INTERVAL_SECONDS*1e3);n&&(this.iframe.style.display="block",await v(.005*1e3));const r=new MessageChannel,l=new Promise((i,c)=>{r.port1.onmessage=async s=>{const{data:u}=s;r.port1.close(),n&&(await v(.1*1e3),this.iframe&&(this.iframe.style.display="none")),u.success?i(u.data):c(new Error(u.error))}});return(o=this.iframe.contentWindow)==null||o.postMessage({data:{...t,...await this.onIframeLoadedInitVariables()},eventType:e},this.iframeBaseUrl,[r.port2]),l}destroy(){this.iframe&&L.delete(this.iframe.src)}}class $e extends _e{constructor({clientId:e,baseUrl:t,ecosystem:n}){super({baseUrl:t,clientId:e,container:typeof document>"u"?void 0:document.body,ecosystem:n,iframeId:De+((n==null?void 0:n.id)||""),link:je({baseUrl:t,clientId:e,ecosystem:n,path:ne}).href,localStorage:new V({clientId:e,ecosystem:n,storage:x})}),this.clientId=e,this.ecosystem=n}}function je({clientId:a,baseUrl:e,path:t,ecosystem:n,queryParams:r}){var o;const l=new URL(`${t}`,e);if(r)for(const i of Object.keys(r))l.searchParams.set(i,((o=r[i])==null?void 0:o.toString())||"");return l.searchParams.set("clientId",a),(n==null?void 0:n.partnerId)!==void 0&&l.searchParams.set("partnerId",n.partnerId),(n==null?void 0:n.id)!==void 0&&l.searchParams.set("ecosystemId",n.id),l}const De="thirdweb-in-app-wallet-iframe";async function Ue({client:a,ecosystem:e,authToken:t}){const r=await w(a,e)(`${p("inAppWallet")}/api/v1/enclave-wallet/generate`,{headers:{Authorization:`Bearer embedded-wallet-token:${t}`,"Content-Type":"application/json","x-thirdweb-client-id":a.clientId},method:"POST"});if(!r.ok)throw new Error(`Failed to generate wallet - ${r.status} ${r.statusText}`);const{wallet:l}=await r.json();return l}class Fe{constructor({baseUrl:e,querier:t,preLogin:n,postLogin:r,client:l,ecosystem:o}){Object.defineProperty(this,"LoginQuerier",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"preLogin",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"postLogin",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"client",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"baseUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ecosystem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.baseUrl=e,this.LoginQuerier=t,this.preLogin=n,this.postLogin=r,this.client=l,this.ecosystem=o}async sendEmailLoginOtp({email:e}){return await this.LoginQuerier.call({params:{email:e},procedureName:"sendThirdwebEmailLoginOtp"})}async sendSmsLoginOtp({phoneNumber:e}){return await this.LoginQuerier.call({params:{phoneNumber:e},procedureName:"sendThirdwebSmsLoginOtp"})}}class Ne extends Fe{async authenticateWithModal(){return this.LoginQuerier.call({params:void 0,procedureName:"loginWithThirdwebModal",showIframe:!0})}async loginWithModal(){await this.preLogin();const e=await this.authenticateWithModal();return this.postLogin(e)}async authenticateWithIframe({email:e}){return this.LoginQuerier.call({params:{email:e},procedureName:"loginWithThirdwebModal",showIframe:!0})}async loginWithIframe({email:e}){await this.preLogin();const t=await this.authenticateWithIframe({email:e});return this.postLogin(t)}async authenticateWithCustomJwt({encryptionKey:e,jwt:t}){if(!e||e.length===0)throw new Error("Encryption key is required for custom jwt auth");return this.LoginQuerier.call({params:{encryptionKey:e,jwt:t},procedureName:"loginWithCustomJwt"})}async loginWithCustomJwt({encryptionKey:e,jwt:t}){if(!e||e.length===0)throw new Error("Encryption key is required for custom jwt auth");await this.preLogin();const n=await this.authenticateWithCustomJwt({encryptionKey:e,jwt:t});return this.postLogin(n)}async authenticateWithCustomAuthEndpoint({encryptionKey:e,payload:t}){return this.LoginQuerier.call({params:{encryptionKey:e,payload:t},procedureName:"loginWithCustomAuthEndpoint"})}async loginWithCustomAuthEndpoint({encryptionKey:e,payload:t}){if(!e||e.length===0)throw new Error("Encryption key is required for custom auth");await this.preLogin();const n=await this.authenticateWithCustomAuthEndpoint({encryptionKey:e,payload:t});return this.postLogin(n)}async authenticateWithEmailOtp({email:e,otp:t,recoveryCode:n}){return this.LoginQuerier.call({params:{email:e,otp:t,recoveryCode:n},procedureName:"verifyThirdwebEmailLoginOtp"})}async loginWithEmailOtp({email:e,otp:t,recoveryCode:n}){const r=await this.authenticateWithEmailOtp({email:e,otp:t,recoveryCode:n});return this.postLogin(r)}async authenticateWithSmsOtp({phoneNumber:e,otp:t,recoveryCode:n}){return this.LoginQuerier.call({params:{otp:t,phoneNumber:e,recoveryCode:n},procedureName:"verifyThirdwebSmsLoginOtp"})}async loginWithSmsOtp({phoneNumber:e,otp:t,recoveryCode:n}){const r=await this.authenticateWithSmsOtp({otp:t,phoneNumber:e,recoveryCode:n});return this.postLogin(r)}}class Re{constructor({client:e,querier:t,onAuthSuccess:n,ecosystem:r,baseUrl:l,localStorage:o}){Object.defineProperty(this,"client",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ecosystem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"AuthQuerier",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"localStorage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onAuthSuccess",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"BaseLogin",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.client=e,this.ecosystem=r,this.AuthQuerier=t,this.localStorage=o,this.onAuthSuccess=n,this.BaseLogin=new Ne({baseUrl:l,client:e,ecosystem:r,postLogin:async i=>this.postLogin(i),preLogin:async()=>{await this.preLogin()},querier:t})}async preLogin(){await this.logout()}async postLogin({storedToken:e,walletDetails:t}){return e.shouldStoreCookieString&&await this.localStorage.saveAuthCookie(e.cookieString),await this.onAuthSuccess({storedToken:e,walletDetails:t})}async loginWithAuthToken(e,t){var l;e.storedToken.authProvider!=="Backend"&&await this.preLogin();const n=await O({authToken:e.storedToken.cookieString,client:this.client,ecosystem:this.ecosystem});if(!n)throw new Error("Cannot login, no user found for auth token");if(n.wallets.length>0&&((l=n.wallets[0])==null?void 0:l.type)==="enclave")return this.postLogin({storedToken:e.storedToken,walletDetails:{walletAddress:n.wallets[0].address}});if(n.wallets.length===0){const o=await Ue({authToken:e.storedToken.cookieString,client:this.client,ecosystem:this.ecosystem});return this.postLogin({storedToken:e.storedToken,walletDetails:{walletAddress:o.address}})}const r=await this.AuthQuerier.call({params:{recoveryCode:t,storedToken:e.storedToken},procedureName:"loginWithStoredTokenDetails"});return this.postLogin(r)}async loginWithModal(){return this.BaseLogin.loginWithModal()}async authenticateWithModal(){return this.BaseLogin.authenticateWithModal()}async loginWithIframe(e){return this.BaseLogin.loginWithIframe(e)}async authenticateWithIframe(e){return this.BaseLogin.authenticateWithIframe(e)}async loginWithCustomJwt(e){return this.BaseLogin.loginWithCustomJwt(e)}async authenticateWithCustomJwt(e){return this.BaseLogin.authenticateWithCustomJwt(e)}async loginWithCustomAuthEndpoint(e){return this.BaseLogin.loginWithCustomAuthEndpoint(e)}async authenticateWithCustomAuthEndpoint(e){return this.BaseLogin.authenticateWithCustomAuthEndpoint(e)}async sendEmailLoginOtp({email:e}){return this.BaseLogin.sendEmailLoginOtp({email:e})}async sendSmsLoginOtp({phoneNumber:e}){return this.BaseLogin.sendSmsLoginOtp({phoneNumber:e})}async loginWithEmailOtp(e){return await this.preLogin(),this.BaseLogin.loginWithEmailOtp(e)}async authenticateWithEmailOtp(e){return this.BaseLogin.authenticateWithEmailOtp(e)}async loginWithSmsOtp(e){return await this.preLogin(),this.BaseLogin.loginWithSmsOtp(e)}async authenticateWithSmsOtp(e){return this.BaseLogin.authenticateWithSmsOtp(e)}async logout(){const e=await this.localStorage.removeAuthCookie(),t=await this.localStorage.removeWalletUserId();return{success:e||t}}}const Be="width=350, height=500",N=({isWindowOpenedByFn:a,win:e,closeOpenedWindow:t})=>{a?e==null||e.close():e&&t?t(e):e&&e.close()};async function Me(a){const e=k({...a,mode:a.mode||"redirect"});a.mode==="redirect"?window.location.href=e:window.open(e),await new Promise(t=>setTimeout(t,5e3))}const ze=async a=>{let e=a.openedWindow,t=!1;if(e||(e=window.open(k({...a,mode:"popup"}),`Login to ${a.authOption}`,Be),t=!0),!e)throw new Error("Something went wrong opening pop-up");return await new Promise((r,l)=>{const o=window.setInterval(async()=>{e.closed&&(clearInterval(o),window.removeEventListener("message",i),l(new Error("User closed login window")))},1e3),i=async c=>{if(c.origin===p("inAppWallet")){if(typeof c.data!="object"){l(new Error("Invalid event data"));return}switch(c.data.eventType){case"oauthSuccessResult":{window.removeEventListener("message",i),clearInterval(o),N({closeOpenedWindow:a.closeOpenedWindow,isWindowOpenedByFn:t,win:e}),c.data.authResult&&r(c.data.authResult);break}case"oauthFailureResult":{window.removeEventListener("message",i),clearInterval(o),N({closeOpenedWindow:a.closeOpenedWindow,isWindowOpenedByFn:t,win:e}),l(new Error(c.data.errorString));break}}}};window.addEventListener("message",i)})},Ge=async a=>{const{client:e,ecosystem:t}=a,n=k({authOption:a.strategy,client:e,ecosystem:t}),r={"Content-Type":"application/json","x-client-id":e.clientId};t!=null&&t.id&&(r["x-ecosystem-id"]=t.id),t!=null&&t.partnerId&&(r["x-ecosystem-partner-id"]=t.partnerId);const l=(()=>{switch(a.strategy){case"email":return{email:a.email};case"phone":return{phone:a.phoneNumber}}})(),o=await fetch(n,{body:g(l),headers:r,method:"POST"});if(!o.ok){const i=await o.text();let c;try{const s=JSON.parse(i);s&&typeof s.message=="string"&&(c=s.message)}catch{}throw new Error(c||"Failed to send verification code")}return await o.json()},R=async a=>{const{client:e,ecosystem:t}=a,n=C({authOption:a.strategy,client:a.client,ecosystem:a.ecosystem}),r={"Content-Type":"application/json","x-client-id":e.clientId};t!=null&&t.id&&(r["x-ecosystem-id"]=t.id),t!=null&&t.partnerId&&(r["x-ecosystem-partner-id"]=t.partnerId);const l=(()=>{switch(a.strategy){case"email":return{code:a.verificationCode,email:a.email};case"phone":return{code:a.verificationCode,phone:a.phoneNumber}}})(),o=await fetch(n,{body:g(l),headers:r,method:"POST"});if(!o.ok)throw new Error("Failed to verify verification code");return await o.json()};class B{constructor({client:e,ecosystem:t,querier:n,localStorage:r}){Object.defineProperty(this,"client",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ecosystem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"walletManagerQuerier",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"localStorage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.client=e,this.ecosystem=t,this.walletManagerQuerier=n,this.localStorage=r}async postWalletSetUp(e){e.deviceShareStored&&await this.localStorage.saveDeviceShare(e.deviceShareStored,e.storedToken.authDetails.userWalletId)}async getUserWalletStatus(){const e=await this.walletManagerQuerier.call({params:void 0,procedureName:"getUserStatus"});return e.status==="Logged In, Wallet Initialized"?{status:"Logged In, Wallet Initialized",...e.user,account:await this.getAccount()}:e.status==="Logged In, New Device"?{status:"Logged In, New Device",...e.user}:e.status==="Logged In, Wallet Uninitialized"?{status:"Logged In, Wallet Uninitialized",...e.user}:{status:e.status}}async getAccount(){var o;const e=this.walletManagerQuerier,t=this.client,n=(o=this.ecosystem)==null?void 0:o.partnerId,{address:r}=await e.call({params:void 0,procedureName:"getAddress"}),l=async i=>{const c={chainId:i.chainId,data:i.data,gasLimit:i.gas,nonce:i.nonce,to:i.to??void 0,value:i.value};i.maxFeePerGas?(c.accessList=i.accessList,c.maxFeePerGas=i.maxFeePerGas,c.maxPriorityFeePerGas=i.maxPriorityFeePerGas,c.type=2):(c.gasPrice=i.gasPrice,c.type=0);const s=$().rpc,{signedTransaction:u}=await e.call({params:{chainId:i.chainId,partnerId:n,rpcEndpoint:`https://${i.chainId}.${s}`,transaction:c},procedureName:"signTransaction"});return u};return{address:y(r),async sendTransaction(i){const c=P({chain:b(i.chainId),client:t}),s=await l(i),u=await M(c,s);return z({chainId:i.chainId,client:t,contractAddress:i.to??void 0,gasPrice:i.gasPrice,transactionHash:u,walletAddress:r,walletType:"inApp"}),{transactionHash:u}},async signMessage({message:i}){const c=typeof i=="string"?i:i.raw instanceof Uint8Array?i.raw:te(i.raw),{signedMessage:s}=await e.call({params:{chainId:1,message:c,partnerId:n},procedureName:"signMessage"});return s},async signTransaction(i){if(!i.chainId)throw new Error("chainId required in tx to sign");return l({...i,chainId:i.chainId})},async signTypedData(i){var _;const c=G(i);(_=c.types)!=null&&_.EIP712Domain&&(c.types.EIP712Domain=void 0);const s=c.domain,u=s==null?void 0:s.chainId,h={...s!=null&&s.verifyingContract?{verifyingContract:s==null?void 0:s.verifyingContract}:{},name:s==null?void 0:s.name,version:s==null?void 0:s.version};u&&(h.chainId=u);const f=$().rpc,{signedTypedData:Y}=await e.call({params:{chainId:Number.parseInt(BigInt(u||1).toString()),domain:h,message:c.message,partnerId:n,rpcEndpoint:`https://${u}.${f}`,types:c.types},procedureName:"signTypedDataV4"});return Y}}}}class Je{isClientIdLegacyPaper(e){return e.indexOf("-")>0&&e.length===36}constructor({client:e,onAuthSuccess:t,ecosystem:n,passkeyDomain:r,storage:l}){if(Object.defineProperty(this,"client",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ecosystem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"querier",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"storage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"wallet",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"auth",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"passkeyDomain",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.isClientIdLegacyPaper(e.clientId))throw new Error("You are using a legacy clientId. Please use the clientId found on the thirdweb dashboard settings page");const o=p("inAppWallet");this.client=e,this.ecosystem=n,this.passkeyDomain=r,this.storage=new V({clientId:e.clientId,ecosystem:n,storage:l??Ve()}),this.querier=new $e({baseUrl:o,clientId:e.clientId,ecosystem:n}),this.auth=new Re({baseUrl:o,client:e,ecosystem:n,localStorage:this.storage,onAuthSuccess:async i=>{if(t==null||t(i),i.storedToken.authDetails.walletType==="sharded"&&(await this.querier.call({params:{storedToken:i.storedToken},procedureName:"migrateFromShardToEnclave"})||console.warn("Failed to migrate from sharded to enclave wallet, continuing with sharded wallet")),this.wallet=await this.initializeWallet(i.storedToken.cookieString),!this.wallet)throw new Error("Failed to initialize wallet");const c="deviceShareStored"in i.walletDetails?i.walletDetails.deviceShareStored:void 0;return await this.wallet.postWalletSetUp({deviceShareStored:c,storedToken:i.storedToken}),this.wallet instanceof B&&await this.querier.call({params:{authCookie:i.storedToken.cookieString,clientId:this.client.clientId,deviceShareStored:"deviceShareStored"in i.walletDetails?i.walletDetails.deviceShareStored:null,ecosystemId:n==null?void 0:n.id,partnerId:n==null?void 0:n.partnerId,walletUserId:i.storedToken.authDetails.userWalletId},procedureName:"initIframe"}),{user:{account:await this.wallet.getAccount(),authDetails:i.storedToken.authDetails,status:"Logged In, Wallet Initialized",walletAddress:i.walletDetails.walletAddress}}},querier:this.querier})}async initializeWallet(e){var r;const t=await this.storage.getAuthCookie();if(!e&&t===null)throw new Error("No auth token provided and no stored auth token found to initialize the wallet");const n=await O({authToken:e||t,client:this.client,ecosystem:this.ecosystem});if(!n)throw new Error("Cannot initialize wallet, no user logged in");if(n.wallets.length===0)throw new Error("Cannot initialize wallet, this user does not have a wallet generated yet");return((r=n.wallets[0])==null?void 0:r.type)==="enclave"?new Oe({address:n.wallets[0].address,client:this.client,ecosystem:this.ecosystem,storage:this.storage}):new B({client:this.client,ecosystem:this.ecosystem,localStorage:this.storage,querier:this.querier})}async getUser(){if(!this.wallet){const e=await this.storage.getAuthCookie();if(!e)return{status:"Logged Out"};this.wallet=await this.initializeWallet(e)}if(!this.wallet)throw new Error("Wallet not initialized");return await this.wallet.getUserWalletStatus()}getAccount(){if(!this.wallet)throw new Error("Wallet not initialized");return this.wallet.getAccount()}async preAuthenticate(e){return Ge({...e,client:this.client,ecosystem:this.ecosystem})}async authenticateWithRedirect(e,t,n){return Me({authOption:e,client:this.client,ecosystem:this.ecosystem,mode:t,redirectUrl:n})}async loginWithAuthToken(e,t){return this.auth.loginWithAuthToken(e,t)}async authenticate(e){const t=e.strategy;switch(t){case"email":return R({...e,client:this.client,ecosystem:this.ecosystem});case"phone":return R({...e,client:this.client,ecosystem:this.ecosystem});case"auth_endpoint":return he({client:this.client,ecosystem:this.ecosystem,payload:e.payload});case"jwt":return ge({client:this.client,ecosystem:this.ecosystem,jwt:e.jwt});case"passkey":return this.passkeyAuth(e);case"iframe_email_verification":return this.auth.authenticateWithIframe({email:e.email});case"iframe":return this.auth.authenticateWithModal();case"apple":case"facebook":case"google":case"telegram":case"github":case"twitch":case"farcaster":case"line":case"x":case"tiktok":case"epic":case"steam":case"coinbase":case"discord":return ze({authOption:t,client:this.client,closeOpenedWindow:e.closeOpenedWindow,ecosystem:this.ecosystem,openedWindow:e.openedWindow});case"guest":return pe({client:this.client,ecosystem:this.ecosystem,storage:this.storage});case"backend":return we({client:this.client,ecosystem:this.ecosystem,walletSecret:e.walletSecret});case"wallet":return Ee({client:this.client,ecosystem:this.ecosystem,wallet:e.wallet,chain:e.chain})}}async connect(e){const t=e.strategy;switch(t){case"auth_endpoint":case"jwt":{const n=await this.authenticate(e);return await this.loginWithAuthToken(n,e.encryptionKey)}case"iframe_email_verification":return this.auth.loginWithIframe({email:e.email});case"iframe":return this.auth.loginWithModal();case"passkey":{const n=await this.passkeyAuth(e);return this.loginWithAuthToken(n)}case"backend":case"phone":case"email":case"wallet":case"apple":case"facebook":case"google":case"farcaster":case"telegram":case"github":case"line":case"x":case"tiktok":case"epic":case"guest":case"coinbase":case"twitch":case"steam":case"discord":{const n=await this.authenticate(e);return await this.auth.loginWithAuthToken(n)}default:xe(t)}}async logout(){return await this.auth.logout()}async passkeyAuth(e){const{PasskeyWebClient:t}=await I(async()=>{const{PasskeyWebClient:i}=await import("./passkeys-D0W4dAEq.js");return{PasskeyWebClient:i}},__vite__mapDeps([2,3,1,4,5,6,7])),{passkeyName:n,storeLastUsedPasskey:r=!0}=e,l=new t,o=this.storage;return e.type==="sign-up"?Ie({client:this.client,ecosystem:this.ecosystem,passkeyClient:l,rp:{id:this.passkeyDomain??window.location.hostname,name:this.passkeyDomain??window.document.title},storage:r?o:void 0,username:n}):be({client:this.client,ecosystem:this.ecosystem,passkeyClient:l,rp:{id:this.passkeyDomain??window.location.hostname,name:this.passkeyDomain??window.document.title},storage:r?o:void 0})}async linkProfile(e){const{storedToken:t}=await this.authenticate(e);return await me({client:e.client,ecosystem:e.ecosystem||this.ecosystem,storage:this.storage,tokenToLink:t.cookieString})}async unlinkProfile(e,t){return await fe({allowAccountDeletion:t,client:this.client,ecosystem:this.ecosystem,profileToUnlink:e,storage:this.storage})}async getProfiles(){return ye({client:this.client,ecosystem:this.ecosystem,storage:this.storage})}}function xe(a,e){throw new Error(`Invalid param: ${a}`)}function Ve(){return typeof window<"u"&&window.localStorage?x:oe}export{Je as InAppWebConnector};
package/index.html CHANGED
@@ -5,12 +5,12 @@
5
5
  <link rel="shortcut icon" type="image/x-icon" href="https://decentraland.org/images/icons/favicon-32x32.png" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
7
  <title>Decentraland | Authorization</title>
8
- <script type="module" crossorigin src="https://cdn.decentraland.org/@dcl/auth-site/4.11.1/assets/index-rUP73pzB.js"></script>
9
- <link rel="modulepreload" crossorigin href="https://cdn.decentraland.org/@dcl/auth-site/4.11.1/assets/thirdweb-D6clKR4w.js">
10
- <link rel="modulepreload" crossorigin href="https://cdn.decentraland.org/@dcl/auth-site/4.11.1/assets/vendor-BgiNx-Ph.js">
11
- <link rel="modulepreload" crossorigin href="https://cdn.decentraland.org/@dcl/auth-site/4.11.1/assets/ui-DNHWrHSH.js">
12
- <link rel="stylesheet" crossorigin href="https://cdn.decentraland.org/@dcl/auth-site/4.11.1/assets/ui-byNMPSE1.css">
13
- <link rel="stylesheet" crossorigin href="https://cdn.decentraland.org/@dcl/auth-site/4.11.1/assets/index-CY-fRScv.css">
8
+ <script type="module" crossorigin src="https://cdn.decentraland.org/@dcl/auth-site/4.11.2/assets/index-Cv55CQzJ.js"></script>
9
+ <link rel="modulepreload" crossorigin href="https://cdn.decentraland.org/@dcl/auth-site/4.11.2/assets/thirdweb-DJ2OLvBE.js">
10
+ <link rel="modulepreload" crossorigin href="https://cdn.decentraland.org/@dcl/auth-site/4.11.2/assets/vendor-Co_R173r.js">
11
+ <link rel="modulepreload" crossorigin href="https://cdn.decentraland.org/@dcl/auth-site/4.11.2/assets/ui-Dy6xokVk.js">
12
+ <link rel="stylesheet" crossorigin href="https://cdn.decentraland.org/@dcl/auth-site/4.11.2/assets/ui-DkpUgtr0.css">
13
+ <link rel="stylesheet" crossorigin href="https://cdn.decentraland.org/@dcl/auth-site/4.11.2/assets/index-Caf6hxBL.css">
14
14
  </head>
15
15
  <body>
16
16
  <div id="root"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcl/auth-site",
3
- "version": "4.11.1",
3
+ "version": "4.11.2",
4
4
  "description": "Auth website",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -17,6 +17,6 @@
17
17
  "type": "git",
18
18
  "url": "https://github.com/decentraland/auth.git"
19
19
  },
20
- "homepage": "https://cdn.decentraland.org/@dcl/auth-site/4.11.1",
21
- "commit": "1be259c945c619c5277aa0afbb0c6d2c811543e8"
20
+ "homepage": "https://cdn.decentraland.org/@dcl/auth-site/4.11.2",
21
+ "commit": "6a0fdff9bb0f74762773d2dfc2ab0eaaf7b827e7"
22
22
  }
@@ -1,5 +0,0 @@
1
- import{p as ut}from"./thirdweb-D6clKR4w.js";var U=(e=>(e.MissingApiKey="MISSING_API_KEY",e.ModalNotReady="MODAL_NOT_READY",e.MalformedResponse="MALFORMED_RESPONSE",e.InvalidArgument="INVALID_ARGUMENT",e.ExtensionNotInitialized="EXTENSION_NOT_INITIALIZED",e.IncompatibleExtensions="INCOMPATIBLE_EXTENSIONS",e))(U||{}),j=(e=>(e.SyncWeb3Method="SYNC_WEB3_METHOD",e.DuplicateIframe="DUPLICATE_IFRAME",e.ReactNativeEndpointConfiguration="REACT_NATIVE_ENDPOINT_CONFIGURATION",e.DeprecationNotice="DEPRECATION_NOTICE",e.ProductAnnouncement="ANNOUNCEMENT",e))(j||{}),_e=(e=>(e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.MagicLinkFailedVerification=-1e4]="MagicLinkFailedVerification",e[e.MagicLinkExpired=-10001]="MagicLinkExpired",e[e.MagicLinkRateLimited=-10002]="MagicLinkRateLimited",e[e.MagicLinkInvalidRedirectURL=-10006]="MagicLinkInvalidRedirectURL",e[e.UserAlreadyLoggedIn=-10003]="UserAlreadyLoggedIn",e[e.UpdateEmailFailed=-10004]="UpdateEmailFailed",e[e.UserRequestEditEmail=-10005]="UserRequestEditEmail",e[e.InactiveRecipient=-10010]="InactiveRecipient",e[e.AccessDeniedToUser=-10011]="AccessDeniedToUser",e[e.RedirectLoginComplete=-10015]="RedirectLoginComplete",e))(_e||{}),M=(e=>(e.MetaMask="metamask",e.CoinbaseWallet="coinbase_wallet",e))(M||{}),ae=(e=>(e.WalletSelected="wallet_selected",e.WalletConnected="wallet_connected",e.WalletRejected="wallet_rejected",e))(ae||{}),h=(e=>(e.LoginWithSms="magic_auth_login_with_sms",e.LoginWithEmailOTP="magic_auth_login_with_email_otp",e.LoginWithMagicLink="magic_auth_login_with_magic_link",e.LoginWithCredential="magic_auth_login_with_credential",e.SetAuthorizationToken="magic_auth_set_authorization_token",e.GetIdToken="magic_auth_get_id_token",e.GenerateIdToken="magic_auth_generate_id_token",e.GetMetadata="magic_auth_get_metadata",e.IsLoggedIn="magic_is_logged_in",e.Logout="magic_auth_logout",e.UpdateEmail="magic_auth_update_email",e.UserSettings="magic_auth_settings",e.UserSettingsTestMode="magic_auth_settings_testing_mode",e.LoginWithSmsTestMode="magic_auth_login_with_sms_testing_mode",e.LoginWithEmailOTPTestMode="magic_auth_login_with_email_otp_testing_mode",e.LoginWithMagicLinkTestMode="magic_login_with_magic_link_testing_mode",e.LoginWithCredentialTestMode="magic_auth_login_with_credential_testing_mode",e.GetIdTokenTestMode="magic_auth_get_id_token_testing_mode",e.GenerateIdTokenTestMode="magic_auth_generate_id_token_testing_mode",e.GetMetadataTestMode="magic_auth_get_metadata_testing_mode",e.IsLoggedInTestMode="magic_auth_is_logged_in_testing_mode",e.LogoutTestMode="magic_auth_logout_testing_mode",e.UpdateEmailTestMode="magic_auth_update_email_testing_mode",e.IntermediaryEvent="magic_intermediary_event",e.RequestAccounts="eth_requestAccounts",e.GetInfo="magic_get_info",e.ShowUI="magic_wallet",e.NFTPurchase="magic_nft_purchase",e.NFTCheckout="magic_nft_checkout",e.NFTTransfer="magic_nft_transfer",e.RequestUserInfoWithUI="mc_request_user_info",e.Disconnect="mc_disconnect",e.RecoverAccount="magic_auth_recover_account",e.RecoverAccountTestMode="magic_auth_recover_account_testing_mode",e.MagicBoxHeartBeat="magic_box_heart_beat",e.AutoConnect="mc_auto_connect",e.Login="mc_login",e.EncryptV1="magic_auth_encrypt_v1",e.DecryptV1="magic_auth_decrypt_v1",e.ShowNFTs="magic_show_nfts",e.ShowOnRamp="magic_show_fiat_onramp",e.ShowSendTokensUI="magic_show_send_tokens_ui",e.ShowAddress="magic_show_address",e.ShowBalances="magic_show_balances",e.SendGaslessTransaction="eth_sendGaslessTransaction",e))(h||{}),k=(e=>(e.MAGIC_HANDLE_RESPONSE="MAGIC_HANDLE_RESPONSE",e.MAGIC_OVERLAY_READY="MAGIC_OVERLAY_READY",e.MAGIC_SHOW_OVERLAY="MAGIC_SHOW_OVERLAY",e.MAGIC_HIDE_OVERLAY="MAGIC_HIDE_OVERLAY",e.MAGIC_HANDLE_EVENT="MAGIC_HANDLE_EVENT",e.MAGIC_MG_BOX_SEND_RECEIPT="MAGIC_MG_BOX_SEND_RECEIPT",e.MAGIC_SEND_PRODUCT_ANNOUNCEMENT="MAGIC_SEND_PRODUCT_ANNOUNCEMENT",e))(k||{}),ce=(e=>(e.MAGIC_HANDLE_REQUEST="MAGIC_HANDLE_REQUEST",e))(ce||{}),dt=(e=>(e.UpdateEmail="update-email",e.MFA="mfa",e.Recovery="recovery",e))(dt||{}),ht=(e=>(e.Retry="retry",e))(ht||{}),pt=(e=>(e.EmailSent="email-sent",e.EmailNotDeliverable="email-not-deliverable",e))(pt||{}),B=(e=>(e.VerifyEmailOtp="verify-email-otp",e.Cancel="cancel",e))(B||{}),mt=(e=>(e.EmailOTPSent="email-otp-sent",e.InvalidEmailOtp="invalid-email-otp",e.ExpiredEmailOtp="expired-email-otp",e))(mt||{}),ge=(e=>(e.Retry="device-retry",e))(ge||{}),Et=(e=>(e.DeviceApproved="device-approved",e.DeviceNeedsApproval="device-needs-approval",e.DeviceVerificationLinkExpired="device-verification-link-expired",e.DeviceVerificationEmailSent="device-verification-email-sent",e))(Et||{}),b=(e=>(e.Retry="Recency/auth-factor-retry",e.Cancel="Recency/auth-factor-verification-cancel",e.VerifyEmailOtp="Recency/auth-factor-verify-email-otp",e))(b||{}),ft=(e=>(e.PrimaryAuthFactorNeedsVerification="Recency/auth-factor-needs-verification",e.PrimaryAuthFactorVerified="Recency/auth-factor-verified",e.InvalidEmailOtp="Recency/auth-factor-invalid-email-otp",e.EmailExpired="Recency/auth-factor-verification-email-expired",e.EmailSent="Recency/auth-factor-verification-email-sent",e.EmailNotDeliverable="Recency/auth-factor-verification-email-not-deliverable",e))(ft||{}),P=(e=>(e.RetryWithNewEmail="UpdateEmail/retry-with-new-email",e.Cancel="UpdateEmail/new-email-verification-cancel",e.VerifyEmailOtp="UpdateEmail/new-email-verify-otp",e))(P||{}),gt=(e=>(e.NewAuthFactorNeedsVerification="UpdateEmail/new-email-needs-verification",e.EmailUpdated="UpdateEmail/email-updated",e.InvalidEmailOtp="UpdateEmail/new-email-invalid-email-otp",e.EmailExpired="UpdateEmail/new-email-verification-email-expired",e.EmailSent="UpdateEmail/new-email-verification-email-sent",e.EmailNotDeliverable="UpdateEmail/new-email-verification-email-not-deliverable",e.InvalidEmail="UpdateEmail/new-email-invalid",e.EmailAlreadyExists="UpdateEmail/new-email-already-exists",e))(gt||{}),vt=(e=>(e.Harmony="HARMONY",e))(vt||{}),_t=(e=>(e.PhoneNumber="phone_number",e))(_t||{}),Ee={},It=Object.create,pe=Object.defineProperty,yt=Object.defineProperties,wt=Object.getOwnPropertyDescriptor,Rt=Object.getOwnPropertyDescriptors,$t=Object.getOwnPropertyNames,Te=Object.getOwnPropertySymbols,Nt=Object.getPrototypeOf,He=Object.prototype.hasOwnProperty,At=Object.prototype.propertyIsEnumerable,Le=(e,t,r)=>t in e?pe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ie=(e,t)=>{for(var r in t||(t={}))He.call(t,r)&&Le(e,r,t[r]);if(Te)for(var r of Te(t))At.call(t,r)&&Le(e,r,t[r]);return e},ye=(e,t)=>yt(e,Rt(t)),Ot=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Mt=(e,t)=>{for(var r in t)pe(e,r,{get:t[r],enumerable:!0})},Tt=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of $t(t))!He.call(e,n)&&n!==r&&pe(e,n,{get:()=>t[n],enumerable:!(i=wt(t,n))||i.enumerable});return e},Lt=(e,t,r)=>(r=e!=null?It(Nt(e)):{},Tt(!e||!e.__esModule?pe(r,"default",{value:e,enumerable:!0}):r,e)),_=(e,t,r)=>new Promise((i,n)=>{var s=u=>{try{o(r.next(u))}catch(l){n(l)}},a=u=>{try{o(r.throw(u))}catch(l){n(l)}},o=u=>u.done?i(u.value):Promise.resolve(u.value).then(s,a);o((r=r.apply(e,t)).next())}),St=Ot((e,t)=>{var r=Object.prototype.hasOwnProperty,i="~";function n(){}Object.create&&(n.prototype=Object.create(null),new n().__proto__||(i=!1));function s(l,c,d){this.fn=l,this.context=c,this.once=d||!1}function a(l,c,d,f,v){if(typeof d!="function")throw new TypeError("The listener must be a function");var I=new s(d,f||l,v),$=i?i+c:c;return l._events[$]?l._events[$].fn?l._events[$]=[l._events[$],I]:l._events[$].push(I):(l._events[$]=I,l._eventsCount++),l}function o(l,c){--l._eventsCount===0?l._events=new n:delete l._events[c]}function u(){this._events=new n,this._eventsCount=0}u.prototype.eventNames=function(){var l=[],c,d;if(this._eventsCount===0)return l;for(d in c=this._events)r.call(c,d)&&l.push(i?d.slice(1):d);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(c)):l},u.prototype.listeners=function(l){var c=i?i+l:l,d=this._events[c];if(!d)return[];if(d.fn)return[d.fn];for(var f=0,v=d.length,I=new Array(v);f<v;f++)I[f]=d[f].fn;return I},u.prototype.listenerCount=function(l){var c=i?i+l:l,d=this._events[c];return d?d.fn?1:d.length:0},u.prototype.emit=function(l,c,d,f,v,I){var $=i?i+l:l;if(!this._events[$])return!1;var p=this._events[$],L=arguments.length,C,y;if(p.fn){switch(p.once&&this.removeListener(l,p.fn,void 0,!0),L){case 1:return p.fn.call(p.context),!0;case 2:return p.fn.call(p.context,c),!0;case 3:return p.fn.call(p.context,c,d),!0;case 4:return p.fn.call(p.context,c,d,f),!0;case 5:return p.fn.call(p.context,c,d,f,v),!0;case 6:return p.fn.call(p.context,c,d,f,v,I),!0}for(y=1,C=new Array(L-1);y<L;y++)C[y-1]=arguments[y];p.fn.apply(p.context,C)}else{var ct=p.length,V;for(y=0;y<ct;y++)switch(p[y].once&&this.removeListener(l,p[y].fn,void 0,!0),L){case 1:p[y].fn.call(p[y].context);break;case 2:p[y].fn.call(p[y].context,c);break;case 3:p[y].fn.call(p[y].context,c,d);break;case 4:p[y].fn.call(p[y].context,c,d,f);break;default:if(!C)for(V=1,C=new Array(L-1);V<L;V++)C[V-1]=arguments[V];p[y].fn.apply(p[y].context,C)}}return!0},u.prototype.on=function(l,c,d){return a(this,l,c,d,!1)},u.prototype.once=function(l,c,d){return a(this,l,c,d,!0)},u.prototype.removeListener=function(l,c,d,f){var v=i?i+l:l;if(!this._events[v])return this;if(!c)return o(this,v),this;var I=this._events[v];if(I.fn)I.fn===c&&(!f||I.once)&&(!d||I.context===d)&&o(this,v);else{for(var $=0,p=[],L=I.length;$<L;$++)(I[$].fn!==c||f&&!I[$].once||d&&I[$].context!==d)&&p.push(I[$]);p.length?this._events[v]=p.length===1?p[0]:p:o(this,v)}return this},u.prototype.removeAllListeners=function(l){var c;return l?(c=i?i+l:l,this._events[c]&&o(this,c)):(this._events=new n,this._eventsCount=0),this},u.prototype.off=u.prototype.removeListener,u.prototype.addListener=u.prototype.on,u.prefixed=i,u.EventEmitter=u,typeof t<"u"&&(t.exports=u)});function Ct(e){let t={exports:{}};return e(t,t.exports),t.exports}var bt=Number.MAX_SAFE_INTEGER||9007199254740991,we={MAX_LENGTH:256,MAX_SAFE_INTEGER:bt,MAX_SAFE_COMPONENT_LENGTH:16},Pt=typeof ut=="object"&&Ee&&Ee.NODE_DEBUG&&/\bsemver\b/i.test(Ee.NODE_DEBUG)?(...e)=>console.error("SEMVER",...e):()=>{},E=Pt,ee=Ct(function(e,t){let{MAX_SAFE_COMPONENT_LENGTH:r}=we,i=(t=e.exports={}).re=[],n=t.src=[],s=t.t={},a=0,o=(u,l,c)=>{let d=a++;E(d,l),s[u]=d,n[d]=l,i[d]=new RegExp(l,c?"g":void 0)};o("NUMERICIDENTIFIER","0|[1-9]\\d*"),o("NUMERICIDENTIFIERLOOSE","[0-9]+"),o("NONNUMERICIDENTIFIER","\\d*[a-zA-Z-][a-zA-Z0-9-]*"),o("MAINVERSION",`(${n[s.NUMERICIDENTIFIER]})\\.(${n[s.NUMERICIDENTIFIER]})\\.(${n[s.NUMERICIDENTIFIER]})`),o("MAINVERSIONLOOSE",`(${n[s.NUMERICIDENTIFIERLOOSE]})\\.(${n[s.NUMERICIDENTIFIERLOOSE]})\\.(${n[s.NUMERICIDENTIFIERLOOSE]})`),o("PRERELEASEIDENTIFIER",`(?:${n[s.NUMERICIDENTIFIER]}|${n[s.NONNUMERICIDENTIFIER]})`),o("PRERELEASEIDENTIFIERLOOSE",`(?:${n[s.NUMERICIDENTIFIERLOOSE]}|${n[s.NONNUMERICIDENTIFIER]})`),o("PRERELEASE",`(?:-(${n[s.PRERELEASEIDENTIFIER]}(?:\\.${n[s.PRERELEASEIDENTIFIER]})*))`),o("PRERELEASELOOSE",`(?:-?(${n[s.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${n[s.PRERELEASEIDENTIFIERLOOSE]})*))`),o("BUILDIDENTIFIER","[0-9A-Za-z-]+"),o("BUILD",`(?:\\+(${n[s.BUILDIDENTIFIER]}(?:\\.${n[s.BUILDIDENTIFIER]})*))`),o("FULLPLAIN",`v?${n[s.MAINVERSION]}${n[s.PRERELEASE]}?${n[s.BUILD]}?`),o("FULL",`^${n[s.FULLPLAIN]}$`),o("LOOSEPLAIN",`[v=\\s]*${n[s.MAINVERSIONLOOSE]}${n[s.PRERELEASELOOSE]}?${n[s.BUILD]}?`),o("LOOSE",`^${n[s.LOOSEPLAIN]}$`),o("GTLT","((?:<|>)?=?)"),o("XRANGEIDENTIFIERLOOSE",`${n[s.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),o("XRANGEIDENTIFIER",`${n[s.NUMERICIDENTIFIER]}|x|X|\\*`),o("XRANGEPLAIN",`[v=\\s]*(${n[s.XRANGEIDENTIFIER]})(?:\\.(${n[s.XRANGEIDENTIFIER]})(?:\\.(${n[s.XRANGEIDENTIFIER]})(?:${n[s.PRERELEASE]})?${n[s.BUILD]}?)?)?`),o("XRANGEPLAINLOOSE",`[v=\\s]*(${n[s.XRANGEIDENTIFIERLOOSE]})(?:\\.(${n[s.XRANGEIDENTIFIERLOOSE]})(?:\\.(${n[s.XRANGEIDENTIFIERLOOSE]})(?:${n[s.PRERELEASELOOSE]})?${n[s.BUILD]}?)?)?`),o("XRANGE",`^${n[s.GTLT]}\\s*${n[s.XRANGEPLAIN]}$`),o("XRANGELOOSE",`^${n[s.GTLT]}\\s*${n[s.XRANGEPLAINLOOSE]}$`),o("COERCE",`(^|[^\\d])(\\d{1,${r}})(?:\\.(\\d{1,${r}}))?(?:\\.(\\d{1,${r}}))?(?:$|[^\\d])`),o("COERCERTL",n[s.COERCE],!0),o("LONETILDE","(?:~>?)"),o("TILDETRIM",`(\\s*)${n[s.LONETILDE]}\\s+`,!0),t.tildeTrimReplace="$1~",o("TILDE",`^${n[s.LONETILDE]}${n[s.XRANGEPLAIN]}$`),o("TILDELOOSE",`^${n[s.LONETILDE]}${n[s.XRANGEPLAINLOOSE]}$`),o("LONECARET","(?:\\^)"),o("CARETTRIM",`(\\s*)${n[s.LONECARET]}\\s+`,!0),t.caretTrimReplace="$1^",o("CARET",`^${n[s.LONECARET]}${n[s.XRANGEPLAIN]}$`),o("CARETLOOSE",`^${n[s.LONECARET]}${n[s.XRANGEPLAINLOOSE]}$`),o("COMPARATORLOOSE",`^${n[s.GTLT]}\\s*(${n[s.LOOSEPLAIN]})$|^$`),o("COMPARATOR",`^${n[s.GTLT]}\\s*(${n[s.FULLPLAIN]})$|^$`),o("COMPARATORTRIM",`(\\s*)${n[s.GTLT]}\\s*(${n[s.LOOSEPLAIN]}|${n[s.XRANGEPLAIN]})`,!0),t.comparatorTrimReplace="$1$2$3",o("HYPHENRANGE",`^\\s*(${n[s.XRANGEPLAIN]})\\s+-\\s+(${n[s.XRANGEPLAIN]})\\s*$`),o("HYPHENRANGELOOSE",`^\\s*(${n[s.XRANGEPLAINLOOSE]})\\s+-\\s+(${n[s.XRANGEPLAINLOOSE]})\\s*$`),o("STAR","(<|>)?=?\\s*\\*"),o("GTE0","^\\s*>=\\s*0.0.0\\s*$"),o("GTE0PRE","^\\s*>=\\s*0.0.0-0\\s*$")}),Se=/^[0-9]+$/,kt=(e,t)=>{let r=Se.test(e),i=Se.test(t);return r&&i&&(e=+e,t=+t),e===t?0:r&&!i?-1:i&&!r?1:e<t?-1:1},Ut={compareIdentifiers:kt},{MAX_LENGTH:Ce,MAX_SAFE_INTEGER:re}=we,{re:be,t:Pe}=ee,{compareIdentifiers:H}=Ut,w=class{constructor(e,t){if(t&&typeof t=="object"||(t={loose:!!t,includePrerelease:!1}),e instanceof w){if(e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease)return e;e=e.version}else if(typeof e!="string")throw new TypeError(`Invalid Version: ${e}`);if(e.length>Ce)throw new TypeError(`version is longer than ${Ce} characters`);E("SemVer",e,t),this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease;let r=e.trim().match(t.loose?be[Pe.LOOSE]:be[Pe.FULL]);if(!r)throw new TypeError(`Invalid Version: ${e}`);if(this.raw=e,this.major=+r[1],this.minor=+r[2],this.patch=+r[3],this.major>re||this.major<0)throw new TypeError("Invalid major version");if(this.minor>re||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>re||this.patch<0)throw new TypeError("Invalid patch version");r[4]?this.prerelease=r[4].split(".").map(i=>{if(/^[0-9]+$/.test(i)){let n=+i;if(n>=0&&n<re)return n}return i}):this.prerelease=[],this.build=r[5]?r[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(e){if(E("SemVer.compare",this.version,this.options,e),!(e instanceof w)){if(typeof e=="string"&&e===this.version)return 0;e=new w(e,this.options)}return e.version===this.version?0:this.compareMain(e)||this.comparePre(e)}compareMain(e){return e instanceof w||(e=new w(e,this.options)),H(this.major,e.major)||H(this.minor,e.minor)||H(this.patch,e.patch)}comparePre(e){if(e instanceof w||(e=new w(e,this.options)),this.prerelease.length&&!e.prerelease.length)return-1;if(!this.prerelease.length&&e.prerelease.length)return 1;if(!this.prerelease.length&&!e.prerelease.length)return 0;let t=0;do{let r=this.prerelease[t],i=e.prerelease[t];if(E("prerelease compare",t,r,i),r===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(r===void 0)return-1;if(r!==i)return H(r,i)}while(++t)}compareBuild(e){e instanceof w||(e=new w(e,this.options));let t=0;do{let r=this.build[t],i=e.build[t];if(E("prerelease compare",t,r,i),r===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(r===void 0)return-1;if(r!==i)return H(r,i)}while(++t)}inc(e,t){switch(e){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",t);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",t);break;case"prepatch":this.prerelease.length=0,this.inc("patch",t),this.inc("pre",t);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",t),this.inc("pre",t);break;case"major":this.minor===0&&this.patch===0&&this.prerelease.length!==0||this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":this.patch===0&&this.prerelease.length!==0||this.minor++,this.patch=0,this.prerelease=[];break;case"patch":this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case"pre":if(this.prerelease.length===0)this.prerelease=[0];else{let r=this.prerelease.length;for(;--r>=0;)typeof this.prerelease[r]=="number"&&(this.prerelease[r]++,r=-2);r===-1&&this.prerelease.push(0)}t&&(this.prerelease[0]===t?isNaN(this.prerelease[1])&&(this.prerelease=[t,0]):this.prerelease=[t,0]);break;default:throw new Error(`invalid increment argument: ${e}`)}return this.format(),this.raw=this.version,this}},Dt=(e,t,r)=>new w(e,r).compare(new w(t,r)),q=Dt,Gt=(e,t,r)=>q(e,t,r)===0,xt=Gt,Ft=(e,t,r)=>q(e,t,r)!==0,Wt=Ft,jt=(e,t,r)=>q(e,t,r)>0,qt=jt,Vt=(e,t,r)=>q(e,t,r)>=0,Ht=Vt,Xt=(e,t,r)=>q(e,t,r)<0,Bt=Xt,Kt=(e,t,r)=>q(e,t,r)<=0,Yt=Kt,zt=(e,t,r,i)=>{switch(t){case"===":return typeof e=="object"&&(e=e.version),typeof r=="object"&&(r=r.version),e===r;case"!==":return typeof e=="object"&&(e=e.version),typeof r=="object"&&(r=r.version),e!==r;case"":case"=":case"==":return xt(e,r,i);case"!=":return Wt(e,r,i);case">":return qt(e,r,i);case">=":return Ht(e,r,i);case"<":return Bt(e,r,i);case"<=":return Yt(e,r,i);default:throw new TypeError(`Invalid operator: ${t}`)}},fe=zt,X=Symbol("SemVer ANY"),Q=class{static get ANY(){return X}constructor(e,t){if(t&&typeof t=="object"||(t={loose:!!t,includePrerelease:!1}),e instanceof Q){if(e.loose===!!t.loose)return e;e=e.value}E("comparator",e,t),this.options=t,this.loose=!!t.loose,this.parse(e),this.semver===X?this.value="":this.value=this.operator+this.semver.version,E("comp",this)}parse(e){let t=this.options.loose?ke[Ue.COMPARATORLOOSE]:ke[Ue.COMPARATOR],r=e.match(t);if(!r)throw new TypeError(`Invalid comparator: ${e}`);this.operator=r[1]!==void 0?r[1]:"",this.operator==="="&&(this.operator=""),r[2]?this.semver=new w(r[2],this.options.loose):this.semver=X}toString(){return this.value}test(e){if(E("Comparator.test",e,this.options.loose),this.semver===X||e===X)return!0;if(typeof e=="string")try{e=new w(e,this.options)}catch{return!1}return fe(e,this.operator,this.semver,this.options)}intersects(e,t){if(!(e instanceof Q))throw new TypeError("a Comparator is required");if(t&&typeof t=="object"||(t={loose:!!t,includePrerelease:!1}),this.operator==="")return this.value===""||new F(e.value,t).test(this.value);if(e.operator==="")return e.value===""||new F(this.value,t).test(e.semver);let r=!(this.operator!==">="&&this.operator!==">"||e.operator!==">="&&e.operator!==">"),i=!(this.operator!=="<="&&this.operator!=="<"||e.operator!=="<="&&e.operator!=="<"),n=this.semver.version===e.semver.version,s=!(this.operator!==">="&&this.operator!=="<="||e.operator!==">="&&e.operator!=="<="),a=fe(this.semver,"<",e.semver,t)&&(this.operator===">="||this.operator===">")&&(e.operator==="<="||e.operator==="<"),o=fe(this.semver,">",e.semver,t)&&(this.operator==="<="||this.operator==="<")&&(e.operator===">="||e.operator===">");return r||i||n&&s||a||o}},{re:ke,t:Ue}=ee,F=class{constructor(e,t){if(t&&typeof t=="object"||(t={loose:!!t,includePrerelease:!1}),e instanceof F)return e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease?e:new F(e.raw,t);if(e instanceof Q)return this.raw=e.value,this.set=[[e]],this.format(),this;if(this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease,this.raw=e,this.set=e.split(/\s*\|\|\s*/).map(r=>this.parseRange(r.trim())).filter(r=>r.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${e}`);this.format()}format(){return this.range=this.set.map(e=>e.join(" ").trim()).join("||").trim(),this.range}toString(){return this.range}parseRange(e){let{loose:t}=this.options;e=e.trim();let r=t?N[R.HYPHENRANGELOOSE]:N[R.HYPHENRANGE];e=e.replace(r,cr(this.options.includePrerelease)),E("hyphen replace",e),e=e.replace(N[R.COMPARATORTRIM],Jt),E("comparator trim",e,N[R.COMPARATORTRIM]),e=(e=(e=e.replace(N[R.TILDETRIM],Qt)).replace(N[R.CARETTRIM],Zt)).split(/\s+/).join(" ");let i=t?N[R.COMPARATORLOOSE]:N[R.COMPARATOR];return e.split(" ").map(n=>er(n,this.options)).join(" ").split(/\s+/).map(n=>lr(n,this.options)).filter(this.options.loose?n=>!!n.match(i):()=>!0).map(n=>new Q(n,this.options))}intersects(e,t){if(!(e instanceof F))throw new TypeError("a Range is required");return this.set.some(r=>De(r,t)&&e.set.some(i=>De(i,t)&&r.every(n=>i.every(s=>n.intersects(s,t)))))}test(e){if(!e)return!1;if(typeof e=="string")try{e=new w(e,this.options)}catch{return!1}for(let t=0;t<this.set.length;t++)if(ur(this.set[t],e,this.options))return!0;return!1}},{re:N,t:R,comparatorTrimReplace:Jt,tildeTrimReplace:Qt,caretTrimReplace:Zt}=ee,De=(e,t)=>{let r=!0,i=e.slice(),n=i.pop();for(;r&&i.length;)r=i.every(s=>n.intersects(s,t)),n=i.pop();return r},er=(e,t)=>(E("comp",e,t),e=ir(e,t),E("caret",e),e=tr(e,t),E("tildes",e),e=sr(e,t),E("xrange",e),e=ar(e,t),E("stars",e),e),A=e=>!e||e.toLowerCase()==="x"||e==="*",tr=(e,t)=>e.trim().split(/\s+/).map(r=>rr(r,t)).join(" "),rr=(e,t)=>{let r=t.loose?N[R.TILDELOOSE]:N[R.TILDE];return e.replace(r,(i,n,s,a,o)=>{let u;return E("tilde",e,i,n,s,a,o),A(n)?u="":A(s)?u=`>=${n}.0.0 <${+n+1}.0.0-0`:A(a)?u=`>=${n}.${s}.0 <${n}.${+s+1}.0-0`:o?(E("replaceTilde pr",o),u=`>=${n}.${s}.${a}-${o} <${n}.${+s+1}.0-0`):u=`>=${n}.${s}.${a} <${n}.${+s+1}.0-0`,E("tilde return",u),u})},ir=(e,t)=>e.trim().split(/\s+/).map(r=>nr(r,t)).join(" "),nr=(e,t)=>{E("caret",e,t);let r=t.loose?N[R.CARETLOOSE]:N[R.CARET],i=t.includePrerelease?"-0":"";return e.replace(r,(n,s,a,o,u)=>{let l;return E("caret",e,n,s,a,o,u),A(s)?l="":A(a)?l=`>=${s}.0.0${i} <${+s+1}.0.0-0`:A(o)?l=s==="0"?`>=${s}.${a}.0${i} <${s}.${+a+1}.0-0`:`>=${s}.${a}.0${i} <${+s+1}.0.0-0`:u?(E("replaceCaret pr",u),l=s==="0"?a==="0"?`>=${s}.${a}.${o}-${u} <${s}.${a}.${+o+1}-0`:`>=${s}.${a}.${o}-${u} <${s}.${+a+1}.0-0`:`>=${s}.${a}.${o}-${u} <${+s+1}.0.0-0`):(E("no pr"),l=s==="0"?a==="0"?`>=${s}.${a}.${o}${i} <${s}.${a}.${+o+1}-0`:`>=${s}.${a}.${o}${i} <${s}.${+a+1}.0-0`:`>=${s}.${a}.${o} <${+s+1}.0.0-0`),E("caret return",l),l})},sr=(e,t)=>(E("replaceXRanges",e,t),e.split(/\s+/).map(r=>or(r,t)).join(" ")),or=(e,t)=>{e=e.trim();let r=t.loose?N[R.XRANGELOOSE]:N[R.XRANGE];return e.replace(r,(i,n,s,a,o,u)=>{E("xRange",e,i,n,s,a,o,u);let l=A(s),c=l||A(a),d=c||A(o),f=d;return n==="="&&f&&(n=""),u=t.includePrerelease?"-0":"",l?i=n===">"||n==="<"?"<0.0.0-0":"*":n&&f?(c&&(a=0),o=0,n===">"?(n=">=",c?(s=+s+1,a=0,o=0):(a=+a+1,o=0)):n==="<="&&(n="<",c?s=+s+1:a=+a+1),n==="<"&&(u="-0"),i=`${n+s}.${a}.${o}${u}`):c?i=`>=${s}.0.0${u} <${+s+1}.0.0-0`:d&&(i=`>=${s}.${a}.0${u} <${s}.${+a+1}.0-0`),E("xRange return",i),i})},ar=(e,t)=>(E("replaceStars",e,t),e.trim().replace(N[R.STAR],"")),lr=(e,t)=>(E("replaceGTE0",e,t),e.trim().replace(N[t.includePrerelease?R.GTE0PRE:R.GTE0],"")),cr=e=>(t,r,i,n,s,a,o,u,l,c,d,f,v)=>`${r=A(i)?"":A(n)?`>=${i}.0.0${e?"-0":""}`:A(s)?`>=${i}.${n}.0${e?"-0":""}`:a?`>=${r}`:`>=${r}${e?"-0":""}`} ${u=A(l)?"":A(c)?`<${+l+1}.0.0-0`:A(d)?`<${l}.${+c+1}.0-0`:f?`<=${l}.${c}.${d}-${f}`:e?`<${l}.${c}.${+d+1}-0`:`<=${u}`}`.trim(),ur=(e,t,r)=>{for(let i=0;i<e.length;i++)if(!e[i].test(t))return!1;if(t.prerelease.length&&!r.includePrerelease){for(let i=0;i<e.length;i++)if(E(e[i].semver),e[i].semver!==Q.ANY&&e[i].semver.prerelease.length>0){let n=e[i].semver;if(n.major===t.major&&n.minor===t.minor&&n.patch===t.patch)return!0}return!1}return!0},dr=(e,t,r)=>{try{t=new F(t,r)}catch{return!1}return t.test(e)},{MAX_LENGTH:hr}=we,{re:Ge,t:xe}=ee,pr=(e,t)=>{if(t&&typeof t=="object"||(t={loose:!!t,includePrerelease:!1}),e instanceof w)return e;if(typeof e!="string"||e.length>hr||!(t.loose?Ge[xe.LOOSE]:Ge[xe.FULL]).test(e))return null;try{return new w(e,t)}catch{return null}},mr=pr,{re:ie,t:ne}=ee,Er=(e,t)=>{if(e instanceof w)return e;if(typeof e=="number"&&(e=String(e)),typeof e!="string")return null;let r=null;if((t=t||{}).rtl){let i;for(;(i=ie[ne.COERCERTL].exec(e))&&(!r||r.index+r[0].length!==e.length);)r&&i.index+i[0].length===r.index+r[0].length||(r=i),ie[ne.COERCERTL].lastIndex=i.index+i[1].length+i[2].length;ie[ne.COERCERTL].lastIndex=-1}else r=e.match(ie[ne.COERCE]);return r===null?null:mr(`${r[2]}.${r[3]||"0"}.${r[4]||"0"}`,t)};function fr(e){return String.fromCharCode(parseInt(e.slice(1),16))}function gr(e){return`%${`00${e.charCodeAt(0).toString(16)}`.slice(-2)}`}function vr(e){return btoa(encodeURIComponent(e).replace(/%[0-9A-F]{2}/g,fr))}function _r(e){return decodeURIComponent(Array.from(atob(e),gr).join(""))}function Xe(e){return vr(JSON.stringify(e))}function Ir(e){return JSON.parse(_r(e))}function K(e){return typeof e>"u"}function yr(e){return e===null}function Be(e){return yr(e)||K(e)}function wr(e){return Be(e)?!1:!K(e.jsonrpc)&&!K(e.id)&&(!K(e.result)||!K(e.error))}function Rr(e){return Be(e)?!1:typeof e=="number"&&Object.values(_e).includes(e)}function ue(e){if(!e)return!0;for(let t in e)if(Object.hasOwnProperty.call(e,t))return!1;return!0}var g={};function _i(e,t){return Object.assign(g,t),e}var $r={"magic-sdk":"magic-sdk","@magic-sdk/react-native":"magic-sdk-rn","@magic-sdk/react-native-bare":"magic-sdk-rn-bare","@magic-sdk/react-native-expo":"magic-sdk-rn-expo"},D=class extends Error{constructor(e,t){super(`Magic SDK Error: [${e}] ${t}`),this.code=e,this.rawMessage=t,this.__proto__=Error,Object.setPrototypeOf(this,D.prototype)}},de=class extends Error{constructor(e){super(),this.__proto__=Error;let t=Number(e==null?void 0:e.code);this.rawMessage=(e==null?void 0:e.message)||"Internal error",this.code=Rr(t)?t:_e.InternalError,this.message=`Magic RPC Error: [${this.code}] ${this.rawMessage}`,this.data=(e==null?void 0:e.data)||void 0,Object.setPrototypeOf(this,de.prototype)}},te=class{constructor(e,t){this.code=e,this.rawMessage=t,this.message=`Magic SDK Warning: [${e}] ${t}`}log(){console.warn(this.message)}},Ke=class extends Error{constructor(e,t,r,i){super(`Magic Extension Error (${e.name}): [${t}] ${r}`),this.code=t,this.rawMessage=r,this.data=i,this.__proto__=Error,Object.setPrototypeOf(this,Ke.prototype)}},Fe=class{constructor(e,t,r){this.code=t,this.rawMessage=r,this.message=`Magic Extension Warning (${e.name}): [${t}] ${r}`}log(){console.warn(this.message)}};function Nr(){return new D(U.MissingApiKey,"Please provide an API key that you acquired from the Magic developer dashboard.")}function Ar(){return new D(U.ModalNotReady,"Modal is not ready.")}function Or(){return new D(U.MalformedResponse,"Response from the Magic iframe is malformed.")}function Mr(e){return new D(U.ExtensionNotInitialized,`Extensions must be initialized with a Magic SDK instance before \`Extension.${e}\` can be accessed. Do not invoke \`Extension.${e}\` inside an extension constructor.`)}function Tr(e){let t=`Some extensions are incompatible with \`${g.sdkName}@${g.version}\`:`;return e.filter(r=>typeof r.compat<"u"&&r.compat!==null).forEach(r=>{let i=r.compat[g.sdkName];typeof i=="string"?t+=`
2
- - Extension \`${r.name}\` supports version(s) \`${i}\``:i||(t+=`
3
- - Extension \`${r.name}\` does not support ${g.platform} environments.`)}),new D(U.IncompatibleExtensions,t)}function Lr(e){let t=r=>{let i=r+1,n=i%10,s=i%100;return n===1&&s!==11?`${i}st`:n===2&&s!==12?`${i}nd`:n===3&&s!==13?`${i}rd`:`${i}th`};return new D(U.InvalidArgument,`Invalid ${t(e.argument)} argument given to \`${e.procedure}\`.
4
- Expected: \`${e.expected}\`
5
- Received: \`${e.received}\``)}function Ii(){return new te(j.DuplicateIframe,"Duplicate iframes found.")}function Sr(){return new te(j.SyncWeb3Method,"Non-async web3 methods are deprecated in web3 > 1.0 and are not supported by the Magic web3 provider. Please use an async method instead.")}function Cr(){return new te(j.ReactNativeEndpointConfiguration,`CUSTOM DOMAINS ARE NOT SUPPORTED WHEN USING MAGIC SDK WITH REACT NATIVE! The \`endpoint\` parameter SHOULD NOT be provided. The Magic \`<iframe>\` is automatically wrapped by a WebView pointed at \`${g.defaultEndpoint}\`. Changing this default behavior will lead to unexpected results and potentially security-threatening bugs.`)}function Y(e){let{method:t,removalVersions:r,useInstead:i}=e,n=r[g.sdkName],s=i?` Use \`${i}\` instead.`:"",a=`\`${t}\` will be removed from \`${g.sdkName}\` in version \`${n}\`.${s}`;return new te(j.DeprecationNotice,a)}function*br(){let e=0;for(;;)e<Number.MAX_SAFE_INTEGER?yield++e:e=0}var Pr=br();function Ye(){return Pr.next().value}var ze=Symbol("Payload pre-processed by Magic SDK");function Je(e){return Object.defineProperty(e,ze,{value:!0,enumerable:!1}),e}function kr(e){return!!e[ze]}function he(e){var t,r,i;return kr(e)||(e.jsonrpc=(t=e.jsonrpc)!=null?t:"2.0",e.id=Ye(),e.method=(r=e.method)!=null?r:"noop",e.params=(i=e.params)!=null?i:[],Je(e)),e}function m(e,t=[]){return Je({params:t,method:e,jsonrpc:"2.0",id:Ye()})}var Re=class{constructor(e){e instanceof Re?(this._jsonrpc=e.payload.jsonrpc,this._id=e.payload.id,this._result=e.payload.result,this._error=e.payload.error):wr(e)?(this._jsonrpc=e.jsonrpc,this._id=e.id,this._result=e.result,this._error=e.error):(this._jsonrpc=e.jsonrpc,this._id=e.id,this._result=void 0,this._error=void 0)}applyError(e){return this._error=e,this}applyResult(e){return this._result=e,this}get hasError(){return typeof this._error<"u"&&this._error!==null}get hasResult(){return typeof this._result<"u"}get payload(){return{jsonrpc:this._jsonrpc,id:this._id,result:this._result,error:this._error}}},Ur=Lt(St()),Dr=class extends Ur.default{};function Qe(){let e=new Dr;return{emitter:e,createChainingEmitterMethod:(t,r)=>(...i)=>(e[t].apply(e,i),r),createBoundEmitterMethod:t=>(...r)=>e[t].apply(e,r)}}var Ze=Symbol("isPromiEvent");function Gr(e){return!!e[Ze]}function Z(e){let t=et(e),{createBoundEmitterMethod:r,createChainingEmitterMethod:i}=Qe(),n=Symbol("Promise.then"),s=Symbol("Promise.catch"),a=Symbol("Promise.finally"),o=(c,d)=>(...f)=>{let v=d[c].apply(d,f);return u(v)},u=c=>Object.assign(c,{[Ze]:!0,[n]:c[n]||c.then,[s]:c[s]||c.catch,[a]:c[a]||c.finally,then:o(n,c),catch:o(s,c),finally:o(a,c),on:i("on",c),once:i("once",c),addListener:i("addListener",c),off:i("off",c),removeListener:i("removeListener",c),removeAllListeners:i("removeAllListeners",c),emit:r("emit"),eventNames:r("eventNames"),listeners:r("listeners"),listenerCount:r("listenerCount")}),l=u(t.then(c=>(l.emit("done",c),l.emit("settled"),c),c=>{throw l.emit("error",c),l.emit("settled"),c}));return l}function et(e){return new Promise((t,r)=>{let i=e(t,r);Promise.resolve(i).catch(r)})}var G=class{constructor(e){this.sdk=e}get overlay(){return this.sdk.overlay}request(e){let t=this.overlay.post(ce.MAGIC_HANDLE_REQUEST,he(e)),r=Z((n,s)=>{t.then(a=>{if(i(),a.hasError)s(new de(a.payload.error));else if(a.hasResult)n(a.payload.result);else throw Or()}).catch(a=>{i(),s(a)})}),i=this.overlay.on(k.MAGIC_HANDLE_EVENT,n=>{var s;let{response:a}=n.data;if(a.id===e.id&&((s=a.result)!=null&&s.event)){let{event:o,params:u=[]}=a.result;r.emit(o,...u)}});return r}createIntermediaryEvent(e,t){return r=>{let i=m(h.IntermediaryEvent,[{payloadId:t,eventType:e,args:r}]);this.request(i)}}};function xr(e,t){let[r]=e.split(".").map(Number);return r>=t}var z={"magic-sdk":"v18.0.0","@magic-sdk/react-native":"v14.0.0","@magic-sdk/react-native-bare":"v19.0.0","@magic-sdk/react-native-expo":"v19.0.0"},Fr=class extends G{loginWithMagicLink(e){let t=g.sdkName==="@magic-sdk/react-native"||g.sdkName==="@magic-sdk/react-native-bare"||g.sdkName==="@magic-sdk/react-native-expo";if(t&&xr(g.version,19))throw new Error("loginWithMagicLink() is deprecated for this package, please utlize a passcode method like loginWithSMS or loginWithEmailOTP instead.");t&&Y({method:"auth.loginWithMagicLink()",removalVersions:z,useInstead:"auth.loginWithEmailOTP()"}).log();let{email:r,showUI:i=!0,redirectURI:n,overrides:s}=e,a=m(this.sdk.testMode?h.LoginWithMagicLinkTestMode:h.LoginWithMagicLink,[{email:r,showUI:i,redirectURI:n,overrides:s}]);return this.request(a)}loginWithSMS(e){let{phoneNumber:t}=e,r=m(this.sdk.testMode?h.LoginWithSmsTestMode:h.LoginWithSms,[{phoneNumber:t,showUI:!0}]);return this.request(r)}loginWithEmailOTP(e){let{email:t,showUI:r,deviceCheckUI:i,overrides:n}=e,s=m(this.sdk.testMode?h.LoginWithEmailOTPTestMode:h.LoginWithEmailOTP,[{email:t,showUI:r,deviceCheckUI:i,overrides:n}]),a=this.request(s);return!i&&a&&a.on(ge.Retry,()=>{this.createIntermediaryEvent(ge.Retry,s.id)()}),!r&&a&&(a.on(B.VerifyEmailOtp,o=>{this.createIntermediaryEvent(B.VerifyEmailOtp,s.id)(o)}),a.on(B.Cancel,()=>{this.createIntermediaryEvent(B.Cancel,s.id)()})),a}loginWithCredential(e){let t=e??"";if(!e&&g.platform==="web"){t=window.location.search;let i=window.location.origin+window.location.pathname;window.history.replaceState(null,"",i)}let r=m(this.sdk.testMode?h.LoginWithCredentialTestMode:h.LoginWithCredential,[t]);return this.request(r)}setAuthorizationToken(e){let t=m(h.SetAuthorizationToken,[{jwt:e}]);return this.request(t)}updateEmailWithUI(e){let{email:t,showUI:r=!0}=e,i=m(this.sdk.testMode?h.UpdateEmailTestMode:h.UpdateEmail,[{email:t,showUI:r}]),n=this.request(i);return r||(n.on(b.Retry,()=>{this.createIntermediaryEvent(b.Retry,i.id)()}),n.on(b.Cancel,()=>{this.createIntermediaryEvent(b.Cancel,i.id)()}),n.on(b.VerifyEmailOtp,s=>{this.createIntermediaryEvent(b.VerifyEmailOtp,i.id)(s)}),n.on(P.RetryWithNewEmail,s=>{this.createIntermediaryEvent(P.RetryWithNewEmail,i.id)(s)}),n.on(P.Cancel,()=>{this.createIntermediaryEvent(P.Cancel,i.id)()}),n.on(P.VerifyEmailOtp,s=>{this.createIntermediaryEvent(P.VerifyEmailOtp,i.id)(s)})),n}},tt={};Mt(tt,{clear:()=>Wr,getItem:()=>O,iterate:()=>rt,key:()=>qr,keys:()=>Vr,length:()=>jr,removeItem:()=>W,setItem:()=>T});var se;function S(e){return(...t)=>_(this,null,function*(){return se||(se=yield g.configureStorage()),yield se.ready(),se[e](...t)})}var O=S("getItem"),T=S("setItem"),W=S("removeItem"),Wr=S("clear"),jr=S("length"),qr=S("key"),Vr=S("keys"),rt=S("iterate");function Hr(){let e=window.crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&191|128;let t="";return t+=e[0].toString(16),t+=e[1].toString(16),t+=e[2].toString(16),t+=e[3].toString(16),t+="-",t+=e[4].toString(16),t+=e[5].toString(16),t+="-",t+=e[6].toString(16),t+=e[7].toString(16),t+="-",t+=e[8].toString(16),t+=e[9].toString(16),t+="-",t+=e[10].toString(16),t+=e[11].toString(16),t+=e[12].toString(16),t+=e[13].toString(16),t+=e[14].toString(16),t+=e[15].toString(16),t}var it="STORE_KEY_PRIVATE_KEY",ve="STORE_KEY_PUBLIC_JWK",nt="ECDSA",Xr="P-256",Br={name:nt,namedCurve:Xr};function me(){let e=typeof window<"u"&&!!window.crypto,t=e&&!!window.crypto.subtle;return e&&t}function Kr(){return _(this,null,function*(){let e=yield Yr();if(!e){console.info("unable to create public key or webcrypto is unsupported");return}let{subtle:t}=window.crypto,r=yield O(it);if(!r||!t){console.info("unable to find private key or webcrypto unsupported");return}let i={iat:Math.floor(new Date().getTime()/1e3),jti:Hr()},n={typ:"dpop+jwt",alg:"ES256",jwk:e},s={protected:We(JSON.stringify(n)),claims:We(JSON.stringify(i))},a=Jr(`${s.protected}.${s.claims}`),o={name:nt,hash:{name:"SHA-256"}},u=Zr(new Uint8Array(yield t.sign(o,r,a)));return`${s.protected}.${s.claims}.${u}`})}function Yr(){return _(this,null,function*(){if(!me()){console.info("webcrypto is not supported");return}return(yield O(ve))||(yield zr()),O(ve)})}function zr(){return _(this,null,function*(){let{subtle:e}=window.crypto,t=yield e.generateKey(Br,!1,["sign"]),r=yield e.exportKey("jwk",t.publicKey);yield T(it,t.privateKey),yield T(ve,r)})}function We(e){return st(Qr(e))}function Jr(e){return new TextEncoder().encode(e)}function st(e){return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+/g,"")}function Qr(e){return encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(t,r)=>String.fromCharCode(parseInt(r,16)))}function Zr(e){let t="";return e.forEach(r=>{t+=String.fromCharCode(r)}),st(t)}var $e="ds",Ne="ek",Ae="iv",Oe="AES-GCM",ei=256;function Me(){return _(this,null,function*(){let e=[];yield rt((t,r,i)=>{r.startsWith(`${$e}_`)&&e.push(r)});for(let t of e)yield W(t)})}function ot(e){let t="",r=new Uint8Array(e),i=r.byteLength;for(let n=0;n<i;n++)t+=String.fromCharCode(r[n]);return window.btoa(t)}function at(e){let t=window.atob(e),r=t.length,i=new Uint8Array(r);for(let n=0;n<r;n++)i[n]=t.charCodeAt(n);return i.buffer}function ti(){return _(this,null,function*(){if(!me()){console.info("webcrypto is not supported");return}let{crypto:e}=window;return(yield O(Ae))||e.getRandomValues(new Uint8Array(12))})}function ri(){return _(this,null,function*(){if(!me()){console.info("webcrypto is not supported");return}let{subtle:e}=window.crypto;return(yield O(Ne))||(yield e.generateKey({name:Oe,length:ei},!1,["encrypt","decrypt"]))})}function ii(e,t){return _(this,null,function*(){let r=yield ti(),i=yield ri();if(!r||!i||!e)return;let n=at(e),{subtle:s}=window.crypto,a=yield s.encrypt({name:Oe,iv:r},i,n),o=ot(a);yield T(`${$e}_${t}`,o),yield T(Ne,i),yield T(Ae,r)})}function ni(e){return _(this,null,function*(){let t=yield O(`${$e}_${e}`),r=yield O(Ae),i=yield O(Ne);if(!r||!t||!i||!me())return;let{subtle:n}=window.crypto,s=yield n.decrypt({name:Oe,iv:r},i,at(t));return ot(s)})}function je(e,t){return t?new URL(e,t):new URL(e)}var si=class extends G{constructor(){super(...arguments),this.localForageKey="mc_active_wallet",this.localForageIsLoggedInKey="magic_auth_is_logged_in",this.userLoggedOutCallbacks=[]}getIdToken(e){let t=m(this.sdk.testMode?h.GetIdTokenTestMode:h.GetIdToken,[e]);return this.request(t)}generateIdToken(e){let t=m(this.sdk.testMode?h.GenerateIdTokenTestMode:h.GenerateIdToken,[e]);return this.request(t)}getInfo(){return _(this,null,function*(){let e=yield O(this.localForageKey),t=m(h.GetInfo,[{walletType:e}]);return this.request(t)})}isLoggedIn(){return Z((e,t)=>_(this,null,function*(){try{let r=!1;this.sdk.useStorageCache&&(r=(yield O(this.localForageIsLoggedInKey))==="true",r&&e(!0));let i=m(this.sdk.testMode?h.IsLoggedInTestMode:h.IsLoggedIn),n=yield this.request(i);this.sdk.useStorageCache&&(n?T(this.localForageIsLoggedInKey,!0):W(this.localForageIsLoggedInKey),r&&!n&&this.emitUserLoggedOut(!0)),e(n)}catch(r){t(r)}}))}logout(){return W(this.localForageKey),W(this.localForageIsLoggedInKey),Me(),Z((e,t)=>_(this,null,function*(){try{let r=m(this.sdk.testMode?h.LogoutTestMode:h.Logout),i=yield this.request(r);this.sdk.useStorageCache&&this.emitUserLoggedOut(i),e(i)}catch(r){t(r)}}))}requestInfoWithUI(e){let t=m(h.RequestUserInfoWithUI,e?[e]:[]);return this.request(t)}showSettings(e){let t=m(this.sdk.testMode?h.UserSettingsTestMode:h.UserSettings,[e]);return this.request(t)}recoverAccount(e){let t=m(this.sdk.testMode?h.RecoverAccountTestMode:h.RecoverAccount,[e]);return this.request(t)}getMetadata(){Y({method:"user.getMetadata()",removalVersions:z,useInstead:"user.getInfo()"}).log();let e=m(this.sdk.testMode?h.GetMetadataTestMode:h.GetMetadata);return this.request(e)}onUserLoggedOut(e){this.userLoggedOutCallbacks.push(e)}emitUserLoggedOut(e){this.userLoggedOutCallbacks.forEach(t=>{t(e)})}},oi=class extends G{constructor(){super(...arguments),this.localForageKey="mc_active_wallet"}connectWithUI(){let e=Z((t,r)=>_(this,null,function*(){try{if(this.isMetaMaskBrowser()&&(yield this.isWalletEnabled(M.MetaMask))){let o=yield this.autoConnectIfWalletBrowser(M.MetaMask);t(o);return}if(this.isCoinbaseWalletBrowser()&&(yield this.isWalletEnabled(M.CoinbaseWallet))){let o=yield this.autoConnectIfWalletBrowser(M.CoinbaseWallet);t(o);return}let i=this.getUserEnv(),n=m(h.Login,[i]),s=this.request(n);s.on(ae.WalletSelected,o=>this.handleWalletSelected(ye(Ie({},o),{payloadId:n.id}))),s.on("id-token-created",o=>{e.emit("id-token-created",o)});let a=yield s;a.error&&r(a),t(a)}catch(i){r(i)}}));return e}showUI(){return this.request(m(h.ShowUI))}showAddress(){return this.request(m(h.ShowAddress))}showSendTokensUI(){return this.request(m(h.ShowSendTokensUI))}showOnRamp(){return this.request(m(h.ShowOnRamp))}showNFTs(){return this.request(m(h.ShowNFTs))}showBalances(){return this.request(m(h.ShowBalances))}sendGaslessTransaction(e,t){return this.request(m(h.SendGaslessTransaction,[e,t]))}getInfo(){return _(this,null,function*(){Y({method:"wallet.getInfo()",removalVersions:z,useInstead:"user.getInfo()"}).log();let e=yield O(this.localForageKey),t=m(h.GetInfo,[{walletType:e}]);return this.request(t)})}disconnect(){Y({method:"wallet.disconnect()",removalVersions:z,useInstead:"user.logout()"}).log(),W(this.localForageKey),Me();let e=m(h.Disconnect);return this.request(e)}requestUserInfoWithUI(e){Y({method:"wallet.requestUserInfoWithUI()",removalVersions:z,useInstead:"user.requestUserInfoWithUI()"}).log();let t=m(h.RequestUserInfoWithUI,e?[e]:[]);return this.request(t)}getProvider(){return _(this,null,function*(){switch(yield O(this.localForageKey)){case M.MetaMask:return this.getMetaMaskProvider();case M.CoinbaseWallet:return this.getCoinbaseProvider();default:return this.sdk.rpcProvider}})}isMetaMaskInstalled(){var e,t,r;return((e=window.ethereum)==null?void 0:e.isMetaMask)||!!((r=(t=window.ethereum)==null?void 0:t.providers)!=null&&r.find(i=>i==null?void 0:i.isMetaMask))}isMetaMaskBrowser(){return this.isMobile()&&this.isMetaMaskInstalled()}getMetaMaskProvider(){var e,t;return((t=(e=window.ethereum)==null?void 0:e.providers)==null?void 0:t.find(r=>r==null?void 0:r.isMetaMask))||window.ethereum}connectToMetaMask(){if(this.isMobile()&&!this.isMetaMaskInstalled()){let e=`https://metamask.app.link/dapp/${window.location.href.replace(/(^\w+:|^)\/\//,"")}`;window.location.href=e}return this.getMetaMaskProvider().request({method:"eth_requestAccounts"})}isCoinbaseWalletInstalled(){var e,t,r;return((e=window.ethereum)==null?void 0:e.isCoinbaseWallet)||!!((r=(t=window.ethereum)==null?void 0:t.providers)!=null&&r.find(i=>i==null?void 0:i.isCoinbaseWallet))}isCoinbaseWalletBrowser(){var e;return!!((e=window.ethereum)!=null&&e.isCoinbaseBrowser)}getCoinbaseProvider(){var e,t;return((t=(e=window.ethereum)==null?void 0:e.providers)==null?void 0:t.find(r=>r==null?void 0:r.isCoinbaseWallet))||window.ethereum}connectToCoinbaseWallet(){if(this.isMobile()&&!this.isCoinbaseWalletBrowser()){let e=`https://go.cb-w.com/dapp?cb_url=${encodeURIComponent(window.location.href)}`;window.location.href=e}return this.getCoinbaseProvider().request({method:"eth_requestAccounts"})}isMobile(){return/Android|webOS|iPhone|iPad|iPod|BlackBerry|BB|PlayBook|IEMobile|Windows Phone|Silk|Opera Mini/i.test(navigator.userAgent)}getUserEnv(){return{env:{isMetaMaskInstalled:this.isMetaMaskInstalled(),isCoinbaseWalletInstalled:this.isCoinbaseWalletInstalled()}}}connectToThirdPartyWallet(e){switch(e){case M.MetaMask:return this.connectToMetaMask();case M.CoinbaseWallet:return this.connectToCoinbaseWallet();default:throw new Error(`Invalid provider: ${e}. Must be one of "metamask" or "coinbase_wallet".`)}}isWalletEnabled(e){let t=m("mc_is_wallet_enabled",[{wallet:e}]);return this.request(t)}handleWalletSelected(e){return _(this,null,function*(){try{let t=yield this.connectToThirdPartyWallet(e.wallet);yield T(this.localForageKey,e.wallet),this.createIntermediaryEvent(ae.WalletConnected,e.payloadId)(t)}catch(t){console.error(t),this.createIntermediaryEvent(ae.WalletRejected,e.payloadId)()}})}autoConnectIfWalletBrowser(e){return _(this,null,function*(){let t;e===M.MetaMask&&(t=yield this.getMetaMaskProvider().request({method:"eth_requestAccounts"})),e===M.CoinbaseWallet&&(t=yield this.getCoinbaseProvider().request({method:"eth_requestAccounts"})),yield T(this.localForageKey,e);let r=m(h.AutoConnect,[{wallet:e,address:t}]);return this.request(r)})}},{createBoundEmitterMethod:oe,createChainingEmitterMethod:x}=Qe(),ai=class extends G{constructor(){super(...arguments),this.isMagic=!0,this.on=x("on",this),this.once=x("once",this),this.addListener=x("addListener",this),this.off=x("off",this),this.removeListener=x("removeListener",this),this.removeAllListeners=x("removeAllListeners",this),this.emit=oe("emit"),this.eventNames=oe("eventNames"),this.listeners=oe("listeners"),this.listenerCount=oe("listenerCount")}sendAsync(e,t){if(!t)throw Lr({procedure:"Magic.rpcProvider.sendAsync",argument:1,expected:"function",received:t===null?"null":typeof t});if(Array.isArray(e))this.overlay.post(ce.MAGIC_HANDLE_REQUEST,e.map(r=>{let i=he(r);return this.prefixPayloadMethodForTestMode(i),i})).then(r=>{t(null,r.map(i=>ye(Ie({},i.payload),{error:i.hasError?new de(i.payload.error):null})))});else{let r=he(e);this.prefixPayloadMethodForTestMode(r),this.overlay.post(ce.MAGIC_HANDLE_REQUEST,r).then(i=>{t(i.hasError?new de(i.payload.error):null,i.payload)})}}send(e,t){if(typeof e=="string"){let i=m(e,Array.isArray(t)?t:[]);return this.request(i)}if(Array.isArray(e)||t){this.sendAsync(e,t);return}let r=Sr();return r.log(),new Re(e).applyError({code:-32603,message:r.rawMessage}).payload}enable(){let e=m(h.Login);return this.request(e)}request(e){return this.prefixPayloadMethodForTestMode(e),super.request(e)}prefixPayloadMethodForTestMode(e){let t="testMode/eth/";this.sdk.testMode&&(e.method=`${t}${e.method}`)}},qe=["request","overlay","sdk"];function li(e){let t=Object.getPrototypeOf(e),r=[t];for(;t!==G.prototype;)t=Object.getPrototypeOf(t),r.push(t);return r}var lt=class extends G{constructor(){super(void 0),this.__sdk_access_field_descriptors__=new Map,this.__is_initialized__=!1,this.utils={createPromiEvent:Z,isPromiEvent:Gr,encodeJSON:Xe,decodeJSON:Ir,createJsonRpcRequestPayload:m,standardizeJsonRpcRequestPayload:he,storage:tt};let e=[this,...li(this)];qe.forEach(t=>{let r=e.map(a=>Object.getOwnPropertyDescriptor(a,t)),i=r.findIndex(a=>!!a),n=i>0,s=r[i];s&&(this.__sdk_access_field_descriptors__.set(t,{descriptor:s,isPrototypeField:n}),Object.defineProperty(this,t,{configurable:!0,get:()=>{throw Mr(t)}}))})}init(e){this.__is_initialized__||(qe.forEach(t=>{if(this.__sdk_access_field_descriptors__.has(t)){let{descriptor:r,isPrototypeField:i}=this.__sdk_access_field_descriptors__.get(t);i?delete this[t]:Object.defineProperty(this,t,r)}}),this.sdk=e,this.__is_initialized__=!0)}createDeprecationWarning(e){let{method:t,removalVersion:r,useInstead:i}=e,n=i?` Use \`${i}\` instead.`:"",s=`\`${t}\` will be removed from this Extension in version \`${r}\`.${n}`;return new Fe(this,"DEPRECATION_NOTICE",s)}createWarning(e,t){return new Fe(this,e,t)}createError(e,t,r){return new Ke(this,e,t,r)}},ci=class extends lt{},J=class extends lt{};J.Internal=ci,J.Anonymous="anonymous extension";var ui=class extends G{purchase(e){let t=m(h.NFTPurchase,[e]);return this.request(t)}checkout(e){let t=m(h.NFTCheckout,[e]);return this.request(t)}transfer(e){let t=m(h.NFTTransfer,[e]);return this.request(t)}};function Ve(e){return e.compat&&e.compat[g.sdkName]!=null?typeof e.compat[g.sdkName]=="string"?dr(Er(g.version),e.compat[g.sdkName]):!!e.compat[g.sdkName]:!0}function di(e,t,r){return!t&&!r?`${e}_eth_mainnet`:r?`${e}_${JSON.stringify(r)}`:t?typeof t=="string"?`${e}_eth_${t}`:`${e}_${t.rpcUrl}_${t.chainId}_${t.chainType}`:`${e}_unknown`}function hi(e){var t;let r=(t=e==null?void 0:e.extensions)!=null?t:[],i={},n=[];if(Array.isArray(r)?r.forEach(s=>{Ve(s)?(s.init(this),(s.name||s.name!==J.Anonymous)&&(this[s.name]=s),s instanceof J.Internal&&(ue(s.config)||(i[s.name]=s.config))):n.push(s)}):Object.keys(r).forEach(s=>{if(Ve(r[s])){r[s].init(this);let a=r[s];this[s]=a,a instanceof J.Internal&&(ue(a.config)||(i[r[s].name]=a.config))}else n.push(r[s])}),n.length)throw Tr(n);return i}var le=class{constructor(e,t){this.apiKey=e;var r;if(!e)throw Nr();g.platform==="react-native"&&(t!=null&&t.endpoint)&&Cr().log();let{defaultEndpoint:i,version:n}=g;this.testMode=!!(t!=null&&t.testMode),this.useStorageCache=!!(t!=null&&t.useStorageCache),this.endpoint=je((r=t==null?void 0:t.endpoint)!=null?r:i).origin,this.auth=new Fr(this),this.user=new si(this),this.wallet=new oi(this),this.nft=new ui(this),this.rpcProvider=new ai(this);let s=hi.call(this,t);this.parameters=Xe(ye(Ie({API_KEY:this.apiKey,DOMAIN_ORIGIN:window.location?window.location.origin:"",ETH_NETWORK:t==null?void 0:t.network,host:je(this.endpoint).host,sdk:$r[g.sdkName],version:n,ext:ue(s)?void 0:s,locale:(t==null?void 0:t.locale)||"en_US"},g.bundleId?{bundleId:g.bundleId}:{}),{meta:t==null?void 0:t.meta})),this.networkHash=di(this.apiKey,t==null?void 0:t.network,ue(s)?void 0:s),t!=null&&t.deferPreload||this.preload()}get overlay(){if(!le.__overlays__.has(this.parameters)){let e=new g.ViewController(this.endpoint,this.parameters,this.networkHash);e.init(),le.__overlays__.set(this.parameters,e)}return le.__overlays__.get(this.parameters)}preload(){return _(this,null,function*(){yield this.overlay.checkIsReadyForRequest})}},pi=le;pi.__overlays__=new Map;function mi(e,t){return t&&Array.isArray(e)?e.find(r=>r.id===t):e}function Ei(e,t){var r;let i=(r=t.data.response)==null?void 0:r.id,n=mi(e,i);if(i&&n){let s=new Re(n).applyResult(t.data.response.result).applyError(t.data.response.error);return{id:i,response:s}}return{}}function fi(e,t,r){return _(this,null,function*(){var i;let n=yield O("rt"),s;if(g.platform==="web")try{s=(i=yield O("jwt"))!=null?i:yield Kr()}catch(u){console.error("webcrypto error",u)}let a={msgType:e,payload:t};s&&(a.jwt=s),s&&n&&(a.rt=n);let o=yield ni(r);return o&&(a.deviceShare=o),a})}function gi(e){return _(this,null,function*(){!e.data.rt||(yield T("rt",e.data.rt))})}var yi=class{constructor(e,t,r){this.endpoint=e,this.parameters=t,this.networkHash=r,this.messageHandlers=new Set,this.isConnectedToInternet=!0,this.checkIsReadyForRequest=this.waitForReady(),this.isReadyForRequest=!1,this.listen()}post(e,t){return _(this,null,function*(){return et((r,i)=>_(this,null,function*(){if(!this.isConnectedToInternet){let l=Ar();i(l)}this.isReadyForRequest||(yield this.waitForReady());let n=[],s=Array.isArray(t)?t.map(l=>l.id):[],a=yield fi(`${e}-${this.parameters}`,t,this.networkHash);yield this._post(a);let o=l=>c=>{var d;let{id:f,response:v}=Ei(t,c);if(gi(c),((d=v==null?void 0:v.payload.error)==null?void 0:d.message)==="User denied account access.")Me();else if(c.data.deviceShare){let{deviceShare:I}=c.data;ii(I,this.networkHash)}f&&v&&Array.isArray(t)&&s.includes(f)?(n.push(v),n.length===t.length&&(l(),r(n))):f&&v&&!Array.isArray(t)&&f===t.id&&(l(),r(v))},u=this.on(k.MAGIC_HANDLE_RESPONSE,o(()=>u()))}))})}on(e,t){let r=t.bind(window),i=n=>{n.data.msgType===`${e}-${this.parameters}`&&r(n)};return this.messageHandlers.add(i),()=>this.messageHandlers.delete(i)}waitForReady(){return new Promise(e=>{let t=this.on(k.MAGIC_OVERLAY_READY,()=>{this.isReadyForRequest=!0,e(),t()})})}listen(){this.on(k.MAGIC_HIDE_OVERLAY,()=>{this.hideOverlay()}),this.on(k.MAGIC_SHOW_OVERLAY,()=>{this.showOverlay()}),this.on(k.MAGIC_SEND_PRODUCT_ANNOUNCEMENT,e=>{e.data.response.result.product_announcement&&new te(j.ProductAnnouncement,e.data.response.result.product_announcement).log()})}};export{pi as $,D as A,yi as B,ae as E,B as I,je as J,_i as K,gt as L,pt as N,ft as O,ge as R,Et as T,P as U,Ke as V,te as W,de as _,J as a,mt as b,ht as c,ce as d,_e as e,k as f,dt as g,b as h,U as i,vt as k,Ar as m,j as p,Ii as q,Fe as s,M as u,h as v,Gr as x,_t as y};
@@ -1 +0,0 @@
1
- import{a as g}from"./index-B6Hui9GU.js";import"./thirdweb-D6clKR4w.js";var m=Object.defineProperty,v=Object.defineProperties,y=Object.getOwnPropertyDescriptors,c=Object.getOwnPropertySymbols,w=Object.prototype.hasOwnProperty,f=Object.prototype.propertyIsEnumerable,d=(e,r,t)=>r in e?m(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,h=(e,r)=>{for(var t in r||(r={}))w.call(r,t)&&d(e,t,r[t]);if(c)for(var t of c(r))f.call(r,t)&&d(e,t,r[t]);return e},_=(e,r)=>v(e,y(r)),p=(e,r,t)=>new Promise((n,s)=>{var l=a=>{try{o(t.next(a))}catch(u){s(u)}},i=a=>{try{o(t.throw(a))}catch(u){s(u)}},o=a=>a.done?n(a.value):Promise.resolve(a.value).then(l,i);o((t=t.apply(e,r)).next())}),b=(e=>(e.Start="magic_oauth_login_with_redirect_start",e.Verify="magic_oauth_login_with_redirect_verify",e.Popup="magic_oauth_login_with_popup",e.VerifyTelegramData="magic_oauth_verify_telegram_data",e))(b||{}),R=(e=>(e.InvalidRequest="invalid_request",e.InvalidClient="invalid_client",e.InvalidScope="invalid_scope",e.InvalidGrant="invalid_grant",e.UnauthorizedClient="unauthorized_client",e.UnsupportedResponseType="unsupported_response_type",e.UnsupportedGrantType="unsupported_grant_type",e.UnsupportedTokenType="unsupported_token_type",e.AccessDenied="access_denied",e.ServerError="server_error",e.TemporarilyUnavailable="temporarily_unavailable",e))(R||{}),I=class extends g.Internal{constructor(){super(),this.name="oauth2",this.config={},this.compat={"magic-sdk":">=2.4.6","@magic-sdk/react-native":!1,"@magic-sdk/react-native-bare":!1,"@magic-sdk/react-native-expo":!1},this.seamlessTelegramLogin()}loginWithRedirect(e){return this.utils.createPromiEvent((r,t)=>p(this,null,function*(){var n;let s=this.utils.createJsonRpcRequestPayload("magic_oauth_login_with_redirect_start",[_(h({},e),{apiKey:this.sdk.apiKey,platform:"web"})]),l=yield this.request(s),i=l,o=l;if(o.error&&t(this.createError(o.error,(n=o.error_description)!=null?n:"An error occurred.",{errorURI:o.error_uri,provider:o.provider})),i!=null&&i.oauthAuthoriationURI){let a=i.useMagicServerCallback?new URL(i.oauthAuthoriationURI,this.sdk.endpoint).href:i.oauthAuthoriationURI;i!=null&&i.shouldReturnURI?r(a):window.location.href=a}r(null)}))}getRedirectResult(e,r){let t=r||window.location.search,n=window.location.origin+window.location.pathname;return window.history.replaceState(null,"",n),P.call(this,t,e)}loginWithPopup(e){let r=this.utils.createJsonRpcRequestPayload("magic_oauth_login_with_popup",[_(h({},e),{apiKey:this.sdk.apiKey,platform:"web"})]);return this.request(r)}seamlessTelegramLogin(){try{if(!window.location.hash.toString().includes("#tgWebAppData"))return;let e=document.createElement("script");e.src="https://telegram.org/js/telegram-web-app.js",document.head.prepend(e),e.onload=()=>p(this,null,function*(){var r;try{let t=(r=window.Telegram)==null?void 0:r.WebApp.initData,n=this.utils.createJsonRpcRequestPayload("magic_oauth_verify_telegram_data",[{userData:t,isMiniApp:!0}]);yield this.request(n)}catch(t){console.log("Error while verifying telegram data",t)}})}catch(e){console.log("Error while loading telegram-web-app script",e)}}};function P(e,r){return this.utils.createPromiEvent((t,n)=>p(this,null,function*(){var s;let l=this.utils.createJsonRpcRequestPayload("magic_oauth_login_with_redirect_verify",[{authorizationResponseParams:e,magicApiKey:this.sdk.apiKey,platform:"web",lifespan:r}]),i=yield this.request(l),o=i,a=i;a.error&&n(this.createError(a.error,(s=a.error_description)!=null?s:"An error occurred.",{errorURI:a.error_uri,provider:a.provider})),t(o)}))}export{R as OAuthErrorCode,I as OAuthExtension,b as OAuthPayloadMethods};
@@ -1 +0,0 @@
1
- import{g as se}from"./ui-DNHWrHSH.js";import{K as Wr,$ as qr,B as Kr,m as Vr,q as Xr,J as Ye}from"./index-B6Hui9GU.js";import{g as dt,R as vt,T as ht,k as yt,E as pt,a as mt,V as bt,s as gt,I as _t,b as wt,c as It,N as Et,f as St,d as Ot,v as jt,_ as Nt,e as At,h as Bt,O as kt,y as xt,A as Dt,i as Rt,W as Ct,p as Lt,U as Mt,L as Tt,u as zt,x as Ft}from"./index-B6Hui9GU.js";import"./vendor-BgiNx-Ph.js";import"./thirdweb-D6clKR4w.js";var Yr=Object.create,Qe=Object.defineProperty,Jr=Object.getOwnPropertyDescriptor,Qr=Object.getOwnPropertyNames,Zr=Object.getPrototypeOf,Hr=Object.prototype.hasOwnProperty,pe=(_=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(_,{get:(O,m)=>(typeof require<"u"?require:O)[m]}):_)(function(_){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+_+'" is not supported')}),Ze=(_,O)=>()=>(O||_((O={exports:{}}).exports,O),O.exports),Gr=(_,O,m,x)=>{if(O&&typeof O=="object"||typeof O=="function")for(let q of Qr(O))!Hr.call(_,q)&&q!==m&&Qe(_,q,{get:()=>O[q],enumerable:!(x=Jr(O,q))||x.enumerable});return _},He=(_,O,m)=>(m=_!=null?Yr(Zr(_)):{},Gr(!_||!_.__esModule?Qe(m,"default",{value:_,enumerable:!0}):m,_)),me=(_,O,m)=>new Promise((x,q)=>{var C=D=>{try{j(m.next(D))}catch(L){q(L)}},P=D=>{try{j(m.throw(D))}catch(L){q(L)}},j=D=>D.done?x(D.value):Promise.resolve(D.value).then(C,P);j((m=m.apply(_,O)).next())}),$r=Ze((_,O)=>{(function(m){if(typeof _=="object"&&typeof O<"u")O.exports=m();else if(typeof define=="function"&&define.amd)define([],m);else{var x;typeof window<"u"?x=window:typeof se<"u"?x=se:typeof self<"u"?x=self:x=this,x.localforage=m()}})(function(){return(function m(x,q,C){function P(L,Y){if(!q[L]){if(!x[L]){var y=typeof pe=="function"&&pe;if(!Y&&y)return y(L,!0);if(j)return j(L,!0);var w=new Error("Cannot find module '"+L+"'");throw w.code="MODULE_NOT_FOUND",w}var z=q[L]={exports:{}};x[L][0].call(z.exports,function(F){var Z=x[L][1][F];return P(Z||F)},z,z.exports,m,x,q,C)}return q[L].exports}for(var j=typeof pe=="function"&&pe,D=0;D<C.length;D++)P(C[D]);return P})({1:[function(m,x,q){(function(C){var P=C.MutationObserver||C.WebKitMutationObserver,j;if(P){var D=0,L=new P(F),Y=C.document.createTextNode("");L.observe(Y,{characterData:!0}),j=function(){Y.data=D=++D%2}}else if(!C.setImmediate&&typeof C.MessageChannel<"u"){var y=new C.MessageChannel;y.port1.onmessage=F,j=function(){y.port2.postMessage(0)}}else"document"in C&&"onreadystatechange"in C.document.createElement("script")?j=function(){var A=C.document.createElement("script");A.onreadystatechange=function(){F(),A.onreadystatechange=null,A.parentNode.removeChild(A),A=null},C.document.documentElement.appendChild(A)}:j=function(){setTimeout(F,0)};var w,z=[];function F(){w=!0;for(var A,G,U=z.length;U;){for(G=z,z=[],A=-1;++A<U;)G[A]();U=z.length}w=!1}x.exports=Z;function Z(A){z.push(A)===1&&!w&&j()}}).call(this,typeof se<"u"?se:typeof self<"u"?self:typeof window<"u"?window:{})},{}],2:[function(m,x,q){var C=m(1);function P(){}var j={},D=["REJECTED"],L=["FULFILLED"],Y=["PENDING"];x.exports=y;function y(v){if(typeof v!="function")throw new TypeError("resolver must be a function");this.state=Y,this.queue=[],this.outcome=void 0,v!==P&&Z(this,v)}y.prototype.catch=function(v){return this.then(null,v)},y.prototype.then=function(v,N){if(typeof v!="function"&&this.state===L||typeof N!="function"&&this.state===D)return this;var E=new this.constructor(P);if(this.state!==Y){var B=this.state===L?v:N;z(E,B,this.outcome)}else this.queue.push(new w(E,v,N));return E};function w(v,N,E){this.promise=v,typeof N=="function"&&(this.onFulfilled=N,this.callFulfilled=this.otherCallFulfilled),typeof E=="function"&&(this.onRejected=E,this.callRejected=this.otherCallRejected)}w.prototype.callFulfilled=function(v){j.resolve(this.promise,v)},w.prototype.otherCallFulfilled=function(v){z(this.promise,this.onFulfilled,v)},w.prototype.callRejected=function(v){j.reject(this.promise,v)},w.prototype.otherCallRejected=function(v){z(this.promise,this.onRejected,v)};function z(v,N,E){C(function(){var B;try{B=N(E)}catch(K){return j.reject(v,K)}B===v?j.reject(v,new TypeError("Cannot resolve promise with itself")):j.resolve(v,B)})}j.resolve=function(v,N){var E=A(F,N);if(E.status==="error")return j.reject(v,E.value);var B=E.value;if(B)Z(v,B);else{v.state=L,v.outcome=N;for(var K=-1,X=v.queue.length;++K<X;)v.queue[K].callFulfilled(N)}return v},j.reject=function(v,N){v.state=D,v.outcome=N;for(var E=-1,B=v.queue.length;++E<B;)v.queue[E].callRejected(N);return v};function F(v){var N=v&&v.then;if(v&&(typeof v=="object"||typeof v=="function")&&typeof N=="function")return function(){N.apply(v,arguments)}}function Z(v,N){var E=!1;function B(Q){E||(E=!0,j.reject(v,Q))}function K(Q){E||(E=!0,j.resolve(v,Q))}function X(){N(K,B)}var J=A(X);J.status==="error"&&B(J.value)}function A(v,N){var E={};try{E.value=v(N),E.status="success"}catch(B){E.status="error",E.value=B}return E}y.resolve=G;function G(v){return v instanceof this?v:j.resolve(new this(P),v)}y.reject=U;function U(v){var N=new this(P);return j.reject(N,v)}y.all=oe;function oe(v){var N=this;if(Object.prototype.toString.call(v)!=="[object Array]")return this.reject(new TypeError("must be an array"));var E=v.length,B=!1;if(!E)return this.resolve([]);for(var K=new Array(E),X=0,J=-1,Q=new this(P);++J<E;)$(v[J],J);return Q;function $(ie,ue){N.resolve(ie).then(le,function(re){B||(B=!0,j.reject(Q,re))});function le(re){K[ue]=re,++X===E&&!B&&(B=!0,j.resolve(Q,K))}}}y.race=ee;function ee(v){var N=this;if(Object.prototype.toString.call(v)!=="[object Array]")return this.reject(new TypeError("must be an array"));var E=v.length,B=!1;if(!E)return this.resolve([]);for(var K=-1,X=new this(P);++K<E;)J(v[K]);return X;function J(Q){N.resolve(Q).then(function($){B||(B=!0,j.resolve(X,$))},function($){B||(B=!0,j.reject(X,$))})}}},{1:1}],3:[function(m,x,q){(function(C){typeof C.Promise!="function"&&(C.Promise=m(2))}).call(this,typeof se<"u"?se:typeof self<"u"?self:typeof window<"u"?window:{})},{2:2}],4:[function(m,x,q){var C=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function P(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}function j(){try{if(typeof indexedDB<"u")return indexedDB;if(typeof webkitIndexedDB<"u")return webkitIndexedDB;if(typeof mozIndexedDB<"u")return mozIndexedDB;if(typeof OIndexedDB<"u")return OIndexedDB;if(typeof msIndexedDB<"u")return msIndexedDB}catch{return}}var D=j();function L(){try{if(!D||!D.open)return!1;var e=typeof openDatabase<"u"&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),r=typeof fetch=="function"&&fetch.toString().indexOf("[native code")!==-1;return(!e||r)&&typeof indexedDB<"u"&&typeof IDBKeyRange<"u"}catch{return!1}}function Y(e,r){e=e||[],r=r||{};try{return new Blob(e,r)}catch(i){if(i.name!=="TypeError")throw i;for(var t=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,o=new t,n=0;n<e.length;n+=1)o.append(e[n]);return o.getBlob(r.type)}}typeof Promise>"u"&&m(3);var y=Promise;function w(e,r){r&&e.then(function(t){r(null,t)},function(t){r(t)})}function z(e,r,t){typeof r=="function"&&e.then(r),typeof t=="function"&&e.catch(t)}function F(e){return typeof e!="string"&&(console.warn(e+" used as a key, but it is not a string."),e=String(e)),e}function Z(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}var A="local-forage-detect-blob-support",G=void 0,U={},oe=Object.prototype.toString,ee="readonly",v="readwrite";function N(e){for(var r=e.length,t=new ArrayBuffer(r),o=new Uint8Array(t),n=0;n<r;n++)o[n]=e.charCodeAt(n);return t}function E(e){return new y(function(r){var t=e.transaction(A,v),o=Y([""]);t.objectStore(A).put(o,"key"),t.onabort=function(n){n.preventDefault(),n.stopPropagation(),r(!1)},t.oncomplete=function(){var n=navigator.userAgent.match(/Chrome\/(\d+)/),i=navigator.userAgent.match(/Edge\//);r(i||!n||parseInt(n[1],10)>=43)}}).catch(function(){return!1})}function B(e){return typeof G=="boolean"?y.resolve(G):E(e).then(function(r){return G=r,G})}function K(e){var r=U[e.name],t={};t.promise=new y(function(o,n){t.resolve=o,t.reject=n}),r.deferredOperations.push(t),r.dbReady?r.dbReady=r.dbReady.then(function(){return t.promise}):r.dbReady=t.promise}function X(e){var r=U[e.name],t=r.deferredOperations.pop();if(t)return t.resolve(),t.promise}function J(e,r){var t=U[e.name],o=t.deferredOperations.pop();if(o)return o.reject(r),o.promise}function Q(e,r){return new y(function(t,o){if(U[e.name]=U[e.name]||g(),e.db)if(r)K(e),e.db.close();else return t(e.db);var n=[e.name];r&&n.push(e.version);var i=D.open.apply(D,n);r&&(i.onupgradeneeded=function(u){var c=i.result;try{c.createObjectStore(e.storeName),u.oldVersion<=1&&c.createObjectStore(A)}catch(d){if(d.name==="ConstraintError")console.warn('The database "'+e.name+'" has been upgraded from version '+u.oldVersion+" to version "+u.newVersion+', but the storage "'+e.storeName+'" already exists.');else throw d}}),i.onerror=function(u){u.preventDefault(),o(i.error)},i.onsuccess=function(){var u=i.result;u.onversionchange=function(c){c.target.close()},t(u),X(e)}})}function $(e){return Q(e,!1)}function ie(e){return Q(e,!0)}function ue(e,r){if(!e.db)return!0;var t=!e.db.objectStoreNames.contains(e.storeName),o=e.version<e.db.version,n=e.version>e.db.version;if(o&&(e.version!==r&&console.warn('The database "'+e.name+`" can't be downgraded from version `+e.db.version+" to version "+e.version+"."),e.version=e.db.version),n||t){if(t){var i=e.db.version+1;i>e.version&&(e.version=i)}return!0}return!1}function le(e){return new y(function(r,t){var o=new FileReader;o.onerror=t,o.onloadend=function(n){var i=btoa(n.target.result||"");r({__local_forage_encoded_blob:!0,data:i,type:e.type})},o.readAsBinaryString(e)})}function re(e){var r=N(atob(e.data));return Y([r],{type:e.type})}function a(e){return e&&e.__local_forage_encoded_blob}function f(e){var r=this,t=r._initReady().then(function(){var o=U[r._dbInfo.name];if(o&&o.dbReady)return o.dbReady});return z(t,e,e),t}function h(e){K(e);for(var r=U[e.name],t=r.forages,o=0;o<t.length;o++){var n=t[o];n._dbInfo.db&&(n._dbInfo.db.close(),n._dbInfo.db=null)}return e.db=null,$(e).then(function(i){return e.db=i,ue(e)?ie(e):i}).then(function(i){e.db=r.db=i;for(var u=0;u<t.length;u++)t[u]._dbInfo.db=i}).catch(function(i){throw J(e,i),i})}function p(e,r,t,o){o===void 0&&(o=1);try{var n=e.db.transaction(e.storeName,r);t(null,n)}catch(i){if(o>0&&(!e.db||i.name==="InvalidStateError"||i.name==="NotFoundError"))return y.resolve().then(function(){if(!e.db||i.name==="NotFoundError"&&!e.db.objectStoreNames.contains(e.storeName)&&e.version<=e.db.version)return e.db&&(e.version=e.db.version+1),ie(e)}).then(function(){return h(e).then(function(){p(e,r,t,o-1)})}).catch(t);t(i)}}function g(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function I(e){var r=this,t={db:null};if(e)for(var o in e)t[o]=e[o];var n=U[t.name];n||(n=g(),U[t.name]=n),n.forages.push(r),r._initReady||(r._initReady=r.ready,r.ready=f);var i=[];function u(){return y.resolve()}for(var c=0;c<n.forages.length;c++){var d=n.forages[c];d!==r&&i.push(d._initReady().catch(u))}var l=n.forages.slice(0);return y.all(i).then(function(){return t.db=n.db,$(t)}).then(function(s){return t.db=s,ue(t,r._defaultConfig.version)?ie(t):s}).then(function(s){t.db=n.db=s,r._dbInfo=t;for(var b=0;b<l.length;b++){var S=l[b];S!==r&&(S._dbInfo.db=t.db,S._dbInfo.version=t.version)}})}function M(e,r){var t=this;e=F(e);var o=new y(function(n,i){t.ready().then(function(){p(t._dbInfo,ee,function(u,c){if(u)return i(u);try{var d=c.objectStore(t._dbInfo.storeName),l=d.get(e);l.onsuccess=function(){var s=l.result;s===void 0&&(s=null),a(s)&&(s=re(s)),n(s)},l.onerror=function(){i(l.error)}}catch(s){i(s)}})}).catch(i)});return w(o,r),o}function V(e,r){var t=this,o=new y(function(n,i){t.ready().then(function(){p(t._dbInfo,ee,function(u,c){if(u)return i(u);try{var d=c.objectStore(t._dbInfo.storeName),l=d.openCursor(),s=1;l.onsuccess=function(){var b=l.result;if(b){var S=b.value;a(S)&&(S=re(S));var R=e(S,b.key,s++);R!==void 0?n(R):b.continue()}else n()},l.onerror=function(){i(l.error)}}catch(b){i(b)}})}).catch(i)});return w(o,r),o}function ce(e,r,t){var o=this;e=F(e);var n=new y(function(i,u){var c;o.ready().then(function(){return c=o._dbInfo,oe.call(r)==="[object Blob]"?B(c.db).then(function(d){return d?r:le(r)}):r}).then(function(d){p(o._dbInfo,v,function(l,s){if(l)return u(l);try{var b=s.objectStore(o._dbInfo.storeName);d===null&&(d=void 0);var S=b.put(d,e);s.oncomplete=function(){d===void 0&&(d=null),i(d)},s.onabort=s.onerror=function(){var R=S.error?S.error:S.transaction.error;u(R)}}catch(R){u(R)}})}).catch(u)});return w(n,t),n}function ae(e,r){var t=this;e=F(e);var o=new y(function(n,i){t.ready().then(function(){p(t._dbInfo,v,function(u,c){if(u)return i(u);try{var d=c.objectStore(t._dbInfo.storeName),l=d.delete(e);c.oncomplete=function(){n()},c.onerror=function(){i(l.error)},c.onabort=function(){var s=l.error?l.error:l.transaction.error;i(s)}}catch(s){i(s)}})}).catch(i)});return w(o,r),o}function de(e){var r=this,t=new y(function(o,n){r.ready().then(function(){p(r._dbInfo,v,function(i,u){if(i)return n(i);try{var c=u.objectStore(r._dbInfo.storeName),d=c.clear();u.oncomplete=function(){o()},u.onabort=u.onerror=function(){var l=d.error?d.error:d.transaction.error;n(l)}}catch(l){n(l)}})}).catch(n)});return w(t,e),t}function Ge(e){var r=this,t=new y(function(o,n){r.ready().then(function(){p(r._dbInfo,ee,function(i,u){if(i)return n(i);try{var c=u.objectStore(r._dbInfo.storeName),d=c.count();d.onsuccess=function(){o(d.result)},d.onerror=function(){n(d.error)}}catch(l){n(l)}})}).catch(n)});return w(t,e),t}function $e(e,r){var t=this,o=new y(function(n,i){if(e<0){n(null);return}t.ready().then(function(){p(t._dbInfo,ee,function(u,c){if(u)return i(u);try{var d=c.objectStore(t._dbInfo.storeName),l=!1,s=d.openKeyCursor();s.onsuccess=function(){var b=s.result;if(!b){n(null);return}e===0||l?n(b.key):(l=!0,b.advance(e))},s.onerror=function(){i(s.error)}}catch(b){i(b)}})}).catch(i)});return w(o,r),o}function er(e){var r=this,t=new y(function(o,n){r.ready().then(function(){p(r._dbInfo,ee,function(i,u){if(i)return n(i);try{var c=u.objectStore(r._dbInfo.storeName),d=c.openKeyCursor(),l=[];d.onsuccess=function(){var s=d.result;if(!s){o(l);return}l.push(s.key),s.continue()},d.onerror=function(){n(d.error)}}catch(s){n(s)}})}).catch(n)});return w(t,e),t}function rr(e,r){r=Z.apply(this,arguments);var t=this.config();e=typeof e!="function"&&e||{},e.name||(e.name=e.name||t.name,e.storeName=e.storeName||t.storeName);var o=this,n;if(!e.name)n=y.reject("Invalid arguments");else{var i=e.name===t.name&&o._dbInfo.db,u=i?y.resolve(o._dbInfo.db):$(e).then(function(c){var d=U[e.name],l=d.forages;d.db=c;for(var s=0;s<l.length;s++)l[s]._dbInfo.db=c;return c});e.storeName?n=u.then(function(c){if(c.objectStoreNames.contains(e.storeName)){var d=c.version+1;K(e);var l=U[e.name],s=l.forages;c.close();for(var b=0;b<s.length;b++){var S=s[b];S._dbInfo.db=null,S._dbInfo.version=d}var R=new y(function(k,W){var T=D.open(e.name,d);T.onerror=function(H){var Oe=T.result;Oe.close(),W(H)},T.onupgradeneeded=function(){var H=T.result;H.deleteObjectStore(e.storeName)},T.onsuccess=function(){var H=T.result;H.close(),k(H)}});return R.then(function(k){l.db=k;for(var W=0;W<s.length;W++){var T=s[W];T._dbInfo.db=k,X(T._dbInfo)}}).catch(function(k){throw(J(e,k)||y.resolve()).catch(function(){}),k})}}):n=u.then(function(c){K(e);var d=U[e.name],l=d.forages;c.close();for(var s=0;s<l.length;s++){var b=l[s];b._dbInfo.db=null}var S=new y(function(R,k){var W=D.deleteDatabase(e.name);W.onerror=function(){var T=W.result;T&&T.close(),k(W.error)},W.onblocked=function(){console.warn('dropInstance blocked for database "'+e.name+'" until all open connections are closed')},W.onsuccess=function(){var T=W.result;T&&T.close(),R(T)}});return S.then(function(R){d.db=R;for(var k=0;k<l.length;k++){var W=l[k];X(W._dbInfo)}}).catch(function(R){throw(J(e,R)||y.resolve()).catch(function(){}),R})})}return w(n,r),n}var tr={_driver:"asyncStorage",_initStorage:I,_support:L(),iterate:V,getItem:M,setItem:ce,removeItem:ae,clear:de,length:Ge,key:$e,keys:er,dropInstance:rr};function nr(){return typeof openDatabase=="function"}var te="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",or="~~local_forage_type~",Ae=/^~~local_forage_type~([^~]+)~/,he="__lfsc__:",be=he.length,ge="arbf",_e="blob",Be="si08",ke="ui08",xe="uic8",De="si16",Re="si32",Ce="ur16",Le="ui32",Me="fl32",Te="fl64",ze=be+ge.length,Fe=Object.prototype.toString;function Pe(e){var r=e.length*.75,t=e.length,o,n=0,i,u,c,d;e[e.length-1]==="="&&(r--,e[e.length-2]==="="&&r--);var l=new ArrayBuffer(r),s=new Uint8Array(l);for(o=0;o<t;o+=4)i=te.indexOf(e[o]),u=te.indexOf(e[o+1]),c=te.indexOf(e[o+2]),d=te.indexOf(e[o+3]),s[n++]=i<<2|u>>4,s[n++]=(u&15)<<4|c>>2,s[n++]=(c&3)<<6|d&63;return l}function we(e){var r=new Uint8Array(e),t="",o;for(o=0;o<r.length;o+=3)t+=te[r[o]>>2],t+=te[(r[o]&3)<<4|r[o+1]>>4],t+=te[(r[o+1]&15)<<2|r[o+2]>>6],t+=te[r[o+2]&63];return r.length%3===2?t=t.substring(0,t.length-1)+"=":r.length%3===1&&(t=t.substring(0,t.length-2)+"=="),t}function ir(e,r){var t="";if(e&&(t=Fe.call(e)),e&&(t==="[object ArrayBuffer]"||e.buffer&&Fe.call(e.buffer)==="[object ArrayBuffer]")){var o,n=he;e instanceof ArrayBuffer?(o=e,n+=ge):(o=e.buffer,t==="[object Int8Array]"?n+=Be:t==="[object Uint8Array]"?n+=ke:t==="[object Uint8ClampedArray]"?n+=xe:t==="[object Int16Array]"?n+=De:t==="[object Uint16Array]"?n+=Ce:t==="[object Int32Array]"?n+=Re:t==="[object Uint32Array]"?n+=Le:t==="[object Float32Array]"?n+=Me:t==="[object Float64Array]"?n+=Te:r(new Error("Failed to get type for BinaryArray"))),r(n+we(o))}else if(t==="[object Blob]"){var i=new FileReader;i.onload=function(){var u=or+e.type+"~"+we(this.result);r(he+_e+u)},i.readAsArrayBuffer(e)}else try{r(JSON.stringify(e))}catch(u){console.error("Couldn't convert value into a JSON string: ",e),r(null,u)}}function ar(e){if(e.substring(0,be)!==he)return JSON.parse(e);var r=e.substring(ze),t=e.substring(be,ze),o;if(t===_e&&Ae.test(r)){var n=r.match(Ae);o=n[1],r=r.substring(n[0].length)}var i=Pe(r);switch(t){case ge:return i;case _e:return Y([i],{type:o});case Be:return new Int8Array(i);case ke:return new Uint8Array(i);case xe:return new Uint8ClampedArray(i);case De:return new Int16Array(i);case Ce:return new Uint16Array(i);case Re:return new Int32Array(i);case Le:return new Uint32Array(i);case Me:return new Float32Array(i);case Te:return new Float64Array(i);default:throw new Error("Unkown type: "+t)}}var Ie={serialize:ir,deserialize:ar,stringToBuffer:Pe,bufferToString:we};function Ue(e,r,t,o){e.executeSql("CREATE TABLE IF NOT EXISTS "+r.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],t,o)}function ur(e){var r=this,t={db:null};if(e)for(var o in e)t[o]=typeof e[o]!="string"?e[o].toString():e[o];var n=new y(function(i,u){try{t.db=openDatabase(t.name,String(t.version),t.description,t.size)}catch(c){return u(c)}t.db.transaction(function(c){Ue(c,t,function(){r._dbInfo=t,i()},function(d,l){u(l)})},u)});return t.serializer=Ie,n}function ne(e,r,t,o,n,i){e.executeSql(t,o,n,function(u,c){c.code===c.SYNTAX_ERR?u.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[r.storeName],function(d,l){l.rows.length?i(d,c):Ue(d,r,function(){d.executeSql(t,o,n,i)},i)},i):i(u,c)},i)}function cr(e,r){var t=this;e=F(e);var o=new y(function(n,i){t.ready().then(function(){var u=t._dbInfo;u.db.transaction(function(c){ne(c,u,"SELECT * FROM "+u.storeName+" WHERE key = ? LIMIT 1",[e],function(d,l){var s=l.rows.length?l.rows.item(0).value:null;s&&(s=u.serializer.deserialize(s)),n(s)},function(d,l){i(l)})})}).catch(i)});return w(o,r),o}function fr(e,r){var t=this,o=new y(function(n,i){t.ready().then(function(){var u=t._dbInfo;u.db.transaction(function(c){ne(c,u,"SELECT * FROM "+u.storeName,[],function(d,l){for(var s=l.rows,b=s.length,S=0;S<b;S++){var R=s.item(S),k=R.value;if(k&&(k=u.serializer.deserialize(k)),k=e(k,R.key,S+1),k!==void 0){n(k);return}}n()},function(d,l){i(l)})})}).catch(i)});return w(o,r),o}function We(e,r,t,o){var n=this;e=F(e);var i=new y(function(u,c){n.ready().then(function(){r===void 0&&(r=null);var d=r,l=n._dbInfo;l.serializer.serialize(r,function(s,b){b?c(b):l.db.transaction(function(S){ne(S,l,"INSERT OR REPLACE INTO "+l.storeName+" (key, value) VALUES (?, ?)",[e,s],function(){u(d)},function(R,k){c(k)})},function(S){if(S.code===S.QUOTA_ERR){if(o>0){u(We.apply(n,[e,d,t,o-1]));return}c(S)}})})}).catch(c)});return w(i,t),i}function sr(e,r,t){return We.apply(this,[e,r,t,1])}function lr(e,r){var t=this;e=F(e);var o=new y(function(n,i){t.ready().then(function(){var u=t._dbInfo;u.db.transaction(function(c){ne(c,u,"DELETE FROM "+u.storeName+" WHERE key = ?",[e],function(){n()},function(d,l){i(l)})})}).catch(i)});return w(o,r),o}function dr(e){var r=this,t=new y(function(o,n){r.ready().then(function(){var i=r._dbInfo;i.db.transaction(function(u){ne(u,i,"DELETE FROM "+i.storeName,[],function(){o()},function(c,d){n(d)})})}).catch(n)});return w(t,e),t}function vr(e){var r=this,t=new y(function(o,n){r.ready().then(function(){var i=r._dbInfo;i.db.transaction(function(u){ne(u,i,"SELECT COUNT(key) as c FROM "+i.storeName,[],function(c,d){var l=d.rows.item(0).c;o(l)},function(c,d){n(d)})})}).catch(n)});return w(t,e),t}function hr(e,r){var t=this,o=new y(function(n,i){t.ready().then(function(){var u=t._dbInfo;u.db.transaction(function(c){ne(c,u,"SELECT key FROM "+u.storeName+" WHERE id = ? LIMIT 1",[e+1],function(d,l){var s=l.rows.length?l.rows.item(0).key:null;n(s)},function(d,l){i(l)})})}).catch(i)});return w(o,r),o}function yr(e){var r=this,t=new y(function(o,n){r.ready().then(function(){var i=r._dbInfo;i.db.transaction(function(u){ne(u,i,"SELECT key FROM "+i.storeName,[],function(c,d){for(var l=[],s=0;s<d.rows.length;s++)l.push(d.rows.item(s).key);o(l)},function(c,d){n(d)})})}).catch(n)});return w(t,e),t}function pr(e){return new y(function(r,t){e.transaction(function(o){o.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(n,i){for(var u=[],c=0;c<i.rows.length;c++)u.push(i.rows.item(c).name);r({db:e,storeNames:u})},function(n,i){t(i)})},function(o){t(o)})})}function mr(e,r){r=Z.apply(this,arguments);var t=this.config();e=typeof e!="function"&&e||{},e.name||(e.name=e.name||t.name,e.storeName=e.storeName||t.storeName);var o=this,n;return e.name?n=new y(function(i){var u;e.name===t.name?u=o._dbInfo.db:u=openDatabase(e.name,"","",0),e.storeName?i({db:u,storeNames:[e.storeName]}):i(pr(u))}).then(function(i){return new y(function(u,c){i.db.transaction(function(d){function l(R){return new y(function(k,W){d.executeSql("DROP TABLE IF EXISTS "+R,[],function(){k()},function(T,H){W(H)})})}for(var s=[],b=0,S=i.storeNames.length;b<S;b++)s.push(l(i.storeNames[b]));y.all(s).then(function(){u()}).catch(function(R){c(R)})},function(d){c(d)})})}):n=y.reject("Invalid arguments"),w(n,r),n}var br={_driver:"webSQLStorage",_initStorage:ur,_support:nr(),iterate:fr,getItem:cr,setItem:sr,removeItem:lr,clear:dr,length:vr,key:hr,keys:yr,dropInstance:mr};function gr(){try{return typeof localStorage<"u"&&"setItem"in localStorage&&!!localStorage.setItem}catch{return!1}}function qe(e,r){var t=e.name+"/";return e.storeName!==r.storeName&&(t+=e.storeName+"/"),t}function _r(){var e="_localforage_support_test";try{return localStorage.setItem(e,!0),localStorage.removeItem(e),!1}catch{return!0}}function wr(){return!_r()||localStorage.length>0}function Ir(e){var r=this,t={};if(e)for(var o in e)t[o]=e[o];return t.keyPrefix=qe(e,r._defaultConfig),wr()?(r._dbInfo=t,t.serializer=Ie,y.resolve()):y.reject()}function Er(e){var r=this,t=r.ready().then(function(){for(var o=r._dbInfo.keyPrefix,n=localStorage.length-1;n>=0;n--){var i=localStorage.key(n);i.indexOf(o)===0&&localStorage.removeItem(i)}});return w(t,e),t}function Sr(e,r){var t=this;e=F(e);var o=t.ready().then(function(){var n=t._dbInfo,i=localStorage.getItem(n.keyPrefix+e);return i&&(i=n.serializer.deserialize(i)),i});return w(o,r),o}function Or(e,r){var t=this,o=t.ready().then(function(){for(var n=t._dbInfo,i=n.keyPrefix,u=i.length,c=localStorage.length,d=1,l=0;l<c;l++){var s=localStorage.key(l);if(s.indexOf(i)===0){var b=localStorage.getItem(s);if(b&&(b=n.serializer.deserialize(b)),b=e(b,s.substring(u),d++),b!==void 0)return b}}});return w(o,r),o}function jr(e,r){var t=this,o=t.ready().then(function(){var n=t._dbInfo,i;try{i=localStorage.key(e)}catch{i=null}return i&&(i=i.substring(n.keyPrefix.length)),i});return w(o,r),o}function Nr(e){var r=this,t=r.ready().then(function(){for(var o=r._dbInfo,n=localStorage.length,i=[],u=0;u<n;u++){var c=localStorage.key(u);c.indexOf(o.keyPrefix)===0&&i.push(c.substring(o.keyPrefix.length))}return i});return w(t,e),t}function Ar(e){var r=this,t=r.keys().then(function(o){return o.length});return w(t,e),t}function Br(e,r){var t=this;e=F(e);var o=t.ready().then(function(){var n=t._dbInfo;localStorage.removeItem(n.keyPrefix+e)});return w(o,r),o}function kr(e,r,t){var o=this;e=F(e);var n=o.ready().then(function(){r===void 0&&(r=null);var i=r;return new y(function(u,c){var d=o._dbInfo;d.serializer.serialize(r,function(l,s){if(s)c(s);else try{localStorage.setItem(d.keyPrefix+e,l),u(i)}catch(b){(b.name==="QuotaExceededError"||b.name==="NS_ERROR_DOM_QUOTA_REACHED")&&c(b),c(b)}})})});return w(n,t),n}function xr(e,r){if(r=Z.apply(this,arguments),e=typeof e!="function"&&e||{},!e.name){var t=this.config();e.name=e.name||t.name,e.storeName=e.storeName||t.storeName}var o=this,n;return e.name?n=new y(function(i){e.storeName?i(qe(e,o._defaultConfig)):i(e.name+"/")}).then(function(i){for(var u=localStorage.length-1;u>=0;u--){var c=localStorage.key(u);c.indexOf(i)===0&&localStorage.removeItem(c)}}):n=y.reject("Invalid arguments"),w(n,r),n}var Dr={_driver:"localStorageWrapper",_initStorage:Ir,_support:gr(),iterate:Or,getItem:Sr,setItem:kr,removeItem:Br,clear:Er,length:Ar,key:jr,keys:Nr,dropInstance:xr},Rr=function(e,r){return e===r||typeof e=="number"&&typeof r=="number"&&isNaN(e)&&isNaN(r)},Cr=function(e,r){for(var t=e.length,o=0;o<t;){if(Rr(e[o],r))return!0;o++}return!1},Ke=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"},ve={},Ve={},fe={INDEXEDDB:tr,WEBSQL:br,LOCALSTORAGE:Dr},Lr=[fe.INDEXEDDB._driver,fe.WEBSQL._driver,fe.LOCALSTORAGE._driver],ye=["dropInstance"],Ee=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(ye),Mr={description:"",driver:Lr.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function Tr(e,r){e[r]=function(){var t=arguments;return e.ready().then(function(){return e[r].apply(e,t)})}}function Se(){for(var e=1;e<arguments.length;e++){var r=arguments[e];if(r)for(var t in r)r.hasOwnProperty(t)&&(Ke(r[t])?arguments[0][t]=r[t].slice():arguments[0][t]=r[t])}return arguments[0]}var zr=(function(){function e(r){P(this,e);for(var t in fe)if(fe.hasOwnProperty(t)){var o=fe[t],n=o._driver;this[t]=n,ve[n]||this.defineDriver(o)}this._defaultConfig=Se({},Mr),this._config=Se({},this._defaultConfig,r),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch(function(){})}return e.prototype.config=function(r){if((typeof r>"u"?"undefined":C(r))==="object"){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var t in r){if(t==="storeName"&&(r[t]=r[t].replace(/\W/g,"_")),t==="version"&&typeof r[t]!="number")return new Error("Database version must be a number.");this._config[t]=r[t]}return"driver"in r&&r.driver?this.setDriver(this._config.driver):!0}else return typeof r=="string"?this._config[r]:this._config},e.prototype.defineDriver=function(r,t,o){var n=new y(function(i,u){try{var c=r._driver,d=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!r._driver){u(d);return}for(var l=Ee.concat("_initStorage"),s=0,b=l.length;s<b;s++){var S=l[s],R=!Cr(ye,S);if((R||r[S])&&typeof r[S]!="function"){u(d);return}}var k=function(){for(var T=function(Pr){return function(){var Ur=new Error("Method "+Pr+" is not implemented by the current driver"),Xe=y.reject(Ur);return w(Xe,arguments[arguments.length-1]),Xe}},H=0,Oe=ye.length;H<Oe;H++){var je=ye[H];r[je]||(r[je]=T(je))}};k();var W=function(T){ve[c]&&console.info("Redefining LocalForage driver: "+c),ve[c]=r,Ve[c]=T,i()};"_support"in r?r._support&&typeof r._support=="function"?r._support().then(W,u):W(!!r._support):W(!0)}catch(T){u(T)}});return z(n,t,o),n},e.prototype.driver=function(){return this._driver||null},e.prototype.getDriver=function(r,t,o){var n=ve[r]?y.resolve(ve[r]):y.reject(new Error("Driver not found."));return z(n,t,o),n},e.prototype.getSerializer=function(r){var t=y.resolve(Ie);return z(t,r),t},e.prototype.ready=function(r){var t=this,o=t._driverSet.then(function(){return t._ready===null&&(t._ready=t._initDriver()),t._ready});return z(o,r,r),o},e.prototype.setDriver=function(r,t,o){var n=this;Ke(r)||(r=[r]);var i=this._getSupportedDrivers(r);function u(){n._config.driver=n.driver()}function c(s){return n._extend(s),u(),n._ready=n._initStorage(n._config),n._ready}function d(s){return function(){var b=0;function S(){for(;b<s.length;){var R=s[b];return b++,n._dbInfo=null,n._ready=null,n.getDriver(R).then(c).catch(S)}u();var k=new Error("No available storage method found.");return n._driverSet=y.reject(k),n._driverSet}return S()}}var l=this._driverSet!==null?this._driverSet.catch(function(){return y.resolve()}):y.resolve();return this._driverSet=l.then(function(){var s=i[0];return n._dbInfo=null,n._ready=null,n.getDriver(s).then(function(b){n._driver=b._driver,u(),n._wrapLibraryMethodsWithReady(),n._initDriver=d(i)})}).catch(function(){u();var s=new Error("No available storage method found.");return n._driverSet=y.reject(s),n._driverSet}),z(this._driverSet,t,o),this._driverSet},e.prototype.supports=function(r){return!!Ve[r]},e.prototype._extend=function(r){Se(this,r)},e.prototype._getSupportedDrivers=function(r){for(var t=[],o=0,n=r.length;o<n;o++){var i=r[o];this.supports(i)&&t.push(i)}return t},e.prototype._wrapLibraryMethodsWithReady=function(){for(var r=0,t=Ee.length;r<t;r++)Tr(this,Ee[r])},e.prototype.createInstance=function(r){return new e(r)},e})(),Fr=new zr;x.exports=Fr},{3:3}]},{},[4])(4)})}),et=Ze((_,O)=>{(function(m,x){typeof _=="object"&&typeof O<"u"?x(_):typeof define=="function"&&define.amd?define("localforage-driver-memory",["exports"],x):x(m.LocalforageDriverMemory={})})(typeof self<"u"?self:_,function(m){var x="localforage-driver-memory";function q(a){var f=typeof Symbol=="function"&&a[Symbol.iterator],h=0;return f?f.call(a):{next:function(){return a&&h>=a.length&&(a=void 0),{value:a&&a[h++],done:!a}}}}function C(a,f){a=a||[],f=f||{};try{return new Blob(a,f)}catch(I){if(I.name!=="TypeError")throw I;for(var h=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,p=new h,g=0;g<a.length;g+=1)p.append(a[g]);return p.getBlob(f.type)}}var P=/^~~local_forage_type~([^~]+)~/,j=9,D=j+4,L=Object.prototype.toString;function Y(a){var f=a.length*.75,h=a.length;a[a.length-1]==="="&&(f--,a[a.length-2]==="="&&f--);for(var p=new ArrayBuffer(f),g=new Uint8Array(p),I=0,M=0;I<h;I+=4){var V="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a[I]),ce="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a[I+1]),ae="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a[I+2]),de="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a[I+3]);g[M++]=V<<2|ce>>4,g[M++]=(ce&15)<<4|ae>>2,g[M++]=(ae&3)<<6|de&63}return p}function y(a){for(var f=new Uint8Array(a),h="",p=0;p<f.length;p+=3)h+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[f[p]>>2],h+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(f[p]&3)<<4|f[p+1]>>4],h+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(f[p+1]&15)<<2|f[p+2]>>6],h+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[f[p+2]&63];return f.length%3===2?h=h.substring(0,h.length-1)+"=":f.length%3===1&&(h=h.substring(0,h.length-2)+"=="),h}function w(a,f){var h="";if(a&&(h=L.call(a)),a&&(h==="[object ArrayBuffer]"||a.buffer&&L.call(a.buffer)==="[object ArrayBuffer]")){var p=void 0,g="__lfsc__:";a instanceof ArrayBuffer?(p=a,g+="arbf"):(p=a.buffer,h==="[object Int8Array]"?g+="si08":h==="[object Uint8Array]"?g+="ui08":h==="[object Uint8ClampedArray]"?g+="uic8":h==="[object Int16Array]"?g+="si16":h==="[object Uint16Array]"?g+="ur16":h==="[object Int32Array]"?g+="si32":h==="[object Uint32Array]"?g+="ui32":h==="[object Float32Array]"?g+="fl32":h==="[object Float64Array]"?g+="fl64":f(new Error("Failed to get type for BinaryArray"))),f(g+y(p))}else if(h==="[object Blob]"){var I=new FileReader;I.onload=function(){var M="~~local_forage_type~"+a.type+"~"+y(this.result);f("__lfsc__:blob"+M)},I.readAsArrayBuffer(a)}else try{f(JSON.stringify(a))}catch(M){console.error("Couldn't convert value into a JSON string: ",a),f(null,M)}}function z(a){if(a.substring(0,j)!=="__lfsc__:")return JSON.parse(a);var f=a.substring(D),h=a.substring(j,D),p;if(h==="blob"&&P.test(f)){var g=f.match(P);p=g[1],f=f.substring(g[0].length)}var I=Y(f);switch(h){case"arbf":return I;case"blob":return C([I],{type:p});case"si08":return new Int8Array(I);case"ui08":return new Uint8Array(I);case"uic8":return new Uint8ClampedArray(I);case"si16":return new Int16Array(I);case"ur16":return new Uint16Array(I);case"si32":return new Int32Array(I);case"ui32":return new Uint32Array(I);case"fl32":return new Float32Array(I);case"fl64":return new Float64Array(I);default:throw new Error("Unkown type: "+h)}}function F(a){var f,h;if(a===null||typeof a!="object"||"isActiveClone"in a)return a;var p=a instanceof Date?new Date(a):a.constructor();try{for(var g=q(Object.keys(a)),I=g.next();!I.done;I=g.next()){var M=I.value;Object.prototype.hasOwnProperty.call(a,M)&&(a.isActiveClone=null,p[M]=F(a[M]),delete a.isActiveClone)}}catch(V){f={error:V}}finally{try{I&&!I.done&&(h=g.return)&&h.call(g)}finally{if(f)throw f.error}}return p}function Z(a,f){return(a.name||f.name)+"/"+(a.storeName||f.storeName)+"/"}function A(a,f){f&&a.then(function(h){f(null,h)},function(h){f(h)})}function G(){for(var a=[],f=0;f<arguments.length;f++)a[f]=arguments[f];if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}function U(a,f){var h=this;if(f=G.apply(this,arguments),a=typeof a!="function"&&a||{},!a.name){var p=this.config();a.name=a.name||p.name,a.storeName=a.storeName||p.storeName}var g;return a.name?g=new Promise(function(I){a.storeName?I(Z(a,h._defaultConfig)):I(a.name+"/")}):g=Promise.reject("Invalid arguments"),{promise:g,callback:f}}function oe(a){return typeof a!="string"&&(console.warn(a+" used as a key, but it is not a string."),a=String(a)),a}var ee={bufferToString:y,deserialize:z,serialize:w,stringToBuffer:Y},v={},N=(function(){function a(f){this.kp=f,this.data={}}return a.resolve=function(f){return v[f]||(v[f]=new a(f)),v[f]},a.prototype.clear=function(){this.data={}},a.prototype.drop=function(){this.clear(),delete v[this.kp]},a.prototype.get=function(f){return this.data[f]},a.prototype.key=function(f){return this.keys()[f]},a.prototype.keys=function(){return Object.keys(this.data)},a.prototype.rm=function(f){delete this.data[f]},a.prototype.set=function(f,h){this.data[f]=h},a})();function E(a){var f=a?F(a):{},h=Z(f,this._defaultConfig),p=N.resolve(h);return this._dbInfo=f,this._dbInfo.serializer=ee,this._dbInfo.keyPrefix=h,this._dbInfo.mStore=p,Promise.resolve()}function B(a){var f=this,h=this.ready().then(function(){f._dbInfo.mStore.clear()});return A(h,a),h}function K(a,f){var h=U.apply(this,arguments),p=h.promise,g=h.callback,I=p.then(function(M){N.resolve(M).drop()});return A(I,g),p}function X(a,f){var h=this;a=oe(a);var p=this.ready().then(function(){var g=h._dbInfo.mStore.get(a);return g==null?null:h._dbInfo.serializer.deserialize(g)});return A(p,f),p}function J(a,f){var h=this,p=this.ready().then(function(){for(var g=h._dbInfo.mStore,I=g.keys(),M=0;M<I.length;M++){var V=g.get(I[M]);if(V&&(V=h._dbInfo.serializer.deserialize(V)),V=a(V,I[M],M+1),V!==void 0)return V}});return A(p,f),p}function Q(a,f){var h=this,p=this.ready().then(function(){var g;try{g=h._dbInfo.mStore.key(a),g===void 0&&(g=null)}catch{g=null}return g});return A(p,f),p}function $(a){var f=this,h=this.ready().then(function(){return f._dbInfo.mStore.keys()});return A(h,a),h}function ie(a){var f=this.keys().then(function(h){return h.length});return A(f,a),f}function ue(a,f){var h=this;a=oe(a);var p=this.ready().then(function(){h._dbInfo.mStore.rm(a)});return A(p,f),p}function le(a,f,h){var p=this;a=oe(a);var g=this.ready().then(function(){f===void 0&&(f=null);var I=f;return new Promise(function(M,V){p._dbInfo.serializer.serialize(f,function(ce,ae){if(ae)V(ae);else try{p._dbInfo.mStore.set(a,ce),M(I)}catch(de){V(de)}})})});return A(g,h),g}var re=!0;m._support=re,m._driver=x,m._initStorage=E,m.clear=B,m.dropInstance=K,m.getItem=X,m.iterate=J,m.key=Q,m.keys=$,m.length=ie,m.removeItem=ue,m.setItem=le,Object.defineProperty(m,"__esModule",{value:!0})})}),Ne=He($r()),Je=He(et()),rt={display:"none",position:"fixed",top:"0",right:"0",width:"100%",height:"100%",borderRadius:"0",border:"none",zIndex:"2147483647"};function tt(_){for(let[O,m]of Object.entries(rt))_.style[O]=m}function nt(_){return!![].slice.call(document.querySelectorAll(".magic-iframe")).find(m=>m.src.includes(_))}var ot=class extends Kr{constructor(){super(...arguments),this.activeElement=null}init(){this.test="hello",this.iframe=new Promise(_=>{let O=()=>{if(nt(encodeURIComponent(this.parameters)))Xr().log();else{let m=document.createElement("iframe");m.classList.add("magic-iframe"),m.dataset.magicIframeLabel=Ye(this.endpoint).host,m.title="Secure Modal",m.src=Ye(`/send?params=${encodeURIComponent(this.parameters)}`,this.endpoint).href,tt(m),document.body.appendChild(m),_(m)}};["loaded","interactive","complete"].includes(document.readyState)?O():window.addEventListener("load",O,!1)}),window.addEventListener("message",_=>{var O;if(_.origin===this.endpoint&&_.data&&_.data.msgType&&this.messageHandlers.size){_.data.response=(O=_.data.response)!=null?O:{};for(let m of this.messageHandlers.values())m(_)}})}showOverlay(){return me(this,null,function*(){let _=yield this.iframe;_.style.display="block",this.activeElement=document.activeElement,_.focus()})}hideOverlay(){return me(this,null,function*(){var _;let O=yield this.iframe;O.style.display="none",(_=this.activeElement)!=null&&_.focus&&this.activeElement.focus(),this.activeElement=null})}_post(_){return me(this,null,function*(){let O=yield this.iframe;if(O&&O.contentWindow)O.contentWindow.postMessage(_,this.endpoint);else throw Vr()})}},ft=Wr(qr,{platform:"web",sdkName:"magic-sdk",version:"27.0.0",defaultEndpoint:"https://auth.magic.link/",ViewController:ot,configureStorage:()=>me(void 0,null,function*(){let _=Ne.default.createInstance({name:"MagicAuthLocalStorageDB",storeName:"MagicAuthLocalStorage"});return yield _.defineDriver(Je),yield _.setDriver([Ne.default.INDEXEDDB,Ne.default.LOCALSTORAGE,Je._driver]),_})});export{dt as DeepLinkPage,vt as DeviceVerificationEventEmit,ht as DeviceVerificationEventOnReceived,yt as EthChainType,pt as Events,mt as Extension,bt as ExtensionError,gt as ExtensionWarning,_t as LoginWithEmailOTPEventEmit,wt as LoginWithEmailOTPEventOnReceived,It as LoginWithMagicLinkEventEmit,Et as LoginWithMagicLinkEventOnReceived,ft as Magic,St as MagicIncomingWindowMessage,Ot as MagicOutgoingWindowMessage,jt as MagicPayloadMethod,Nt as RPCError,At as RPCErrorCode,Bt as RecencyCheckEventEmit,kt as RecencyCheckEventOnReceived,xt as RecoveryMethodType,Dt as SDKError,Rt as SDKErrorCode,Ct as SDKWarning,Lt as SDKWarningCode,Mt as UpdateEmailEventEmit,Tt as UpdateEmailEventOnReceived,zt as Wallets,Ft as isPromiEvent};