Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@magic-sdk/provider

Package Overview
Dependencies
Maintainers
19
Versions
711
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@magic-sdk/provider - npm Package Compare versions

Comparing version 28.15.0 to 28.16.0-canary.826.11522534563.0

4

./dist/cjs/index.js

@@ -1,6 +0,6 @@

"use strict";var Jt=Object.create;var re=Object.defineProperty,Gt=Object.defineProperties,Kt=Object.getOwnPropertyDescriptor,jt=Object.getOwnPropertyDescriptors,Bt=Object.getOwnPropertyNames,at=Object.getOwnPropertySymbols,Vt=Object.getPrototypeOf,lt=Object.prototype.hasOwnProperty,Ht=Object.prototype.propertyIsEnumerable;var ct=(n,t,e)=>t in n?re(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,V=(n,t)=>{for(var e in t||(t={}))lt.call(t,e)&&ct(n,e,t[e]);if(at)for(var e of at(t))Ht.call(t,e)&&ct(n,e,t[e]);return n},H=(n,t)=>Gt(n,jt(t));var Xt=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports),dt=(n,t)=>{for(var e in t)re(n,e,{get:t[e],enumerable:!0})},ut=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Bt(t))!lt.call(n,o)&&o!==e&&re(n,o,{get:()=>t[o],enumerable:!(r=Kt(t,o))||r.enumerable});return n};var zt=(n,t,e)=>(e=n!=null?Jt(Vt(n)):{},ut(t||!n||!n.__esModule?re(e,"default",{value:n,enumerable:!0}):e,n)),Yt=n=>ut(re({},"__esModule",{value:!0}),n);var E=(n,t,e)=>new Promise((r,o)=>{var s=c=>{try{a(e.next(c))}catch(l){o(l)}},i=c=>{try{a(e.throw(c))}catch(l){o(l)}},a=c=>c.done?r(c.value):Promise.resolve(c.value).then(s,i);a((e=e.apply(n,t)).next())});var At=Xt(($r,Xe)=>{"use strict";var Bn=Object.prototype.hasOwnProperty,M="~";function ce(){}Object.create&&(ce.prototype=Object.create(null),new ce().__proto__||(M=!1));function Vn(n,t,e){this.fn=n,this.context=t,this.once=e||!1}function Ct(n,t,e,r,o){if(typeof e!="function")throw new TypeError("The listener must be a function");var s=new Vn(e,r||n,o),i=M?M+t:t;return n._events[i]?n._events[i].fn?n._events[i]=[n._events[i],s]:n._events[i].push(s):(n._events[i]=s,n._eventsCount++),n}function ve(n,t){--n._eventsCount===0?n._events=new ce:delete n._events[t]}function w(){this._events=new ce,this._eventsCount=0}w.prototype.eventNames=function(){var t=[],e,r;if(this._eventsCount===0)return t;for(r in e=this._events)Bn.call(e,r)&&t.push(M?r.slice(1):r);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(e)):t};w.prototype.listeners=function(t){var e=M?M+t:t,r=this._events[e];if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,i=new Array(s);o<s;o++)i[o]=r[o].fn;return i};w.prototype.listenerCount=function(t){var e=M?M+t:t,r=this._events[e];return r?r.fn?1:r.length:0};w.prototype.emit=function(t,e,r,o,s,i){var a=M?M+t:t;if(!this._events[a])return!1;var c=this._events[a],l=arguments.length,d,m;if(c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,e),!0;case 3:return c.fn.call(c.context,e,r),!0;case 4:return c.fn.call(c.context,e,r,o),!0;case 5:return c.fn.call(c.context,e,r,o,s),!0;case 6:return c.fn.call(c.context,e,r,o,s,i),!0}for(m=1,d=new Array(l-1);m<l;m++)d[m-1]=arguments[m];c.fn.apply(c.context,d)}else{var A=c.length,I;for(m=0;m<A;m++)switch(c[m].once&&this.removeListener(t,c[m].fn,void 0,!0),l){case 1:c[m].fn.call(c[m].context);break;case 2:c[m].fn.call(c[m].context,e);break;case 3:c[m].fn.call(c[m].context,e,r);break;case 4:c[m].fn.call(c[m].context,e,r,o);break;default:if(!d)for(I=1,d=new Array(l-1);I<l;I++)d[I-1]=arguments[I];c[m].fn.apply(c[m].context,d)}}return!0};w.prototype.on=function(t,e,r){return Ct(this,t,e,r,!1)};w.prototype.once=function(t,e,r){return Ct(this,t,e,r,!0)};w.prototype.removeListener=function(t,e,r,o){var s=M?M+t:t;if(!this._events[s])return this;if(!e)return ve(this,s),this;var i=this._events[s];if(i.fn)i.fn===e&&(!o||i.once)&&(!r||i.context===r)&&ve(this,s);else{for(var a=0,c=[],l=i.length;a<l;a++)(i[a].fn!==e||o&&!i[a].once||r&&i[a].context!==r)&&c.push(i[a]);c.length?this._events[s]=c.length===1?c[0]:c:ve(this,s)}return this};w.prototype.removeAllListeners=function(t){var e;return t?(e=M?M+t:t,this._events[e]&&ve(this,e)):(this._events=new ce,this._eventsCount=0),this};w.prototype.off=w.prototype.removeListener;w.prototype.addListener=w.prototype.on;w.prefixed=M;w.EventEmitter=w;typeof Xe<"u"&&(Xe.exports=w)});var Er={};dt(Er,{Extension:()=>_,MagicExtensionError:()=>K,MagicExtensionWarning:()=>Y,MagicRPCError:()=>L,MagicSDKError:()=>$,MagicSDKWarning:()=>D,SDKBase:()=>pe,STORE_KEY_PRIVATE_KEY:()=>Me,STORE_KEY_PUBLIC_JWK:()=>de,TypedEmitter:()=>Te,ViewController:()=>_e,clearKeys:()=>er,createDeprecationWarning:()=>U,createDuplicateIframeWarning:()=>Jn,createExtensionNotInitializedError:()=>Ke,createIncompatibleExtensionsError:()=>je,createInvalidArgumentError:()=>Be,createJwt:()=>et,createMalformedResponseError:()=>Ge,createMissingApiKeyError:()=>We,createModalNotReadyError:()=>Je,createPromiEvent:()=>O,createPromise:()=>be,createReactNativeEndpointConfigurationWarning:()=>He,createSDK:()=>wt,createSynchronousWeb3MethodWarning:()=>Ve,createTypedEmitter:()=>le,createURL:()=>xe,decodeJSON:()=>De,encodeJSON:()=>ae,getPayloadId:()=>Re,isEmpty:()=>z,isJsonRpcErrorCode:()=>Fe,isJsonRpcRequestPayload:()=>Fn,isJsonRpcResponsePayload:()=>Ue,isMagicPayloadMethod:()=>Wn,isMajorVersionAtLeast:()=>Ye,isPromiEvent:()=>ze,isWebCryptoSupported:()=>ee,storage:()=>Z,uuid:()=>Ze});module.exports=Yt(Er);function Qt(n){let t={exports:{}};return n(t,t.exports),t.exports}var Zt=Number.MAX_SAFE_INTEGER||9007199254740991;var qe={SEMVER_SPEC_VERSION:"2.0.0",MAX_LENGTH:256,MAX_SAFE_INTEGER:Zt,MAX_SAFE_COMPONENT_LENGTH:16},en=typeof process=="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...n)=>console.error("SEMVER",...n):()=>{},g=en,ie=Qt(function(n,t){let{MAX_SAFE_COMPONENT_LENGTH:e}=qe,r=(t=n.exports={}).re=[],o=t.src=[],s=t.t={},i=0,a=(c,l,d)=>{let m=i++;g(m,l),s[c]=m,o[m]=l,r[m]=new RegExp(l,d?"g":void 0)};a("NUMERICIDENTIFIER","0|[1-9]\\d*"),a("NUMERICIDENTIFIERLOOSE","[0-9]+"),a("NONNUMERICIDENTIFIER","\\d*[a-zA-Z-][a-zA-Z0-9-]*"),a("MAINVERSION",`(${o[s.NUMERICIDENTIFIER]})\\.(${o[s.NUMERICIDENTIFIER]})\\.(${o[s.NUMERICIDENTIFIER]})`),a("MAINVERSIONLOOSE",`(${o[s.NUMERICIDENTIFIERLOOSE]})\\.(${o[s.NUMERICIDENTIFIERLOOSE]})\\.(${o[s.NUMERICIDENTIFIERLOOSE]})`),a("PRERELEASEIDENTIFIER",`(?:${o[s.NUMERICIDENTIFIER]}|${o[s.NONNUMERICIDENTIFIER]})`),a("PRERELEASEIDENTIFIERLOOSE",`(?:${o[s.NUMERICIDENTIFIERLOOSE]}|${o[s.NONNUMERICIDENTIFIER]})`),a("PRERELEASE",`(?:-(${o[s.PRERELEASEIDENTIFIER]}(?:\\.${o[s.PRERELEASEIDENTIFIER]})*))`),a("PRERELEASELOOSE",`(?:-?(${o[s.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${o[s.PRERELEASEIDENTIFIERLOOSE]})*))`),a("BUILDIDENTIFIER","[0-9A-Za-z-]+"),a("BUILD",`(?:\\+(${o[s.BUILDIDENTIFIER]}(?:\\.${o[s.BUILDIDENTIFIER]})*))`),a("FULLPLAIN",`v?${o[s.MAINVERSION]}${o[s.PRERELEASE]}?${o[s.BUILD]}?`),a("FULL",`^${o[s.FULLPLAIN]}$`),a("LOOSEPLAIN",`[v=\\s]*${o[s.MAINVERSIONLOOSE]}${o[s.PRERELEASELOOSE]}?${o[s.BUILD]}?`),a("LOOSE",`^${o[s.LOOSEPLAIN]}$`),a("GTLT","((?:<|>)?=?)"),a("XRANGEIDENTIFIERLOOSE",`${o[s.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),a("XRANGEIDENTIFIER",`${o[s.NUMERICIDENTIFIER]}|x|X|\\*`),a("XRANGEPLAIN",`[v=\\s]*(${o[s.XRANGEIDENTIFIER]})(?:\\.(${o[s.XRANGEIDENTIFIER]})(?:\\.(${o[s.XRANGEIDENTIFIER]})(?:${o[s.PRERELEASE]})?${o[s.BUILD]}?)?)?`),a("XRANGEPLAINLOOSE",`[v=\\s]*(${o[s.XRANGEIDENTIFIERLOOSE]})(?:\\.(${o[s.XRANGEIDENTIFIERLOOSE]})(?:\\.(${o[s.XRANGEIDENTIFIERLOOSE]})(?:${o[s.PRERELEASELOOSE]})?${o[s.BUILD]}?)?)?`),a("XRANGE",`^${o[s.GTLT]}\\s*${o[s.XRANGEPLAIN]}$`),a("XRANGELOOSE",`^${o[s.GTLT]}\\s*${o[s.XRANGEPLAINLOOSE]}$`),a("COERCE",`(^|[^\\d])(\\d{1,${e}})(?:\\.(\\d{1,${e}}))?(?:\\.(\\d{1,${e}}))?(?:$|[^\\d])`),a("COERCERTL",o[s.COERCE],!0),a("LONETILDE","(?:~>?)"),a("TILDETRIM",`(\\s*)${o[s.LONETILDE]}\\s+`,!0),t.tildeTrimReplace="$1~",a("TILDE",`^${o[s.LONETILDE]}${o[s.XRANGEPLAIN]}$`),a("TILDELOOSE",`^${o[s.LONETILDE]}${o[s.XRANGEPLAINLOOSE]}$`),a("LONECARET","(?:\\^)"),a("CARETTRIM",`(\\s*)${o[s.LONECARET]}\\s+`,!0),t.caretTrimReplace="$1^",a("CARET",`^${o[s.LONECARET]}${o[s.XRANGEPLAIN]}$`),a("CARETLOOSE",`^${o[s.LONECARET]}${o[s.XRANGEPLAINLOOSE]}$`),a("COMPARATORLOOSE",`^${o[s.GTLT]}\\s*(${o[s.LOOSEPLAIN]})$|^$`),a("COMPARATOR",`^${o[s.GTLT]}\\s*(${o[s.FULLPLAIN]})$|^$`),a("COMPARATORTRIM",`(\\s*)${o[s.GTLT]}\\s*(${o[s.LOOSEPLAIN]}|${o[s.XRANGEPLAIN]})`,!0),t.comparatorTrimReplace="$1$2$3",a("HYPHENRANGE",`^\\s*(${o[s.XRANGEPLAIN]})\\s+-\\s+(${o[s.XRANGEPLAIN]})\\s*$`),a("HYPHENRANGELOOSE",`^\\s*(${o[s.XRANGEPLAINLOOSE]})\\s+-\\s+(${o[s.XRANGEPLAINLOOSE]})\\s*$`),a("STAR","(<|>)?=?\\s*\\*"),a("GTE0","^\\s*>=\\s*0.0.0\\s*$"),a("GTE0PRE","^\\s*>=\\s*0.0.0-0\\s*$")}),pt=/^[0-9]+$/,Tt=(n,t)=>{let e=pt.test(n),r=pt.test(t);return e&&r&&(n=+n,t=+t),n===t?0:e&&!r?-1:r&&!e?1:n<t?-1:1},tn=(n,t)=>Tt(t,n),nn={compareIdentifiers:Tt,rcompareIdentifiers:tn},{MAX_LENGTH:ht,MAX_SAFE_INTEGER:me}=qe,{re:mt,t:ft}=ie,{compareIdentifiers:se}=nn,R=class{constructor(t,e){if(e&&typeof e=="object"||(e={loose:!!e,includePrerelease:!1}),t instanceof R){if(t.loose===!!e.loose&&t.includePrerelease===!!e.includePrerelease)return t;t=t.version}else if(typeof t!="string")throw new TypeError(`Invalid Version: ${t}`);if(t.length>ht)throw new TypeError(`version is longer than ${ht} characters`);g("SemVer",t,e),this.options=e,this.loose=!!e.loose,this.includePrerelease=!!e.includePrerelease;let r=t.trim().match(e.loose?mt[ft.LOOSE]:mt[ft.FULL]);if(!r)throw new TypeError(`Invalid Version: ${t}`);if(this.raw=t,this.major=+r[1],this.minor=+r[2],this.patch=+r[3],this.major>me||this.major<0)throw new TypeError("Invalid major version");if(this.minor>me||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>me||this.patch<0)throw new TypeError("Invalid patch version");r[4]?this.prerelease=r[4].split(".").map(o=>{if(/^[0-9]+$/.test(o)){let s=+o;if(s>=0&&s<me)return s}return o}):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(t){if(g("SemVer.compare",this.version,this.options,t),!(t instanceof R)){if(typeof t=="string"&&t===this.version)return 0;t=new R(t,this.options)}return t.version===this.version?0:this.compareMain(t)||this.comparePre(t)}compareMain(t){return t instanceof R||(t=new R(t,this.options)),se(this.major,t.major)||se(this.minor,t.minor)||se(this.patch,t.patch)}comparePre(t){if(t instanceof R||(t=new R(t,this.options)),this.prerelease.length&&!t.prerelease.length)return-1;if(!this.prerelease.length&&t.prerelease.length)return 1;if(!this.prerelease.length&&!t.prerelease.length)return 0;let e=0;do{let r=this.prerelease[e],o=t.prerelease[e];if(g("prerelease compare",e,r,o),r===void 0&&o===void 0)return 0;if(o===void 0)return 1;if(r===void 0)return-1;if(r!==o)return se(r,o)}while(++e)}compareBuild(t){t instanceof R||(t=new R(t,this.options));let e=0;do{let r=this.build[e],o=t.build[e];if(g("prerelease compare",e,r,o),r===void 0&&o===void 0)return 0;if(o===void 0)return 1;if(r===void 0)return-1;if(r!==o)return se(r,o)}while(++e)}inc(t,e){switch(t){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",e);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",e);break;case"prepatch":this.prerelease.length=0,this.inc("patch",e),this.inc("pre",e);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",e),this.inc("pre",e);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)}e&&(this.prerelease[0]===e?isNaN(this.prerelease[1])&&(this.prerelease=[e,0]):this.prerelease=[e,0]);break;default:throw new Error(`invalid increment argument: ${t}`)}return this.format(),this.raw=this.version,this}},rn=(n,t,e)=>new R(n,e).compare(new R(t,e)),X=rn,sn=(n,t,e)=>X(n,t,e)===0,on=sn,an=(n,t,e)=>X(n,t,e)!==0,cn=an,ln=(n,t,e)=>X(n,t,e)>0,dn=ln,un=(n,t,e)=>X(n,t,e)>=0,pn=un,hn=(n,t,e)=>X(n,t,e)<0,mn=hn,fn=(n,t,e)=>X(n,t,e)<=0,En=fn,gn=(n,t,e,r)=>{switch(t){case"===":return typeof n=="object"&&(n=n.version),typeof e=="object"&&(e=e.version),n===e;case"!==":return typeof n=="object"&&(n=n.version),typeof e=="object"&&(e=e.version),n!==e;case"":case"=":case"==":return on(n,e,r);case"!=":return cn(n,e,r);case">":return dn(n,e,r);case">=":return pn(n,e,r);case"<":return mn(n,e,r);case"<=":return En(n,e,r);default:throw new TypeError(`Invalid operator: ${t}`)}},ke=gn,oe=Symbol("SemVer ANY"),F=class{static get ANY(){return oe}constructor(t,e){if(e&&typeof e=="object"||(e={loose:!!e,includePrerelease:!1}),t instanceof F){if(t.loose===!!e.loose)return t;t=t.value}g("comparator",t,e),this.options=e,this.loose=!!e.loose,this.parse(t),this.semver===oe?this.value="":this.value=this.operator+this.semver.version,g("comp",this)}parse(t){let e=this.options.loose?Et[gt.COMPARATORLOOSE]:Et[gt.COMPARATOR],r=t.match(e);if(!r)throw new TypeError(`Invalid comparator: ${t}`);this.operator=r[1]!==void 0?r[1]:"",this.operator==="="&&(this.operator=""),r[2]?this.semver=new R(r[2],this.options.loose):this.semver=oe}toString(){return this.value}test(t){if(g("Comparator.test",t,this.options.loose),this.semver===oe||t===oe)return!0;if(typeof t=="string")try{t=new R(t,this.options)}catch(e){return!1}return ke(t,this.operator,this.semver,this.options)}intersects(t,e){if(!(t instanceof F))throw new TypeError("a Comparator is required");if(e&&typeof e=="object"||(e={loose:!!e,includePrerelease:!1}),this.operator==="")return this.value===""||new k(t.value,e).test(this.value);if(t.operator==="")return t.value===""||new k(this.value,e).test(t.semver);let r=!(this.operator!==">="&&this.operator!==">"||t.operator!==">="&&t.operator!==">"),o=!(this.operator!=="<="&&this.operator!=="<"||t.operator!=="<="&&t.operator!=="<"),s=this.semver.version===t.semver.version,i=!(this.operator!==">="&&this.operator!=="<="||t.operator!==">="&&t.operator!=="<="),a=ke(this.semver,"<",t.semver,e)&&(this.operator===">="||this.operator===">")&&(t.operator==="<="||t.operator==="<"),c=ke(this.semver,">",t.semver,e)&&(this.operator==="<="||this.operator==="<")&&(t.operator===">="||t.operator===">");return r||o||s&&i||a||c}},{re:Et,t:gt}=ie,k=class{constructor(t,e){if(e&&typeof e=="object"||(e={loose:!!e,includePrerelease:!1}),t instanceof k)return t.loose===!!e.loose&&t.includePrerelease===!!e.includePrerelease?t:new k(t.raw,e);if(t instanceof F)return this.raw=t.value,this.set=[[t]],this.format(),this;if(this.options=e,this.loose=!!e.loose,this.includePrerelease=!!e.includePrerelease,this.raw=t,this.set=t.split(/\s*\|\|\s*/).map(r=>this.parseRange(r.trim())).filter(r=>r.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${t}`);this.format()}format(){return this.range=this.set.map(t=>t.join(" ").trim()).join("||").trim(),this.range}toString(){return this.range}parseRange(t){let{loose:e}=this.options;t=t.trim();let r=e?b[T.HYPHENRANGELOOSE]:b[T.HYPHENRANGE];t=t.replace(r,Nn(this.options.includePrerelease)),g("hyphen replace",t),t=t.replace(b[T.COMPARATORTRIM],yn),g("comparator trim",t,b[T.COMPARATORTRIM]),t=(t=(t=t.replace(b[T.TILDETRIM],Rn)).replace(b[T.CARETTRIM],vn)).split(/\s+/).join(" ");let o=e?b[T.COMPARATORLOOSE]:b[T.COMPARATOR];return t.split(" ").map(s=>Tn(s,this.options)).join(" ").split(/\s+/).map(s=>An(s,this.options)).filter(this.options.loose?s=>!!s.match(o):()=>!0).map(s=>new F(s,this.options))}intersects(t,e){if(!(t instanceof k))throw new TypeError("a Range is required");return this.set.some(r=>yt(r,e)&&t.set.some(o=>yt(o,e)&&r.every(s=>o.every(i=>s.intersects(i,e)))))}test(t){if(!t)return!1;if(typeof t=="string")try{t=new R(t,this.options)}catch(e){return!1}for(let e=0;e<this.set.length;e++)if(Sn(this.set[e],t,this.options))return!0;return!1}},{re:b,t:T,comparatorTrimReplace:yn,tildeTrimReplace:Rn,caretTrimReplace:vn}=ie,yt=(n,t)=>{let e=!0,r=n.slice(),o=r.pop();for(;e&&r.length;)e=r.every(s=>o.intersects(s,t)),o=r.pop();return e},Tn=(n,t)=>(g("comp",n,t),n=wn(n,t),g("caret",n),n=In(n,t),g("tildes",n),n=Mn(n,t),g("xrange",n),n=Cn(n,t),g("stars",n),n),P=n=>!n||n.toLowerCase()==="x"||n==="*",In=(n,t)=>n.trim().split(/\s+/).map(e=>bn(e,t)).join(" "),bn=(n,t)=>{let e=t.loose?b[T.TILDELOOSE]:b[T.TILDE];return n.replace(e,(r,o,s,i,a)=>{let c;return g("tilde",n,r,o,s,i,a),P(o)?c="":P(s)?c=`>=${o}.0.0 <${+o+1}.0.0-0`:P(i)?c=`>=${o}.${s}.0 <${o}.${+s+1}.0-0`:a?(g("replaceTilde pr",a),c=`>=${o}.${s}.${i}-${a} <${o}.${+s+1}.0-0`):c=`>=${o}.${s}.${i} <${o}.${+s+1}.0-0`,g("tilde return",c),c})},wn=(n,t)=>n.trim().split(/\s+/).map(e=>Pn(e,t)).join(" "),Pn=(n,t)=>{g("caret",n,t);let e=t.loose?b[T.CARETLOOSE]:b[T.CARET],r=t.includePrerelease?"-0":"";return n.replace(e,(o,s,i,a,c)=>{let l;return g("caret",n,o,s,i,a,c),P(s)?l="":P(i)?l=`>=${s}.0.0${r} <${+s+1}.0.0-0`:P(a)?l=s==="0"?`>=${s}.${i}.0${r} <${s}.${+i+1}.0-0`:`>=${s}.${i}.0${r} <${+s+1}.0.0-0`:c?(g("replaceCaret pr",c),l=s==="0"?i==="0"?`>=${s}.${i}.${a}-${c} <${s}.${i}.${+a+1}-0`:`>=${s}.${i}.${a}-${c} <${s}.${+i+1}.0-0`:`>=${s}.${i}.${a}-${c} <${+s+1}.0.0-0`):(g("no pr"),l=s==="0"?i==="0"?`>=${s}.${i}.${a}${r} <${s}.${i}.${+a+1}-0`:`>=${s}.${i}.${a}${r} <${s}.${+i+1}.0-0`:`>=${s}.${i}.${a} <${+s+1}.0.0-0`),g("caret return",l),l})},Mn=(n,t)=>(g("replaceXRanges",n,t),n.split(/\s+/).map(e=>xn(e,t)).join(" ")),xn=(n,t)=>{n=n.trim();let e=t.loose?b[T.XRANGELOOSE]:b[T.XRANGE];return n.replace(e,(r,o,s,i,a,c)=>{g("xRange",n,r,o,s,i,a,c);let l=P(s),d=l||P(i),m=d||P(a),A=m;return o==="="&&A&&(o=""),c=t.includePrerelease?"-0":"",l?r=o===">"||o==="<"?"<0.0.0-0":"*":o&&A?(d&&(i=0),a=0,o===">"?(o=">=",d?(s=+s+1,i=0,a=0):(i=+i+1,a=0)):o==="<="&&(o="<",d?s=+s+1:i=+i+1),o==="<"&&(c="-0"),r=`${o+s}.${i}.${a}${c}`):d?r=`>=${s}.0.0${c} <${+s+1}.0.0-0`:m&&(r=`>=${s}.${i}.0${c} <${s}.${+i+1}.0-0`),g("xRange return",r),r})},Cn=(n,t)=>(g("replaceStars",n,t),n.trim().replace(b[T.STAR],"")),An=(n,t)=>(g("replaceGTE0",n,t),n.trim().replace(b[t.includePrerelease?T.GTE0PRE:T.GTE0],"")),Nn=n=>(t,e,r,o,s,i,a,c,l,d,m,A,I)=>`${e=P(r)?"":P(o)?`>=${r}.0.0${n?"-0":""}`:P(s)?`>=${r}.${o}.0${n?"-0":""}`:i?`>=${e}`:`>=${e}${n?"-0":""}`} ${c=P(l)?"":P(d)?`<${+l+1}.0.0-0`:P(m)?`<${l}.${+d+1}.0-0`:A?`<=${l}.${d}.${m}-${A}`:n?`<${l}.${d}.${+m+1}-0`:`<=${c}`}`.trim(),Sn=(n,t,e)=>{for(let r=0;r<n.length;r++)if(!n[r].test(t))return!1;if(t.prerelease.length&&!e.includePrerelease){for(let r=0;r<n.length;r++)if(g(n[r].semver),n[r].semver!==F.ANY&&n[r].semver.prerelease.length>0){let o=n[r].semver;if(o.major===t.major&&o.minor===t.minor&&o.patch===t.patch)return!0}return!1}return!0},It=(n,t,e)=>{try{t=new k(t,e)}catch(r){return!1}return t.test(n)};var{MAX_LENGTH:$n}=qe,{re:Rt,t:vt}=ie,Ln=(n,t)=>{if(t&&typeof t=="object"||(t={loose:!!t,includePrerelease:!1}),n instanceof R)return n;if(typeof n!="string"||n.length>$n||!(t.loose?Rt[vt.LOOSE]:Rt[vt.FULL]).test(n))return null;try{return new R(n,t)}catch(e){return null}},On=Ln,{re:fe,t:Ee}=ie,bt=(n,t)=>{if(n instanceof R)return n;if(typeof n=="number"&&(n=String(n)),typeof n!="string")return null;let e=null;if((t=t||{}).rtl){let r;for(;(r=fe[Ee.COERCERTL].exec(n))&&(!e||e.index+e[0].length!==n.length);)e&&r.index+r[0].length===e.index+e[0].length||(e=r),fe[Ee.COERCERTL].lastIndex=r.index+r[1].length+r[2].length;fe[Ee.COERCERTL].lastIndex=-1}else e=n.match(fe[Ee.COERCE]);return e===null?null:On(`${e[2]}.${e[3]||"0"}.${e[4]||"0"}`,t)};function _n(n){return String.fromCharCode(parseInt(n.slice(1),16))}function kn(n){return`%${`00${n.charCodeAt(0).toString(16)}`.slice(-2)}`}function qn(n){return btoa(encodeURIComponent(n).replace(/%[0-9A-F]{2}/g,_n))}function Dn(n){return decodeURIComponent(Array.from(atob(n),kn).join(""))}function ae(n){return qn(JSON.stringify(n))}function De(n){return JSON.parse(Dn(n))}var N=require("@magic-sdk/types");var ge=require("@magic-sdk/types");function q(n){return typeof n=="undefined"}function Un(n){return n===null}function ye(n){return Un(n)||q(n)}function Fn(n){return ye(n)?!1:!q(n.jsonrpc)&&!q(n.id)&&!q(n.method)&&!q(n.params)}function Ue(n){return ye(n)?!1:!q(n.jsonrpc)&&!q(n.id)&&(!q(n.result)||!q(n.error))}function Wn(n){return ye(n)?!1:typeof n=="string"&&Object.values(ge.MagicPayloadMethod).includes(n)}function Fe(n){return ye(n)?!1:typeof n=="number"&&Object.values(ge.RPCErrorCode).includes(n)}function z(n){if(!n)return!0;for(let t in n)if(Object.hasOwnProperty.call(n,t))return!1;return!0}var f={};function wt(n,t){return Object.assign(f,t),n}var Pt={"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"};var $=class extends Error{constructor(e,r){super(`Magic SDK Error: [${e}] ${r}`);this.code=e;this.rawMessage=r;this.__proto__=Error;Object.setPrototypeOf(this,$.prototype)}},L=class extends Error{constructor(e){super();this.__proto__=Error;let r=Number(e==null?void 0:e.code);this.rawMessage=(e==null?void 0:e.message)||"Internal error",this.code=Fe(r)?r:N.RPCErrorCode.InternalError,this.message=`Magic RPC Error: [${this.code}] ${this.rawMessage}`,this.data=(e==null?void 0:e.data)||void 0,Object.setPrototypeOf(this,L.prototype)}},D=class{constructor(t,e){this.code=t;this.rawMessage=e;this.message=`Magic SDK Warning: [${t}] ${e}`}log(){console.warn(this.message)}},K=class extends Error{constructor(e,r,o,s){super(`Magic Extension Error (${e.name}): [${r}] ${o}`);this.code=r;this.rawMessage=o;this.data=s;this.__proto__=Error;Object.setPrototypeOf(this,K.prototype)}},Y=class{constructor(t,e,r){this.code=e;this.rawMessage=r;this.message=`Magic Extension Warning (${t.name}): [${e}] ${r}`}log(){console.warn(this.message)}};function We(){return new $(N.SDKErrorCode.MissingApiKey,"Please provide an API key that you acquired from the Magic developer dashboard.")}function Je(){return new $(N.SDKErrorCode.ModalNotReady,"Modal is not ready.")}function Ge(){return new $(N.SDKErrorCode.MalformedResponse,"Response from the Magic iframe is malformed.")}function Ke(n){return new $(N.SDKErrorCode.ExtensionNotInitialized,`Extensions must be initialized with a Magic SDK instance before \`Extension.${n}\` can be accessed. Do not invoke \`Extension.${n}\` inside an extension constructor.`)}function je(n){let t=`Some extensions are incompatible with \`${f.sdkName}@${f.version}\`:`;return n.filter(e=>typeof e.compat!="undefined"&&e.compat!==null).forEach(e=>{let r=e.compat[f.sdkName];typeof r=="string"?t+=`
"use strict";var Jt=Object.create;var re=Object.defineProperty,Gt=Object.defineProperties,Kt=Object.getOwnPropertyDescriptor,jt=Object.getOwnPropertyDescriptors,Bt=Object.getOwnPropertyNames,at=Object.getOwnPropertySymbols,Vt=Object.getPrototypeOf,lt=Object.prototype.hasOwnProperty,Ht=Object.prototype.propertyIsEnumerable;var ct=(n,t,e)=>t in n?re(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,V=(n,t)=>{for(var e in t||(t={}))lt.call(t,e)&&ct(n,e,t[e]);if(at)for(var e of at(t))Ht.call(t,e)&&ct(n,e,t[e]);return n},H=(n,t)=>Gt(n,jt(t));var Xt=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports),dt=(n,t)=>{for(var e in t)re(n,e,{get:t[e],enumerable:!0})},ut=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Bt(t))!lt.call(n,o)&&o!==e&&re(n,o,{get:()=>t[o],enumerable:!(r=Kt(t,o))||r.enumerable});return n};var zt=(n,t,e)=>(e=n!=null?Jt(Vt(n)):{},ut(t||!n||!n.__esModule?re(e,"default",{value:n,enumerable:!0}):e,n)),Yt=n=>ut(re({},"__esModule",{value:!0}),n);var E=(n,t,e)=>new Promise((r,o)=>{var s=c=>{try{a(e.next(c))}catch(l){o(l)}},i=c=>{try{a(e.throw(c))}catch(l){o(l)}},a=c=>c.done?r(c.value):Promise.resolve(c.value).then(s,i);a((e=e.apply(n,t)).next())});var At=Xt(($r,Xe)=>{"use strict";var Bn=Object.prototype.hasOwnProperty,M="~";function ce(){}Object.create&&(ce.prototype=Object.create(null),new ce().__proto__||(M=!1));function Vn(n,t,e){this.fn=n,this.context=t,this.once=e||!1}function Ct(n,t,e,r,o){if(typeof e!="function")throw new TypeError("The listener must be a function");var s=new Vn(e,r||n,o),i=M?M+t:t;return n._events[i]?n._events[i].fn?n._events[i]=[n._events[i],s]:n._events[i].push(s):(n._events[i]=s,n._eventsCount++),n}function ve(n,t){--n._eventsCount===0?n._events=new ce:delete n._events[t]}function w(){this._events=new ce,this._eventsCount=0}w.prototype.eventNames=function(){var t=[],e,r;if(this._eventsCount===0)return t;for(r in e=this._events)Bn.call(e,r)&&t.push(M?r.slice(1):r);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(e)):t};w.prototype.listeners=function(t){var e=M?M+t:t,r=this._events[e];if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,i=new Array(s);o<s;o++)i[o]=r[o].fn;return i};w.prototype.listenerCount=function(t){var e=M?M+t:t,r=this._events[e];return r?r.fn?1:r.length:0};w.prototype.emit=function(t,e,r,o,s,i){var a=M?M+t:t;if(!this._events[a])return!1;var c=this._events[a],l=arguments.length,d,m;if(c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,e),!0;case 3:return c.fn.call(c.context,e,r),!0;case 4:return c.fn.call(c.context,e,r,o),!0;case 5:return c.fn.call(c.context,e,r,o,s),!0;case 6:return c.fn.call(c.context,e,r,o,s,i),!0}for(m=1,d=new Array(l-1);m<l;m++)d[m-1]=arguments[m];c.fn.apply(c.context,d)}else{var A=c.length,I;for(m=0;m<A;m++)switch(c[m].once&&this.removeListener(t,c[m].fn,void 0,!0),l){case 1:c[m].fn.call(c[m].context);break;case 2:c[m].fn.call(c[m].context,e);break;case 3:c[m].fn.call(c[m].context,e,r);break;case 4:c[m].fn.call(c[m].context,e,r,o);break;default:if(!d)for(I=1,d=new Array(l-1);I<l;I++)d[I-1]=arguments[I];c[m].fn.apply(c[m].context,d)}}return!0};w.prototype.on=function(t,e,r){return Ct(this,t,e,r,!1)};w.prototype.once=function(t,e,r){return Ct(this,t,e,r,!0)};w.prototype.removeListener=function(t,e,r,o){var s=M?M+t:t;if(!this._events[s])return this;if(!e)return ve(this,s),this;var i=this._events[s];if(i.fn)i.fn===e&&(!o||i.once)&&(!r||i.context===r)&&ve(this,s);else{for(var a=0,c=[],l=i.length;a<l;a++)(i[a].fn!==e||o&&!i[a].once||r&&i[a].context!==r)&&c.push(i[a]);c.length?this._events[s]=c.length===1?c[0]:c:ve(this,s)}return this};w.prototype.removeAllListeners=function(t){var e;return t?(e=M?M+t:t,this._events[e]&&ve(this,e)):(this._events=new ce,this._eventsCount=0),this};w.prototype.off=w.prototype.removeListener;w.prototype.addListener=w.prototype.on;w.prefixed=M;w.EventEmitter=w;typeof Xe<"u"&&(Xe.exports=w)});var Er={};dt(Er,{Extension:()=>_,MagicExtensionError:()=>K,MagicExtensionWarning:()=>Y,MagicRPCError:()=>L,MagicSDKError:()=>$,MagicSDKWarning:()=>q,SDKBase:()=>pe,STORE_KEY_PRIVATE_KEY:()=>Me,STORE_KEY_PUBLIC_JWK:()=>de,TypedEmitter:()=>Te,ViewController:()=>_e,clearKeys:()=>er,createDeprecationWarning:()=>U,createDuplicateIframeWarning:()=>Jn,createExtensionNotInitializedError:()=>Ke,createIncompatibleExtensionsError:()=>je,createInvalidArgumentError:()=>Be,createJwt:()=>et,createMalformedResponseError:()=>Ge,createMissingApiKeyError:()=>We,createModalNotReadyError:()=>Je,createPromiEvent:()=>O,createPromise:()=>be,createReactNativeEndpointConfigurationWarning:()=>He,createSDK:()=>wt,createSynchronousWeb3MethodWarning:()=>Ve,createTypedEmitter:()=>le,createURL:()=>xe,decodeJSON:()=>qe,encodeJSON:()=>ae,getPayloadId:()=>Re,isEmpty:()=>z,isJsonRpcErrorCode:()=>Fe,isJsonRpcRequestPayload:()=>Fn,isJsonRpcResponsePayload:()=>Ue,isMagicPayloadMethod:()=>Wn,isMajorVersionAtLeast:()=>Ye,isPromiEvent:()=>ze,isWebCryptoSupported:()=>ee,storage:()=>Z,uuid:()=>Ze});module.exports=Yt(Er);function Qt(n){let t={exports:{}};return n(t,t.exports),t.exports}var Zt=Number.MAX_SAFE_INTEGER||9007199254740991;var De={SEMVER_SPEC_VERSION:"2.0.0",MAX_LENGTH:256,MAX_SAFE_INTEGER:Zt,MAX_SAFE_COMPONENT_LENGTH:16},en=typeof process=="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...n)=>console.error("SEMVER",...n):()=>{},y=en,ie=Qt(function(n,t){let{MAX_SAFE_COMPONENT_LENGTH:e}=De,r=(t=n.exports={}).re=[],o=t.src=[],s=t.t={},i=0,a=(c,l,d)=>{let m=i++;y(m,l),s[c]=m,o[m]=l,r[m]=new RegExp(l,d?"g":void 0)};a("NUMERICIDENTIFIER","0|[1-9]\\d*"),a("NUMERICIDENTIFIERLOOSE","[0-9]+"),a("NONNUMERICIDENTIFIER","\\d*[a-zA-Z-][a-zA-Z0-9-]*"),a("MAINVERSION",`(${o[s.NUMERICIDENTIFIER]})\\.(${o[s.NUMERICIDENTIFIER]})\\.(${o[s.NUMERICIDENTIFIER]})`),a("MAINVERSIONLOOSE",`(${o[s.NUMERICIDENTIFIERLOOSE]})\\.(${o[s.NUMERICIDENTIFIERLOOSE]})\\.(${o[s.NUMERICIDENTIFIERLOOSE]})`),a("PRERELEASEIDENTIFIER",`(?:${o[s.NUMERICIDENTIFIER]}|${o[s.NONNUMERICIDENTIFIER]})`),a("PRERELEASEIDENTIFIERLOOSE",`(?:${o[s.NUMERICIDENTIFIERLOOSE]}|${o[s.NONNUMERICIDENTIFIER]})`),a("PRERELEASE",`(?:-(${o[s.PRERELEASEIDENTIFIER]}(?:\\.${o[s.PRERELEASEIDENTIFIER]})*))`),a("PRERELEASELOOSE",`(?:-?(${o[s.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${o[s.PRERELEASEIDENTIFIERLOOSE]})*))`),a("BUILDIDENTIFIER","[0-9A-Za-z-]+"),a("BUILD",`(?:\\+(${o[s.BUILDIDENTIFIER]}(?:\\.${o[s.BUILDIDENTIFIER]})*))`),a("FULLPLAIN",`v?${o[s.MAINVERSION]}${o[s.PRERELEASE]}?${o[s.BUILD]}?`),a("FULL",`^${o[s.FULLPLAIN]}$`),a("LOOSEPLAIN",`[v=\\s]*${o[s.MAINVERSIONLOOSE]}${o[s.PRERELEASELOOSE]}?${o[s.BUILD]}?`),a("LOOSE",`^${o[s.LOOSEPLAIN]}$`),a("GTLT","((?:<|>)?=?)"),a("XRANGEIDENTIFIERLOOSE",`${o[s.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),a("XRANGEIDENTIFIER",`${o[s.NUMERICIDENTIFIER]}|x|X|\\*`),a("XRANGEPLAIN",`[v=\\s]*(${o[s.XRANGEIDENTIFIER]})(?:\\.(${o[s.XRANGEIDENTIFIER]})(?:\\.(${o[s.XRANGEIDENTIFIER]})(?:${o[s.PRERELEASE]})?${o[s.BUILD]}?)?)?`),a("XRANGEPLAINLOOSE",`[v=\\s]*(${o[s.XRANGEIDENTIFIERLOOSE]})(?:\\.(${o[s.XRANGEIDENTIFIERLOOSE]})(?:\\.(${o[s.XRANGEIDENTIFIERLOOSE]})(?:${o[s.PRERELEASELOOSE]})?${o[s.BUILD]}?)?)?`),a("XRANGE",`^${o[s.GTLT]}\\s*${o[s.XRANGEPLAIN]}$`),a("XRANGELOOSE",`^${o[s.GTLT]}\\s*${o[s.XRANGEPLAINLOOSE]}$`),a("COERCE",`(^|[^\\d])(\\d{1,${e}})(?:\\.(\\d{1,${e}}))?(?:\\.(\\d{1,${e}}))?(?:$|[^\\d])`),a("COERCERTL",o[s.COERCE],!0),a("LONETILDE","(?:~>?)"),a("TILDETRIM",`(\\s*)${o[s.LONETILDE]}\\s+`,!0),t.tildeTrimReplace="$1~",a("TILDE",`^${o[s.LONETILDE]}${o[s.XRANGEPLAIN]}$`),a("TILDELOOSE",`^${o[s.LONETILDE]}${o[s.XRANGEPLAINLOOSE]}$`),a("LONECARET","(?:\\^)"),a("CARETTRIM",`(\\s*)${o[s.LONECARET]}\\s+`,!0),t.caretTrimReplace="$1^",a("CARET",`^${o[s.LONECARET]}${o[s.XRANGEPLAIN]}$`),a("CARETLOOSE",`^${o[s.LONECARET]}${o[s.XRANGEPLAINLOOSE]}$`),a("COMPARATORLOOSE",`^${o[s.GTLT]}\\s*(${o[s.LOOSEPLAIN]})$|^$`),a("COMPARATOR",`^${o[s.GTLT]}\\s*(${o[s.FULLPLAIN]})$|^$`),a("COMPARATORTRIM",`(\\s*)${o[s.GTLT]}\\s*(${o[s.LOOSEPLAIN]}|${o[s.XRANGEPLAIN]})`,!0),t.comparatorTrimReplace="$1$2$3",a("HYPHENRANGE",`^\\s*(${o[s.XRANGEPLAIN]})\\s+-\\s+(${o[s.XRANGEPLAIN]})\\s*$`),a("HYPHENRANGELOOSE",`^\\s*(${o[s.XRANGEPLAINLOOSE]})\\s+-\\s+(${o[s.XRANGEPLAINLOOSE]})\\s*$`),a("STAR","(<|>)?=?\\s*\\*"),a("GTE0","^\\s*>=\\s*0.0.0\\s*$"),a("GTE0PRE","^\\s*>=\\s*0.0.0-0\\s*$")}),pt=/^[0-9]+$/,Tt=(n,t)=>{let e=pt.test(n),r=pt.test(t);return e&&r&&(n=+n,t=+t),n===t?0:e&&!r?-1:r&&!e?1:n<t?-1:1},tn=(n,t)=>Tt(t,n),nn={compareIdentifiers:Tt,rcompareIdentifiers:tn},{MAX_LENGTH:ht,MAX_SAFE_INTEGER:me}=De,{re:mt,t:ft}=ie,{compareIdentifiers:se}=nn,R=class{constructor(t,e){if(e&&typeof e=="object"||(e={loose:!!e,includePrerelease:!1}),t instanceof R){if(t.loose===!!e.loose&&t.includePrerelease===!!e.includePrerelease)return t;t=t.version}else if(typeof t!="string")throw new TypeError(`Invalid Version: ${t}`);if(t.length>ht)throw new TypeError(`version is longer than ${ht} characters`);y("SemVer",t,e),this.options=e,this.loose=!!e.loose,this.includePrerelease=!!e.includePrerelease;let r=t.trim().match(e.loose?mt[ft.LOOSE]:mt[ft.FULL]);if(!r)throw new TypeError(`Invalid Version: ${t}`);if(this.raw=t,this.major=+r[1],this.minor=+r[2],this.patch=+r[3],this.major>me||this.major<0)throw new TypeError("Invalid major version");if(this.minor>me||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>me||this.patch<0)throw new TypeError("Invalid patch version");r[4]?this.prerelease=r[4].split(".").map(o=>{if(/^[0-9]+$/.test(o)){let s=+o;if(s>=0&&s<me)return s}return o}):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(t){if(y("SemVer.compare",this.version,this.options,t),!(t instanceof R)){if(typeof t=="string"&&t===this.version)return 0;t=new R(t,this.options)}return t.version===this.version?0:this.compareMain(t)||this.comparePre(t)}compareMain(t){return t instanceof R||(t=new R(t,this.options)),se(this.major,t.major)||se(this.minor,t.minor)||se(this.patch,t.patch)}comparePre(t){if(t instanceof R||(t=new R(t,this.options)),this.prerelease.length&&!t.prerelease.length)return-1;if(!this.prerelease.length&&t.prerelease.length)return 1;if(!this.prerelease.length&&!t.prerelease.length)return 0;let e=0;do{let r=this.prerelease[e],o=t.prerelease[e];if(y("prerelease compare",e,r,o),r===void 0&&o===void 0)return 0;if(o===void 0)return 1;if(r===void 0)return-1;if(r!==o)return se(r,o)}while(++e)}compareBuild(t){t instanceof R||(t=new R(t,this.options));let e=0;do{let r=this.build[e],o=t.build[e];if(y("prerelease compare",e,r,o),r===void 0&&o===void 0)return 0;if(o===void 0)return 1;if(r===void 0)return-1;if(r!==o)return se(r,o)}while(++e)}inc(t,e){switch(t){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",e);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",e);break;case"prepatch":this.prerelease.length=0,this.inc("patch",e),this.inc("pre",e);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",e),this.inc("pre",e);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)}e&&(this.prerelease[0]===e?isNaN(this.prerelease[1])&&(this.prerelease=[e,0]):this.prerelease=[e,0]);break;default:throw new Error(`invalid increment argument: ${t}`)}return this.format(),this.raw=this.version,this}},rn=(n,t,e)=>new R(n,e).compare(new R(t,e)),X=rn,sn=(n,t,e)=>X(n,t,e)===0,on=sn,an=(n,t,e)=>X(n,t,e)!==0,cn=an,ln=(n,t,e)=>X(n,t,e)>0,dn=ln,un=(n,t,e)=>X(n,t,e)>=0,pn=un,hn=(n,t,e)=>X(n,t,e)<0,mn=hn,fn=(n,t,e)=>X(n,t,e)<=0,En=fn,yn=(n,t,e,r)=>{switch(t){case"===":return typeof n=="object"&&(n=n.version),typeof e=="object"&&(e=e.version),n===e;case"!==":return typeof n=="object"&&(n=n.version),typeof e=="object"&&(e=e.version),n!==e;case"":case"=":case"==":return on(n,e,r);case"!=":return cn(n,e,r);case">":return dn(n,e,r);case">=":return pn(n,e,r);case"<":return mn(n,e,r);case"<=":return En(n,e,r);default:throw new TypeError(`Invalid operator: ${t}`)}},ke=yn,oe=Symbol("SemVer ANY"),F=class{static get ANY(){return oe}constructor(t,e){if(e&&typeof e=="object"||(e={loose:!!e,includePrerelease:!1}),t instanceof F){if(t.loose===!!e.loose)return t;t=t.value}y("comparator",t,e),this.options=e,this.loose=!!e.loose,this.parse(t),this.semver===oe?this.value="":this.value=this.operator+this.semver.version,y("comp",this)}parse(t){let e=this.options.loose?Et[yt.COMPARATORLOOSE]:Et[yt.COMPARATOR],r=t.match(e);if(!r)throw new TypeError(`Invalid comparator: ${t}`);this.operator=r[1]!==void 0?r[1]:"",this.operator==="="&&(this.operator=""),r[2]?this.semver=new R(r[2],this.options.loose):this.semver=oe}toString(){return this.value}test(t){if(y("Comparator.test",t,this.options.loose),this.semver===oe||t===oe)return!0;if(typeof t=="string")try{t=new R(t,this.options)}catch(e){return!1}return ke(t,this.operator,this.semver,this.options)}intersects(t,e){if(!(t instanceof F))throw new TypeError("a Comparator is required");if(e&&typeof e=="object"||(e={loose:!!e,includePrerelease:!1}),this.operator==="")return this.value===""||new k(t.value,e).test(this.value);if(t.operator==="")return t.value===""||new k(this.value,e).test(t.semver);let r=!(this.operator!==">="&&this.operator!==">"||t.operator!==">="&&t.operator!==">"),o=!(this.operator!=="<="&&this.operator!=="<"||t.operator!=="<="&&t.operator!=="<"),s=this.semver.version===t.semver.version,i=!(this.operator!==">="&&this.operator!=="<="||t.operator!==">="&&t.operator!=="<="),a=ke(this.semver,"<",t.semver,e)&&(this.operator===">="||this.operator===">")&&(t.operator==="<="||t.operator==="<"),c=ke(this.semver,">",t.semver,e)&&(this.operator==="<="||this.operator==="<")&&(t.operator===">="||t.operator===">");return r||o||s&&i||a||c}},{re:Et,t:yt}=ie,k=class{constructor(t,e){if(e&&typeof e=="object"||(e={loose:!!e,includePrerelease:!1}),t instanceof k)return t.loose===!!e.loose&&t.includePrerelease===!!e.includePrerelease?t:new k(t.raw,e);if(t instanceof F)return this.raw=t.value,this.set=[[t]],this.format(),this;if(this.options=e,this.loose=!!e.loose,this.includePrerelease=!!e.includePrerelease,this.raw=t,this.set=t.split(/\s*\|\|\s*/).map(r=>this.parseRange(r.trim())).filter(r=>r.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${t}`);this.format()}format(){return this.range=this.set.map(t=>t.join(" ").trim()).join("||").trim(),this.range}toString(){return this.range}parseRange(t){let{loose:e}=this.options;t=t.trim();let r=e?b[T.HYPHENRANGELOOSE]:b[T.HYPHENRANGE];t=t.replace(r,Nn(this.options.includePrerelease)),y("hyphen replace",t),t=t.replace(b[T.COMPARATORTRIM],gn),y("comparator trim",t,b[T.COMPARATORTRIM]),t=(t=(t=t.replace(b[T.TILDETRIM],Rn)).replace(b[T.CARETTRIM],vn)).split(/\s+/).join(" ");let o=e?b[T.COMPARATORLOOSE]:b[T.COMPARATOR];return t.split(" ").map(s=>Tn(s,this.options)).join(" ").split(/\s+/).map(s=>An(s,this.options)).filter(this.options.loose?s=>!!s.match(o):()=>!0).map(s=>new F(s,this.options))}intersects(t,e){if(!(t instanceof k))throw new TypeError("a Range is required");return this.set.some(r=>gt(r,e)&&t.set.some(o=>gt(o,e)&&r.every(s=>o.every(i=>s.intersects(i,e)))))}test(t){if(!t)return!1;if(typeof t=="string")try{t=new R(t,this.options)}catch(e){return!1}for(let e=0;e<this.set.length;e++)if(Sn(this.set[e],t,this.options))return!0;return!1}},{re:b,t:T,comparatorTrimReplace:gn,tildeTrimReplace:Rn,caretTrimReplace:vn}=ie,gt=(n,t)=>{let e=!0,r=n.slice(),o=r.pop();for(;e&&r.length;)e=r.every(s=>o.intersects(s,t)),o=r.pop();return e},Tn=(n,t)=>(y("comp",n,t),n=wn(n,t),y("caret",n),n=In(n,t),y("tildes",n),n=Mn(n,t),y("xrange",n),n=Cn(n,t),y("stars",n),n),P=n=>!n||n.toLowerCase()==="x"||n==="*",In=(n,t)=>n.trim().split(/\s+/).map(e=>bn(e,t)).join(" "),bn=(n,t)=>{let e=t.loose?b[T.TILDELOOSE]:b[T.TILDE];return n.replace(e,(r,o,s,i,a)=>{let c;return y("tilde",n,r,o,s,i,a),P(o)?c="":P(s)?c=`>=${o}.0.0 <${+o+1}.0.0-0`:P(i)?c=`>=${o}.${s}.0 <${o}.${+s+1}.0-0`:a?(y("replaceTilde pr",a),c=`>=${o}.${s}.${i}-${a} <${o}.${+s+1}.0-0`):c=`>=${o}.${s}.${i} <${o}.${+s+1}.0-0`,y("tilde return",c),c})},wn=(n,t)=>n.trim().split(/\s+/).map(e=>Pn(e,t)).join(" "),Pn=(n,t)=>{y("caret",n,t);let e=t.loose?b[T.CARETLOOSE]:b[T.CARET],r=t.includePrerelease?"-0":"";return n.replace(e,(o,s,i,a,c)=>{let l;return y("caret",n,o,s,i,a,c),P(s)?l="":P(i)?l=`>=${s}.0.0${r} <${+s+1}.0.0-0`:P(a)?l=s==="0"?`>=${s}.${i}.0${r} <${s}.${+i+1}.0-0`:`>=${s}.${i}.0${r} <${+s+1}.0.0-0`:c?(y("replaceCaret pr",c),l=s==="0"?i==="0"?`>=${s}.${i}.${a}-${c} <${s}.${i}.${+a+1}-0`:`>=${s}.${i}.${a}-${c} <${s}.${+i+1}.0-0`:`>=${s}.${i}.${a}-${c} <${+s+1}.0.0-0`):(y("no pr"),l=s==="0"?i==="0"?`>=${s}.${i}.${a}${r} <${s}.${i}.${+a+1}-0`:`>=${s}.${i}.${a}${r} <${s}.${+i+1}.0-0`:`>=${s}.${i}.${a} <${+s+1}.0.0-0`),y("caret return",l),l})},Mn=(n,t)=>(y("replaceXRanges",n,t),n.split(/\s+/).map(e=>xn(e,t)).join(" ")),xn=(n,t)=>{n=n.trim();let e=t.loose?b[T.XRANGELOOSE]:b[T.XRANGE];return n.replace(e,(r,o,s,i,a,c)=>{y("xRange",n,r,o,s,i,a,c);let l=P(s),d=l||P(i),m=d||P(a),A=m;return o==="="&&A&&(o=""),c=t.includePrerelease?"-0":"",l?r=o===">"||o==="<"?"<0.0.0-0":"*":o&&A?(d&&(i=0),a=0,o===">"?(o=">=",d?(s=+s+1,i=0,a=0):(i=+i+1,a=0)):o==="<="&&(o="<",d?s=+s+1:i=+i+1),o==="<"&&(c="-0"),r=`${o+s}.${i}.${a}${c}`):d?r=`>=${s}.0.0${c} <${+s+1}.0.0-0`:m&&(r=`>=${s}.${i}.0${c} <${s}.${+i+1}.0-0`),y("xRange return",r),r})},Cn=(n,t)=>(y("replaceStars",n,t),n.trim().replace(b[T.STAR],"")),An=(n,t)=>(y("replaceGTE0",n,t),n.trim().replace(b[t.includePrerelease?T.GTE0PRE:T.GTE0],"")),Nn=n=>(t,e,r,o,s,i,a,c,l,d,m,A,I)=>`${e=P(r)?"":P(o)?`>=${r}.0.0${n?"-0":""}`:P(s)?`>=${r}.${o}.0${n?"-0":""}`:i?`>=${e}`:`>=${e}${n?"-0":""}`} ${c=P(l)?"":P(d)?`<${+l+1}.0.0-0`:P(m)?`<${l}.${+d+1}.0-0`:A?`<=${l}.${d}.${m}-${A}`:n?`<${l}.${d}.${+m+1}-0`:`<=${c}`}`.trim(),Sn=(n,t,e)=>{for(let r=0;r<n.length;r++)if(!n[r].test(t))return!1;if(t.prerelease.length&&!e.includePrerelease){for(let r=0;r<n.length;r++)if(y(n[r].semver),n[r].semver!==F.ANY&&n[r].semver.prerelease.length>0){let o=n[r].semver;if(o.major===t.major&&o.minor===t.minor&&o.patch===t.patch)return!0}return!1}return!0},It=(n,t,e)=>{try{t=new k(t,e)}catch(r){return!1}return t.test(n)};var{MAX_LENGTH:$n}=De,{re:Rt,t:vt}=ie,Ln=(n,t)=>{if(t&&typeof t=="object"||(t={loose:!!t,includePrerelease:!1}),n instanceof R)return n;if(typeof n!="string"||n.length>$n||!(t.loose?Rt[vt.LOOSE]:Rt[vt.FULL]).test(n))return null;try{return new R(n,t)}catch(e){return null}},On=Ln,{re:fe,t:Ee}=ie,bt=(n,t)=>{if(n instanceof R)return n;if(typeof n=="number"&&(n=String(n)),typeof n!="string")return null;let e=null;if((t=t||{}).rtl){let r;for(;(r=fe[Ee.COERCERTL].exec(n))&&(!e||e.index+e[0].length!==n.length);)e&&r.index+r[0].length===e.index+e[0].length||(e=r),fe[Ee.COERCERTL].lastIndex=r.index+r[1].length+r[2].length;fe[Ee.COERCERTL].lastIndex=-1}else e=n.match(fe[Ee.COERCE]);return e===null?null:On(`${e[2]}.${e[3]||"0"}.${e[4]||"0"}`,t)};function _n(n){return String.fromCharCode(parseInt(n.slice(1),16))}function kn(n){return`%${`00${n.charCodeAt(0).toString(16)}`.slice(-2)}`}function Dn(n){return btoa(encodeURIComponent(n).replace(/%[0-9A-F]{2}/g,_n))}function qn(n){return decodeURIComponent(Array.from(atob(n),kn).join(""))}function ae(n){return Dn(JSON.stringify(n))}function qe(n){return JSON.parse(qn(n))}var N=require("@magic-sdk/types");var ye=require("@magic-sdk/types");function D(n){return typeof n=="undefined"}function Un(n){return n===null}function ge(n){return Un(n)||D(n)}function Fn(n){return ge(n)?!1:!D(n.jsonrpc)&&!D(n.id)&&!D(n.method)&&!D(n.params)}function Ue(n){return ge(n)?!1:!D(n.jsonrpc)&&!D(n.id)&&(!D(n.result)||!D(n.error))}function Wn(n){return ge(n)?!1:typeof n=="string"&&Object.values(ye.MagicPayloadMethod).includes(n)}function Fe(n){return ge(n)?!1:typeof n=="number"&&Object.values(ye.RPCErrorCode).includes(n)}function z(n){if(!n)return!0;for(let t in n)if(Object.hasOwnProperty.call(n,t))return!1;return!0}var f={};function wt(n,t){return Object.assign(f,t),n}var Pt={"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"};var $=class extends Error{constructor(e,r){super(`Magic SDK Error: [${e}] ${r}`);this.code=e;this.rawMessage=r;this.__proto__=Error;Object.setPrototypeOf(this,$.prototype)}},L=class extends Error{constructor(e){super();this.__proto__=Error;let r=Number(e==null?void 0:e.code);this.rawMessage=(e==null?void 0:e.message)||"Internal error",this.code=Fe(r)?r:N.RPCErrorCode.InternalError,this.message=`Magic RPC Error: [${this.code}] ${this.rawMessage}`,this.data=(e==null?void 0:e.data)||void 0,Object.setPrototypeOf(this,L.prototype)}},q=class{constructor(t,e){this.code=t;this.rawMessage=e;this.message=`Magic SDK Warning: [${t}] ${e}`}log(){console.warn(this.message)}},K=class extends Error{constructor(e,r,o,s){super(`Magic Extension Error (${e.name}): [${r}] ${o}`);this.code=r;this.rawMessage=o;this.data=s;this.__proto__=Error;Object.setPrototypeOf(this,K.prototype)}},Y=class{constructor(t,e,r){this.code=e;this.rawMessage=r;this.message=`Magic Extension Warning (${t.name}): [${e}] ${r}`}log(){console.warn(this.message)}};function We(){return new $(N.SDKErrorCode.MissingApiKey,"Please provide an API key that you acquired from the Magic developer dashboard.")}function Je(){return new $(N.SDKErrorCode.ModalNotReady,"Modal is not ready.")}function Ge(){return new $(N.SDKErrorCode.MalformedResponse,"Response from the Magic iframe is malformed.")}function Ke(n){return new $(N.SDKErrorCode.ExtensionNotInitialized,`Extensions must be initialized with a Magic SDK instance before \`Extension.${n}\` can be accessed. Do not invoke \`Extension.${n}\` inside an extension constructor.`)}function je(n){let t=`Some extensions are incompatible with \`${f.sdkName}@${f.version}\`:`;return n.filter(e=>typeof e.compat!="undefined"&&e.compat!==null).forEach(e=>{let r=e.compat[f.sdkName];typeof r=="string"?t+=`
- Extension \`${e.name}\` supports version(s) \`${r}\``:r||(t+=`
- Extension \`${e.name}\` does not support ${f.platform} environments.`)}),new $(N.SDKErrorCode.IncompatibleExtensions,t)}function Be(n){let t=e=>{let r=e+1,o=r%10,s=r%100;return o===1&&s!==11?`${r}st`:o===2&&s!==12?`${r}nd`:o===3&&s!==13?`${r}rd`:`${r}th`};return new $(N.SDKErrorCode.InvalidArgument,`Invalid ${t(n.argument)} argument given to \`${n.procedure}\`.
Expected: \`${n.expected}\`
Received: \`${n.received}\``)}function Jn(){return new D(N.SDKWarningCode.DuplicateIframe,"Duplicate iframes found.")}function Ve(){return new D(N.SDKWarningCode.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 He(){return new D(N.SDKWarningCode.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 \`${f.defaultEndpoint}\`. Changing this default behavior will lead to unexpected results and potentially security-threatening bugs.`)}function U(n){let{method:t,removalVersions:e,useInstead:r}=n,o=e[f.sdkName],s=r?` Use \`${r}\` instead.`:"",i=`\`${t}\` will be removed from \`${f.sdkName}\` in version \`${o}\`.${s}`;return new D(N.SDKWarningCode.DeprecationNotice,i)}var h=require("@magic-sdk/types");var Q=require("@magic-sdk/types");function*Gn(){let n=0;for(;;)n<Number.MAX_SAFE_INTEGER?yield++n:n=0}var Kn=Gn();function Re(){return Kn.next().value}var Mt=Symbol("Payload pre-processed by Magic SDK");function xt(n){return Object.defineProperty(n,Mt,{value:!0,enumerable:!1}),n}function jn(n){return!!n[Mt]}function j(n){var t,e,r;return jn(n)||(n.jsonrpc=(t=n.jsonrpc)!=null?t:"2.0",n.id=Re(),n.method=(e=n.method)!=null?e:"noop",n.params=(r=n.params)!=null?r:[],xt(n)),n}function u(n,t=[]){return xt({params:t,method:n,jsonrpc:"2.0",id:Re()})}var W=class{constructor(t){t instanceof W?(this._jsonrpc=t.payload.jsonrpc,this._id=t.payload.id,this._result=t.payload.result,this._error=t.payload.error):Ue(t)?(this._jsonrpc=t.jsonrpc,this._id=t.id,this._result=t.result,this._error=t.error):(this._jsonrpc=t.jsonrpc,this._id=t.id,this._result=void 0,this._error=void 0)}applyError(t){return this._error=t,this}applyResult(t){return this._result=t,this}get hasError(){return typeof this._error!="undefined"&&this._error!==null}get hasResult(){return typeof this._result!="undefined"}get payload(){return{jsonrpc:this._jsonrpc,id:this._id,result:this._result,error:this._error}}};var Ie=require("@magic-sdk/types");var Nt=zt(At()),Te=class extends Nt.default{};function le(){let n=new Te;return{emitter:n,createChainingEmitterMethod:(r,o)=>(...s)=>(n[r].apply(n,s),o),createBoundEmitterMethod:r=>(...o)=>n[r].apply(n,o)}}var St=Symbol("isPromiEvent");function ze(n){return!!n[St]}function O(n){let t=be(n),{createBoundEmitterMethod:e,createChainingEmitterMethod:r}=le(),o=Symbol("Promise.then"),s=Symbol("Promise.catch"),i=Symbol("Promise.finally"),a=(d,m)=>(...A)=>{let I=m[d].apply(m,A);return c(I)},c=d=>Object.assign(d,{[St]:!0,[o]:d[o]||d.then,[s]:d[s]||d.catch,[i]:d[i]||d.finally,then:a(o,d),catch:a(s,d),finally:a(i,d),on:r("on",d),once:r("once",d),addListener:r("addListener",d),off:r("off",d),removeListener:r("removeListener",d),removeAllListeners:r("removeAllListeners",d),emit:e("emit"),eventNames:e("eventNames"),listeners:e("listeners"),listenerCount:e("listenerCount")}),l=c(t.then(d=>(l.emit("done",d),l.emit("settled"),d),d=>{throw l.emit("error",d),l.emit("settled"),d}));return l.on(Ie.UserEventsOnReceived.ClosedByUser,()=>{l.emit(Ie.UserEventsEmit.ClosedByUser)}),l}function be(n){return new Promise((t,e)=>{let r=n(t,e);Promise.resolve(r).catch(e)})}var x=class{constructor(t){this.sdk=t}get overlay(){return this.sdk.overlay}request(t){let e=this.overlay.post(Q.MagicOutgoingWindowMessage.MAGIC_HANDLE_REQUEST,j(t)),r=O((s,i)=>{e.then(a=>{if(o(),a.hasError)i(new L(a.payload.error));else if(a.hasResult)s(a.payload.result);else throw Ge()}).catch(a=>{o(),i(a)})}),o=this.overlay.on(Q.MagicIncomingWindowMessage.MAGIC_HANDLE_EVENT,s=>{var a;let{response:i}=s.data;if(i.id===t.id&&((a=i.result)==null?void 0:a.event)){let{event:c,params:l=[]}=i.result;r.emit(c,...l)}});return r}createIntermediaryEvent(t,e){return o=>{let s=u(Q.MagicPayloadMethod.IntermediaryEvent,[{payloadId:e,eventType:t,args:o}]);this.request(s)}}};function Ye(n,t){let[e]=n.split(".").map(Number);return e>=t}var B={"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"},we=class extends x{loginWithMagicLink(t){let e=f.sdkName==="@magic-sdk/react-native"||f.sdkName==="@magic-sdk/react-native-bare"||f.sdkName==="@magic-sdk/react-native-expo";if(e&&Ye(f.version,19))throw new Error("loginWithMagicLink() is deprecated for this package, please utlize a passcode method like loginWithSMS or loginWithEmailOTP instead.");e&&U({method:"auth.loginWithMagicLink()",removalVersions:B,useInstead:"auth.loginWithEmailOTP()"}).log();let{email:r,showUI:o=!0,redirectURI:s,overrides:i,lifespan:a}=t,c=u(this.sdk.testMode?h.MagicPayloadMethod.LoginWithMagicLinkTestMode:h.MagicPayloadMethod.LoginWithMagicLink,[{email:r,showUI:o,redirectURI:s,overrides:i,lifespan:a}]);return this.request(c)}loginWithSMS(t){let{phoneNumber:e,showUI:r=!0,lifespan:o}=t,s=u(this.sdk.testMode?h.MagicPayloadMethod.LoginWithSmsTestMode:h.MagicPayloadMethod.LoginWithSms,[{phoneNumber:e,showUI:r,lifespan:o}]),i=this.request(s);return!r&&i&&(i.on(h.LoginWithSmsOTPEventEmit.VerifySmsOtp,a=>{this.createIntermediaryEvent(h.LoginWithSmsOTPEventEmit.VerifySmsOtp,s.id)(a)}),i.on(h.LoginWithSmsOTPEventEmit.Cancel,()=>{this.createIntermediaryEvent(h.LoginWithSmsOTPEventEmit.Cancel,s.id)()})),i}loginWithEmailOTP(t){let{email:e,showUI:r,deviceCheckUI:o,overrides:s,lifespan:i}=t,a=u(this.sdk.testMode?h.MagicPayloadMethod.LoginWithEmailOTPTestMode:h.MagicPayloadMethod.LoginWithEmailOTP,[{email:e,showUI:r,deviceCheckUI:o,overrides:s,lifespan:i}]),c=this.request(a);return!o&&c&&c.on(h.DeviceVerificationEventEmit.Retry,()=>{this.createIntermediaryEvent(h.DeviceVerificationEventEmit.Retry,a.id)()}),!r&&c&&(c.on(h.LoginWithEmailOTPEventEmit.VerifyEmailOtp,l=>{this.createIntermediaryEvent(h.LoginWithEmailOTPEventEmit.VerifyEmailOtp,a.id)(l)}),c.on(h.LoginWithEmailOTPEventEmit.VerifyMFACode,l=>{this.createIntermediaryEvent(h.LoginWithEmailOTPEventEmit.VerifyMFACode,a.id)(l)}),c.on(h.LoginWithEmailOTPEventEmit.Cancel,()=>{this.createIntermediaryEvent(h.LoginWithEmailOTPEventEmit.Cancel,a.id)()})),c}loginWithCredential(t){let{credentialOrQueryString:e,lifespan:r}=t||{},o=e!=null?e:"";if(!e&&f.platform==="web"){o=window.location.search;let i=window.location.origin+window.location.pathname;window.history.replaceState(null,"",i)}let s=u(this.sdk.testMode?h.MagicPayloadMethod.LoginWithCredentialTestMode:h.MagicPayloadMethod.LoginWithCredential,[o,r]);return this.request(s)}setAuthorizationToken(t){let e=u(h.MagicPayloadMethod.SetAuthorizationToken,[{jwt:t}]);return this.request(e)}updateEmailWithUI(t){let{email:e,showUI:r=!0}=t,o=u(this.sdk.testMode?h.MagicPayloadMethod.UpdateEmailTestMode:h.MagicPayloadMethod.UpdateEmail,[{email:e,showUI:r}]),s=this.request(o);return r||(s.on(h.RecencyCheckEventEmit.Retry,()=>{this.createIntermediaryEvent(h.RecencyCheckEventEmit.Retry,o.id)()}),s.on(h.RecencyCheckEventEmit.Cancel,()=>{this.createIntermediaryEvent(h.RecencyCheckEventEmit.Cancel,o.id)()}),s.on(h.RecencyCheckEventEmit.VerifyEmailOtp,i=>{this.createIntermediaryEvent(h.RecencyCheckEventEmit.VerifyEmailOtp,o.id)(i)}),s.on(h.RecencyCheckEventEmit.VerifyMFACode,i=>{this.createIntermediaryEvent(h.RecencyCheckEventEmit.VerifyMFACode,o.id)(i)}),s.on(h.UpdateEmailEventEmit.RetryWithNewEmail,i=>{this.createIntermediaryEvent(h.UpdateEmailEventEmit.RetryWithNewEmail,o.id)(i)}),s.on(h.UpdateEmailEventEmit.Cancel,()=>{this.createIntermediaryEvent(h.UpdateEmailEventEmit.Cancel,o.id)()}),s.on(h.UpdateEmailEventEmit.VerifyEmailOtp,i=>{this.createIntermediaryEvent(h.UpdateEmailEventEmit.VerifyEmailOtp,o.id)(i)})),s}};var p=require("@magic-sdk/types");var Z={};dt(Z,{clear:()=>Hn,getItem:()=>v,iterate:()=>Qe,key:()=>zn,keys:()=>Yn,length:()=>Xn,removeItem:()=>S,setItem:()=>C});var Pe;function J(n){return(...t)=>E(this,null,function*(){return Pe||(Pe=yield f.configureStorage()),yield Pe.ready(),Pe[n](...t)})}var v=J("getItem"),C=J("setItem"),S=J("removeItem"),Hn=J("clear"),Xn=J("length"),zn=J("key"),Yn=J("keys"),Qe=J("iterate");function Ze(){let n=window.crypto.getRandomValues(new Uint8Array(16));n[6]=n[6]&15|64,n[8]=n[8]&191|128;let t="";return t+=n[0].toString(16),t+=n[1].toString(16),t+=n[2].toString(16),t+=n[3].toString(16),t+="-",t+=n[4].toString(16),t+=n[5].toString(16),t+="-",t+=n[6].toString(16),t+=n[7].toString(16),t+="-",t+=n[8].toString(16),t+=n[9].toString(16),t+="-",t+=n[10].toString(16),t+=n[11].toString(16),t+=n[12].toString(16),t+=n[13].toString(16),t+=n[14].toString(16),t+=n[15].toString(16),t}var Me="STORE_KEY_PRIVATE_KEY",de="STORE_KEY_PUBLIC_JWK",Lt="ECDSA",Qn="P-256",Zn={name:Lt,namedCurve:Qn};function ee(){let n=typeof window!="undefined"&&!!window.crypto,t=n&&!!window.crypto.subtle;return n&&t}function er(){S(de),S(Me)}function et(){return E(this,null,function*(){let n=yield tr();if(!n){console.info("unable to create public key or webcrypto is unsupported");return}let{subtle:t}=window.crypto,e=yield v(Me);if(!e||!t){console.info("unable to find private key or webcrypto unsupported");return}let r={iat:Math.floor(new Date().getTime()/1e3),jti:Ze()},o={typ:"dpop+jwt",alg:"ES256",jwk:n},s={protected:$t(JSON.stringify(o)),claims:$t(JSON.stringify(r))},i=rr(`${s.protected}.${s.claims}`),a={name:Lt,hash:{name:"SHA-256"}},c=or(new Uint8Array(yield t.sign(a,e,i)));return`${s.protected}.${s.claims}.${c}`})}function tr(){return E(this,null,function*(){if(!ee()){console.info("webcrypto is not supported");return}return(yield v(de))||(yield nr()),v(de)})}function nr(){return E(this,null,function*(){let{subtle:n}=window.crypto,t=yield n.generateKey(Zn,!1,["sign"]),e=yield n.exportKey("jwk",t.publicKey);yield C(Me,t.privateKey),yield C(de,e)})}function $t(n){return Ot(sr(n))}function rr(n){return new TextEncoder().encode(n)}function Ot(n){return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+/g,"")}function sr(n){return encodeURIComponent(n).replace(/%([0-9A-F]{2})/g,(e,r)=>String.fromCharCode(parseInt(r,16)))}function or(n){let t="";return n.forEach(e=>{t+=String.fromCharCode(e)}),Ot(t)}var tt="ds",nt="ek",rt="iv",st="AES-GCM",ir=256;function te(){return E(this,null,function*(){let n=[];yield Qe((t,e,r)=>{e.startsWith(`${tt}_`)&&n.push(e)});for(let t of n)yield S(t)})}function _t(n){let t="",e=new Uint8Array(n),r=e.byteLength;for(let o=0;o<r;o++)t+=String.fromCharCode(e[o]);return window.btoa(t)}function kt(n){let t=window.atob(n),e=t.length,r=new Uint8Array(e);for(let o=0;o<e;o++)r[o]=t.charCodeAt(o);return r.buffer}function ar(){return E(this,null,function*(){if(!ee()){console.info("webcrypto is not supported");return}let{crypto:n}=window,t=yield v(rt);return t||n.getRandomValues(new Uint8Array(12))})}function cr(){return E(this,null,function*(){if(!ee()){console.info("webcrypto is not supported");return}let{subtle:n}=window.crypto,t=yield v(nt);return t||(yield n.generateKey({name:st,length:ir},!1,["encrypt","decrypt"]))})}function qt(n,t){return E(this,null,function*(){let e=yield ar(),r=yield cr();if(!e||!r||!n)return;let o=kt(n),{subtle:s}=window.crypto,i=yield s.encrypt({name:st,iv:e},r,o),a=_t(i);yield C(`${tt}_${t}`,a),yield C(nt,r),yield C(rt,e)})}function Dt(n){return E(this,null,function*(){let t=yield v(`${tt}_${n}`),e=yield v(rt),r=yield v(nt);if(!e||!t||!r||!ee())return;let{subtle:o}=window.crypto,s=yield o.decrypt({name:st,iv:e},r,kt(t));return _t(s)})}function xe(n,t){return t?new URL(n,t):new URL(n)}var Ce=class extends x{constructor(){super(...arguments);this.localForageKey="mc_active_wallet";this.localForageIsLoggedInKey="magic_auth_is_logged_in";this.userLoggedOutCallbacks=[]}getIdToken(e){let r=u(this.sdk.testMode?p.MagicPayloadMethod.GetIdTokenTestMode:p.MagicPayloadMethod.GetIdToken,[e]);return this.request(r)}generateIdToken(e){let r=u(this.sdk.testMode?p.MagicPayloadMethod.GenerateIdTokenTestMode:p.MagicPayloadMethod.GenerateIdToken,[e]);return this.request(r)}getInfo(){return E(this,null,function*(){let e=yield v(this.localForageKey),r=u(p.MagicPayloadMethod.GetInfo,[{walletType:e}]);return this.request(r)})}isLoggedIn(){return O((e,r)=>E(this,null,function*(){try{let o=!1;this.sdk.useStorageCache&&(o=(yield v(this.localForageIsLoggedInKey))==="true",o&&e(!0));let s=u(this.sdk.testMode?p.MagicPayloadMethod.IsLoggedInTestMode:p.MagicPayloadMethod.IsLoggedIn),i=yield this.request(s);this.sdk.useStorageCache&&(i?C(this.localForageIsLoggedInKey,!0):S(this.localForageIsLoggedInKey),o&&!i&&this.emitUserLoggedOut(!0)),e(i)}catch(o){r(o)}}))}logout(){return S(this.localForageKey),S(this.localForageIsLoggedInKey),te(),O((e,r)=>E(this,null,function*(){try{let o=u(this.sdk.testMode?p.MagicPayloadMethod.LogoutTestMode:p.MagicPayloadMethod.Logout),s=yield this.request(o);this.sdk.useStorageCache&&this.emitUserLoggedOut(s),e(s)}catch(o){r(o)}}))}requestInfoWithUI(e){let r=u(p.MagicPayloadMethod.RequestUserInfoWithUI,e?[e]:[]);return this.request(r)}showSettings(e){let{showUI:r=!0}=e||{},o=u(this.sdk.testMode?p.MagicPayloadMethod.UserSettingsTestMode:p.MagicPayloadMethod.UserSettings,[e]),s=this.request(o);return!r&&s&&(s.on(p.RecoveryFactorEventEmit.SendNewPhoneNumber,i=>{this.createIntermediaryEvent(p.RecoveryFactorEventEmit.SendNewPhoneNumber,o.id)(i)}),s.on(p.RecoveryFactorEventEmit.SendOtpCode,i=>{this.createIntermediaryEvent(p.RecoveryFactorEventEmit.SendOtpCode,o.id)(i)}),s.on(p.RecoveryFactorEventEmit.StartEditPhoneNumber,()=>{this.createIntermediaryEvent(p.RecoveryFactorEventEmit.StartEditPhoneNumber,o.id)()}),s.on(p.RecoveryFactorEventEmit.Cancel,()=>{this.createIntermediaryEvent(p.RecoveryFactorEventEmit.Cancel,o.id)()}),s.on(p.RecencyCheckEventEmit.VerifyEmailOtp,i=>{this.createIntermediaryEvent(p.RecencyCheckEventEmit.VerifyEmailOtp,o.id)(i)})),s}recoverAccount(e){let r=u(this.sdk.testMode?p.MagicPayloadMethod.RecoverAccountTestMode:p.MagicPayloadMethod.RecoverAccount,[e]);return this.request(r)}revealPrivateKey(){let e=u(p.MagicPayloadMethod.RevealPK);return this.request(e)}getMetadata(){U({method:"user.getMetadata()",removalVersions:B,useInstead:"user.getInfo()"}).log();let e=u(this.sdk.testMode?p.MagicPayloadMethod.GetMetadataTestMode:p.MagicPayloadMethod.GetMetadata);return this.request(e)}onUserLoggedOut(e){this.userLoggedOutCallbacks.push(e)}enableMFA(e){let{showUI:r=!0}=e,o=u(p.MagicPayloadMethod.EnableMFA,[{showUI:r}]),s=this.request(o);return!r&&s&&(s.on(p.EnableMFAEventEmit.VerifyMFACode,i=>{this.createIntermediaryEvent(p.EnableMFAEventEmit.VerifyMFACode,o.id)(i)}),s.on(p.EnableMFAEventEmit.Cancel,()=>{this.createIntermediaryEvent(p.EnableMFAEventEmit.Cancel,o.id)()})),s}disableMFA(e){let{showUI:r=!0}=e,o=u(p.MagicPayloadMethod.DisableMFA,[{showUI:r}]),s=this.request(o);return!r&&s&&(s.on(p.DisableMFAEventEmit.VerifyMFACode,i=>{this.createIntermediaryEvent(p.DisableMFAEventEmit.VerifyMFACode,o.id)(i)}),s.on(p.DisableMFAEventEmit.LostDevice,i=>{this.createIntermediaryEvent(p.DisableMFAEventEmit.LostDevice,o.id)(i)}),s.on(p.DisableMFAEventEmit.Cancel,()=>{this.createIntermediaryEvent(p.DisableMFAEventEmit.Cancel,o.id)()})),s}emitUserLoggedOut(e){this.userLoggedOutCallbacks.forEach(r=>{r(e)})}};var y=require("@magic-sdk/types");var Ae=class extends x{constructor(){super(...arguments);this.localForageKey="mc_active_wallet"}connectWithUI(){let e=O((r,o)=>E(this,null,function*(){try{if(this.isMetaMaskBrowser()&&(yield this.isWalletEnabled(y.Wallets.MetaMask))){let l=yield this.autoConnectIfWalletBrowser(y.Wallets.MetaMask);r(l);return}if(this.isCoinbaseWalletBrowser()&&(yield this.isWalletEnabled(y.Wallets.CoinbaseWallet))){let l=yield this.autoConnectIfWalletBrowser(y.Wallets.CoinbaseWallet);r(l);return}let s=this.getUserEnv(),i=u(y.MagicPayloadMethod.Login,[s]),a=this.request(i);a.on(y.Events.WalletSelected,l=>this.handleWalletSelected(H(V({},l),{payloadId:i.id}))),a.on("id-token-created",l=>{e.emit("id-token-created",l)});let c=yield a;c.error&&o(c),r(c)}catch(s){o(s)}}));return e}showUI(e){return this.request(u(y.MagicPayloadMethod.ShowUI,[e]))}showAddress(){return this.request(u(y.MagicPayloadMethod.ShowAddress))}showSendTokensUI(){return this.request(u(y.MagicPayloadMethod.ShowSendTokensUI))}showOnRamp(){return this.request(u(y.MagicPayloadMethod.ShowOnRamp))}showNFTs(){return this.request(u(y.MagicPayloadMethod.ShowNFTs))}showBalances(){return this.request(u(y.MagicPayloadMethod.ShowBalances))}sendGaslessTransaction(e,r){return this.request(u(y.MagicPayloadMethod.SendGaslessTransaction,[e,r]))}getInfo(){return E(this,null,function*(){U({method:"wallet.getInfo()",removalVersions:B,useInstead:"user.getInfo()"}).log();let e=yield v(this.localForageKey),r=u(y.MagicPayloadMethod.GetInfo,[{walletType:e}]);return this.request(r)})}disconnect(){U({method:"wallet.disconnect()",removalVersions:B,useInstead:"user.logout()"}).log(),S(this.localForageKey),te();let e=u(y.MagicPayloadMethod.Disconnect);return this.request(e)}requestUserInfoWithUI(e){U({method:"wallet.requestUserInfoWithUI()",removalVersions:B,useInstead:"user.requestUserInfoWithUI()"}).log();let r=u(y.MagicPayloadMethod.RequestUserInfoWithUI,e?[e]:[]);return this.request(r)}getProvider(){return E(this,null,function*(){switch(yield v(this.localForageKey)){case y.Wallets.MetaMask:return this.getMetaMaskProvider();case y.Wallets.CoinbaseWallet:return this.getCoinbaseProvider();default:return this.sdk.rpcProvider}})}isMetaMaskInstalled(){var e,r,o;return((e=window.ethereum)==null?void 0:e.isMetaMask)||!!((o=(r=window.ethereum)==null?void 0:r.providers)!=null&&o.find(s=>s==null?void 0:s.isMetaMask))}isMetaMaskBrowser(){return this.isMobile()&&this.isMetaMaskInstalled()}getMetaMaskProvider(){var e,r;return((r=(e=window.ethereum)==null?void 0:e.providers)==null?void 0:r.find(o=>o==null?void 0:o.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,r,o;return((e=window.ethereum)==null?void 0:e.isCoinbaseWallet)||!!((o=(r=window.ethereum)==null?void 0:r.providers)!=null&&o.find(s=>s==null?void 0:s.isCoinbaseWallet))}isCoinbaseWalletBrowser(){var e;return!!((e=window.ethereum)!=null&&e.isCoinbaseBrowser)}getCoinbaseProvider(){var e,r;return((r=(e=window.ethereum)==null?void 0:e.providers)==null?void 0:r.find(o=>o==null?void 0:o.isCoinbaseWallet))||window.ethereum}connectToCoinbaseWallet(){if(this.isMobile()&&!this.isCoinbaseWalletBrowser()){let r=`https://go.cb-w.com/dapp?cb_url=${encodeURIComponent(window.location.href)}`;window.location.href=r}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 y.Wallets.MetaMask:return this.connectToMetaMask();case y.Wallets.CoinbaseWallet:return this.connectToCoinbaseWallet();default:throw new Error(`Invalid provider: ${e}. Must be one of "metamask" or "coinbase_wallet".`)}}isWalletEnabled(e){let r=u("mc_is_wallet_enabled",[{wallet:e}]);return this.request(r)}handleWalletSelected(e){return E(this,null,function*(){try{let r=yield this.connectToThirdPartyWallet(e.wallet);yield C(this.localForageKey,e.wallet),this.createIntermediaryEvent(y.Events.WalletConnected,e.payloadId)(r)}catch(r){console.error(r),this.createIntermediaryEvent(y.Events.WalletRejected,e.payloadId)()}})}autoConnectIfWalletBrowser(e){return E(this,null,function*(){let r;e===y.Wallets.MetaMask&&(r=yield this.getMetaMaskProvider().request({method:"eth_requestAccounts"})),e===y.Wallets.CoinbaseWallet&&(r=yield this.getCoinbaseProvider().request({method:"eth_requestAccounts"})),yield C(this.localForageKey,e);let o=u(y.MagicPayloadMethod.AutoConnect,[{wallet:e,address:r}]);return this.request(o)})}};var ue=require("@magic-sdk/types");var{createBoundEmitterMethod:Ne,createChainingEmitterMethod:ne}=le(),Se=class extends x{constructor(){super(...arguments);this.isMagic=!0;this.on=ne("on",this);this.once=ne("once",this);this.addListener=ne("addListener",this);this.off=ne("off",this);this.removeListener=ne("removeListener",this);this.removeAllListeners=ne("removeAllListeners",this);this.emit=Ne("emit");this.eventNames=Ne("eventNames");this.listeners=Ne("listeners");this.listenerCount=Ne("listenerCount")}sendAsync(e,r){if(!r)throw Be({procedure:"Magic.rpcProvider.sendAsync",argument:1,expected:"function",received:r===null?"null":typeof r});if(Array.isArray(e))this.overlay.post(ue.MagicOutgoingWindowMessage.MAGIC_HANDLE_REQUEST,e.map(o=>{let s=j(o);return this.prefixPayloadMethodForTestMode(s),s})).then(o=>{r(null,o.map(s=>H(V({},s.payload),{error:s.hasError?new L(s.payload.error):null})))});else{let o=j(e);this.prefixPayloadMethodForTestMode(o),this.overlay.post(ue.MagicOutgoingWindowMessage.MAGIC_HANDLE_REQUEST,o).then(s=>{r(s.hasError?new L(s.payload.error):null,s.payload)})}}send(e,r){if(typeof e=="string"){let s=u(e,Array.isArray(r)?r:[]);return this.request(s)}if(Array.isArray(e)||!!r){this.sendAsync(e,r);return}let o=Ve();return o.log(),new W(e).applyError({code:-32603,message:o.rawMessage}).payload}enable(){let e=u(ue.MagicPayloadMethod.Login);return this.request(e)}request(e){return this.prefixPayloadMethodForTestMode(e),super.request(e)}prefixPayloadMethodForTestMode(e){let r="testMode/eth/";this.sdk.testMode&&(e.method=`${r}${e.method}`)}};var Ut=["request","overlay","sdk"];function lr(n){let t=Object.getPrototypeOf(n),e=[t];for(;t!==x.prototype;)t=Object.getPrototypeOf(t),e.push(t);return e}var $e=class extends x{constructor(){super(void 0);this.__sdk_access_field_descriptors__=new Map;this.__is_initialized__=!1;this.utils={createPromiEvent:O,isPromiEvent:ze,encodeJSON:ae,decodeJSON:De,createJsonRpcRequestPayload:u,standardizeJsonRpcRequestPayload:j,storage:Z};let e=[this,...lr(this)];Ut.forEach(r=>{let o=e.map(c=>Object.getOwnPropertyDescriptor(c,r)),s=o.findIndex(c=>!!c),i=s>0,a=o[s];a&&(this.__sdk_access_field_descriptors__.set(r,{descriptor:a,isPrototypeField:i}),Object.defineProperty(this,r,{configurable:!0,get:()=>{throw Ke(r)}}))})}init(e){this.__is_initialized__||(Ut.forEach(r=>{if(this.__sdk_access_field_descriptors__.has(r)){let{descriptor:o,isPrototypeField:s}=this.__sdk_access_field_descriptors__.get(r);s?delete this[r]:Object.defineProperty(this,r,o)}}),this.sdk=e,this.__is_initialized__=!0)}createDeprecationWarning(e){let{method:r,removalVersion:o,useInstead:s}=e,i=s?` Use \`${s}\` instead.`:"",a=`\`${r}\` will be removed from this Extension in version \`${o}\`.${i}`;return new Y(this,"DEPRECATION_NOTICE",a)}createWarning(e,r){return new Y(this,e,r)}createError(e,r,o){return new K(this,e,r,o)}},ot=class extends $e{},_=class extends $e{};_.Internal=ot,_.Anonymous="anonymous extension";var Le=require("@magic-sdk/types");var Oe=class extends x{purchase(t){let e=u(Le.MagicPayloadMethod.NFTPurchase,[t]);return this.request(e)}checkout(t){let e=u(Le.MagicPayloadMethod.NFTCheckout,[t]);return this.request(e)}transfer(t){let e=u(Le.MagicPayloadMethod.NFTTransfer,[t]);return this.request(e)}};function Ft(n){return n.compat&&n.compat[f.sdkName]!=null?typeof n.compat[f.sdkName]=="string"?It(bt(f.version),n.compat[f.sdkName]):!!n.compat[f.sdkName]:!0}function dr(n,t,e){return!t&&!e?`${n}_eth_mainnet`:e?`${n}_${JSON.stringify(e)}`:t?typeof t=="string"?`${n}_eth_${t}`:`${n}_${t.rpcUrl}_${t.chainId}_${t.chainType}`:`${n}_unknown`}function ur(n){var o;let t=(o=n==null?void 0:n.extensions)!=null?o:[],e={},r=[];if(Array.isArray(t)?t.forEach(s=>{Ft(s)?(s.init(this),(s.name||s.name!==_.Anonymous)&&(this[s.name]=s),s instanceof _.Internal&&(z(s.config)||(e[s.name]=s.config))):r.push(s)}):Object.keys(t).forEach(s=>{if(Ft(t[s])){t[s].init(this);let i=t[s];this[s]=i,i instanceof _.Internal&&(z(i.config)||(e[t[s].name]=i.config))}else r.push(t[s])}),r.length)throw je(r);return e}var he=class{constructor(t,e){this.apiKey=t;var i;if(!t)throw We();f.platform==="react-native"&&(e==null?void 0:e.endpoint)&&He().log();let{defaultEndpoint:r,version:o}=f;this.testMode=!!(e!=null&&e.testMode),this.useStorageCache=!!(e!=null&&e.useStorageCache),this.endpoint=xe((i=e==null?void 0:e.endpoint)!=null?i:r).origin,this.auth=new we(this),this.user=new Ce(this),this.wallet=new Ae(this),this.nft=new Oe(this),this.rpcProvider=new Se(this);let s=ur.call(this,e);this.parameters=ae(H(V({API_KEY:this.apiKey,DOMAIN_ORIGIN:window.location?window.location.origin:"",ETH_NETWORK:e==null?void 0:e.network,host:xe(this.endpoint).host,sdk:Pt[f.sdkName],version:o,ext:z(s)?void 0:s,locale:(e==null?void 0:e.locale)||"en_US"},f.bundleId?{bundleId:f.bundleId}:{}),{meta:e==null?void 0:e.meta})),this.networkHash=dr(this.apiKey,e==null?void 0:e.network,z(s)?void 0:s),e!=null&&e.deferPreload||this.preload()}get overlay(){if(!he.__overlays__.has(this.parameters)){let t=new f.ViewController(this.endpoint,this.parameters,this.networkHash);t.init(),he.__overlays__.set(this.parameters,t)}return he.__overlays__.get(this.parameters)}preload(){return E(this,null,function*(){yield this.overlay.checkIsReadyForRequest})}},pe=he;pe.__overlays__=new Map;var G=require("@magic-sdk/types");function pr(n,t){return t&&Array.isArray(n)?n.find(e=>e.id===t):n}function hr(n,t){var o;let e=(o=t.data.response)==null?void 0:o.id,r=pr(n,e);if(e&&r){let s=new W(r).applyResult(t.data.response.result).applyError(t.data.response.error);return{id:e,response:s}}return{}}function mr(n,t,e){return E(this,null,function*(){var a;let r=yield v("rt"),o;if(f.platform==="web")try{o=(a=yield v("jwt"))!=null?a:yield et()}catch(c){console.error("webcrypto error",c)}let s={msgType:n,payload:t};o&&(s.jwt=o),o&&r&&(s.rt=r);let i=yield Dt(e);return i&&(s.deviceShare=i),s})}function fr(n){return E(this,null,function*(){!n.data.rt||(yield C("rt",n.data.rt))})}var _e=class{constructor(t,e,r){this.endpoint=t;this.parameters=e;this.networkHash=r;this.messageHandlers=new Set;this.isConnectedToInternet=!0;this.checkIsReadyForRequest=this.waitForReady(),this.isReadyForRequest=!1,this.listen()}post(t,e){return E(this,null,function*(){return be((r,o)=>E(this,null,function*(){if(!this.isConnectedToInternet){let d=Je();o(d)}this.isReadyForRequest||(yield this.waitForReady());let s=[],i=Array.isArray(e)?e.map(d=>d.id):[],a=yield mr(`${t}-${this.parameters}`,e,this.networkHash);yield this._post(a);let c=d=>m=>{var it;let{id:A,response:I}=hr(e,m);if(fr(m),((it=I==null?void 0:I.payload.error)==null?void 0:it.message)==="User denied account access.")te();else if(m.data.deviceShare){let{deviceShare:Wt}=m.data;qt(Wt,this.networkHash)}A&&I&&Array.isArray(e)&&i.includes(A)?(s.push(I),s.length===e.length&&(d(),r(s))):A&&I&&!Array.isArray(e)&&A===e.id&&(d(),r(I))},l=this.on(G.MagicIncomingWindowMessage.MAGIC_HANDLE_RESPONSE,c(()=>l()))}))})}on(t,e){let r=e.bind(window),o=s=>{s.data.msgType===`${t}-${this.parameters}`&&r(s)};return this.messageHandlers.add(o),()=>this.messageHandlers.delete(o)}waitForReady(){return new Promise(t=>{let e=this.on(G.MagicIncomingWindowMessage.MAGIC_OVERLAY_READY,()=>{this.isReadyForRequest=!0,t(),e()});setTimeout(()=>{this.isReadyForRequest=!0,t(),e()},15e3)})}listen(){this.on(G.MagicIncomingWindowMessage.MAGIC_HIDE_OVERLAY,()=>{this.hideOverlay()}),this.on(G.MagicIncomingWindowMessage.MAGIC_SHOW_OVERLAY,()=>{this.showOverlay()}),this.on(G.MagicIncomingWindowMessage.MAGIC_SEND_PRODUCT_ANNOUNCEMENT,t=>{t.data.response.result.product_announcement&&new D(G.SDKWarningCode.ProductAnnouncement,t.data.response.result.product_announcement).log()})}};
Received: \`${n.received}\``)}function Jn(){return new q(N.SDKWarningCode.DuplicateIframe,"Duplicate iframes found.")}function Ve(){return new q(N.SDKWarningCode.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 He(){return new q(N.SDKWarningCode.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 \`${f.defaultEndpoint}\`. Changing this default behavior will lead to unexpected results and potentially security-threatening bugs.`)}function U(n){let{method:t,removalVersions:e,useInstead:r}=n,o=e[f.sdkName],s=r?` Use \`${r}\` instead.`:"",i=`\`${t}\` will be removed from \`${f.sdkName}\` in version \`${o}\`.${s}`;return new q(N.SDKWarningCode.DeprecationNotice,i)}var u=require("@magic-sdk/types");var Q=require("@magic-sdk/types");function*Gn(){let n=0;for(;;)n<Number.MAX_SAFE_INTEGER?yield++n:n=0}var Kn=Gn();function Re(){return Kn.next().value}var Mt=Symbol("Payload pre-processed by Magic SDK");function xt(n){return Object.defineProperty(n,Mt,{value:!0,enumerable:!1}),n}function jn(n){return!!n[Mt]}function j(n){var t,e,r;return jn(n)||(n.jsonrpc=(t=n.jsonrpc)!=null?t:"2.0",n.id=Re(),n.method=(e=n.method)!=null?e:"noop",n.params=(r=n.params)!=null?r:[],xt(n)),n}function p(n,t=[]){return xt({params:t,method:n,jsonrpc:"2.0",id:Re()})}var W=class{constructor(t){t instanceof W?(this._jsonrpc=t.payload.jsonrpc,this._id=t.payload.id,this._result=t.payload.result,this._error=t.payload.error):Ue(t)?(this._jsonrpc=t.jsonrpc,this._id=t.id,this._result=t.result,this._error=t.error):(this._jsonrpc=t.jsonrpc,this._id=t.id,this._result=void 0,this._error=void 0)}applyError(t){return this._error=t,this}applyResult(t){return this._result=t,this}get hasError(){return typeof this._error!="undefined"&&this._error!==null}get hasResult(){return typeof this._result!="undefined"}get payload(){return{jsonrpc:this._jsonrpc,id:this._id,result:this._result,error:this._error}}};var Ie=require("@magic-sdk/types");var Nt=zt(At()),Te=class extends Nt.default{};function le(){let n=new Te;return{emitter:n,createChainingEmitterMethod:(r,o)=>(...s)=>(n[r].apply(n,s),o),createBoundEmitterMethod:r=>(...o)=>n[r].apply(n,o)}}var St=Symbol("isPromiEvent");function ze(n){return!!n[St]}function O(n){let t=be(n),{createBoundEmitterMethod:e,createChainingEmitterMethod:r}=le(),o=Symbol("Promise.then"),s=Symbol("Promise.catch"),i=Symbol("Promise.finally"),a=(d,m)=>(...A)=>{let I=m[d].apply(m,A);return c(I)},c=d=>Object.assign(d,{[St]:!0,[o]:d[o]||d.then,[s]:d[s]||d.catch,[i]:d[i]||d.finally,then:a(o,d),catch:a(s,d),finally:a(i,d),on:r("on",d),once:r("once",d),addListener:r("addListener",d),off:r("off",d),removeListener:r("removeListener",d),removeAllListeners:r("removeAllListeners",d),emit:e("emit"),eventNames:e("eventNames"),listeners:e("listeners"),listenerCount:e("listenerCount")}),l=c(t.then(d=>(l.emit("done",d),l.emit("settled"),d),d=>{throw l.emit("error",d),l.emit("settled"),d}));return l.on(Ie.UserEventsOnReceived.ClosedByUser,()=>{l.emit(Ie.UserEventsEmit.ClosedByUser)}),l}function be(n){return new Promise((t,e)=>{let r=n(t,e);Promise.resolve(r).catch(e)})}var x=class{constructor(t){this.sdk=t}get overlay(){return this.sdk.overlay}request(t){let e=this.overlay.post(Q.MagicOutgoingWindowMessage.MAGIC_HANDLE_REQUEST,j(t)),r=O((s,i)=>{e.then(a=>{if(o(),a.hasError)i(new L(a.payload.error));else if(a.hasResult)s(a.payload.result);else throw Ge()}).catch(a=>{o(),i(a)})}),o=this.overlay.on(Q.MagicIncomingWindowMessage.MAGIC_HANDLE_EVENT,s=>{var a;let{response:i}=s.data;if(i.id===t.id&&((a=i.result)==null?void 0:a.event)){let{event:c,params:l=[]}=i.result;r.emit(c,...l)}});return r}createIntermediaryEvent(t,e){return o=>{let s=p(Q.MagicPayloadMethod.IntermediaryEvent,[{payloadId:e,eventType:t,args:o}]);this.request(s)}}};function Ye(n,t){let[e]=n.split(".").map(Number);return e>=t}var B={"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"},we=class extends x{loginWithMagicLink(t){let e=f.sdkName==="@magic-sdk/react-native"||f.sdkName==="@magic-sdk/react-native-bare"||f.sdkName==="@magic-sdk/react-native-expo";if(e&&Ye(f.version,19))throw new Error("loginWithMagicLink() is deprecated for this package, please utlize a passcode method like loginWithSMS or loginWithEmailOTP instead.");e&&U({method:"auth.loginWithMagicLink()",removalVersions:B,useInstead:"auth.loginWithEmailOTP()"}).log();let{email:r,showUI:o=!0,redirectURI:s,overrides:i,lifespan:a}=t,c=p(this.sdk.testMode?u.MagicPayloadMethod.LoginWithMagicLinkTestMode:u.MagicPayloadMethod.LoginWithMagicLink,[{email:r,showUI:o,redirectURI:s,overrides:i,lifespan:a}]);return this.request(c)}loginWithSMS(t){let{phoneNumber:e,showUI:r=!0,lifespan:o}=t,s=p(this.sdk.testMode?u.MagicPayloadMethod.LoginWithSmsTestMode:u.MagicPayloadMethod.LoginWithSms,[{phoneNumber:e,showUI:r,lifespan:o}]),i=this.request(s);return!r&&i&&(i.on(u.LoginWithSmsOTPEventEmit.VerifySmsOtp,a=>{this.createIntermediaryEvent(u.LoginWithSmsOTPEventEmit.VerifySmsOtp,s.id)(a)}),i.on(u.LoginWithSmsOTPEventEmit.Cancel,()=>{this.createIntermediaryEvent(u.LoginWithSmsOTPEventEmit.Cancel,s.id)()})),i}loginWithEmailOTP(t){let{email:e,showUI:r,deviceCheckUI:o,overrides:s,lifespan:i}=t,a=p(this.sdk.testMode?u.MagicPayloadMethod.LoginWithEmailOTPTestMode:u.MagicPayloadMethod.LoginWithEmailOTP,[{email:e,showUI:r,deviceCheckUI:o,overrides:s,lifespan:i}]),c=this.request(a);return!o&&c&&c.on(u.DeviceVerificationEventEmit.Retry,()=>{this.createIntermediaryEvent(u.DeviceVerificationEventEmit.Retry,a.id)()}),!r&&c&&(c.on(u.LoginWithEmailOTPEventEmit.VerifyEmailOtp,l=>{this.createIntermediaryEvent(u.LoginWithEmailOTPEventEmit.VerifyEmailOtp,a.id)(l)}),c.on(u.LoginWithEmailOTPEventEmit.VerifyMFACode,l=>{this.createIntermediaryEvent(u.LoginWithEmailOTPEventEmit.VerifyMFACode,a.id)(l)}),c.on(u.LoginWithEmailOTPEventEmit.LostDevice,()=>{this.createIntermediaryEvent(u.LoginWithEmailOTPEventEmit.LostDevice,a.id)()}),c.on(u.LoginWithEmailOTPEventEmit.VerifyRecoveryCode,l=>{this.createIntermediaryEvent(u.LoginWithEmailOTPEventEmit.VerifyRecoveryCode,a.id)(l)}),c.on(u.LoginWithEmailOTPEventEmit.Cancel,()=>{this.createIntermediaryEvent(u.LoginWithEmailOTPEventEmit.Cancel,a.id)()})),c}loginWithCredential(t){let{credentialOrQueryString:e,lifespan:r}=t||{},o=e!=null?e:"";if(!e&&f.platform==="web"){o=window.location.search;let i=window.location.origin+window.location.pathname;window.history.replaceState(null,"",i)}let s=p(this.sdk.testMode?u.MagicPayloadMethod.LoginWithCredentialTestMode:u.MagicPayloadMethod.LoginWithCredential,[o,r]);return this.request(s)}setAuthorizationToken(t){let e=p(u.MagicPayloadMethod.SetAuthorizationToken,[{jwt:t}]);return this.request(e)}updateEmailWithUI(t){let{email:e,showUI:r=!0}=t,o=p(this.sdk.testMode?u.MagicPayloadMethod.UpdateEmailTestMode:u.MagicPayloadMethod.UpdateEmail,[{email:e,showUI:r}]),s=this.request(o);return r||(s.on(u.RecencyCheckEventEmit.Retry,()=>{this.createIntermediaryEvent(u.RecencyCheckEventEmit.Retry,o.id)()}),s.on(u.RecencyCheckEventEmit.Cancel,()=>{this.createIntermediaryEvent(u.RecencyCheckEventEmit.Cancel,o.id)()}),s.on(u.RecencyCheckEventEmit.VerifyEmailOtp,i=>{this.createIntermediaryEvent(u.RecencyCheckEventEmit.VerifyEmailOtp,o.id)(i)}),s.on(u.RecencyCheckEventEmit.VerifyMFACode,i=>{this.createIntermediaryEvent(u.RecencyCheckEventEmit.VerifyMFACode,o.id)(i)}),s.on(u.UpdateEmailEventEmit.RetryWithNewEmail,i=>{this.createIntermediaryEvent(u.UpdateEmailEventEmit.RetryWithNewEmail,o.id)(i)}),s.on(u.UpdateEmailEventEmit.Cancel,()=>{this.createIntermediaryEvent(u.UpdateEmailEventEmit.Cancel,o.id)()}),s.on(u.UpdateEmailEventEmit.VerifyEmailOtp,i=>{this.createIntermediaryEvent(u.UpdateEmailEventEmit.VerifyEmailOtp,o.id)(i)})),s}};var h=require("@magic-sdk/types");var Z={};dt(Z,{clear:()=>Hn,getItem:()=>v,iterate:()=>Qe,key:()=>zn,keys:()=>Yn,length:()=>Xn,removeItem:()=>S,setItem:()=>C});var Pe;function J(n){return(...t)=>E(this,null,function*(){return Pe||(Pe=yield f.configureStorage()),yield Pe.ready(),Pe[n](...t)})}var v=J("getItem"),C=J("setItem"),S=J("removeItem"),Hn=J("clear"),Xn=J("length"),zn=J("key"),Yn=J("keys"),Qe=J("iterate");function Ze(){let n=window.crypto.getRandomValues(new Uint8Array(16));n[6]=n[6]&15|64,n[8]=n[8]&191|128;let t="";return t+=n[0].toString(16),t+=n[1].toString(16),t+=n[2].toString(16),t+=n[3].toString(16),t+="-",t+=n[4].toString(16),t+=n[5].toString(16),t+="-",t+=n[6].toString(16),t+=n[7].toString(16),t+="-",t+=n[8].toString(16),t+=n[9].toString(16),t+="-",t+=n[10].toString(16),t+=n[11].toString(16),t+=n[12].toString(16),t+=n[13].toString(16),t+=n[14].toString(16),t+=n[15].toString(16),t}var Me="STORE_KEY_PRIVATE_KEY",de="STORE_KEY_PUBLIC_JWK",Lt="ECDSA",Qn="P-256",Zn={name:Lt,namedCurve:Qn};function ee(){let n=typeof window!="undefined"&&!!window.crypto,t=n&&!!window.crypto.subtle;return n&&t}function er(){S(de),S(Me)}function et(){return E(this,null,function*(){let n=yield tr();if(!n){console.info("unable to create public key or webcrypto is unsupported");return}let{subtle:t}=window.crypto,e=yield v(Me);if(!e||!t){console.info("unable to find private key or webcrypto unsupported");return}let r={iat:Math.floor(new Date().getTime()/1e3),jti:Ze()},o={typ:"dpop+jwt",alg:"ES256",jwk:n},s={protected:$t(JSON.stringify(o)),claims:$t(JSON.stringify(r))},i=rr(`${s.protected}.${s.claims}`),a={name:Lt,hash:{name:"SHA-256"}},c=or(new Uint8Array(yield t.sign(a,e,i)));return`${s.protected}.${s.claims}.${c}`})}function tr(){return E(this,null,function*(){if(!ee()){console.info("webcrypto is not supported");return}return(yield v(de))||(yield nr()),v(de)})}function nr(){return E(this,null,function*(){let{subtle:n}=window.crypto,t=yield n.generateKey(Zn,!1,["sign"]),e=yield n.exportKey("jwk",t.publicKey);yield C(Me,t.privateKey),yield C(de,e)})}function $t(n){return Ot(sr(n))}function rr(n){return new TextEncoder().encode(n)}function Ot(n){return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+/g,"")}function sr(n){return encodeURIComponent(n).replace(/%([0-9A-F]{2})/g,(e,r)=>String.fromCharCode(parseInt(r,16)))}function or(n){let t="";return n.forEach(e=>{t+=String.fromCharCode(e)}),Ot(t)}var tt="ds",nt="ek",rt="iv",st="AES-GCM",ir=256;function te(){return E(this,null,function*(){let n=[];yield Qe((t,e,r)=>{e.startsWith(`${tt}_`)&&n.push(e)});for(let t of n)yield S(t)})}function _t(n){let t="",e=new Uint8Array(n),r=e.byteLength;for(let o=0;o<r;o++)t+=String.fromCharCode(e[o]);return window.btoa(t)}function kt(n){let t=window.atob(n),e=t.length,r=new Uint8Array(e);for(let o=0;o<e;o++)r[o]=t.charCodeAt(o);return r.buffer}function ar(){return E(this,null,function*(){if(!ee()){console.info("webcrypto is not supported");return}let{crypto:n}=window,t=yield v(rt);return t||n.getRandomValues(new Uint8Array(12))})}function cr(){return E(this,null,function*(){if(!ee()){console.info("webcrypto is not supported");return}let{subtle:n}=window.crypto,t=yield v(nt);return t||(yield n.generateKey({name:st,length:ir},!1,["encrypt","decrypt"]))})}function Dt(n,t){return E(this,null,function*(){let e=yield ar(),r=yield cr();if(!e||!r||!n)return;let o=kt(n),{subtle:s}=window.crypto,i=yield s.encrypt({name:st,iv:e},r,o),a=_t(i);yield C(`${tt}_${t}`,a),yield C(nt,r),yield C(rt,e)})}function qt(n){return E(this,null,function*(){let t=yield v(`${tt}_${n}`),e=yield v(rt),r=yield v(nt);if(!e||!t||!r||!ee())return;let{subtle:o}=window.crypto,s=yield o.decrypt({name:st,iv:e},r,kt(t));return _t(s)})}function xe(n,t){return t?new URL(n,t):new URL(n)}var Ce=class extends x{constructor(){super(...arguments);this.localForageKey="mc_active_wallet";this.localForageIsLoggedInKey="magic_auth_is_logged_in";this.userLoggedOutCallbacks=[]}getIdToken(e){let r=p(this.sdk.testMode?h.MagicPayloadMethod.GetIdTokenTestMode:h.MagicPayloadMethod.GetIdToken,[e]);return this.request(r)}generateIdToken(e){let r=p(this.sdk.testMode?h.MagicPayloadMethod.GenerateIdTokenTestMode:h.MagicPayloadMethod.GenerateIdToken,[e]);return this.request(r)}getInfo(){return E(this,null,function*(){let e=yield v(this.localForageKey),r=p(h.MagicPayloadMethod.GetInfo,[{walletType:e}]);return this.request(r)})}isLoggedIn(){return O((e,r)=>E(this,null,function*(){try{let o=!1;this.sdk.useStorageCache&&(o=(yield v(this.localForageIsLoggedInKey))==="true",o&&e(!0));let s=p(this.sdk.testMode?h.MagicPayloadMethod.IsLoggedInTestMode:h.MagicPayloadMethod.IsLoggedIn),i=yield this.request(s);this.sdk.useStorageCache&&(i?C(this.localForageIsLoggedInKey,!0):S(this.localForageIsLoggedInKey),o&&!i&&this.emitUserLoggedOut(!0)),e(i)}catch(o){r(o)}}))}logout(){return S(this.localForageKey),S(this.localForageIsLoggedInKey),te(),O((e,r)=>E(this,null,function*(){try{let o=p(this.sdk.testMode?h.MagicPayloadMethod.LogoutTestMode:h.MagicPayloadMethod.Logout),s=yield this.request(o);this.sdk.useStorageCache&&this.emitUserLoggedOut(s),e(s)}catch(o){r(o)}}))}requestInfoWithUI(e){let r=p(h.MagicPayloadMethod.RequestUserInfoWithUI,e?[e]:[]);return this.request(r)}showSettings(e){let{showUI:r=!0}=e||{},o=p(this.sdk.testMode?h.MagicPayloadMethod.UserSettingsTestMode:h.MagicPayloadMethod.UserSettings,[e]),s=this.request(o);return!r&&s&&(s.on(h.RecoveryFactorEventEmit.SendNewPhoneNumber,i=>{this.createIntermediaryEvent(h.RecoveryFactorEventEmit.SendNewPhoneNumber,o.id)(i)}),s.on(h.RecoveryFactorEventEmit.SendOtpCode,i=>{this.createIntermediaryEvent(h.RecoveryFactorEventEmit.SendOtpCode,o.id)(i)}),s.on(h.RecoveryFactorEventEmit.StartEditPhoneNumber,()=>{this.createIntermediaryEvent(h.RecoveryFactorEventEmit.StartEditPhoneNumber,o.id)()}),s.on(h.RecoveryFactorEventEmit.Cancel,()=>{this.createIntermediaryEvent(h.RecoveryFactorEventEmit.Cancel,o.id)()}),s.on(h.RecencyCheckEventEmit.VerifyEmailOtp,i=>{this.createIntermediaryEvent(h.RecencyCheckEventEmit.VerifyEmailOtp,o.id)(i)})),s}recoverAccount(e){let r=p(this.sdk.testMode?h.MagicPayloadMethod.RecoverAccountTestMode:h.MagicPayloadMethod.RecoverAccount,[e]);return this.request(r)}revealPrivateKey(){let e=p(h.MagicPayloadMethod.RevealPK);return this.request(e)}getMetadata(){U({method:"user.getMetadata()",removalVersions:B,useInstead:"user.getInfo()"}).log();let e=p(this.sdk.testMode?h.MagicPayloadMethod.GetMetadataTestMode:h.MagicPayloadMethod.GetMetadata);return this.request(e)}onUserLoggedOut(e){this.userLoggedOutCallbacks.push(e)}enableMFA(e){let{showUI:r=!0}=e,o=p(h.MagicPayloadMethod.EnableMFA,[{showUI:r}]),s=this.request(o);return!r&&s&&(s.on(h.EnableMFAEventEmit.VerifyMFACode,i=>{this.createIntermediaryEvent(h.EnableMFAEventEmit.VerifyMFACode,o.id)(i)}),s.on(h.EnableMFAEventEmit.Cancel,()=>{this.createIntermediaryEvent(h.EnableMFAEventEmit.Cancel,o.id)()})),s}disableMFA(e){let{showUI:r=!0}=e,o=p(h.MagicPayloadMethod.DisableMFA,[{showUI:r}]),s=this.request(o);return!r&&s&&(s.on(h.DisableMFAEventEmit.VerifyMFACode,i=>{this.createIntermediaryEvent(h.DisableMFAEventEmit.VerifyMFACode,o.id)(i)}),s.on(h.DisableMFAEventEmit.LostDevice,i=>{this.createIntermediaryEvent(h.DisableMFAEventEmit.LostDevice,o.id)(i)}),s.on(h.DisableMFAEventEmit.Cancel,()=>{this.createIntermediaryEvent(h.DisableMFAEventEmit.Cancel,o.id)()})),s}emitUserLoggedOut(e){this.userLoggedOutCallbacks.forEach(r=>{r(e)})}};var g=require("@magic-sdk/types");var Ae=class extends x{constructor(){super(...arguments);this.localForageKey="mc_active_wallet"}connectWithUI(){let e=O((r,o)=>E(this,null,function*(){try{if(this.isMetaMaskBrowser()&&(yield this.isWalletEnabled(g.Wallets.MetaMask))){let l=yield this.autoConnectIfWalletBrowser(g.Wallets.MetaMask);r(l);return}if(this.isCoinbaseWalletBrowser()&&(yield this.isWalletEnabled(g.Wallets.CoinbaseWallet))){let l=yield this.autoConnectIfWalletBrowser(g.Wallets.CoinbaseWallet);r(l);return}let s=this.getUserEnv(),i=p(g.MagicPayloadMethod.Login,[s]),a=this.request(i);a.on(g.Events.WalletSelected,l=>this.handleWalletSelected(H(V({},l),{payloadId:i.id}))),a.on("id-token-created",l=>{e.emit("id-token-created",l)});let c=yield a;c.error&&o(c),r(c)}catch(s){o(s)}}));return e}showUI(e){return this.request(p(g.MagicPayloadMethod.ShowUI,[e]))}showAddress(){return this.request(p(g.MagicPayloadMethod.ShowAddress))}showSendTokensUI(){return this.request(p(g.MagicPayloadMethod.ShowSendTokensUI))}showOnRamp(){return this.request(p(g.MagicPayloadMethod.ShowOnRamp))}showNFTs(){return this.request(p(g.MagicPayloadMethod.ShowNFTs))}showBalances(){return this.request(p(g.MagicPayloadMethod.ShowBalances))}sendGaslessTransaction(e,r){return this.request(p(g.MagicPayloadMethod.SendGaslessTransaction,[e,r]))}getInfo(){return E(this,null,function*(){U({method:"wallet.getInfo()",removalVersions:B,useInstead:"user.getInfo()"}).log();let e=yield v(this.localForageKey),r=p(g.MagicPayloadMethod.GetInfo,[{walletType:e}]);return this.request(r)})}disconnect(){U({method:"wallet.disconnect()",removalVersions:B,useInstead:"user.logout()"}).log(),S(this.localForageKey),te();let e=p(g.MagicPayloadMethod.Disconnect);return this.request(e)}requestUserInfoWithUI(e){U({method:"wallet.requestUserInfoWithUI()",removalVersions:B,useInstead:"user.requestUserInfoWithUI()"}).log();let r=p(g.MagicPayloadMethod.RequestUserInfoWithUI,e?[e]:[]);return this.request(r)}getProvider(){return E(this,null,function*(){switch(yield v(this.localForageKey)){case g.Wallets.MetaMask:return this.getMetaMaskProvider();case g.Wallets.CoinbaseWallet:return this.getCoinbaseProvider();default:return this.sdk.rpcProvider}})}isMetaMaskInstalled(){var e,r,o;return((e=window.ethereum)==null?void 0:e.isMetaMask)||!!((o=(r=window.ethereum)==null?void 0:r.providers)!=null&&o.find(s=>s==null?void 0:s.isMetaMask))}isMetaMaskBrowser(){return this.isMobile()&&this.isMetaMaskInstalled()}getMetaMaskProvider(){var e,r;return((r=(e=window.ethereum)==null?void 0:e.providers)==null?void 0:r.find(o=>o==null?void 0:o.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,r,o;return((e=window.ethereum)==null?void 0:e.isCoinbaseWallet)||!!((o=(r=window.ethereum)==null?void 0:r.providers)!=null&&o.find(s=>s==null?void 0:s.isCoinbaseWallet))}isCoinbaseWalletBrowser(){var e;return!!((e=window.ethereum)!=null&&e.isCoinbaseBrowser)}getCoinbaseProvider(){var e,r;return((r=(e=window.ethereum)==null?void 0:e.providers)==null?void 0:r.find(o=>o==null?void 0:o.isCoinbaseWallet))||window.ethereum}connectToCoinbaseWallet(){if(this.isMobile()&&!this.isCoinbaseWalletBrowser()){let r=`https://go.cb-w.com/dapp?cb_url=${encodeURIComponent(window.location.href)}`;window.location.href=r}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 g.Wallets.MetaMask:return this.connectToMetaMask();case g.Wallets.CoinbaseWallet:return this.connectToCoinbaseWallet();default:throw new Error(`Invalid provider: ${e}. Must be one of "metamask" or "coinbase_wallet".`)}}isWalletEnabled(e){let r=p("mc_is_wallet_enabled",[{wallet:e}]);return this.request(r)}handleWalletSelected(e){return E(this,null,function*(){try{let r=yield this.connectToThirdPartyWallet(e.wallet);yield C(this.localForageKey,e.wallet),this.createIntermediaryEvent(g.Events.WalletConnected,e.payloadId)(r)}catch(r){console.error(r),this.createIntermediaryEvent(g.Events.WalletRejected,e.payloadId)()}})}autoConnectIfWalletBrowser(e){return E(this,null,function*(){let r;e===g.Wallets.MetaMask&&(r=yield this.getMetaMaskProvider().request({method:"eth_requestAccounts"})),e===g.Wallets.CoinbaseWallet&&(r=yield this.getCoinbaseProvider().request({method:"eth_requestAccounts"})),yield C(this.localForageKey,e);let o=p(g.MagicPayloadMethod.AutoConnect,[{wallet:e,address:r}]);return this.request(o)})}};var ue=require("@magic-sdk/types");var{createBoundEmitterMethod:Ne,createChainingEmitterMethod:ne}=le(),Se=class extends x{constructor(){super(...arguments);this.isMagic=!0;this.on=ne("on",this);this.once=ne("once",this);this.addListener=ne("addListener",this);this.off=ne("off",this);this.removeListener=ne("removeListener",this);this.removeAllListeners=ne("removeAllListeners",this);this.emit=Ne("emit");this.eventNames=Ne("eventNames");this.listeners=Ne("listeners");this.listenerCount=Ne("listenerCount")}sendAsync(e,r){if(!r)throw Be({procedure:"Magic.rpcProvider.sendAsync",argument:1,expected:"function",received:r===null?"null":typeof r});if(Array.isArray(e))this.overlay.post(ue.MagicOutgoingWindowMessage.MAGIC_HANDLE_REQUEST,e.map(o=>{let s=j(o);return this.prefixPayloadMethodForTestMode(s),s})).then(o=>{r(null,o.map(s=>H(V({},s.payload),{error:s.hasError?new L(s.payload.error):null})))});else{let o=j(e);this.prefixPayloadMethodForTestMode(o),this.overlay.post(ue.MagicOutgoingWindowMessage.MAGIC_HANDLE_REQUEST,o).then(s=>{r(s.hasError?new L(s.payload.error):null,s.payload)})}}send(e,r){if(typeof e=="string"){let s=p(e,Array.isArray(r)?r:[]);return this.request(s)}if(Array.isArray(e)||!!r){this.sendAsync(e,r);return}let o=Ve();return o.log(),new W(e).applyError({code:-32603,message:o.rawMessage}).payload}enable(){let e=p(ue.MagicPayloadMethod.Login);return this.request(e)}request(e){return this.prefixPayloadMethodForTestMode(e),super.request(e)}prefixPayloadMethodForTestMode(e){let r="testMode/eth/";this.sdk.testMode&&(e.method=`${r}${e.method}`)}};var Ut=["request","overlay","sdk"];function lr(n){let t=Object.getPrototypeOf(n),e=[t];for(;t!==x.prototype;)t=Object.getPrototypeOf(t),e.push(t);return e}var $e=class extends x{constructor(){super(void 0);this.__sdk_access_field_descriptors__=new Map;this.__is_initialized__=!1;this.utils={createPromiEvent:O,isPromiEvent:ze,encodeJSON:ae,decodeJSON:qe,createJsonRpcRequestPayload:p,standardizeJsonRpcRequestPayload:j,storage:Z};let e=[this,...lr(this)];Ut.forEach(r=>{let o=e.map(c=>Object.getOwnPropertyDescriptor(c,r)),s=o.findIndex(c=>!!c),i=s>0,a=o[s];a&&(this.__sdk_access_field_descriptors__.set(r,{descriptor:a,isPrototypeField:i}),Object.defineProperty(this,r,{configurable:!0,get:()=>{throw Ke(r)}}))})}init(e){this.__is_initialized__||(Ut.forEach(r=>{if(this.__sdk_access_field_descriptors__.has(r)){let{descriptor:o,isPrototypeField:s}=this.__sdk_access_field_descriptors__.get(r);s?delete this[r]:Object.defineProperty(this,r,o)}}),this.sdk=e,this.__is_initialized__=!0)}createDeprecationWarning(e){let{method:r,removalVersion:o,useInstead:s}=e,i=s?` Use \`${s}\` instead.`:"",a=`\`${r}\` will be removed from this Extension in version \`${o}\`.${i}`;return new Y(this,"DEPRECATION_NOTICE",a)}createWarning(e,r){return new Y(this,e,r)}createError(e,r,o){return new K(this,e,r,o)}},ot=class extends $e{},_=class extends $e{};_.Internal=ot,_.Anonymous="anonymous extension";var Le=require("@magic-sdk/types");var Oe=class extends x{purchase(t){let e=p(Le.MagicPayloadMethod.NFTPurchase,[t]);return this.request(e)}checkout(t){let e=p(Le.MagicPayloadMethod.NFTCheckout,[t]);return this.request(e)}transfer(t){let e=p(Le.MagicPayloadMethod.NFTTransfer,[t]);return this.request(e)}};function Ft(n){return n.compat&&n.compat[f.sdkName]!=null?typeof n.compat[f.sdkName]=="string"?It(bt(f.version),n.compat[f.sdkName]):!!n.compat[f.sdkName]:!0}function dr(n,t,e){return!t&&!e?`${n}_eth_mainnet`:e?`${n}_${JSON.stringify(e)}`:t?typeof t=="string"?`${n}_eth_${t}`:`${n}_${t.rpcUrl}_${t.chainId}_${t.chainType}`:`${n}_unknown`}function ur(n){var o;let t=(o=n==null?void 0:n.extensions)!=null?o:[],e={},r=[];if(Array.isArray(t)?t.forEach(s=>{Ft(s)?(s.init(this),(s.name||s.name!==_.Anonymous)&&(this[s.name]=s),s instanceof _.Internal&&(z(s.config)||(e[s.name]=s.config))):r.push(s)}):Object.keys(t).forEach(s=>{if(Ft(t[s])){t[s].init(this);let i=t[s];this[s]=i,i instanceof _.Internal&&(z(i.config)||(e[t[s].name]=i.config))}else r.push(t[s])}),r.length)throw je(r);return e}var he=class{constructor(t,e){this.apiKey=t;var i;if(!t)throw We();f.platform==="react-native"&&(e==null?void 0:e.endpoint)&&He().log();let{defaultEndpoint:r,version:o}=f;this.testMode=!!(e!=null&&e.testMode),this.useStorageCache=!!(e!=null&&e.useStorageCache),this.endpoint=xe((i=e==null?void 0:e.endpoint)!=null?i:r).origin,this.auth=new we(this),this.user=new Ce(this),this.wallet=new Ae(this),this.nft=new Oe(this),this.rpcProvider=new Se(this);let s=ur.call(this,e);this.parameters=ae(H(V({API_KEY:this.apiKey,DOMAIN_ORIGIN:window.location?window.location.origin:"",ETH_NETWORK:e==null?void 0:e.network,host:xe(this.endpoint).host,sdk:Pt[f.sdkName],version:o,ext:z(s)?void 0:s,locale:(e==null?void 0:e.locale)||"en_US"},f.bundleId?{bundleId:f.bundleId}:{}),{meta:e==null?void 0:e.meta})),this.networkHash=dr(this.apiKey,e==null?void 0:e.network,z(s)?void 0:s),e!=null&&e.deferPreload||this.preload()}get overlay(){if(!he.__overlays__.has(this.parameters)){let t=new f.ViewController(this.endpoint,this.parameters,this.networkHash);t.init(),he.__overlays__.set(this.parameters,t)}return he.__overlays__.get(this.parameters)}preload(){return E(this,null,function*(){yield this.overlay.checkIsReadyForRequest})}},pe=he;pe.__overlays__=new Map;var G=require("@magic-sdk/types");function pr(n,t){return t&&Array.isArray(n)?n.find(e=>e.id===t):n}function hr(n,t){var o;let e=(o=t.data.response)==null?void 0:o.id,r=pr(n,e);if(e&&r){let s=new W(r).applyResult(t.data.response.result).applyError(t.data.response.error);return{id:e,response:s}}return{}}function mr(n,t,e){return E(this,null,function*(){var a;let r=yield v("rt"),o;if(f.platform==="web")try{o=(a=yield v("jwt"))!=null?a:yield et()}catch(c){console.error("webcrypto error",c)}let s={msgType:n,payload:t};o&&(s.jwt=o),o&&r&&(s.rt=r);let i=yield qt(e);return i&&(s.deviceShare=i),s})}function fr(n){return E(this,null,function*(){!n.data.rt||(yield C("rt",n.data.rt))})}var _e=class{constructor(t,e,r){this.endpoint=t;this.parameters=e;this.networkHash=r;this.messageHandlers=new Set;this.isConnectedToInternet=!0;this.checkIsReadyForRequest=this.waitForReady(),this.isReadyForRequest=!1,this.listen()}post(t,e){return E(this,null,function*(){return be((r,o)=>E(this,null,function*(){if(!this.isConnectedToInternet){let d=Je();o(d)}this.isReadyForRequest||(yield this.waitForReady());let s=[],i=Array.isArray(e)?e.map(d=>d.id):[],a=yield mr(`${t}-${this.parameters}`,e,this.networkHash);yield this._post(a);let c=d=>m=>{var it;let{id:A,response:I}=hr(e,m);if(fr(m),((it=I==null?void 0:I.payload.error)==null?void 0:it.message)==="User denied account access.")te();else if(m.data.deviceShare){let{deviceShare:Wt}=m.data;Dt(Wt,this.networkHash)}A&&I&&Array.isArray(e)&&i.includes(A)?(s.push(I),s.length===e.length&&(d(),r(s))):A&&I&&!Array.isArray(e)&&A===e.id&&(d(),r(I))},l=this.on(G.MagicIncomingWindowMessage.MAGIC_HANDLE_RESPONSE,c(()=>l()))}))})}on(t,e){let r=e.bind(window),o=s=>{s.data.msgType===`${t}-${this.parameters}`&&r(s)};return this.messageHandlers.add(o),()=>this.messageHandlers.delete(o)}waitForReady(){return new Promise(t=>{let e=this.on(G.MagicIncomingWindowMessage.MAGIC_OVERLAY_READY,()=>{this.isReadyForRequest=!0,t(),e()});setTimeout(()=>{this.isReadyForRequest=!0,t(),e()},15e3)})}listen(){this.on(G.MagicIncomingWindowMessage.MAGIC_HIDE_OVERLAY,()=>{this.hideOverlay()}),this.on(G.MagicIncomingWindowMessage.MAGIC_SHOW_OVERLAY,()=>{this.showOverlay()}),this.on(G.MagicIncomingWindowMessage.MAGIC_SEND_PRODUCT_ANNOUNCEMENT,t=>{t.data.response.result.product_announcement&&new q(G.SDKWarningCode.ProductAnnouncement,t.data.response.result.product_announcement).log()})}};
//# sourceMappingURL=index.js.map

@@ -1,6 +0,6 @@

"use strict";var Jt=Object.create;var re=Object.defineProperty,Gt=Object.defineProperties,Kt=Object.getOwnPropertyDescriptor,jt=Object.getOwnPropertyDescriptors,Bt=Object.getOwnPropertyNames,at=Object.getOwnPropertySymbols,Vt=Object.getPrototypeOf,lt=Object.prototype.hasOwnProperty,Ht=Object.prototype.propertyIsEnumerable;var ct=(n,t,e)=>t in n?re(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,V=(n,t)=>{for(var e in t||(t={}))lt.call(t,e)&&ct(n,e,t[e]);if(at)for(var e of at(t))Ht.call(t,e)&&ct(n,e,t[e]);return n},H=(n,t)=>Gt(n,jt(t));var Xt=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports),dt=(n,t)=>{for(var e in t)re(n,e,{get:t[e],enumerable:!0})},ut=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Bt(t))!lt.call(n,o)&&o!==e&&re(n,o,{get:()=>t[o],enumerable:!(r=Kt(t,o))||r.enumerable});return n};var zt=(n,t,e)=>(e=n!=null?Jt(Vt(n)):{},ut(t||!n||!n.__esModule?re(e,"default",{value:n,enumerable:!0}):e,n)),Yt=n=>ut(re({},"__esModule",{value:!0}),n);var E=(n,t,e)=>new Promise((r,o)=>{var s=c=>{try{a(e.next(c))}catch(l){o(l)}},i=c=>{try{a(e.throw(c))}catch(l){o(l)}},a=c=>c.done?r(c.value):Promise.resolve(c.value).then(s,i);a((e=e.apply(n,t)).next())});var At=Xt(($r,Xe)=>{"use strict";var Bn=Object.prototype.hasOwnProperty,M="~";function ce(){}Object.create&&(ce.prototype=Object.create(null),new ce().__proto__||(M=!1));function Vn(n,t,e){this.fn=n,this.context=t,this.once=e||!1}function Ct(n,t,e,r,o){if(typeof e!="function")throw new TypeError("The listener must be a function");var s=new Vn(e,r||n,o),i=M?M+t:t;return n._events[i]?n._events[i].fn?n._events[i]=[n._events[i],s]:n._events[i].push(s):(n._events[i]=s,n._eventsCount++),n}function ve(n,t){--n._eventsCount===0?n._events=new ce:delete n._events[t]}function w(){this._events=new ce,this._eventsCount=0}w.prototype.eventNames=function(){var t=[],e,r;if(this._eventsCount===0)return t;for(r in e=this._events)Bn.call(e,r)&&t.push(M?r.slice(1):r);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(e)):t};w.prototype.listeners=function(t){var e=M?M+t:t,r=this._events[e];if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,i=new Array(s);o<s;o++)i[o]=r[o].fn;return i};w.prototype.listenerCount=function(t){var e=M?M+t:t,r=this._events[e];return r?r.fn?1:r.length:0};w.prototype.emit=function(t,e,r,o,s,i){var a=M?M+t:t;if(!this._events[a])return!1;var c=this._events[a],l=arguments.length,d,m;if(c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,e),!0;case 3:return c.fn.call(c.context,e,r),!0;case 4:return c.fn.call(c.context,e,r,o),!0;case 5:return c.fn.call(c.context,e,r,o,s),!0;case 6:return c.fn.call(c.context,e,r,o,s,i),!0}for(m=1,d=new Array(l-1);m<l;m++)d[m-1]=arguments[m];c.fn.apply(c.context,d)}else{var A=c.length,I;for(m=0;m<A;m++)switch(c[m].once&&this.removeListener(t,c[m].fn,void 0,!0),l){case 1:c[m].fn.call(c[m].context);break;case 2:c[m].fn.call(c[m].context,e);break;case 3:c[m].fn.call(c[m].context,e,r);break;case 4:c[m].fn.call(c[m].context,e,r,o);break;default:if(!d)for(I=1,d=new Array(l-1);I<l;I++)d[I-1]=arguments[I];c[m].fn.apply(c[m].context,d)}}return!0};w.prototype.on=function(t,e,r){return Ct(this,t,e,r,!1)};w.prototype.once=function(t,e,r){return Ct(this,t,e,r,!0)};w.prototype.removeListener=function(t,e,r,o){var s=M?M+t:t;if(!this._events[s])return this;if(!e)return ve(this,s),this;var i=this._events[s];if(i.fn)i.fn===e&&(!o||i.once)&&(!r||i.context===r)&&ve(this,s);else{for(var a=0,c=[],l=i.length;a<l;a++)(i[a].fn!==e||o&&!i[a].once||r&&i[a].context!==r)&&c.push(i[a]);c.length?this._events[s]=c.length===1?c[0]:c:ve(this,s)}return this};w.prototype.removeAllListeners=function(t){var e;return t?(e=M?M+t:t,this._events[e]&&ve(this,e)):(this._events=new ce,this._eventsCount=0),this};w.prototype.off=w.prototype.removeListener;w.prototype.addListener=w.prototype.on;w.prefixed=M;w.EventEmitter=w;typeof Xe<"u"&&(Xe.exports=w)});var Er={};dt(Er,{Extension:()=>_,MagicExtensionError:()=>K,MagicExtensionWarning:()=>Y,MagicRPCError:()=>L,MagicSDKError:()=>$,MagicSDKWarning:()=>D,SDKBase:()=>pe,STORE_KEY_PRIVATE_KEY:()=>Me,STORE_KEY_PUBLIC_JWK:()=>de,TypedEmitter:()=>Te,ViewController:()=>_e,clearKeys:()=>er,createDeprecationWarning:()=>U,createDuplicateIframeWarning:()=>Jn,createExtensionNotInitializedError:()=>Ke,createIncompatibleExtensionsError:()=>je,createInvalidArgumentError:()=>Be,createJwt:()=>et,createMalformedResponseError:()=>Ge,createMissingApiKeyError:()=>We,createModalNotReadyError:()=>Je,createPromiEvent:()=>O,createPromise:()=>be,createReactNativeEndpointConfigurationWarning:()=>He,createSDK:()=>wt,createSynchronousWeb3MethodWarning:()=>Ve,createTypedEmitter:()=>le,createURL:()=>xe,decodeJSON:()=>De,encodeJSON:()=>ae,getPayloadId:()=>Re,isEmpty:()=>z,isJsonRpcErrorCode:()=>Fe,isJsonRpcRequestPayload:()=>Fn,isJsonRpcResponsePayload:()=>Ue,isMagicPayloadMethod:()=>Wn,isMajorVersionAtLeast:()=>Ye,isPromiEvent:()=>ze,isWebCryptoSupported:()=>ee,storage:()=>Z,uuid:()=>Ze});module.exports=Yt(Er);function Qt(n){let t={exports:{}};return n(t,t.exports),t.exports}var Zt=Number.MAX_SAFE_INTEGER||9007199254740991;var qe={SEMVER_SPEC_VERSION:"2.0.0",MAX_LENGTH:256,MAX_SAFE_INTEGER:Zt,MAX_SAFE_COMPONENT_LENGTH:16},en=typeof process=="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...n)=>console.error("SEMVER",...n):()=>{},g=en,ie=Qt(function(n,t){let{MAX_SAFE_COMPONENT_LENGTH:e}=qe,r=(t=n.exports={}).re=[],o=t.src=[],s=t.t={},i=0,a=(c,l,d)=>{let m=i++;g(m,l),s[c]=m,o[m]=l,r[m]=new RegExp(l,d?"g":void 0)};a("NUMERICIDENTIFIER","0|[1-9]\\d*"),a("NUMERICIDENTIFIERLOOSE","[0-9]+"),a("NONNUMERICIDENTIFIER","\\d*[a-zA-Z-][a-zA-Z0-9-]*"),a("MAINVERSION",`(${o[s.NUMERICIDENTIFIER]})\\.(${o[s.NUMERICIDENTIFIER]})\\.(${o[s.NUMERICIDENTIFIER]})`),a("MAINVERSIONLOOSE",`(${o[s.NUMERICIDENTIFIERLOOSE]})\\.(${o[s.NUMERICIDENTIFIERLOOSE]})\\.(${o[s.NUMERICIDENTIFIERLOOSE]})`),a("PRERELEASEIDENTIFIER",`(?:${o[s.NUMERICIDENTIFIER]}|${o[s.NONNUMERICIDENTIFIER]})`),a("PRERELEASEIDENTIFIERLOOSE",`(?:${o[s.NUMERICIDENTIFIERLOOSE]}|${o[s.NONNUMERICIDENTIFIER]})`),a("PRERELEASE",`(?:-(${o[s.PRERELEASEIDENTIFIER]}(?:\\.${o[s.PRERELEASEIDENTIFIER]})*))`),a("PRERELEASELOOSE",`(?:-?(${o[s.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${o[s.PRERELEASEIDENTIFIERLOOSE]})*))`),a("BUILDIDENTIFIER","[0-9A-Za-z-]+"),a("BUILD",`(?:\\+(${o[s.BUILDIDENTIFIER]}(?:\\.${o[s.BUILDIDENTIFIER]})*))`),a("FULLPLAIN",`v?${o[s.MAINVERSION]}${o[s.PRERELEASE]}?${o[s.BUILD]}?`),a("FULL",`^${o[s.FULLPLAIN]}$`),a("LOOSEPLAIN",`[v=\\s]*${o[s.MAINVERSIONLOOSE]}${o[s.PRERELEASELOOSE]}?${o[s.BUILD]}?`),a("LOOSE",`^${o[s.LOOSEPLAIN]}$`),a("GTLT","((?:<|>)?=?)"),a("XRANGEIDENTIFIERLOOSE",`${o[s.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),a("XRANGEIDENTIFIER",`${o[s.NUMERICIDENTIFIER]}|x|X|\\*`),a("XRANGEPLAIN",`[v=\\s]*(${o[s.XRANGEIDENTIFIER]})(?:\\.(${o[s.XRANGEIDENTIFIER]})(?:\\.(${o[s.XRANGEIDENTIFIER]})(?:${o[s.PRERELEASE]})?${o[s.BUILD]}?)?)?`),a("XRANGEPLAINLOOSE",`[v=\\s]*(${o[s.XRANGEIDENTIFIERLOOSE]})(?:\\.(${o[s.XRANGEIDENTIFIERLOOSE]})(?:\\.(${o[s.XRANGEIDENTIFIERLOOSE]})(?:${o[s.PRERELEASELOOSE]})?${o[s.BUILD]}?)?)?`),a("XRANGE",`^${o[s.GTLT]}\\s*${o[s.XRANGEPLAIN]}$`),a("XRANGELOOSE",`^${o[s.GTLT]}\\s*${o[s.XRANGEPLAINLOOSE]}$`),a("COERCE",`(^|[^\\d])(\\d{1,${e}})(?:\\.(\\d{1,${e}}))?(?:\\.(\\d{1,${e}}))?(?:$|[^\\d])`),a("COERCERTL",o[s.COERCE],!0),a("LONETILDE","(?:~>?)"),a("TILDETRIM",`(\\s*)${o[s.LONETILDE]}\\s+`,!0),t.tildeTrimReplace="$1~",a("TILDE",`^${o[s.LONETILDE]}${o[s.XRANGEPLAIN]}$`),a("TILDELOOSE",`^${o[s.LONETILDE]}${o[s.XRANGEPLAINLOOSE]}$`),a("LONECARET","(?:\\^)"),a("CARETTRIM",`(\\s*)${o[s.LONECARET]}\\s+`,!0),t.caretTrimReplace="$1^",a("CARET",`^${o[s.LONECARET]}${o[s.XRANGEPLAIN]}$`),a("CARETLOOSE",`^${o[s.LONECARET]}${o[s.XRANGEPLAINLOOSE]}$`),a("COMPARATORLOOSE",`^${o[s.GTLT]}\\s*(${o[s.LOOSEPLAIN]})$|^$`),a("COMPARATOR",`^${o[s.GTLT]}\\s*(${o[s.FULLPLAIN]})$|^$`),a("COMPARATORTRIM",`(\\s*)${o[s.GTLT]}\\s*(${o[s.LOOSEPLAIN]}|${o[s.XRANGEPLAIN]})`,!0),t.comparatorTrimReplace="$1$2$3",a("HYPHENRANGE",`^\\s*(${o[s.XRANGEPLAIN]})\\s+-\\s+(${o[s.XRANGEPLAIN]})\\s*$`),a("HYPHENRANGELOOSE",`^\\s*(${o[s.XRANGEPLAINLOOSE]})\\s+-\\s+(${o[s.XRANGEPLAINLOOSE]})\\s*$`),a("STAR","(<|>)?=?\\s*\\*"),a("GTE0","^\\s*>=\\s*0.0.0\\s*$"),a("GTE0PRE","^\\s*>=\\s*0.0.0-0\\s*$")}),pt=/^[0-9]+$/,Tt=(n,t)=>{let e=pt.test(n),r=pt.test(t);return e&&r&&(n=+n,t=+t),n===t?0:e&&!r?-1:r&&!e?1:n<t?-1:1},tn=(n,t)=>Tt(t,n),nn={compareIdentifiers:Tt,rcompareIdentifiers:tn},{MAX_LENGTH:ht,MAX_SAFE_INTEGER:me}=qe,{re:mt,t:ft}=ie,{compareIdentifiers:se}=nn,R=class{constructor(t,e){if(e&&typeof e=="object"||(e={loose:!!e,includePrerelease:!1}),t instanceof R){if(t.loose===!!e.loose&&t.includePrerelease===!!e.includePrerelease)return t;t=t.version}else if(typeof t!="string")throw new TypeError(`Invalid Version: ${t}`);if(t.length>ht)throw new TypeError(`version is longer than ${ht} characters`);g("SemVer",t,e),this.options=e,this.loose=!!e.loose,this.includePrerelease=!!e.includePrerelease;let r=t.trim().match(e.loose?mt[ft.LOOSE]:mt[ft.FULL]);if(!r)throw new TypeError(`Invalid Version: ${t}`);if(this.raw=t,this.major=+r[1],this.minor=+r[2],this.patch=+r[3],this.major>me||this.major<0)throw new TypeError("Invalid major version");if(this.minor>me||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>me||this.patch<0)throw new TypeError("Invalid patch version");r[4]?this.prerelease=r[4].split(".").map(o=>{if(/^[0-9]+$/.test(o)){let s=+o;if(s>=0&&s<me)return s}return o}):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(t){if(g("SemVer.compare",this.version,this.options,t),!(t instanceof R)){if(typeof t=="string"&&t===this.version)return 0;t=new R(t,this.options)}return t.version===this.version?0:this.compareMain(t)||this.comparePre(t)}compareMain(t){return t instanceof R||(t=new R(t,this.options)),se(this.major,t.major)||se(this.minor,t.minor)||se(this.patch,t.patch)}comparePre(t){if(t instanceof R||(t=new R(t,this.options)),this.prerelease.length&&!t.prerelease.length)return-1;if(!this.prerelease.length&&t.prerelease.length)return 1;if(!this.prerelease.length&&!t.prerelease.length)return 0;let e=0;do{let r=this.prerelease[e],o=t.prerelease[e];if(g("prerelease compare",e,r,o),r===void 0&&o===void 0)return 0;if(o===void 0)return 1;if(r===void 0)return-1;if(r!==o)return se(r,o)}while(++e)}compareBuild(t){t instanceof R||(t=new R(t,this.options));let e=0;do{let r=this.build[e],o=t.build[e];if(g("prerelease compare",e,r,o),r===void 0&&o===void 0)return 0;if(o===void 0)return 1;if(r===void 0)return-1;if(r!==o)return se(r,o)}while(++e)}inc(t,e){switch(t){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",e);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",e);break;case"prepatch":this.prerelease.length=0,this.inc("patch",e),this.inc("pre",e);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",e),this.inc("pre",e);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)}e&&(this.prerelease[0]===e?isNaN(this.prerelease[1])&&(this.prerelease=[e,0]):this.prerelease=[e,0]);break;default:throw new Error(`invalid increment argument: ${t}`)}return this.format(),this.raw=this.version,this}},rn=(n,t,e)=>new R(n,e).compare(new R(t,e)),X=rn,sn=(n,t,e)=>X(n,t,e)===0,on=sn,an=(n,t,e)=>X(n,t,e)!==0,cn=an,ln=(n,t,e)=>X(n,t,e)>0,dn=ln,un=(n,t,e)=>X(n,t,e)>=0,pn=un,hn=(n,t,e)=>X(n,t,e)<0,mn=hn,fn=(n,t,e)=>X(n,t,e)<=0,En=fn,gn=(n,t,e,r)=>{switch(t){case"===":return typeof n=="object"&&(n=n.version),typeof e=="object"&&(e=e.version),n===e;case"!==":return typeof n=="object"&&(n=n.version),typeof e=="object"&&(e=e.version),n!==e;case"":case"=":case"==":return on(n,e,r);case"!=":return cn(n,e,r);case">":return dn(n,e,r);case">=":return pn(n,e,r);case"<":return mn(n,e,r);case"<=":return En(n,e,r);default:throw new TypeError(`Invalid operator: ${t}`)}},ke=gn,oe=Symbol("SemVer ANY"),F=class{static get ANY(){return oe}constructor(t,e){if(e&&typeof e=="object"||(e={loose:!!e,includePrerelease:!1}),t instanceof F){if(t.loose===!!e.loose)return t;t=t.value}g("comparator",t,e),this.options=e,this.loose=!!e.loose,this.parse(t),this.semver===oe?this.value="":this.value=this.operator+this.semver.version,g("comp",this)}parse(t){let e=this.options.loose?Et[gt.COMPARATORLOOSE]:Et[gt.COMPARATOR],r=t.match(e);if(!r)throw new TypeError(`Invalid comparator: ${t}`);this.operator=r[1]!==void 0?r[1]:"",this.operator==="="&&(this.operator=""),r[2]?this.semver=new R(r[2],this.options.loose):this.semver=oe}toString(){return this.value}test(t){if(g("Comparator.test",t,this.options.loose),this.semver===oe||t===oe)return!0;if(typeof t=="string")try{t=new R(t,this.options)}catch(e){return!1}return ke(t,this.operator,this.semver,this.options)}intersects(t,e){if(!(t instanceof F))throw new TypeError("a Comparator is required");if(e&&typeof e=="object"||(e={loose:!!e,includePrerelease:!1}),this.operator==="")return this.value===""||new k(t.value,e).test(this.value);if(t.operator==="")return t.value===""||new k(this.value,e).test(t.semver);let r=!(this.operator!==">="&&this.operator!==">"||t.operator!==">="&&t.operator!==">"),o=!(this.operator!=="<="&&this.operator!=="<"||t.operator!=="<="&&t.operator!=="<"),s=this.semver.version===t.semver.version,i=!(this.operator!==">="&&this.operator!=="<="||t.operator!==">="&&t.operator!=="<="),a=ke(this.semver,"<",t.semver,e)&&(this.operator===">="||this.operator===">")&&(t.operator==="<="||t.operator==="<"),c=ke(this.semver,">",t.semver,e)&&(this.operator==="<="||this.operator==="<")&&(t.operator===">="||t.operator===">");return r||o||s&&i||a||c}},{re:Et,t:gt}=ie,k=class{constructor(t,e){if(e&&typeof e=="object"||(e={loose:!!e,includePrerelease:!1}),t instanceof k)return t.loose===!!e.loose&&t.includePrerelease===!!e.includePrerelease?t:new k(t.raw,e);if(t instanceof F)return this.raw=t.value,this.set=[[t]],this.format(),this;if(this.options=e,this.loose=!!e.loose,this.includePrerelease=!!e.includePrerelease,this.raw=t,this.set=t.split(/\s*\|\|\s*/).map(r=>this.parseRange(r.trim())).filter(r=>r.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${t}`);this.format()}format(){return this.range=this.set.map(t=>t.join(" ").trim()).join("||").trim(),this.range}toString(){return this.range}parseRange(t){let{loose:e}=this.options;t=t.trim();let r=e?b[T.HYPHENRANGELOOSE]:b[T.HYPHENRANGE];t=t.replace(r,Nn(this.options.includePrerelease)),g("hyphen replace",t),t=t.replace(b[T.COMPARATORTRIM],yn),g("comparator trim",t,b[T.COMPARATORTRIM]),t=(t=(t=t.replace(b[T.TILDETRIM],Rn)).replace(b[T.CARETTRIM],vn)).split(/\s+/).join(" ");let o=e?b[T.COMPARATORLOOSE]:b[T.COMPARATOR];return t.split(" ").map(s=>Tn(s,this.options)).join(" ").split(/\s+/).map(s=>An(s,this.options)).filter(this.options.loose?s=>!!s.match(o):()=>!0).map(s=>new F(s,this.options))}intersects(t,e){if(!(t instanceof k))throw new TypeError("a Range is required");return this.set.some(r=>yt(r,e)&&t.set.some(o=>yt(o,e)&&r.every(s=>o.every(i=>s.intersects(i,e)))))}test(t){if(!t)return!1;if(typeof t=="string")try{t=new R(t,this.options)}catch(e){return!1}for(let e=0;e<this.set.length;e++)if(Sn(this.set[e],t,this.options))return!0;return!1}},{re:b,t:T,comparatorTrimReplace:yn,tildeTrimReplace:Rn,caretTrimReplace:vn}=ie,yt=(n,t)=>{let e=!0,r=n.slice(),o=r.pop();for(;e&&r.length;)e=r.every(s=>o.intersects(s,t)),o=r.pop();return e},Tn=(n,t)=>(g("comp",n,t),n=wn(n,t),g("caret",n),n=In(n,t),g("tildes",n),n=Mn(n,t),g("xrange",n),n=Cn(n,t),g("stars",n),n),P=n=>!n||n.toLowerCase()==="x"||n==="*",In=(n,t)=>n.trim().split(/\s+/).map(e=>bn(e,t)).join(" "),bn=(n,t)=>{let e=t.loose?b[T.TILDELOOSE]:b[T.TILDE];return n.replace(e,(r,o,s,i,a)=>{let c;return g("tilde",n,r,o,s,i,a),P(o)?c="":P(s)?c=`>=${o}.0.0 <${+o+1}.0.0-0`:P(i)?c=`>=${o}.${s}.0 <${o}.${+s+1}.0-0`:a?(g("replaceTilde pr",a),c=`>=${o}.${s}.${i}-${a} <${o}.${+s+1}.0-0`):c=`>=${o}.${s}.${i} <${o}.${+s+1}.0-0`,g("tilde return",c),c})},wn=(n,t)=>n.trim().split(/\s+/).map(e=>Pn(e,t)).join(" "),Pn=(n,t)=>{g("caret",n,t);let e=t.loose?b[T.CARETLOOSE]:b[T.CARET],r=t.includePrerelease?"-0":"";return n.replace(e,(o,s,i,a,c)=>{let l;return g("caret",n,o,s,i,a,c),P(s)?l="":P(i)?l=`>=${s}.0.0${r} <${+s+1}.0.0-0`:P(a)?l=s==="0"?`>=${s}.${i}.0${r} <${s}.${+i+1}.0-0`:`>=${s}.${i}.0${r} <${+s+1}.0.0-0`:c?(g("replaceCaret pr",c),l=s==="0"?i==="0"?`>=${s}.${i}.${a}-${c} <${s}.${i}.${+a+1}-0`:`>=${s}.${i}.${a}-${c} <${s}.${+i+1}.0-0`:`>=${s}.${i}.${a}-${c} <${+s+1}.0.0-0`):(g("no pr"),l=s==="0"?i==="0"?`>=${s}.${i}.${a}${r} <${s}.${i}.${+a+1}-0`:`>=${s}.${i}.${a}${r} <${s}.${+i+1}.0-0`:`>=${s}.${i}.${a} <${+s+1}.0.0-0`),g("caret return",l),l})},Mn=(n,t)=>(g("replaceXRanges",n,t),n.split(/\s+/).map(e=>xn(e,t)).join(" ")),xn=(n,t)=>{n=n.trim();let e=t.loose?b[T.XRANGELOOSE]:b[T.XRANGE];return n.replace(e,(r,o,s,i,a,c)=>{g("xRange",n,r,o,s,i,a,c);let l=P(s),d=l||P(i),m=d||P(a),A=m;return o==="="&&A&&(o=""),c=t.includePrerelease?"-0":"",l?r=o===">"||o==="<"?"<0.0.0-0":"*":o&&A?(d&&(i=0),a=0,o===">"?(o=">=",d?(s=+s+1,i=0,a=0):(i=+i+1,a=0)):o==="<="&&(o="<",d?s=+s+1:i=+i+1),o==="<"&&(c="-0"),r=`${o+s}.${i}.${a}${c}`):d?r=`>=${s}.0.0${c} <${+s+1}.0.0-0`:m&&(r=`>=${s}.${i}.0${c} <${s}.${+i+1}.0-0`),g("xRange return",r),r})},Cn=(n,t)=>(g("replaceStars",n,t),n.trim().replace(b[T.STAR],"")),An=(n,t)=>(g("replaceGTE0",n,t),n.trim().replace(b[t.includePrerelease?T.GTE0PRE:T.GTE0],"")),Nn=n=>(t,e,r,o,s,i,a,c,l,d,m,A,I)=>`${e=P(r)?"":P(o)?`>=${r}.0.0${n?"-0":""}`:P(s)?`>=${r}.${o}.0${n?"-0":""}`:i?`>=${e}`:`>=${e}${n?"-0":""}`} ${c=P(l)?"":P(d)?`<${+l+1}.0.0-0`:P(m)?`<${l}.${+d+1}.0-0`:A?`<=${l}.${d}.${m}-${A}`:n?`<${l}.${d}.${+m+1}-0`:`<=${c}`}`.trim(),Sn=(n,t,e)=>{for(let r=0;r<n.length;r++)if(!n[r].test(t))return!1;if(t.prerelease.length&&!e.includePrerelease){for(let r=0;r<n.length;r++)if(g(n[r].semver),n[r].semver!==F.ANY&&n[r].semver.prerelease.length>0){let o=n[r].semver;if(o.major===t.major&&o.minor===t.minor&&o.patch===t.patch)return!0}return!1}return!0},It=(n,t,e)=>{try{t=new k(t,e)}catch(r){return!1}return t.test(n)};var{MAX_LENGTH:$n}=qe,{re:Rt,t:vt}=ie,Ln=(n,t)=>{if(t&&typeof t=="object"||(t={loose:!!t,includePrerelease:!1}),n instanceof R)return n;if(typeof n!="string"||n.length>$n||!(t.loose?Rt[vt.LOOSE]:Rt[vt.FULL]).test(n))return null;try{return new R(n,t)}catch(e){return null}},On=Ln,{re:fe,t:Ee}=ie,bt=(n,t)=>{if(n instanceof R)return n;if(typeof n=="number"&&(n=String(n)),typeof n!="string")return null;let e=null;if((t=t||{}).rtl){let r;for(;(r=fe[Ee.COERCERTL].exec(n))&&(!e||e.index+e[0].length!==n.length);)e&&r.index+r[0].length===e.index+e[0].length||(e=r),fe[Ee.COERCERTL].lastIndex=r.index+r[1].length+r[2].length;fe[Ee.COERCERTL].lastIndex=-1}else e=n.match(fe[Ee.COERCE]);return e===null?null:On(`${e[2]}.${e[3]||"0"}.${e[4]||"0"}`,t)};function _n(n){return String.fromCharCode(parseInt(n.slice(1),16))}function kn(n){return`%${`00${n.charCodeAt(0).toString(16)}`.slice(-2)}`}function qn(n){return btoa(encodeURIComponent(n).replace(/%[0-9A-F]{2}/g,_n))}function Dn(n){return decodeURIComponent(Array.from(atob(n),kn).join(""))}function ae(n){return qn(JSON.stringify(n))}function De(n){return JSON.parse(Dn(n))}var N=require("@magic-sdk/types");var ge=require("@magic-sdk/types");function q(n){return typeof n=="undefined"}function Un(n){return n===null}function ye(n){return Un(n)||q(n)}function Fn(n){return ye(n)?!1:!q(n.jsonrpc)&&!q(n.id)&&!q(n.method)&&!q(n.params)}function Ue(n){return ye(n)?!1:!q(n.jsonrpc)&&!q(n.id)&&(!q(n.result)||!q(n.error))}function Wn(n){return ye(n)?!1:typeof n=="string"&&Object.values(ge.MagicPayloadMethod).includes(n)}function Fe(n){return ye(n)?!1:typeof n=="number"&&Object.values(ge.RPCErrorCode).includes(n)}function z(n){if(!n)return!0;for(let t in n)if(Object.hasOwnProperty.call(n,t))return!1;return!0}var f={};function wt(n,t){return Object.assign(f,t),n}var Pt={"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"};var $=class extends Error{constructor(e,r){super(`Magic SDK Error: [${e}] ${r}`);this.code=e;this.rawMessage=r;this.__proto__=Error;Object.setPrototypeOf(this,$.prototype)}},L=class extends Error{constructor(e){super();this.__proto__=Error;let r=Number(e==null?void 0:e.code);this.rawMessage=(e==null?void 0:e.message)||"Internal error",this.code=Fe(r)?r:N.RPCErrorCode.InternalError,this.message=`Magic RPC Error: [${this.code}] ${this.rawMessage}`,this.data=(e==null?void 0:e.data)||void 0,Object.setPrototypeOf(this,L.prototype)}},D=class{constructor(t,e){this.code=t;this.rawMessage=e;this.message=`Magic SDK Warning: [${t}] ${e}`}log(){console.warn(this.message)}},K=class extends Error{constructor(e,r,o,s){super(`Magic Extension Error (${e.name}): [${r}] ${o}`);this.code=r;this.rawMessage=o;this.data=s;this.__proto__=Error;Object.setPrototypeOf(this,K.prototype)}},Y=class{constructor(t,e,r){this.code=e;this.rawMessage=r;this.message=`Magic Extension Warning (${t.name}): [${e}] ${r}`}log(){console.warn(this.message)}};function We(){return new $(N.SDKErrorCode.MissingApiKey,"Please provide an API key that you acquired from the Magic developer dashboard.")}function Je(){return new $(N.SDKErrorCode.ModalNotReady,"Modal is not ready.")}function Ge(){return new $(N.SDKErrorCode.MalformedResponse,"Response from the Magic iframe is malformed.")}function Ke(n){return new $(N.SDKErrorCode.ExtensionNotInitialized,`Extensions must be initialized with a Magic SDK instance before \`Extension.${n}\` can be accessed. Do not invoke \`Extension.${n}\` inside an extension constructor.`)}function je(n){let t=`Some extensions are incompatible with \`${f.sdkName}@${f.version}\`:`;return n.filter(e=>typeof e.compat!="undefined"&&e.compat!==null).forEach(e=>{let r=e.compat[f.sdkName];typeof r=="string"?t+=`
"use strict";var Jt=Object.create;var re=Object.defineProperty,Gt=Object.defineProperties,Kt=Object.getOwnPropertyDescriptor,jt=Object.getOwnPropertyDescriptors,Bt=Object.getOwnPropertyNames,at=Object.getOwnPropertySymbols,Vt=Object.getPrototypeOf,lt=Object.prototype.hasOwnProperty,Ht=Object.prototype.propertyIsEnumerable;var ct=(n,t,e)=>t in n?re(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,V=(n,t)=>{for(var e in t||(t={}))lt.call(t,e)&&ct(n,e,t[e]);if(at)for(var e of at(t))Ht.call(t,e)&&ct(n,e,t[e]);return n},H=(n,t)=>Gt(n,jt(t));var Xt=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports),dt=(n,t)=>{for(var e in t)re(n,e,{get:t[e],enumerable:!0})},ut=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Bt(t))!lt.call(n,o)&&o!==e&&re(n,o,{get:()=>t[o],enumerable:!(r=Kt(t,o))||r.enumerable});return n};var zt=(n,t,e)=>(e=n!=null?Jt(Vt(n)):{},ut(t||!n||!n.__esModule?re(e,"default",{value:n,enumerable:!0}):e,n)),Yt=n=>ut(re({},"__esModule",{value:!0}),n);var E=(n,t,e)=>new Promise((r,o)=>{var s=c=>{try{a(e.next(c))}catch(l){o(l)}},i=c=>{try{a(e.throw(c))}catch(l){o(l)}},a=c=>c.done?r(c.value):Promise.resolve(c.value).then(s,i);a((e=e.apply(n,t)).next())});var At=Xt(($r,Xe)=>{"use strict";var Bn=Object.prototype.hasOwnProperty,M="~";function ce(){}Object.create&&(ce.prototype=Object.create(null),new ce().__proto__||(M=!1));function Vn(n,t,e){this.fn=n,this.context=t,this.once=e||!1}function Ct(n,t,e,r,o){if(typeof e!="function")throw new TypeError("The listener must be a function");var s=new Vn(e,r||n,o),i=M?M+t:t;return n._events[i]?n._events[i].fn?n._events[i]=[n._events[i],s]:n._events[i].push(s):(n._events[i]=s,n._eventsCount++),n}function ve(n,t){--n._eventsCount===0?n._events=new ce:delete n._events[t]}function w(){this._events=new ce,this._eventsCount=0}w.prototype.eventNames=function(){var t=[],e,r;if(this._eventsCount===0)return t;for(r in e=this._events)Bn.call(e,r)&&t.push(M?r.slice(1):r);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(e)):t};w.prototype.listeners=function(t){var e=M?M+t:t,r=this._events[e];if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,i=new Array(s);o<s;o++)i[o]=r[o].fn;return i};w.prototype.listenerCount=function(t){var e=M?M+t:t,r=this._events[e];return r?r.fn?1:r.length:0};w.prototype.emit=function(t,e,r,o,s,i){var a=M?M+t:t;if(!this._events[a])return!1;var c=this._events[a],l=arguments.length,d,m;if(c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,e),!0;case 3:return c.fn.call(c.context,e,r),!0;case 4:return c.fn.call(c.context,e,r,o),!0;case 5:return c.fn.call(c.context,e,r,o,s),!0;case 6:return c.fn.call(c.context,e,r,o,s,i),!0}for(m=1,d=new Array(l-1);m<l;m++)d[m-1]=arguments[m];c.fn.apply(c.context,d)}else{var A=c.length,I;for(m=0;m<A;m++)switch(c[m].once&&this.removeListener(t,c[m].fn,void 0,!0),l){case 1:c[m].fn.call(c[m].context);break;case 2:c[m].fn.call(c[m].context,e);break;case 3:c[m].fn.call(c[m].context,e,r);break;case 4:c[m].fn.call(c[m].context,e,r,o);break;default:if(!d)for(I=1,d=new Array(l-1);I<l;I++)d[I-1]=arguments[I];c[m].fn.apply(c[m].context,d)}}return!0};w.prototype.on=function(t,e,r){return Ct(this,t,e,r,!1)};w.prototype.once=function(t,e,r){return Ct(this,t,e,r,!0)};w.prototype.removeListener=function(t,e,r,o){var s=M?M+t:t;if(!this._events[s])return this;if(!e)return ve(this,s),this;var i=this._events[s];if(i.fn)i.fn===e&&(!o||i.once)&&(!r||i.context===r)&&ve(this,s);else{for(var a=0,c=[],l=i.length;a<l;a++)(i[a].fn!==e||o&&!i[a].once||r&&i[a].context!==r)&&c.push(i[a]);c.length?this._events[s]=c.length===1?c[0]:c:ve(this,s)}return this};w.prototype.removeAllListeners=function(t){var e;return t?(e=M?M+t:t,this._events[e]&&ve(this,e)):(this._events=new ce,this._eventsCount=0),this};w.prototype.off=w.prototype.removeListener;w.prototype.addListener=w.prototype.on;w.prefixed=M;w.EventEmitter=w;typeof Xe<"u"&&(Xe.exports=w)});var Er={};dt(Er,{Extension:()=>_,MagicExtensionError:()=>K,MagicExtensionWarning:()=>Y,MagicRPCError:()=>L,MagicSDKError:()=>$,MagicSDKWarning:()=>q,SDKBase:()=>pe,STORE_KEY_PRIVATE_KEY:()=>Me,STORE_KEY_PUBLIC_JWK:()=>de,TypedEmitter:()=>Te,ViewController:()=>_e,clearKeys:()=>er,createDeprecationWarning:()=>U,createDuplicateIframeWarning:()=>Jn,createExtensionNotInitializedError:()=>Ke,createIncompatibleExtensionsError:()=>je,createInvalidArgumentError:()=>Be,createJwt:()=>et,createMalformedResponseError:()=>Ge,createMissingApiKeyError:()=>We,createModalNotReadyError:()=>Je,createPromiEvent:()=>O,createPromise:()=>be,createReactNativeEndpointConfigurationWarning:()=>He,createSDK:()=>wt,createSynchronousWeb3MethodWarning:()=>Ve,createTypedEmitter:()=>le,createURL:()=>xe,decodeJSON:()=>qe,encodeJSON:()=>ae,getPayloadId:()=>Re,isEmpty:()=>z,isJsonRpcErrorCode:()=>Fe,isJsonRpcRequestPayload:()=>Fn,isJsonRpcResponsePayload:()=>Ue,isMagicPayloadMethod:()=>Wn,isMajorVersionAtLeast:()=>Ye,isPromiEvent:()=>ze,isWebCryptoSupported:()=>ee,storage:()=>Z,uuid:()=>Ze});module.exports=Yt(Er);function Qt(n){let t={exports:{}};return n(t,t.exports),t.exports}var Zt=Number.MAX_SAFE_INTEGER||9007199254740991;var De={SEMVER_SPEC_VERSION:"2.0.0",MAX_LENGTH:256,MAX_SAFE_INTEGER:Zt,MAX_SAFE_COMPONENT_LENGTH:16},en=typeof process=="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...n)=>console.error("SEMVER",...n):()=>{},y=en,ie=Qt(function(n,t){let{MAX_SAFE_COMPONENT_LENGTH:e}=De,r=(t=n.exports={}).re=[],o=t.src=[],s=t.t={},i=0,a=(c,l,d)=>{let m=i++;y(m,l),s[c]=m,o[m]=l,r[m]=new RegExp(l,d?"g":void 0)};a("NUMERICIDENTIFIER","0|[1-9]\\d*"),a("NUMERICIDENTIFIERLOOSE","[0-9]+"),a("NONNUMERICIDENTIFIER","\\d*[a-zA-Z-][a-zA-Z0-9-]*"),a("MAINVERSION",`(${o[s.NUMERICIDENTIFIER]})\\.(${o[s.NUMERICIDENTIFIER]})\\.(${o[s.NUMERICIDENTIFIER]})`),a("MAINVERSIONLOOSE",`(${o[s.NUMERICIDENTIFIERLOOSE]})\\.(${o[s.NUMERICIDENTIFIERLOOSE]})\\.(${o[s.NUMERICIDENTIFIERLOOSE]})`),a("PRERELEASEIDENTIFIER",`(?:${o[s.NUMERICIDENTIFIER]}|${o[s.NONNUMERICIDENTIFIER]})`),a("PRERELEASEIDENTIFIERLOOSE",`(?:${o[s.NUMERICIDENTIFIERLOOSE]}|${o[s.NONNUMERICIDENTIFIER]})`),a("PRERELEASE",`(?:-(${o[s.PRERELEASEIDENTIFIER]}(?:\\.${o[s.PRERELEASEIDENTIFIER]})*))`),a("PRERELEASELOOSE",`(?:-?(${o[s.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${o[s.PRERELEASEIDENTIFIERLOOSE]})*))`),a("BUILDIDENTIFIER","[0-9A-Za-z-]+"),a("BUILD",`(?:\\+(${o[s.BUILDIDENTIFIER]}(?:\\.${o[s.BUILDIDENTIFIER]})*))`),a("FULLPLAIN",`v?${o[s.MAINVERSION]}${o[s.PRERELEASE]}?${o[s.BUILD]}?`),a("FULL",`^${o[s.FULLPLAIN]}$`),a("LOOSEPLAIN",`[v=\\s]*${o[s.MAINVERSIONLOOSE]}${o[s.PRERELEASELOOSE]}?${o[s.BUILD]}?`),a("LOOSE",`^${o[s.LOOSEPLAIN]}$`),a("GTLT","((?:<|>)?=?)"),a("XRANGEIDENTIFIERLOOSE",`${o[s.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),a("XRANGEIDENTIFIER",`${o[s.NUMERICIDENTIFIER]}|x|X|\\*`),a("XRANGEPLAIN",`[v=\\s]*(${o[s.XRANGEIDENTIFIER]})(?:\\.(${o[s.XRANGEIDENTIFIER]})(?:\\.(${o[s.XRANGEIDENTIFIER]})(?:${o[s.PRERELEASE]})?${o[s.BUILD]}?)?)?`),a("XRANGEPLAINLOOSE",`[v=\\s]*(${o[s.XRANGEIDENTIFIERLOOSE]})(?:\\.(${o[s.XRANGEIDENTIFIERLOOSE]})(?:\\.(${o[s.XRANGEIDENTIFIERLOOSE]})(?:${o[s.PRERELEASELOOSE]})?${o[s.BUILD]}?)?)?`),a("XRANGE",`^${o[s.GTLT]}\\s*${o[s.XRANGEPLAIN]}$`),a("XRANGELOOSE",`^${o[s.GTLT]}\\s*${o[s.XRANGEPLAINLOOSE]}$`),a("COERCE",`(^|[^\\d])(\\d{1,${e}})(?:\\.(\\d{1,${e}}))?(?:\\.(\\d{1,${e}}))?(?:$|[^\\d])`),a("COERCERTL",o[s.COERCE],!0),a("LONETILDE","(?:~>?)"),a("TILDETRIM",`(\\s*)${o[s.LONETILDE]}\\s+`,!0),t.tildeTrimReplace="$1~",a("TILDE",`^${o[s.LONETILDE]}${o[s.XRANGEPLAIN]}$`),a("TILDELOOSE",`^${o[s.LONETILDE]}${o[s.XRANGEPLAINLOOSE]}$`),a("LONECARET","(?:\\^)"),a("CARETTRIM",`(\\s*)${o[s.LONECARET]}\\s+`,!0),t.caretTrimReplace="$1^",a("CARET",`^${o[s.LONECARET]}${o[s.XRANGEPLAIN]}$`),a("CARETLOOSE",`^${o[s.LONECARET]}${o[s.XRANGEPLAINLOOSE]}$`),a("COMPARATORLOOSE",`^${o[s.GTLT]}\\s*(${o[s.LOOSEPLAIN]})$|^$`),a("COMPARATOR",`^${o[s.GTLT]}\\s*(${o[s.FULLPLAIN]})$|^$`),a("COMPARATORTRIM",`(\\s*)${o[s.GTLT]}\\s*(${o[s.LOOSEPLAIN]}|${o[s.XRANGEPLAIN]})`,!0),t.comparatorTrimReplace="$1$2$3",a("HYPHENRANGE",`^\\s*(${o[s.XRANGEPLAIN]})\\s+-\\s+(${o[s.XRANGEPLAIN]})\\s*$`),a("HYPHENRANGELOOSE",`^\\s*(${o[s.XRANGEPLAINLOOSE]})\\s+-\\s+(${o[s.XRANGEPLAINLOOSE]})\\s*$`),a("STAR","(<|>)?=?\\s*\\*"),a("GTE0","^\\s*>=\\s*0.0.0\\s*$"),a("GTE0PRE","^\\s*>=\\s*0.0.0-0\\s*$")}),pt=/^[0-9]+$/,Tt=(n,t)=>{let e=pt.test(n),r=pt.test(t);return e&&r&&(n=+n,t=+t),n===t?0:e&&!r?-1:r&&!e?1:n<t?-1:1},tn=(n,t)=>Tt(t,n),nn={compareIdentifiers:Tt,rcompareIdentifiers:tn},{MAX_LENGTH:ht,MAX_SAFE_INTEGER:me}=De,{re:mt,t:ft}=ie,{compareIdentifiers:se}=nn,R=class{constructor(t,e){if(e&&typeof e=="object"||(e={loose:!!e,includePrerelease:!1}),t instanceof R){if(t.loose===!!e.loose&&t.includePrerelease===!!e.includePrerelease)return t;t=t.version}else if(typeof t!="string")throw new TypeError(`Invalid Version: ${t}`);if(t.length>ht)throw new TypeError(`version is longer than ${ht} characters`);y("SemVer",t,e),this.options=e,this.loose=!!e.loose,this.includePrerelease=!!e.includePrerelease;let r=t.trim().match(e.loose?mt[ft.LOOSE]:mt[ft.FULL]);if(!r)throw new TypeError(`Invalid Version: ${t}`);if(this.raw=t,this.major=+r[1],this.minor=+r[2],this.patch=+r[3],this.major>me||this.major<0)throw new TypeError("Invalid major version");if(this.minor>me||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>me||this.patch<0)throw new TypeError("Invalid patch version");r[4]?this.prerelease=r[4].split(".").map(o=>{if(/^[0-9]+$/.test(o)){let s=+o;if(s>=0&&s<me)return s}return o}):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(t){if(y("SemVer.compare",this.version,this.options,t),!(t instanceof R)){if(typeof t=="string"&&t===this.version)return 0;t=new R(t,this.options)}return t.version===this.version?0:this.compareMain(t)||this.comparePre(t)}compareMain(t){return t instanceof R||(t=new R(t,this.options)),se(this.major,t.major)||se(this.minor,t.minor)||se(this.patch,t.patch)}comparePre(t){if(t instanceof R||(t=new R(t,this.options)),this.prerelease.length&&!t.prerelease.length)return-1;if(!this.prerelease.length&&t.prerelease.length)return 1;if(!this.prerelease.length&&!t.prerelease.length)return 0;let e=0;do{let r=this.prerelease[e],o=t.prerelease[e];if(y("prerelease compare",e,r,o),r===void 0&&o===void 0)return 0;if(o===void 0)return 1;if(r===void 0)return-1;if(r!==o)return se(r,o)}while(++e)}compareBuild(t){t instanceof R||(t=new R(t,this.options));let e=0;do{let r=this.build[e],o=t.build[e];if(y("prerelease compare",e,r,o),r===void 0&&o===void 0)return 0;if(o===void 0)return 1;if(r===void 0)return-1;if(r!==o)return se(r,o)}while(++e)}inc(t,e){switch(t){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",e);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",e);break;case"prepatch":this.prerelease.length=0,this.inc("patch",e),this.inc("pre",e);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",e),this.inc("pre",e);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)}e&&(this.prerelease[0]===e?isNaN(this.prerelease[1])&&(this.prerelease=[e,0]):this.prerelease=[e,0]);break;default:throw new Error(`invalid increment argument: ${t}`)}return this.format(),this.raw=this.version,this}},rn=(n,t,e)=>new R(n,e).compare(new R(t,e)),X=rn,sn=(n,t,e)=>X(n,t,e)===0,on=sn,an=(n,t,e)=>X(n,t,e)!==0,cn=an,ln=(n,t,e)=>X(n,t,e)>0,dn=ln,un=(n,t,e)=>X(n,t,e)>=0,pn=un,hn=(n,t,e)=>X(n,t,e)<0,mn=hn,fn=(n,t,e)=>X(n,t,e)<=0,En=fn,yn=(n,t,e,r)=>{switch(t){case"===":return typeof n=="object"&&(n=n.version),typeof e=="object"&&(e=e.version),n===e;case"!==":return typeof n=="object"&&(n=n.version),typeof e=="object"&&(e=e.version),n!==e;case"":case"=":case"==":return on(n,e,r);case"!=":return cn(n,e,r);case">":return dn(n,e,r);case">=":return pn(n,e,r);case"<":return mn(n,e,r);case"<=":return En(n,e,r);default:throw new TypeError(`Invalid operator: ${t}`)}},ke=yn,oe=Symbol("SemVer ANY"),F=class{static get ANY(){return oe}constructor(t,e){if(e&&typeof e=="object"||(e={loose:!!e,includePrerelease:!1}),t instanceof F){if(t.loose===!!e.loose)return t;t=t.value}y("comparator",t,e),this.options=e,this.loose=!!e.loose,this.parse(t),this.semver===oe?this.value="":this.value=this.operator+this.semver.version,y("comp",this)}parse(t){let e=this.options.loose?Et[yt.COMPARATORLOOSE]:Et[yt.COMPARATOR],r=t.match(e);if(!r)throw new TypeError(`Invalid comparator: ${t}`);this.operator=r[1]!==void 0?r[1]:"",this.operator==="="&&(this.operator=""),r[2]?this.semver=new R(r[2],this.options.loose):this.semver=oe}toString(){return this.value}test(t){if(y("Comparator.test",t,this.options.loose),this.semver===oe||t===oe)return!0;if(typeof t=="string")try{t=new R(t,this.options)}catch(e){return!1}return ke(t,this.operator,this.semver,this.options)}intersects(t,e){if(!(t instanceof F))throw new TypeError("a Comparator is required");if(e&&typeof e=="object"||(e={loose:!!e,includePrerelease:!1}),this.operator==="")return this.value===""||new k(t.value,e).test(this.value);if(t.operator==="")return t.value===""||new k(this.value,e).test(t.semver);let r=!(this.operator!==">="&&this.operator!==">"||t.operator!==">="&&t.operator!==">"),o=!(this.operator!=="<="&&this.operator!=="<"||t.operator!=="<="&&t.operator!=="<"),s=this.semver.version===t.semver.version,i=!(this.operator!==">="&&this.operator!=="<="||t.operator!==">="&&t.operator!=="<="),a=ke(this.semver,"<",t.semver,e)&&(this.operator===">="||this.operator===">")&&(t.operator==="<="||t.operator==="<"),c=ke(this.semver,">",t.semver,e)&&(this.operator==="<="||this.operator==="<")&&(t.operator===">="||t.operator===">");return r||o||s&&i||a||c}},{re:Et,t:yt}=ie,k=class{constructor(t,e){if(e&&typeof e=="object"||(e={loose:!!e,includePrerelease:!1}),t instanceof k)return t.loose===!!e.loose&&t.includePrerelease===!!e.includePrerelease?t:new k(t.raw,e);if(t instanceof F)return this.raw=t.value,this.set=[[t]],this.format(),this;if(this.options=e,this.loose=!!e.loose,this.includePrerelease=!!e.includePrerelease,this.raw=t,this.set=t.split(/\s*\|\|\s*/).map(r=>this.parseRange(r.trim())).filter(r=>r.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${t}`);this.format()}format(){return this.range=this.set.map(t=>t.join(" ").trim()).join("||").trim(),this.range}toString(){return this.range}parseRange(t){let{loose:e}=this.options;t=t.trim();let r=e?b[T.HYPHENRANGELOOSE]:b[T.HYPHENRANGE];t=t.replace(r,Nn(this.options.includePrerelease)),y("hyphen replace",t),t=t.replace(b[T.COMPARATORTRIM],gn),y("comparator trim",t,b[T.COMPARATORTRIM]),t=(t=(t=t.replace(b[T.TILDETRIM],Rn)).replace(b[T.CARETTRIM],vn)).split(/\s+/).join(" ");let o=e?b[T.COMPARATORLOOSE]:b[T.COMPARATOR];return t.split(" ").map(s=>Tn(s,this.options)).join(" ").split(/\s+/).map(s=>An(s,this.options)).filter(this.options.loose?s=>!!s.match(o):()=>!0).map(s=>new F(s,this.options))}intersects(t,e){if(!(t instanceof k))throw new TypeError("a Range is required");return this.set.some(r=>gt(r,e)&&t.set.some(o=>gt(o,e)&&r.every(s=>o.every(i=>s.intersects(i,e)))))}test(t){if(!t)return!1;if(typeof t=="string")try{t=new R(t,this.options)}catch(e){return!1}for(let e=0;e<this.set.length;e++)if(Sn(this.set[e],t,this.options))return!0;return!1}},{re:b,t:T,comparatorTrimReplace:gn,tildeTrimReplace:Rn,caretTrimReplace:vn}=ie,gt=(n,t)=>{let e=!0,r=n.slice(),o=r.pop();for(;e&&r.length;)e=r.every(s=>o.intersects(s,t)),o=r.pop();return e},Tn=(n,t)=>(y("comp",n,t),n=wn(n,t),y("caret",n),n=In(n,t),y("tildes",n),n=Mn(n,t),y("xrange",n),n=Cn(n,t),y("stars",n),n),P=n=>!n||n.toLowerCase()==="x"||n==="*",In=(n,t)=>n.trim().split(/\s+/).map(e=>bn(e,t)).join(" "),bn=(n,t)=>{let e=t.loose?b[T.TILDELOOSE]:b[T.TILDE];return n.replace(e,(r,o,s,i,a)=>{let c;return y("tilde",n,r,o,s,i,a),P(o)?c="":P(s)?c=`>=${o}.0.0 <${+o+1}.0.0-0`:P(i)?c=`>=${o}.${s}.0 <${o}.${+s+1}.0-0`:a?(y("replaceTilde pr",a),c=`>=${o}.${s}.${i}-${a} <${o}.${+s+1}.0-0`):c=`>=${o}.${s}.${i} <${o}.${+s+1}.0-0`,y("tilde return",c),c})},wn=(n,t)=>n.trim().split(/\s+/).map(e=>Pn(e,t)).join(" "),Pn=(n,t)=>{y("caret",n,t);let e=t.loose?b[T.CARETLOOSE]:b[T.CARET],r=t.includePrerelease?"-0":"";return n.replace(e,(o,s,i,a,c)=>{let l;return y("caret",n,o,s,i,a,c),P(s)?l="":P(i)?l=`>=${s}.0.0${r} <${+s+1}.0.0-0`:P(a)?l=s==="0"?`>=${s}.${i}.0${r} <${s}.${+i+1}.0-0`:`>=${s}.${i}.0${r} <${+s+1}.0.0-0`:c?(y("replaceCaret pr",c),l=s==="0"?i==="0"?`>=${s}.${i}.${a}-${c} <${s}.${i}.${+a+1}-0`:`>=${s}.${i}.${a}-${c} <${s}.${+i+1}.0-0`:`>=${s}.${i}.${a}-${c} <${+s+1}.0.0-0`):(y("no pr"),l=s==="0"?i==="0"?`>=${s}.${i}.${a}${r} <${s}.${i}.${+a+1}-0`:`>=${s}.${i}.${a}${r} <${s}.${+i+1}.0-0`:`>=${s}.${i}.${a} <${+s+1}.0.0-0`),y("caret return",l),l})},Mn=(n,t)=>(y("replaceXRanges",n,t),n.split(/\s+/).map(e=>xn(e,t)).join(" ")),xn=(n,t)=>{n=n.trim();let e=t.loose?b[T.XRANGELOOSE]:b[T.XRANGE];return n.replace(e,(r,o,s,i,a,c)=>{y("xRange",n,r,o,s,i,a,c);let l=P(s),d=l||P(i),m=d||P(a),A=m;return o==="="&&A&&(o=""),c=t.includePrerelease?"-0":"",l?r=o===">"||o==="<"?"<0.0.0-0":"*":o&&A?(d&&(i=0),a=0,o===">"?(o=">=",d?(s=+s+1,i=0,a=0):(i=+i+1,a=0)):o==="<="&&(o="<",d?s=+s+1:i=+i+1),o==="<"&&(c="-0"),r=`${o+s}.${i}.${a}${c}`):d?r=`>=${s}.0.0${c} <${+s+1}.0.0-0`:m&&(r=`>=${s}.${i}.0${c} <${s}.${+i+1}.0-0`),y("xRange return",r),r})},Cn=(n,t)=>(y("replaceStars",n,t),n.trim().replace(b[T.STAR],"")),An=(n,t)=>(y("replaceGTE0",n,t),n.trim().replace(b[t.includePrerelease?T.GTE0PRE:T.GTE0],"")),Nn=n=>(t,e,r,o,s,i,a,c,l,d,m,A,I)=>`${e=P(r)?"":P(o)?`>=${r}.0.0${n?"-0":""}`:P(s)?`>=${r}.${o}.0${n?"-0":""}`:i?`>=${e}`:`>=${e}${n?"-0":""}`} ${c=P(l)?"":P(d)?`<${+l+1}.0.0-0`:P(m)?`<${l}.${+d+1}.0-0`:A?`<=${l}.${d}.${m}-${A}`:n?`<${l}.${d}.${+m+1}-0`:`<=${c}`}`.trim(),Sn=(n,t,e)=>{for(let r=0;r<n.length;r++)if(!n[r].test(t))return!1;if(t.prerelease.length&&!e.includePrerelease){for(let r=0;r<n.length;r++)if(y(n[r].semver),n[r].semver!==F.ANY&&n[r].semver.prerelease.length>0){let o=n[r].semver;if(o.major===t.major&&o.minor===t.minor&&o.patch===t.patch)return!0}return!1}return!0},It=(n,t,e)=>{try{t=new k(t,e)}catch(r){return!1}return t.test(n)};var{MAX_LENGTH:$n}=De,{re:Rt,t:vt}=ie,Ln=(n,t)=>{if(t&&typeof t=="object"||(t={loose:!!t,includePrerelease:!1}),n instanceof R)return n;if(typeof n!="string"||n.length>$n||!(t.loose?Rt[vt.LOOSE]:Rt[vt.FULL]).test(n))return null;try{return new R(n,t)}catch(e){return null}},On=Ln,{re:fe,t:Ee}=ie,bt=(n,t)=>{if(n instanceof R)return n;if(typeof n=="number"&&(n=String(n)),typeof n!="string")return null;let e=null;if((t=t||{}).rtl){let r;for(;(r=fe[Ee.COERCERTL].exec(n))&&(!e||e.index+e[0].length!==n.length);)e&&r.index+r[0].length===e.index+e[0].length||(e=r),fe[Ee.COERCERTL].lastIndex=r.index+r[1].length+r[2].length;fe[Ee.COERCERTL].lastIndex=-1}else e=n.match(fe[Ee.COERCE]);return e===null?null:On(`${e[2]}.${e[3]||"0"}.${e[4]||"0"}`,t)};function _n(n){return String.fromCharCode(parseInt(n.slice(1),16))}function kn(n){return`%${`00${n.charCodeAt(0).toString(16)}`.slice(-2)}`}function Dn(n){return btoa(encodeURIComponent(n).replace(/%[0-9A-F]{2}/g,_n))}function qn(n){return decodeURIComponent(Array.from(atob(n),kn).join(""))}function ae(n){return Dn(JSON.stringify(n))}function qe(n){return JSON.parse(qn(n))}var N=require("@magic-sdk/types");var ye=require("@magic-sdk/types");function D(n){return typeof n=="undefined"}function Un(n){return n===null}function ge(n){return Un(n)||D(n)}function Fn(n){return ge(n)?!1:!D(n.jsonrpc)&&!D(n.id)&&!D(n.method)&&!D(n.params)}function Ue(n){return ge(n)?!1:!D(n.jsonrpc)&&!D(n.id)&&(!D(n.result)||!D(n.error))}function Wn(n){return ge(n)?!1:typeof n=="string"&&Object.values(ye.MagicPayloadMethod).includes(n)}function Fe(n){return ge(n)?!1:typeof n=="number"&&Object.values(ye.RPCErrorCode).includes(n)}function z(n){if(!n)return!0;for(let t in n)if(Object.hasOwnProperty.call(n,t))return!1;return!0}var f={};function wt(n,t){return Object.assign(f,t),n}var Pt={"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"};var $=class extends Error{constructor(e,r){super(`Magic SDK Error: [${e}] ${r}`);this.code=e;this.rawMessage=r;this.__proto__=Error;Object.setPrototypeOf(this,$.prototype)}},L=class extends Error{constructor(e){super();this.__proto__=Error;let r=Number(e==null?void 0:e.code);this.rawMessage=(e==null?void 0:e.message)||"Internal error",this.code=Fe(r)?r:N.RPCErrorCode.InternalError,this.message=`Magic RPC Error: [${this.code}] ${this.rawMessage}`,this.data=(e==null?void 0:e.data)||void 0,Object.setPrototypeOf(this,L.prototype)}},q=class{constructor(t,e){this.code=t;this.rawMessage=e;this.message=`Magic SDK Warning: [${t}] ${e}`}log(){console.warn(this.message)}},K=class extends Error{constructor(e,r,o,s){super(`Magic Extension Error (${e.name}): [${r}] ${o}`);this.code=r;this.rawMessage=o;this.data=s;this.__proto__=Error;Object.setPrototypeOf(this,K.prototype)}},Y=class{constructor(t,e,r){this.code=e;this.rawMessage=r;this.message=`Magic Extension Warning (${t.name}): [${e}] ${r}`}log(){console.warn(this.message)}};function We(){return new $(N.SDKErrorCode.MissingApiKey,"Please provide an API key that you acquired from the Magic developer dashboard.")}function Je(){return new $(N.SDKErrorCode.ModalNotReady,"Modal is not ready.")}function Ge(){return new $(N.SDKErrorCode.MalformedResponse,"Response from the Magic iframe is malformed.")}function Ke(n){return new $(N.SDKErrorCode.ExtensionNotInitialized,`Extensions must be initialized with a Magic SDK instance before \`Extension.${n}\` can be accessed. Do not invoke \`Extension.${n}\` inside an extension constructor.`)}function je(n){let t=`Some extensions are incompatible with \`${f.sdkName}@${f.version}\`:`;return n.filter(e=>typeof e.compat!="undefined"&&e.compat!==null).forEach(e=>{let r=e.compat[f.sdkName];typeof r=="string"?t+=`
- Extension \`${e.name}\` supports version(s) \`${r}\``:r||(t+=`
- Extension \`${e.name}\` does not support ${f.platform} environments.`)}),new $(N.SDKErrorCode.IncompatibleExtensions,t)}function Be(n){let t=e=>{let r=e+1,o=r%10,s=r%100;return o===1&&s!==11?`${r}st`:o===2&&s!==12?`${r}nd`:o===3&&s!==13?`${r}rd`:`${r}th`};return new $(N.SDKErrorCode.InvalidArgument,`Invalid ${t(n.argument)} argument given to \`${n.procedure}\`.
Expected: \`${n.expected}\`
Received: \`${n.received}\``)}function Jn(){return new D(N.SDKWarningCode.DuplicateIframe,"Duplicate iframes found.")}function Ve(){return new D(N.SDKWarningCode.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 He(){return new D(N.SDKWarningCode.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 \`${f.defaultEndpoint}\`. Changing this default behavior will lead to unexpected results and potentially security-threatening bugs.`)}function U(n){let{method:t,removalVersions:e,useInstead:r}=n,o=e[f.sdkName],s=r?` Use \`${r}\` instead.`:"",i=`\`${t}\` will be removed from \`${f.sdkName}\` in version \`${o}\`.${s}`;return new D(N.SDKWarningCode.DeprecationNotice,i)}var h=require("@magic-sdk/types");var Q=require("@magic-sdk/types");function*Gn(){let n=0;for(;;)n<Number.MAX_SAFE_INTEGER?yield++n:n=0}var Kn=Gn();function Re(){return Kn.next().value}var Mt=Symbol("Payload pre-processed by Magic SDK");function xt(n){return Object.defineProperty(n,Mt,{value:!0,enumerable:!1}),n}function jn(n){return!!n[Mt]}function j(n){var t,e,r;return jn(n)||(n.jsonrpc=(t=n.jsonrpc)!=null?t:"2.0",n.id=Re(),n.method=(e=n.method)!=null?e:"noop",n.params=(r=n.params)!=null?r:[],xt(n)),n}function u(n,t=[]){return xt({params:t,method:n,jsonrpc:"2.0",id:Re()})}var W=class{constructor(t){t instanceof W?(this._jsonrpc=t.payload.jsonrpc,this._id=t.payload.id,this._result=t.payload.result,this._error=t.payload.error):Ue(t)?(this._jsonrpc=t.jsonrpc,this._id=t.id,this._result=t.result,this._error=t.error):(this._jsonrpc=t.jsonrpc,this._id=t.id,this._result=void 0,this._error=void 0)}applyError(t){return this._error=t,this}applyResult(t){return this._result=t,this}get hasError(){return typeof this._error!="undefined"&&this._error!==null}get hasResult(){return typeof this._result!="undefined"}get payload(){return{jsonrpc:this._jsonrpc,id:this._id,result:this._result,error:this._error}}};var Ie=require("@magic-sdk/types");var Nt=zt(At()),Te=class extends Nt.default{};function le(){let n=new Te;return{emitter:n,createChainingEmitterMethod:(r,o)=>(...s)=>(n[r].apply(n,s),o),createBoundEmitterMethod:r=>(...o)=>n[r].apply(n,o)}}var St=Symbol("isPromiEvent");function ze(n){return!!n[St]}function O(n){let t=be(n),{createBoundEmitterMethod:e,createChainingEmitterMethod:r}=le(),o=Symbol("Promise.then"),s=Symbol("Promise.catch"),i=Symbol("Promise.finally"),a=(d,m)=>(...A)=>{let I=m[d].apply(m,A);return c(I)},c=d=>Object.assign(d,{[St]:!0,[o]:d[o]||d.then,[s]:d[s]||d.catch,[i]:d[i]||d.finally,then:a(o,d),catch:a(s,d),finally:a(i,d),on:r("on",d),once:r("once",d),addListener:r("addListener",d),off:r("off",d),removeListener:r("removeListener",d),removeAllListeners:r("removeAllListeners",d),emit:e("emit"),eventNames:e("eventNames"),listeners:e("listeners"),listenerCount:e("listenerCount")}),l=c(t.then(d=>(l.emit("done",d),l.emit("settled"),d),d=>{throw l.emit("error",d),l.emit("settled"),d}));return l.on(Ie.UserEventsOnReceived.ClosedByUser,()=>{l.emit(Ie.UserEventsEmit.ClosedByUser)}),l}function be(n){return new Promise((t,e)=>{let r=n(t,e);Promise.resolve(r).catch(e)})}var x=class{constructor(t){this.sdk=t}get overlay(){return this.sdk.overlay}request(t){let e=this.overlay.post(Q.MagicOutgoingWindowMessage.MAGIC_HANDLE_REQUEST,j(t)),r=O((s,i)=>{e.then(a=>{if(o(),a.hasError)i(new L(a.payload.error));else if(a.hasResult)s(a.payload.result);else throw Ge()}).catch(a=>{o(),i(a)})}),o=this.overlay.on(Q.MagicIncomingWindowMessage.MAGIC_HANDLE_EVENT,s=>{var a;let{response:i}=s.data;if(i.id===t.id&&((a=i.result)==null?void 0:a.event)){let{event:c,params:l=[]}=i.result;r.emit(c,...l)}});return r}createIntermediaryEvent(t,e){return o=>{let s=u(Q.MagicPayloadMethod.IntermediaryEvent,[{payloadId:e,eventType:t,args:o}]);this.request(s)}}};function Ye(n,t){let[e]=n.split(".").map(Number);return e>=t}var B={"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"},we=class extends x{loginWithMagicLink(t){let e=f.sdkName==="@magic-sdk/react-native"||f.sdkName==="@magic-sdk/react-native-bare"||f.sdkName==="@magic-sdk/react-native-expo";if(e&&Ye(f.version,19))throw new Error("loginWithMagicLink() is deprecated for this package, please utlize a passcode method like loginWithSMS or loginWithEmailOTP instead.");e&&U({method:"auth.loginWithMagicLink()",removalVersions:B,useInstead:"auth.loginWithEmailOTP()"}).log();let{email:r,showUI:o=!0,redirectURI:s,overrides:i,lifespan:a}=t,c=u(this.sdk.testMode?h.MagicPayloadMethod.LoginWithMagicLinkTestMode:h.MagicPayloadMethod.LoginWithMagicLink,[{email:r,showUI:o,redirectURI:s,overrides:i,lifespan:a}]);return this.request(c)}loginWithSMS(t){let{phoneNumber:e,showUI:r=!0,lifespan:o}=t,s=u(this.sdk.testMode?h.MagicPayloadMethod.LoginWithSmsTestMode:h.MagicPayloadMethod.LoginWithSms,[{phoneNumber:e,showUI:r,lifespan:o}]),i=this.request(s);return!r&&i&&(i.on(h.LoginWithSmsOTPEventEmit.VerifySmsOtp,a=>{this.createIntermediaryEvent(h.LoginWithSmsOTPEventEmit.VerifySmsOtp,s.id)(a)}),i.on(h.LoginWithSmsOTPEventEmit.Cancel,()=>{this.createIntermediaryEvent(h.LoginWithSmsOTPEventEmit.Cancel,s.id)()})),i}loginWithEmailOTP(t){let{email:e,showUI:r,deviceCheckUI:o,overrides:s,lifespan:i}=t,a=u(this.sdk.testMode?h.MagicPayloadMethod.LoginWithEmailOTPTestMode:h.MagicPayloadMethod.LoginWithEmailOTP,[{email:e,showUI:r,deviceCheckUI:o,overrides:s,lifespan:i}]),c=this.request(a);return!o&&c&&c.on(h.DeviceVerificationEventEmit.Retry,()=>{this.createIntermediaryEvent(h.DeviceVerificationEventEmit.Retry,a.id)()}),!r&&c&&(c.on(h.LoginWithEmailOTPEventEmit.VerifyEmailOtp,l=>{this.createIntermediaryEvent(h.LoginWithEmailOTPEventEmit.VerifyEmailOtp,a.id)(l)}),c.on(h.LoginWithEmailOTPEventEmit.VerifyMFACode,l=>{this.createIntermediaryEvent(h.LoginWithEmailOTPEventEmit.VerifyMFACode,a.id)(l)}),c.on(h.LoginWithEmailOTPEventEmit.Cancel,()=>{this.createIntermediaryEvent(h.LoginWithEmailOTPEventEmit.Cancel,a.id)()})),c}loginWithCredential(t){let{credentialOrQueryString:e,lifespan:r}=t||{},o=e!=null?e:"";if(!e&&f.platform==="web"){o=window.location.search;let i=window.location.origin+window.location.pathname;window.history.replaceState(null,"",i)}let s=u(this.sdk.testMode?h.MagicPayloadMethod.LoginWithCredentialTestMode:h.MagicPayloadMethod.LoginWithCredential,[o,r]);return this.request(s)}setAuthorizationToken(t){let e=u(h.MagicPayloadMethod.SetAuthorizationToken,[{jwt:t}]);return this.request(e)}updateEmailWithUI(t){let{email:e,showUI:r=!0}=t,o=u(this.sdk.testMode?h.MagicPayloadMethod.UpdateEmailTestMode:h.MagicPayloadMethod.UpdateEmail,[{email:e,showUI:r}]),s=this.request(o);return r||(s.on(h.RecencyCheckEventEmit.Retry,()=>{this.createIntermediaryEvent(h.RecencyCheckEventEmit.Retry,o.id)()}),s.on(h.RecencyCheckEventEmit.Cancel,()=>{this.createIntermediaryEvent(h.RecencyCheckEventEmit.Cancel,o.id)()}),s.on(h.RecencyCheckEventEmit.VerifyEmailOtp,i=>{this.createIntermediaryEvent(h.RecencyCheckEventEmit.VerifyEmailOtp,o.id)(i)}),s.on(h.RecencyCheckEventEmit.VerifyMFACode,i=>{this.createIntermediaryEvent(h.RecencyCheckEventEmit.VerifyMFACode,o.id)(i)}),s.on(h.UpdateEmailEventEmit.RetryWithNewEmail,i=>{this.createIntermediaryEvent(h.UpdateEmailEventEmit.RetryWithNewEmail,o.id)(i)}),s.on(h.UpdateEmailEventEmit.Cancel,()=>{this.createIntermediaryEvent(h.UpdateEmailEventEmit.Cancel,o.id)()}),s.on(h.UpdateEmailEventEmit.VerifyEmailOtp,i=>{this.createIntermediaryEvent(h.UpdateEmailEventEmit.VerifyEmailOtp,o.id)(i)})),s}};var p=require("@magic-sdk/types");var Z={};dt(Z,{clear:()=>Hn,getItem:()=>v,iterate:()=>Qe,key:()=>zn,keys:()=>Yn,length:()=>Xn,removeItem:()=>S,setItem:()=>C});var Pe;function J(n){return(...t)=>E(this,null,function*(){return Pe||(Pe=yield f.configureStorage()),yield Pe.ready(),Pe[n](...t)})}var v=J("getItem"),C=J("setItem"),S=J("removeItem"),Hn=J("clear"),Xn=J("length"),zn=J("key"),Yn=J("keys"),Qe=J("iterate");function Ze(){let n=window.crypto.getRandomValues(new Uint8Array(16));n[6]=n[6]&15|64,n[8]=n[8]&191|128;let t="";return t+=n[0].toString(16),t+=n[1].toString(16),t+=n[2].toString(16),t+=n[3].toString(16),t+="-",t+=n[4].toString(16),t+=n[5].toString(16),t+="-",t+=n[6].toString(16),t+=n[7].toString(16),t+="-",t+=n[8].toString(16),t+=n[9].toString(16),t+="-",t+=n[10].toString(16),t+=n[11].toString(16),t+=n[12].toString(16),t+=n[13].toString(16),t+=n[14].toString(16),t+=n[15].toString(16),t}var Me="STORE_KEY_PRIVATE_KEY",de="STORE_KEY_PUBLIC_JWK",Lt="ECDSA",Qn="P-256",Zn={name:Lt,namedCurve:Qn};function ee(){let n=typeof window!="undefined"&&!!window.crypto,t=n&&!!window.crypto.subtle;return n&&t}function er(){S(de),S(Me)}function et(){return E(this,null,function*(){let n=yield tr();if(!n){console.info("unable to create public key or webcrypto is unsupported");return}let{subtle:t}=window.crypto,e=yield v(Me);if(!e||!t){console.info("unable to find private key or webcrypto unsupported");return}let r={iat:Math.floor(new Date().getTime()/1e3),jti:Ze()},o={typ:"dpop+jwt",alg:"ES256",jwk:n},s={protected:$t(JSON.stringify(o)),claims:$t(JSON.stringify(r))},i=rr(`${s.protected}.${s.claims}`),a={name:Lt,hash:{name:"SHA-256"}},c=or(new Uint8Array(yield t.sign(a,e,i)));return`${s.protected}.${s.claims}.${c}`})}function tr(){return E(this,null,function*(){if(!ee()){console.info("webcrypto is not supported");return}return(yield v(de))||(yield nr()),v(de)})}function nr(){return E(this,null,function*(){let{subtle:n}=window.crypto,t=yield n.generateKey(Zn,!1,["sign"]),e=yield n.exportKey("jwk",t.publicKey);yield C(Me,t.privateKey),yield C(de,e)})}function $t(n){return Ot(sr(n))}function rr(n){return new TextEncoder().encode(n)}function Ot(n){return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+/g,"")}function sr(n){return encodeURIComponent(n).replace(/%([0-9A-F]{2})/g,(e,r)=>String.fromCharCode(parseInt(r,16)))}function or(n){let t="";return n.forEach(e=>{t+=String.fromCharCode(e)}),Ot(t)}var tt="ds",nt="ek",rt="iv",st="AES-GCM",ir=256;function te(){return E(this,null,function*(){let n=[];yield Qe((t,e,r)=>{e.startsWith(`${tt}_`)&&n.push(e)});for(let t of n)yield S(t)})}function _t(n){let t="",e=new Uint8Array(n),r=e.byteLength;for(let o=0;o<r;o++)t+=String.fromCharCode(e[o]);return window.btoa(t)}function kt(n){let t=window.atob(n),e=t.length,r=new Uint8Array(e);for(let o=0;o<e;o++)r[o]=t.charCodeAt(o);return r.buffer}function ar(){return E(this,null,function*(){if(!ee()){console.info("webcrypto is not supported");return}let{crypto:n}=window,t=yield v(rt);return t||n.getRandomValues(new Uint8Array(12))})}function cr(){return E(this,null,function*(){if(!ee()){console.info("webcrypto is not supported");return}let{subtle:n}=window.crypto,t=yield v(nt);return t||(yield n.generateKey({name:st,length:ir},!1,["encrypt","decrypt"]))})}function qt(n,t){return E(this,null,function*(){let e=yield ar(),r=yield cr();if(!e||!r||!n)return;let o=kt(n),{subtle:s}=window.crypto,i=yield s.encrypt({name:st,iv:e},r,o),a=_t(i);yield C(`${tt}_${t}`,a),yield C(nt,r),yield C(rt,e)})}function Dt(n){return E(this,null,function*(){let t=yield v(`${tt}_${n}`),e=yield v(rt),r=yield v(nt);if(!e||!t||!r||!ee())return;let{subtle:o}=window.crypto,s=yield o.decrypt({name:st,iv:e},r,kt(t));return _t(s)})}function xe(n,t){return t?new URL(n,t):new URL(n)}var Ce=class extends x{constructor(){super(...arguments);this.localForageKey="mc_active_wallet";this.localForageIsLoggedInKey="magic_auth_is_logged_in";this.userLoggedOutCallbacks=[]}getIdToken(e){let r=u(this.sdk.testMode?p.MagicPayloadMethod.GetIdTokenTestMode:p.MagicPayloadMethod.GetIdToken,[e]);return this.request(r)}generateIdToken(e){let r=u(this.sdk.testMode?p.MagicPayloadMethod.GenerateIdTokenTestMode:p.MagicPayloadMethod.GenerateIdToken,[e]);return this.request(r)}getInfo(){return E(this,null,function*(){let e=yield v(this.localForageKey),r=u(p.MagicPayloadMethod.GetInfo,[{walletType:e}]);return this.request(r)})}isLoggedIn(){return O((e,r)=>E(this,null,function*(){try{let o=!1;this.sdk.useStorageCache&&(o=(yield v(this.localForageIsLoggedInKey))==="true",o&&e(!0));let s=u(this.sdk.testMode?p.MagicPayloadMethod.IsLoggedInTestMode:p.MagicPayloadMethod.IsLoggedIn),i=yield this.request(s);this.sdk.useStorageCache&&(i?C(this.localForageIsLoggedInKey,!0):S(this.localForageIsLoggedInKey),o&&!i&&this.emitUserLoggedOut(!0)),e(i)}catch(o){r(o)}}))}logout(){return S(this.localForageKey),S(this.localForageIsLoggedInKey),te(),O((e,r)=>E(this,null,function*(){try{let o=u(this.sdk.testMode?p.MagicPayloadMethod.LogoutTestMode:p.MagicPayloadMethod.Logout),s=yield this.request(o);this.sdk.useStorageCache&&this.emitUserLoggedOut(s),e(s)}catch(o){r(o)}}))}requestInfoWithUI(e){let r=u(p.MagicPayloadMethod.RequestUserInfoWithUI,e?[e]:[]);return this.request(r)}showSettings(e){let{showUI:r=!0}=e||{},o=u(this.sdk.testMode?p.MagicPayloadMethod.UserSettingsTestMode:p.MagicPayloadMethod.UserSettings,[e]),s=this.request(o);return!r&&s&&(s.on(p.RecoveryFactorEventEmit.SendNewPhoneNumber,i=>{this.createIntermediaryEvent(p.RecoveryFactorEventEmit.SendNewPhoneNumber,o.id)(i)}),s.on(p.RecoveryFactorEventEmit.SendOtpCode,i=>{this.createIntermediaryEvent(p.RecoveryFactorEventEmit.SendOtpCode,o.id)(i)}),s.on(p.RecoveryFactorEventEmit.StartEditPhoneNumber,()=>{this.createIntermediaryEvent(p.RecoveryFactorEventEmit.StartEditPhoneNumber,o.id)()}),s.on(p.RecoveryFactorEventEmit.Cancel,()=>{this.createIntermediaryEvent(p.RecoveryFactorEventEmit.Cancel,o.id)()}),s.on(p.RecencyCheckEventEmit.VerifyEmailOtp,i=>{this.createIntermediaryEvent(p.RecencyCheckEventEmit.VerifyEmailOtp,o.id)(i)})),s}recoverAccount(e){let r=u(this.sdk.testMode?p.MagicPayloadMethod.RecoverAccountTestMode:p.MagicPayloadMethod.RecoverAccount,[e]);return this.request(r)}revealPrivateKey(){let e=u(p.MagicPayloadMethod.RevealPK);return this.request(e)}getMetadata(){U({method:"user.getMetadata()",removalVersions:B,useInstead:"user.getInfo()"}).log();let e=u(this.sdk.testMode?p.MagicPayloadMethod.GetMetadataTestMode:p.MagicPayloadMethod.GetMetadata);return this.request(e)}onUserLoggedOut(e){this.userLoggedOutCallbacks.push(e)}enableMFA(e){let{showUI:r=!0}=e,o=u(p.MagicPayloadMethod.EnableMFA,[{showUI:r}]),s=this.request(o);return!r&&s&&(s.on(p.EnableMFAEventEmit.VerifyMFACode,i=>{this.createIntermediaryEvent(p.EnableMFAEventEmit.VerifyMFACode,o.id)(i)}),s.on(p.EnableMFAEventEmit.Cancel,()=>{this.createIntermediaryEvent(p.EnableMFAEventEmit.Cancel,o.id)()})),s}disableMFA(e){let{showUI:r=!0}=e,o=u(p.MagicPayloadMethod.DisableMFA,[{showUI:r}]),s=this.request(o);return!r&&s&&(s.on(p.DisableMFAEventEmit.VerifyMFACode,i=>{this.createIntermediaryEvent(p.DisableMFAEventEmit.VerifyMFACode,o.id)(i)}),s.on(p.DisableMFAEventEmit.LostDevice,i=>{this.createIntermediaryEvent(p.DisableMFAEventEmit.LostDevice,o.id)(i)}),s.on(p.DisableMFAEventEmit.Cancel,()=>{this.createIntermediaryEvent(p.DisableMFAEventEmit.Cancel,o.id)()})),s}emitUserLoggedOut(e){this.userLoggedOutCallbacks.forEach(r=>{r(e)})}};var y=require("@magic-sdk/types");var Ae=class extends x{constructor(){super(...arguments);this.localForageKey="mc_active_wallet"}connectWithUI(){let e=O((r,o)=>E(this,null,function*(){try{if(this.isMetaMaskBrowser()&&(yield this.isWalletEnabled(y.Wallets.MetaMask))){let l=yield this.autoConnectIfWalletBrowser(y.Wallets.MetaMask);r(l);return}if(this.isCoinbaseWalletBrowser()&&(yield this.isWalletEnabled(y.Wallets.CoinbaseWallet))){let l=yield this.autoConnectIfWalletBrowser(y.Wallets.CoinbaseWallet);r(l);return}let s=this.getUserEnv(),i=u(y.MagicPayloadMethod.Login,[s]),a=this.request(i);a.on(y.Events.WalletSelected,l=>this.handleWalletSelected(H(V({},l),{payloadId:i.id}))),a.on("id-token-created",l=>{e.emit("id-token-created",l)});let c=yield a;c.error&&o(c),r(c)}catch(s){o(s)}}));return e}showUI(e){return this.request(u(y.MagicPayloadMethod.ShowUI,[e]))}showAddress(){return this.request(u(y.MagicPayloadMethod.ShowAddress))}showSendTokensUI(){return this.request(u(y.MagicPayloadMethod.ShowSendTokensUI))}showOnRamp(){return this.request(u(y.MagicPayloadMethod.ShowOnRamp))}showNFTs(){return this.request(u(y.MagicPayloadMethod.ShowNFTs))}showBalances(){return this.request(u(y.MagicPayloadMethod.ShowBalances))}sendGaslessTransaction(e,r){return this.request(u(y.MagicPayloadMethod.SendGaslessTransaction,[e,r]))}getInfo(){return E(this,null,function*(){U({method:"wallet.getInfo()",removalVersions:B,useInstead:"user.getInfo()"}).log();let e=yield v(this.localForageKey),r=u(y.MagicPayloadMethod.GetInfo,[{walletType:e}]);return this.request(r)})}disconnect(){U({method:"wallet.disconnect()",removalVersions:B,useInstead:"user.logout()"}).log(),S(this.localForageKey),te();let e=u(y.MagicPayloadMethod.Disconnect);return this.request(e)}requestUserInfoWithUI(e){U({method:"wallet.requestUserInfoWithUI()",removalVersions:B,useInstead:"user.requestUserInfoWithUI()"}).log();let r=u(y.MagicPayloadMethod.RequestUserInfoWithUI,e?[e]:[]);return this.request(r)}getProvider(){return E(this,null,function*(){switch(yield v(this.localForageKey)){case y.Wallets.MetaMask:return this.getMetaMaskProvider();case y.Wallets.CoinbaseWallet:return this.getCoinbaseProvider();default:return this.sdk.rpcProvider}})}isMetaMaskInstalled(){var e,r,o;return((e=window.ethereum)==null?void 0:e.isMetaMask)||!!((o=(r=window.ethereum)==null?void 0:r.providers)!=null&&o.find(s=>s==null?void 0:s.isMetaMask))}isMetaMaskBrowser(){return this.isMobile()&&this.isMetaMaskInstalled()}getMetaMaskProvider(){var e,r;return((r=(e=window.ethereum)==null?void 0:e.providers)==null?void 0:r.find(o=>o==null?void 0:o.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,r,o;return((e=window.ethereum)==null?void 0:e.isCoinbaseWallet)||!!((o=(r=window.ethereum)==null?void 0:r.providers)!=null&&o.find(s=>s==null?void 0:s.isCoinbaseWallet))}isCoinbaseWalletBrowser(){var e;return!!((e=window.ethereum)!=null&&e.isCoinbaseBrowser)}getCoinbaseProvider(){var e,r;return((r=(e=window.ethereum)==null?void 0:e.providers)==null?void 0:r.find(o=>o==null?void 0:o.isCoinbaseWallet))||window.ethereum}connectToCoinbaseWallet(){if(this.isMobile()&&!this.isCoinbaseWalletBrowser()){let r=`https://go.cb-w.com/dapp?cb_url=${encodeURIComponent(window.location.href)}`;window.location.href=r}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 y.Wallets.MetaMask:return this.connectToMetaMask();case y.Wallets.CoinbaseWallet:return this.connectToCoinbaseWallet();default:throw new Error(`Invalid provider: ${e}. Must be one of "metamask" or "coinbase_wallet".`)}}isWalletEnabled(e){let r=u("mc_is_wallet_enabled",[{wallet:e}]);return this.request(r)}handleWalletSelected(e){return E(this,null,function*(){try{let r=yield this.connectToThirdPartyWallet(e.wallet);yield C(this.localForageKey,e.wallet),this.createIntermediaryEvent(y.Events.WalletConnected,e.payloadId)(r)}catch(r){console.error(r),this.createIntermediaryEvent(y.Events.WalletRejected,e.payloadId)()}})}autoConnectIfWalletBrowser(e){return E(this,null,function*(){let r;e===y.Wallets.MetaMask&&(r=yield this.getMetaMaskProvider().request({method:"eth_requestAccounts"})),e===y.Wallets.CoinbaseWallet&&(r=yield this.getCoinbaseProvider().request({method:"eth_requestAccounts"})),yield C(this.localForageKey,e);let o=u(y.MagicPayloadMethod.AutoConnect,[{wallet:e,address:r}]);return this.request(o)})}};var ue=require("@magic-sdk/types");var{createBoundEmitterMethod:Ne,createChainingEmitterMethod:ne}=le(),Se=class extends x{constructor(){super(...arguments);this.isMagic=!0;this.on=ne("on",this);this.once=ne("once",this);this.addListener=ne("addListener",this);this.off=ne("off",this);this.removeListener=ne("removeListener",this);this.removeAllListeners=ne("removeAllListeners",this);this.emit=Ne("emit");this.eventNames=Ne("eventNames");this.listeners=Ne("listeners");this.listenerCount=Ne("listenerCount")}sendAsync(e,r){if(!r)throw Be({procedure:"Magic.rpcProvider.sendAsync",argument:1,expected:"function",received:r===null?"null":typeof r});if(Array.isArray(e))this.overlay.post(ue.MagicOutgoingWindowMessage.MAGIC_HANDLE_REQUEST,e.map(o=>{let s=j(o);return this.prefixPayloadMethodForTestMode(s),s})).then(o=>{r(null,o.map(s=>H(V({},s.payload),{error:s.hasError?new L(s.payload.error):null})))});else{let o=j(e);this.prefixPayloadMethodForTestMode(o),this.overlay.post(ue.MagicOutgoingWindowMessage.MAGIC_HANDLE_REQUEST,o).then(s=>{r(s.hasError?new L(s.payload.error):null,s.payload)})}}send(e,r){if(typeof e=="string"){let s=u(e,Array.isArray(r)?r:[]);return this.request(s)}if(Array.isArray(e)||!!r){this.sendAsync(e,r);return}let o=Ve();return o.log(),new W(e).applyError({code:-32603,message:o.rawMessage}).payload}enable(){let e=u(ue.MagicPayloadMethod.Login);return this.request(e)}request(e){return this.prefixPayloadMethodForTestMode(e),super.request(e)}prefixPayloadMethodForTestMode(e){let r="testMode/eth/";this.sdk.testMode&&(e.method=`${r}${e.method}`)}};var Ut=["request","overlay","sdk"];function lr(n){let t=Object.getPrototypeOf(n),e=[t];for(;t!==x.prototype;)t=Object.getPrototypeOf(t),e.push(t);return e}var $e=class extends x{constructor(){super(void 0);this.__sdk_access_field_descriptors__=new Map;this.__is_initialized__=!1;this.utils={createPromiEvent:O,isPromiEvent:ze,encodeJSON:ae,decodeJSON:De,createJsonRpcRequestPayload:u,standardizeJsonRpcRequestPayload:j,storage:Z};let e=[this,...lr(this)];Ut.forEach(r=>{let o=e.map(c=>Object.getOwnPropertyDescriptor(c,r)),s=o.findIndex(c=>!!c),i=s>0,a=o[s];a&&(this.__sdk_access_field_descriptors__.set(r,{descriptor:a,isPrototypeField:i}),Object.defineProperty(this,r,{configurable:!0,get:()=>{throw Ke(r)}}))})}init(e){this.__is_initialized__||(Ut.forEach(r=>{if(this.__sdk_access_field_descriptors__.has(r)){let{descriptor:o,isPrototypeField:s}=this.__sdk_access_field_descriptors__.get(r);s?delete this[r]:Object.defineProperty(this,r,o)}}),this.sdk=e,this.__is_initialized__=!0)}createDeprecationWarning(e){let{method:r,removalVersion:o,useInstead:s}=e,i=s?` Use \`${s}\` instead.`:"",a=`\`${r}\` will be removed from this Extension in version \`${o}\`.${i}`;return new Y(this,"DEPRECATION_NOTICE",a)}createWarning(e,r){return new Y(this,e,r)}createError(e,r,o){return new K(this,e,r,o)}},ot=class extends $e{},_=class extends $e{};_.Internal=ot,_.Anonymous="anonymous extension";var Le=require("@magic-sdk/types");var Oe=class extends x{purchase(t){let e=u(Le.MagicPayloadMethod.NFTPurchase,[t]);return this.request(e)}checkout(t){let e=u(Le.MagicPayloadMethod.NFTCheckout,[t]);return this.request(e)}transfer(t){let e=u(Le.MagicPayloadMethod.NFTTransfer,[t]);return this.request(e)}};function Ft(n){return n.compat&&n.compat[f.sdkName]!=null?typeof n.compat[f.sdkName]=="string"?It(bt(f.version),n.compat[f.sdkName]):!!n.compat[f.sdkName]:!0}function dr(n,t,e){return!t&&!e?`${n}_eth_mainnet`:e?`${n}_${JSON.stringify(e)}`:t?typeof t=="string"?`${n}_eth_${t}`:`${n}_${t.rpcUrl}_${t.chainId}_${t.chainType}`:`${n}_unknown`}function ur(n){var o;let t=(o=n==null?void 0:n.extensions)!=null?o:[],e={},r=[];if(Array.isArray(t)?t.forEach(s=>{Ft(s)?(s.init(this),(s.name||s.name!==_.Anonymous)&&(this[s.name]=s),s instanceof _.Internal&&(z(s.config)||(e[s.name]=s.config))):r.push(s)}):Object.keys(t).forEach(s=>{if(Ft(t[s])){t[s].init(this);let i=t[s];this[s]=i,i instanceof _.Internal&&(z(i.config)||(e[t[s].name]=i.config))}else r.push(t[s])}),r.length)throw je(r);return e}var he=class{constructor(t,e){this.apiKey=t;var i;if(!t)throw We();f.platform==="react-native"&&(e==null?void 0:e.endpoint)&&He().log();let{defaultEndpoint:r,version:o}=f;this.testMode=!!(e!=null&&e.testMode),this.useStorageCache=!!(e!=null&&e.useStorageCache),this.endpoint=xe((i=e==null?void 0:e.endpoint)!=null?i:r).origin,this.auth=new we(this),this.user=new Ce(this),this.wallet=new Ae(this),this.nft=new Oe(this),this.rpcProvider=new Se(this);let s=ur.call(this,e);this.parameters=ae(H(V({API_KEY:this.apiKey,DOMAIN_ORIGIN:window.location?window.location.origin:"",ETH_NETWORK:e==null?void 0:e.network,host:xe(this.endpoint).host,sdk:Pt[f.sdkName],version:o,ext:z(s)?void 0:s,locale:(e==null?void 0:e.locale)||"en_US"},f.bundleId?{bundleId:f.bundleId}:{}),{meta:e==null?void 0:e.meta})),this.networkHash=dr(this.apiKey,e==null?void 0:e.network,z(s)?void 0:s),e!=null&&e.deferPreload||this.preload()}get overlay(){if(!he.__overlays__.has(this.parameters)){let t=new f.ViewController(this.endpoint,this.parameters,this.networkHash);t.init(),he.__overlays__.set(this.parameters,t)}return he.__overlays__.get(this.parameters)}preload(){return E(this,null,function*(){yield this.overlay.checkIsReadyForRequest})}},pe=he;pe.__overlays__=new Map;var G=require("@magic-sdk/types");function pr(n,t){return t&&Array.isArray(n)?n.find(e=>e.id===t):n}function hr(n,t){var o;let e=(o=t.data.response)==null?void 0:o.id,r=pr(n,e);if(e&&r){let s=new W(r).applyResult(t.data.response.result).applyError(t.data.response.error);return{id:e,response:s}}return{}}function mr(n,t,e){return E(this,null,function*(){var a;let r=yield v("rt"),o;if(f.platform==="web")try{o=(a=yield v("jwt"))!=null?a:yield et()}catch(c){console.error("webcrypto error",c)}let s={msgType:n,payload:t};o&&(s.jwt=o),o&&r&&(s.rt=r);let i=yield Dt(e);return i&&(s.deviceShare=i),s})}function fr(n){return E(this,null,function*(){!n.data.rt||(yield C("rt",n.data.rt))})}var _e=class{constructor(t,e,r){this.endpoint=t;this.parameters=e;this.networkHash=r;this.messageHandlers=new Set;this.isConnectedToInternet=!0;this.checkIsReadyForRequest=this.waitForReady(),this.isReadyForRequest=!1,this.listen()}post(t,e){return E(this,null,function*(){return be((r,o)=>E(this,null,function*(){if(!this.isConnectedToInternet){let d=Je();o(d)}this.isReadyForRequest||(yield this.waitForReady());let s=[],i=Array.isArray(e)?e.map(d=>d.id):[],a=yield mr(`${t}-${this.parameters}`,e,this.networkHash);yield this._post(a);let c=d=>m=>{var it;let{id:A,response:I}=hr(e,m);if(fr(m),((it=I==null?void 0:I.payload.error)==null?void 0:it.message)==="User denied account access.")te();else if(m.data.deviceShare){let{deviceShare:Wt}=m.data;qt(Wt,this.networkHash)}A&&I&&Array.isArray(e)&&i.includes(A)?(s.push(I),s.length===e.length&&(d(),r(s))):A&&I&&!Array.isArray(e)&&A===e.id&&(d(),r(I))},l=this.on(G.MagicIncomingWindowMessage.MAGIC_HANDLE_RESPONSE,c(()=>l()))}))})}on(t,e){let r=e.bind(window),o=s=>{s.data.msgType===`${t}-${this.parameters}`&&r(s)};return this.messageHandlers.add(o),()=>this.messageHandlers.delete(o)}waitForReady(){return new Promise(t=>{let e=this.on(G.MagicIncomingWindowMessage.MAGIC_OVERLAY_READY,()=>{this.isReadyForRequest=!0,t(),e()});setTimeout(()=>{this.isReadyForRequest=!0,t(),e()},15e3)})}listen(){this.on(G.MagicIncomingWindowMessage.MAGIC_HIDE_OVERLAY,()=>{this.hideOverlay()}),this.on(G.MagicIncomingWindowMessage.MAGIC_SHOW_OVERLAY,()=>{this.showOverlay()}),this.on(G.MagicIncomingWindowMessage.MAGIC_SEND_PRODUCT_ANNOUNCEMENT,t=>{t.data.response.result.product_announcement&&new D(G.SDKWarningCode.ProductAnnouncement,t.data.response.result.product_announcement).log()})}};
Received: \`${n.received}\``)}function Jn(){return new q(N.SDKWarningCode.DuplicateIframe,"Duplicate iframes found.")}function Ve(){return new q(N.SDKWarningCode.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 He(){return new q(N.SDKWarningCode.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 \`${f.defaultEndpoint}\`. Changing this default behavior will lead to unexpected results and potentially security-threatening bugs.`)}function U(n){let{method:t,removalVersions:e,useInstead:r}=n,o=e[f.sdkName],s=r?` Use \`${r}\` instead.`:"",i=`\`${t}\` will be removed from \`${f.sdkName}\` in version \`${o}\`.${s}`;return new q(N.SDKWarningCode.DeprecationNotice,i)}var u=require("@magic-sdk/types");var Q=require("@magic-sdk/types");function*Gn(){let n=0;for(;;)n<Number.MAX_SAFE_INTEGER?yield++n:n=0}var Kn=Gn();function Re(){return Kn.next().value}var Mt=Symbol("Payload pre-processed by Magic SDK");function xt(n){return Object.defineProperty(n,Mt,{value:!0,enumerable:!1}),n}function jn(n){return!!n[Mt]}function j(n){var t,e,r;return jn(n)||(n.jsonrpc=(t=n.jsonrpc)!=null?t:"2.0",n.id=Re(),n.method=(e=n.method)!=null?e:"noop",n.params=(r=n.params)!=null?r:[],xt(n)),n}function p(n,t=[]){return xt({params:t,method:n,jsonrpc:"2.0",id:Re()})}var W=class{constructor(t){t instanceof W?(this._jsonrpc=t.payload.jsonrpc,this._id=t.payload.id,this._result=t.payload.result,this._error=t.payload.error):Ue(t)?(this._jsonrpc=t.jsonrpc,this._id=t.id,this._result=t.result,this._error=t.error):(this._jsonrpc=t.jsonrpc,this._id=t.id,this._result=void 0,this._error=void 0)}applyError(t){return this._error=t,this}applyResult(t){return this._result=t,this}get hasError(){return typeof this._error!="undefined"&&this._error!==null}get hasResult(){return typeof this._result!="undefined"}get payload(){return{jsonrpc:this._jsonrpc,id:this._id,result:this._result,error:this._error}}};var Ie=require("@magic-sdk/types");var Nt=zt(At()),Te=class extends Nt.default{};function le(){let n=new Te;return{emitter:n,createChainingEmitterMethod:(r,o)=>(...s)=>(n[r].apply(n,s),o),createBoundEmitterMethod:r=>(...o)=>n[r].apply(n,o)}}var St=Symbol("isPromiEvent");function ze(n){return!!n[St]}function O(n){let t=be(n),{createBoundEmitterMethod:e,createChainingEmitterMethod:r}=le(),o=Symbol("Promise.then"),s=Symbol("Promise.catch"),i=Symbol("Promise.finally"),a=(d,m)=>(...A)=>{let I=m[d].apply(m,A);return c(I)},c=d=>Object.assign(d,{[St]:!0,[o]:d[o]||d.then,[s]:d[s]||d.catch,[i]:d[i]||d.finally,then:a(o,d),catch:a(s,d),finally:a(i,d),on:r("on",d),once:r("once",d),addListener:r("addListener",d),off:r("off",d),removeListener:r("removeListener",d),removeAllListeners:r("removeAllListeners",d),emit:e("emit"),eventNames:e("eventNames"),listeners:e("listeners"),listenerCount:e("listenerCount")}),l=c(t.then(d=>(l.emit("done",d),l.emit("settled"),d),d=>{throw l.emit("error",d),l.emit("settled"),d}));return l.on(Ie.UserEventsOnReceived.ClosedByUser,()=>{l.emit(Ie.UserEventsEmit.ClosedByUser)}),l}function be(n){return new Promise((t,e)=>{let r=n(t,e);Promise.resolve(r).catch(e)})}var x=class{constructor(t){this.sdk=t}get overlay(){return this.sdk.overlay}request(t){let e=this.overlay.post(Q.MagicOutgoingWindowMessage.MAGIC_HANDLE_REQUEST,j(t)),r=O((s,i)=>{e.then(a=>{if(o(),a.hasError)i(new L(a.payload.error));else if(a.hasResult)s(a.payload.result);else throw Ge()}).catch(a=>{o(),i(a)})}),o=this.overlay.on(Q.MagicIncomingWindowMessage.MAGIC_HANDLE_EVENT,s=>{var a;let{response:i}=s.data;if(i.id===t.id&&((a=i.result)==null?void 0:a.event)){let{event:c,params:l=[]}=i.result;r.emit(c,...l)}});return r}createIntermediaryEvent(t,e){return o=>{let s=p(Q.MagicPayloadMethod.IntermediaryEvent,[{payloadId:e,eventType:t,args:o}]);this.request(s)}}};function Ye(n,t){let[e]=n.split(".").map(Number);return e>=t}var B={"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"},we=class extends x{loginWithMagicLink(t){let e=f.sdkName==="@magic-sdk/react-native"||f.sdkName==="@magic-sdk/react-native-bare"||f.sdkName==="@magic-sdk/react-native-expo";if(e&&Ye(f.version,19))throw new Error("loginWithMagicLink() is deprecated for this package, please utlize a passcode method like loginWithSMS or loginWithEmailOTP instead.");e&&U({method:"auth.loginWithMagicLink()",removalVersions:B,useInstead:"auth.loginWithEmailOTP()"}).log();let{email:r,showUI:o=!0,redirectURI:s,overrides:i,lifespan:a}=t,c=p(this.sdk.testMode?u.MagicPayloadMethod.LoginWithMagicLinkTestMode:u.MagicPayloadMethod.LoginWithMagicLink,[{email:r,showUI:o,redirectURI:s,overrides:i,lifespan:a}]);return this.request(c)}loginWithSMS(t){let{phoneNumber:e,showUI:r=!0,lifespan:o}=t,s=p(this.sdk.testMode?u.MagicPayloadMethod.LoginWithSmsTestMode:u.MagicPayloadMethod.LoginWithSms,[{phoneNumber:e,showUI:r,lifespan:o}]),i=this.request(s);return!r&&i&&(i.on(u.LoginWithSmsOTPEventEmit.VerifySmsOtp,a=>{this.createIntermediaryEvent(u.LoginWithSmsOTPEventEmit.VerifySmsOtp,s.id)(a)}),i.on(u.LoginWithSmsOTPEventEmit.Cancel,()=>{this.createIntermediaryEvent(u.LoginWithSmsOTPEventEmit.Cancel,s.id)()})),i}loginWithEmailOTP(t){let{email:e,showUI:r,deviceCheckUI:o,overrides:s,lifespan:i}=t,a=p(this.sdk.testMode?u.MagicPayloadMethod.LoginWithEmailOTPTestMode:u.MagicPayloadMethod.LoginWithEmailOTP,[{email:e,showUI:r,deviceCheckUI:o,overrides:s,lifespan:i}]),c=this.request(a);return!o&&c&&c.on(u.DeviceVerificationEventEmit.Retry,()=>{this.createIntermediaryEvent(u.DeviceVerificationEventEmit.Retry,a.id)()}),!r&&c&&(c.on(u.LoginWithEmailOTPEventEmit.VerifyEmailOtp,l=>{this.createIntermediaryEvent(u.LoginWithEmailOTPEventEmit.VerifyEmailOtp,a.id)(l)}),c.on(u.LoginWithEmailOTPEventEmit.VerifyMFACode,l=>{this.createIntermediaryEvent(u.LoginWithEmailOTPEventEmit.VerifyMFACode,a.id)(l)}),c.on(u.LoginWithEmailOTPEventEmit.LostDevice,()=>{this.createIntermediaryEvent(u.LoginWithEmailOTPEventEmit.LostDevice,a.id)()}),c.on(u.LoginWithEmailOTPEventEmit.VerifyRecoveryCode,l=>{this.createIntermediaryEvent(u.LoginWithEmailOTPEventEmit.VerifyRecoveryCode,a.id)(l)}),c.on(u.LoginWithEmailOTPEventEmit.Cancel,()=>{this.createIntermediaryEvent(u.LoginWithEmailOTPEventEmit.Cancel,a.id)()})),c}loginWithCredential(t){let{credentialOrQueryString:e,lifespan:r}=t||{},o=e!=null?e:"";if(!e&&f.platform==="web"){o=window.location.search;let i=window.location.origin+window.location.pathname;window.history.replaceState(null,"",i)}let s=p(this.sdk.testMode?u.MagicPayloadMethod.LoginWithCredentialTestMode:u.MagicPayloadMethod.LoginWithCredential,[o,r]);return this.request(s)}setAuthorizationToken(t){let e=p(u.MagicPayloadMethod.SetAuthorizationToken,[{jwt:t}]);return this.request(e)}updateEmailWithUI(t){let{email:e,showUI:r=!0}=t,o=p(this.sdk.testMode?u.MagicPayloadMethod.UpdateEmailTestMode:u.MagicPayloadMethod.UpdateEmail,[{email:e,showUI:r}]),s=this.request(o);return r||(s.on(u.RecencyCheckEventEmit.Retry,()=>{this.createIntermediaryEvent(u.RecencyCheckEventEmit.Retry,o.id)()}),s.on(u.RecencyCheckEventEmit.Cancel,()=>{this.createIntermediaryEvent(u.RecencyCheckEventEmit.Cancel,o.id)()}),s.on(u.RecencyCheckEventEmit.VerifyEmailOtp,i=>{this.createIntermediaryEvent(u.RecencyCheckEventEmit.VerifyEmailOtp,o.id)(i)}),s.on(u.RecencyCheckEventEmit.VerifyMFACode,i=>{this.createIntermediaryEvent(u.RecencyCheckEventEmit.VerifyMFACode,o.id)(i)}),s.on(u.UpdateEmailEventEmit.RetryWithNewEmail,i=>{this.createIntermediaryEvent(u.UpdateEmailEventEmit.RetryWithNewEmail,o.id)(i)}),s.on(u.UpdateEmailEventEmit.Cancel,()=>{this.createIntermediaryEvent(u.UpdateEmailEventEmit.Cancel,o.id)()}),s.on(u.UpdateEmailEventEmit.VerifyEmailOtp,i=>{this.createIntermediaryEvent(u.UpdateEmailEventEmit.VerifyEmailOtp,o.id)(i)})),s}};var h=require("@magic-sdk/types");var Z={};dt(Z,{clear:()=>Hn,getItem:()=>v,iterate:()=>Qe,key:()=>zn,keys:()=>Yn,length:()=>Xn,removeItem:()=>S,setItem:()=>C});var Pe;function J(n){return(...t)=>E(this,null,function*(){return Pe||(Pe=yield f.configureStorage()),yield Pe.ready(),Pe[n](...t)})}var v=J("getItem"),C=J("setItem"),S=J("removeItem"),Hn=J("clear"),Xn=J("length"),zn=J("key"),Yn=J("keys"),Qe=J("iterate");function Ze(){let n=window.crypto.getRandomValues(new Uint8Array(16));n[6]=n[6]&15|64,n[8]=n[8]&191|128;let t="";return t+=n[0].toString(16),t+=n[1].toString(16),t+=n[2].toString(16),t+=n[3].toString(16),t+="-",t+=n[4].toString(16),t+=n[5].toString(16),t+="-",t+=n[6].toString(16),t+=n[7].toString(16),t+="-",t+=n[8].toString(16),t+=n[9].toString(16),t+="-",t+=n[10].toString(16),t+=n[11].toString(16),t+=n[12].toString(16),t+=n[13].toString(16),t+=n[14].toString(16),t+=n[15].toString(16),t}var Me="STORE_KEY_PRIVATE_KEY",de="STORE_KEY_PUBLIC_JWK",Lt="ECDSA",Qn="P-256",Zn={name:Lt,namedCurve:Qn};function ee(){let n=typeof window!="undefined"&&!!window.crypto,t=n&&!!window.crypto.subtle;return n&&t}function er(){S(de),S(Me)}function et(){return E(this,null,function*(){let n=yield tr();if(!n){console.info("unable to create public key or webcrypto is unsupported");return}let{subtle:t}=window.crypto,e=yield v(Me);if(!e||!t){console.info("unable to find private key or webcrypto unsupported");return}let r={iat:Math.floor(new Date().getTime()/1e3),jti:Ze()},o={typ:"dpop+jwt",alg:"ES256",jwk:n},s={protected:$t(JSON.stringify(o)),claims:$t(JSON.stringify(r))},i=rr(`${s.protected}.${s.claims}`),a={name:Lt,hash:{name:"SHA-256"}},c=or(new Uint8Array(yield t.sign(a,e,i)));return`${s.protected}.${s.claims}.${c}`})}function tr(){return E(this,null,function*(){if(!ee()){console.info("webcrypto is not supported");return}return(yield v(de))||(yield nr()),v(de)})}function nr(){return E(this,null,function*(){let{subtle:n}=window.crypto,t=yield n.generateKey(Zn,!1,["sign"]),e=yield n.exportKey("jwk",t.publicKey);yield C(Me,t.privateKey),yield C(de,e)})}function $t(n){return Ot(sr(n))}function rr(n){return new TextEncoder().encode(n)}function Ot(n){return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+/g,"")}function sr(n){return encodeURIComponent(n).replace(/%([0-9A-F]{2})/g,(e,r)=>String.fromCharCode(parseInt(r,16)))}function or(n){let t="";return n.forEach(e=>{t+=String.fromCharCode(e)}),Ot(t)}var tt="ds",nt="ek",rt="iv",st="AES-GCM",ir=256;function te(){return E(this,null,function*(){let n=[];yield Qe((t,e,r)=>{e.startsWith(`${tt}_`)&&n.push(e)});for(let t of n)yield S(t)})}function _t(n){let t="",e=new Uint8Array(n),r=e.byteLength;for(let o=0;o<r;o++)t+=String.fromCharCode(e[o]);return window.btoa(t)}function kt(n){let t=window.atob(n),e=t.length,r=new Uint8Array(e);for(let o=0;o<e;o++)r[o]=t.charCodeAt(o);return r.buffer}function ar(){return E(this,null,function*(){if(!ee()){console.info("webcrypto is not supported");return}let{crypto:n}=window,t=yield v(rt);return t||n.getRandomValues(new Uint8Array(12))})}function cr(){return E(this,null,function*(){if(!ee()){console.info("webcrypto is not supported");return}let{subtle:n}=window.crypto,t=yield v(nt);return t||(yield n.generateKey({name:st,length:ir},!1,["encrypt","decrypt"]))})}function Dt(n,t){return E(this,null,function*(){let e=yield ar(),r=yield cr();if(!e||!r||!n)return;let o=kt(n),{subtle:s}=window.crypto,i=yield s.encrypt({name:st,iv:e},r,o),a=_t(i);yield C(`${tt}_${t}`,a),yield C(nt,r),yield C(rt,e)})}function qt(n){return E(this,null,function*(){let t=yield v(`${tt}_${n}`),e=yield v(rt),r=yield v(nt);if(!e||!t||!r||!ee())return;let{subtle:o}=window.crypto,s=yield o.decrypt({name:st,iv:e},r,kt(t));return _t(s)})}function xe(n,t){return t?new URL(n,t):new URL(n)}var Ce=class extends x{constructor(){super(...arguments);this.localForageKey="mc_active_wallet";this.localForageIsLoggedInKey="magic_auth_is_logged_in";this.userLoggedOutCallbacks=[]}getIdToken(e){let r=p(this.sdk.testMode?h.MagicPayloadMethod.GetIdTokenTestMode:h.MagicPayloadMethod.GetIdToken,[e]);return this.request(r)}generateIdToken(e){let r=p(this.sdk.testMode?h.MagicPayloadMethod.GenerateIdTokenTestMode:h.MagicPayloadMethod.GenerateIdToken,[e]);return this.request(r)}getInfo(){return E(this,null,function*(){let e=yield v(this.localForageKey),r=p(h.MagicPayloadMethod.GetInfo,[{walletType:e}]);return this.request(r)})}isLoggedIn(){return O((e,r)=>E(this,null,function*(){try{let o=!1;this.sdk.useStorageCache&&(o=(yield v(this.localForageIsLoggedInKey))==="true",o&&e(!0));let s=p(this.sdk.testMode?h.MagicPayloadMethod.IsLoggedInTestMode:h.MagicPayloadMethod.IsLoggedIn),i=yield this.request(s);this.sdk.useStorageCache&&(i?C(this.localForageIsLoggedInKey,!0):S(this.localForageIsLoggedInKey),o&&!i&&this.emitUserLoggedOut(!0)),e(i)}catch(o){r(o)}}))}logout(){return S(this.localForageKey),S(this.localForageIsLoggedInKey),te(),O((e,r)=>E(this,null,function*(){try{let o=p(this.sdk.testMode?h.MagicPayloadMethod.LogoutTestMode:h.MagicPayloadMethod.Logout),s=yield this.request(o);this.sdk.useStorageCache&&this.emitUserLoggedOut(s),e(s)}catch(o){r(o)}}))}requestInfoWithUI(e){let r=p(h.MagicPayloadMethod.RequestUserInfoWithUI,e?[e]:[]);return this.request(r)}showSettings(e){let{showUI:r=!0}=e||{},o=p(this.sdk.testMode?h.MagicPayloadMethod.UserSettingsTestMode:h.MagicPayloadMethod.UserSettings,[e]),s=this.request(o);return!r&&s&&(s.on(h.RecoveryFactorEventEmit.SendNewPhoneNumber,i=>{this.createIntermediaryEvent(h.RecoveryFactorEventEmit.SendNewPhoneNumber,o.id)(i)}),s.on(h.RecoveryFactorEventEmit.SendOtpCode,i=>{this.createIntermediaryEvent(h.RecoveryFactorEventEmit.SendOtpCode,o.id)(i)}),s.on(h.RecoveryFactorEventEmit.StartEditPhoneNumber,()=>{this.createIntermediaryEvent(h.RecoveryFactorEventEmit.StartEditPhoneNumber,o.id)()}),s.on(h.RecoveryFactorEventEmit.Cancel,()=>{this.createIntermediaryEvent(h.RecoveryFactorEventEmit.Cancel,o.id)()}),s.on(h.RecencyCheckEventEmit.VerifyEmailOtp,i=>{this.createIntermediaryEvent(h.RecencyCheckEventEmit.VerifyEmailOtp,o.id)(i)})),s}recoverAccount(e){let r=p(this.sdk.testMode?h.MagicPayloadMethod.RecoverAccountTestMode:h.MagicPayloadMethod.RecoverAccount,[e]);return this.request(r)}revealPrivateKey(){let e=p(h.MagicPayloadMethod.RevealPK);return this.request(e)}getMetadata(){U({method:"user.getMetadata()",removalVersions:B,useInstead:"user.getInfo()"}).log();let e=p(this.sdk.testMode?h.MagicPayloadMethod.GetMetadataTestMode:h.MagicPayloadMethod.GetMetadata);return this.request(e)}onUserLoggedOut(e){this.userLoggedOutCallbacks.push(e)}enableMFA(e){let{showUI:r=!0}=e,o=p(h.MagicPayloadMethod.EnableMFA,[{showUI:r}]),s=this.request(o);return!r&&s&&(s.on(h.EnableMFAEventEmit.VerifyMFACode,i=>{this.createIntermediaryEvent(h.EnableMFAEventEmit.VerifyMFACode,o.id)(i)}),s.on(h.EnableMFAEventEmit.Cancel,()=>{this.createIntermediaryEvent(h.EnableMFAEventEmit.Cancel,o.id)()})),s}disableMFA(e){let{showUI:r=!0}=e,o=p(h.MagicPayloadMethod.DisableMFA,[{showUI:r}]),s=this.request(o);return!r&&s&&(s.on(h.DisableMFAEventEmit.VerifyMFACode,i=>{this.createIntermediaryEvent(h.DisableMFAEventEmit.VerifyMFACode,o.id)(i)}),s.on(h.DisableMFAEventEmit.LostDevice,i=>{this.createIntermediaryEvent(h.DisableMFAEventEmit.LostDevice,o.id)(i)}),s.on(h.DisableMFAEventEmit.Cancel,()=>{this.createIntermediaryEvent(h.DisableMFAEventEmit.Cancel,o.id)()})),s}emitUserLoggedOut(e){this.userLoggedOutCallbacks.forEach(r=>{r(e)})}};var g=require("@magic-sdk/types");var Ae=class extends x{constructor(){super(...arguments);this.localForageKey="mc_active_wallet"}connectWithUI(){let e=O((r,o)=>E(this,null,function*(){try{if(this.isMetaMaskBrowser()&&(yield this.isWalletEnabled(g.Wallets.MetaMask))){let l=yield this.autoConnectIfWalletBrowser(g.Wallets.MetaMask);r(l);return}if(this.isCoinbaseWalletBrowser()&&(yield this.isWalletEnabled(g.Wallets.CoinbaseWallet))){let l=yield this.autoConnectIfWalletBrowser(g.Wallets.CoinbaseWallet);r(l);return}let s=this.getUserEnv(),i=p(g.MagicPayloadMethod.Login,[s]),a=this.request(i);a.on(g.Events.WalletSelected,l=>this.handleWalletSelected(H(V({},l),{payloadId:i.id}))),a.on("id-token-created",l=>{e.emit("id-token-created",l)});let c=yield a;c.error&&o(c),r(c)}catch(s){o(s)}}));return e}showUI(e){return this.request(p(g.MagicPayloadMethod.ShowUI,[e]))}showAddress(){return this.request(p(g.MagicPayloadMethod.ShowAddress))}showSendTokensUI(){return this.request(p(g.MagicPayloadMethod.ShowSendTokensUI))}showOnRamp(){return this.request(p(g.MagicPayloadMethod.ShowOnRamp))}showNFTs(){return this.request(p(g.MagicPayloadMethod.ShowNFTs))}showBalances(){return this.request(p(g.MagicPayloadMethod.ShowBalances))}sendGaslessTransaction(e,r){return this.request(p(g.MagicPayloadMethod.SendGaslessTransaction,[e,r]))}getInfo(){return E(this,null,function*(){U({method:"wallet.getInfo()",removalVersions:B,useInstead:"user.getInfo()"}).log();let e=yield v(this.localForageKey),r=p(g.MagicPayloadMethod.GetInfo,[{walletType:e}]);return this.request(r)})}disconnect(){U({method:"wallet.disconnect()",removalVersions:B,useInstead:"user.logout()"}).log(),S(this.localForageKey),te();let e=p(g.MagicPayloadMethod.Disconnect);return this.request(e)}requestUserInfoWithUI(e){U({method:"wallet.requestUserInfoWithUI()",removalVersions:B,useInstead:"user.requestUserInfoWithUI()"}).log();let r=p(g.MagicPayloadMethod.RequestUserInfoWithUI,e?[e]:[]);return this.request(r)}getProvider(){return E(this,null,function*(){switch(yield v(this.localForageKey)){case g.Wallets.MetaMask:return this.getMetaMaskProvider();case g.Wallets.CoinbaseWallet:return this.getCoinbaseProvider();default:return this.sdk.rpcProvider}})}isMetaMaskInstalled(){var e,r,o;return((e=window.ethereum)==null?void 0:e.isMetaMask)||!!((o=(r=window.ethereum)==null?void 0:r.providers)!=null&&o.find(s=>s==null?void 0:s.isMetaMask))}isMetaMaskBrowser(){return this.isMobile()&&this.isMetaMaskInstalled()}getMetaMaskProvider(){var e,r;return((r=(e=window.ethereum)==null?void 0:e.providers)==null?void 0:r.find(o=>o==null?void 0:o.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,r,o;return((e=window.ethereum)==null?void 0:e.isCoinbaseWallet)||!!((o=(r=window.ethereum)==null?void 0:r.providers)!=null&&o.find(s=>s==null?void 0:s.isCoinbaseWallet))}isCoinbaseWalletBrowser(){var e;return!!((e=window.ethereum)!=null&&e.isCoinbaseBrowser)}getCoinbaseProvider(){var e,r;return((r=(e=window.ethereum)==null?void 0:e.providers)==null?void 0:r.find(o=>o==null?void 0:o.isCoinbaseWallet))||window.ethereum}connectToCoinbaseWallet(){if(this.isMobile()&&!this.isCoinbaseWalletBrowser()){let r=`https://go.cb-w.com/dapp?cb_url=${encodeURIComponent(window.location.href)}`;window.location.href=r}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 g.Wallets.MetaMask:return this.connectToMetaMask();case g.Wallets.CoinbaseWallet:return this.connectToCoinbaseWallet();default:throw new Error(`Invalid provider: ${e}. Must be one of "metamask" or "coinbase_wallet".`)}}isWalletEnabled(e){let r=p("mc_is_wallet_enabled",[{wallet:e}]);return this.request(r)}handleWalletSelected(e){return E(this,null,function*(){try{let r=yield this.connectToThirdPartyWallet(e.wallet);yield C(this.localForageKey,e.wallet),this.createIntermediaryEvent(g.Events.WalletConnected,e.payloadId)(r)}catch(r){console.error(r),this.createIntermediaryEvent(g.Events.WalletRejected,e.payloadId)()}})}autoConnectIfWalletBrowser(e){return E(this,null,function*(){let r;e===g.Wallets.MetaMask&&(r=yield this.getMetaMaskProvider().request({method:"eth_requestAccounts"})),e===g.Wallets.CoinbaseWallet&&(r=yield this.getCoinbaseProvider().request({method:"eth_requestAccounts"})),yield C(this.localForageKey,e);let o=p(g.MagicPayloadMethod.AutoConnect,[{wallet:e,address:r}]);return this.request(o)})}};var ue=require("@magic-sdk/types");var{createBoundEmitterMethod:Ne,createChainingEmitterMethod:ne}=le(),Se=class extends x{constructor(){super(...arguments);this.isMagic=!0;this.on=ne("on",this);this.once=ne("once",this);this.addListener=ne("addListener",this);this.off=ne("off",this);this.removeListener=ne("removeListener",this);this.removeAllListeners=ne("removeAllListeners",this);this.emit=Ne("emit");this.eventNames=Ne("eventNames");this.listeners=Ne("listeners");this.listenerCount=Ne("listenerCount")}sendAsync(e,r){if(!r)throw Be({procedure:"Magic.rpcProvider.sendAsync",argument:1,expected:"function",received:r===null?"null":typeof r});if(Array.isArray(e))this.overlay.post(ue.MagicOutgoingWindowMessage.MAGIC_HANDLE_REQUEST,e.map(o=>{let s=j(o);return this.prefixPayloadMethodForTestMode(s),s})).then(o=>{r(null,o.map(s=>H(V({},s.payload),{error:s.hasError?new L(s.payload.error):null})))});else{let o=j(e);this.prefixPayloadMethodForTestMode(o),this.overlay.post(ue.MagicOutgoingWindowMessage.MAGIC_HANDLE_REQUEST,o).then(s=>{r(s.hasError?new L(s.payload.error):null,s.payload)})}}send(e,r){if(typeof e=="string"){let s=p(e,Array.isArray(r)?r:[]);return this.request(s)}if(Array.isArray(e)||!!r){this.sendAsync(e,r);return}let o=Ve();return o.log(),new W(e).applyError({code:-32603,message:o.rawMessage}).payload}enable(){let e=p(ue.MagicPayloadMethod.Login);return this.request(e)}request(e){return this.prefixPayloadMethodForTestMode(e),super.request(e)}prefixPayloadMethodForTestMode(e){let r="testMode/eth/";this.sdk.testMode&&(e.method=`${r}${e.method}`)}};var Ut=["request","overlay","sdk"];function lr(n){let t=Object.getPrototypeOf(n),e=[t];for(;t!==x.prototype;)t=Object.getPrototypeOf(t),e.push(t);return e}var $e=class extends x{constructor(){super(void 0);this.__sdk_access_field_descriptors__=new Map;this.__is_initialized__=!1;this.utils={createPromiEvent:O,isPromiEvent:ze,encodeJSON:ae,decodeJSON:qe,createJsonRpcRequestPayload:p,standardizeJsonRpcRequestPayload:j,storage:Z};let e=[this,...lr(this)];Ut.forEach(r=>{let o=e.map(c=>Object.getOwnPropertyDescriptor(c,r)),s=o.findIndex(c=>!!c),i=s>0,a=o[s];a&&(this.__sdk_access_field_descriptors__.set(r,{descriptor:a,isPrototypeField:i}),Object.defineProperty(this,r,{configurable:!0,get:()=>{throw Ke(r)}}))})}init(e){this.__is_initialized__||(Ut.forEach(r=>{if(this.__sdk_access_field_descriptors__.has(r)){let{descriptor:o,isPrototypeField:s}=this.__sdk_access_field_descriptors__.get(r);s?delete this[r]:Object.defineProperty(this,r,o)}}),this.sdk=e,this.__is_initialized__=!0)}createDeprecationWarning(e){let{method:r,removalVersion:o,useInstead:s}=e,i=s?` Use \`${s}\` instead.`:"",a=`\`${r}\` will be removed from this Extension in version \`${o}\`.${i}`;return new Y(this,"DEPRECATION_NOTICE",a)}createWarning(e,r){return new Y(this,e,r)}createError(e,r,o){return new K(this,e,r,o)}},ot=class extends $e{},_=class extends $e{};_.Internal=ot,_.Anonymous="anonymous extension";var Le=require("@magic-sdk/types");var Oe=class extends x{purchase(t){let e=p(Le.MagicPayloadMethod.NFTPurchase,[t]);return this.request(e)}checkout(t){let e=p(Le.MagicPayloadMethod.NFTCheckout,[t]);return this.request(e)}transfer(t){let e=p(Le.MagicPayloadMethod.NFTTransfer,[t]);return this.request(e)}};function Ft(n){return n.compat&&n.compat[f.sdkName]!=null?typeof n.compat[f.sdkName]=="string"?It(bt(f.version),n.compat[f.sdkName]):!!n.compat[f.sdkName]:!0}function dr(n,t,e){return!t&&!e?`${n}_eth_mainnet`:e?`${n}_${JSON.stringify(e)}`:t?typeof t=="string"?`${n}_eth_${t}`:`${n}_${t.rpcUrl}_${t.chainId}_${t.chainType}`:`${n}_unknown`}function ur(n){var o;let t=(o=n==null?void 0:n.extensions)!=null?o:[],e={},r=[];if(Array.isArray(t)?t.forEach(s=>{Ft(s)?(s.init(this),(s.name||s.name!==_.Anonymous)&&(this[s.name]=s),s instanceof _.Internal&&(z(s.config)||(e[s.name]=s.config))):r.push(s)}):Object.keys(t).forEach(s=>{if(Ft(t[s])){t[s].init(this);let i=t[s];this[s]=i,i instanceof _.Internal&&(z(i.config)||(e[t[s].name]=i.config))}else r.push(t[s])}),r.length)throw je(r);return e}var he=class{constructor(t,e){this.apiKey=t;var i;if(!t)throw We();f.platform==="react-native"&&(e==null?void 0:e.endpoint)&&He().log();let{defaultEndpoint:r,version:o}=f;this.testMode=!!(e!=null&&e.testMode),this.useStorageCache=!!(e!=null&&e.useStorageCache),this.endpoint=xe((i=e==null?void 0:e.endpoint)!=null?i:r).origin,this.auth=new we(this),this.user=new Ce(this),this.wallet=new Ae(this),this.nft=new Oe(this),this.rpcProvider=new Se(this);let s=ur.call(this,e);this.parameters=ae(H(V({API_KEY:this.apiKey,DOMAIN_ORIGIN:window.location?window.location.origin:"",ETH_NETWORK:e==null?void 0:e.network,host:xe(this.endpoint).host,sdk:Pt[f.sdkName],version:o,ext:z(s)?void 0:s,locale:(e==null?void 0:e.locale)||"en_US"},f.bundleId?{bundleId:f.bundleId}:{}),{meta:e==null?void 0:e.meta})),this.networkHash=dr(this.apiKey,e==null?void 0:e.network,z(s)?void 0:s),e!=null&&e.deferPreload||this.preload()}get overlay(){if(!he.__overlays__.has(this.parameters)){let t=new f.ViewController(this.endpoint,this.parameters,this.networkHash);t.init(),he.__overlays__.set(this.parameters,t)}return he.__overlays__.get(this.parameters)}preload(){return E(this,null,function*(){yield this.overlay.checkIsReadyForRequest})}},pe=he;pe.__overlays__=new Map;var G=require("@magic-sdk/types");function pr(n,t){return t&&Array.isArray(n)?n.find(e=>e.id===t):n}function hr(n,t){var o;let e=(o=t.data.response)==null?void 0:o.id,r=pr(n,e);if(e&&r){let s=new W(r).applyResult(t.data.response.result).applyError(t.data.response.error);return{id:e,response:s}}return{}}function mr(n,t,e){return E(this,null,function*(){var a;let r=yield v("rt"),o;if(f.platform==="web")try{o=(a=yield v("jwt"))!=null?a:yield et()}catch(c){console.error("webcrypto error",c)}let s={msgType:n,payload:t};o&&(s.jwt=o),o&&r&&(s.rt=r);let i=yield qt(e);return i&&(s.deviceShare=i),s})}function fr(n){return E(this,null,function*(){!n.data.rt||(yield C("rt",n.data.rt))})}var _e=class{constructor(t,e,r){this.endpoint=t;this.parameters=e;this.networkHash=r;this.messageHandlers=new Set;this.isConnectedToInternet=!0;this.checkIsReadyForRequest=this.waitForReady(),this.isReadyForRequest=!1,this.listen()}post(t,e){return E(this,null,function*(){return be((r,o)=>E(this,null,function*(){if(!this.isConnectedToInternet){let d=Je();o(d)}this.isReadyForRequest||(yield this.waitForReady());let s=[],i=Array.isArray(e)?e.map(d=>d.id):[],a=yield mr(`${t}-${this.parameters}`,e,this.networkHash);yield this._post(a);let c=d=>m=>{var it;let{id:A,response:I}=hr(e,m);if(fr(m),((it=I==null?void 0:I.payload.error)==null?void 0:it.message)==="User denied account access.")te();else if(m.data.deviceShare){let{deviceShare:Wt}=m.data;Dt(Wt,this.networkHash)}A&&I&&Array.isArray(e)&&i.includes(A)?(s.push(I),s.length===e.length&&(d(),r(s))):A&&I&&!Array.isArray(e)&&A===e.id&&(d(),r(I))},l=this.on(G.MagicIncomingWindowMessage.MAGIC_HANDLE_RESPONSE,c(()=>l()))}))})}on(t,e){let r=e.bind(window),o=s=>{s.data.msgType===`${t}-${this.parameters}`&&r(s)};return this.messageHandlers.add(o),()=>this.messageHandlers.delete(o)}waitForReady(){return new Promise(t=>{let e=this.on(G.MagicIncomingWindowMessage.MAGIC_OVERLAY_READY,()=>{this.isReadyForRequest=!0,t(),e()});setTimeout(()=>{this.isReadyForRequest=!0,t(),e()},15e3)})}listen(){this.on(G.MagicIncomingWindowMessage.MAGIC_HIDE_OVERLAY,()=>{this.hideOverlay()}),this.on(G.MagicIncomingWindowMessage.MAGIC_SHOW_OVERLAY,()=>{this.showOverlay()}),this.on(G.MagicIncomingWindowMessage.MAGIC_SEND_PRODUCT_ANNOUNCEMENT,t=>{t.data.response.result.product_announcement&&new q(G.SDKWarningCode.ProductAnnouncement,t.data.response.result.product_announcement).log()})}};
//# sourceMappingURL=index.js.map

@@ -1,6 +0,6 @@

var Ht=Object.create;var he=Object.defineProperty,Xt=Object.defineProperties,zt=Object.getOwnPropertyDescriptor,Yt=Object.getOwnPropertyDescriptors,Qt=Object.getOwnPropertyNames,Qe=Object.getOwnPropertySymbols,Zt=Object.getPrototypeOf,et=Object.prototype.hasOwnProperty,en=Object.prototype.propertyIsEnumerable;var Ze=(n,t,e)=>t in n?he(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,V=(n,t)=>{for(var e in t||(t={}))et.call(t,e)&&Ze(n,e,t[e]);if(Qe)for(var e of Qe(t))en.call(t,e)&&Ze(n,e,t[e]);return n},H=(n,t)=>Xt(n,Yt(t));var tn=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports),nn=(n,t)=>{for(var e in t)he(n,e,{get:t[e],enumerable:!0})},rn=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Qt(t))!et.call(n,o)&&o!==e&&he(n,o,{get:()=>t[o],enumerable:!(r=zt(t,o))||r.enumerable});return n};var sn=(n,t,e)=>(e=n!=null?Ht(Zt(n)):{},rn(t||!n||!n.__esModule?he(e,"default",{value:n,enumerable:!0}):e,n));var m=(n,t,e)=>new Promise((r,o)=>{var s=c=>{try{a(e.next(c))}catch(l){o(l)}},i=c=>{try{a(e.throw(c))}catch(l){o(l)}},a=c=>c.done?r(c.value):Promise.resolve(c.value).then(s,i);a((e=e.apply(n,t)).next())});var Ct=tn((zr,qe)=>{"use strict";var er=Object.prototype.hasOwnProperty,w="~";function ce(){}Object.create&&(ce.prototype=Object.create(null),new ce().__proto__||(w=!1));function tr(n,t,e){this.fn=n,this.context=t,this.once=e||!1}function xt(n,t,e,r,o){if(typeof e!="function")throw new TypeError("The listener must be a function");var s=new tr(e,r||n,o),i=w?w+t:t;return n._events[i]?n._events[i].fn?n._events[i]=[n._events[i],s]:n._events[i].push(s):(n._events[i]=s,n._eventsCount++),n}function ve(n,t){--n._eventsCount===0?n._events=new ce:delete n._events[t]}function I(){this._events=new ce,this._eventsCount=0}I.prototype.eventNames=function(){var t=[],e,r;if(this._eventsCount===0)return t;for(r in e=this._events)er.call(e,r)&&t.push(w?r.slice(1):r);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(e)):t};I.prototype.listeners=function(t){var e=w?w+t:t,r=this._events[e];if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,i=new Array(s);o<s;o++)i[o]=r[o].fn;return i};I.prototype.listenerCount=function(t){var e=w?w+t:t,r=this._events[e];return r?r.fn?1:r.length:0};I.prototype.emit=function(t,e,r,o,s,i){var a=w?w+t:t;if(!this._events[a])return!1;var c=this._events[a],l=arguments.length,d,p;if(c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,e),!0;case 3:return c.fn.call(c.context,e,r),!0;case 4:return c.fn.call(c.context,e,r,o),!0;case 5:return c.fn.call(c.context,e,r,o,s),!0;case 6:return c.fn.call(c.context,e,r,o,s,i),!0}for(p=1,d=new Array(l-1);p<l;p++)d[p-1]=arguments[p];c.fn.apply(c.context,d)}else{var x=c.length,v;for(p=0;p<x;p++)switch(c[p].once&&this.removeListener(t,c[p].fn,void 0,!0),l){case 1:c[p].fn.call(c[p].context);break;case 2:c[p].fn.call(c[p].context,e);break;case 3:c[p].fn.call(c[p].context,e,r);break;case 4:c[p].fn.call(c[p].context,e,r,o);break;default:if(!d)for(v=1,d=new Array(l-1);v<l;v++)d[v-1]=arguments[v];c[p].fn.apply(c[p].context,d)}}return!0};I.prototype.on=function(t,e,r){return xt(this,t,e,r,!1)};I.prototype.once=function(t,e,r){return xt(this,t,e,r,!0)};I.prototype.removeListener=function(t,e,r,o){var s=w?w+t:t;if(!this._events[s])return this;if(!e)return ve(this,s),this;var i=this._events[s];if(i.fn)i.fn===e&&(!o||i.once)&&(!r||i.context===r)&&ve(this,s);else{for(var a=0,c=[],l=i.length;a<l;a++)(i[a].fn!==e||o&&!i[a].once||r&&i[a].context!==r)&&c.push(i[a]);c.length?this._events[s]=c.length===1?c[0]:c:ve(this,s)}return this};I.prototype.removeAllListeners=function(t){var e;return t?(e=w?w+t:t,this._events[e]&&ve(this,e)):(this._events=new ce,this._eventsCount=0),this};I.prototype.off=I.prototype.removeListener;I.prototype.addListener=I.prototype.on;I.prefixed=w;I.EventEmitter=I;typeof qe<"u"&&(qe.exports=I)});function on(n){let t={exports:{}};return n(t,t.exports),t.exports}var an=Number.MAX_SAFE_INTEGER||9007199254740991;var _e={SEMVER_SPEC_VERSION:"2.0.0",MAX_LENGTH:256,MAX_SAFE_INTEGER:an,MAX_SAFE_COMPONENT_LENGTH:16},cn=typeof process=="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...n)=>console.error("SEMVER",...n):()=>{},f=cn,oe=on(function(n,t){let{MAX_SAFE_COMPONENT_LENGTH:e}=_e,r=(t=n.exports={}).re=[],o=t.src=[],s=t.t={},i=0,a=(c,l,d)=>{let p=i++;f(p,l),s[c]=p,o[p]=l,r[p]=new RegExp(l,d?"g":void 0)};a("NUMERICIDENTIFIER","0|[1-9]\\d*"),a("NUMERICIDENTIFIERLOOSE","[0-9]+"),a("NONNUMERICIDENTIFIER","\\d*[a-zA-Z-][a-zA-Z0-9-]*"),a("MAINVERSION",`(${o[s.NUMERICIDENTIFIER]})\\.(${o[s.NUMERICIDENTIFIER]})\\.(${o[s.NUMERICIDENTIFIER]})`),a("MAINVERSIONLOOSE",`(${o[s.NUMERICIDENTIFIERLOOSE]})\\.(${o[s.NUMERICIDENTIFIERLOOSE]})\\.(${o[s.NUMERICIDENTIFIERLOOSE]})`),a("PRERELEASEIDENTIFIER",`(?:${o[s.NUMERICIDENTIFIER]}|${o[s.NONNUMERICIDENTIFIER]})`),a("PRERELEASEIDENTIFIERLOOSE",`(?:${o[s.NUMERICIDENTIFIERLOOSE]}|${o[s.NONNUMERICIDENTIFIER]})`),a("PRERELEASE",`(?:-(${o[s.PRERELEASEIDENTIFIER]}(?:\\.${o[s.PRERELEASEIDENTIFIER]})*))`),a("PRERELEASELOOSE",`(?:-?(${o[s.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${o[s.PRERELEASEIDENTIFIERLOOSE]})*))`),a("BUILDIDENTIFIER","[0-9A-Za-z-]+"),a("BUILD",`(?:\\+(${o[s.BUILDIDENTIFIER]}(?:\\.${o[s.BUILDIDENTIFIER]})*))`),a("FULLPLAIN",`v?${o[s.MAINVERSION]}${o[s.PRERELEASE]}?${o[s.BUILD]}?`),a("FULL",`^${o[s.FULLPLAIN]}$`),a("LOOSEPLAIN",`[v=\\s]*${o[s.MAINVERSIONLOOSE]}${o[s.PRERELEASELOOSE]}?${o[s.BUILD]}?`),a("LOOSE",`^${o[s.LOOSEPLAIN]}$`),a("GTLT","((?:<|>)?=?)"),a("XRANGEIDENTIFIERLOOSE",`${o[s.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),a("XRANGEIDENTIFIER",`${o[s.NUMERICIDENTIFIER]}|x|X|\\*`),a("XRANGEPLAIN",`[v=\\s]*(${o[s.XRANGEIDENTIFIER]})(?:\\.(${o[s.XRANGEIDENTIFIER]})(?:\\.(${o[s.XRANGEIDENTIFIER]})(?:${o[s.PRERELEASE]})?${o[s.BUILD]}?)?)?`),a("XRANGEPLAINLOOSE",`[v=\\s]*(${o[s.XRANGEIDENTIFIERLOOSE]})(?:\\.(${o[s.XRANGEIDENTIFIERLOOSE]})(?:\\.(${o[s.XRANGEIDENTIFIERLOOSE]})(?:${o[s.PRERELEASELOOSE]})?${o[s.BUILD]}?)?)?`),a("XRANGE",`^${o[s.GTLT]}\\s*${o[s.XRANGEPLAIN]}$`),a("XRANGELOOSE",`^${o[s.GTLT]}\\s*${o[s.XRANGEPLAINLOOSE]}$`),a("COERCE",`(^|[^\\d])(\\d{1,${e}})(?:\\.(\\d{1,${e}}))?(?:\\.(\\d{1,${e}}))?(?:$|[^\\d])`),a("COERCERTL",o[s.COERCE],!0),a("LONETILDE","(?:~>?)"),a("TILDETRIM",`(\\s*)${o[s.LONETILDE]}\\s+`,!0),t.tildeTrimReplace="$1~",a("TILDE",`^${o[s.LONETILDE]}${o[s.XRANGEPLAIN]}$`),a("TILDELOOSE",`^${o[s.LONETILDE]}${o[s.XRANGEPLAINLOOSE]}$`),a("LONECARET","(?:\\^)"),a("CARETTRIM",`(\\s*)${o[s.LONECARET]}\\s+`,!0),t.caretTrimReplace="$1^",a("CARET",`^${o[s.LONECARET]}${o[s.XRANGEPLAIN]}$`),a("CARETLOOSE",`^${o[s.LONECARET]}${o[s.XRANGEPLAINLOOSE]}$`),a("COMPARATORLOOSE",`^${o[s.GTLT]}\\s*(${o[s.LOOSEPLAIN]})$|^$`),a("COMPARATOR",`^${o[s.GTLT]}\\s*(${o[s.FULLPLAIN]})$|^$`),a("COMPARATORTRIM",`(\\s*)${o[s.GTLT]}\\s*(${o[s.LOOSEPLAIN]}|${o[s.XRANGEPLAIN]})`,!0),t.comparatorTrimReplace="$1$2$3",a("HYPHENRANGE",`^\\s*(${o[s.XRANGEPLAIN]})\\s+-\\s+(${o[s.XRANGEPLAIN]})\\s*$`),a("HYPHENRANGELOOSE",`^\\s*(${o[s.XRANGEPLAINLOOSE]})\\s+-\\s+(${o[s.XRANGEPLAINLOOSE]})\\s*$`),a("STAR","(<|>)?=?\\s*\\*"),a("GTE0","^\\s*>=\\s*0.0.0\\s*$"),a("GTE0PRE","^\\s*>=\\s*0.0.0-0\\s*$")}),tt=/^[0-9]+$/,dt=(n,t)=>{let e=tt.test(n),r=tt.test(t);return e&&r&&(n=+n,t=+t),n===t?0:e&&!r?-1:r&&!e?1:n<t?-1:1},ln=(n,t)=>dt(t,n),dn={compareIdentifiers:dt,rcompareIdentifiers:ln},{MAX_LENGTH:nt,MAX_SAFE_INTEGER:me}=_e,{re:rt,t:st}=oe,{compareIdentifiers:re}=dn,E=class{constructor(t,e){if(e&&typeof e=="object"||(e={loose:!!e,includePrerelease:!1}),t instanceof E){if(t.loose===!!e.loose&&t.includePrerelease===!!e.includePrerelease)return t;t=t.version}else if(typeof t!="string")throw new TypeError(`Invalid Version: ${t}`);if(t.length>nt)throw new TypeError(`version is longer than ${nt} characters`);f("SemVer",t,e),this.options=e,this.loose=!!e.loose,this.includePrerelease=!!e.includePrerelease;let r=t.trim().match(e.loose?rt[st.LOOSE]:rt[st.FULL]);if(!r)throw new TypeError(`Invalid Version: ${t}`);if(this.raw=t,this.major=+r[1],this.minor=+r[2],this.patch=+r[3],this.major>me||this.major<0)throw new TypeError("Invalid major version");if(this.minor>me||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>me||this.patch<0)throw new TypeError("Invalid patch version");r[4]?this.prerelease=r[4].split(".").map(o=>{if(/^[0-9]+$/.test(o)){let s=+o;if(s>=0&&s<me)return s}return o}):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(t){if(f("SemVer.compare",this.version,this.options,t),!(t instanceof E)){if(typeof t=="string"&&t===this.version)return 0;t=new E(t,this.options)}return t.version===this.version?0:this.compareMain(t)||this.comparePre(t)}compareMain(t){return t instanceof E||(t=new E(t,this.options)),re(this.major,t.major)||re(this.minor,t.minor)||re(this.patch,t.patch)}comparePre(t){if(t instanceof E||(t=new E(t,this.options)),this.prerelease.length&&!t.prerelease.length)return-1;if(!this.prerelease.length&&t.prerelease.length)return 1;if(!this.prerelease.length&&!t.prerelease.length)return 0;let e=0;do{let r=this.prerelease[e],o=t.prerelease[e];if(f("prerelease compare",e,r,o),r===void 0&&o===void 0)return 0;if(o===void 0)return 1;if(r===void 0)return-1;if(r!==o)return re(r,o)}while(++e)}compareBuild(t){t instanceof E||(t=new E(t,this.options));let e=0;do{let r=this.build[e],o=t.build[e];if(f("prerelease compare",e,r,o),r===void 0&&o===void 0)return 0;if(o===void 0)return 1;if(r===void 0)return-1;if(r!==o)return re(r,o)}while(++e)}inc(t,e){switch(t){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",e);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",e);break;case"prepatch":this.prerelease.length=0,this.inc("patch",e),this.inc("pre",e);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",e),this.inc("pre",e);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)}e&&(this.prerelease[0]===e?isNaN(this.prerelease[1])&&(this.prerelease=[e,0]):this.prerelease=[e,0]);break;default:throw new Error(`invalid increment argument: ${t}`)}return this.format(),this.raw=this.version,this}},un=(n,t,e)=>new E(n,e).compare(new E(t,e)),X=un,pn=(n,t,e)=>X(n,t,e)===0,hn=pn,mn=(n,t,e)=>X(n,t,e)!==0,fn=mn,En=(n,t,e)=>X(n,t,e)>0,gn=En,yn=(n,t,e)=>X(n,t,e)>=0,Rn=yn,vn=(n,t,e)=>X(n,t,e)<0,Tn=vn,In=(n,t,e)=>X(n,t,e)<=0,bn=In,wn=(n,t,e,r)=>{switch(t){case"===":return typeof n=="object"&&(n=n.version),typeof e=="object"&&(e=e.version),n===e;case"!==":return typeof n=="object"&&(n=n.version),typeof e=="object"&&(e=e.version),n!==e;case"":case"=":case"==":return hn(n,e,r);case"!=":return fn(n,e,r);case">":return gn(n,e,r);case">=":return Rn(n,e,r);case"<":return Tn(n,e,r);case"<=":return bn(n,e,r);default:throw new TypeError(`Invalid operator: ${t}`)}},Oe=wn,se=Symbol("SemVer ANY"),D=class{static get ANY(){return se}constructor(t,e){if(e&&typeof e=="object"||(e={loose:!!e,includePrerelease:!1}),t instanceof D){if(t.loose===!!e.loose)return t;t=t.value}f("comparator",t,e),this.options=e,this.loose=!!e.loose,this.parse(t),this.semver===se?this.value="":this.value=this.operator+this.semver.version,f("comp",this)}parse(t){let e=this.options.loose?ot[it.COMPARATORLOOSE]:ot[it.COMPARATOR],r=t.match(e);if(!r)throw new TypeError(`Invalid comparator: ${t}`);this.operator=r[1]!==void 0?r[1]:"",this.operator==="="&&(this.operator=""),r[2]?this.semver=new E(r[2],this.options.loose):this.semver=se}toString(){return this.value}test(t){if(f("Comparator.test",t,this.options.loose),this.semver===se||t===se)return!0;if(typeof t=="string")try{t=new E(t,this.options)}catch(e){return!1}return Oe(t,this.operator,this.semver,this.options)}intersects(t,e){if(!(t instanceof D))throw new TypeError("a Comparator is required");if(e&&typeof e=="object"||(e={loose:!!e,includePrerelease:!1}),this.operator==="")return this.value===""||new L(t.value,e).test(this.value);if(t.operator==="")return t.value===""||new L(this.value,e).test(t.semver);let r=!(this.operator!==">="&&this.operator!==">"||t.operator!==">="&&t.operator!==">"),o=!(this.operator!=="<="&&this.operator!=="<"||t.operator!=="<="&&t.operator!=="<"),s=this.semver.version===t.semver.version,i=!(this.operator!==">="&&this.operator!=="<="||t.operator!==">="&&t.operator!=="<="),a=Oe(this.semver,"<",t.semver,e)&&(this.operator===">="||this.operator===">")&&(t.operator==="<="||t.operator==="<"),c=Oe(this.semver,">",t.semver,e)&&(this.operator==="<="||this.operator==="<")&&(t.operator===">="||t.operator===">");return r||o||s&&i||a||c}},{re:ot,t:it}=oe,L=class{constructor(t,e){if(e&&typeof e=="object"||(e={loose:!!e,includePrerelease:!1}),t instanceof L)return t.loose===!!e.loose&&t.includePrerelease===!!e.includePrerelease?t:new L(t.raw,e);if(t instanceof D)return this.raw=t.value,this.set=[[t]],this.format(),this;if(this.options=e,this.loose=!!e.loose,this.includePrerelease=!!e.includePrerelease,this.raw=t,this.set=t.split(/\s*\|\|\s*/).map(r=>this.parseRange(r.trim())).filter(r=>r.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${t}`);this.format()}format(){return this.range=this.set.map(t=>t.join(" ").trim()).join("||").trim(),this.range}toString(){return this.range}parseRange(t){let{loose:e}=this.options;t=t.trim();let r=e?T[R.HYPHENRANGELOOSE]:T[R.HYPHENRANGE];t=t.replace(r,qn(this.options.includePrerelease)),f("hyphen replace",t),t=t.replace(T[R.COMPARATORTRIM],Pn),f("comparator trim",t,T[R.COMPARATORTRIM]),t=(t=(t=t.replace(T[R.TILDETRIM],Mn)).replace(T[R.CARETTRIM],xn)).split(/\s+/).join(" ");let o=e?T[R.COMPARATORLOOSE]:T[R.COMPARATOR];return t.split(" ").map(s=>Cn(s,this.options)).join(" ").split(/\s+/).map(s=>kn(s,this.options)).filter(this.options.loose?s=>!!s.match(o):()=>!0).map(s=>new D(s,this.options))}intersects(t,e){if(!(t instanceof L))throw new TypeError("a Range is required");return this.set.some(r=>at(r,e)&&t.set.some(o=>at(o,e)&&r.every(s=>o.every(i=>s.intersects(i,e)))))}test(t){if(!t)return!1;if(typeof t=="string")try{t=new E(t,this.options)}catch(e){return!1}for(let e=0;e<this.set.length;e++)if(Dn(this.set[e],t,this.options))return!0;return!1}},{re:T,t:R,comparatorTrimReplace:Pn,tildeTrimReplace:Mn,caretTrimReplace:xn}=oe,at=(n,t)=>{let e=!0,r=n.slice(),o=r.pop();for(;e&&r.length;)e=r.every(s=>o.intersects(s,t)),o=r.pop();return e},Cn=(n,t)=>(f("comp",n,t),n=Sn(n,t),f("caret",n),n=An(n,t),f("tildes",n),n=Ln(n,t),f("xrange",n),n=_n(n,t),f("stars",n),n),b=n=>!n||n.toLowerCase()==="x"||n==="*",An=(n,t)=>n.trim().split(/\s+/).map(e=>Nn(e,t)).join(" "),Nn=(n,t)=>{let e=t.loose?T[R.TILDELOOSE]:T[R.TILDE];return n.replace(e,(r,o,s,i,a)=>{let c;return f("tilde",n,r,o,s,i,a),b(o)?c="":b(s)?c=`>=${o}.0.0 <${+o+1}.0.0-0`:b(i)?c=`>=${o}.${s}.0 <${o}.${+s+1}.0-0`:a?(f("replaceTilde pr",a),c=`>=${o}.${s}.${i}-${a} <${o}.${+s+1}.0-0`):c=`>=${o}.${s}.${i} <${o}.${+s+1}.0-0`,f("tilde return",c),c})},Sn=(n,t)=>n.trim().split(/\s+/).map(e=>$n(e,t)).join(" "),$n=(n,t)=>{f("caret",n,t);let e=t.loose?T[R.CARETLOOSE]:T[R.CARET],r=t.includePrerelease?"-0":"";return n.replace(e,(o,s,i,a,c)=>{let l;return f("caret",n,o,s,i,a,c),b(s)?l="":b(i)?l=`>=${s}.0.0${r} <${+s+1}.0.0-0`:b(a)?l=s==="0"?`>=${s}.${i}.0${r} <${s}.${+i+1}.0-0`:`>=${s}.${i}.0${r} <${+s+1}.0.0-0`:c?(f("replaceCaret pr",c),l=s==="0"?i==="0"?`>=${s}.${i}.${a}-${c} <${s}.${i}.${+a+1}-0`:`>=${s}.${i}.${a}-${c} <${s}.${+i+1}.0-0`:`>=${s}.${i}.${a}-${c} <${+s+1}.0.0-0`):(f("no pr"),l=s==="0"?i==="0"?`>=${s}.${i}.${a}${r} <${s}.${i}.${+a+1}-0`:`>=${s}.${i}.${a}${r} <${s}.${+i+1}.0-0`:`>=${s}.${i}.${a} <${+s+1}.0.0-0`),f("caret return",l),l})},Ln=(n,t)=>(f("replaceXRanges",n,t),n.split(/\s+/).map(e=>On(e,t)).join(" ")),On=(n,t)=>{n=n.trim();let e=t.loose?T[R.XRANGELOOSE]:T[R.XRANGE];return n.replace(e,(r,o,s,i,a,c)=>{f("xRange",n,r,o,s,i,a,c);let l=b(s),d=l||b(i),p=d||b(a),x=p;return o==="="&&x&&(o=""),c=t.includePrerelease?"-0":"",l?r=o===">"||o==="<"?"<0.0.0-0":"*":o&&x?(d&&(i=0),a=0,o===">"?(o=">=",d?(s=+s+1,i=0,a=0):(i=+i+1,a=0)):o==="<="&&(o="<",d?s=+s+1:i=+i+1),o==="<"&&(c="-0"),r=`${o+s}.${i}.${a}${c}`):d?r=`>=${s}.0.0${c} <${+s+1}.0.0-0`:p&&(r=`>=${s}.${i}.0${c} <${s}.${+i+1}.0-0`),f("xRange return",r),r})},_n=(n,t)=>(f("replaceStars",n,t),n.trim().replace(T[R.STAR],"")),kn=(n,t)=>(f("replaceGTE0",n,t),n.trim().replace(T[t.includePrerelease?R.GTE0PRE:R.GTE0],"")),qn=n=>(t,e,r,o,s,i,a,c,l,d,p,x,v)=>`${e=b(r)?"":b(o)?`>=${r}.0.0${n?"-0":""}`:b(s)?`>=${r}.${o}.0${n?"-0":""}`:i?`>=${e}`:`>=${e}${n?"-0":""}`} ${c=b(l)?"":b(d)?`<${+l+1}.0.0-0`:b(p)?`<${l}.${+d+1}.0-0`:x?`<=${l}.${d}.${p}-${x}`:n?`<${l}.${d}.${+p+1}-0`:`<=${c}`}`.trim(),Dn=(n,t,e)=>{for(let r=0;r<n.length;r++)if(!n[r].test(t))return!1;if(t.prerelease.length&&!e.includePrerelease){for(let r=0;r<n.length;r++)if(f(n[r].semver),n[r].semver!==D.ANY&&n[r].semver.prerelease.length>0){let o=n[r].semver;if(o.major===t.major&&o.minor===t.minor&&o.patch===t.patch)return!0}return!1}return!0},ut=(n,t,e)=>{try{t=new L(t,e)}catch(r){return!1}return t.test(n)};var{MAX_LENGTH:Un}=_e,{re:ct,t:lt}=oe,Fn=(n,t)=>{if(t&&typeof t=="object"||(t={loose:!!t,includePrerelease:!1}),n instanceof E)return n;if(typeof n!="string"||n.length>Un||!(t.loose?ct[lt.LOOSE]:ct[lt.FULL]).test(n))return null;try{return new E(n,t)}catch(e){return null}},Wn=Fn,{re:fe,t:Ee}=oe,pt=(n,t)=>{if(n instanceof E)return n;if(typeof n=="number"&&(n=String(n)),typeof n!="string")return null;let e=null;if((t=t||{}).rtl){let r;for(;(r=fe[Ee.COERCERTL].exec(n))&&(!e||e.index+e[0].length!==n.length);)e&&r.index+r[0].length===e.index+e[0].length||(e=r),fe[Ee.COERCERTL].lastIndex=r.index+r[1].length+r[2].length;fe[Ee.COERCERTL].lastIndex=-1}else e=n.match(fe[Ee.COERCE]);return e===null?null:Wn(`${e[2]}.${e[3]||"0"}.${e[4]||"0"}`,t)};function Jn(n){return String.fromCharCode(parseInt(n.slice(1),16))}function Gn(n){return`%${`00${n.charCodeAt(0).toString(16)}`.slice(-2)}`}function Kn(n){return btoa(encodeURIComponent(n).replace(/%[0-9A-F]{2}/g,Jn))}function jn(n){return decodeURIComponent(Array.from(atob(n),Gn).join(""))}function ge(n){return Kn(JSON.stringify(n))}function ht(n){return JSON.parse(jn(n))}import{RPCErrorCode as zn,SDKErrorCode as Y,SDKWarningCode as Re}from"@magic-sdk/types";import{MagicPayloadMethod as Bn,RPCErrorCode as Vn}from"@magic-sdk/types";function O(n){return typeof n=="undefined"}function Hn(n){return n===null}function ye(n){return Hn(n)||O(n)}function kr(n){return ye(n)?!1:!O(n.jsonrpc)&&!O(n.id)&&!O(n.method)&&!O(n.params)}function mt(n){return ye(n)?!1:!O(n.jsonrpc)&&!O(n.id)&&(!O(n.result)||!O(n.error))}function qr(n){return ye(n)?!1:typeof n=="string"&&Object.values(Bn).includes(n)}function ft(n){return ye(n)?!1:typeof n=="number"&&Object.values(Vn).includes(n)}function ie(n){if(!n)return!0;for(let t in n)if(Object.hasOwnProperty.call(n,t))return!1;return!0}var h={};function Xn(n,t){return Object.assign(h,t),n}var Et={"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"};var S=class extends Error{constructor(e,r){super(`Magic SDK Error: [${e}] ${r}`);this.code=e;this.rawMessage=r;this.__proto__=Error;Object.setPrototypeOf(this,S.prototype)}},_=class extends Error{constructor(e){super();this.__proto__=Error;let r=Number(e==null?void 0:e.code);this.rawMessage=(e==null?void 0:e.message)||"Internal error",this.code=ft(r)?r:zn.InternalError,this.message=`Magic RPC Error: [${this.code}] ${this.rawMessage}`,this.data=(e==null?void 0:e.data)||void 0,Object.setPrototypeOf(this,_.prototype)}},U=class{constructor(t,e){this.code=t;this.rawMessage=e;this.message=`Magic SDK Warning: [${t}] ${e}`}log(){console.warn(this.message)}},z=class extends Error{constructor(e,r,o,s){super(`Magic Extension Error (${e.name}): [${r}] ${o}`);this.code=r;this.rawMessage=o;this.data=s;this.__proto__=Error;Object.setPrototypeOf(this,z.prototype)}},ae=class{constructor(t,e,r){this.code=e;this.rawMessage=r;this.message=`Magic Extension Warning (${t.name}): [${e}] ${r}`}log(){console.warn(this.message)}};function gt(){return new S(Y.MissingApiKey,"Please provide an API key that you acquired from the Magic developer dashboard.")}function yt(){return new S(Y.ModalNotReady,"Modal is not ready.")}function Rt(){return new S(Y.MalformedResponse,"Response from the Magic iframe is malformed.")}function vt(n){return new S(Y.ExtensionNotInitialized,`Extensions must be initialized with a Magic SDK instance before \`Extension.${n}\` can be accessed. Do not invoke \`Extension.${n}\` inside an extension constructor.`)}function Tt(n){let t=`Some extensions are incompatible with \`${h.sdkName}@${h.version}\`:`;return n.filter(e=>typeof e.compat!="undefined"&&e.compat!==null).forEach(e=>{let r=e.compat[h.sdkName];typeof r=="string"?t+=`
var Ht=Object.create;var he=Object.defineProperty,Xt=Object.defineProperties,zt=Object.getOwnPropertyDescriptor,Yt=Object.getOwnPropertyDescriptors,Qt=Object.getOwnPropertyNames,Qe=Object.getOwnPropertySymbols,Zt=Object.getPrototypeOf,et=Object.prototype.hasOwnProperty,en=Object.prototype.propertyIsEnumerable;var Ze=(n,t,e)=>t in n?he(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,H=(n,t)=>{for(var e in t||(t={}))et.call(t,e)&&Ze(n,e,t[e]);if(Qe)for(var e of Qe(t))en.call(t,e)&&Ze(n,e,t[e]);return n},X=(n,t)=>Xt(n,Yt(t));var tn=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports),nn=(n,t)=>{for(var e in t)he(n,e,{get:t[e],enumerable:!0})},rn=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Qt(t))!et.call(n,o)&&o!==e&&he(n,o,{get:()=>t[o],enumerable:!(r=zt(t,o))||r.enumerable});return n};var sn=(n,t,e)=>(e=n!=null?Ht(Zt(n)):{},rn(t||!n||!n.__esModule?he(e,"default",{value:n,enumerable:!0}):e,n));var m=(n,t,e)=>new Promise((r,o)=>{var s=c=>{try{a(e.next(c))}catch(l){o(l)}},i=c=>{try{a(e.throw(c))}catch(l){o(l)}},a=c=>c.done?r(c.value):Promise.resolve(c.value).then(s,i);a((e=e.apply(n,t)).next())});var Ct=tn((zr,De)=>{"use strict";var er=Object.prototype.hasOwnProperty,w="~";function ce(){}Object.create&&(ce.prototype=Object.create(null),new ce().__proto__||(w=!1));function tr(n,t,e){this.fn=n,this.context=t,this.once=e||!1}function xt(n,t,e,r,o){if(typeof e!="function")throw new TypeError("The listener must be a function");var s=new tr(e,r||n,o),i=w?w+t:t;return n._events[i]?n._events[i].fn?n._events[i]=[n._events[i],s]:n._events[i].push(s):(n._events[i]=s,n._eventsCount++),n}function ve(n,t){--n._eventsCount===0?n._events=new ce:delete n._events[t]}function I(){this._events=new ce,this._eventsCount=0}I.prototype.eventNames=function(){var t=[],e,r;if(this._eventsCount===0)return t;for(r in e=this._events)er.call(e,r)&&t.push(w?r.slice(1):r);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(e)):t};I.prototype.listeners=function(t){var e=w?w+t:t,r=this._events[e];if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,i=new Array(s);o<s;o++)i[o]=r[o].fn;return i};I.prototype.listenerCount=function(t){var e=w?w+t:t,r=this._events[e];return r?r.fn?1:r.length:0};I.prototype.emit=function(t,e,r,o,s,i){var a=w?w+t:t;if(!this._events[a])return!1;var c=this._events[a],l=arguments.length,d,p;if(c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,e),!0;case 3:return c.fn.call(c.context,e,r),!0;case 4:return c.fn.call(c.context,e,r,o),!0;case 5:return c.fn.call(c.context,e,r,o,s),!0;case 6:return c.fn.call(c.context,e,r,o,s,i),!0}for(p=1,d=new Array(l-1);p<l;p++)d[p-1]=arguments[p];c.fn.apply(c.context,d)}else{var x=c.length,v;for(p=0;p<x;p++)switch(c[p].once&&this.removeListener(t,c[p].fn,void 0,!0),l){case 1:c[p].fn.call(c[p].context);break;case 2:c[p].fn.call(c[p].context,e);break;case 3:c[p].fn.call(c[p].context,e,r);break;case 4:c[p].fn.call(c[p].context,e,r,o);break;default:if(!d)for(v=1,d=new Array(l-1);v<l;v++)d[v-1]=arguments[v];c[p].fn.apply(c[p].context,d)}}return!0};I.prototype.on=function(t,e,r){return xt(this,t,e,r,!1)};I.prototype.once=function(t,e,r){return xt(this,t,e,r,!0)};I.prototype.removeListener=function(t,e,r,o){var s=w?w+t:t;if(!this._events[s])return this;if(!e)return ve(this,s),this;var i=this._events[s];if(i.fn)i.fn===e&&(!o||i.once)&&(!r||i.context===r)&&ve(this,s);else{for(var a=0,c=[],l=i.length;a<l;a++)(i[a].fn!==e||o&&!i[a].once||r&&i[a].context!==r)&&c.push(i[a]);c.length?this._events[s]=c.length===1?c[0]:c:ve(this,s)}return this};I.prototype.removeAllListeners=function(t){var e;return t?(e=w?w+t:t,this._events[e]&&ve(this,e)):(this._events=new ce,this._eventsCount=0),this};I.prototype.off=I.prototype.removeListener;I.prototype.addListener=I.prototype.on;I.prefixed=w;I.EventEmitter=I;typeof De<"u"&&(De.exports=I)});function on(n){let t={exports:{}};return n(t,t.exports),t.exports}var an=Number.MAX_SAFE_INTEGER||9007199254740991;var _e={SEMVER_SPEC_VERSION:"2.0.0",MAX_LENGTH:256,MAX_SAFE_INTEGER:an,MAX_SAFE_COMPONENT_LENGTH:16},cn=typeof process=="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...n)=>console.error("SEMVER",...n):()=>{},f=cn,oe=on(function(n,t){let{MAX_SAFE_COMPONENT_LENGTH:e}=_e,r=(t=n.exports={}).re=[],o=t.src=[],s=t.t={},i=0,a=(c,l,d)=>{let p=i++;f(p,l),s[c]=p,o[p]=l,r[p]=new RegExp(l,d?"g":void 0)};a("NUMERICIDENTIFIER","0|[1-9]\\d*"),a("NUMERICIDENTIFIERLOOSE","[0-9]+"),a("NONNUMERICIDENTIFIER","\\d*[a-zA-Z-][a-zA-Z0-9-]*"),a("MAINVERSION",`(${o[s.NUMERICIDENTIFIER]})\\.(${o[s.NUMERICIDENTIFIER]})\\.(${o[s.NUMERICIDENTIFIER]})`),a("MAINVERSIONLOOSE",`(${o[s.NUMERICIDENTIFIERLOOSE]})\\.(${o[s.NUMERICIDENTIFIERLOOSE]})\\.(${o[s.NUMERICIDENTIFIERLOOSE]})`),a("PRERELEASEIDENTIFIER",`(?:${o[s.NUMERICIDENTIFIER]}|${o[s.NONNUMERICIDENTIFIER]})`),a("PRERELEASEIDENTIFIERLOOSE",`(?:${o[s.NUMERICIDENTIFIERLOOSE]}|${o[s.NONNUMERICIDENTIFIER]})`),a("PRERELEASE",`(?:-(${o[s.PRERELEASEIDENTIFIER]}(?:\\.${o[s.PRERELEASEIDENTIFIER]})*))`),a("PRERELEASELOOSE",`(?:-?(${o[s.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${o[s.PRERELEASEIDENTIFIERLOOSE]})*))`),a("BUILDIDENTIFIER","[0-9A-Za-z-]+"),a("BUILD",`(?:\\+(${o[s.BUILDIDENTIFIER]}(?:\\.${o[s.BUILDIDENTIFIER]})*))`),a("FULLPLAIN",`v?${o[s.MAINVERSION]}${o[s.PRERELEASE]}?${o[s.BUILD]}?`),a("FULL",`^${o[s.FULLPLAIN]}$`),a("LOOSEPLAIN",`[v=\\s]*${o[s.MAINVERSIONLOOSE]}${o[s.PRERELEASELOOSE]}?${o[s.BUILD]}?`),a("LOOSE",`^${o[s.LOOSEPLAIN]}$`),a("GTLT","((?:<|>)?=?)"),a("XRANGEIDENTIFIERLOOSE",`${o[s.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),a("XRANGEIDENTIFIER",`${o[s.NUMERICIDENTIFIER]}|x|X|\\*`),a("XRANGEPLAIN",`[v=\\s]*(${o[s.XRANGEIDENTIFIER]})(?:\\.(${o[s.XRANGEIDENTIFIER]})(?:\\.(${o[s.XRANGEIDENTIFIER]})(?:${o[s.PRERELEASE]})?${o[s.BUILD]}?)?)?`),a("XRANGEPLAINLOOSE",`[v=\\s]*(${o[s.XRANGEIDENTIFIERLOOSE]})(?:\\.(${o[s.XRANGEIDENTIFIERLOOSE]})(?:\\.(${o[s.XRANGEIDENTIFIERLOOSE]})(?:${o[s.PRERELEASELOOSE]})?${o[s.BUILD]}?)?)?`),a("XRANGE",`^${o[s.GTLT]}\\s*${o[s.XRANGEPLAIN]}$`),a("XRANGELOOSE",`^${o[s.GTLT]}\\s*${o[s.XRANGEPLAINLOOSE]}$`),a("COERCE",`(^|[^\\d])(\\d{1,${e}})(?:\\.(\\d{1,${e}}))?(?:\\.(\\d{1,${e}}))?(?:$|[^\\d])`),a("COERCERTL",o[s.COERCE],!0),a("LONETILDE","(?:~>?)"),a("TILDETRIM",`(\\s*)${o[s.LONETILDE]}\\s+`,!0),t.tildeTrimReplace="$1~",a("TILDE",`^${o[s.LONETILDE]}${o[s.XRANGEPLAIN]}$`),a("TILDELOOSE",`^${o[s.LONETILDE]}${o[s.XRANGEPLAINLOOSE]}$`),a("LONECARET","(?:\\^)"),a("CARETTRIM",`(\\s*)${o[s.LONECARET]}\\s+`,!0),t.caretTrimReplace="$1^",a("CARET",`^${o[s.LONECARET]}${o[s.XRANGEPLAIN]}$`),a("CARETLOOSE",`^${o[s.LONECARET]}${o[s.XRANGEPLAINLOOSE]}$`),a("COMPARATORLOOSE",`^${o[s.GTLT]}\\s*(${o[s.LOOSEPLAIN]})$|^$`),a("COMPARATOR",`^${o[s.GTLT]}\\s*(${o[s.FULLPLAIN]})$|^$`),a("COMPARATORTRIM",`(\\s*)${o[s.GTLT]}\\s*(${o[s.LOOSEPLAIN]}|${o[s.XRANGEPLAIN]})`,!0),t.comparatorTrimReplace="$1$2$3",a("HYPHENRANGE",`^\\s*(${o[s.XRANGEPLAIN]})\\s+-\\s+(${o[s.XRANGEPLAIN]})\\s*$`),a("HYPHENRANGELOOSE",`^\\s*(${o[s.XRANGEPLAINLOOSE]})\\s+-\\s+(${o[s.XRANGEPLAINLOOSE]})\\s*$`),a("STAR","(<|>)?=?\\s*\\*"),a("GTE0","^\\s*>=\\s*0.0.0\\s*$"),a("GTE0PRE","^\\s*>=\\s*0.0.0-0\\s*$")}),tt=/^[0-9]+$/,dt=(n,t)=>{let e=tt.test(n),r=tt.test(t);return e&&r&&(n=+n,t=+t),n===t?0:e&&!r?-1:r&&!e?1:n<t?-1:1},ln=(n,t)=>dt(t,n),dn={compareIdentifiers:dt,rcompareIdentifiers:ln},{MAX_LENGTH:nt,MAX_SAFE_INTEGER:me}=_e,{re:rt,t:st}=oe,{compareIdentifiers:re}=dn,E=class{constructor(t,e){if(e&&typeof e=="object"||(e={loose:!!e,includePrerelease:!1}),t instanceof E){if(t.loose===!!e.loose&&t.includePrerelease===!!e.includePrerelease)return t;t=t.version}else if(typeof t!="string")throw new TypeError(`Invalid Version: ${t}`);if(t.length>nt)throw new TypeError(`version is longer than ${nt} characters`);f("SemVer",t,e),this.options=e,this.loose=!!e.loose,this.includePrerelease=!!e.includePrerelease;let r=t.trim().match(e.loose?rt[st.LOOSE]:rt[st.FULL]);if(!r)throw new TypeError(`Invalid Version: ${t}`);if(this.raw=t,this.major=+r[1],this.minor=+r[2],this.patch=+r[3],this.major>me||this.major<0)throw new TypeError("Invalid major version");if(this.minor>me||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>me||this.patch<0)throw new TypeError("Invalid patch version");r[4]?this.prerelease=r[4].split(".").map(o=>{if(/^[0-9]+$/.test(o)){let s=+o;if(s>=0&&s<me)return s}return o}):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(t){if(f("SemVer.compare",this.version,this.options,t),!(t instanceof E)){if(typeof t=="string"&&t===this.version)return 0;t=new E(t,this.options)}return t.version===this.version?0:this.compareMain(t)||this.comparePre(t)}compareMain(t){return t instanceof E||(t=new E(t,this.options)),re(this.major,t.major)||re(this.minor,t.minor)||re(this.patch,t.patch)}comparePre(t){if(t instanceof E||(t=new E(t,this.options)),this.prerelease.length&&!t.prerelease.length)return-1;if(!this.prerelease.length&&t.prerelease.length)return 1;if(!this.prerelease.length&&!t.prerelease.length)return 0;let e=0;do{let r=this.prerelease[e],o=t.prerelease[e];if(f("prerelease compare",e,r,o),r===void 0&&o===void 0)return 0;if(o===void 0)return 1;if(r===void 0)return-1;if(r!==o)return re(r,o)}while(++e)}compareBuild(t){t instanceof E||(t=new E(t,this.options));let e=0;do{let r=this.build[e],o=t.build[e];if(f("prerelease compare",e,r,o),r===void 0&&o===void 0)return 0;if(o===void 0)return 1;if(r===void 0)return-1;if(r!==o)return re(r,o)}while(++e)}inc(t,e){switch(t){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",e);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",e);break;case"prepatch":this.prerelease.length=0,this.inc("patch",e),this.inc("pre",e);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",e),this.inc("pre",e);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)}e&&(this.prerelease[0]===e?isNaN(this.prerelease[1])&&(this.prerelease=[e,0]):this.prerelease=[e,0]);break;default:throw new Error(`invalid increment argument: ${t}`)}return this.format(),this.raw=this.version,this}},un=(n,t,e)=>new E(n,e).compare(new E(t,e)),z=un,pn=(n,t,e)=>z(n,t,e)===0,hn=pn,mn=(n,t,e)=>z(n,t,e)!==0,fn=mn,En=(n,t,e)=>z(n,t,e)>0,yn=En,gn=(n,t,e)=>z(n,t,e)>=0,Rn=gn,vn=(n,t,e)=>z(n,t,e)<0,Tn=vn,In=(n,t,e)=>z(n,t,e)<=0,bn=In,wn=(n,t,e,r)=>{switch(t){case"===":return typeof n=="object"&&(n=n.version),typeof e=="object"&&(e=e.version),n===e;case"!==":return typeof n=="object"&&(n=n.version),typeof e=="object"&&(e=e.version),n!==e;case"":case"=":case"==":return hn(n,e,r);case"!=":return fn(n,e,r);case">":return yn(n,e,r);case">=":return Rn(n,e,r);case"<":return Tn(n,e,r);case"<=":return bn(n,e,r);default:throw new TypeError(`Invalid operator: ${t}`)}},Oe=wn,se=Symbol("SemVer ANY"),U=class{static get ANY(){return se}constructor(t,e){if(e&&typeof e=="object"||(e={loose:!!e,includePrerelease:!1}),t instanceof U){if(t.loose===!!e.loose)return t;t=t.value}f("comparator",t,e),this.options=e,this.loose=!!e.loose,this.parse(t),this.semver===se?this.value="":this.value=this.operator+this.semver.version,f("comp",this)}parse(t){let e=this.options.loose?ot[it.COMPARATORLOOSE]:ot[it.COMPARATOR],r=t.match(e);if(!r)throw new TypeError(`Invalid comparator: ${t}`);this.operator=r[1]!==void 0?r[1]:"",this.operator==="="&&(this.operator=""),r[2]?this.semver=new E(r[2],this.options.loose):this.semver=se}toString(){return this.value}test(t){if(f("Comparator.test",t,this.options.loose),this.semver===se||t===se)return!0;if(typeof t=="string")try{t=new E(t,this.options)}catch(e){return!1}return Oe(t,this.operator,this.semver,this.options)}intersects(t,e){if(!(t instanceof U))throw new TypeError("a Comparator is required");if(e&&typeof e=="object"||(e={loose:!!e,includePrerelease:!1}),this.operator==="")return this.value===""||new O(t.value,e).test(this.value);if(t.operator==="")return t.value===""||new O(this.value,e).test(t.semver);let r=!(this.operator!==">="&&this.operator!==">"||t.operator!==">="&&t.operator!==">"),o=!(this.operator!=="<="&&this.operator!=="<"||t.operator!=="<="&&t.operator!=="<"),s=this.semver.version===t.semver.version,i=!(this.operator!==">="&&this.operator!=="<="||t.operator!==">="&&t.operator!=="<="),a=Oe(this.semver,"<",t.semver,e)&&(this.operator===">="||this.operator===">")&&(t.operator==="<="||t.operator==="<"),c=Oe(this.semver,">",t.semver,e)&&(this.operator==="<="||this.operator==="<")&&(t.operator===">="||t.operator===">");return r||o||s&&i||a||c}},{re:ot,t:it}=oe,O=class{constructor(t,e){if(e&&typeof e=="object"||(e={loose:!!e,includePrerelease:!1}),t instanceof O)return t.loose===!!e.loose&&t.includePrerelease===!!e.includePrerelease?t:new O(t.raw,e);if(t instanceof U)return this.raw=t.value,this.set=[[t]],this.format(),this;if(this.options=e,this.loose=!!e.loose,this.includePrerelease=!!e.includePrerelease,this.raw=t,this.set=t.split(/\s*\|\|\s*/).map(r=>this.parseRange(r.trim())).filter(r=>r.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${t}`);this.format()}format(){return this.range=this.set.map(t=>t.join(" ").trim()).join("||").trim(),this.range}toString(){return this.range}parseRange(t){let{loose:e}=this.options;t=t.trim();let r=e?T[R.HYPHENRANGELOOSE]:T[R.HYPHENRANGE];t=t.replace(r,Dn(this.options.includePrerelease)),f("hyphen replace",t),t=t.replace(T[R.COMPARATORTRIM],Pn),f("comparator trim",t,T[R.COMPARATORTRIM]),t=(t=(t=t.replace(T[R.TILDETRIM],Mn)).replace(T[R.CARETTRIM],xn)).split(/\s+/).join(" ");let o=e?T[R.COMPARATORLOOSE]:T[R.COMPARATOR];return t.split(" ").map(s=>Cn(s,this.options)).join(" ").split(/\s+/).map(s=>kn(s,this.options)).filter(this.options.loose?s=>!!s.match(o):()=>!0).map(s=>new U(s,this.options))}intersects(t,e){if(!(t instanceof O))throw new TypeError("a Range is required");return this.set.some(r=>at(r,e)&&t.set.some(o=>at(o,e)&&r.every(s=>o.every(i=>s.intersects(i,e)))))}test(t){if(!t)return!1;if(typeof t=="string")try{t=new E(t,this.options)}catch(e){return!1}for(let e=0;e<this.set.length;e++)if(qn(this.set[e],t,this.options))return!0;return!1}},{re:T,t:R,comparatorTrimReplace:Pn,tildeTrimReplace:Mn,caretTrimReplace:xn}=oe,at=(n,t)=>{let e=!0,r=n.slice(),o=r.pop();for(;e&&r.length;)e=r.every(s=>o.intersects(s,t)),o=r.pop();return e},Cn=(n,t)=>(f("comp",n,t),n=Sn(n,t),f("caret",n),n=An(n,t),f("tildes",n),n=Ln(n,t),f("xrange",n),n=_n(n,t),f("stars",n),n),b=n=>!n||n.toLowerCase()==="x"||n==="*",An=(n,t)=>n.trim().split(/\s+/).map(e=>Nn(e,t)).join(" "),Nn=(n,t)=>{let e=t.loose?T[R.TILDELOOSE]:T[R.TILDE];return n.replace(e,(r,o,s,i,a)=>{let c;return f("tilde",n,r,o,s,i,a),b(o)?c="":b(s)?c=`>=${o}.0.0 <${+o+1}.0.0-0`:b(i)?c=`>=${o}.${s}.0 <${o}.${+s+1}.0-0`:a?(f("replaceTilde pr",a),c=`>=${o}.${s}.${i}-${a} <${o}.${+s+1}.0-0`):c=`>=${o}.${s}.${i} <${o}.${+s+1}.0-0`,f("tilde return",c),c})},Sn=(n,t)=>n.trim().split(/\s+/).map(e=>$n(e,t)).join(" "),$n=(n,t)=>{f("caret",n,t);let e=t.loose?T[R.CARETLOOSE]:T[R.CARET],r=t.includePrerelease?"-0":"";return n.replace(e,(o,s,i,a,c)=>{let l;return f("caret",n,o,s,i,a,c),b(s)?l="":b(i)?l=`>=${s}.0.0${r} <${+s+1}.0.0-0`:b(a)?l=s==="0"?`>=${s}.${i}.0${r} <${s}.${+i+1}.0-0`:`>=${s}.${i}.0${r} <${+s+1}.0.0-0`:c?(f("replaceCaret pr",c),l=s==="0"?i==="0"?`>=${s}.${i}.${a}-${c} <${s}.${i}.${+a+1}-0`:`>=${s}.${i}.${a}-${c} <${s}.${+i+1}.0-0`:`>=${s}.${i}.${a}-${c} <${+s+1}.0.0-0`):(f("no pr"),l=s==="0"?i==="0"?`>=${s}.${i}.${a}${r} <${s}.${i}.${+a+1}-0`:`>=${s}.${i}.${a}${r} <${s}.${+i+1}.0-0`:`>=${s}.${i}.${a} <${+s+1}.0.0-0`),f("caret return",l),l})},Ln=(n,t)=>(f("replaceXRanges",n,t),n.split(/\s+/).map(e=>On(e,t)).join(" ")),On=(n,t)=>{n=n.trim();let e=t.loose?T[R.XRANGELOOSE]:T[R.XRANGE];return n.replace(e,(r,o,s,i,a,c)=>{f("xRange",n,r,o,s,i,a,c);let l=b(s),d=l||b(i),p=d||b(a),x=p;return o==="="&&x&&(o=""),c=t.includePrerelease?"-0":"",l?r=o===">"||o==="<"?"<0.0.0-0":"*":o&&x?(d&&(i=0),a=0,o===">"?(o=">=",d?(s=+s+1,i=0,a=0):(i=+i+1,a=0)):o==="<="&&(o="<",d?s=+s+1:i=+i+1),o==="<"&&(c="-0"),r=`${o+s}.${i}.${a}${c}`):d?r=`>=${s}.0.0${c} <${+s+1}.0.0-0`:p&&(r=`>=${s}.${i}.0${c} <${s}.${+i+1}.0-0`),f("xRange return",r),r})},_n=(n,t)=>(f("replaceStars",n,t),n.trim().replace(T[R.STAR],"")),kn=(n,t)=>(f("replaceGTE0",n,t),n.trim().replace(T[t.includePrerelease?R.GTE0PRE:R.GTE0],"")),Dn=n=>(t,e,r,o,s,i,a,c,l,d,p,x,v)=>`${e=b(r)?"":b(o)?`>=${r}.0.0${n?"-0":""}`:b(s)?`>=${r}.${o}.0${n?"-0":""}`:i?`>=${e}`:`>=${e}${n?"-0":""}`} ${c=b(l)?"":b(d)?`<${+l+1}.0.0-0`:b(p)?`<${l}.${+d+1}.0-0`:x?`<=${l}.${d}.${p}-${x}`:n?`<${l}.${d}.${+p+1}-0`:`<=${c}`}`.trim(),qn=(n,t,e)=>{for(let r=0;r<n.length;r++)if(!n[r].test(t))return!1;if(t.prerelease.length&&!e.includePrerelease){for(let r=0;r<n.length;r++)if(f(n[r].semver),n[r].semver!==U.ANY&&n[r].semver.prerelease.length>0){let o=n[r].semver;if(o.major===t.major&&o.minor===t.minor&&o.patch===t.patch)return!0}return!1}return!0},ut=(n,t,e)=>{try{t=new O(t,e)}catch(r){return!1}return t.test(n)};var{MAX_LENGTH:Un}=_e,{re:ct,t:lt}=oe,Fn=(n,t)=>{if(t&&typeof t=="object"||(t={loose:!!t,includePrerelease:!1}),n instanceof E)return n;if(typeof n!="string"||n.length>Un||!(t.loose?ct[lt.LOOSE]:ct[lt.FULL]).test(n))return null;try{return new E(n,t)}catch(e){return null}},Wn=Fn,{re:fe,t:Ee}=oe,pt=(n,t)=>{if(n instanceof E)return n;if(typeof n=="number"&&(n=String(n)),typeof n!="string")return null;let e=null;if((t=t||{}).rtl){let r;for(;(r=fe[Ee.COERCERTL].exec(n))&&(!e||e.index+e[0].length!==n.length);)e&&r.index+r[0].length===e.index+e[0].length||(e=r),fe[Ee.COERCERTL].lastIndex=r.index+r[1].length+r[2].length;fe[Ee.COERCERTL].lastIndex=-1}else e=n.match(fe[Ee.COERCE]);return e===null?null:Wn(`${e[2]}.${e[3]||"0"}.${e[4]||"0"}`,t)};function Jn(n){return String.fromCharCode(parseInt(n.slice(1),16))}function Gn(n){return`%${`00${n.charCodeAt(0).toString(16)}`.slice(-2)}`}function Kn(n){return btoa(encodeURIComponent(n).replace(/%[0-9A-F]{2}/g,Jn))}function jn(n){return decodeURIComponent(Array.from(atob(n),Gn).join(""))}function ye(n){return Kn(JSON.stringify(n))}function ht(n){return JSON.parse(jn(n))}import{RPCErrorCode as zn,SDKErrorCode as Q,SDKWarningCode as Re}from"@magic-sdk/types";import{MagicPayloadMethod as Bn,RPCErrorCode as Vn}from"@magic-sdk/types";function _(n){return typeof n=="undefined"}function Hn(n){return n===null}function ge(n){return Hn(n)||_(n)}function kr(n){return ge(n)?!1:!_(n.jsonrpc)&&!_(n.id)&&!_(n.method)&&!_(n.params)}function mt(n){return ge(n)?!1:!_(n.jsonrpc)&&!_(n.id)&&(!_(n.result)||!_(n.error))}function Dr(n){return ge(n)?!1:typeof n=="string"&&Object.values(Bn).includes(n)}function ft(n){return ge(n)?!1:typeof n=="number"&&Object.values(Vn).includes(n)}function ie(n){if(!n)return!0;for(let t in n)if(Object.hasOwnProperty.call(n,t))return!1;return!0}var h={};function Xn(n,t){return Object.assign(h,t),n}var Et={"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"};var S=class extends Error{constructor(e,r){super(`Magic SDK Error: [${e}] ${r}`);this.code=e;this.rawMessage=r;this.__proto__=Error;Object.setPrototypeOf(this,S.prototype)}},k=class extends Error{constructor(e){super();this.__proto__=Error;let r=Number(e==null?void 0:e.code);this.rawMessage=(e==null?void 0:e.message)||"Internal error",this.code=ft(r)?r:zn.InternalError,this.message=`Magic RPC Error: [${this.code}] ${this.rawMessage}`,this.data=(e==null?void 0:e.data)||void 0,Object.setPrototypeOf(this,k.prototype)}},F=class{constructor(t,e){this.code=t;this.rawMessage=e;this.message=`Magic SDK Warning: [${t}] ${e}`}log(){console.warn(this.message)}},Y=class extends Error{constructor(e,r,o,s){super(`Magic Extension Error (${e.name}): [${r}] ${o}`);this.code=r;this.rawMessage=o;this.data=s;this.__proto__=Error;Object.setPrototypeOf(this,Y.prototype)}},ae=class{constructor(t,e,r){this.code=e;this.rawMessage=r;this.message=`Magic Extension Warning (${t.name}): [${e}] ${r}`}log(){console.warn(this.message)}};function yt(){return new S(Q.MissingApiKey,"Please provide an API key that you acquired from the Magic developer dashboard.")}function gt(){return new S(Q.ModalNotReady,"Modal is not ready.")}function Rt(){return new S(Q.MalformedResponse,"Response from the Magic iframe is malformed.")}function vt(n){return new S(Q.ExtensionNotInitialized,`Extensions must be initialized with a Magic SDK instance before \`Extension.${n}\` can be accessed. Do not invoke \`Extension.${n}\` inside an extension constructor.`)}function Tt(n){let t=`Some extensions are incompatible with \`${h.sdkName}@${h.version}\`:`;return n.filter(e=>typeof e.compat!="undefined"&&e.compat!==null).forEach(e=>{let r=e.compat[h.sdkName];typeof r=="string"?t+=`
- Extension \`${e.name}\` supports version(s) \`${r}\``:r||(t+=`
- Extension \`${e.name}\` does not support ${h.platform} environments.`)}),new S(Y.IncompatibleExtensions,t)}function It(n){let t=e=>{let r=e+1,o=r%10,s=r%100;return o===1&&s!==11?`${r}st`:o===2&&s!==12?`${r}nd`:o===3&&s!==13?`${r}rd`:`${r}th`};return new S(Y.InvalidArgument,`Invalid ${t(n.argument)} argument given to \`${n.procedure}\`.
- Extension \`${e.name}\` does not support ${h.platform} environments.`)}),new S(Q.IncompatibleExtensions,t)}function It(n){let t=e=>{let r=e+1,o=r%10,s=r%100;return o===1&&s!==11?`${r}st`:o===2&&s!==12?`${r}nd`:o===3&&s!==13?`${r}rd`:`${r}th`};return new S(Q.InvalidArgument,`Invalid ${t(n.argument)} argument given to \`${n.procedure}\`.
Expected: \`${n.expected}\`
Received: \`${n.received}\``)}function Kr(){return new U(Re.DuplicateIframe,"Duplicate iframes found.")}function bt(){return new U(Re.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 wt(){return new U(Re.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 \`${h.defaultEndpoint}\`. Changing this default behavior will lead to unexpected results and potentially security-threatening bugs.`)}function F(n){let{method:t,removalVersions:e,useInstead:r}=n,o=e[h.sdkName],s=r?` Use \`${r}\` instead.`:"",i=`\`${t}\` will be removed from \`${h.sdkName}\` in version \`${o}\`.${s}`;return new U(Re.DeprecationNotice,i)}import{MagicPayloadMethod as N,DeviceVerificationEventEmit as Lt,LoginWithEmailOTPEventEmit as Q,UpdateEmailEventEmit as Z,RecencyCheckEventEmit as J,LoginWithSmsOTPEventEmit as Ie}from"@magic-sdk/types";import{MagicOutgoingWindowMessage as sr,MagicIncomingWindowMessage as or,MagicPayloadMethod as ir}from"@magic-sdk/types";function*Yn(){let n=0;for(;;)n<Number.MAX_SAFE_INTEGER?yield++n:n=0}var Qn=Yn();function ke(){return Qn.next().value}var Pt=Symbol("Payload pre-processed by Magic SDK");function Mt(n){return Object.defineProperty(n,Pt,{value:!0,enumerable:!1}),n}function Zn(n){return!!n[Pt]}function j(n){var t,e,r;return Zn(n)||(n.jsonrpc=(t=n.jsonrpc)!=null?t:"2.0",n.id=ke(),n.method=(e=n.method)!=null?e:"noop",n.params=(r=n.params)!=null?r:[],Mt(n)),n}function u(n,t=[]){return Mt({params:t,method:n,jsonrpc:"2.0",id:ke()})}var W=class{constructor(t){t instanceof W?(this._jsonrpc=t.payload.jsonrpc,this._id=t.payload.id,this._result=t.payload.result,this._error=t.payload.error):mt(t)?(this._jsonrpc=t.jsonrpc,this._id=t.id,this._result=t.result,this._error=t.error):(this._jsonrpc=t.jsonrpc,this._id=t.id,this._result=void 0,this._error=void 0)}applyError(t){return this._error=t,this}applyResult(t){return this._result=t,this}get hasError(){return typeof this._error!="undefined"&&this._error!==null}get hasResult(){return typeof this._result!="undefined"}get payload(){return{jsonrpc:this._jsonrpc,id:this._id,result:this._result,error:this._error}}};import{UserEventsEmit as nr,UserEventsOnReceived as rr}from"@magic-sdk/types";var At=sn(Ct()),De=class extends At.default{};function Te(){let n=new De;return{emitter:n,createChainingEmitterMethod:(r,o)=>(...s)=>(n[r].apply(n,s),o),createBoundEmitterMethod:r=>(...o)=>n[r].apply(n,o)}}var Nt=Symbol("isPromiEvent");function St(n){return!!n[Nt]}function k(n){let t=Ue(n),{createBoundEmitterMethod:e,createChainingEmitterMethod:r}=Te(),o=Symbol("Promise.then"),s=Symbol("Promise.catch"),i=Symbol("Promise.finally"),a=(d,p)=>(...x)=>{let v=p[d].apply(p,x);return c(v)},c=d=>Object.assign(d,{[Nt]:!0,[o]:d[o]||d.then,[s]:d[s]||d.catch,[i]:d[i]||d.finally,then:a(o,d),catch:a(s,d),finally:a(i,d),on:r("on",d),once:r("once",d),addListener:r("addListener",d),off:r("off",d),removeListener:r("removeListener",d),removeAllListeners:r("removeAllListeners",d),emit:e("emit"),eventNames:e("eventNames"),listeners:e("listeners"),listenerCount:e("listenerCount")}),l=c(t.then(d=>(l.emit("done",d),l.emit("settled"),d),d=>{throw l.emit("error",d),l.emit("settled"),d}));return l.on(rr.ClosedByUser,()=>{l.emit(nr.ClosedByUser)}),l}function Ue(n){return new Promise((t,e)=>{let r=n(t,e);Promise.resolve(r).catch(e)})}var P=class{constructor(t){this.sdk=t}get overlay(){return this.sdk.overlay}request(t){let e=this.overlay.post(sr.MAGIC_HANDLE_REQUEST,j(t)),r=k((s,i)=>{e.then(a=>{if(o(),a.hasError)i(new _(a.payload.error));else if(a.hasResult)s(a.payload.result);else throw Rt()}).catch(a=>{o(),i(a)})}),o=this.overlay.on(or.MAGIC_HANDLE_EVENT,s=>{var a;let{response:i}=s.data;if(i.id===t.id&&((a=i.result)==null?void 0:a.event)){let{event:c,params:l=[]}=i.result;r.emit(c,...l)}});return r}createIntermediaryEvent(t,e){return o=>{let s=u(ir.IntermediaryEvent,[{payloadId:e,eventType:t,args:o}]);this.request(s)}}};function $t(n,t){let[e]=n.split(".").map(Number);return e>=t}var B={"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"},be=class extends P{loginWithMagicLink(t){let e=h.sdkName==="@magic-sdk/react-native"||h.sdkName==="@magic-sdk/react-native-bare"||h.sdkName==="@magic-sdk/react-native-expo";if(e&&$t(h.version,19))throw new Error("loginWithMagicLink() is deprecated for this package, please utlize a passcode method like loginWithSMS or loginWithEmailOTP instead.");e&&F({method:"auth.loginWithMagicLink()",removalVersions:B,useInstead:"auth.loginWithEmailOTP()"}).log();let{email:r,showUI:o=!0,redirectURI:s,overrides:i,lifespan:a}=t,c=u(this.sdk.testMode?N.LoginWithMagicLinkTestMode:N.LoginWithMagicLink,[{email:r,showUI:o,redirectURI:s,overrides:i,lifespan:a}]);return this.request(c)}loginWithSMS(t){let{phoneNumber:e,showUI:r=!0,lifespan:o}=t,s=u(this.sdk.testMode?N.LoginWithSmsTestMode:N.LoginWithSms,[{phoneNumber:e,showUI:r,lifespan:o}]),i=this.request(s);return!r&&i&&(i.on(Ie.VerifySmsOtp,a=>{this.createIntermediaryEvent(Ie.VerifySmsOtp,s.id)(a)}),i.on(Ie.Cancel,()=>{this.createIntermediaryEvent(Ie.Cancel,s.id)()})),i}loginWithEmailOTP(t){let{email:e,showUI:r,deviceCheckUI:o,overrides:s,lifespan:i}=t,a=u(this.sdk.testMode?N.LoginWithEmailOTPTestMode:N.LoginWithEmailOTP,[{email:e,showUI:r,deviceCheckUI:o,overrides:s,lifespan:i}]),c=this.request(a);return!o&&c&&c.on(Lt.Retry,()=>{this.createIntermediaryEvent(Lt.Retry,a.id)()}),!r&&c&&(c.on(Q.VerifyEmailOtp,l=>{this.createIntermediaryEvent(Q.VerifyEmailOtp,a.id)(l)}),c.on(Q.VerifyMFACode,l=>{this.createIntermediaryEvent(Q.VerifyMFACode,a.id)(l)}),c.on(Q.Cancel,()=>{this.createIntermediaryEvent(Q.Cancel,a.id)()})),c}loginWithCredential(t){let{credentialOrQueryString:e,lifespan:r}=t||{},o=e!=null?e:"";if(!e&&h.platform==="web"){o=window.location.search;let i=window.location.origin+window.location.pathname;window.history.replaceState(null,"",i)}let s=u(this.sdk.testMode?N.LoginWithCredentialTestMode:N.LoginWithCredential,[o,r]);return this.request(s)}setAuthorizationToken(t){let e=u(N.SetAuthorizationToken,[{jwt:t}]);return this.request(e)}updateEmailWithUI(t){let{email:e,showUI:r=!0}=t,o=u(this.sdk.testMode?N.UpdateEmailTestMode:N.UpdateEmail,[{email:e,showUI:r}]),s=this.request(o);return r||(s.on(J.Retry,()=>{this.createIntermediaryEvent(J.Retry,o.id)()}),s.on(J.Cancel,()=>{this.createIntermediaryEvent(J.Cancel,o.id)()}),s.on(J.VerifyEmailOtp,i=>{this.createIntermediaryEvent(J.VerifyEmailOtp,o.id)(i)}),s.on(J.VerifyMFACode,i=>{this.createIntermediaryEvent(J.VerifyMFACode,o.id)(i)}),s.on(Z.RetryWithNewEmail,i=>{this.createIntermediaryEvent(Z.RetryWithNewEmail,o.id)(i)}),s.on(Z.Cancel,()=>{this.createIntermediaryEvent(Z.Cancel,o.id)()}),s.on(Z.VerifyEmailOtp,i=>{this.createIntermediaryEvent(Z.VerifyEmailOtp,o.id)(i)})),s}};import{MagicPayloadMethod as y,EnableMFAEventEmit as Me,DisableMFAEventEmit as te,RecencyCheckEventEmit as Gt,RecoveryFactorEventEmit as K}from"@magic-sdk/types";var le={};nn(le,{clear:()=>ar,getItem:()=>g,iterate:()=>Fe,key:()=>lr,keys:()=>dr,length:()=>cr,removeItem:()=>C,setItem:()=>M});var we;function G(n){return(...t)=>m(this,null,function*(){return we||(we=yield h.configureStorage()),yield we.ready(),we[n](...t)})}var g=G("getItem"),M=G("setItem"),C=G("removeItem"),ar=G("clear"),cr=G("length"),lr=G("key"),dr=G("keys"),Fe=G("iterate");function Ot(){let n=window.crypto.getRandomValues(new Uint8Array(16));n[6]=n[6]&15|64,n[8]=n[8]&191|128;let t="";return t+=n[0].toString(16),t+=n[1].toString(16),t+=n[2].toString(16),t+=n[3].toString(16),t+="-",t+=n[4].toString(16),t+=n[5].toString(16),t+="-",t+=n[6].toString(16),t+=n[7].toString(16),t+="-",t+=n[8].toString(16),t+=n[9].toString(16),t+="-",t+=n[10].toString(16),t+=n[11].toString(16),t+=n[12].toString(16),t+=n[13].toString(16),t+=n[14].toString(16),t+=n[15].toString(16),t}var We="STORE_KEY_PRIVATE_KEY",Pe="STORE_KEY_PUBLIC_JWK",kt="ECDSA",ur="P-256",pr={name:kt,namedCurve:ur};function de(){let n=typeof window!="undefined"&&!!window.crypto,t=n&&!!window.crypto.subtle;return n&&t}function Ss(){C(Pe),C(We)}function qt(){return m(this,null,function*(){let n=yield hr();if(!n){console.info("unable to create public key or webcrypto is unsupported");return}let{subtle:t}=window.crypto,e=yield g(We);if(!e||!t){console.info("unable to find private key or webcrypto unsupported");return}let r={iat:Math.floor(new Date().getTime()/1e3),jti:Ot()},o={typ:"dpop+jwt",alg:"ES256",jwk:n},s={protected:_t(JSON.stringify(o)),claims:_t(JSON.stringify(r))},i=fr(`${s.protected}.${s.claims}`),a={name:kt,hash:{name:"SHA-256"}},c=gr(new Uint8Array(yield t.sign(a,e,i)));return`${s.protected}.${s.claims}.${c}`})}function hr(){return m(this,null,function*(){if(!de()){console.info("webcrypto is not supported");return}return(yield g(Pe))||(yield mr()),g(Pe)})}function mr(){return m(this,null,function*(){let{subtle:n}=window.crypto,t=yield n.generateKey(pr,!1,["sign"]),e=yield n.exportKey("jwk",t.publicKey);yield M(We,t.privateKey),yield M(Pe,e)})}function _t(n){return Dt(Er(n))}function fr(n){return new TextEncoder().encode(n)}function Dt(n){return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+/g,"")}function Er(n){return encodeURIComponent(n).replace(/%([0-9A-F]{2})/g,(e,r)=>String.fromCharCode(parseInt(r,16)))}function gr(n){let t="";return n.forEach(e=>{t+=String.fromCharCode(e)}),Dt(t)}var Je="ds",Ge="ek",Ke="iv",je="AES-GCM",yr=256;function ee(){return m(this,null,function*(){let n=[];yield Fe((t,e,r)=>{e.startsWith(`${Je}_`)&&n.push(e)});for(let t of n)yield C(t)})}function Ut(n){let t="",e=new Uint8Array(n),r=e.byteLength;for(let o=0;o<r;o++)t+=String.fromCharCode(e[o]);return window.btoa(t)}function Ft(n){let t=window.atob(n),e=t.length,r=new Uint8Array(e);for(let o=0;o<e;o++)r[o]=t.charCodeAt(o);return r.buffer}function Rr(){return m(this,null,function*(){if(!de()){console.info("webcrypto is not supported");return}let{crypto:n}=window,t=yield g(Ke);return t||n.getRandomValues(new Uint8Array(12))})}function vr(){return m(this,null,function*(){if(!de()){console.info("webcrypto is not supported");return}let{subtle:n}=window.crypto,t=yield g(Ge);return t||(yield n.generateKey({name:je,length:yr},!1,["encrypt","decrypt"]))})}function Wt(n,t){return m(this,null,function*(){let e=yield Rr(),r=yield vr();if(!e||!r||!n)return;let o=Ft(n),{subtle:s}=window.crypto,i=yield s.encrypt({name:je,iv:e},r,o),a=Ut(i);yield M(`${Je}_${t}`,a),yield M(Ge,r),yield M(Ke,e)})}function Jt(n){return m(this,null,function*(){let t=yield g(`${Je}_${n}`),e=yield g(Ke),r=yield g(Ge);if(!e||!t||!r||!de())return;let{subtle:o}=window.crypto,s=yield o.decrypt({name:je,iv:e},r,Ft(t));return Ut(s)})}function Be(n,t){return t?new URL(n,t):new URL(n)}var xe=class extends P{constructor(){super(...arguments);this.localForageKey="mc_active_wallet";this.localForageIsLoggedInKey="magic_auth_is_logged_in";this.userLoggedOutCallbacks=[]}getIdToken(e){let r=u(this.sdk.testMode?y.GetIdTokenTestMode:y.GetIdToken,[e]);return this.request(r)}generateIdToken(e){let r=u(this.sdk.testMode?y.GenerateIdTokenTestMode:y.GenerateIdToken,[e]);return this.request(r)}getInfo(){return m(this,null,function*(){let e=yield g(this.localForageKey),r=u(y.GetInfo,[{walletType:e}]);return this.request(r)})}isLoggedIn(){return k((e,r)=>m(this,null,function*(){try{let o=!1;this.sdk.useStorageCache&&(o=(yield g(this.localForageIsLoggedInKey))==="true",o&&e(!0));let s=u(this.sdk.testMode?y.IsLoggedInTestMode:y.IsLoggedIn),i=yield this.request(s);this.sdk.useStorageCache&&(i?M(this.localForageIsLoggedInKey,!0):C(this.localForageIsLoggedInKey),o&&!i&&this.emitUserLoggedOut(!0)),e(i)}catch(o){r(o)}}))}logout(){return C(this.localForageKey),C(this.localForageIsLoggedInKey),ee(),k((e,r)=>m(this,null,function*(){try{let o=u(this.sdk.testMode?y.LogoutTestMode:y.Logout),s=yield this.request(o);this.sdk.useStorageCache&&this.emitUserLoggedOut(s),e(s)}catch(o){r(o)}}))}requestInfoWithUI(e){let r=u(y.RequestUserInfoWithUI,e?[e]:[]);return this.request(r)}showSettings(e){let{showUI:r=!0}=e||{},o=u(this.sdk.testMode?y.UserSettingsTestMode:y.UserSettings,[e]),s=this.request(o);return!r&&s&&(s.on(K.SendNewPhoneNumber,i=>{this.createIntermediaryEvent(K.SendNewPhoneNumber,o.id)(i)}),s.on(K.SendOtpCode,i=>{this.createIntermediaryEvent(K.SendOtpCode,o.id)(i)}),s.on(K.StartEditPhoneNumber,()=>{this.createIntermediaryEvent(K.StartEditPhoneNumber,o.id)()}),s.on(K.Cancel,()=>{this.createIntermediaryEvent(K.Cancel,o.id)()}),s.on(Gt.VerifyEmailOtp,i=>{this.createIntermediaryEvent(Gt.VerifyEmailOtp,o.id)(i)})),s}recoverAccount(e){let r=u(this.sdk.testMode?y.RecoverAccountTestMode:y.RecoverAccount,[e]);return this.request(r)}revealPrivateKey(){let e=u(y.RevealPK);return this.request(e)}getMetadata(){F({method:"user.getMetadata()",removalVersions:B,useInstead:"user.getInfo()"}).log();let e=u(this.sdk.testMode?y.GetMetadataTestMode:y.GetMetadata);return this.request(e)}onUserLoggedOut(e){this.userLoggedOutCallbacks.push(e)}enableMFA(e){let{showUI:r=!0}=e,o=u(y.EnableMFA,[{showUI:r}]),s=this.request(o);return!r&&s&&(s.on(Me.VerifyMFACode,i=>{this.createIntermediaryEvent(Me.VerifyMFACode,o.id)(i)}),s.on(Me.Cancel,()=>{this.createIntermediaryEvent(Me.Cancel,o.id)()})),s}disableMFA(e){let{showUI:r=!0}=e,o=u(y.DisableMFA,[{showUI:r}]),s=this.request(o);return!r&&s&&(s.on(te.VerifyMFACode,i=>{this.createIntermediaryEvent(te.VerifyMFACode,o.id)(i)}),s.on(te.LostDevice,i=>{this.createIntermediaryEvent(te.LostDevice,o.id)(i)}),s.on(te.Cancel,()=>{this.createIntermediaryEvent(te.Cancel,o.id)()})),s}emitUserLoggedOut(e){this.userLoggedOutCallbacks.forEach(r=>{r(e)})}};import{Events as Ve,MagicPayloadMethod as A,Wallets as $}from"@magic-sdk/types";var Ce=class extends P{constructor(){super(...arguments);this.localForageKey="mc_active_wallet"}connectWithUI(){let e=k((r,o)=>m(this,null,function*(){try{if(this.isMetaMaskBrowser()&&(yield this.isWalletEnabled($.MetaMask))){let l=yield this.autoConnectIfWalletBrowser($.MetaMask);r(l);return}if(this.isCoinbaseWalletBrowser()&&(yield this.isWalletEnabled($.CoinbaseWallet))){let l=yield this.autoConnectIfWalletBrowser($.CoinbaseWallet);r(l);return}let s=this.getUserEnv(),i=u(A.Login,[s]),a=this.request(i);a.on(Ve.WalletSelected,l=>this.handleWalletSelected(H(V({},l),{payloadId:i.id}))),a.on("id-token-created",l=>{e.emit("id-token-created",l)});let c=yield a;c.error&&o(c),r(c)}catch(s){o(s)}}));return e}showUI(e){return this.request(u(A.ShowUI,[e]))}showAddress(){return this.request(u(A.ShowAddress))}showSendTokensUI(){return this.request(u(A.ShowSendTokensUI))}showOnRamp(){return this.request(u(A.ShowOnRamp))}showNFTs(){return this.request(u(A.ShowNFTs))}showBalances(){return this.request(u(A.ShowBalances))}sendGaslessTransaction(e,r){return this.request(u(A.SendGaslessTransaction,[e,r]))}getInfo(){return m(this,null,function*(){F({method:"wallet.getInfo()",removalVersions:B,useInstead:"user.getInfo()"}).log();let e=yield g(this.localForageKey),r=u(A.GetInfo,[{walletType:e}]);return this.request(r)})}disconnect(){F({method:"wallet.disconnect()",removalVersions:B,useInstead:"user.logout()"}).log(),C(this.localForageKey),ee();let e=u(A.Disconnect);return this.request(e)}requestUserInfoWithUI(e){F({method:"wallet.requestUserInfoWithUI()",removalVersions:B,useInstead:"user.requestUserInfoWithUI()"}).log();let r=u(A.RequestUserInfoWithUI,e?[e]:[]);return this.request(r)}getProvider(){return m(this,null,function*(){switch(yield g(this.localForageKey)){case $.MetaMask:return this.getMetaMaskProvider();case $.CoinbaseWallet:return this.getCoinbaseProvider();default:return this.sdk.rpcProvider}})}isMetaMaskInstalled(){var e,r,o;return((e=window.ethereum)==null?void 0:e.isMetaMask)||!!((o=(r=window.ethereum)==null?void 0:r.providers)!=null&&o.find(s=>s==null?void 0:s.isMetaMask))}isMetaMaskBrowser(){return this.isMobile()&&this.isMetaMaskInstalled()}getMetaMaskProvider(){var e,r;return((r=(e=window.ethereum)==null?void 0:e.providers)==null?void 0:r.find(o=>o==null?void 0:o.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,r,o;return((e=window.ethereum)==null?void 0:e.isCoinbaseWallet)||!!((o=(r=window.ethereum)==null?void 0:r.providers)!=null&&o.find(s=>s==null?void 0:s.isCoinbaseWallet))}isCoinbaseWalletBrowser(){var e;return!!((e=window.ethereum)!=null&&e.isCoinbaseBrowser)}getCoinbaseProvider(){var e,r;return((r=(e=window.ethereum)==null?void 0:e.providers)==null?void 0:r.find(o=>o==null?void 0:o.isCoinbaseWallet))||window.ethereum}connectToCoinbaseWallet(){if(this.isMobile()&&!this.isCoinbaseWalletBrowser()){let r=`https://go.cb-w.com/dapp?cb_url=${encodeURIComponent(window.location.href)}`;window.location.href=r}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 $.MetaMask:return this.connectToMetaMask();case $.CoinbaseWallet:return this.connectToCoinbaseWallet();default:throw new Error(`Invalid provider: ${e}. Must be one of "metamask" or "coinbase_wallet".`)}}isWalletEnabled(e){let r=u("mc_is_wallet_enabled",[{wallet:e}]);return this.request(r)}handleWalletSelected(e){return m(this,null,function*(){try{let r=yield this.connectToThirdPartyWallet(e.wallet);yield M(this.localForageKey,e.wallet),this.createIntermediaryEvent(Ve.WalletConnected,e.payloadId)(r)}catch(r){console.error(r),this.createIntermediaryEvent(Ve.WalletRejected,e.payloadId)()}})}autoConnectIfWalletBrowser(e){return m(this,null,function*(){let r;e===$.MetaMask&&(r=yield this.getMetaMaskProvider().request({method:"eth_requestAccounts"})),e===$.CoinbaseWallet&&(r=yield this.getCoinbaseProvider().request({method:"eth_requestAccounts"})),yield M(this.localForageKey,e);let o=u(A.AutoConnect,[{wallet:e,address:r}]);return this.request(o)})}};import{MagicOutgoingWindowMessage as Kt,MagicPayloadMethod as Tr}from"@magic-sdk/types";var{createBoundEmitterMethod:Ae,createChainingEmitterMethod:ne}=Te(),Ne=class extends P{constructor(){super(...arguments);this.isMagic=!0;this.on=ne("on",this);this.once=ne("once",this);this.addListener=ne("addListener",this);this.off=ne("off",this);this.removeListener=ne("removeListener",this);this.removeAllListeners=ne("removeAllListeners",this);this.emit=Ae("emit");this.eventNames=Ae("eventNames");this.listeners=Ae("listeners");this.listenerCount=Ae("listenerCount")}sendAsync(e,r){if(!r)throw It({procedure:"Magic.rpcProvider.sendAsync",argument:1,expected:"function",received:r===null?"null":typeof r});if(Array.isArray(e))this.overlay.post(Kt.MAGIC_HANDLE_REQUEST,e.map(o=>{let s=j(o);return this.prefixPayloadMethodForTestMode(s),s})).then(o=>{r(null,o.map(s=>H(V({},s.payload),{error:s.hasError?new _(s.payload.error):null})))});else{let o=j(e);this.prefixPayloadMethodForTestMode(o),this.overlay.post(Kt.MAGIC_HANDLE_REQUEST,o).then(s=>{r(s.hasError?new _(s.payload.error):null,s.payload)})}}send(e,r){if(typeof e=="string"){let s=u(e,Array.isArray(r)?r:[]);return this.request(s)}if(Array.isArray(e)||!!r){this.sendAsync(e,r);return}let o=bt();return o.log(),new W(e).applyError({code:-32603,message:o.rawMessage}).payload}enable(){let e=u(Tr.Login);return this.request(e)}request(e){return this.prefixPayloadMethodForTestMode(e),super.request(e)}prefixPayloadMethodForTestMode(e){let r="testMode/eth/";this.sdk.testMode&&(e.method=`${r}${e.method}`)}};var jt=["request","overlay","sdk"];function Ir(n){let t=Object.getPrototypeOf(n),e=[t];for(;t!==P.prototype;)t=Object.getPrototypeOf(t),e.push(t);return e}var Se=class extends P{constructor(){super(void 0);this.__sdk_access_field_descriptors__=new Map;this.__is_initialized__=!1;this.utils={createPromiEvent:k,isPromiEvent:St,encodeJSON:ge,decodeJSON:ht,createJsonRpcRequestPayload:u,standardizeJsonRpcRequestPayload:j,storage:le};let e=[this,...Ir(this)];jt.forEach(r=>{let o=e.map(c=>Object.getOwnPropertyDescriptor(c,r)),s=o.findIndex(c=>!!c),i=s>0,a=o[s];a&&(this.__sdk_access_field_descriptors__.set(r,{descriptor:a,isPrototypeField:i}),Object.defineProperty(this,r,{configurable:!0,get:()=>{throw vt(r)}}))})}init(e){this.__is_initialized__||(jt.forEach(r=>{if(this.__sdk_access_field_descriptors__.has(r)){let{descriptor:o,isPrototypeField:s}=this.__sdk_access_field_descriptors__.get(r);s?delete this[r]:Object.defineProperty(this,r,o)}}),this.sdk=e,this.__is_initialized__=!0)}createDeprecationWarning(e){let{method:r,removalVersion:o,useInstead:s}=e,i=s?` Use \`${s}\` instead.`:"",a=`\`${r}\` will be removed from this Extension in version \`${o}\`.${i}`;return new ae(this,"DEPRECATION_NOTICE",a)}createWarning(e,r){return new ae(this,e,r)}createError(e,r,o){return new z(this,e,r,o)}},He=class extends Se{},q=class extends Se{};q.Internal=He,q.Anonymous="anonymous extension";import{MagicPayloadMethod as Xe}from"@magic-sdk/types";var $e=class extends P{purchase(t){let e=u(Xe.NFTPurchase,[t]);return this.request(e)}checkout(t){let e=u(Xe.NFTCheckout,[t]);return this.request(e)}transfer(t){let e=u(Xe.NFTTransfer,[t]);return this.request(e)}};function Bt(n){return n.compat&&n.compat[h.sdkName]!=null?typeof n.compat[h.sdkName]=="string"?ut(pt(h.version),n.compat[h.sdkName]):!!n.compat[h.sdkName]:!0}function br(n,t,e){return!t&&!e?`${n}_eth_mainnet`:e?`${n}_${JSON.stringify(e)}`:t?typeof t=="string"?`${n}_eth_${t}`:`${n}_${t.rpcUrl}_${t.chainId}_${t.chainType}`:`${n}_unknown`}function wr(n){var o;let t=(o=n==null?void 0:n.extensions)!=null?o:[],e={},r=[];if(Array.isArray(t)?t.forEach(s=>{Bt(s)?(s.init(this),(s.name||s.name!==q.Anonymous)&&(this[s.name]=s),s instanceof q.Internal&&(ie(s.config)||(e[s.name]=s.config))):r.push(s)}):Object.keys(t).forEach(s=>{if(Bt(t[s])){t[s].init(this);let i=t[s];this[s]=i,i instanceof q.Internal&&(ie(i.config)||(e[t[s].name]=i.config))}else r.push(t[s])}),r.length)throw Tt(r);return e}var ue=class{constructor(t,e){this.apiKey=t;var i;if(!t)throw gt();h.platform==="react-native"&&(e==null?void 0:e.endpoint)&&wt().log();let{defaultEndpoint:r,version:o}=h;this.testMode=!!(e!=null&&e.testMode),this.useStorageCache=!!(e!=null&&e.useStorageCache),this.endpoint=Be((i=e==null?void 0:e.endpoint)!=null?i:r).origin,this.auth=new be(this),this.user=new xe(this),this.wallet=new Ce(this),this.nft=new $e(this),this.rpcProvider=new Ne(this);let s=wr.call(this,e);this.parameters=ge(H(V({API_KEY:this.apiKey,DOMAIN_ORIGIN:window.location?window.location.origin:"",ETH_NETWORK:e==null?void 0:e.network,host:Be(this.endpoint).host,sdk:Et[h.sdkName],version:o,ext:ie(s)?void 0:s,locale:(e==null?void 0:e.locale)||"en_US"},h.bundleId?{bundleId:h.bundleId}:{}),{meta:e==null?void 0:e.meta})),this.networkHash=br(this.apiKey,e==null?void 0:e.network,ie(s)?void 0:s),e!=null&&e.deferPreload||this.preload()}get overlay(){if(!ue.__overlays__.has(this.parameters)){let t=new h.ViewController(this.endpoint,this.parameters,this.networkHash);t.init(),ue.__overlays__.set(this.parameters,t)}return ue.__overlays__.get(this.parameters)}preload(){return m(this,null,function*(){yield this.overlay.checkIsReadyForRequest})}},Le=ue;Le.__overlays__=new Map;import{MagicIncomingWindowMessage as pe,SDKWarningCode as Pr}from"@magic-sdk/types";function Mr(n,t){return t&&Array.isArray(n)?n.find(e=>e.id===t):n}function xr(n,t){var o;let e=(o=t.data.response)==null?void 0:o.id,r=Mr(n,e);if(e&&r){let s=new W(r).applyResult(t.data.response.result).applyError(t.data.response.error);return{id:e,response:s}}return{}}function Cr(n,t,e){return m(this,null,function*(){var a;let r=yield g("rt"),o;if(h.platform==="web")try{o=(a=yield g("jwt"))!=null?a:yield qt()}catch(c){console.error("webcrypto error",c)}let s={msgType:n,payload:t};o&&(s.jwt=o),o&&r&&(s.rt=r);let i=yield Jt(e);return i&&(s.deviceShare=i),s})}function Ar(n){return m(this,null,function*(){!n.data.rt||(yield M("rt",n.data.rt))})}var ze=class{constructor(t,e,r){this.endpoint=t;this.parameters=e;this.networkHash=r;this.messageHandlers=new Set;this.isConnectedToInternet=!0;this.checkIsReadyForRequest=this.waitForReady(),this.isReadyForRequest=!1,this.listen()}post(t,e){return m(this,null,function*(){return Ue((r,o)=>m(this,null,function*(){if(!this.isConnectedToInternet){let d=yt();o(d)}this.isReadyForRequest||(yield this.waitForReady());let s=[],i=Array.isArray(e)?e.map(d=>d.id):[],a=yield Cr(`${t}-${this.parameters}`,e,this.networkHash);yield this._post(a);let c=d=>p=>{var Ye;let{id:x,response:v}=xr(e,p);if(Ar(p),((Ye=v==null?void 0:v.payload.error)==null?void 0:Ye.message)==="User denied account access.")ee();else if(p.data.deviceShare){let{deviceShare:Vt}=p.data;Wt(Vt,this.networkHash)}x&&v&&Array.isArray(e)&&i.includes(x)?(s.push(v),s.length===e.length&&(d(),r(s))):x&&v&&!Array.isArray(e)&&x===e.id&&(d(),r(v))},l=this.on(pe.MAGIC_HANDLE_RESPONSE,c(()=>l()))}))})}on(t,e){let r=e.bind(window),o=s=>{s.data.msgType===`${t}-${this.parameters}`&&r(s)};return this.messageHandlers.add(o),()=>this.messageHandlers.delete(o)}waitForReady(){return new Promise(t=>{let e=this.on(pe.MAGIC_OVERLAY_READY,()=>{this.isReadyForRequest=!0,t(),e()});setTimeout(()=>{this.isReadyForRequest=!0,t(),e()},15e3)})}listen(){this.on(pe.MAGIC_HIDE_OVERLAY,()=>{this.hideOverlay()}),this.on(pe.MAGIC_SHOW_OVERLAY,()=>{this.showOverlay()}),this.on(pe.MAGIC_SEND_PRODUCT_ANNOUNCEMENT,t=>{t.data.response.result.product_announcement&&new U(Pr.ProductAnnouncement,t.data.response.result.product_announcement).log()})}};export{q as Extension,z as MagicExtensionError,ae as MagicExtensionWarning,_ as MagicRPCError,S as MagicSDKError,U as MagicSDKWarning,Le as SDKBase,We as STORE_KEY_PRIVATE_KEY,Pe as STORE_KEY_PUBLIC_JWK,De as TypedEmitter,ze as ViewController,Ss as clearKeys,F as createDeprecationWarning,Kr as createDuplicateIframeWarning,vt as createExtensionNotInitializedError,Tt as createIncompatibleExtensionsError,It as createInvalidArgumentError,qt as createJwt,Rt as createMalformedResponseError,gt as createMissingApiKeyError,yt as createModalNotReadyError,k as createPromiEvent,Ue as createPromise,wt as createReactNativeEndpointConfigurationWarning,Xn as createSDK,bt as createSynchronousWeb3MethodWarning,Te as createTypedEmitter,Be as createURL,ht as decodeJSON,ge as encodeJSON,ke as getPayloadId,ie as isEmpty,ft as isJsonRpcErrorCode,kr as isJsonRpcRequestPayload,mt as isJsonRpcResponsePayload,qr as isMagicPayloadMethod,$t as isMajorVersionAtLeast,St as isPromiEvent,de as isWebCryptoSupported,le as storage,Ot as uuid};
Received: \`${n.received}\``)}function Kr(){return new F(Re.DuplicateIframe,"Duplicate iframes found.")}function bt(){return new F(Re.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 wt(){return new F(Re.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 \`${h.defaultEndpoint}\`. Changing this default behavior will lead to unexpected results and potentially security-threatening bugs.`)}function W(n){let{method:t,removalVersions:e,useInstead:r}=n,o=e[h.sdkName],s=r?` Use \`${r}\` instead.`:"",i=`\`${t}\` will be removed from \`${h.sdkName}\` in version \`${o}\`.${s}`;return new F(Re.DeprecationNotice,i)}import{MagicPayloadMethod as N,DeviceVerificationEventEmit as Lt,LoginWithEmailOTPEventEmit as $,UpdateEmailEventEmit as Z,RecencyCheckEventEmit as G,LoginWithSmsOTPEventEmit as Ie}from"@magic-sdk/types";import{MagicOutgoingWindowMessage as sr,MagicIncomingWindowMessage as or,MagicPayloadMethod as ir}from"@magic-sdk/types";function*Yn(){let n=0;for(;;)n<Number.MAX_SAFE_INTEGER?yield++n:n=0}var Qn=Yn();function ke(){return Qn.next().value}var Pt=Symbol("Payload pre-processed by Magic SDK");function Mt(n){return Object.defineProperty(n,Pt,{value:!0,enumerable:!1}),n}function Zn(n){return!!n[Pt]}function B(n){var t,e,r;return Zn(n)||(n.jsonrpc=(t=n.jsonrpc)!=null?t:"2.0",n.id=ke(),n.method=(e=n.method)!=null?e:"noop",n.params=(r=n.params)!=null?r:[],Mt(n)),n}function u(n,t=[]){return Mt({params:t,method:n,jsonrpc:"2.0",id:ke()})}var J=class{constructor(t){t instanceof J?(this._jsonrpc=t.payload.jsonrpc,this._id=t.payload.id,this._result=t.payload.result,this._error=t.payload.error):mt(t)?(this._jsonrpc=t.jsonrpc,this._id=t.id,this._result=t.result,this._error=t.error):(this._jsonrpc=t.jsonrpc,this._id=t.id,this._result=void 0,this._error=void 0)}applyError(t){return this._error=t,this}applyResult(t){return this._result=t,this}get hasError(){return typeof this._error!="undefined"&&this._error!==null}get hasResult(){return typeof this._result!="undefined"}get payload(){return{jsonrpc:this._jsonrpc,id:this._id,result:this._result,error:this._error}}};import{UserEventsEmit as nr,UserEventsOnReceived as rr}from"@magic-sdk/types";var At=sn(Ct()),qe=class extends At.default{};function Te(){let n=new qe;return{emitter:n,createChainingEmitterMethod:(r,o)=>(...s)=>(n[r].apply(n,s),o),createBoundEmitterMethod:r=>(...o)=>n[r].apply(n,o)}}var Nt=Symbol("isPromiEvent");function St(n){return!!n[Nt]}function D(n){let t=Ue(n),{createBoundEmitterMethod:e,createChainingEmitterMethod:r}=Te(),o=Symbol("Promise.then"),s=Symbol("Promise.catch"),i=Symbol("Promise.finally"),a=(d,p)=>(...x)=>{let v=p[d].apply(p,x);return c(v)},c=d=>Object.assign(d,{[Nt]:!0,[o]:d[o]||d.then,[s]:d[s]||d.catch,[i]:d[i]||d.finally,then:a(o,d),catch:a(s,d),finally:a(i,d),on:r("on",d),once:r("once",d),addListener:r("addListener",d),off:r("off",d),removeListener:r("removeListener",d),removeAllListeners:r("removeAllListeners",d),emit:e("emit"),eventNames:e("eventNames"),listeners:e("listeners"),listenerCount:e("listenerCount")}),l=c(t.then(d=>(l.emit("done",d),l.emit("settled"),d),d=>{throw l.emit("error",d),l.emit("settled"),d}));return l.on(rr.ClosedByUser,()=>{l.emit(nr.ClosedByUser)}),l}function Ue(n){return new Promise((t,e)=>{let r=n(t,e);Promise.resolve(r).catch(e)})}var P=class{constructor(t){this.sdk=t}get overlay(){return this.sdk.overlay}request(t){let e=this.overlay.post(sr.MAGIC_HANDLE_REQUEST,B(t)),r=D((s,i)=>{e.then(a=>{if(o(),a.hasError)i(new k(a.payload.error));else if(a.hasResult)s(a.payload.result);else throw Rt()}).catch(a=>{o(),i(a)})}),o=this.overlay.on(or.MAGIC_HANDLE_EVENT,s=>{var a;let{response:i}=s.data;if(i.id===t.id&&((a=i.result)==null?void 0:a.event)){let{event:c,params:l=[]}=i.result;r.emit(c,...l)}});return r}createIntermediaryEvent(t,e){return o=>{let s=u(ir.IntermediaryEvent,[{payloadId:e,eventType:t,args:o}]);this.request(s)}}};function $t(n,t){let[e]=n.split(".").map(Number);return e>=t}var V={"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"},be=class extends P{loginWithMagicLink(t){let e=h.sdkName==="@magic-sdk/react-native"||h.sdkName==="@magic-sdk/react-native-bare"||h.sdkName==="@magic-sdk/react-native-expo";if(e&&$t(h.version,19))throw new Error("loginWithMagicLink() is deprecated for this package, please utlize a passcode method like loginWithSMS or loginWithEmailOTP instead.");e&&W({method:"auth.loginWithMagicLink()",removalVersions:V,useInstead:"auth.loginWithEmailOTP()"}).log();let{email:r,showUI:o=!0,redirectURI:s,overrides:i,lifespan:a}=t,c=u(this.sdk.testMode?N.LoginWithMagicLinkTestMode:N.LoginWithMagicLink,[{email:r,showUI:o,redirectURI:s,overrides:i,lifespan:a}]);return this.request(c)}loginWithSMS(t){let{phoneNumber:e,showUI:r=!0,lifespan:o}=t,s=u(this.sdk.testMode?N.LoginWithSmsTestMode:N.LoginWithSms,[{phoneNumber:e,showUI:r,lifespan:o}]),i=this.request(s);return!r&&i&&(i.on(Ie.VerifySmsOtp,a=>{this.createIntermediaryEvent(Ie.VerifySmsOtp,s.id)(a)}),i.on(Ie.Cancel,()=>{this.createIntermediaryEvent(Ie.Cancel,s.id)()})),i}loginWithEmailOTP(t){let{email:e,showUI:r,deviceCheckUI:o,overrides:s,lifespan:i}=t,a=u(this.sdk.testMode?N.LoginWithEmailOTPTestMode:N.LoginWithEmailOTP,[{email:e,showUI:r,deviceCheckUI:o,overrides:s,lifespan:i}]),c=this.request(a);return!o&&c&&c.on(Lt.Retry,()=>{this.createIntermediaryEvent(Lt.Retry,a.id)()}),!r&&c&&(c.on($.VerifyEmailOtp,l=>{this.createIntermediaryEvent($.VerifyEmailOtp,a.id)(l)}),c.on($.VerifyMFACode,l=>{this.createIntermediaryEvent($.VerifyMFACode,a.id)(l)}),c.on($.LostDevice,()=>{this.createIntermediaryEvent($.LostDevice,a.id)()}),c.on($.VerifyRecoveryCode,l=>{this.createIntermediaryEvent($.VerifyRecoveryCode,a.id)(l)}),c.on($.Cancel,()=>{this.createIntermediaryEvent($.Cancel,a.id)()})),c}loginWithCredential(t){let{credentialOrQueryString:e,lifespan:r}=t||{},o=e!=null?e:"";if(!e&&h.platform==="web"){o=window.location.search;let i=window.location.origin+window.location.pathname;window.history.replaceState(null,"",i)}let s=u(this.sdk.testMode?N.LoginWithCredentialTestMode:N.LoginWithCredential,[o,r]);return this.request(s)}setAuthorizationToken(t){let e=u(N.SetAuthorizationToken,[{jwt:t}]);return this.request(e)}updateEmailWithUI(t){let{email:e,showUI:r=!0}=t,o=u(this.sdk.testMode?N.UpdateEmailTestMode:N.UpdateEmail,[{email:e,showUI:r}]),s=this.request(o);return r||(s.on(G.Retry,()=>{this.createIntermediaryEvent(G.Retry,o.id)()}),s.on(G.Cancel,()=>{this.createIntermediaryEvent(G.Cancel,o.id)()}),s.on(G.VerifyEmailOtp,i=>{this.createIntermediaryEvent(G.VerifyEmailOtp,o.id)(i)}),s.on(G.VerifyMFACode,i=>{this.createIntermediaryEvent(G.VerifyMFACode,o.id)(i)}),s.on(Z.RetryWithNewEmail,i=>{this.createIntermediaryEvent(Z.RetryWithNewEmail,o.id)(i)}),s.on(Z.Cancel,()=>{this.createIntermediaryEvent(Z.Cancel,o.id)()}),s.on(Z.VerifyEmailOtp,i=>{this.createIntermediaryEvent(Z.VerifyEmailOtp,o.id)(i)})),s}};import{MagicPayloadMethod as g,EnableMFAEventEmit as Me,DisableMFAEventEmit as te,RecencyCheckEventEmit as Gt,RecoveryFactorEventEmit as j}from"@magic-sdk/types";var le={};nn(le,{clear:()=>ar,getItem:()=>y,iterate:()=>Fe,key:()=>lr,keys:()=>dr,length:()=>cr,removeItem:()=>C,setItem:()=>M});var we;function K(n){return(...t)=>m(this,null,function*(){return we||(we=yield h.configureStorage()),yield we.ready(),we[n](...t)})}var y=K("getItem"),M=K("setItem"),C=K("removeItem"),ar=K("clear"),cr=K("length"),lr=K("key"),dr=K("keys"),Fe=K("iterate");function Ot(){let n=window.crypto.getRandomValues(new Uint8Array(16));n[6]=n[6]&15|64,n[8]=n[8]&191|128;let t="";return t+=n[0].toString(16),t+=n[1].toString(16),t+=n[2].toString(16),t+=n[3].toString(16),t+="-",t+=n[4].toString(16),t+=n[5].toString(16),t+="-",t+=n[6].toString(16),t+=n[7].toString(16),t+="-",t+=n[8].toString(16),t+=n[9].toString(16),t+="-",t+=n[10].toString(16),t+=n[11].toString(16),t+=n[12].toString(16),t+=n[13].toString(16),t+=n[14].toString(16),t+=n[15].toString(16),t}var We="STORE_KEY_PRIVATE_KEY",Pe="STORE_KEY_PUBLIC_JWK",kt="ECDSA",ur="P-256",pr={name:kt,namedCurve:ur};function de(){let n=typeof window!="undefined"&&!!window.crypto,t=n&&!!window.crypto.subtle;return n&&t}function Ss(){C(Pe),C(We)}function Dt(){return m(this,null,function*(){let n=yield hr();if(!n){console.info("unable to create public key or webcrypto is unsupported");return}let{subtle:t}=window.crypto,e=yield y(We);if(!e||!t){console.info("unable to find private key or webcrypto unsupported");return}let r={iat:Math.floor(new Date().getTime()/1e3),jti:Ot()},o={typ:"dpop+jwt",alg:"ES256",jwk:n},s={protected:_t(JSON.stringify(o)),claims:_t(JSON.stringify(r))},i=fr(`${s.protected}.${s.claims}`),a={name:kt,hash:{name:"SHA-256"}},c=yr(new Uint8Array(yield t.sign(a,e,i)));return`${s.protected}.${s.claims}.${c}`})}function hr(){return m(this,null,function*(){if(!de()){console.info("webcrypto is not supported");return}return(yield y(Pe))||(yield mr()),y(Pe)})}function mr(){return m(this,null,function*(){let{subtle:n}=window.crypto,t=yield n.generateKey(pr,!1,["sign"]),e=yield n.exportKey("jwk",t.publicKey);yield M(We,t.privateKey),yield M(Pe,e)})}function _t(n){return qt(Er(n))}function fr(n){return new TextEncoder().encode(n)}function qt(n){return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+/g,"")}function Er(n){return encodeURIComponent(n).replace(/%([0-9A-F]{2})/g,(e,r)=>String.fromCharCode(parseInt(r,16)))}function yr(n){let t="";return n.forEach(e=>{t+=String.fromCharCode(e)}),qt(t)}var Je="ds",Ge="ek",Ke="iv",je="AES-GCM",gr=256;function ee(){return m(this,null,function*(){let n=[];yield Fe((t,e,r)=>{e.startsWith(`${Je}_`)&&n.push(e)});for(let t of n)yield C(t)})}function Ut(n){let t="",e=new Uint8Array(n),r=e.byteLength;for(let o=0;o<r;o++)t+=String.fromCharCode(e[o]);return window.btoa(t)}function Ft(n){let t=window.atob(n),e=t.length,r=new Uint8Array(e);for(let o=0;o<e;o++)r[o]=t.charCodeAt(o);return r.buffer}function Rr(){return m(this,null,function*(){if(!de()){console.info("webcrypto is not supported");return}let{crypto:n}=window,t=yield y(Ke);return t||n.getRandomValues(new Uint8Array(12))})}function vr(){return m(this,null,function*(){if(!de()){console.info("webcrypto is not supported");return}let{subtle:n}=window.crypto,t=yield y(Ge);return t||(yield n.generateKey({name:je,length:gr},!1,["encrypt","decrypt"]))})}function Wt(n,t){return m(this,null,function*(){let e=yield Rr(),r=yield vr();if(!e||!r||!n)return;let o=Ft(n),{subtle:s}=window.crypto,i=yield s.encrypt({name:je,iv:e},r,o),a=Ut(i);yield M(`${Je}_${t}`,a),yield M(Ge,r),yield M(Ke,e)})}function Jt(n){return m(this,null,function*(){let t=yield y(`${Je}_${n}`),e=yield y(Ke),r=yield y(Ge);if(!e||!t||!r||!de())return;let{subtle:o}=window.crypto,s=yield o.decrypt({name:je,iv:e},r,Ft(t));return Ut(s)})}function Be(n,t){return t?new URL(n,t):new URL(n)}var xe=class extends P{constructor(){super(...arguments);this.localForageKey="mc_active_wallet";this.localForageIsLoggedInKey="magic_auth_is_logged_in";this.userLoggedOutCallbacks=[]}getIdToken(e){let r=u(this.sdk.testMode?g.GetIdTokenTestMode:g.GetIdToken,[e]);return this.request(r)}generateIdToken(e){let r=u(this.sdk.testMode?g.GenerateIdTokenTestMode:g.GenerateIdToken,[e]);return this.request(r)}getInfo(){return m(this,null,function*(){let e=yield y(this.localForageKey),r=u(g.GetInfo,[{walletType:e}]);return this.request(r)})}isLoggedIn(){return D((e,r)=>m(this,null,function*(){try{let o=!1;this.sdk.useStorageCache&&(o=(yield y(this.localForageIsLoggedInKey))==="true",o&&e(!0));let s=u(this.sdk.testMode?g.IsLoggedInTestMode:g.IsLoggedIn),i=yield this.request(s);this.sdk.useStorageCache&&(i?M(this.localForageIsLoggedInKey,!0):C(this.localForageIsLoggedInKey),o&&!i&&this.emitUserLoggedOut(!0)),e(i)}catch(o){r(o)}}))}logout(){return C(this.localForageKey),C(this.localForageIsLoggedInKey),ee(),D((e,r)=>m(this,null,function*(){try{let o=u(this.sdk.testMode?g.LogoutTestMode:g.Logout),s=yield this.request(o);this.sdk.useStorageCache&&this.emitUserLoggedOut(s),e(s)}catch(o){r(o)}}))}requestInfoWithUI(e){let r=u(g.RequestUserInfoWithUI,e?[e]:[]);return this.request(r)}showSettings(e){let{showUI:r=!0}=e||{},o=u(this.sdk.testMode?g.UserSettingsTestMode:g.UserSettings,[e]),s=this.request(o);return!r&&s&&(s.on(j.SendNewPhoneNumber,i=>{this.createIntermediaryEvent(j.SendNewPhoneNumber,o.id)(i)}),s.on(j.SendOtpCode,i=>{this.createIntermediaryEvent(j.SendOtpCode,o.id)(i)}),s.on(j.StartEditPhoneNumber,()=>{this.createIntermediaryEvent(j.StartEditPhoneNumber,o.id)()}),s.on(j.Cancel,()=>{this.createIntermediaryEvent(j.Cancel,o.id)()}),s.on(Gt.VerifyEmailOtp,i=>{this.createIntermediaryEvent(Gt.VerifyEmailOtp,o.id)(i)})),s}recoverAccount(e){let r=u(this.sdk.testMode?g.RecoverAccountTestMode:g.RecoverAccount,[e]);return this.request(r)}revealPrivateKey(){let e=u(g.RevealPK);return this.request(e)}getMetadata(){W({method:"user.getMetadata()",removalVersions:V,useInstead:"user.getInfo()"}).log();let e=u(this.sdk.testMode?g.GetMetadataTestMode:g.GetMetadata);return this.request(e)}onUserLoggedOut(e){this.userLoggedOutCallbacks.push(e)}enableMFA(e){let{showUI:r=!0}=e,o=u(g.EnableMFA,[{showUI:r}]),s=this.request(o);return!r&&s&&(s.on(Me.VerifyMFACode,i=>{this.createIntermediaryEvent(Me.VerifyMFACode,o.id)(i)}),s.on(Me.Cancel,()=>{this.createIntermediaryEvent(Me.Cancel,o.id)()})),s}disableMFA(e){let{showUI:r=!0}=e,o=u(g.DisableMFA,[{showUI:r}]),s=this.request(o);return!r&&s&&(s.on(te.VerifyMFACode,i=>{this.createIntermediaryEvent(te.VerifyMFACode,o.id)(i)}),s.on(te.LostDevice,i=>{this.createIntermediaryEvent(te.LostDevice,o.id)(i)}),s.on(te.Cancel,()=>{this.createIntermediaryEvent(te.Cancel,o.id)()})),s}emitUserLoggedOut(e){this.userLoggedOutCallbacks.forEach(r=>{r(e)})}};import{Events as Ve,MagicPayloadMethod as A,Wallets as L}from"@magic-sdk/types";var Ce=class extends P{constructor(){super(...arguments);this.localForageKey="mc_active_wallet"}connectWithUI(){let e=D((r,o)=>m(this,null,function*(){try{if(this.isMetaMaskBrowser()&&(yield this.isWalletEnabled(L.MetaMask))){let l=yield this.autoConnectIfWalletBrowser(L.MetaMask);r(l);return}if(this.isCoinbaseWalletBrowser()&&(yield this.isWalletEnabled(L.CoinbaseWallet))){let l=yield this.autoConnectIfWalletBrowser(L.CoinbaseWallet);r(l);return}let s=this.getUserEnv(),i=u(A.Login,[s]),a=this.request(i);a.on(Ve.WalletSelected,l=>this.handleWalletSelected(X(H({},l),{payloadId:i.id}))),a.on("id-token-created",l=>{e.emit("id-token-created",l)});let c=yield a;c.error&&o(c),r(c)}catch(s){o(s)}}));return e}showUI(e){return this.request(u(A.ShowUI,[e]))}showAddress(){return this.request(u(A.ShowAddress))}showSendTokensUI(){return this.request(u(A.ShowSendTokensUI))}showOnRamp(){return this.request(u(A.ShowOnRamp))}showNFTs(){return this.request(u(A.ShowNFTs))}showBalances(){return this.request(u(A.ShowBalances))}sendGaslessTransaction(e,r){return this.request(u(A.SendGaslessTransaction,[e,r]))}getInfo(){return m(this,null,function*(){W({method:"wallet.getInfo()",removalVersions:V,useInstead:"user.getInfo()"}).log();let e=yield y(this.localForageKey),r=u(A.GetInfo,[{walletType:e}]);return this.request(r)})}disconnect(){W({method:"wallet.disconnect()",removalVersions:V,useInstead:"user.logout()"}).log(),C(this.localForageKey),ee();let e=u(A.Disconnect);return this.request(e)}requestUserInfoWithUI(e){W({method:"wallet.requestUserInfoWithUI()",removalVersions:V,useInstead:"user.requestUserInfoWithUI()"}).log();let r=u(A.RequestUserInfoWithUI,e?[e]:[]);return this.request(r)}getProvider(){return m(this,null,function*(){switch(yield y(this.localForageKey)){case L.MetaMask:return this.getMetaMaskProvider();case L.CoinbaseWallet:return this.getCoinbaseProvider();default:return this.sdk.rpcProvider}})}isMetaMaskInstalled(){var e,r,o;return((e=window.ethereum)==null?void 0:e.isMetaMask)||!!((o=(r=window.ethereum)==null?void 0:r.providers)!=null&&o.find(s=>s==null?void 0:s.isMetaMask))}isMetaMaskBrowser(){return this.isMobile()&&this.isMetaMaskInstalled()}getMetaMaskProvider(){var e,r;return((r=(e=window.ethereum)==null?void 0:e.providers)==null?void 0:r.find(o=>o==null?void 0:o.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,r,o;return((e=window.ethereum)==null?void 0:e.isCoinbaseWallet)||!!((o=(r=window.ethereum)==null?void 0:r.providers)!=null&&o.find(s=>s==null?void 0:s.isCoinbaseWallet))}isCoinbaseWalletBrowser(){var e;return!!((e=window.ethereum)!=null&&e.isCoinbaseBrowser)}getCoinbaseProvider(){var e,r;return((r=(e=window.ethereum)==null?void 0:e.providers)==null?void 0:r.find(o=>o==null?void 0:o.isCoinbaseWallet))||window.ethereum}connectToCoinbaseWallet(){if(this.isMobile()&&!this.isCoinbaseWalletBrowser()){let r=`https://go.cb-w.com/dapp?cb_url=${encodeURIComponent(window.location.href)}`;window.location.href=r}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 L.MetaMask:return this.connectToMetaMask();case L.CoinbaseWallet:return this.connectToCoinbaseWallet();default:throw new Error(`Invalid provider: ${e}. Must be one of "metamask" or "coinbase_wallet".`)}}isWalletEnabled(e){let r=u("mc_is_wallet_enabled",[{wallet:e}]);return this.request(r)}handleWalletSelected(e){return m(this,null,function*(){try{let r=yield this.connectToThirdPartyWallet(e.wallet);yield M(this.localForageKey,e.wallet),this.createIntermediaryEvent(Ve.WalletConnected,e.payloadId)(r)}catch(r){console.error(r),this.createIntermediaryEvent(Ve.WalletRejected,e.payloadId)()}})}autoConnectIfWalletBrowser(e){return m(this,null,function*(){let r;e===L.MetaMask&&(r=yield this.getMetaMaskProvider().request({method:"eth_requestAccounts"})),e===L.CoinbaseWallet&&(r=yield this.getCoinbaseProvider().request({method:"eth_requestAccounts"})),yield M(this.localForageKey,e);let o=u(A.AutoConnect,[{wallet:e,address:r}]);return this.request(o)})}};import{MagicOutgoingWindowMessage as Kt,MagicPayloadMethod as Tr}from"@magic-sdk/types";var{createBoundEmitterMethod:Ae,createChainingEmitterMethod:ne}=Te(),Ne=class extends P{constructor(){super(...arguments);this.isMagic=!0;this.on=ne("on",this);this.once=ne("once",this);this.addListener=ne("addListener",this);this.off=ne("off",this);this.removeListener=ne("removeListener",this);this.removeAllListeners=ne("removeAllListeners",this);this.emit=Ae("emit");this.eventNames=Ae("eventNames");this.listeners=Ae("listeners");this.listenerCount=Ae("listenerCount")}sendAsync(e,r){if(!r)throw It({procedure:"Magic.rpcProvider.sendAsync",argument:1,expected:"function",received:r===null?"null":typeof r});if(Array.isArray(e))this.overlay.post(Kt.MAGIC_HANDLE_REQUEST,e.map(o=>{let s=B(o);return this.prefixPayloadMethodForTestMode(s),s})).then(o=>{r(null,o.map(s=>X(H({},s.payload),{error:s.hasError?new k(s.payload.error):null})))});else{let o=B(e);this.prefixPayloadMethodForTestMode(o),this.overlay.post(Kt.MAGIC_HANDLE_REQUEST,o).then(s=>{r(s.hasError?new k(s.payload.error):null,s.payload)})}}send(e,r){if(typeof e=="string"){let s=u(e,Array.isArray(r)?r:[]);return this.request(s)}if(Array.isArray(e)||!!r){this.sendAsync(e,r);return}let o=bt();return o.log(),new J(e).applyError({code:-32603,message:o.rawMessage}).payload}enable(){let e=u(Tr.Login);return this.request(e)}request(e){return this.prefixPayloadMethodForTestMode(e),super.request(e)}prefixPayloadMethodForTestMode(e){let r="testMode/eth/";this.sdk.testMode&&(e.method=`${r}${e.method}`)}};var jt=["request","overlay","sdk"];function Ir(n){let t=Object.getPrototypeOf(n),e=[t];for(;t!==P.prototype;)t=Object.getPrototypeOf(t),e.push(t);return e}var Se=class extends P{constructor(){super(void 0);this.__sdk_access_field_descriptors__=new Map;this.__is_initialized__=!1;this.utils={createPromiEvent:D,isPromiEvent:St,encodeJSON:ye,decodeJSON:ht,createJsonRpcRequestPayload:u,standardizeJsonRpcRequestPayload:B,storage:le};let e=[this,...Ir(this)];jt.forEach(r=>{let o=e.map(c=>Object.getOwnPropertyDescriptor(c,r)),s=o.findIndex(c=>!!c),i=s>0,a=o[s];a&&(this.__sdk_access_field_descriptors__.set(r,{descriptor:a,isPrototypeField:i}),Object.defineProperty(this,r,{configurable:!0,get:()=>{throw vt(r)}}))})}init(e){this.__is_initialized__||(jt.forEach(r=>{if(this.__sdk_access_field_descriptors__.has(r)){let{descriptor:o,isPrototypeField:s}=this.__sdk_access_field_descriptors__.get(r);s?delete this[r]:Object.defineProperty(this,r,o)}}),this.sdk=e,this.__is_initialized__=!0)}createDeprecationWarning(e){let{method:r,removalVersion:o,useInstead:s}=e,i=s?` Use \`${s}\` instead.`:"",a=`\`${r}\` will be removed from this Extension in version \`${o}\`.${i}`;return new ae(this,"DEPRECATION_NOTICE",a)}createWarning(e,r){return new ae(this,e,r)}createError(e,r,o){return new Y(this,e,r,o)}},He=class extends Se{},q=class extends Se{};q.Internal=He,q.Anonymous="anonymous extension";import{MagicPayloadMethod as Xe}from"@magic-sdk/types";var $e=class extends P{purchase(t){let e=u(Xe.NFTPurchase,[t]);return this.request(e)}checkout(t){let e=u(Xe.NFTCheckout,[t]);return this.request(e)}transfer(t){let e=u(Xe.NFTTransfer,[t]);return this.request(e)}};function Bt(n){return n.compat&&n.compat[h.sdkName]!=null?typeof n.compat[h.sdkName]=="string"?ut(pt(h.version),n.compat[h.sdkName]):!!n.compat[h.sdkName]:!0}function br(n,t,e){return!t&&!e?`${n}_eth_mainnet`:e?`${n}_${JSON.stringify(e)}`:t?typeof t=="string"?`${n}_eth_${t}`:`${n}_${t.rpcUrl}_${t.chainId}_${t.chainType}`:`${n}_unknown`}function wr(n){var o;let t=(o=n==null?void 0:n.extensions)!=null?o:[],e={},r=[];if(Array.isArray(t)?t.forEach(s=>{Bt(s)?(s.init(this),(s.name||s.name!==q.Anonymous)&&(this[s.name]=s),s instanceof q.Internal&&(ie(s.config)||(e[s.name]=s.config))):r.push(s)}):Object.keys(t).forEach(s=>{if(Bt(t[s])){t[s].init(this);let i=t[s];this[s]=i,i instanceof q.Internal&&(ie(i.config)||(e[t[s].name]=i.config))}else r.push(t[s])}),r.length)throw Tt(r);return e}var ue=class{constructor(t,e){this.apiKey=t;var i;if(!t)throw yt();h.platform==="react-native"&&(e==null?void 0:e.endpoint)&&wt().log();let{defaultEndpoint:r,version:o}=h;this.testMode=!!(e!=null&&e.testMode),this.useStorageCache=!!(e!=null&&e.useStorageCache),this.endpoint=Be((i=e==null?void 0:e.endpoint)!=null?i:r).origin,this.auth=new be(this),this.user=new xe(this),this.wallet=new Ce(this),this.nft=new $e(this),this.rpcProvider=new Ne(this);let s=wr.call(this,e);this.parameters=ye(X(H({API_KEY:this.apiKey,DOMAIN_ORIGIN:window.location?window.location.origin:"",ETH_NETWORK:e==null?void 0:e.network,host:Be(this.endpoint).host,sdk:Et[h.sdkName],version:o,ext:ie(s)?void 0:s,locale:(e==null?void 0:e.locale)||"en_US"},h.bundleId?{bundleId:h.bundleId}:{}),{meta:e==null?void 0:e.meta})),this.networkHash=br(this.apiKey,e==null?void 0:e.network,ie(s)?void 0:s),e!=null&&e.deferPreload||this.preload()}get overlay(){if(!ue.__overlays__.has(this.parameters)){let t=new h.ViewController(this.endpoint,this.parameters,this.networkHash);t.init(),ue.__overlays__.set(this.parameters,t)}return ue.__overlays__.get(this.parameters)}preload(){return m(this,null,function*(){yield this.overlay.checkIsReadyForRequest})}},Le=ue;Le.__overlays__=new Map;import{MagicIncomingWindowMessage as pe,SDKWarningCode as Pr}from"@magic-sdk/types";function Mr(n,t){return t&&Array.isArray(n)?n.find(e=>e.id===t):n}function xr(n,t){var o;let e=(o=t.data.response)==null?void 0:o.id,r=Mr(n,e);if(e&&r){let s=new J(r).applyResult(t.data.response.result).applyError(t.data.response.error);return{id:e,response:s}}return{}}function Cr(n,t,e){return m(this,null,function*(){var a;let r=yield y("rt"),o;if(h.platform==="web")try{o=(a=yield y("jwt"))!=null?a:yield Dt()}catch(c){console.error("webcrypto error",c)}let s={msgType:n,payload:t};o&&(s.jwt=o),o&&r&&(s.rt=r);let i=yield Jt(e);return i&&(s.deviceShare=i),s})}function Ar(n){return m(this,null,function*(){!n.data.rt||(yield M("rt",n.data.rt))})}var ze=class{constructor(t,e,r){this.endpoint=t;this.parameters=e;this.networkHash=r;this.messageHandlers=new Set;this.isConnectedToInternet=!0;this.checkIsReadyForRequest=this.waitForReady(),this.isReadyForRequest=!1,this.listen()}post(t,e){return m(this,null,function*(){return Ue((r,o)=>m(this,null,function*(){if(!this.isConnectedToInternet){let d=gt();o(d)}this.isReadyForRequest||(yield this.waitForReady());let s=[],i=Array.isArray(e)?e.map(d=>d.id):[],a=yield Cr(`${t}-${this.parameters}`,e,this.networkHash);yield this._post(a);let c=d=>p=>{var Ye;let{id:x,response:v}=xr(e,p);if(Ar(p),((Ye=v==null?void 0:v.payload.error)==null?void 0:Ye.message)==="User denied account access.")ee();else if(p.data.deviceShare){let{deviceShare:Vt}=p.data;Wt(Vt,this.networkHash)}x&&v&&Array.isArray(e)&&i.includes(x)?(s.push(v),s.length===e.length&&(d(),r(s))):x&&v&&!Array.isArray(e)&&x===e.id&&(d(),r(v))},l=this.on(pe.MAGIC_HANDLE_RESPONSE,c(()=>l()))}))})}on(t,e){let r=e.bind(window),o=s=>{s.data.msgType===`${t}-${this.parameters}`&&r(s)};return this.messageHandlers.add(o),()=>this.messageHandlers.delete(o)}waitForReady(){return new Promise(t=>{let e=this.on(pe.MAGIC_OVERLAY_READY,()=>{this.isReadyForRequest=!0,t(),e()});setTimeout(()=>{this.isReadyForRequest=!0,t(),e()},15e3)})}listen(){this.on(pe.MAGIC_HIDE_OVERLAY,()=>{this.hideOverlay()}),this.on(pe.MAGIC_SHOW_OVERLAY,()=>{this.showOverlay()}),this.on(pe.MAGIC_SEND_PRODUCT_ANNOUNCEMENT,t=>{t.data.response.result.product_announcement&&new F(Pr.ProductAnnouncement,t.data.response.result.product_announcement).log()})}};export{q as Extension,Y as MagicExtensionError,ae as MagicExtensionWarning,k as MagicRPCError,S as MagicSDKError,F as MagicSDKWarning,Le as SDKBase,We as STORE_KEY_PRIVATE_KEY,Pe as STORE_KEY_PUBLIC_JWK,qe as TypedEmitter,ze as ViewController,Ss as clearKeys,W as createDeprecationWarning,Kr as createDuplicateIframeWarning,vt as createExtensionNotInitializedError,Tt as createIncompatibleExtensionsError,It as createInvalidArgumentError,Dt as createJwt,Rt as createMalformedResponseError,yt as createMissingApiKeyError,gt as createModalNotReadyError,D as createPromiEvent,Ue as createPromise,wt as createReactNativeEndpointConfigurationWarning,Xn as createSDK,bt as createSynchronousWeb3MethodWarning,Te as createTypedEmitter,Be as createURL,ht as decodeJSON,ye as encodeJSON,ke as getPayloadId,ie as isEmpty,ft as isJsonRpcErrorCode,kr as isJsonRpcRequestPayload,mt as isJsonRpcResponsePayload,Dr as isMagicPayloadMethod,$t as isMajorVersionAtLeast,St as isPromiEvent,de as isWebCryptoSupported,le as storage,Ot as uuid};
//# sourceMappingURL=index.js.map

@@ -66,2 +66,5 @@ import { LoginWithMagicLinkConfiguration, LoginWithSmsConfiguration, LoginWithEmailOTPConfiguration, UpdateEmailConfiguration, LoginWithCredentialConfiguration } from '@magic-sdk/types';

"mfa-sent-handle": () => void;
"recovery-code-sent-handle": () => void;
"invalid-recovery-code": () => void;
"recovery-code-success": () => void;
"Auth/id-token-created": (idToken: string) => void;

@@ -71,2 +74,4 @@ "Wallet/wallet-info-fetched": () => void;

"verify-mfa-code": (mfa: string) => void;
"lost-device": () => void;
"verify-recovery-code": (recoveryCode: string) => void;
cancel: () => void;

@@ -73,0 +78,0 @@ } & {

{
"name": "@magic-sdk/provider",
"version": "28.15.0",
"version": "28.16.0-canary.826.11522534563.0",
"description": "Core business logic for Magic SDK packages.",

@@ -38,3 +38,3 @@ "author": "Magic Labs <team@magic.link> (https://magic.link/)",

"dependencies": {
"@magic-sdk/types": "^24.13.0",
"@magic-sdk/types": "24.14.0-canary.826.11522534563.0",
"eventemitter3": "^4.0.4",

@@ -46,3 +46,3 @@ "web3-core": "1.5.2"

},
"gitHead": "a03dc68081a84d020049154d0a65e73b1274dca1"
"gitHead": "456d870e51a03655dd67507fef13260d8305cbf7"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc