@privy-io/react-auth 1.18.0-beta.7 → 1.18.0-beta.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- var Ls=Object.create;var Xt=Object.defineProperty;var As=Object.getOwnPropertyDescriptor;var Ss=Object.getOwnPropertyNames;var Ps=Object.getPrototypeOf,ks=Object.prototype.hasOwnProperty;var ln=(e,t)=>()=>(e&&(t=e(e=0)),t);var Se=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),cn=(e,t)=>{for(var o in t)Xt(e,o,{get:t[o],enumerable:!0})},dn=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Ss(t))!ks.call(e,n)&&n!==o&&Xt(e,n,{get:()=>t[n],enumerable:!(r=As(t,n))||r.enumerable});return e};var Ts=(e,t,o)=>(o=e!=null?Ls(Ps(e)):{},dn(t||!e||!e.__esModule?Xt(o,"default",{value:e,enumerable:!0}):o,e)),un=e=>dn(Xt({},"__esModule",{value:!0}),e);var uo=Se((Q2,co)=>{var $n,jn,zn,qn,Zn,Kn,Jn,Yn,Xn,so,lr,Qn,ei,ti,ct,oi,ri,ni,ii,ai,si,li,ci,di,lo;(function(e){var t=typeof global=="object"?global:typeof self=="object"?self:typeof this=="object"?this:{};typeof define=="function"&&define.amd?define("tslib",["exports"],function(r){e(o(t,o(r)))}):typeof co=="object"&&typeof co.exports=="object"?e(o(t,o(co.exports))):e(o(t));function o(r,n){return r!==t&&(typeof Object.create=="function"?Object.defineProperty(r,"__esModule",{value:!0}):r.__esModule=!0),function(i,a){return r[i]=n?n(i,a):a}}})(function(e){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(r[i]=n[i])};$n=function(r,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");t(r,n);function i(){this.constructor=r}r.prototype=n===null?Object.create(n):(i.prototype=n.prototype,new i)},jn=Object.assign||function(r){for(var n,i=1,a=arguments.length;i<a;i++){n=arguments[i];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(r[s]=n[s])}return r},zn=function(r,n){var i={};for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&n.indexOf(a)<0&&(i[a]=r[a]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,a=Object.getOwnPropertySymbols(r);s<a.length;s++)n.indexOf(a[s])<0&&Object.prototype.propertyIsEnumerable.call(r,a[s])&&(i[a[s]]=r[a[s]]);return i},qn=function(r,n,i,a){var s=arguments.length,l=s<3?n:a===null?a=Object.getOwnPropertyDescriptor(n,i):a,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")l=Reflect.decorate(r,n,i,a);else for(var h=r.length-1;h>=0;h--)(d=r[h])&&(l=(s<3?d(l):s>3?d(n,i,l):d(n,i))||l);return s>3&&l&&Object.defineProperty(n,i,l),l},Zn=function(r,n){return function(i,a){n(i,a,r)}},Kn=function(r,n){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,n)},Jn=function(r,n,i,a){function s(l){return l instanceof i?l:new i(function(d){d(l)})}return new(i||(i=Promise))(function(l,d){function h(p){try{u(a.next(p))}catch(b){d(b)}}function g(p){try{u(a.throw(p))}catch(b){d(b)}}function u(p){p.done?l(p.value):s(p.value).then(h,g)}u((a=a.apply(r,n||[])).next())})},Yn=function(r,n){var i={label:0,sent:function(){if(l[0]&1)throw l[1];return l[1]},trys:[],ops:[]},a,s,l,d;return d={next:h(0),throw:h(1),return:h(2)},typeof Symbol=="function"&&(d[Symbol.iterator]=function(){return this}),d;function h(u){return function(p){return g([u,p])}}function g(u){if(a)throw new TypeError("Generator is already executing.");for(;i;)try{if(a=1,s&&(l=u[0]&2?s.return:u[0]?s.throw||((l=s.return)&&l.call(s),0):s.next)&&!(l=l.call(s,u[1])).done)return l;switch(s=0,l&&(u=[u[0]&2,l.value]),u[0]){case 0:case 1:l=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,s=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(l=i.trys,!(l=l.length>0&&l[l.length-1])&&(u[0]===6||u[0]===2)){i=0;continue}if(u[0]===3&&(!l||u[1]>l[0]&&u[1]<l[3])){i.label=u[1];break}if(u[0]===6&&i.label<l[1]){i.label=l[1],l=u;break}if(l&&i.label<l[2]){i.label=l[2],i.ops.push(u);break}l[2]&&i.ops.pop(),i.trys.pop();continue}u=n.call(r,i)}catch(p){u=[6,p],s=0}finally{a=l=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}},Xn=function(r,n){for(var i in r)i!=="default"&&!Object.prototype.hasOwnProperty.call(n,i)&&lo(n,r,i)},lo=Object.create?function(r,n,i,a){a===void 0&&(a=i);var s=Object.getOwnPropertyDescriptor(n,i);(!s||("get"in s?!n.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return n[i]}}),Object.defineProperty(r,a,s)}:function(r,n,i,a){a===void 0&&(a=i),r[a]=n[i]},so=function(r){var n=typeof Symbol=="function"&&Symbol.iterator,i=n&&r[n],a=0;if(i)return i.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&a>=r.length&&(r=void 0),{value:r&&r[a++],done:!r}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")},lr=function(r,n){var i=typeof Symbol=="function"&&r[Symbol.iterator];if(!i)return r;var a=i.call(r),s,l=[],d;try{for(;(n===void 0||n-- >0)&&!(s=a.next()).done;)l.push(s.value)}catch(h){d={error:h}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(d)throw d.error}}return l},Qn=function(){for(var r=[],n=0;n<arguments.length;n++)r=r.concat(lr(arguments[n]));return r},ei=function(){for(var r=0,n=0,i=arguments.length;n<i;n++)r+=arguments[n].length;for(var a=Array(r),s=0,n=0;n<i;n++)for(var l=arguments[n],d=0,h=l.length;d<h;d++,s++)a[s]=l[d];return a},ti=function(r,n,i){if(i||arguments.length===2)for(var a=0,s=n.length,l;a<s;a++)(l||!(a in n))&&(l||(l=Array.prototype.slice.call(n,0,a)),l[a]=n[a]);return r.concat(l||Array.prototype.slice.call(n))},ct=function(r){return this instanceof ct?(this.v=r,this):new ct(r)},oi=function(r,n,i){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var a=i.apply(r,n||[]),s,l=[];return s={},d("next"),d("throw"),d("return"),s[Symbol.asyncIterator]=function(){return this},s;function d(c){a[c]&&(s[c]=function(w){return new Promise(function(A,P){l.push([c,w,A,P])>1||h(c,w)})})}function h(c,w){try{g(a[c](w))}catch(A){b(l[0][3],A)}}function g(c){c.value instanceof ct?Promise.resolve(c.value.v).then(u,p):b(l[0][2],c)}function u(c){h("next",c)}function p(c){h("throw",c)}function b(c,w){c(w),l.shift(),l.length&&h(l[0][0],l[0][1])}},ri=function(r){var n,i;return n={},a("next"),a("throw",function(s){throw s}),a("return"),n[Symbol.iterator]=function(){return this},n;function a(s,l){n[s]=r[s]?function(d){return(i=!i)?{value:ct(r[s](d)),done:s==="return"}:l?l(d):d}:l}},ni=function(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r[Symbol.asyncIterator],i;return n?n.call(r):(r=typeof so=="function"?so(r):r[Symbol.iterator](),i={},a("next"),a("throw"),a("return"),i[Symbol.asyncIterator]=function(){return this},i);function a(l){i[l]=r[l]&&function(d){return new Promise(function(h,g){d=r[l](d),s(h,g,d.done,d.value)})}}function s(l,d,h,g){Promise.resolve(g).then(function(u){l({value:u,done:h})},d)}},ii=function(r,n){return Object.defineProperty?Object.defineProperty(r,"raw",{value:n}):r.raw=n,r};var o=Object.create?function(r,n){Object.defineProperty(r,"default",{enumerable:!0,value:n})}:function(r,n){r.default=n};ai=function(r){if(r&&r.__esModule)return r;var n={};if(r!=null)for(var i in r)i!=="default"&&Object.prototype.hasOwnProperty.call(r,i)&&lo(n,r,i);return o(n,r),n},si=function(r){return r&&r.__esModule?r:{default:r}},li=function(r,n,i,a){if(i==="a"&&!a)throw new TypeError("Private accessor was defined without a getter");if(typeof n=="function"?r!==n||!a:!n.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return i==="m"?a:i==="a"?a.call(r):a?a.value:n.get(r)},ci=function(r,n,i,a,s){if(a==="m")throw new TypeError("Private method is not writable");if(a==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof n=="function"?r!==n||!s:!n.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return a==="a"?s.call(r,i):s?s.value=i:n.set(r,i),i},di=function(r,n){if(n===null||typeof n!="object"&&typeof n!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof r=="function"?n===r:r.has(n)},e("__extends",$n),e("__assign",jn),e("__rest",zn),e("__decorate",qn),e("__param",Zn),e("__metadata",Kn),e("__awaiter",Jn),e("__generator",Yn),e("__exportStar",Xn),e("__createBinding",lo),e("__values",so),e("__read",lr),e("__spread",Qn),e("__spreadArrays",ei),e("__spreadArray",ti),e("__await",ct),e("__asyncGenerator",oi),e("__asyncDelegator",ri),e("__asyncValues",ni),e("__makeTemplateObject",ii),e("__importStar",ai),e("__importDefault",si),e("__classPrivateFieldGet",li),e("__classPrivateFieldSet",ci),e("__classPrivateFieldIn",di)})});var cr=Se(R=>{"use strict";Object.defineProperty(R,"__esModule",{value:!0});R.getLocalStorage=R.getLocalStorageOrThrow=R.getCrypto=R.getCryptoOrThrow=R.getLocation=R.getLocationOrThrow=R.getNavigator=R.getNavigatorOrThrow=R.getDocument=R.getDocumentOrThrow=R.getFromWindowOrThrow=R.getFromWindow=void 0;function Ze(e){let t;return typeof window<"u"&&typeof window[e]<"u"&&(t=window[e]),t}R.getFromWindow=Ze;function dt(e){let t=Ze(e);if(!t)throw new Error(`${e} is not defined in Window`);return t}R.getFromWindowOrThrow=dt;function Ys(){return dt("document")}R.getDocumentOrThrow=Ys;function Xs(){return Ze("document")}R.getDocument=Xs;function Qs(){return dt("navigator")}R.getNavigatorOrThrow=Qs;function el(){return Ze("navigator")}R.getNavigator=el;function tl(){return dt("location")}R.getLocationOrThrow=tl;function ol(){return Ze("location")}R.getLocation=ol;function rl(){return dt("crypto")}R.getCryptoOrThrow=rl;function nl(){return Ze("crypto")}R.getCrypto=nl;function il(){return dt("localStorage")}R.getLocalStorageOrThrow=il;function al(){return Ze("localStorage")}R.getLocalStorage=al});var pi=Se(po=>{"use strict";Object.defineProperty(po,"__esModule",{value:!0});po.getWindowMetadata=void 0;var ui=cr();function sl(){let e,t;try{e=ui.getDocumentOrThrow(),t=ui.getLocationOrThrow()}catch{return null}function o(){let g=e.getElementsByTagName("link"),u=[];for(let p=0;p<g.length;p++){let b=g[p],c=b.getAttribute("rel");if(c&&c.toLowerCase().indexOf("icon")>-1){let w=b.getAttribute("href");if(w)if(w.toLowerCase().indexOf("https:")===-1&&w.toLowerCase().indexOf("http:")===-1&&w.indexOf("//")!==0){let A=t.protocol+"//"+t.host;if(w.indexOf("/")===0)A+=w;else{let P=t.pathname.split("/");P.pop(),A+=P.join("/")+"/"+w}u.push(A)}else if(w.indexOf("//")===0){let A=t.protocol+w;u.push(A)}else u.push(w)}}return u}function r(...g){let u=e.getElementsByTagName("meta");for(let p=0;p<u.length;p++){let b=u[p],c=["itemprop","property","name"].map(w=>b.getAttribute(w)).filter(w=>w?g.includes(w):!1);if(c.length&&c){let w=b.getAttribute("content");if(w)return w}}return""}function n(){let g=r("name","og:site_name","og:title","twitter:title");return g||(g=e.title),g}function i(){return r("description","og:description","twitter:description","keywords")}let a=n(),s=i(),l=t.origin,d=o();return{description:s,url:l,icons:d,name:a}}po.getWindowMetadata=sl});var _i={};cn(_i,{BotInfo:()=>wi,BrowserInfo:()=>hi,NodeInfo:()=>gi,ReactNativeInfo:()=>yi,SearchBotDeviceInfo:()=>bi,browserName:()=>fl,detect:()=>pl,detectOS:()=>Ci,getNodeVersion:()=>xi,parseUserAgent:()=>dr});function pl(e){return e?dr(e):typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new yi:typeof navigator<"u"?dr(navigator.userAgent):xi()}function vi(e){return e!==""&&ul.reduce(function(t,o){var r=o[0],n=o[1];if(t)return t;var i=n.exec(e);return!!i&&[r,i]},!1)}function fl(e){var t=vi(e);return t?t[0]:null}function dr(e){var t=vi(e);if(!t)return null;var o=t[0],r=t[1];if(o==="searchbot")return new wi;var n=r[1]&&r[1].split(/[._]/).slice(0,3);n?n.length<fi&&(n=ll(n,ml(fi-n.length))):n=[];var i=n.join("."),a=Ci(e),s=dl.exec(e);return s&&s[1]?new bi(o,i,a,s[1]):new hi(o,i,a)}function Ci(e){for(var t=0,o=mi.length;t<o;t++){var r=mi[t],n=r[0],i=r[1],a=i.exec(e);if(a)return n}return null}function xi(){var e=typeof process<"u"&&process.version;return e?new gi(process.version.slice(1)):null}function ml(e){for(var t=[],o=0;o<e;o++)t.push("0");return t}var ll,hi,gi,bi,wi,yi,cl,dl,fi,ul,mi,Ei=ln(()=>{ll=function(){for(var e=0,t=0,o=arguments.length;t<o;t++)e+=arguments[t].length;for(var r=Array(e),n=0,t=0;t<o;t++)for(var i=arguments[t],a=0,s=i.length;a<s;a++,n++)r[n]=i[a];return r},hi=function(){function e(t,o,r){this.name=t,this.version=o,this.os=r,this.type="browser"}return e}(),gi=function(){function e(t){this.version=t,this.type="node",this.name="node",this.os=process.platform}return e}(),bi=function(){function e(t,o,r,n){this.name=t,this.version=o,this.os=r,this.bot=n,this.type="bot-device"}return e}(),wi=function(){function e(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return e}(),yi=function(){function e(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return e}(),cl=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,dl=/(nuhk|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,fi=3,ul=[["aol",/AOLShield\/([0-9\._]+)/],["edge",/Edge\/([0-9\._]+)/],["edge-ios",/EdgiOS\/([0-9\._]+)/],["yandexbrowser",/YaBrowser\/([0-9\._]+)/],["kakaotalk",/KAKAOTALK\s([0-9\.]+)/],["samsung",/SamsungBrowser\/([0-9\.]+)/],["silk",/\bSilk\/([0-9._-]+)\b/],["miui",/MiuiBrowser\/([0-9\.]+)$/],["beaker",/BeakerBrowser\/([0-9\.]+)/],["edge-chromium",/EdgA?\/([0-9\.]+)/],["chromium-webview",/(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["chrome",/(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["phantomjs",/PhantomJS\/([0-9\.]+)(:?\s|$)/],["crios",/CriOS\/([0-9\.]+)(:?\s|$)/],["firefox",/Firefox\/([0-9\.]+)(?:\s|$)/],["fxios",/FxiOS\/([0-9\.]+)/],["opera-mini",/Opera Mini.*Version\/([0-9\.]+)/],["opera",/Opera\/([0-9\.]+)(?:\s|$)/],["opera",/OPR\/([0-9\.]+)(:?\s|$)/],["ie",/Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/],["ie",/MSIE\s([0-9\.]+);.*Trident\/[4-7].0/],["ie",/MSIE\s(7\.0)/],["bb10",/BB10;\sTouch.*Version\/([0-9\.]+)/],["android",/Android\s([0-9\.]+)/],["ios",/Version\/([0-9\._]+).*Mobile.*Safari.*/],["safari",/Version\/([0-9\._]+).*Safari/],["facebook",/FBAV\/([0-9\.]+)/],["instagram",/Instagram\s([0-9\.]+)/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Mobile/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Gecko\)$/],["searchbot",cl]],mi=[["iOS",/iP(hone|od|ad)/],["Android OS",/Android/],["BlackBerry OS",/BlackBerry|BB10/],["Windows Mobile",/IEMobile/],["Amazon OS",/Kindle/],["Windows 3.11",/Win16/],["Windows 95",/(Windows 95)|(Win95)|(Windows_95)/],["Windows 98",/(Windows 98)|(Win98)/],["Windows 2000",/(Windows NT 5.0)|(Windows 2000)/],["Windows XP",/(Windows NT 5.1)|(Windows XP)/],["Windows Server 2003",/(Windows NT 5.2)/],["Windows Vista",/(Windows NT 6.0)/],["Windows 7",/(Windows NT 6.1)/],["Windows 8",/(Windows NT 6.2)/],["Windows 8.1",/(Windows NT 6.3)/],["Windows 10",/(Windows NT 10.0)/],["Windows ME",/Windows ME/],["Open BSD",/OpenBSD/],["Sun OS",/SunOS/],["Chrome OS",/CrOS/],["Linux",/(Linux)|(X11)/],["Mac OS",/(Mac_PowerPC)|(Macintosh)/],["QNX",/QNX/],["BeOS",/BeOS/],["OS/2",/OS\/2/]]});var pr=Se(x=>{"use strict";Object.defineProperty(x,"__esModule",{value:!0});x.getClientMeta=x.getLocalStorage=x.getLocalStorageOrThrow=x.getCrypto=x.getCryptoOrThrow=x.getLocation=x.getLocationOrThrow=x.getNavigator=x.getNavigatorOrThrow=x.getDocument=x.getDocumentOrThrow=x.getFromWindowOrThrow=x.getFromWindow=x.isBrowser=x.isNode=x.isMobile=x.isIOS=x.isAndroid=x.detectOS=x.detectEnv=void 0;var Li=uo(),hl=Li.__importStar(pi()),fe=Li.__importStar(cr()),gl=(Ei(),un(_i));function ur(e){return(0,gl.detect)(e)}x.detectEnv=ur;function fo(){let e=ur();return e&&e.os?e.os:void 0}x.detectOS=fo;function Ai(){let e=fo();return e?e.toLowerCase().includes("android"):!1}x.isAndroid=Ai;function Si(){let e=fo();return e?e.toLowerCase().includes("ios")||e.toLowerCase().includes("mac")&&navigator.maxTouchPoints>1:!1}x.isIOS=Si;function bl(){return fo()?Ai()||Si():!1}x.isMobile=bl;function Pi(){let e=ur();return e&&e.name?e.name.toLowerCase()==="node":!1}x.isNode=Pi;function wl(){return!Pi()&&!!(0,x.getNavigator)()}x.isBrowser=wl;x.getFromWindow=fe.getFromWindow;x.getFromWindowOrThrow=fe.getFromWindowOrThrow;x.getDocumentOrThrow=fe.getDocumentOrThrow;x.getDocument=fe.getDocument;x.getNavigatorOrThrow=fe.getNavigatorOrThrow;x.getNavigator=fe.getNavigator;x.getLocationOrThrow=fe.getLocationOrThrow;x.getLocation=fe.getLocation;x.getCryptoOrThrow=fe.getCryptoOrThrow;x.getCrypto=fe.getCrypto;x.getLocalStorageOrThrow=fe.getLocalStorageOrThrow;x.getLocalStorage=fe.getLocalStorage;function yl(){return hl.getWindowMetadata()}x.getClientMeta=yl});var ki={};cn(ki,{safeJsonParse:()=>vl,safeJsonStringify:()=>Cl});function vl(e){if(typeof e!="string")throw new Error(`Cannot safe json parse value of type ${typeof e}`);try{return JSON.parse(e)}catch{return e}}function Cl(e){return typeof e=="string"?e:JSON.stringify(e)}var Ti=ln(()=>{});var fr=Se(ut=>{"use strict";Object.defineProperty(ut,"__esModule",{value:!0});ut.safeJsonStringify=ut.safeJsonParse=void 0;var xl=uo(),Wi=xl.__importStar((Ti(),un(ki)));ut.safeJsonParse=Wi.safeJsonParse;ut.safeJsonStringify=Wi.safeJsonStringify});var hr=Se(Ne=>{"use strict";Object.defineProperty(Ne,"__esModule",{value:!0});Ne.removeLocal=Ne.getLocal=Ne.setLocal=void 0;var Mi=fr(),mr=pr();function _l(e,t){let o=(0,Mi.safeJsonStringify)(t),r=(0,mr.getLocalStorage)();r&&r.setItem(e,o)}Ne.setLocal=_l;function El(e){let t=null,o=null,r=(0,mr.getLocalStorage)();return r&&(o=r.getItem(e)),t=o&&(0,Mi.safeJsonParse)(o),t}Ne.getLocal=El;function Ll(e){let t=(0,mr.getLocalStorage)();t&&t.removeItem(e)}Ne.removeLocal=Ll});var Ri=Se(re=>{"use strict";Object.defineProperty(re,"__esModule",{value:!0});re.getMobileLinkRegistry=re.getMobileRegistryEntry=re.saveMobileLinkInfo=re.formatIOSMobile=re.mobileLinkChoiceKey=void 0;var Al=hr();re.mobileLinkChoiceKey="WALLETCONNECT_DEEPLINK_CHOICE";function Sl(e,t){let o=encodeURIComponent(e);return t.universalLink?`${t.universalLink}/wc?uri=${o}`:t.deepLink?`${t.deepLink}${t.deepLink.endsWith(":")?"//":"/"}wc?uri=${o}`:""}re.formatIOSMobile=Sl;function Pl(e){let t=e.href.split("?")[0];(0,Al.setLocal)(re.mobileLinkChoiceKey,Object.assign(Object.assign({},e),{href:t}))}re.saveMobileLinkInfo=Pl;function Ii(e,t){return e.filter(o=>o.name.toLowerCase().includes(t.toLowerCase()))[0]}re.getMobileRegistryEntry=Ii;function kl(e,t){let o=e;return t&&(o=t.map(r=>Ii(e,r)).filter(Boolean)),o}re.getMobileLinkRegistry=kl});var Di=Se(_e=>{"use strict";Object.defineProperty(_e,"__esModule",{value:!0});_e.formatMobileRegistry=_e.formatMobileRegistryEntry=_e.getDappRegistryUrl=_e.getWalletRegistryUrl=void 0;var Oi="https://registry.walletconnect.com";function Tl(){return Oi+"/api/v2/wallets"}_e.getWalletRegistryUrl=Tl;function Wl(){return Oi+"/api/v2/dapps"}_e.getDappRegistryUrl=Wl;function Ni(e,t="mobile"){var o;return{name:e.name||"",shortName:e.metadata.shortName||"",color:e.metadata.colors.primary||"",logo:(o=e.image_url.sm)!==null&&o!==void 0?o:"",universalLink:e[t].universal||"",deepLink:e[t].native||""}}_e.formatMobileRegistryEntry=Ni;function Ml(e,t="mobile"){return Object.values(e).filter(o=>!!o[t].universal||!!o[t].native).map(o=>Ni(o,t))}_e.formatMobileRegistry=Ml});var Ui=Se(Ke=>{"use strict";Object.defineProperty(Ke,"__esModule",{value:!0});var Rt=uo();Rt.__exportStar(pr(),Ke);Rt.__exportStar(fr(),Ke);Rt.__exportStar(hr(),Ke);Rt.__exportStar(Ri(),Ke);Rt.__exportStar(Di(),Ke)});import{Web3Provider as $1}from"@ethersproject/providers";import{useEffect as _s,useState as X}from"react";var C=()=>{throw new Error("You need to wrap your application with the <PrivyProvider> initialized with your app id.")};import Ws from"axios";var ge=class extends Error{constructor(o,r){super(o);r instanceof Error&&(this.cause=r)}toString(){return`${this.type}: ${this.message}${this.cause?` [cause: ${this.cause}]`:""}`}},ot=class extends ge{constructor(o,r,n,i){super(n,i);this.type=o;this.status=r}},v=class extends ge{constructor(o,r){super(o,r);this.type="client_error"}};var V=class extends ge{constructor(o,r){super(o,r);this.type="connector_error"}},$=e=>{if(e instanceof ge)return e;if(!Ws.isAxiosError(e))return ue(e);if(!e.response)return new ot("api_error",null,e.message,e);let{type:t,message:o,error:r}=e.response.data;return new ot(t||"ApiError",e.response.status,o||r,e)},ue=e=>e instanceof ge?e:e instanceof Error?new v(e.message,e):new v(`Internal error: ${e}`);var pn=()=>"/api/v1/sessions",fn=()=>"/api/v1/sessions/logout",mn=()=>"/api/v1/sessions/fork",hn=()=>"/api/v1/siwe/init",gn=()=>"/api/v1/siwe/authenticate",bn=()=>"/api/v1/siwe/link",wn=()=>"/api/v1/passwordless/init",yn=()=>"/api/v1/passwordless/authenticate",vn=()=>"/api/v1/passwordless/link",Cn=()=>"/api/v1/passwordless_sms/init",xn=()=>"/api/v1/passwordless_sms/authenticate",_n=()=>"/api/v1/passwordless_sms/link",En=()=>"/api/v1/oauth/init",Ln=()=>"/api/v1/oauth/authenticate",An=()=>"/api/v1/oauth/link",Sn=()=>"/api/v1/siwe/unlink",Pn=()=>"/api/v1/passwordless/unlink",kn=()=>"/api/v1/passwordless_sms/unlink",Tn=()=>"/api/v1/oauth/unlink";var Wt=class{constructor(t){this.meta={email:t}}async authenticate(){if(!this.api)throw new v("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new v("Email and email code must be set prior to calling authenticate.");try{let t=yn(),o=await this.api.post(t,{email:this.meta.email,code:this.meta.emailCode});return{user:o.data.user,token:o.data.token,refresh_token:o.data.refresh_token,is_new_user:o.data.is_new_user}}catch(t){throw $(t)}}async link(){if(!this.api)throw new v("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new v("Email and email code must be set prior to calling authenticate.");try{let t=vn();return(await this.api.post(t,{email:this.meta.email,code:this.meta.emailCode})).data}catch(t){throw $(t)}}async sendCodeEmail(t){if(!this.api)throw new v("Auth flow has no API instance");if(t&&(this.meta.email=t),!this.meta.email)throw new v("Email must be set when initialzing authentication.");try{let o=wn();return(await this.api.post(o,{email:this.meta.email})).data}catch(o){throw $(o)}}};var rt=class{constructor(t,o,r){this.meta={provider:t},this.meta.authorizationCode=o,this.meta.stateCode=r}isActive(){return!!(this.meta.authorizationCode&&this.meta.stateCode&&this.meta.provider)}async authenticate(){if(!this.api)throw new v("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new v("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling authenticate.");if(this.meta.authorizationCode==="undefined")throw new v("User denied confirmation during OAuth flow");try{let t=Ln(),o=await this.api.post(t,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode});return{user:o.data.user,token:o.data.token,refresh_token:o.data.refresh_token,is_new_user:o.data.is_new_user}}catch(t){throw $(t)}}async link(){if(!this.api)throw new v("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new v("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling link.");if(this.meta.authorizationCode==="undefined")throw new v("User denied confirmation during OAuth flow");try{let t=An();return(await this.api.post(t,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode})).data}catch(t){throw $(t)}}async getAuthorizationUrl(){if(!this.api)throw new v("Auth flow has no API instance");if(!this.meta.provider)throw new v("Provider must be set when initialzing OAuth authentication.");try{let t=En();return(await this.api.post(t,{provider:this.meta.provider,redirect_to:window.location.href})).data}catch(t){throw $(t)}}};var Mt=class{constructor(t,o,r){this._meta={walletType:o,walletId:r},this.connectors=t,this.walletConnector=this.connectors.createWalletConnector(o,null,r)}get meta(){return{...this._meta,walletName:this.walletConnector.walletBranding.name,walletIcon:this.walletConnector.walletBranding.icon}}async authenticate(){if(!this.api)throw new v("Auth flow has no API instance");try{let{message:t,signature:o}=await this.sign(),r=await this.api.post(gn(),{message:t,signature:o});return this.connectors.addWalletConnector(this.walletConnector),await this.connectors.setActiveWallet(this.walletConnector.address)||console.warn("Failed to set active wallet"),{user:r.data.user,token:r.data.token,refresh_token:r.data.refresh_token,is_new_user:r.data.is_new_user}}catch(t){throw $(t)}}async link(){if(!this.api)throw new v("Auth flow has no API instance");try{let{message:t,signature:o}=await this.sign(),r=await this.api.post(bn(),{message:t,signature:o});return this.connectors.addWalletConnector(this.walletConnector),await this.connectors.setActiveWallet(this.walletConnector.address)||console.warn("Failed to set active wallet"),r.data}catch(t){throw $(t)}}async promptConnect(){if(!this.api)throw new v("Auth flow has no API instance");let t=await this.walletConnector.connect({showPrompt:!0});return await this.buildSiweMessage(t),t}async sign(){if(!this.api)throw new v("Auth flow has no API instance");if(!this.preparedMessage){let o=await this.walletConnector.connect({showPrompt:!1});await this.buildSiweMessage(o)}if(!this.preparedMessage)throw new v("Could not prepare SIWE message");let t=await this.walletConnector.sign(this.preparedMessage);return{message:this.preparedMessage,signature:t}}async buildSiweMessage(t){if(!this.api)throw new v("Auth flow has no API instance");let o=t.address,r=t.chainId,n=await this.api.post(hn(),{address:o});return this.preparedMessage=this.walletConnector.prepareMessage(r,o,n.data.nonce),this.preparedMessage}};var It=class{constructor(t){this.meta={phoneNumber:t}}async authenticate(){if(!this.api)throw new v("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new v("phone number and sms code must be set prior to calling authenticate.");try{let t=xn(),o=await this.api.post(t,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode});return{user:o.data.user,token:o.data.token,refresh_token:o.data.refresh_token,is_new_user:o.data.is_new_user}}catch(t){throw $(t)}}async link(){if(!this.api)throw new v("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new v("phone number and sms code must be set prior to calling authenticate.");try{let t=_n();return(await this.api.post(t,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode})).data}catch(t){throw $(t)}}async sendSmsCode(t){if(!this.api)throw new v("Auth flow has no API instance");if(t&&(this.meta.phoneNumber=t),!this.meta.phoneNumber)throw new v("phone nNumber must be set when initialzing authentication.");try{let o=Cn();return(await this.api.post(o,{phoneNumber:this.meta.phoneNumber})).data}catch(o){throw $(o)}}};import{getAddress as Nl}from"@ethersproject/address";var Wn="1.18.0-beta.7";var Mn="https://api.privy.io/v0",Qo=process.env.NEXT_PUBLIC_PRIVY_AUTH_URL||"https://auth.privy.io",Qt="4df5e2316331463a9130964bd6078dfa",In=1e4,pe=1400,er=Wn;var nt="privy:token",eo="privy:refresh_token",to="privy:connectors",tr="walletconnect",Rn=3e4;var or=class{constructor(){this._cache={}}get(t){return this._cache[t]}put(t,o){o!==void 0?this._cache[t]=o:this.del(t)}del(t){delete this._cache[t]}getKeys(){return Object.keys(this._cache)}},rr=class{get(t){let o=localStorage.getItem(t);return o===null?void 0:JSON.parse(o)}put(t,o){o!==void 0?localStorage.setItem(t,JSON.stringify(o)):this.del(t)}del(t){localStorage.removeItem(t)}getKeys(){return Object.entries(localStorage).map(([t])=>t)}};function Is(){return typeof window<"u"&&window.localStorage?new rr:new or}var j=Is();import Hs from"@coinbase/wallet-sdk";import{getAddress as Vs}from"@ethersproject/address";import{jsx as On,jsxs as Rs}from"react/jsx-runtime";var ve=({style:e,...t})=>Rs("svg",{width:"1024",height:"1024",viewBox:"0 0 1024 1024",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"28px",width:"28px",...e},...t,children:[On("rect",{width:"1024",height:"1024",fill:"#0052FF",rx:100,ry:100}),On("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z",fill:"white"})]});import{getAddress as Bs}from"@ethersproject/address";import{Web3Provider as Gs}from"@ethersproject/providers";import{ErrorCode as Os}from"@ethersproject/logger";var it=class extends V{constructor(){super("Wallet timeout");this.type="wallet_error"}},$e=class extends V{constructor(){super("User rejected connection");this.type="wallet_error"}},Ce=e=>{if(e instanceof V)return e;if((e==null?void 0:e.code)&&(e==null?void 0:e.reason)){let t=new at(e);return e.code===Os.ACTION_REJECTED&&(t.details=Ve.E4001_USER_REJECTED_REQUEST),t}return e!=null&&e.code?new at(e):new V("Unknown connector error",e)},nr=class extends ge{constructor(o,r,n){super(o);this.type="provider_error";this.code=r,this.data=n}},at=class extends nr{constructor(o){var i,a,s;let r=o;super(r.message,r.code,r.data);let n=Object.values(Ve).find(l=>l.eipCode===r.code);this.details=n||Ve.UNKNOWN_ERROR,r.code===-32002&&((i=r.message)!=null&&i.includes("already pending for origin")?(a=r.message)!=null&&a.includes("wallet_requestPermissions")?this.details=Ve.E32002_CONNECTION_ALREADY_PENDING:this.details=Ve.E32002_REQUEST_ALREADY_PENDING:(s=r.message)!=null&&s.includes("Already processing")&&r.message.includes("eth_requestAccounts")&&(this.details=Ve.E32002_WALLET_LOCKED))}},Ns={ERROR_USER_EXISTS:{message:"User already exists for this address",detail:"Try another address!",retryable:!1},ERROR_TIMED_OUT:{message:"Wallet request timed out",detail:"Please try connecting again.",retryable:!0},ERROR_WALLET_CONNECTION:{message:"Could not log in with wallet",detail:"Please try connecting again.",retryable:!0},ERROR_USER_REJECTED_CONNECTION:{message:"You rejected the request",detail:"Please try connecting again.",retryable:!0}},Ds={E32002_CONNECTION_ALREADY_PENDING:{eipCode:-32002,message:"Connection request already pending",detail:"Don\u2019t see your wallet modal? Check your other browser windows.",retryable:!1},E32002_REQUEST_ALREADY_PENDING:{eipCode:-32002,message:"Resource request already pending",detail:"Don\u2019t see your wallet modal? Check your other browser windows.",retryable:!1},E32002_WALLET_LOCKED:{eipCode:-32002,message:"Wallet might be locked",detail:"Don\u2019t see your wallet modal? Check your other browser windows.",retryable:!1},E4001_USER_REJECTED_REQUEST:{eipCode:4001,message:"Signature rejected",detail:"Please try signing again.",retryable:!0}},Us={E4001_DEFAULT_USER_REJECTED_REQUEST:{eipCode:4001,message:"User Rejected Request",detail:"The user rejected the request.",default:!0,retryable:!0},E4100_DEFAULT_UNAUTHORIZED:{eipCode:4100,message:"Unauthorized",detail:"The requested method and/or account has not been authorized by the user.",default:!0,retryable:!1},E4200_DEFAULT_UNSUPPORTED_METHOD:{eipCode:4200,message:"Unsupported Method",detail:"The Provider does not support the requested method.",default:!0,retryable:!1},E4900_DEFAULT_DISCONNECTED:{eipCode:4900,message:"Disconnected",detail:"The Provider is disconnected from all chains.",default:!0,retryable:!0},E4901_DEFAULT_CHAIN_DISCONNECTED:{eipCode:4901,message:"Chain Disconnected",detail:"The Provider is not connected to the requested chain.",default:!0,retryable:!0},E32700_DEFAULT_PARSE_ERROR:{eipCode:-32700,message:"Parse error",detail:"Invalid JSON",default:!0,retryable:!1},E32600_DEFAULT_INVALID_REQUEST:{eipCode:-32600,message:"Invalid request",detail:"JSON is not a valid request object",default:!0,retryable:!1},E32601_DEFAULT_METHOD_NOT_FOUND:{eipCode:-32601,message:"Method not found",detail:"Method does not exist",default:!0,retryable:!1},E32602_DEFAULT_INVALID_PARAMS:{eipCode:-32602,message:"Invalid params",detail:"Invalid method parameters",default:!0,retryable:!1},E32603_DEFAULT_INTERNAL_ERROR:{eipCode:-32603,message:"Internal error",detail:"Internal JSON-RPC error",default:!0,retryable:!0},E32000_DEFAULT_INVALID_INPUT:{eipCode:-32e3,message:"Invalid input",detail:"Missing or invalid parameters",default:!0,retryable:!1},E32001_DEFAULT_RESOURCE_NOT_FOUND:{eipCode:-32001,message:"Resource not found",detail:"Requested resource not found",default:!0,retryable:!1},E32002_DEFAULT_RESOURCE_UNAVAILABLE:{eipCode:-32002,message:"Resource unavailable",detail:"Requested resource not available",default:!0,retryable:!0},E32003_DEFAULT_TRANSACTION_REJECTED:{eipCode:-32003,message:"Transaction rejected",detail:"Transaction creation failed",default:!0,retryable:!0},E32004_DEFAULT_METHOD_NOT_SUPPORTED:{eipCode:-32004,message:"Method not supported",detail:"Method is not implemented",default:!0,retryable:!1},E32005_DEFAULT_LIMIT_EXCEEDED:{eipCode:-32005,message:"Limit exceeded",detail:"Request exceeds defined limit",default:!0,retryable:!1},E32006_DEFAULT_JSON_RPC_VERSION_NOT_SUPPORTED:{eipCode:-32006,message:"JSON-RPC version not supported",detail:"Version of JSON-RPC protocol is not supported",default:!0,retryable:!1}},Ve={UNKNOWN_ERROR:{eipCode:0,message:"Unknown error",detail:"Unknown error",retryable:!0},...Us,...Ds},je={...Ns,...Ve};var Fs=12e4,ir=(e=new it,t=Fs)=>new Promise((o,r)=>setTimeout(()=>{r(e)},t)),xe=class{constructor(t){this.removeListener=(t,o)=>{if(this.walletProvider)return this.walletProvider.removeListener(t,o)};this.setWalletProvider=t=>{this.walletProvider=t,this._subscriptions.forEach(o=>{var r;(r=this.walletProvider)==null||r.on(o.eventName,o.listener)})};this.walletProvider=t,this._subscriptions=[]}on(t,o){if(this.walletProvider)return this.walletProvider.on(t,o);this._subscriptions.push({eventName:t,listener:o})}async request(t){if(!this.walletProvider)throw new V(`A wallet request of type ${t.method} was made before setting a wallet provider.`);return Promise.race([this.walletProvider.request(t),ir()]).catch(o=>{throw Ce(o)})}},ze=class extends xe{constructor(o){super(o)}},oo=class extends xe{constructor(t){super(t)}sendAsync(t,o){throw new Error("sendAsync is no longer supported by EIP-1193. Use the request method instead.")}};var Pe=class{constructor(t,o,r){this.createSiweMessage=(t,o,r,n,i,a,s)=>`${r} wants you to sign in with your Ethereum account:
1
+ var Ls=Object.create;var Xt=Object.defineProperty;var As=Object.getOwnPropertyDescriptor;var Ss=Object.getOwnPropertyNames;var Ps=Object.getPrototypeOf,ks=Object.prototype.hasOwnProperty;var ln=(e,t)=>()=>(e&&(t=e(e=0)),t);var Se=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),cn=(e,t)=>{for(var o in t)Xt(e,o,{get:t[o],enumerable:!0})},dn=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Ss(t))!ks.call(e,n)&&n!==o&&Xt(e,n,{get:()=>t[n],enumerable:!(r=As(t,n))||r.enumerable});return e};var Ts=(e,t,o)=>(o=e!=null?Ls(Ps(e)):{},dn(t||!e||!e.__esModule?Xt(o,"default",{value:e,enumerable:!0}):o,e)),un=e=>dn(Xt({},"__esModule",{value:!0}),e);var uo=Se((Q2,co)=>{var $n,jn,zn,qn,Zn,Kn,Jn,Yn,Xn,so,lr,Qn,ei,ti,ct,oi,ri,ni,ii,ai,si,li,ci,di,lo;(function(e){var t=typeof global=="object"?global:typeof self=="object"?self:typeof this=="object"?this:{};typeof define=="function"&&define.amd?define("tslib",["exports"],function(r){e(o(t,o(r)))}):typeof co=="object"&&typeof co.exports=="object"?e(o(t,o(co.exports))):e(o(t));function o(r,n){return r!==t&&(typeof Object.create=="function"?Object.defineProperty(r,"__esModule",{value:!0}):r.__esModule=!0),function(i,a){return r[i]=n?n(i,a):a}}})(function(e){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(r[i]=n[i])};$n=function(r,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");t(r,n);function i(){this.constructor=r}r.prototype=n===null?Object.create(n):(i.prototype=n.prototype,new i)},jn=Object.assign||function(r){for(var n,i=1,a=arguments.length;i<a;i++){n=arguments[i];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(r[s]=n[s])}return r},zn=function(r,n){var i={};for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&n.indexOf(a)<0&&(i[a]=r[a]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,a=Object.getOwnPropertySymbols(r);s<a.length;s++)n.indexOf(a[s])<0&&Object.prototype.propertyIsEnumerable.call(r,a[s])&&(i[a[s]]=r[a[s]]);return i},qn=function(r,n,i,a){var s=arguments.length,l=s<3?n:a===null?a=Object.getOwnPropertyDescriptor(n,i):a,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")l=Reflect.decorate(r,n,i,a);else for(var h=r.length-1;h>=0;h--)(d=r[h])&&(l=(s<3?d(l):s>3?d(n,i,l):d(n,i))||l);return s>3&&l&&Object.defineProperty(n,i,l),l},Zn=function(r,n){return function(i,a){n(i,a,r)}},Kn=function(r,n){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,n)},Jn=function(r,n,i,a){function s(l){return l instanceof i?l:new i(function(d){d(l)})}return new(i||(i=Promise))(function(l,d){function h(p){try{u(a.next(p))}catch(b){d(b)}}function g(p){try{u(a.throw(p))}catch(b){d(b)}}function u(p){p.done?l(p.value):s(p.value).then(h,g)}u((a=a.apply(r,n||[])).next())})},Yn=function(r,n){var i={label:0,sent:function(){if(l[0]&1)throw l[1];return l[1]},trys:[],ops:[]},a,s,l,d;return d={next:h(0),throw:h(1),return:h(2)},typeof Symbol=="function"&&(d[Symbol.iterator]=function(){return this}),d;function h(u){return function(p){return g([u,p])}}function g(u){if(a)throw new TypeError("Generator is already executing.");for(;i;)try{if(a=1,s&&(l=u[0]&2?s.return:u[0]?s.throw||((l=s.return)&&l.call(s),0):s.next)&&!(l=l.call(s,u[1])).done)return l;switch(s=0,l&&(u=[u[0]&2,l.value]),u[0]){case 0:case 1:l=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,s=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(l=i.trys,!(l=l.length>0&&l[l.length-1])&&(u[0]===6||u[0]===2)){i=0;continue}if(u[0]===3&&(!l||u[1]>l[0]&&u[1]<l[3])){i.label=u[1];break}if(u[0]===6&&i.label<l[1]){i.label=l[1],l=u;break}if(l&&i.label<l[2]){i.label=l[2],i.ops.push(u);break}l[2]&&i.ops.pop(),i.trys.pop();continue}u=n.call(r,i)}catch(p){u=[6,p],s=0}finally{a=l=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}},Xn=function(r,n){for(var i in r)i!=="default"&&!Object.prototype.hasOwnProperty.call(n,i)&&lo(n,r,i)},lo=Object.create?function(r,n,i,a){a===void 0&&(a=i);var s=Object.getOwnPropertyDescriptor(n,i);(!s||("get"in s?!n.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return n[i]}}),Object.defineProperty(r,a,s)}:function(r,n,i,a){a===void 0&&(a=i),r[a]=n[i]},so=function(r){var n=typeof Symbol=="function"&&Symbol.iterator,i=n&&r[n],a=0;if(i)return i.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&a>=r.length&&(r=void 0),{value:r&&r[a++],done:!r}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")},lr=function(r,n){var i=typeof Symbol=="function"&&r[Symbol.iterator];if(!i)return r;var a=i.call(r),s,l=[],d;try{for(;(n===void 0||n-- >0)&&!(s=a.next()).done;)l.push(s.value)}catch(h){d={error:h}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(d)throw d.error}}return l},Qn=function(){for(var r=[],n=0;n<arguments.length;n++)r=r.concat(lr(arguments[n]));return r},ei=function(){for(var r=0,n=0,i=arguments.length;n<i;n++)r+=arguments[n].length;for(var a=Array(r),s=0,n=0;n<i;n++)for(var l=arguments[n],d=0,h=l.length;d<h;d++,s++)a[s]=l[d];return a},ti=function(r,n,i){if(i||arguments.length===2)for(var a=0,s=n.length,l;a<s;a++)(l||!(a in n))&&(l||(l=Array.prototype.slice.call(n,0,a)),l[a]=n[a]);return r.concat(l||Array.prototype.slice.call(n))},ct=function(r){return this instanceof ct?(this.v=r,this):new ct(r)},oi=function(r,n,i){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var a=i.apply(r,n||[]),s,l=[];return s={},d("next"),d("throw"),d("return"),s[Symbol.asyncIterator]=function(){return this},s;function d(c){a[c]&&(s[c]=function(w){return new Promise(function(A,P){l.push([c,w,A,P])>1||h(c,w)})})}function h(c,w){try{g(a[c](w))}catch(A){b(l[0][3],A)}}function g(c){c.value instanceof ct?Promise.resolve(c.value.v).then(u,p):b(l[0][2],c)}function u(c){h("next",c)}function p(c){h("throw",c)}function b(c,w){c(w),l.shift(),l.length&&h(l[0][0],l[0][1])}},ri=function(r){var n,i;return n={},a("next"),a("throw",function(s){throw s}),a("return"),n[Symbol.iterator]=function(){return this},n;function a(s,l){n[s]=r[s]?function(d){return(i=!i)?{value:ct(r[s](d)),done:s==="return"}:l?l(d):d}:l}},ni=function(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r[Symbol.asyncIterator],i;return n?n.call(r):(r=typeof so=="function"?so(r):r[Symbol.iterator](),i={},a("next"),a("throw"),a("return"),i[Symbol.asyncIterator]=function(){return this},i);function a(l){i[l]=r[l]&&function(d){return new Promise(function(h,g){d=r[l](d),s(h,g,d.done,d.value)})}}function s(l,d,h,g){Promise.resolve(g).then(function(u){l({value:u,done:h})},d)}},ii=function(r,n){return Object.defineProperty?Object.defineProperty(r,"raw",{value:n}):r.raw=n,r};var o=Object.create?function(r,n){Object.defineProperty(r,"default",{enumerable:!0,value:n})}:function(r,n){r.default=n};ai=function(r){if(r&&r.__esModule)return r;var n={};if(r!=null)for(var i in r)i!=="default"&&Object.prototype.hasOwnProperty.call(r,i)&&lo(n,r,i);return o(n,r),n},si=function(r){return r&&r.__esModule?r:{default:r}},li=function(r,n,i,a){if(i==="a"&&!a)throw new TypeError("Private accessor was defined without a getter");if(typeof n=="function"?r!==n||!a:!n.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return i==="m"?a:i==="a"?a.call(r):a?a.value:n.get(r)},ci=function(r,n,i,a,s){if(a==="m")throw new TypeError("Private method is not writable");if(a==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof n=="function"?r!==n||!s:!n.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return a==="a"?s.call(r,i):s?s.value=i:n.set(r,i),i},di=function(r,n){if(n===null||typeof n!="object"&&typeof n!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof r=="function"?n===r:r.has(n)},e("__extends",$n),e("__assign",jn),e("__rest",zn),e("__decorate",qn),e("__param",Zn),e("__metadata",Kn),e("__awaiter",Jn),e("__generator",Yn),e("__exportStar",Xn),e("__createBinding",lo),e("__values",so),e("__read",lr),e("__spread",Qn),e("__spreadArrays",ei),e("__spreadArray",ti),e("__await",ct),e("__asyncGenerator",oi),e("__asyncDelegator",ri),e("__asyncValues",ni),e("__makeTemplateObject",ii),e("__importStar",ai),e("__importDefault",si),e("__classPrivateFieldGet",li),e("__classPrivateFieldSet",ci),e("__classPrivateFieldIn",di)})});var cr=Se(R=>{"use strict";Object.defineProperty(R,"__esModule",{value:!0});R.getLocalStorage=R.getLocalStorageOrThrow=R.getCrypto=R.getCryptoOrThrow=R.getLocation=R.getLocationOrThrow=R.getNavigator=R.getNavigatorOrThrow=R.getDocument=R.getDocumentOrThrow=R.getFromWindowOrThrow=R.getFromWindow=void 0;function Ze(e){let t;return typeof window<"u"&&typeof window[e]<"u"&&(t=window[e]),t}R.getFromWindow=Ze;function dt(e){let t=Ze(e);if(!t)throw new Error(`${e} is not defined in Window`);return t}R.getFromWindowOrThrow=dt;function Ys(){return dt("document")}R.getDocumentOrThrow=Ys;function Xs(){return Ze("document")}R.getDocument=Xs;function Qs(){return dt("navigator")}R.getNavigatorOrThrow=Qs;function el(){return Ze("navigator")}R.getNavigator=el;function tl(){return dt("location")}R.getLocationOrThrow=tl;function ol(){return Ze("location")}R.getLocation=ol;function rl(){return dt("crypto")}R.getCryptoOrThrow=rl;function nl(){return Ze("crypto")}R.getCrypto=nl;function il(){return dt("localStorage")}R.getLocalStorageOrThrow=il;function al(){return Ze("localStorage")}R.getLocalStorage=al});var pi=Se(po=>{"use strict";Object.defineProperty(po,"__esModule",{value:!0});po.getWindowMetadata=void 0;var ui=cr();function sl(){let e,t;try{e=ui.getDocumentOrThrow(),t=ui.getLocationOrThrow()}catch{return null}function o(){let g=e.getElementsByTagName("link"),u=[];for(let p=0;p<g.length;p++){let b=g[p],c=b.getAttribute("rel");if(c&&c.toLowerCase().indexOf("icon")>-1){let w=b.getAttribute("href");if(w)if(w.toLowerCase().indexOf("https:")===-1&&w.toLowerCase().indexOf("http:")===-1&&w.indexOf("//")!==0){let A=t.protocol+"//"+t.host;if(w.indexOf("/")===0)A+=w;else{let P=t.pathname.split("/");P.pop(),A+=P.join("/")+"/"+w}u.push(A)}else if(w.indexOf("//")===0){let A=t.protocol+w;u.push(A)}else u.push(w)}}return u}function r(...g){let u=e.getElementsByTagName("meta");for(let p=0;p<u.length;p++){let b=u[p],c=["itemprop","property","name"].map(w=>b.getAttribute(w)).filter(w=>w?g.includes(w):!1);if(c.length&&c){let w=b.getAttribute("content");if(w)return w}}return""}function n(){let g=r("name","og:site_name","og:title","twitter:title");return g||(g=e.title),g}function i(){return r("description","og:description","twitter:description","keywords")}let a=n(),s=i(),l=t.origin,d=o();return{description:s,url:l,icons:d,name:a}}po.getWindowMetadata=sl});var _i={};cn(_i,{BotInfo:()=>wi,BrowserInfo:()=>hi,NodeInfo:()=>gi,ReactNativeInfo:()=>yi,SearchBotDeviceInfo:()=>bi,browserName:()=>fl,detect:()=>pl,detectOS:()=>Ci,getNodeVersion:()=>xi,parseUserAgent:()=>dr});function pl(e){return e?dr(e):typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new yi:typeof navigator<"u"?dr(navigator.userAgent):xi()}function vi(e){return e!==""&&ul.reduce(function(t,o){var r=o[0],n=o[1];if(t)return t;var i=n.exec(e);return!!i&&[r,i]},!1)}function fl(e){var t=vi(e);return t?t[0]:null}function dr(e){var t=vi(e);if(!t)return null;var o=t[0],r=t[1];if(o==="searchbot")return new wi;var n=r[1]&&r[1].split(/[._]/).slice(0,3);n?n.length<fi&&(n=ll(n,ml(fi-n.length))):n=[];var i=n.join("."),a=Ci(e),s=dl.exec(e);return s&&s[1]?new bi(o,i,a,s[1]):new hi(o,i,a)}function Ci(e){for(var t=0,o=mi.length;t<o;t++){var r=mi[t],n=r[0],i=r[1],a=i.exec(e);if(a)return n}return null}function xi(){var e=typeof process<"u"&&process.version;return e?new gi(process.version.slice(1)):null}function ml(e){for(var t=[],o=0;o<e;o++)t.push("0");return t}var ll,hi,gi,bi,wi,yi,cl,dl,fi,ul,mi,Ei=ln(()=>{ll=function(){for(var e=0,t=0,o=arguments.length;t<o;t++)e+=arguments[t].length;for(var r=Array(e),n=0,t=0;t<o;t++)for(var i=arguments[t],a=0,s=i.length;a<s;a++,n++)r[n]=i[a];return r},hi=function(){function e(t,o,r){this.name=t,this.version=o,this.os=r,this.type="browser"}return e}(),gi=function(){function e(t){this.version=t,this.type="node",this.name="node",this.os=process.platform}return e}(),bi=function(){function e(t,o,r,n){this.name=t,this.version=o,this.os=r,this.bot=n,this.type="bot-device"}return e}(),wi=function(){function e(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return e}(),yi=function(){function e(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return e}(),cl=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,dl=/(nuhk|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,fi=3,ul=[["aol",/AOLShield\/([0-9\._]+)/],["edge",/Edge\/([0-9\._]+)/],["edge-ios",/EdgiOS\/([0-9\._]+)/],["yandexbrowser",/YaBrowser\/([0-9\._]+)/],["kakaotalk",/KAKAOTALK\s([0-9\.]+)/],["samsung",/SamsungBrowser\/([0-9\.]+)/],["silk",/\bSilk\/([0-9._-]+)\b/],["miui",/MiuiBrowser\/([0-9\.]+)$/],["beaker",/BeakerBrowser\/([0-9\.]+)/],["edge-chromium",/EdgA?\/([0-9\.]+)/],["chromium-webview",/(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["chrome",/(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["phantomjs",/PhantomJS\/([0-9\.]+)(:?\s|$)/],["crios",/CriOS\/([0-9\.]+)(:?\s|$)/],["firefox",/Firefox\/([0-9\.]+)(?:\s|$)/],["fxios",/FxiOS\/([0-9\.]+)/],["opera-mini",/Opera Mini.*Version\/([0-9\.]+)/],["opera",/Opera\/([0-9\.]+)(?:\s|$)/],["opera",/OPR\/([0-9\.]+)(:?\s|$)/],["ie",/Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/],["ie",/MSIE\s([0-9\.]+);.*Trident\/[4-7].0/],["ie",/MSIE\s(7\.0)/],["bb10",/BB10;\sTouch.*Version\/([0-9\.]+)/],["android",/Android\s([0-9\.]+)/],["ios",/Version\/([0-9\._]+).*Mobile.*Safari.*/],["safari",/Version\/([0-9\._]+).*Safari/],["facebook",/FBAV\/([0-9\.]+)/],["instagram",/Instagram\s([0-9\.]+)/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Mobile/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Gecko\)$/],["searchbot",cl]],mi=[["iOS",/iP(hone|od|ad)/],["Android OS",/Android/],["BlackBerry OS",/BlackBerry|BB10/],["Windows Mobile",/IEMobile/],["Amazon OS",/Kindle/],["Windows 3.11",/Win16/],["Windows 95",/(Windows 95)|(Win95)|(Windows_95)/],["Windows 98",/(Windows 98)|(Win98)/],["Windows 2000",/(Windows NT 5.0)|(Windows 2000)/],["Windows XP",/(Windows NT 5.1)|(Windows XP)/],["Windows Server 2003",/(Windows NT 5.2)/],["Windows Vista",/(Windows NT 6.0)/],["Windows 7",/(Windows NT 6.1)/],["Windows 8",/(Windows NT 6.2)/],["Windows 8.1",/(Windows NT 6.3)/],["Windows 10",/(Windows NT 10.0)/],["Windows ME",/Windows ME/],["Open BSD",/OpenBSD/],["Sun OS",/SunOS/],["Chrome OS",/CrOS/],["Linux",/(Linux)|(X11)/],["Mac OS",/(Mac_PowerPC)|(Macintosh)/],["QNX",/QNX/],["BeOS",/BeOS/],["OS/2",/OS\/2/]]});var pr=Se(x=>{"use strict";Object.defineProperty(x,"__esModule",{value:!0});x.getClientMeta=x.getLocalStorage=x.getLocalStorageOrThrow=x.getCrypto=x.getCryptoOrThrow=x.getLocation=x.getLocationOrThrow=x.getNavigator=x.getNavigatorOrThrow=x.getDocument=x.getDocumentOrThrow=x.getFromWindowOrThrow=x.getFromWindow=x.isBrowser=x.isNode=x.isMobile=x.isIOS=x.isAndroid=x.detectOS=x.detectEnv=void 0;var Li=uo(),hl=Li.__importStar(pi()),fe=Li.__importStar(cr()),gl=(Ei(),un(_i));function ur(e){return(0,gl.detect)(e)}x.detectEnv=ur;function fo(){let e=ur();return e&&e.os?e.os:void 0}x.detectOS=fo;function Ai(){let e=fo();return e?e.toLowerCase().includes("android"):!1}x.isAndroid=Ai;function Si(){let e=fo();return e?e.toLowerCase().includes("ios")||e.toLowerCase().includes("mac")&&navigator.maxTouchPoints>1:!1}x.isIOS=Si;function bl(){return fo()?Ai()||Si():!1}x.isMobile=bl;function Pi(){let e=ur();return e&&e.name?e.name.toLowerCase()==="node":!1}x.isNode=Pi;function wl(){return!Pi()&&!!(0,x.getNavigator)()}x.isBrowser=wl;x.getFromWindow=fe.getFromWindow;x.getFromWindowOrThrow=fe.getFromWindowOrThrow;x.getDocumentOrThrow=fe.getDocumentOrThrow;x.getDocument=fe.getDocument;x.getNavigatorOrThrow=fe.getNavigatorOrThrow;x.getNavigator=fe.getNavigator;x.getLocationOrThrow=fe.getLocationOrThrow;x.getLocation=fe.getLocation;x.getCryptoOrThrow=fe.getCryptoOrThrow;x.getCrypto=fe.getCrypto;x.getLocalStorageOrThrow=fe.getLocalStorageOrThrow;x.getLocalStorage=fe.getLocalStorage;function yl(){return hl.getWindowMetadata()}x.getClientMeta=yl});var ki={};cn(ki,{safeJsonParse:()=>vl,safeJsonStringify:()=>Cl});function vl(e){if(typeof e!="string")throw new Error(`Cannot safe json parse value of type ${typeof e}`);try{return JSON.parse(e)}catch{return e}}function Cl(e){return typeof e=="string"?e:JSON.stringify(e)}var Ti=ln(()=>{});var fr=Se(ut=>{"use strict";Object.defineProperty(ut,"__esModule",{value:!0});ut.safeJsonStringify=ut.safeJsonParse=void 0;var xl=uo(),Wi=xl.__importStar((Ti(),un(ki)));ut.safeJsonParse=Wi.safeJsonParse;ut.safeJsonStringify=Wi.safeJsonStringify});var hr=Se(Ne=>{"use strict";Object.defineProperty(Ne,"__esModule",{value:!0});Ne.removeLocal=Ne.getLocal=Ne.setLocal=void 0;var Mi=fr(),mr=pr();function _l(e,t){let o=(0,Mi.safeJsonStringify)(t),r=(0,mr.getLocalStorage)();r&&r.setItem(e,o)}Ne.setLocal=_l;function El(e){let t=null,o=null,r=(0,mr.getLocalStorage)();return r&&(o=r.getItem(e)),t=o&&(0,Mi.safeJsonParse)(o),t}Ne.getLocal=El;function Ll(e){let t=(0,mr.getLocalStorage)();t&&t.removeItem(e)}Ne.removeLocal=Ll});var Ri=Se(re=>{"use strict";Object.defineProperty(re,"__esModule",{value:!0});re.getMobileLinkRegistry=re.getMobileRegistryEntry=re.saveMobileLinkInfo=re.formatIOSMobile=re.mobileLinkChoiceKey=void 0;var Al=hr();re.mobileLinkChoiceKey="WALLETCONNECT_DEEPLINK_CHOICE";function Sl(e,t){let o=encodeURIComponent(e);return t.universalLink?`${t.universalLink}/wc?uri=${o}`:t.deepLink?`${t.deepLink}${t.deepLink.endsWith(":")?"//":"/"}wc?uri=${o}`:""}re.formatIOSMobile=Sl;function Pl(e){let t=e.href.split("?")[0];(0,Al.setLocal)(re.mobileLinkChoiceKey,Object.assign(Object.assign({},e),{href:t}))}re.saveMobileLinkInfo=Pl;function Ii(e,t){return e.filter(o=>o.name.toLowerCase().includes(t.toLowerCase()))[0]}re.getMobileRegistryEntry=Ii;function kl(e,t){let o=e;return t&&(o=t.map(r=>Ii(e,r)).filter(Boolean)),o}re.getMobileLinkRegistry=kl});var Di=Se(_e=>{"use strict";Object.defineProperty(_e,"__esModule",{value:!0});_e.formatMobileRegistry=_e.formatMobileRegistryEntry=_e.getDappRegistryUrl=_e.getWalletRegistryUrl=void 0;var Oi="https://registry.walletconnect.com";function Tl(){return Oi+"/api/v2/wallets"}_e.getWalletRegistryUrl=Tl;function Wl(){return Oi+"/api/v2/dapps"}_e.getDappRegistryUrl=Wl;function Ni(e,t="mobile"){var o;return{name:e.name||"",shortName:e.metadata.shortName||"",color:e.metadata.colors.primary||"",logo:(o=e.image_url.sm)!==null&&o!==void 0?o:"",universalLink:e[t].universal||"",deepLink:e[t].native||""}}_e.formatMobileRegistryEntry=Ni;function Ml(e,t="mobile"){return Object.values(e).filter(o=>!!o[t].universal||!!o[t].native).map(o=>Ni(o,t))}_e.formatMobileRegistry=Ml});var Ui=Se(Ke=>{"use strict";Object.defineProperty(Ke,"__esModule",{value:!0});var Rt=uo();Rt.__exportStar(pr(),Ke);Rt.__exportStar(fr(),Ke);Rt.__exportStar(hr(),Ke);Rt.__exportStar(Ri(),Ke);Rt.__exportStar(Di(),Ke)});import{Web3Provider as $1}from"@ethersproject/providers";import{useEffect as _s,useState as X}from"react";var C=()=>{throw new Error("You need to wrap your application with the <PrivyProvider> initialized with your app id.")};import Ws from"axios";var ge=class extends Error{constructor(o,r){super(o);r instanceof Error&&(this.cause=r)}toString(){return`${this.type}: ${this.message}${this.cause?` [cause: ${this.cause}]`:""}`}},ot=class extends ge{constructor(o,r,n,i){super(n,i);this.type=o;this.status=r}},v=class extends ge{constructor(o,r){super(o,r);this.type="client_error"}};var V=class extends ge{constructor(o,r){super(o,r);this.type="connector_error"}},$=e=>{if(e instanceof ge)return e;if(!Ws.isAxiosError(e))return ue(e);if(!e.response)return new ot("api_error",null,e.message,e);let{type:t,message:o,error:r}=e.response.data;return new ot(t||"ApiError",e.response.status,o||r,e)},ue=e=>e instanceof ge?e:e instanceof Error?new v(e.message,e):new v(`Internal error: ${e}`);var pn=()=>"/api/v1/sessions",fn=()=>"/api/v1/sessions/logout",mn=()=>"/api/v1/sessions/fork",hn=()=>"/api/v1/siwe/init",gn=()=>"/api/v1/siwe/authenticate",bn=()=>"/api/v1/siwe/link",wn=()=>"/api/v1/passwordless/init",yn=()=>"/api/v1/passwordless/authenticate",vn=()=>"/api/v1/passwordless/link",Cn=()=>"/api/v1/passwordless_sms/init",xn=()=>"/api/v1/passwordless_sms/authenticate",_n=()=>"/api/v1/passwordless_sms/link",En=()=>"/api/v1/oauth/init",Ln=()=>"/api/v1/oauth/authenticate",An=()=>"/api/v1/oauth/link",Sn=()=>"/api/v1/siwe/unlink",Pn=()=>"/api/v1/passwordless/unlink",kn=()=>"/api/v1/passwordless_sms/unlink",Tn=()=>"/api/v1/oauth/unlink";var Wt=class{constructor(t){this.meta={email:t}}async authenticate(){if(!this.api)throw new v("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new v("Email and email code must be set prior to calling authenticate.");try{let t=yn(),o=await this.api.post(t,{email:this.meta.email,code:this.meta.emailCode});return{user:o.data.user,token:o.data.token,refresh_token:o.data.refresh_token,is_new_user:o.data.is_new_user}}catch(t){throw $(t)}}async link(){if(!this.api)throw new v("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new v("Email and email code must be set prior to calling authenticate.");try{let t=vn();return(await this.api.post(t,{email:this.meta.email,code:this.meta.emailCode})).data}catch(t){throw $(t)}}async sendCodeEmail(t){if(!this.api)throw new v("Auth flow has no API instance");if(t&&(this.meta.email=t),!this.meta.email)throw new v("Email must be set when initialzing authentication.");try{let o=wn();return(await this.api.post(o,{email:this.meta.email})).data}catch(o){throw $(o)}}};var rt=class{constructor(t,o,r){this.meta={provider:t},this.meta.authorizationCode=o,this.meta.stateCode=r}isActive(){return!!(this.meta.authorizationCode&&this.meta.stateCode&&this.meta.provider)}async authenticate(){if(!this.api)throw new v("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new v("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling authenticate.");if(this.meta.authorizationCode==="undefined")throw new v("User denied confirmation during OAuth flow");try{let t=Ln(),o=await this.api.post(t,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode});return{user:o.data.user,token:o.data.token,refresh_token:o.data.refresh_token,is_new_user:o.data.is_new_user}}catch(t){throw $(t)}}async link(){if(!this.api)throw new v("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new v("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling link.");if(this.meta.authorizationCode==="undefined")throw new v("User denied confirmation during OAuth flow");try{let t=An();return(await this.api.post(t,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode})).data}catch(t){throw $(t)}}async getAuthorizationUrl(){if(!this.api)throw new v("Auth flow has no API instance");if(!this.meta.provider)throw new v("Provider must be set when initialzing OAuth authentication.");try{let t=En();return(await this.api.post(t,{provider:this.meta.provider,redirect_to:window.location.href})).data}catch(t){throw $(t)}}};var Mt=class{constructor(t,o,r){this._meta={walletType:o,walletId:r},this.connectors=t,this.walletConnector=this.connectors.createWalletConnector(o,null,r)}get meta(){return{...this._meta,walletName:this.walletConnector.walletBranding.name,walletIcon:this.walletConnector.walletBranding.icon}}async authenticate(){if(!this.api)throw new v("Auth flow has no API instance");try{let{message:t,signature:o}=await this.sign(),r=await this.api.post(gn(),{message:t,signature:o});return this.connectors.addWalletConnector(this.walletConnector),await this.connectors.setActiveWallet(this.walletConnector.address)||console.warn("Failed to set active wallet"),{user:r.data.user,token:r.data.token,refresh_token:r.data.refresh_token,is_new_user:r.data.is_new_user}}catch(t){throw $(t)}}async link(){if(!this.api)throw new v("Auth flow has no API instance");try{let{message:t,signature:o}=await this.sign(),r=await this.api.post(bn(),{message:t,signature:o});return this.connectors.addWalletConnector(this.walletConnector),await this.connectors.setActiveWallet(this.walletConnector.address)||console.warn("Failed to set active wallet"),r.data}catch(t){throw $(t)}}async promptConnect(){if(!this.api)throw new v("Auth flow has no API instance");let t=await this.walletConnector.connect({showPrompt:!0});return await this.buildSiweMessage(t),t}async sign(){if(!this.api)throw new v("Auth flow has no API instance");if(!this.preparedMessage){let o=await this.walletConnector.connect({showPrompt:!1});await this.buildSiweMessage(o)}if(!this.preparedMessage)throw new v("Could not prepare SIWE message");let t=await this.walletConnector.sign(this.preparedMessage);return{message:this.preparedMessage,signature:t}}async buildSiweMessage(t){if(!this.api)throw new v("Auth flow has no API instance");let o=t.address,r=t.chainId,n=await this.api.post(hn(),{address:o});return this.preparedMessage=this.walletConnector.prepareMessage(r,o,n.data.nonce),this.preparedMessage}};var It=class{constructor(t){this.meta={phoneNumber:t}}async authenticate(){if(!this.api)throw new v("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new v("phone number and sms code must be set prior to calling authenticate.");try{let t=xn(),o=await this.api.post(t,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode});return{user:o.data.user,token:o.data.token,refresh_token:o.data.refresh_token,is_new_user:o.data.is_new_user}}catch(t){throw $(t)}}async link(){if(!this.api)throw new v("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new v("phone number and sms code must be set prior to calling authenticate.");try{let t=_n();return(await this.api.post(t,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode})).data}catch(t){throw $(t)}}async sendSmsCode(t){if(!this.api)throw new v("Auth flow has no API instance");if(t&&(this.meta.phoneNumber=t),!this.meta.phoneNumber)throw new v("phone nNumber must be set when initialzing authentication.");try{let o=Cn();return(await this.api.post(o,{phoneNumber:this.meta.phoneNumber})).data}catch(o){throw $(o)}}};import{getAddress as Nl}from"@ethersproject/address";var Wn="1.18.0-beta.8";var Mn="https://api.privy.io/v0",Qo=process.env.NEXT_PUBLIC_PRIVY_AUTH_URL||"https://auth.privy.io",Qt="4df5e2316331463a9130964bd6078dfa",In=1e4,pe=1400,er=Wn;var nt="privy:token",eo="privy:refresh_token",to="privy:connectors",tr="walletconnect",Rn=3e4;var or=class{constructor(){this._cache={}}get(t){return this._cache[t]}put(t,o){o!==void 0?this._cache[t]=o:this.del(t)}del(t){delete this._cache[t]}getKeys(){return Object.keys(this._cache)}},rr=class{get(t){let o=localStorage.getItem(t);return o===null?void 0:JSON.parse(o)}put(t,o){o!==void 0?localStorage.setItem(t,JSON.stringify(o)):this.del(t)}del(t){localStorage.removeItem(t)}getKeys(){return Object.entries(localStorage).map(([t])=>t)}};function Is(){return typeof window<"u"&&window.localStorage?new rr:new or}var j=Is();import Hs from"@coinbase/wallet-sdk";import{getAddress as Vs}from"@ethersproject/address";import{jsx as On,jsxs as Rs}from"react/jsx-runtime";var ve=({style:e,...t})=>Rs("svg",{width:"1024",height:"1024",viewBox:"0 0 1024 1024",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"28px",width:"28px",...e},...t,children:[On("rect",{width:"1024",height:"1024",fill:"#0052FF",rx:100,ry:100}),On("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z",fill:"white"})]});import{getAddress as Bs}from"@ethersproject/address";import{Web3Provider as Gs}from"@ethersproject/providers";import{ErrorCode as Os}from"@ethersproject/logger";var it=class extends V{constructor(){super("Wallet timeout");this.type="wallet_error"}},$e=class extends V{constructor(){super("User rejected connection");this.type="wallet_error"}},Ce=e=>{if(e instanceof V)return e;if((e==null?void 0:e.code)&&(e==null?void 0:e.reason)){let t=new at(e);return e.code===Os.ACTION_REJECTED&&(t.details=Ve.E4001_USER_REJECTED_REQUEST),t}return e!=null&&e.code?new at(e):new V("Unknown connector error",e)},nr=class extends ge{constructor(o,r,n){super(o);this.type="provider_error";this.code=r,this.data=n}},at=class extends nr{constructor(o){var i,a,s;let r=o;super(r.message,r.code,r.data);let n=Object.values(Ve).find(l=>l.eipCode===r.code);this.details=n||Ve.UNKNOWN_ERROR,r.code===-32002&&((i=r.message)!=null&&i.includes("already pending for origin")?(a=r.message)!=null&&a.includes("wallet_requestPermissions")?this.details=Ve.E32002_CONNECTION_ALREADY_PENDING:this.details=Ve.E32002_REQUEST_ALREADY_PENDING:(s=r.message)!=null&&s.includes("Already processing")&&r.message.includes("eth_requestAccounts")&&(this.details=Ve.E32002_WALLET_LOCKED))}},Ns={ERROR_USER_EXISTS:{message:"User already exists for this address",detail:"Try another address!",retryable:!1},ERROR_TIMED_OUT:{message:"Wallet request timed out",detail:"Please try connecting again.",retryable:!0},ERROR_WALLET_CONNECTION:{message:"Could not log in with wallet",detail:"Please try connecting again.",retryable:!0},ERROR_USER_REJECTED_CONNECTION:{message:"You rejected the request",detail:"Please try connecting again.",retryable:!0}},Ds={E32002_CONNECTION_ALREADY_PENDING:{eipCode:-32002,message:"Connection request already pending",detail:"Don\u2019t see your wallet modal? Check your other browser windows.",retryable:!1},E32002_REQUEST_ALREADY_PENDING:{eipCode:-32002,message:"Resource request already pending",detail:"Don\u2019t see your wallet modal? Check your other browser windows.",retryable:!1},E32002_WALLET_LOCKED:{eipCode:-32002,message:"Wallet might be locked",detail:"Don\u2019t see your wallet modal? Check your other browser windows.",retryable:!1},E4001_USER_REJECTED_REQUEST:{eipCode:4001,message:"Signature rejected",detail:"Please try signing again.",retryable:!0}},Us={E4001_DEFAULT_USER_REJECTED_REQUEST:{eipCode:4001,message:"User Rejected Request",detail:"The user rejected the request.",default:!0,retryable:!0},E4100_DEFAULT_UNAUTHORIZED:{eipCode:4100,message:"Unauthorized",detail:"The requested method and/or account has not been authorized by the user.",default:!0,retryable:!1},E4200_DEFAULT_UNSUPPORTED_METHOD:{eipCode:4200,message:"Unsupported Method",detail:"The Provider does not support the requested method.",default:!0,retryable:!1},E4900_DEFAULT_DISCONNECTED:{eipCode:4900,message:"Disconnected",detail:"The Provider is disconnected from all chains.",default:!0,retryable:!0},E4901_DEFAULT_CHAIN_DISCONNECTED:{eipCode:4901,message:"Chain Disconnected",detail:"The Provider is not connected to the requested chain.",default:!0,retryable:!0},E32700_DEFAULT_PARSE_ERROR:{eipCode:-32700,message:"Parse error",detail:"Invalid JSON",default:!0,retryable:!1},E32600_DEFAULT_INVALID_REQUEST:{eipCode:-32600,message:"Invalid request",detail:"JSON is not a valid request object",default:!0,retryable:!1},E32601_DEFAULT_METHOD_NOT_FOUND:{eipCode:-32601,message:"Method not found",detail:"Method does not exist",default:!0,retryable:!1},E32602_DEFAULT_INVALID_PARAMS:{eipCode:-32602,message:"Invalid params",detail:"Invalid method parameters",default:!0,retryable:!1},E32603_DEFAULT_INTERNAL_ERROR:{eipCode:-32603,message:"Internal error",detail:"Internal JSON-RPC error",default:!0,retryable:!0},E32000_DEFAULT_INVALID_INPUT:{eipCode:-32e3,message:"Invalid input",detail:"Missing or invalid parameters",default:!0,retryable:!1},E32001_DEFAULT_RESOURCE_NOT_FOUND:{eipCode:-32001,message:"Resource not found",detail:"Requested resource not found",default:!0,retryable:!1},E32002_DEFAULT_RESOURCE_UNAVAILABLE:{eipCode:-32002,message:"Resource unavailable",detail:"Requested resource not available",default:!0,retryable:!0},E32003_DEFAULT_TRANSACTION_REJECTED:{eipCode:-32003,message:"Transaction rejected",detail:"Transaction creation failed",default:!0,retryable:!0},E32004_DEFAULT_METHOD_NOT_SUPPORTED:{eipCode:-32004,message:"Method not supported",detail:"Method is not implemented",default:!0,retryable:!1},E32005_DEFAULT_LIMIT_EXCEEDED:{eipCode:-32005,message:"Limit exceeded",detail:"Request exceeds defined limit",default:!0,retryable:!1},E32006_DEFAULT_JSON_RPC_VERSION_NOT_SUPPORTED:{eipCode:-32006,message:"JSON-RPC version not supported",detail:"Version of JSON-RPC protocol is not supported",default:!0,retryable:!1}},Ve={UNKNOWN_ERROR:{eipCode:0,message:"Unknown error",detail:"Unknown error",retryable:!0},...Us,...Ds},je={...Ns,...Ve};var Fs=12e4,ir=(e=new it,t=Fs)=>new Promise((o,r)=>setTimeout(()=>{r(e)},t)),xe=class{constructor(t){this.removeListener=(t,o)=>{if(this.walletProvider)return this.walletProvider.removeListener(t,o)};this.setWalletProvider=t=>{this.walletProvider=t,this._subscriptions.forEach(o=>{var r;(r=this.walletProvider)==null||r.on(o.eventName,o.listener)})};this.walletProvider=t,this._subscriptions=[]}on(t,o){if(this.walletProvider)return this.walletProvider.on(t,o);this._subscriptions.push({eventName:t,listener:o})}async request(t){if(!this.walletProvider)throw new V(`A wallet request of type ${t.method} was made before setting a wallet provider.`);return Promise.race([this.walletProvider.request(t),ir()]).catch(o=>{throw Ce(o)})}},ze=class extends xe{constructor(o){super(o)}},oo=class extends xe{constructor(t){super(t)}sendAsync(t,o){throw new Error("sendAsync is no longer supported by EIP-1193. Use the request method instead.")}};var Pe=class{constructor(t,o,r){this.createSiweMessage=(t,o,r,n,i,a,s)=>`${r} wants you to sign in with your Ethereum account:
2
2
  ${o}
3
3
 
4
4
  ${s}
@@ -426,7 +426,7 @@ Resources:
426
426
  }
427
427
  `,xc=Bt.span`
428
428
  word-break: break-all;
429
- `;import{useEffect as Rr,useState as Ao}from"react";import{isMobile as _c}from"react-device-detect";import Nr from"styled-components";import{Fragment as ha,jsx as le,jsxs as So}from"react/jsx-runtime";var Or=2,Po={metamask:{name:"MetaMask",component:be},coinbase_wallet:{name:"Coinbase Wallet",component:ve},wallet_connect:{name:"WalletConnect",component:lt}},Ec=e=>(e==null?void 0:e.status)===422?je.ERROR_USER_EXISTS:e instanceof at&&!e.details.default?e.details:e instanceof it?je.ERROR_TIMED_OUT:e instanceof $e?je.ERROR_USER_REJECTED_CONNECTION:je.ERROR_WALLET_CONNECTION,ma=()=>{var G,U,F;let[e,t]=Ao(!1),[o,r]=Ao(void 0),{navigate:n,navigateBack:i}=_(),{getAuthFlow:a,walletConnectionStatus:s,closePrivyModal:l,loginWithWallet:d}=T(),{walletConnectors:h}=q(),[g,u]=Ao(0),{user:p}=q(),[b]=Ao((p==null?void 0:p.linkedAccounts.length)||0),c=a(),w=_c&&(c==null?void 0:c.meta.walletType)==="wallet_connect",A=s==null?void 0:s.connected;Rr(()=>{!c||w||!A||W().catch(I=>console.warn("Auto-prompted signature failed",I))},[g,A]),Rr(()=>{if(e){let I=setTimeout(l,pe);return()=>clearTimeout(I)}},[p]);let P=I=>{if((I==null?void 0:I.status)===401&&(I==null?void 0:I.message)==="User is not allowed to login to this app."){n("ALLOWLIST_REJECTION_SCREEN");return}r(Ec(I))};async function W(){try{await d(),t(!0)}catch(I){P(I)}}Rr(()=>{s!=null&&s.connectError&&P(s==null?void 0:s.connectError)},[s]);let M=(c==null?void 0:c.meta.walletType)||"metamask",O=((G=c==null?void 0:c.meta)==null?void 0:G.walletName)||Po[M].name,Q=((U=c==null?void 0:c.meta)==null?void 0:U.walletIcon)||Po[M].component,J=e?`Successfully connected with ${O}`:o?o.message:A?"Sign to verify":`Waiting for ${O}`,D="Don\u2019t see your wallet modal? Check your other browser windows.";if(e){let I=(p==null?void 0:p.linkedAccounts.length)||0;b===I?D="Wallet was already linked.":D="You\u2019re good to go!"}else g>=Or&&o?D="Unable to connect wallet":o?D=o.detail:A&&w?D="Sign the message in your wallet to verify it belongs to you.":M==="metamask"?D="For the best experience, connect only one wallet at a time.":M==="wallet_connect"?D="Open your mobile wallet app to continue":M==="coinbase_wallet"&&(bo()||(Cr(p)?D="Continue with the Coinbase app. Not the right wallet? Reset your connection below.":D="Open the Coinbase app on your phone to continue."));let de=(F=h==null?void 0:h.walletConnectors)==null?void 0:F.find(I=>I.walletType==="coinbase_wallet"),ye=M==="coinbase_wallet"&&(Cr(p)||o===je.ERROR_USER_EXISTS);return So(ha,{children:[le(S,{backFn:i}),So(Lc,{children:[le(Dr,{walletLogo:Q,success:e,fail:!!o}),So(Ac,{children:[le("h3",{children:J}),le("p",{children:D})]}),ye?le(ie,{onClick:()=>de&&(de==null?void 0:de.disconnect()),invisible:e,disabled:e,children:"Use a different wallet"}):o==je.ERROR_USER_EXISTS?le(ie,{onClick:i,children:"Use a different wallet"}):A&&!e&&w?le(ie,{onClick:W,children:"Sign with your wallet"}):le(ie,{onClick:()=>{u(g+1),r(void 0),s==null||s.connectRetry()},invisible:e||!(o!=null&&o.retryable)||g>=Or,disabled:!e&&(!(o!=null&&o.retryable)||g>=Or),children:"Retry"})]})]})},Lc=Nr.div`
429
+ `;import{useEffect as Rr,useState as Ao}from"react";import{isMobile as _c}from"react-device-detect";import Nr from"styled-components";import{Fragment as ha,jsx as le,jsxs as So}from"react/jsx-runtime";var Or=2,Po={metamask:{name:"MetaMask",component:be},coinbase_wallet:{name:"Coinbase Wallet",component:ve},wallet_connect:{name:"WalletConnect",component:lt}},Ec=e=>(e==null?void 0:e.status)===422?je.ERROR_USER_EXISTS:e instanceof at&&!e.details.default?e.details:e instanceof it?je.ERROR_TIMED_OUT:e instanceof $e?je.ERROR_USER_REJECTED_CONNECTION:je.ERROR_WALLET_CONNECTION,ma=()=>{var G,U,F;let[e,t]=Ao(!1),[o,r]=Ao(void 0),{navigate:n,navigateBack:i}=_(),{getAuthFlow:a,walletConnectionStatus:s,closePrivyModal:l,loginWithWallet:d}=T(),{walletConnectors:h}=q(),[g,u]=Ao(0),{user:p}=q(),[b]=Ao((p==null?void 0:p.linkedAccounts.length)||0),c=a(),w=_c&&(c==null?void 0:c.meta.walletType)==="wallet_connect",A=s==null?void 0:s.connected;Rr(()=>{!c||w||!A||W().catch(I=>console.warn("Auto-prompted signature failed",I))},[g,A]),Rr(()=>{if(p&&e){let I=setTimeout(l,pe);return()=>clearTimeout(I)}},[p,e]);let P=I=>{if((I==null?void 0:I.status)===401&&(I==null?void 0:I.message)==="User is not allowed to login to this app."){n("ALLOWLIST_REJECTION_SCREEN");return}r(Ec(I))};async function W(){try{await d(),t(!0)}catch(I){P(I)}}Rr(()=>{s!=null&&s.connectError&&P(s==null?void 0:s.connectError)},[s]);let M=(c==null?void 0:c.meta.walletType)||"metamask",O=((G=c==null?void 0:c.meta)==null?void 0:G.walletName)||Po[M].name,Q=((U=c==null?void 0:c.meta)==null?void 0:U.walletIcon)||Po[M].component,J=e?`Successfully connected with ${O}`:o?o.message:A?"Sign to verify":`Waiting for ${O}`,D="Don\u2019t see your wallet modal? Check your other browser windows.";if(e){let I=(p==null?void 0:p.linkedAccounts.length)||0;b===I?D="Wallet was already linked.":D="You\u2019re good to go!"}else g>=Or&&o?D="Unable to connect wallet":o?D=o.detail:A&&w?D="Sign the message in your wallet to verify it belongs to you.":M==="metamask"?D="For the best experience, connect only one wallet at a time.":M==="wallet_connect"?D="Open your mobile wallet app to continue":M==="coinbase_wallet"&&(bo()||(Cr(p)?D="Continue with the Coinbase app. Not the right wallet? Reset your connection below.":D="Open the Coinbase app on your phone to continue."));let de=(F=h==null?void 0:h.walletConnectors)==null?void 0:F.find(I=>I.walletType==="coinbase_wallet"),ye=M==="coinbase_wallet"&&(Cr(p)||o===je.ERROR_USER_EXISTS);return So(ha,{children:[le(S,{backFn:i}),So(Lc,{children:[le(Dr,{walletLogo:Q,success:e,fail:!!o}),So(Ac,{children:[le("h3",{children:J}),le("p",{children:D})]}),ye?le(ie,{onClick:()=>de&&(de==null?void 0:de.disconnect()),invisible:e,disabled:e,children:"Use a different wallet"}):o==je.ERROR_USER_EXISTS?le(ie,{onClick:i,children:"Use a different wallet"}):A&&!e&&w?le(ie,{onClick:W,children:"Sign with your wallet"}):le(ie,{onClick:()=>{u(g+1),r(void 0),s==null||s.connectRetry()},invisible:e||!(o!=null&&o.retryable)||g>=Or,disabled:!e&&(!(o!=null&&o.retryable)||g>=Or),children:"Retry"})]})]})},Lc=Nr.div`
430
430
  display: flex;
431
431
  flex-direction: column;
432
432
  align-items: center;
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var Ms=Object.create;var go=Object.defineProperty;var Is=Object.getOwnPropertyDescriptor;var Rs=Object.getOwnPropertyNames;var Os=Object.getPrototypeOf,Ns=Object.prototype.hasOwnProperty;var Cn=(e,t)=>()=>(e&&(t=e(e=0)),t);var je=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),br=(e,t)=>{for(var o in t)go(e,o,{get:t[o],enumerable:!0})},xn=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Rs(t))!Ns.call(e,n)&&n!==o&&go(e,n,{get:()=>t[n],enumerable:!(r=Is(t,n))||r.enumerable});return e};var A=(e,t,o)=>(o=e!=null?Ms(Os(e)):{},xn(t||!e||!e.__esModule?go(o,"default",{value:e,enumerable:!0}):o,e)),wr=e=>xn(go({},"__esModule",{value:!0}),e);var ko=je((f1,Po)=>{var li,ci,di,ui,pi,fi,mi,hi,gi,Ao,Pr,bi,wi,yi,kt,vi,Ci,xi,_i,Ei,Li,Ai,Si,Pi,So;(function(e){var t=typeof global=="object"?global:typeof self=="object"?self:typeof this=="object"?this:{};typeof define=="function"&&define.amd?define("tslib",["exports"],function(r){e(o(t,o(r)))}):typeof Po=="object"&&typeof Po.exports=="object"?e(o(t,o(Po.exports))):e(o(t));function o(r,n){return r!==t&&(typeof Object.create=="function"?Object.defineProperty(r,"__esModule",{value:!0}):r.__esModule=!0),function(i,a){return r[i]=n?n(i,a):a}}})(function(e){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(r[i]=n[i])};li=function(r,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");t(r,n);function i(){this.constructor=r}r.prototype=n===null?Object.create(n):(i.prototype=n.prototype,new i)},ci=Object.assign||function(r){for(var n,i=1,a=arguments.length;i<a;i++){n=arguments[i];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(r[s]=n[s])}return r},di=function(r,n){var i={};for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&n.indexOf(a)<0&&(i[a]=r[a]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,a=Object.getOwnPropertySymbols(r);s<a.length;s++)n.indexOf(a[s])<0&&Object.prototype.propertyIsEnumerable.call(r,a[s])&&(i[a[s]]=r[a[s]]);return i},ui=function(r,n,i,a){var s=arguments.length,l=s<3?n:a===null?a=Object.getOwnPropertyDescriptor(n,i):a,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")l=Reflect.decorate(r,n,i,a);else for(var b=r.length-1;b>=0;b--)(d=r[b])&&(l=(s<3?d(l):s>3?d(n,i,l):d(n,i))||l);return s>3&&l&&Object.defineProperty(n,i,l),l},pi=function(r,n){return function(i,a){n(i,a,r)}},fi=function(r,n){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,n)},mi=function(r,n,i,a){function s(l){return l instanceof i?l:new i(function(d){d(l)})}return new(i||(i=Promise))(function(l,d){function b(p){try{u(a.next(p))}catch(y){d(y)}}function w(p){try{u(a.throw(p))}catch(y){d(y)}}function u(p){p.done?l(p.value):s(p.value).then(b,w)}u((a=a.apply(r,n||[])).next())})},hi=function(r,n){var i={label:0,sent:function(){if(l[0]&1)throw l[1];return l[1]},trys:[],ops:[]},a,s,l,d;return d={next:b(0),throw:b(1),return:b(2)},typeof Symbol=="function"&&(d[Symbol.iterator]=function(){return this}),d;function b(u){return function(p){return w([u,p])}}function w(u){if(a)throw new TypeError("Generator is already executing.");for(;i;)try{if(a=1,s&&(l=u[0]&2?s.return:u[0]?s.throw||((l=s.return)&&l.call(s),0):s.next)&&!(l=l.call(s,u[1])).done)return l;switch(s=0,l&&(u=[u[0]&2,l.value]),u[0]){case 0:case 1:l=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,s=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(l=i.trys,!(l=l.length>0&&l[l.length-1])&&(u[0]===6||u[0]===2)){i=0;continue}if(u[0]===3&&(!l||u[1]>l[0]&&u[1]<l[3])){i.label=u[1];break}if(u[0]===6&&i.label<l[1]){i.label=l[1],l=u;break}if(l&&i.label<l[2]){i.label=l[2],i.ops.push(u);break}l[2]&&i.ops.pop(),i.trys.pop();continue}u=n.call(r,i)}catch(p){u=[6,p],s=0}finally{a=l=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}},gi=function(r,n){for(var i in r)i!=="default"&&!Object.prototype.hasOwnProperty.call(n,i)&&So(n,r,i)},So=Object.create?function(r,n,i,a){a===void 0&&(a=i);var s=Object.getOwnPropertyDescriptor(n,i);(!s||("get"in s?!n.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return n[i]}}),Object.defineProperty(r,a,s)}:function(r,n,i,a){a===void 0&&(a=i),r[a]=n[i]},Ao=function(r){var n=typeof Symbol=="function"&&Symbol.iterator,i=n&&r[n],a=0;if(i)return i.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&a>=r.length&&(r=void 0),{value:r&&r[a++],done:!r}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")},Pr=function(r,n){var i=typeof Symbol=="function"&&r[Symbol.iterator];if(!i)return r;var a=i.call(r),s,l=[],d;try{for(;(n===void 0||n-- >0)&&!(s=a.next()).done;)l.push(s.value)}catch(b){d={error:b}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(d)throw d.error}}return l},bi=function(){for(var r=[],n=0;n<arguments.length;n++)r=r.concat(Pr(arguments[n]));return r},wi=function(){for(var r=0,n=0,i=arguments.length;n<i;n++)r+=arguments[n].length;for(var a=Array(r),s=0,n=0;n<i;n++)for(var l=arguments[n],d=0,b=l.length;d<b;d++,s++)a[s]=l[d];return a},yi=function(r,n,i){if(i||arguments.length===2)for(var a=0,s=n.length,l;a<s;a++)(l||!(a in n))&&(l||(l=Array.prototype.slice.call(n,0,a)),l[a]=n[a]);return r.concat(l||Array.prototype.slice.call(n))},kt=function(r){return this instanceof kt?(this.v=r,this):new kt(r)},vi=function(r,n,i){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var a=i.apply(r,n||[]),s,l=[];return s={},d("next"),d("throw"),d("return"),s[Symbol.asyncIterator]=function(){return this},s;function d(c){a[c]&&(s[c]=function(v){return new Promise(function(S,T){l.push([c,v,S,T])>1||b(c,v)})})}function b(c,v){try{w(a[c](v))}catch(S){y(l[0][3],S)}}function w(c){c.value instanceof kt?Promise.resolve(c.value.v).then(u,p):y(l[0][2],c)}function u(c){b("next",c)}function p(c){b("throw",c)}function y(c,v){c(v),l.shift(),l.length&&b(l[0][0],l[0][1])}},Ci=function(r){var n,i;return n={},a("next"),a("throw",function(s){throw s}),a("return"),n[Symbol.iterator]=function(){return this},n;function a(s,l){n[s]=r[s]?function(d){return(i=!i)?{value:kt(r[s](d)),done:s==="return"}:l?l(d):d}:l}},xi=function(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r[Symbol.asyncIterator],i;return n?n.call(r):(r=typeof Ao=="function"?Ao(r):r[Symbol.iterator](),i={},a("next"),a("throw"),a("return"),i[Symbol.asyncIterator]=function(){return this},i);function a(l){i[l]=r[l]&&function(d){return new Promise(function(b,w){d=r[l](d),s(b,w,d.done,d.value)})}}function s(l,d,b,w){Promise.resolve(w).then(function(u){l({value:u,done:b})},d)}},_i=function(r,n){return Object.defineProperty?Object.defineProperty(r,"raw",{value:n}):r.raw=n,r};var o=Object.create?function(r,n){Object.defineProperty(r,"default",{enumerable:!0,value:n})}:function(r,n){r.default=n};Ei=function(r){if(r&&r.__esModule)return r;var n={};if(r!=null)for(var i in r)i!=="default"&&Object.prototype.hasOwnProperty.call(r,i)&&So(n,r,i);return o(n,r),n},Li=function(r){return r&&r.__esModule?r:{default:r}},Ai=function(r,n,i,a){if(i==="a"&&!a)throw new TypeError("Private accessor was defined without a getter");if(typeof n=="function"?r!==n||!a:!n.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return i==="m"?a:i==="a"?a.call(r):a?a.value:n.get(r)},Si=function(r,n,i,a,s){if(a==="m")throw new TypeError("Private method is not writable");if(a==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof n=="function"?r!==n||!s:!n.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return a==="a"?s.call(r,i):s?s.value=i:n.set(r,i),i},Pi=function(r,n){if(n===null||typeof n!="object"&&typeof n!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof r=="function"?n===r:r.has(n)},e("__extends",li),e("__assign",ci),e("__rest",di),e("__decorate",ui),e("__param",pi),e("__metadata",fi),e("__awaiter",mi),e("__generator",hi),e("__exportStar",gi),e("__createBinding",So),e("__values",Ao),e("__read",Pr),e("__spread",bi),e("__spreadArrays",wi),e("__spreadArray",yi),e("__await",kt),e("__asyncGenerator",vi),e("__asyncDelegator",Ci),e("__asyncValues",xi),e("__makeTemplateObject",_i),e("__importStar",Ei),e("__importDefault",Li),e("__classPrivateFieldGet",Ai),e("__classPrivateFieldSet",Si),e("__classPrivateFieldIn",Pi)})});var kr=je(D=>{"use strict";Object.defineProperty(D,"__esModule",{value:!0});D.getLocalStorage=D.getLocalStorageOrThrow=D.getCrypto=D.getCryptoOrThrow=D.getLocation=D.getLocationOrThrow=D.getNavigator=D.getNavigatorOrThrow=D.getDocument=D.getDocumentOrThrow=D.getFromWindowOrThrow=D.getFromWindow=void 0;function mt(e){let t;return typeof window<"u"&&typeof window[e]<"u"&&(t=window[e]),t}D.getFromWindow=mt;function Tt(e){let t=mt(e);if(!t)throw new Error(`${e} is not defined in Window`);return t}D.getFromWindowOrThrow=Tt;function js(){return Tt("document")}D.getDocumentOrThrow=js;function zs(){return mt("document")}D.getDocument=zs;function qs(){return Tt("navigator")}D.getNavigatorOrThrow=qs;function Zs(){return mt("navigator")}D.getNavigator=Zs;function Ks(){return Tt("location")}D.getLocationOrThrow=Ks;function Js(){return mt("location")}D.getLocation=Js;function Ys(){return Tt("crypto")}D.getCryptoOrThrow=Ys;function Xs(){return mt("crypto")}D.getCrypto=Xs;function Qs(){return Tt("localStorage")}D.getLocalStorageOrThrow=Qs;function el(){return mt("localStorage")}D.getLocalStorage=el});var Ti=je(To=>{"use strict";Object.defineProperty(To,"__esModule",{value:!0});To.getWindowMetadata=void 0;var ki=kr();function tl(){let e,t;try{e=ki.getDocumentOrThrow(),t=ki.getLocationOrThrow()}catch{return null}function o(){let w=e.getElementsByTagName("link"),u=[];for(let p=0;p<w.length;p++){let y=w[p],c=y.getAttribute("rel");if(c&&c.toLowerCase().indexOf("icon")>-1){let v=y.getAttribute("href");if(v)if(v.toLowerCase().indexOf("https:")===-1&&v.toLowerCase().indexOf("http:")===-1&&v.indexOf("//")!==0){let S=t.protocol+"//"+t.host;if(v.indexOf("/")===0)S+=v;else{let T=t.pathname.split("/");T.pop(),S+=T.join("/")+"/"+v}u.push(S)}else if(v.indexOf("//")===0){let S=t.protocol+v;u.push(S)}else u.push(v)}}return u}function r(...w){let u=e.getElementsByTagName("meta");for(let p=0;p<u.length;p++){let y=u[p],c=["itemprop","property","name"].map(v=>y.getAttribute(v)).filter(v=>v?w.includes(v):!1);if(c.length&&c){let v=y.getAttribute("content");if(v)return v}}return""}function n(){let w=r("name","og:site_name","og:title","twitter:title");return w||(w=e.title),w}function i(){return r("description","og:description","twitter:description","keywords")}let a=n(),s=i(),l=t.origin,d=o();return{description:s,url:l,icons:d,name:a}}To.getWindowMetadata=tl});var Gi={};br(Gi,{BotInfo:()=>Ni,BrowserInfo:()=>Ii,NodeInfo:()=>Ri,ReactNativeInfo:()=>Di,SearchBotDeviceInfo:()=>Oi,browserName:()=>sl,detect:()=>al,detectOS:()=>Fi,getNodeVersion:()=>Bi,parseUserAgent:()=>Tr});function al(e){return e?Tr(e):typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new Di:typeof navigator<"u"?Tr(navigator.userAgent):Bi()}function Ui(e){return e!==""&&il.reduce(function(t,o){var r=o[0],n=o[1];if(t)return t;var i=n.exec(e);return!!i&&[r,i]},!1)}function sl(e){var t=Ui(e);return t?t[0]:null}function Tr(e){var t=Ui(e);if(!t)return null;var o=t[0],r=t[1];if(o==="searchbot")return new Ni;var n=r[1]&&r[1].split(/[._]/).slice(0,3);n?n.length<Wi&&(n=ol(n,ll(Wi-n.length))):n=[];var i=n.join("."),a=Fi(e),s=nl.exec(e);return s&&s[1]?new Oi(o,i,a,s[1]):new Ii(o,i,a)}function Fi(e){for(var t=0,o=Mi.length;t<o;t++){var r=Mi[t],n=r[0],i=r[1],a=i.exec(e);if(a)return n}return null}function Bi(){var e=typeof process<"u"&&process.version;return e?new Ri(process.version.slice(1)):null}function ll(e){for(var t=[],o=0;o<e;o++)t.push("0");return t}var ol,Ii,Ri,Oi,Ni,Di,rl,nl,Wi,il,Mi,Hi=Cn(()=>{ol=function(){for(var e=0,t=0,o=arguments.length;t<o;t++)e+=arguments[t].length;for(var r=Array(e),n=0,t=0;t<o;t++)for(var i=arguments[t],a=0,s=i.length;a<s;a++,n++)r[n]=i[a];return r},Ii=function(){function e(t,o,r){this.name=t,this.version=o,this.os=r,this.type="browser"}return e}(),Ri=function(){function e(t){this.version=t,this.type="node",this.name="node",this.os=process.platform}return e}(),Oi=function(){function e(t,o,r,n){this.name=t,this.version=o,this.os=r,this.bot=n,this.type="bot-device"}return e}(),Ni=function(){function e(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return e}(),Di=function(){function e(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return e}(),rl=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,nl=/(nuhk|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,Wi=3,il=[["aol",/AOLShield\/([0-9\._]+)/],["edge",/Edge\/([0-9\._]+)/],["edge-ios",/EdgiOS\/([0-9\._]+)/],["yandexbrowser",/YaBrowser\/([0-9\._]+)/],["kakaotalk",/KAKAOTALK\s([0-9\.]+)/],["samsung",/SamsungBrowser\/([0-9\.]+)/],["silk",/\bSilk\/([0-9._-]+)\b/],["miui",/MiuiBrowser\/([0-9\.]+)$/],["beaker",/BeakerBrowser\/([0-9\.]+)/],["edge-chromium",/EdgA?\/([0-9\.]+)/],["chromium-webview",/(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["chrome",/(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["phantomjs",/PhantomJS\/([0-9\.]+)(:?\s|$)/],["crios",/CriOS\/([0-9\.]+)(:?\s|$)/],["firefox",/Firefox\/([0-9\.]+)(?:\s|$)/],["fxios",/FxiOS\/([0-9\.]+)/],["opera-mini",/Opera Mini.*Version\/([0-9\.]+)/],["opera",/Opera\/([0-9\.]+)(?:\s|$)/],["opera",/OPR\/([0-9\.]+)(:?\s|$)/],["ie",/Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/],["ie",/MSIE\s([0-9\.]+);.*Trident\/[4-7].0/],["ie",/MSIE\s(7\.0)/],["bb10",/BB10;\sTouch.*Version\/([0-9\.]+)/],["android",/Android\s([0-9\.]+)/],["ios",/Version\/([0-9\._]+).*Mobile.*Safari.*/],["safari",/Version\/([0-9\._]+).*Safari/],["facebook",/FBAV\/([0-9\.]+)/],["instagram",/Instagram\s([0-9\.]+)/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Mobile/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Gecko\)$/],["searchbot",rl]],Mi=[["iOS",/iP(hone|od|ad)/],["Android OS",/Android/],["BlackBerry OS",/BlackBerry|BB10/],["Windows Mobile",/IEMobile/],["Amazon OS",/Kindle/],["Windows 3.11",/Win16/],["Windows 95",/(Windows 95)|(Win95)|(Windows_95)/],["Windows 98",/(Windows 98)|(Win98)/],["Windows 2000",/(Windows NT 5.0)|(Windows 2000)/],["Windows XP",/(Windows NT 5.1)|(Windows XP)/],["Windows Server 2003",/(Windows NT 5.2)/],["Windows Vista",/(Windows NT 6.0)/],["Windows 7",/(Windows NT 6.1)/],["Windows 8",/(Windows NT 6.2)/],["Windows 8.1",/(Windows NT 6.3)/],["Windows 10",/(Windows NT 10.0)/],["Windows ME",/Windows ME/],["Open BSD",/OpenBSD/],["Sun OS",/SunOS/],["Chrome OS",/CrOS/],["Linux",/(Linux)|(X11)/],["Mac OS",/(Mac_PowerPC)|(Macintosh)/],["QNX",/QNX/],["BeOS",/BeOS/],["OS/2",/OS\/2/]]});var Mr=je(_=>{"use strict";Object.defineProperty(_,"__esModule",{value:!0});_.getClientMeta=_.getLocalStorage=_.getLocalStorageOrThrow=_.getCrypto=_.getCryptoOrThrow=_.getLocation=_.getLocationOrThrow=_.getNavigator=_.getNavigatorOrThrow=_.getDocument=_.getDocumentOrThrow=_.getFromWindowOrThrow=_.getFromWindow=_.isBrowser=_.isNode=_.isMobile=_.isIOS=_.isAndroid=_.detectOS=_.detectEnv=void 0;var Vi=ko(),cl=Vi.__importStar(Ti()),xe=Vi.__importStar(kr()),dl=(Hi(),wr(Gi));function Wr(e){return(0,dl.detect)(e)}_.detectEnv=Wr;function Wo(){let e=Wr();return e&&e.os?e.os:void 0}_.detectOS=Wo;function $i(){let e=Wo();return e?e.toLowerCase().includes("android"):!1}_.isAndroid=$i;function ji(){let e=Wo();return e?e.toLowerCase().includes("ios")||e.toLowerCase().includes("mac")&&navigator.maxTouchPoints>1:!1}_.isIOS=ji;function ul(){return Wo()?$i()||ji():!1}_.isMobile=ul;function zi(){let e=Wr();return e&&e.name?e.name.toLowerCase()==="node":!1}_.isNode=zi;function pl(){return!zi()&&!!(0,_.getNavigator)()}_.isBrowser=pl;_.getFromWindow=xe.getFromWindow;_.getFromWindowOrThrow=xe.getFromWindowOrThrow;_.getDocumentOrThrow=xe.getDocumentOrThrow;_.getDocument=xe.getDocument;_.getNavigatorOrThrow=xe.getNavigatorOrThrow;_.getNavigator=xe.getNavigator;_.getLocationOrThrow=xe.getLocationOrThrow;_.getLocation=xe.getLocation;_.getCryptoOrThrow=xe.getCryptoOrThrow;_.getCrypto=xe.getCrypto;_.getLocalStorageOrThrow=xe.getLocalStorageOrThrow;_.getLocalStorage=xe.getLocalStorage;function fl(){return cl.getWindowMetadata()}_.getClientMeta=fl});var qi={};br(qi,{safeJsonParse:()=>ml,safeJsonStringify:()=>hl});function ml(e){if(typeof e!="string")throw new Error(`Cannot safe json parse value of type ${typeof e}`);try{return JSON.parse(e)}catch{return e}}function hl(e){return typeof e=="string"?e:JSON.stringify(e)}var Zi=Cn(()=>{});var Ir=je(Wt=>{"use strict";Object.defineProperty(Wt,"__esModule",{value:!0});Wt.safeJsonStringify=Wt.safeJsonParse=void 0;var gl=ko(),Ki=gl.__importStar((Zi(),wr(qi)));Wt.safeJsonParse=Ki.safeJsonParse;Wt.safeJsonStringify=Ki.safeJsonStringify});var Or=je(Qe=>{"use strict";Object.defineProperty(Qe,"__esModule",{value:!0});Qe.removeLocal=Qe.getLocal=Qe.setLocal=void 0;var Ji=Ir(),Rr=Mr();function bl(e,t){let o=(0,Ji.safeJsonStringify)(t),r=(0,Rr.getLocalStorage)();r&&r.setItem(e,o)}Qe.setLocal=bl;function wl(e){let t=null,o=null,r=(0,Rr.getLocalStorage)();return r&&(o=r.getItem(e)),t=o&&(0,Ji.safeJsonParse)(o),t}Qe.getLocal=wl;function yl(e){let t=(0,Rr.getLocalStorage)();t&&t.removeItem(e)}Qe.removeLocal=yl});var Xi=je(de=>{"use strict";Object.defineProperty(de,"__esModule",{value:!0});de.getMobileLinkRegistry=de.getMobileRegistryEntry=de.saveMobileLinkInfo=de.formatIOSMobile=de.mobileLinkChoiceKey=void 0;var vl=Or();de.mobileLinkChoiceKey="WALLETCONNECT_DEEPLINK_CHOICE";function Cl(e,t){let o=encodeURIComponent(e);return t.universalLink?`${t.universalLink}/wc?uri=${o}`:t.deepLink?`${t.deepLink}${t.deepLink.endsWith(":")?"//":"/"}wc?uri=${o}`:""}de.formatIOSMobile=Cl;function xl(e){let t=e.href.split("?")[0];(0,vl.setLocal)(de.mobileLinkChoiceKey,Object.assign(Object.assign({},e),{href:t}))}de.saveMobileLinkInfo=xl;function Yi(e,t){return e.filter(o=>o.name.toLowerCase().includes(t.toLowerCase()))[0]}de.getMobileRegistryEntry=Yi;function _l(e,t){let o=e;return t&&(o=t.map(r=>Yi(e,r)).filter(Boolean)),o}de.getMobileLinkRegistry=_l});var ta=je(He=>{"use strict";Object.defineProperty(He,"__esModule",{value:!0});He.formatMobileRegistry=He.formatMobileRegistryEntry=He.getDappRegistryUrl=He.getWalletRegistryUrl=void 0;var Qi="https://registry.walletconnect.com";function El(){return Qi+"/api/v2/wallets"}He.getWalletRegistryUrl=El;function Ll(){return Qi+"/api/v2/dapps"}He.getDappRegistryUrl=Ll;function ea(e,t="mobile"){var o;return{name:e.name||"",shortName:e.metadata.shortName||"",color:e.metadata.colors.primary||"",logo:(o=e.image_url.sm)!==null&&o!==void 0?o:"",universalLink:e[t].universal||"",deepLink:e[t].native||""}}He.formatMobileRegistryEntry=ea;function Al(e,t="mobile"){return Object.values(e).filter(o=>!!o[t].universal||!!o[t].native).map(o=>ea(o,t))}He.formatMobileRegistry=Al});var oa=je(ht=>{"use strict";Object.defineProperty(ht,"__esModule",{value:!0});var eo=ko();eo.__exportStar(Mr(),ht);eo.__exportStar(Ir(),ht);eo.__exportStar(Or(),ht);eo.__exportStar(Xi(),ht);eo.__exportStar(ta(),ht)});var xd={};br(xd,{AsExternalProvider:()=>Xe,ConnectorManager:()=>Mt,PrivyClient:()=>It,PrivyProvider:()=>Ws,PrivyProxyProvider:()=>ke,VERSION:()=>wo,WalletConnector:()=>Ge,getAccessToken:()=>Ts,usePrivy:()=>Q});module.exports=wr(xd);var ks=require("@ethersproject/providers"),X=require("react");var x=()=>{throw new Error("You need to wrap your application with the <PrivyProvider> initialized with your app id.")};var _n=A(require("axios")),Pe=class extends Error{constructor(o,r){super(o);r instanceof Error&&(this.cause=r)}toString(){return`${this.type}: ${this.message}${this.cause?` [cause: ${this.cause}]`:""}`}},_t=class extends Pe{constructor(o,r,n,i){super(n,i);this.type=o;this.status=r}},C=class extends Pe{constructor(o,r){super(o,r);this.type="client_error"}};var K=class extends Pe{constructor(o,r){super(o,r);this.type="connector_error"}},J=e=>{if(e instanceof Pe)return e;if(!_n.default.isAxiosError(e))return ve(e);if(!e.response)return new _t("api_error",null,e.message,e);let{type:t,message:o,error:r}=e.response.data;return new _t(t||"ApiError",e.response.status,o||r,e)},ve=e=>e instanceof Pe?e:e instanceof Error?new C(e.message,e):new C(`Internal error: ${e}`);var En=()=>"/api/v1/sessions",Ln=()=>"/api/v1/sessions/logout",An=()=>"/api/v1/sessions/fork",Sn=()=>"/api/v1/siwe/init",Pn=()=>"/api/v1/siwe/authenticate",kn=()=>"/api/v1/siwe/link",Tn=()=>"/api/v1/passwordless/init",Wn=()=>"/api/v1/passwordless/authenticate",Mn=()=>"/api/v1/passwordless/link",In=()=>"/api/v1/passwordless_sms/init",Rn=()=>"/api/v1/passwordless_sms/authenticate",On=()=>"/api/v1/passwordless_sms/link",Nn=()=>"/api/v1/oauth/init",Dn=()=>"/api/v1/oauth/authenticate",Un=()=>"/api/v1/oauth/link",Fn=()=>"/api/v1/siwe/unlink",Bn=()=>"/api/v1/passwordless/unlink",Gn=()=>"/api/v1/passwordless_sms/unlink",Hn=()=>"/api/v1/oauth/unlink";var Jt=class{constructor(t){this.meta={email:t}}async authenticate(){if(!this.api)throw new C("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new C("Email and email code must be set prior to calling authenticate.");try{let t=Wn(),o=await this.api.post(t,{email:this.meta.email,code:this.meta.emailCode});return{user:o.data.user,token:o.data.token,refresh_token:o.data.refresh_token,is_new_user:o.data.is_new_user}}catch(t){throw J(t)}}async link(){if(!this.api)throw new C("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new C("Email and email code must be set prior to calling authenticate.");try{let t=Mn();return(await this.api.post(t,{email:this.meta.email,code:this.meta.emailCode})).data}catch(t){throw J(t)}}async sendCodeEmail(t){if(!this.api)throw new C("Auth flow has no API instance");if(t&&(this.meta.email=t),!this.meta.email)throw new C("Email must be set when initialzing authentication.");try{let o=Tn();return(await this.api.post(o,{email:this.meta.email})).data}catch(o){throw J(o)}}};var Et=class{constructor(t,o,r){this.meta={provider:t},this.meta.authorizationCode=o,this.meta.stateCode=r}isActive(){return!!(this.meta.authorizationCode&&this.meta.stateCode&&this.meta.provider)}async authenticate(){if(!this.api)throw new C("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new C("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling authenticate.");if(this.meta.authorizationCode==="undefined")throw new C("User denied confirmation during OAuth flow");try{let t=Dn(),o=await this.api.post(t,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode});return{user:o.data.user,token:o.data.token,refresh_token:o.data.refresh_token,is_new_user:o.data.is_new_user}}catch(t){throw J(t)}}async link(){if(!this.api)throw new C("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new C("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling link.");if(this.meta.authorizationCode==="undefined")throw new C("User denied confirmation during OAuth flow");try{let t=Un();return(await this.api.post(t,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode})).data}catch(t){throw J(t)}}async getAuthorizationUrl(){if(!this.api)throw new C("Auth flow has no API instance");if(!this.meta.provider)throw new C("Provider must be set when initialzing OAuth authentication.");try{let t=Nn();return(await this.api.post(t,{provider:this.meta.provider,redirect_to:window.location.href})).data}catch(t){throw J(t)}}};var Yt=class{constructor(t,o,r){this._meta={walletType:o,walletId:r},this.connectors=t,this.walletConnector=this.connectors.createWalletConnector(o,null,r)}get meta(){return{...this._meta,walletName:this.walletConnector.walletBranding.name,walletIcon:this.walletConnector.walletBranding.icon}}async authenticate(){if(!this.api)throw new C("Auth flow has no API instance");try{let{message:t,signature:o}=await this.sign(),r=await this.api.post(Pn(),{message:t,signature:o});return this.connectors.addWalletConnector(this.walletConnector),await this.connectors.setActiveWallet(this.walletConnector.address)||console.warn("Failed to set active wallet"),{user:r.data.user,token:r.data.token,refresh_token:r.data.refresh_token,is_new_user:r.data.is_new_user}}catch(t){throw J(t)}}async link(){if(!this.api)throw new C("Auth flow has no API instance");try{let{message:t,signature:o}=await this.sign(),r=await this.api.post(kn(),{message:t,signature:o});return this.connectors.addWalletConnector(this.walletConnector),await this.connectors.setActiveWallet(this.walletConnector.address)||console.warn("Failed to set active wallet"),r.data}catch(t){throw J(t)}}async promptConnect(){if(!this.api)throw new C("Auth flow has no API instance");let t=await this.walletConnector.connect({showPrompt:!0});return await this.buildSiweMessage(t),t}async sign(){if(!this.api)throw new C("Auth flow has no API instance");if(!this.preparedMessage){let o=await this.walletConnector.connect({showPrompt:!1});await this.buildSiweMessage(o)}if(!this.preparedMessage)throw new C("Could not prepare SIWE message");let t=await this.walletConnector.sign(this.preparedMessage);return{message:this.preparedMessage,signature:t}}async buildSiweMessage(t){if(!this.api)throw new C("Auth flow has no API instance");let o=t.address,r=t.chainId,n=await this.api.post(Sn(),{address:o});return this.preparedMessage=this.walletConnector.prepareMessage(r,o,n.data.nonce),this.preparedMessage}};var Xt=class{constructor(t){this.meta={phoneNumber:t}}async authenticate(){if(!this.api)throw new C("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new C("phone number and sms code must be set prior to calling authenticate.");try{let t=Rn(),o=await this.api.post(t,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode});return{user:o.data.user,token:o.data.token,refresh_token:o.data.refresh_token,is_new_user:o.data.is_new_user}}catch(t){throw J(t)}}async link(){if(!this.api)throw new C("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new C("phone number and sms code must be set prior to calling authenticate.");try{let t=On();return(await this.api.post(t,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode})).data}catch(t){throw J(t)}}async sendSmsCode(t){if(!this.api)throw new C("Auth flow has no API instance");if(t&&(this.meta.phoneNumber=t),!this.meta.phoneNumber)throw new C("phone nNumber must be set when initialzing authentication.");try{let o=In();return(await this.api.post(o,{phoneNumber:this.meta.phoneNumber})).data}catch(o){throw J(o)}}};var aa=require("@ethersproject/address");var Vn="1.18.0-beta.7";var $n="https://api.privy.io/v0",yr=process.env.NEXT_PUBLIC_PRIVY_AUTH_URL||"https://auth.privy.io",bo="4df5e2316331463a9130964bd6078dfa",jn=1e4,Ce=1400,wo=Vn;var Lt="privy:token",yo="privy:refresh_token",vo="privy:connectors",vr="walletconnect",zn=3e4;var Cr=class{constructor(){this._cache={}}get(t){return this._cache[t]}put(t,o){o!==void 0?this._cache[t]=o:this.del(t)}del(t){delete this._cache[t]}getKeys(){return Object.keys(this._cache)}},xr=class{get(t){let o=localStorage.getItem(t);return o===null?void 0:JSON.parse(o)}put(t,o){o!==void 0?localStorage.setItem(t,JSON.stringify(o)):this.del(t)}del(t){localStorage.removeItem(t)}getKeys(){return Object.entries(localStorage).map(([t])=>t)}};function Us(){return typeof window<"u"&&window.localStorage?new xr:new Cr}var Y=Us();var Jn=A(require("@coinbase/wallet-sdk")),Yn=require("@ethersproject/address");var Qt=require("react/jsx-runtime"),Fe=({style:e,...t})=>(0,Qt.jsxs)("svg",{width:"1024",height:"1024",viewBox:"0 0 1024 1024",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"28px",width:"28px",...e},...t,children:[(0,Qt.jsx)("rect",{width:"1024",height:"1024",fill:"#0052FF",rx:100,ry:100}),(0,Qt.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z",fill:"white"})]});var Zn=require("@ethersproject/address"),Kn=require("@ethersproject/providers");var qn=require("@ethersproject/logger");var At=class extends K{constructor(){super("Wallet timeout");this.type="wallet_error"}},ut=class extends K{constructor(){super("User rejected connection");this.type="wallet_error"}},Be=e=>{if(e instanceof K)return e;if((e==null?void 0:e.code)&&(e==null?void 0:e.reason)){let t=new St(e);return e.code===qn.ErrorCode.ACTION_REJECTED&&(t.details=dt.E4001_USER_REJECTED_REQUEST),t}return e!=null&&e.code?new St(e):new K("Unknown connector error",e)},_r=class extends Pe{constructor(o,r,n){super(o);this.type="provider_error";this.code=r,this.data=n}},St=class extends _r{constructor(o){var i,a,s;let r=o;super(r.message,r.code,r.data);let n=Object.values(dt).find(l=>l.eipCode===r.code);this.details=n||dt.UNKNOWN_ERROR,r.code===-32002&&((i=r.message)!=null&&i.includes("already pending for origin")?(a=r.message)!=null&&a.includes("wallet_requestPermissions")?this.details=dt.E32002_CONNECTION_ALREADY_PENDING:this.details=dt.E32002_REQUEST_ALREADY_PENDING:(s=r.message)!=null&&s.includes("Already processing")&&r.message.includes("eth_requestAccounts")&&(this.details=dt.E32002_WALLET_LOCKED))}},Fs={ERROR_USER_EXISTS:{message:"User already exists for this address",detail:"Try another address!",retryable:!1},ERROR_TIMED_OUT:{message:"Wallet request timed out",detail:"Please try connecting again.",retryable:!0},ERROR_WALLET_CONNECTION:{message:"Could not log in with wallet",detail:"Please try connecting again.",retryable:!0},ERROR_USER_REJECTED_CONNECTION:{message:"You rejected the request",detail:"Please try connecting again.",retryable:!0}},Bs={E32002_CONNECTION_ALREADY_PENDING:{eipCode:-32002,message:"Connection request already pending",detail:"Don\u2019t see your wallet modal? Check your other browser windows.",retryable:!1},E32002_REQUEST_ALREADY_PENDING:{eipCode:-32002,message:"Resource request already pending",detail:"Don\u2019t see your wallet modal? Check your other browser windows.",retryable:!1},E32002_WALLET_LOCKED:{eipCode:-32002,message:"Wallet might be locked",detail:"Don\u2019t see your wallet modal? Check your other browser windows.",retryable:!1},E4001_USER_REJECTED_REQUEST:{eipCode:4001,message:"Signature rejected",detail:"Please try signing again.",retryable:!0}},Gs={E4001_DEFAULT_USER_REJECTED_REQUEST:{eipCode:4001,message:"User Rejected Request",detail:"The user rejected the request.",default:!0,retryable:!0},E4100_DEFAULT_UNAUTHORIZED:{eipCode:4100,message:"Unauthorized",detail:"The requested method and/or account has not been authorized by the user.",default:!0,retryable:!1},E4200_DEFAULT_UNSUPPORTED_METHOD:{eipCode:4200,message:"Unsupported Method",detail:"The Provider does not support the requested method.",default:!0,retryable:!1},E4900_DEFAULT_DISCONNECTED:{eipCode:4900,message:"Disconnected",detail:"The Provider is disconnected from all chains.",default:!0,retryable:!0},E4901_DEFAULT_CHAIN_DISCONNECTED:{eipCode:4901,message:"Chain Disconnected",detail:"The Provider is not connected to the requested chain.",default:!0,retryable:!0},E32700_DEFAULT_PARSE_ERROR:{eipCode:-32700,message:"Parse error",detail:"Invalid JSON",default:!0,retryable:!1},E32600_DEFAULT_INVALID_REQUEST:{eipCode:-32600,message:"Invalid request",detail:"JSON is not a valid request object",default:!0,retryable:!1},E32601_DEFAULT_METHOD_NOT_FOUND:{eipCode:-32601,message:"Method not found",detail:"Method does not exist",default:!0,retryable:!1},E32602_DEFAULT_INVALID_PARAMS:{eipCode:-32602,message:"Invalid params",detail:"Invalid method parameters",default:!0,retryable:!1},E32603_DEFAULT_INTERNAL_ERROR:{eipCode:-32603,message:"Internal error",detail:"Internal JSON-RPC error",default:!0,retryable:!0},E32000_DEFAULT_INVALID_INPUT:{eipCode:-32e3,message:"Invalid input",detail:"Missing or invalid parameters",default:!0,retryable:!1},E32001_DEFAULT_RESOURCE_NOT_FOUND:{eipCode:-32001,message:"Resource not found",detail:"Requested resource not found",default:!0,retryable:!1},E32002_DEFAULT_RESOURCE_UNAVAILABLE:{eipCode:-32002,message:"Resource unavailable",detail:"Requested resource not available",default:!0,retryable:!0},E32003_DEFAULT_TRANSACTION_REJECTED:{eipCode:-32003,message:"Transaction rejected",detail:"Transaction creation failed",default:!0,retryable:!0},E32004_DEFAULT_METHOD_NOT_SUPPORTED:{eipCode:-32004,message:"Method not supported",detail:"Method is not implemented",default:!0,retryable:!1},E32005_DEFAULT_LIMIT_EXCEEDED:{eipCode:-32005,message:"Limit exceeded",detail:"Request exceeds defined limit",default:!0,retryable:!1},E32006_DEFAULT_JSON_RPC_VERSION_NOT_SUPPORTED:{eipCode:-32006,message:"JSON-RPC version not supported",detail:"Version of JSON-RPC protocol is not supported",default:!0,retryable:!1}},dt={UNKNOWN_ERROR:{eipCode:0,message:"Unknown error",detail:"Unknown error",retryable:!0},...Gs,...Bs},pt={...Fs,...dt};var Hs=12e4,Er=(e=new At,t=Hs)=>new Promise((o,r)=>setTimeout(()=>{r(e)},t)),ke=class{constructor(t){this.removeListener=(t,o)=>{if(this.walletProvider)return this.walletProvider.removeListener(t,o)};this.setWalletProvider=t=>{this.walletProvider=t,this._subscriptions.forEach(o=>{var r;(r=this.walletProvider)==null||r.on(o.eventName,o.listener)})};this.walletProvider=t,this._subscriptions=[]}on(t,o){if(this.walletProvider)return this.walletProvider.on(t,o);this._subscriptions.push({eventName:t,listener:o})}async request(t){if(!this.walletProvider)throw new K(`A wallet request of type ${t.method} was made before setting a wallet provider.`);return Promise.race([this.walletProvider.request(t),Er()]).catch(o=>{throw Be(o)})}},Xe=class extends ke{constructor(o){super(o)}},Co=class extends ke{constructor(t){super(t)}sendAsync(t,o){throw new Error("sendAsync is no longer supported by EIP-1193. Use the request method instead.")}};var Ge=class{constructor(t,o,r){this.createSiweMessage=(t,o,r,n,i,a,s)=>`${r} wants you to sign in with your Ethereum account:
1
+ "use strict";var Ms=Object.create;var go=Object.defineProperty;var Is=Object.getOwnPropertyDescriptor;var Rs=Object.getOwnPropertyNames;var Os=Object.getPrototypeOf,Ns=Object.prototype.hasOwnProperty;var Cn=(e,t)=>()=>(e&&(t=e(e=0)),t);var je=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),br=(e,t)=>{for(var o in t)go(e,o,{get:t[o],enumerable:!0})},xn=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Rs(t))!Ns.call(e,n)&&n!==o&&go(e,n,{get:()=>t[n],enumerable:!(r=Is(t,n))||r.enumerable});return e};var A=(e,t,o)=>(o=e!=null?Ms(Os(e)):{},xn(t||!e||!e.__esModule?go(o,"default",{value:e,enumerable:!0}):o,e)),wr=e=>xn(go({},"__esModule",{value:!0}),e);var ko=je((f1,Po)=>{var li,ci,di,ui,pi,fi,mi,hi,gi,Ao,Pr,bi,wi,yi,kt,vi,Ci,xi,_i,Ei,Li,Ai,Si,Pi,So;(function(e){var t=typeof global=="object"?global:typeof self=="object"?self:typeof this=="object"?this:{};typeof define=="function"&&define.amd?define("tslib",["exports"],function(r){e(o(t,o(r)))}):typeof Po=="object"&&typeof Po.exports=="object"?e(o(t,o(Po.exports))):e(o(t));function o(r,n){return r!==t&&(typeof Object.create=="function"?Object.defineProperty(r,"__esModule",{value:!0}):r.__esModule=!0),function(i,a){return r[i]=n?n(i,a):a}}})(function(e){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(r[i]=n[i])};li=function(r,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");t(r,n);function i(){this.constructor=r}r.prototype=n===null?Object.create(n):(i.prototype=n.prototype,new i)},ci=Object.assign||function(r){for(var n,i=1,a=arguments.length;i<a;i++){n=arguments[i];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(r[s]=n[s])}return r},di=function(r,n){var i={};for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&n.indexOf(a)<0&&(i[a]=r[a]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,a=Object.getOwnPropertySymbols(r);s<a.length;s++)n.indexOf(a[s])<0&&Object.prototype.propertyIsEnumerable.call(r,a[s])&&(i[a[s]]=r[a[s]]);return i},ui=function(r,n,i,a){var s=arguments.length,l=s<3?n:a===null?a=Object.getOwnPropertyDescriptor(n,i):a,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")l=Reflect.decorate(r,n,i,a);else for(var b=r.length-1;b>=0;b--)(d=r[b])&&(l=(s<3?d(l):s>3?d(n,i,l):d(n,i))||l);return s>3&&l&&Object.defineProperty(n,i,l),l},pi=function(r,n){return function(i,a){n(i,a,r)}},fi=function(r,n){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,n)},mi=function(r,n,i,a){function s(l){return l instanceof i?l:new i(function(d){d(l)})}return new(i||(i=Promise))(function(l,d){function b(p){try{u(a.next(p))}catch(y){d(y)}}function w(p){try{u(a.throw(p))}catch(y){d(y)}}function u(p){p.done?l(p.value):s(p.value).then(b,w)}u((a=a.apply(r,n||[])).next())})},hi=function(r,n){var i={label:0,sent:function(){if(l[0]&1)throw l[1];return l[1]},trys:[],ops:[]},a,s,l,d;return d={next:b(0),throw:b(1),return:b(2)},typeof Symbol=="function"&&(d[Symbol.iterator]=function(){return this}),d;function b(u){return function(p){return w([u,p])}}function w(u){if(a)throw new TypeError("Generator is already executing.");for(;i;)try{if(a=1,s&&(l=u[0]&2?s.return:u[0]?s.throw||((l=s.return)&&l.call(s),0):s.next)&&!(l=l.call(s,u[1])).done)return l;switch(s=0,l&&(u=[u[0]&2,l.value]),u[0]){case 0:case 1:l=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,s=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(l=i.trys,!(l=l.length>0&&l[l.length-1])&&(u[0]===6||u[0]===2)){i=0;continue}if(u[0]===3&&(!l||u[1]>l[0]&&u[1]<l[3])){i.label=u[1];break}if(u[0]===6&&i.label<l[1]){i.label=l[1],l=u;break}if(l&&i.label<l[2]){i.label=l[2],i.ops.push(u);break}l[2]&&i.ops.pop(),i.trys.pop();continue}u=n.call(r,i)}catch(p){u=[6,p],s=0}finally{a=l=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}},gi=function(r,n){for(var i in r)i!=="default"&&!Object.prototype.hasOwnProperty.call(n,i)&&So(n,r,i)},So=Object.create?function(r,n,i,a){a===void 0&&(a=i);var s=Object.getOwnPropertyDescriptor(n,i);(!s||("get"in s?!n.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return n[i]}}),Object.defineProperty(r,a,s)}:function(r,n,i,a){a===void 0&&(a=i),r[a]=n[i]},Ao=function(r){var n=typeof Symbol=="function"&&Symbol.iterator,i=n&&r[n],a=0;if(i)return i.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&a>=r.length&&(r=void 0),{value:r&&r[a++],done:!r}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")},Pr=function(r,n){var i=typeof Symbol=="function"&&r[Symbol.iterator];if(!i)return r;var a=i.call(r),s,l=[],d;try{for(;(n===void 0||n-- >0)&&!(s=a.next()).done;)l.push(s.value)}catch(b){d={error:b}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(d)throw d.error}}return l},bi=function(){for(var r=[],n=0;n<arguments.length;n++)r=r.concat(Pr(arguments[n]));return r},wi=function(){for(var r=0,n=0,i=arguments.length;n<i;n++)r+=arguments[n].length;for(var a=Array(r),s=0,n=0;n<i;n++)for(var l=arguments[n],d=0,b=l.length;d<b;d++,s++)a[s]=l[d];return a},yi=function(r,n,i){if(i||arguments.length===2)for(var a=0,s=n.length,l;a<s;a++)(l||!(a in n))&&(l||(l=Array.prototype.slice.call(n,0,a)),l[a]=n[a]);return r.concat(l||Array.prototype.slice.call(n))},kt=function(r){return this instanceof kt?(this.v=r,this):new kt(r)},vi=function(r,n,i){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var a=i.apply(r,n||[]),s,l=[];return s={},d("next"),d("throw"),d("return"),s[Symbol.asyncIterator]=function(){return this},s;function d(c){a[c]&&(s[c]=function(v){return new Promise(function(S,T){l.push([c,v,S,T])>1||b(c,v)})})}function b(c,v){try{w(a[c](v))}catch(S){y(l[0][3],S)}}function w(c){c.value instanceof kt?Promise.resolve(c.value.v).then(u,p):y(l[0][2],c)}function u(c){b("next",c)}function p(c){b("throw",c)}function y(c,v){c(v),l.shift(),l.length&&b(l[0][0],l[0][1])}},Ci=function(r){var n,i;return n={},a("next"),a("throw",function(s){throw s}),a("return"),n[Symbol.iterator]=function(){return this},n;function a(s,l){n[s]=r[s]?function(d){return(i=!i)?{value:kt(r[s](d)),done:s==="return"}:l?l(d):d}:l}},xi=function(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r[Symbol.asyncIterator],i;return n?n.call(r):(r=typeof Ao=="function"?Ao(r):r[Symbol.iterator](),i={},a("next"),a("throw"),a("return"),i[Symbol.asyncIterator]=function(){return this},i);function a(l){i[l]=r[l]&&function(d){return new Promise(function(b,w){d=r[l](d),s(b,w,d.done,d.value)})}}function s(l,d,b,w){Promise.resolve(w).then(function(u){l({value:u,done:b})},d)}},_i=function(r,n){return Object.defineProperty?Object.defineProperty(r,"raw",{value:n}):r.raw=n,r};var o=Object.create?function(r,n){Object.defineProperty(r,"default",{enumerable:!0,value:n})}:function(r,n){r.default=n};Ei=function(r){if(r&&r.__esModule)return r;var n={};if(r!=null)for(var i in r)i!=="default"&&Object.prototype.hasOwnProperty.call(r,i)&&So(n,r,i);return o(n,r),n},Li=function(r){return r&&r.__esModule?r:{default:r}},Ai=function(r,n,i,a){if(i==="a"&&!a)throw new TypeError("Private accessor was defined without a getter");if(typeof n=="function"?r!==n||!a:!n.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return i==="m"?a:i==="a"?a.call(r):a?a.value:n.get(r)},Si=function(r,n,i,a,s){if(a==="m")throw new TypeError("Private method is not writable");if(a==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof n=="function"?r!==n||!s:!n.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return a==="a"?s.call(r,i):s?s.value=i:n.set(r,i),i},Pi=function(r,n){if(n===null||typeof n!="object"&&typeof n!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof r=="function"?n===r:r.has(n)},e("__extends",li),e("__assign",ci),e("__rest",di),e("__decorate",ui),e("__param",pi),e("__metadata",fi),e("__awaiter",mi),e("__generator",hi),e("__exportStar",gi),e("__createBinding",So),e("__values",Ao),e("__read",Pr),e("__spread",bi),e("__spreadArrays",wi),e("__spreadArray",yi),e("__await",kt),e("__asyncGenerator",vi),e("__asyncDelegator",Ci),e("__asyncValues",xi),e("__makeTemplateObject",_i),e("__importStar",Ei),e("__importDefault",Li),e("__classPrivateFieldGet",Ai),e("__classPrivateFieldSet",Si),e("__classPrivateFieldIn",Pi)})});var kr=je(D=>{"use strict";Object.defineProperty(D,"__esModule",{value:!0});D.getLocalStorage=D.getLocalStorageOrThrow=D.getCrypto=D.getCryptoOrThrow=D.getLocation=D.getLocationOrThrow=D.getNavigator=D.getNavigatorOrThrow=D.getDocument=D.getDocumentOrThrow=D.getFromWindowOrThrow=D.getFromWindow=void 0;function mt(e){let t;return typeof window<"u"&&typeof window[e]<"u"&&(t=window[e]),t}D.getFromWindow=mt;function Tt(e){let t=mt(e);if(!t)throw new Error(`${e} is not defined in Window`);return t}D.getFromWindowOrThrow=Tt;function js(){return Tt("document")}D.getDocumentOrThrow=js;function zs(){return mt("document")}D.getDocument=zs;function qs(){return Tt("navigator")}D.getNavigatorOrThrow=qs;function Zs(){return mt("navigator")}D.getNavigator=Zs;function Ks(){return Tt("location")}D.getLocationOrThrow=Ks;function Js(){return mt("location")}D.getLocation=Js;function Ys(){return Tt("crypto")}D.getCryptoOrThrow=Ys;function Xs(){return mt("crypto")}D.getCrypto=Xs;function Qs(){return Tt("localStorage")}D.getLocalStorageOrThrow=Qs;function el(){return mt("localStorage")}D.getLocalStorage=el});var Ti=je(To=>{"use strict";Object.defineProperty(To,"__esModule",{value:!0});To.getWindowMetadata=void 0;var ki=kr();function tl(){let e,t;try{e=ki.getDocumentOrThrow(),t=ki.getLocationOrThrow()}catch{return null}function o(){let w=e.getElementsByTagName("link"),u=[];for(let p=0;p<w.length;p++){let y=w[p],c=y.getAttribute("rel");if(c&&c.toLowerCase().indexOf("icon")>-1){let v=y.getAttribute("href");if(v)if(v.toLowerCase().indexOf("https:")===-1&&v.toLowerCase().indexOf("http:")===-1&&v.indexOf("//")!==0){let S=t.protocol+"//"+t.host;if(v.indexOf("/")===0)S+=v;else{let T=t.pathname.split("/");T.pop(),S+=T.join("/")+"/"+v}u.push(S)}else if(v.indexOf("//")===0){let S=t.protocol+v;u.push(S)}else u.push(v)}}return u}function r(...w){let u=e.getElementsByTagName("meta");for(let p=0;p<u.length;p++){let y=u[p],c=["itemprop","property","name"].map(v=>y.getAttribute(v)).filter(v=>v?w.includes(v):!1);if(c.length&&c){let v=y.getAttribute("content");if(v)return v}}return""}function n(){let w=r("name","og:site_name","og:title","twitter:title");return w||(w=e.title),w}function i(){return r("description","og:description","twitter:description","keywords")}let a=n(),s=i(),l=t.origin,d=o();return{description:s,url:l,icons:d,name:a}}To.getWindowMetadata=tl});var Gi={};br(Gi,{BotInfo:()=>Ni,BrowserInfo:()=>Ii,NodeInfo:()=>Ri,ReactNativeInfo:()=>Di,SearchBotDeviceInfo:()=>Oi,browserName:()=>sl,detect:()=>al,detectOS:()=>Fi,getNodeVersion:()=>Bi,parseUserAgent:()=>Tr});function al(e){return e?Tr(e):typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new Di:typeof navigator<"u"?Tr(navigator.userAgent):Bi()}function Ui(e){return e!==""&&il.reduce(function(t,o){var r=o[0],n=o[1];if(t)return t;var i=n.exec(e);return!!i&&[r,i]},!1)}function sl(e){var t=Ui(e);return t?t[0]:null}function Tr(e){var t=Ui(e);if(!t)return null;var o=t[0],r=t[1];if(o==="searchbot")return new Ni;var n=r[1]&&r[1].split(/[._]/).slice(0,3);n?n.length<Wi&&(n=ol(n,ll(Wi-n.length))):n=[];var i=n.join("."),a=Fi(e),s=nl.exec(e);return s&&s[1]?new Oi(o,i,a,s[1]):new Ii(o,i,a)}function Fi(e){for(var t=0,o=Mi.length;t<o;t++){var r=Mi[t],n=r[0],i=r[1],a=i.exec(e);if(a)return n}return null}function Bi(){var e=typeof process<"u"&&process.version;return e?new Ri(process.version.slice(1)):null}function ll(e){for(var t=[],o=0;o<e;o++)t.push("0");return t}var ol,Ii,Ri,Oi,Ni,Di,rl,nl,Wi,il,Mi,Hi=Cn(()=>{ol=function(){for(var e=0,t=0,o=arguments.length;t<o;t++)e+=arguments[t].length;for(var r=Array(e),n=0,t=0;t<o;t++)for(var i=arguments[t],a=0,s=i.length;a<s;a++,n++)r[n]=i[a];return r},Ii=function(){function e(t,o,r){this.name=t,this.version=o,this.os=r,this.type="browser"}return e}(),Ri=function(){function e(t){this.version=t,this.type="node",this.name="node",this.os=process.platform}return e}(),Oi=function(){function e(t,o,r,n){this.name=t,this.version=o,this.os=r,this.bot=n,this.type="bot-device"}return e}(),Ni=function(){function e(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return e}(),Di=function(){function e(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return e}(),rl=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,nl=/(nuhk|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,Wi=3,il=[["aol",/AOLShield\/([0-9\._]+)/],["edge",/Edge\/([0-9\._]+)/],["edge-ios",/EdgiOS\/([0-9\._]+)/],["yandexbrowser",/YaBrowser\/([0-9\._]+)/],["kakaotalk",/KAKAOTALK\s([0-9\.]+)/],["samsung",/SamsungBrowser\/([0-9\.]+)/],["silk",/\bSilk\/([0-9._-]+)\b/],["miui",/MiuiBrowser\/([0-9\.]+)$/],["beaker",/BeakerBrowser\/([0-9\.]+)/],["edge-chromium",/EdgA?\/([0-9\.]+)/],["chromium-webview",/(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["chrome",/(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["phantomjs",/PhantomJS\/([0-9\.]+)(:?\s|$)/],["crios",/CriOS\/([0-9\.]+)(:?\s|$)/],["firefox",/Firefox\/([0-9\.]+)(?:\s|$)/],["fxios",/FxiOS\/([0-9\.]+)/],["opera-mini",/Opera Mini.*Version\/([0-9\.]+)/],["opera",/Opera\/([0-9\.]+)(?:\s|$)/],["opera",/OPR\/([0-9\.]+)(:?\s|$)/],["ie",/Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/],["ie",/MSIE\s([0-9\.]+);.*Trident\/[4-7].0/],["ie",/MSIE\s(7\.0)/],["bb10",/BB10;\sTouch.*Version\/([0-9\.]+)/],["android",/Android\s([0-9\.]+)/],["ios",/Version\/([0-9\._]+).*Mobile.*Safari.*/],["safari",/Version\/([0-9\._]+).*Safari/],["facebook",/FBAV\/([0-9\.]+)/],["instagram",/Instagram\s([0-9\.]+)/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Mobile/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Gecko\)$/],["searchbot",rl]],Mi=[["iOS",/iP(hone|od|ad)/],["Android OS",/Android/],["BlackBerry OS",/BlackBerry|BB10/],["Windows Mobile",/IEMobile/],["Amazon OS",/Kindle/],["Windows 3.11",/Win16/],["Windows 95",/(Windows 95)|(Win95)|(Windows_95)/],["Windows 98",/(Windows 98)|(Win98)/],["Windows 2000",/(Windows NT 5.0)|(Windows 2000)/],["Windows XP",/(Windows NT 5.1)|(Windows XP)/],["Windows Server 2003",/(Windows NT 5.2)/],["Windows Vista",/(Windows NT 6.0)/],["Windows 7",/(Windows NT 6.1)/],["Windows 8",/(Windows NT 6.2)/],["Windows 8.1",/(Windows NT 6.3)/],["Windows 10",/(Windows NT 10.0)/],["Windows ME",/Windows ME/],["Open BSD",/OpenBSD/],["Sun OS",/SunOS/],["Chrome OS",/CrOS/],["Linux",/(Linux)|(X11)/],["Mac OS",/(Mac_PowerPC)|(Macintosh)/],["QNX",/QNX/],["BeOS",/BeOS/],["OS/2",/OS\/2/]]});var Mr=je(_=>{"use strict";Object.defineProperty(_,"__esModule",{value:!0});_.getClientMeta=_.getLocalStorage=_.getLocalStorageOrThrow=_.getCrypto=_.getCryptoOrThrow=_.getLocation=_.getLocationOrThrow=_.getNavigator=_.getNavigatorOrThrow=_.getDocument=_.getDocumentOrThrow=_.getFromWindowOrThrow=_.getFromWindow=_.isBrowser=_.isNode=_.isMobile=_.isIOS=_.isAndroid=_.detectOS=_.detectEnv=void 0;var Vi=ko(),cl=Vi.__importStar(Ti()),xe=Vi.__importStar(kr()),dl=(Hi(),wr(Gi));function Wr(e){return(0,dl.detect)(e)}_.detectEnv=Wr;function Wo(){let e=Wr();return e&&e.os?e.os:void 0}_.detectOS=Wo;function $i(){let e=Wo();return e?e.toLowerCase().includes("android"):!1}_.isAndroid=$i;function ji(){let e=Wo();return e?e.toLowerCase().includes("ios")||e.toLowerCase().includes("mac")&&navigator.maxTouchPoints>1:!1}_.isIOS=ji;function ul(){return Wo()?$i()||ji():!1}_.isMobile=ul;function zi(){let e=Wr();return e&&e.name?e.name.toLowerCase()==="node":!1}_.isNode=zi;function pl(){return!zi()&&!!(0,_.getNavigator)()}_.isBrowser=pl;_.getFromWindow=xe.getFromWindow;_.getFromWindowOrThrow=xe.getFromWindowOrThrow;_.getDocumentOrThrow=xe.getDocumentOrThrow;_.getDocument=xe.getDocument;_.getNavigatorOrThrow=xe.getNavigatorOrThrow;_.getNavigator=xe.getNavigator;_.getLocationOrThrow=xe.getLocationOrThrow;_.getLocation=xe.getLocation;_.getCryptoOrThrow=xe.getCryptoOrThrow;_.getCrypto=xe.getCrypto;_.getLocalStorageOrThrow=xe.getLocalStorageOrThrow;_.getLocalStorage=xe.getLocalStorage;function fl(){return cl.getWindowMetadata()}_.getClientMeta=fl});var qi={};br(qi,{safeJsonParse:()=>ml,safeJsonStringify:()=>hl});function ml(e){if(typeof e!="string")throw new Error(`Cannot safe json parse value of type ${typeof e}`);try{return JSON.parse(e)}catch{return e}}function hl(e){return typeof e=="string"?e:JSON.stringify(e)}var Zi=Cn(()=>{});var Ir=je(Wt=>{"use strict";Object.defineProperty(Wt,"__esModule",{value:!0});Wt.safeJsonStringify=Wt.safeJsonParse=void 0;var gl=ko(),Ki=gl.__importStar((Zi(),wr(qi)));Wt.safeJsonParse=Ki.safeJsonParse;Wt.safeJsonStringify=Ki.safeJsonStringify});var Or=je(Qe=>{"use strict";Object.defineProperty(Qe,"__esModule",{value:!0});Qe.removeLocal=Qe.getLocal=Qe.setLocal=void 0;var Ji=Ir(),Rr=Mr();function bl(e,t){let o=(0,Ji.safeJsonStringify)(t),r=(0,Rr.getLocalStorage)();r&&r.setItem(e,o)}Qe.setLocal=bl;function wl(e){let t=null,o=null,r=(0,Rr.getLocalStorage)();return r&&(o=r.getItem(e)),t=o&&(0,Ji.safeJsonParse)(o),t}Qe.getLocal=wl;function yl(e){let t=(0,Rr.getLocalStorage)();t&&t.removeItem(e)}Qe.removeLocal=yl});var Xi=je(de=>{"use strict";Object.defineProperty(de,"__esModule",{value:!0});de.getMobileLinkRegistry=de.getMobileRegistryEntry=de.saveMobileLinkInfo=de.formatIOSMobile=de.mobileLinkChoiceKey=void 0;var vl=Or();de.mobileLinkChoiceKey="WALLETCONNECT_DEEPLINK_CHOICE";function Cl(e,t){let o=encodeURIComponent(e);return t.universalLink?`${t.universalLink}/wc?uri=${o}`:t.deepLink?`${t.deepLink}${t.deepLink.endsWith(":")?"//":"/"}wc?uri=${o}`:""}de.formatIOSMobile=Cl;function xl(e){let t=e.href.split("?")[0];(0,vl.setLocal)(de.mobileLinkChoiceKey,Object.assign(Object.assign({},e),{href:t}))}de.saveMobileLinkInfo=xl;function Yi(e,t){return e.filter(o=>o.name.toLowerCase().includes(t.toLowerCase()))[0]}de.getMobileRegistryEntry=Yi;function _l(e,t){let o=e;return t&&(o=t.map(r=>Yi(e,r)).filter(Boolean)),o}de.getMobileLinkRegistry=_l});var ta=je(He=>{"use strict";Object.defineProperty(He,"__esModule",{value:!0});He.formatMobileRegistry=He.formatMobileRegistryEntry=He.getDappRegistryUrl=He.getWalletRegistryUrl=void 0;var Qi="https://registry.walletconnect.com";function El(){return Qi+"/api/v2/wallets"}He.getWalletRegistryUrl=El;function Ll(){return Qi+"/api/v2/dapps"}He.getDappRegistryUrl=Ll;function ea(e,t="mobile"){var o;return{name:e.name||"",shortName:e.metadata.shortName||"",color:e.metadata.colors.primary||"",logo:(o=e.image_url.sm)!==null&&o!==void 0?o:"",universalLink:e[t].universal||"",deepLink:e[t].native||""}}He.formatMobileRegistryEntry=ea;function Al(e,t="mobile"){return Object.values(e).filter(o=>!!o[t].universal||!!o[t].native).map(o=>ea(o,t))}He.formatMobileRegistry=Al});var oa=je(ht=>{"use strict";Object.defineProperty(ht,"__esModule",{value:!0});var eo=ko();eo.__exportStar(Mr(),ht);eo.__exportStar(Ir(),ht);eo.__exportStar(Or(),ht);eo.__exportStar(Xi(),ht);eo.__exportStar(ta(),ht)});var xd={};br(xd,{AsExternalProvider:()=>Xe,ConnectorManager:()=>Mt,PrivyClient:()=>It,PrivyProvider:()=>Ws,PrivyProxyProvider:()=>ke,VERSION:()=>wo,WalletConnector:()=>Ge,getAccessToken:()=>Ts,usePrivy:()=>Q});module.exports=wr(xd);var ks=require("@ethersproject/providers"),X=require("react");var x=()=>{throw new Error("You need to wrap your application with the <PrivyProvider> initialized with your app id.")};var _n=A(require("axios")),Pe=class extends Error{constructor(o,r){super(o);r instanceof Error&&(this.cause=r)}toString(){return`${this.type}: ${this.message}${this.cause?` [cause: ${this.cause}]`:""}`}},_t=class extends Pe{constructor(o,r,n,i){super(n,i);this.type=o;this.status=r}},C=class extends Pe{constructor(o,r){super(o,r);this.type="client_error"}};var K=class extends Pe{constructor(o,r){super(o,r);this.type="connector_error"}},J=e=>{if(e instanceof Pe)return e;if(!_n.default.isAxiosError(e))return ve(e);if(!e.response)return new _t("api_error",null,e.message,e);let{type:t,message:o,error:r}=e.response.data;return new _t(t||"ApiError",e.response.status,o||r,e)},ve=e=>e instanceof Pe?e:e instanceof Error?new C(e.message,e):new C(`Internal error: ${e}`);var En=()=>"/api/v1/sessions",Ln=()=>"/api/v1/sessions/logout",An=()=>"/api/v1/sessions/fork",Sn=()=>"/api/v1/siwe/init",Pn=()=>"/api/v1/siwe/authenticate",kn=()=>"/api/v1/siwe/link",Tn=()=>"/api/v1/passwordless/init",Wn=()=>"/api/v1/passwordless/authenticate",Mn=()=>"/api/v1/passwordless/link",In=()=>"/api/v1/passwordless_sms/init",Rn=()=>"/api/v1/passwordless_sms/authenticate",On=()=>"/api/v1/passwordless_sms/link",Nn=()=>"/api/v1/oauth/init",Dn=()=>"/api/v1/oauth/authenticate",Un=()=>"/api/v1/oauth/link",Fn=()=>"/api/v1/siwe/unlink",Bn=()=>"/api/v1/passwordless/unlink",Gn=()=>"/api/v1/passwordless_sms/unlink",Hn=()=>"/api/v1/oauth/unlink";var Jt=class{constructor(t){this.meta={email:t}}async authenticate(){if(!this.api)throw new C("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new C("Email and email code must be set prior to calling authenticate.");try{let t=Wn(),o=await this.api.post(t,{email:this.meta.email,code:this.meta.emailCode});return{user:o.data.user,token:o.data.token,refresh_token:o.data.refresh_token,is_new_user:o.data.is_new_user}}catch(t){throw J(t)}}async link(){if(!this.api)throw new C("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new C("Email and email code must be set prior to calling authenticate.");try{let t=Mn();return(await this.api.post(t,{email:this.meta.email,code:this.meta.emailCode})).data}catch(t){throw J(t)}}async sendCodeEmail(t){if(!this.api)throw new C("Auth flow has no API instance");if(t&&(this.meta.email=t),!this.meta.email)throw new C("Email must be set when initialzing authentication.");try{let o=Tn();return(await this.api.post(o,{email:this.meta.email})).data}catch(o){throw J(o)}}};var Et=class{constructor(t,o,r){this.meta={provider:t},this.meta.authorizationCode=o,this.meta.stateCode=r}isActive(){return!!(this.meta.authorizationCode&&this.meta.stateCode&&this.meta.provider)}async authenticate(){if(!this.api)throw new C("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new C("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling authenticate.");if(this.meta.authorizationCode==="undefined")throw new C("User denied confirmation during OAuth flow");try{let t=Dn(),o=await this.api.post(t,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode});return{user:o.data.user,token:o.data.token,refresh_token:o.data.refresh_token,is_new_user:o.data.is_new_user}}catch(t){throw J(t)}}async link(){if(!this.api)throw new C("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new C("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling link.");if(this.meta.authorizationCode==="undefined")throw new C("User denied confirmation during OAuth flow");try{let t=Un();return(await this.api.post(t,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode})).data}catch(t){throw J(t)}}async getAuthorizationUrl(){if(!this.api)throw new C("Auth flow has no API instance");if(!this.meta.provider)throw new C("Provider must be set when initialzing OAuth authentication.");try{let t=Nn();return(await this.api.post(t,{provider:this.meta.provider,redirect_to:window.location.href})).data}catch(t){throw J(t)}}};var Yt=class{constructor(t,o,r){this._meta={walletType:o,walletId:r},this.connectors=t,this.walletConnector=this.connectors.createWalletConnector(o,null,r)}get meta(){return{...this._meta,walletName:this.walletConnector.walletBranding.name,walletIcon:this.walletConnector.walletBranding.icon}}async authenticate(){if(!this.api)throw new C("Auth flow has no API instance");try{let{message:t,signature:o}=await this.sign(),r=await this.api.post(Pn(),{message:t,signature:o});return this.connectors.addWalletConnector(this.walletConnector),await this.connectors.setActiveWallet(this.walletConnector.address)||console.warn("Failed to set active wallet"),{user:r.data.user,token:r.data.token,refresh_token:r.data.refresh_token,is_new_user:r.data.is_new_user}}catch(t){throw J(t)}}async link(){if(!this.api)throw new C("Auth flow has no API instance");try{let{message:t,signature:o}=await this.sign(),r=await this.api.post(kn(),{message:t,signature:o});return this.connectors.addWalletConnector(this.walletConnector),await this.connectors.setActiveWallet(this.walletConnector.address)||console.warn("Failed to set active wallet"),r.data}catch(t){throw J(t)}}async promptConnect(){if(!this.api)throw new C("Auth flow has no API instance");let t=await this.walletConnector.connect({showPrompt:!0});return await this.buildSiweMessage(t),t}async sign(){if(!this.api)throw new C("Auth flow has no API instance");if(!this.preparedMessage){let o=await this.walletConnector.connect({showPrompt:!1});await this.buildSiweMessage(o)}if(!this.preparedMessage)throw new C("Could not prepare SIWE message");let t=await this.walletConnector.sign(this.preparedMessage);return{message:this.preparedMessage,signature:t}}async buildSiweMessage(t){if(!this.api)throw new C("Auth flow has no API instance");let o=t.address,r=t.chainId,n=await this.api.post(Sn(),{address:o});return this.preparedMessage=this.walletConnector.prepareMessage(r,o,n.data.nonce),this.preparedMessage}};var Xt=class{constructor(t){this.meta={phoneNumber:t}}async authenticate(){if(!this.api)throw new C("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new C("phone number and sms code must be set prior to calling authenticate.");try{let t=Rn(),o=await this.api.post(t,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode});return{user:o.data.user,token:o.data.token,refresh_token:o.data.refresh_token,is_new_user:o.data.is_new_user}}catch(t){throw J(t)}}async link(){if(!this.api)throw new C("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new C("phone number and sms code must be set prior to calling authenticate.");try{let t=On();return(await this.api.post(t,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode})).data}catch(t){throw J(t)}}async sendSmsCode(t){if(!this.api)throw new C("Auth flow has no API instance");if(t&&(this.meta.phoneNumber=t),!this.meta.phoneNumber)throw new C("phone nNumber must be set when initialzing authentication.");try{let o=In();return(await this.api.post(o,{phoneNumber:this.meta.phoneNumber})).data}catch(o){throw J(o)}}};var aa=require("@ethersproject/address");var Vn="1.18.0-beta.8";var $n="https://api.privy.io/v0",yr=process.env.NEXT_PUBLIC_PRIVY_AUTH_URL||"https://auth.privy.io",bo="4df5e2316331463a9130964bd6078dfa",jn=1e4,Ce=1400,wo=Vn;var Lt="privy:token",yo="privy:refresh_token",vo="privy:connectors",vr="walletconnect",zn=3e4;var Cr=class{constructor(){this._cache={}}get(t){return this._cache[t]}put(t,o){o!==void 0?this._cache[t]=o:this.del(t)}del(t){delete this._cache[t]}getKeys(){return Object.keys(this._cache)}},xr=class{get(t){let o=localStorage.getItem(t);return o===null?void 0:JSON.parse(o)}put(t,o){o!==void 0?localStorage.setItem(t,JSON.stringify(o)):this.del(t)}del(t){localStorage.removeItem(t)}getKeys(){return Object.entries(localStorage).map(([t])=>t)}};function Us(){return typeof window<"u"&&window.localStorage?new xr:new Cr}var Y=Us();var Jn=A(require("@coinbase/wallet-sdk")),Yn=require("@ethersproject/address");var Qt=require("react/jsx-runtime"),Fe=({style:e,...t})=>(0,Qt.jsxs)("svg",{width:"1024",height:"1024",viewBox:"0 0 1024 1024",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"28px",width:"28px",...e},...t,children:[(0,Qt.jsx)("rect",{width:"1024",height:"1024",fill:"#0052FF",rx:100,ry:100}),(0,Qt.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z",fill:"white"})]});var Zn=require("@ethersproject/address"),Kn=require("@ethersproject/providers");var qn=require("@ethersproject/logger");var At=class extends K{constructor(){super("Wallet timeout");this.type="wallet_error"}},ut=class extends K{constructor(){super("User rejected connection");this.type="wallet_error"}},Be=e=>{if(e instanceof K)return e;if((e==null?void 0:e.code)&&(e==null?void 0:e.reason)){let t=new St(e);return e.code===qn.ErrorCode.ACTION_REJECTED&&(t.details=dt.E4001_USER_REJECTED_REQUEST),t}return e!=null&&e.code?new St(e):new K("Unknown connector error",e)},_r=class extends Pe{constructor(o,r,n){super(o);this.type="provider_error";this.code=r,this.data=n}},St=class extends _r{constructor(o){var i,a,s;let r=o;super(r.message,r.code,r.data);let n=Object.values(dt).find(l=>l.eipCode===r.code);this.details=n||dt.UNKNOWN_ERROR,r.code===-32002&&((i=r.message)!=null&&i.includes("already pending for origin")?(a=r.message)!=null&&a.includes("wallet_requestPermissions")?this.details=dt.E32002_CONNECTION_ALREADY_PENDING:this.details=dt.E32002_REQUEST_ALREADY_PENDING:(s=r.message)!=null&&s.includes("Already processing")&&r.message.includes("eth_requestAccounts")&&(this.details=dt.E32002_WALLET_LOCKED))}},Fs={ERROR_USER_EXISTS:{message:"User already exists for this address",detail:"Try another address!",retryable:!1},ERROR_TIMED_OUT:{message:"Wallet request timed out",detail:"Please try connecting again.",retryable:!0},ERROR_WALLET_CONNECTION:{message:"Could not log in with wallet",detail:"Please try connecting again.",retryable:!0},ERROR_USER_REJECTED_CONNECTION:{message:"You rejected the request",detail:"Please try connecting again.",retryable:!0}},Bs={E32002_CONNECTION_ALREADY_PENDING:{eipCode:-32002,message:"Connection request already pending",detail:"Don\u2019t see your wallet modal? Check your other browser windows.",retryable:!1},E32002_REQUEST_ALREADY_PENDING:{eipCode:-32002,message:"Resource request already pending",detail:"Don\u2019t see your wallet modal? Check your other browser windows.",retryable:!1},E32002_WALLET_LOCKED:{eipCode:-32002,message:"Wallet might be locked",detail:"Don\u2019t see your wallet modal? Check your other browser windows.",retryable:!1},E4001_USER_REJECTED_REQUEST:{eipCode:4001,message:"Signature rejected",detail:"Please try signing again.",retryable:!0}},Gs={E4001_DEFAULT_USER_REJECTED_REQUEST:{eipCode:4001,message:"User Rejected Request",detail:"The user rejected the request.",default:!0,retryable:!0},E4100_DEFAULT_UNAUTHORIZED:{eipCode:4100,message:"Unauthorized",detail:"The requested method and/or account has not been authorized by the user.",default:!0,retryable:!1},E4200_DEFAULT_UNSUPPORTED_METHOD:{eipCode:4200,message:"Unsupported Method",detail:"The Provider does not support the requested method.",default:!0,retryable:!1},E4900_DEFAULT_DISCONNECTED:{eipCode:4900,message:"Disconnected",detail:"The Provider is disconnected from all chains.",default:!0,retryable:!0},E4901_DEFAULT_CHAIN_DISCONNECTED:{eipCode:4901,message:"Chain Disconnected",detail:"The Provider is not connected to the requested chain.",default:!0,retryable:!0},E32700_DEFAULT_PARSE_ERROR:{eipCode:-32700,message:"Parse error",detail:"Invalid JSON",default:!0,retryable:!1},E32600_DEFAULT_INVALID_REQUEST:{eipCode:-32600,message:"Invalid request",detail:"JSON is not a valid request object",default:!0,retryable:!1},E32601_DEFAULT_METHOD_NOT_FOUND:{eipCode:-32601,message:"Method not found",detail:"Method does not exist",default:!0,retryable:!1},E32602_DEFAULT_INVALID_PARAMS:{eipCode:-32602,message:"Invalid params",detail:"Invalid method parameters",default:!0,retryable:!1},E32603_DEFAULT_INTERNAL_ERROR:{eipCode:-32603,message:"Internal error",detail:"Internal JSON-RPC error",default:!0,retryable:!0},E32000_DEFAULT_INVALID_INPUT:{eipCode:-32e3,message:"Invalid input",detail:"Missing or invalid parameters",default:!0,retryable:!1},E32001_DEFAULT_RESOURCE_NOT_FOUND:{eipCode:-32001,message:"Resource not found",detail:"Requested resource not found",default:!0,retryable:!1},E32002_DEFAULT_RESOURCE_UNAVAILABLE:{eipCode:-32002,message:"Resource unavailable",detail:"Requested resource not available",default:!0,retryable:!0},E32003_DEFAULT_TRANSACTION_REJECTED:{eipCode:-32003,message:"Transaction rejected",detail:"Transaction creation failed",default:!0,retryable:!0},E32004_DEFAULT_METHOD_NOT_SUPPORTED:{eipCode:-32004,message:"Method not supported",detail:"Method is not implemented",default:!0,retryable:!1},E32005_DEFAULT_LIMIT_EXCEEDED:{eipCode:-32005,message:"Limit exceeded",detail:"Request exceeds defined limit",default:!0,retryable:!1},E32006_DEFAULT_JSON_RPC_VERSION_NOT_SUPPORTED:{eipCode:-32006,message:"JSON-RPC version not supported",detail:"Version of JSON-RPC protocol is not supported",default:!0,retryable:!1}},dt={UNKNOWN_ERROR:{eipCode:0,message:"Unknown error",detail:"Unknown error",retryable:!0},...Gs,...Bs},pt={...Fs,...dt};var Hs=12e4,Er=(e=new At,t=Hs)=>new Promise((o,r)=>setTimeout(()=>{r(e)},t)),ke=class{constructor(t){this.removeListener=(t,o)=>{if(this.walletProvider)return this.walletProvider.removeListener(t,o)};this.setWalletProvider=t=>{this.walletProvider=t,this._subscriptions.forEach(o=>{var r;(r=this.walletProvider)==null||r.on(o.eventName,o.listener)})};this.walletProvider=t,this._subscriptions=[]}on(t,o){if(this.walletProvider)return this.walletProvider.on(t,o);this._subscriptions.push({eventName:t,listener:o})}async request(t){if(!this.walletProvider)throw new K(`A wallet request of type ${t.method} was made before setting a wallet provider.`);return Promise.race([this.walletProvider.request(t),Er()]).catch(o=>{throw Be(o)})}},Xe=class extends ke{constructor(o){super(o)}},Co=class extends ke{constructor(t){super(t)}sendAsync(t,o){throw new Error("sendAsync is no longer supported by EIP-1193. Use the request method instead.")}};var Ge=class{constructor(t,o,r){this.createSiweMessage=(t,o,r,n,i,a,s)=>`${r} wants you to sign in with your Ethereum account:
2
2
  ${o}
3
3
 
4
4
  ${s}
@@ -426,7 +426,7 @@ Resources:
426
426
  }
427
427
  `,ql=Dt.default.span`
428
428
  word-break: break-all;
429
- `;var Ye=require("react"),Pa=require("react-device-detect"),Zo=A(require("styled-components"));var G=require("react/jsx-runtime"),Xr=2,qo={metamask:{name:"MetaMask",component:Te},coinbase_wallet:{name:"Coinbase Wallet",component:Fe},wallet_connect:{name:"WalletConnect",component:Pt}},Zl=e=>(e==null?void 0:e.status)===422?pt.ERROR_USER_EXISTS:e instanceof St&&!e.details.default?e.details:e instanceof At?pt.ERROR_TIMED_OUT:e instanceof ut?pt.ERROR_USER_REJECTED_CONNECTION:pt.ERROR_WALLET_CONNECTION,ka=()=>{var z,V,$;let[e,t]=(0,Ye.useState)(!1),[o,r]=(0,Ye.useState)(void 0),{navigate:n,navigateBack:i}=E(),{getAuthFlow:a,walletConnectionStatus:s,closePrivyModal:l,loginWithWallet:d}=M(),{walletConnectors:b}=Q(),[w,u]=(0,Ye.useState)(0),{user:p}=Q(),[y]=(0,Ye.useState)((p==null?void 0:p.linkedAccounts.length)||0),c=a(),v=Pa.isMobile&&(c==null?void 0:c.meta.walletType)==="wallet_connect",S=s==null?void 0:s.connected;(0,Ye.useEffect)(()=>{!c||v||!S||I().catch(O=>console.warn("Auto-prompted signature failed",O))},[w,S]),(0,Ye.useEffect)(()=>{if(e){let O=setTimeout(l,Ce);return()=>clearTimeout(O)}},[p]);let T=O=>{if((O==null?void 0:O.status)===401&&(O==null?void 0:O.message)==="User is not allowed to login to this app."){n("ALLOWLIST_REJECTION_SCREEN");return}r(Zl(O))};async function I(){try{await d(),t(!0)}catch(O){T(O)}}(0,Ye.useEffect)(()=>{s!=null&&s.connectError&&T(s==null?void 0:s.connectError)},[s]);let R=(c==null?void 0:c.meta.walletType)||"metamask",B=((z=c==null?void 0:c.meta)==null?void 0:z.walletName)||qo[R].name,se=((V=c==null?void 0:c.meta)==null?void 0:V.walletIcon)||qo[R].component,ie=e?`Successfully connected with ${B}`:o?o.message:S?"Sign to verify":`Waiting for ${B}`,H="Don\u2019t see your wallet modal? Check your other browser windows.";if(e){let O=(p==null?void 0:p.linkedAccounts.length)||0;y===O?H="Wallet was already linked.":H="You\u2019re good to go!"}else w>=Xr&&o?H="Unable to connect wallet":o?H=o.detail:S&&v?H="Sign the message in your wallet to verify it belongs to you.":R==="metamask"?H="For the best experience, connect only one wallet at a time.":R==="wallet_connect"?H="Open your mobile wallet app to continue":R==="coinbase_wallet"&&(No()||(Gr(p)?H="Continue with the Coinbase app. Not the right wallet? Reset your connection below.":H="Open the Coinbase app on your phone to continue."));let ye=($=b==null?void 0:b.walletConnectors)==null?void 0:$.find(O=>O.walletType==="coinbase_wallet"),Ue=R==="coinbase_wallet"&&(Gr(p)||o===pt.ERROR_USER_EXISTS);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(k,{backFn:i}),(0,G.jsxs)(Kl,{children:[(0,G.jsx)(Qr,{walletLogo:se,success:e,fail:!!o}),(0,G.jsxs)(Jl,{children:[(0,G.jsx)("h3",{children:ie}),(0,G.jsx)("p",{children:H})]}),Ue?(0,G.jsx)(pe,{onClick:()=>ye&&(ye==null?void 0:ye.disconnect()),invisible:e,disabled:e,children:"Use a different wallet"}):o==pt.ERROR_USER_EXISTS?(0,G.jsx)(pe,{onClick:i,children:"Use a different wallet"}):S&&!e&&v?(0,G.jsx)(pe,{onClick:I,children:"Sign with your wallet"}):(0,G.jsx)(pe,{onClick:()=>{u(w+1),r(void 0),s==null||s.connectRetry()},invisible:e||!(o!=null&&o.retryable)||w>=Xr,disabled:!e&&(!(o!=null&&o.retryable)||w>=Xr),children:"Retry"})]})]})},Kl=Zo.default.div`
429
+ `;var Ye=require("react"),Pa=require("react-device-detect"),Zo=A(require("styled-components"));var G=require("react/jsx-runtime"),Xr=2,qo={metamask:{name:"MetaMask",component:Te},coinbase_wallet:{name:"Coinbase Wallet",component:Fe},wallet_connect:{name:"WalletConnect",component:Pt}},Zl=e=>(e==null?void 0:e.status)===422?pt.ERROR_USER_EXISTS:e instanceof St&&!e.details.default?e.details:e instanceof At?pt.ERROR_TIMED_OUT:e instanceof ut?pt.ERROR_USER_REJECTED_CONNECTION:pt.ERROR_WALLET_CONNECTION,ka=()=>{var z,V,$;let[e,t]=(0,Ye.useState)(!1),[o,r]=(0,Ye.useState)(void 0),{navigate:n,navigateBack:i}=E(),{getAuthFlow:a,walletConnectionStatus:s,closePrivyModal:l,loginWithWallet:d}=M(),{walletConnectors:b}=Q(),[w,u]=(0,Ye.useState)(0),{user:p}=Q(),[y]=(0,Ye.useState)((p==null?void 0:p.linkedAccounts.length)||0),c=a(),v=Pa.isMobile&&(c==null?void 0:c.meta.walletType)==="wallet_connect",S=s==null?void 0:s.connected;(0,Ye.useEffect)(()=>{!c||v||!S||I().catch(O=>console.warn("Auto-prompted signature failed",O))},[w,S]),(0,Ye.useEffect)(()=>{if(p&&e){let O=setTimeout(l,Ce);return()=>clearTimeout(O)}},[p,e]);let T=O=>{if((O==null?void 0:O.status)===401&&(O==null?void 0:O.message)==="User is not allowed to login to this app."){n("ALLOWLIST_REJECTION_SCREEN");return}r(Zl(O))};async function I(){try{await d(),t(!0)}catch(O){T(O)}}(0,Ye.useEffect)(()=>{s!=null&&s.connectError&&T(s==null?void 0:s.connectError)},[s]);let R=(c==null?void 0:c.meta.walletType)||"metamask",B=((z=c==null?void 0:c.meta)==null?void 0:z.walletName)||qo[R].name,se=((V=c==null?void 0:c.meta)==null?void 0:V.walletIcon)||qo[R].component,ie=e?`Successfully connected with ${B}`:o?o.message:S?"Sign to verify":`Waiting for ${B}`,H="Don\u2019t see your wallet modal? Check your other browser windows.";if(e){let O=(p==null?void 0:p.linkedAccounts.length)||0;y===O?H="Wallet was already linked.":H="You\u2019re good to go!"}else w>=Xr&&o?H="Unable to connect wallet":o?H=o.detail:S&&v?H="Sign the message in your wallet to verify it belongs to you.":R==="metamask"?H="For the best experience, connect only one wallet at a time.":R==="wallet_connect"?H="Open your mobile wallet app to continue":R==="coinbase_wallet"&&(No()||(Gr(p)?H="Continue with the Coinbase app. Not the right wallet? Reset your connection below.":H="Open the Coinbase app on your phone to continue."));let ye=($=b==null?void 0:b.walletConnectors)==null?void 0:$.find(O=>O.walletType==="coinbase_wallet"),Ue=R==="coinbase_wallet"&&(Gr(p)||o===pt.ERROR_USER_EXISTS);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(k,{backFn:i}),(0,G.jsxs)(Kl,{children:[(0,G.jsx)(Qr,{walletLogo:se,success:e,fail:!!o}),(0,G.jsxs)(Jl,{children:[(0,G.jsx)("h3",{children:ie}),(0,G.jsx)("p",{children:H})]}),Ue?(0,G.jsx)(pe,{onClick:()=>ye&&(ye==null?void 0:ye.disconnect()),invisible:e,disabled:e,children:"Use a different wallet"}):o==pt.ERROR_USER_EXISTS?(0,G.jsx)(pe,{onClick:i,children:"Use a different wallet"}):S&&!e&&v?(0,G.jsx)(pe,{onClick:I,children:"Sign with your wallet"}):(0,G.jsx)(pe,{onClick:()=>{u(w+1),r(void 0),s==null||s.connectRetry()},invisible:e||!(o!=null&&o.retryable)||w>=Xr,disabled:!e&&(!(o!=null&&o.retryable)||w>=Xr),children:"Retry"})]})]})},Kl=Zo.default.div`
430
430
  display: flex;
431
431
  flex-direction: column;
432
432
  align-items: center;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@privy-io/react-auth",
3
- "version": "1.18.0-beta.7",
3
+ "version": "1.18.0-beta.8",
4
4
  "description": "React client for the Privy Auth API",
5
5
  "keywords": [
6
6
  "authentication",