@privy-io/react-auth 1.19.0-beta.5 → 1.19.0-beta.6
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 +2 -2
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var ll=Object.create;var co=Object.defineProperty;var cl=Object.getOwnPropertyDescriptor;var dl=Object.getOwnPropertyNames;var pl=Object.getPrototypeOf,ul=Object.prototype.hasOwnProperty;var Ln=(e,t)=>()=>(e&&(t=e(e=0)),t);var ke=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Sn=(e,t)=>{for(var o in t)co(e,o,{get:t[o],enumerable:!0})},Pn=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of dl(t))!ul.call(e,n)&&n!==o&&co(e,n,{get:()=>t[n],enumerable:!(r=cl(t,n))||r.enumerable});return e};var fl=(e,t,o)=>(o=e!=null?ll(pl(e)):{},Pn(t||!e||!e.__esModule?co(o,"default",{value:e,enumerable:!0}):o,e)),An=e=>Pn(co({},"__esModule",{value:!0}),e);var Eo=ke((b2,Co)=>{var di,pi,ui,fi,mi,hi,gi,bi,yi,vo,Er,vi,wi,Ci,bt,Ei,xi,_i,Li,Si,Pi,Ai,ki,Ti,wo;(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])};di=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)},pi=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},ui=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},fi=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},mi=function(r,n){return function(i,a){n(i,a,r)}},hi=function(r,n){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,n)},gi=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(g){try{u(a.next(g))}catch(b){d(b)}}function f(g){try{u(a.throw(g))}catch(b){d(b)}}function u(g){g.done?l(g.value):s(g.value).then(h,f)}u((a=a.apply(r,n||[])).next())})},bi=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(g){return f([u,g])}}function f(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(g){u=[6,g],s=0}finally{a=l=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}},yi=function(r,n){for(var i in r)i!=="default"&&!Object.prototype.hasOwnProperty.call(n,i)&&wo(n,r,i)},wo=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]},vo=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.")},Er=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},vi=function(){for(var r=[],n=0;n<arguments.length;n++)r=r.concat(Er(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,h=l.length;d<h;d++,s++)a[s]=l[d];return a},Ci=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))},bt=function(r){return this instanceof bt?(this.v=r,this):new bt(r)},Ei=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(y){return new Promise(function(_,W){l.push([c,y,_,W])>1||h(c,y)})})}function h(c,y){try{f(a[c](y))}catch(_){b(l[0][3],_)}}function f(c){c.value instanceof bt?Promise.resolve(c.value.v).then(u,g):b(l[0][2],c)}function u(c){h("next",c)}function g(c){h("throw",c)}function b(c,y){c(y),l.shift(),l.length&&h(l[0][0],l[0][1])}},xi=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:bt(r[s](d)),done:s==="return"}:l?l(d):d}:l}},_i=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 vo=="function"?vo(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,f){d=r[l](d),s(h,f,d.done,d.value)})}}function s(l,d,h,f){Promise.resolve(f).then(function(u){l({value:u,done:h})},d)}},Li=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};Si=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)&&wo(n,r,i);return o(n,r),n},Pi=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)},ki=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},Ti=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",di),e("__assign",pi),e("__rest",ui),e("__decorate",fi),e("__param",mi),e("__metadata",hi),e("__awaiter",gi),e("__generator",bi),e("__exportStar",yi),e("__createBinding",wo),e("__values",vo),e("__read",Er),e("__spread",vi),e("__spreadArrays",wi),e("__spreadArray",Ci),e("__await",bt),e("__asyncGenerator",Ei),e("__asyncDelegator",xi),e("__asyncValues",_i),e("__makeTemplateObject",Li),e("__importStar",Si),e("__importDefault",Pi),e("__classPrivateFieldGet",Ai),e("__classPrivateFieldSet",ki),e("__classPrivateFieldIn",Ti)})});var xr=ke(O=>{"use strict";Object.defineProperty(O,"__esModule",{value:!0});O.getLocalStorage=O.getLocalStorageOrThrow=O.getCrypto=O.getCryptoOrThrow=O.getLocation=O.getLocationOrThrow=O.getNavigator=O.getNavigatorOrThrow=O.getDocument=O.getDocumentOrThrow=O.getFromWindowOrThrow=O.getFromWindow=void 0;function Ye(e){let t;return typeof window<"u"&&typeof window[e]<"u"&&(t=window[e]),t}O.getFromWindow=Ye;function yt(e){let t=Ye(e);if(!t)throw new Error(`${e} is not defined in Window`);return t}O.getFromWindowOrThrow=yt;function Bl(){return yt("document")}O.getDocumentOrThrow=Bl;function Fl(){return Ye("document")}O.getDocument=Fl;function Gl(){return yt("navigator")}O.getNavigatorOrThrow=Gl;function Hl(){return Ye("navigator")}O.getNavigator=Hl;function Vl(){return yt("location")}O.getLocationOrThrow=Vl;function jl(){return Ye("location")}O.getLocation=jl;function $l(){return yt("crypto")}O.getCryptoOrThrow=$l;function zl(){return Ye("crypto")}O.getCrypto=zl;function ql(){return yt("localStorage")}O.getLocalStorageOrThrow=ql;function Zl(){return Ye("localStorage")}O.getLocalStorage=Zl});var Ri=ke(xo=>{"use strict";Object.defineProperty(xo,"__esModule",{value:!0});xo.getWindowMetadata=void 0;var Wi=xr();function Kl(){let e,t;try{e=Wi.getDocumentOrThrow(),t=Wi.getLocationOrThrow()}catch{return null}function o(){let f=e.getElementsByTagName("link"),u=[];for(let g=0;g<f.length;g++){let b=f[g],c=b.getAttribute("rel");if(c&&c.toLowerCase().indexOf("icon")>-1){let y=b.getAttribute("href");if(y)if(y.toLowerCase().indexOf("https:")===-1&&y.toLowerCase().indexOf("http:")===-1&&y.indexOf("//")!==0){let _=t.protocol+"//"+t.host;if(y.indexOf("/")===0)_+=y;else{let W=t.pathname.split("/");W.pop(),_+=W.join("/")+"/"+y}u.push(_)}else if(y.indexOf("//")===0){let _=t.protocol+y;u.push(_)}else u.push(y)}}return u}function r(...f){let u=e.getElementsByTagName("meta");for(let g=0;g<u.length;g++){let b=u[g],c=["itemprop","property","name"].map(y=>b.getAttribute(y)).filter(y=>y?f.includes(y):!1);if(c.length&&c){let y=b.getAttribute("content");if(y)return y}}return""}function n(){let f=r("name","og:site_name","og:title","twitter:title");return f||(f=e.title),f}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}}xo.getWindowMetadata=Kl});var Vi={};Sn(Vi,{BotInfo:()=>Ui,BrowserInfo:()=>Oi,NodeInfo:()=>Ni,ReactNativeInfo:()=>Bi,SearchBotDeviceInfo:()=>Di,browserName:()=>tc,detect:()=>ec,detectOS:()=>Gi,getNodeVersion:()=>Hi,parseUserAgent:()=>_r});function ec(e){return e?_r(e):typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new Bi:typeof navigator<"u"?_r(navigator.userAgent):Hi()}function Fi(e){return e!==""&&Ql.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 tc(e){var t=Fi(e);return t?t[0]:null}function _r(e){var t=Fi(e);if(!t)return null;var o=t[0],r=t[1];if(o==="searchbot")return new Ui;var n=r[1]&&r[1].split(/[._]/).slice(0,3);n?n.length<Ii&&(n=Jl(n,oc(Ii-n.length))):n=[];var i=n.join("."),a=Gi(e),s=Xl.exec(e);return s&&s[1]?new Di(o,i,a,s[1]):new Oi(o,i,a)}function Gi(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 Hi(){var e=typeof process<"u"&&process.version;return e?new Ni(process.version.slice(1)):null}function oc(e){for(var t=[],o=0;o<e;o++)t.push("0");return t}var Jl,Oi,Ni,Di,Ui,Bi,Yl,Xl,Ii,Ql,Mi,ji=Ln(()=>{Jl=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},Oi=function(){function e(t,o,r){this.name=t,this.version=o,this.os=r,this.type="browser"}return e}(),Ni=function(){function e(t){this.version=t,this.type="node",this.name="node",this.os=process.platform}return e}(),Di=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}(),Ui=function(){function e(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return e}(),Bi=function(){function e(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return e}(),Yl=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,Xl=/(nuhk|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,Ii=3,Ql=[["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",Yl]],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 Sr=ke(E=>{"use strict";Object.defineProperty(E,"__esModule",{value:!0});E.getClientMeta=E.getLocalStorage=E.getLocalStorageOrThrow=E.getCrypto=E.getCryptoOrThrow=E.getLocation=E.getLocationOrThrow=E.getNavigator=E.getNavigatorOrThrow=E.getDocument=E.getDocumentOrThrow=E.getFromWindowOrThrow=E.getFromWindow=E.isBrowser=E.isNode=E.isMobile=E.isIOS=E.isAndroid=E.detectOS=E.detectEnv=void 0;var $i=Eo(),rc=$i.__importStar(Ri()),me=$i.__importStar(xr()),nc=(ji(),An(Vi));function Lr(e){return(0,nc.detect)(e)}E.detectEnv=Lr;function _o(){let e=Lr();return e&&e.os?e.os:void 0}E.detectOS=_o;function zi(){let e=_o();return e?e.toLowerCase().includes("android"):!1}E.isAndroid=zi;function qi(){let e=_o();return e?e.toLowerCase().includes("ios")||e.toLowerCase().includes("mac")&&navigator.maxTouchPoints>1:!1}E.isIOS=qi;function ic(){return _o()?zi()||qi():!1}E.isMobile=ic;function Zi(){let e=Lr();return e&&e.name?e.name.toLowerCase()==="node":!1}E.isNode=Zi;function ac(){return!Zi()&&!!(0,E.getNavigator)()}E.isBrowser=ac;E.getFromWindow=me.getFromWindow;E.getFromWindowOrThrow=me.getFromWindowOrThrow;E.getDocumentOrThrow=me.getDocumentOrThrow;E.getDocument=me.getDocument;E.getNavigatorOrThrow=me.getNavigatorOrThrow;E.getNavigator=me.getNavigator;E.getLocationOrThrow=me.getLocationOrThrow;E.getLocation=me.getLocation;E.getCryptoOrThrow=me.getCryptoOrThrow;E.getCrypto=me.getCrypto;E.getLocalStorageOrThrow=me.getLocalStorageOrThrow;E.getLocalStorage=me.getLocalStorage;function sc(){return rc.getWindowMetadata()}E.getClientMeta=sc});var Ki={};Sn(Ki,{safeJsonParse:()=>lc,safeJsonStringify:()=>cc});function lc(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 cc(e){return typeof e=="string"?e:JSON.stringify(e)}var Ji=Ln(()=>{});var Pr=ke(vt=>{"use strict";Object.defineProperty(vt,"__esModule",{value:!0});vt.safeJsonStringify=vt.safeJsonParse=void 0;var dc=Eo(),Yi=dc.__importStar((Ji(),An(Ki)));vt.safeJsonParse=Yi.safeJsonParse;vt.safeJsonStringify=Yi.safeJsonStringify});var kr=ke(De=>{"use strict";Object.defineProperty(De,"__esModule",{value:!0});De.removeLocal=De.getLocal=De.setLocal=void 0;var Xi=Pr(),Ar=Sr();function pc(e,t){let o=(0,Xi.safeJsonStringify)(t),r=(0,Ar.getLocalStorage)();r&&r.setItem(e,o)}De.setLocal=pc;function uc(e){let t=null,o=null,r=(0,Ar.getLocalStorage)();return r&&(o=r.getItem(e)),t=o&&(0,Xi.safeJsonParse)(o),t}De.getLocal=uc;function fc(e){let t=(0,Ar.getLocalStorage)();t&&t.removeItem(e)}De.removeLocal=fc});var ea=ke(se=>{"use strict";Object.defineProperty(se,"__esModule",{value:!0});se.getMobileLinkRegistry=se.getMobileRegistryEntry=se.saveMobileLinkInfo=se.formatIOSMobile=se.mobileLinkChoiceKey=void 0;var mc=kr();se.mobileLinkChoiceKey="WALLETCONNECT_DEEPLINK_CHOICE";function hc(e,t){let o=encodeURIComponent(e);return t.universalLink?`${t.universalLink}/wc?uri=${o}`:t.deepLink?`${t.deepLink}${t.deepLink.endsWith(":")?"//":"/"}wc?uri=${o}`:""}se.formatIOSMobile=hc;function gc(e){let t=e.href.split("?")[0];(0,mc.setLocal)(se.mobileLinkChoiceKey,Object.assign(Object.assign({},e),{href:t}))}se.saveMobileLinkInfo=gc;function Qi(e,t){return e.filter(o=>o.name.toLowerCase().includes(t.toLowerCase()))[0]}se.getMobileRegistryEntry=Qi;function bc(e,t){let o=e;return t&&(o=t.map(r=>Qi(e,r)).filter(Boolean)),o}se.getMobileLinkRegistry=bc});var ra=ke(_e=>{"use strict";Object.defineProperty(_e,"__esModule",{value:!0});_e.formatMobileRegistry=_e.formatMobileRegistryEntry=_e.getDappRegistryUrl=_e.getWalletRegistryUrl=void 0;var ta="https://registry.walletconnect.com";function yc(){return ta+"/api/v2/wallets"}_e.getWalletRegistryUrl=yc;function vc(){return ta+"/api/v2/dapps"}_e.getDappRegistryUrl=vc;function oa(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=oa;function wc(e,t="mobile"){return Object.values(e).filter(o=>!!o[t].universal||!!o[t].native).map(o=>oa(o,t))}_e.formatMobileRegistry=wc});var na=ke(Xe=>{"use strict";Object.defineProperty(Xe,"__esModule",{value:!0});var jt=Eo();jt.__exportStar(Sr(),Xe);jt.__exportStar(Pr(),Xe);jt.__exportStar(kr(),Xe);jt.__exportStar(ea(),Xe);jt.__exportStar(ra(),Xe)});import{Web3Provider as Kp}from"@ethersproject/providers";import{useEffect as xn,useState as Q}from"react";var C=()=>{throw new Error("You need to wrap your application with the <PrivyProvider> initialized with your app id.")};import ml from"axios";var ye=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}]`:""}`}},ct=class extends ye{constructor(o,r,n,i){super(n,i);this.type=o;this.status=r}},v=class extends ye{constructor(o,r){super(o,r);this.type="client_error"}};var z=class extends ye{constructor(o,r){super(o,r);this.type="connector_error"}},q=e=>{if(e instanceof ye)return e;if(!ml.isAxiosError(e))return pe(e);if(!e.response)return new ct("api_error",null,e.message,e);let{type:t,message:o,error:r}=e.response.data;return new ct(t||"ApiError",e.response.status,o||r,e)},pe=e=>e instanceof ye?e:e instanceof Error?new v(e.message,e):new v(`Internal error: ${e}`);var kn=()=>"/api/v1/sessions",Tn=()=>"/api/v1/sessions/logout",Wn=()=>"/api/v1/sessions/fork",Rn=()=>"/api/v1/sessions/fork/recover",In=()=>"/api/v1/siwe/init",Mn=()=>"/api/v1/siwe/authenticate",On=()=>"/api/v1/siwe/link",Nn=()=>"/api/v1/passwordless/init",Dn=()=>"/api/v1/passwordless/authenticate",Un=()=>"/api/v1/passwordless/link",Bn=()=>"/api/v1/passwordless_sms/init",Fn=()=>"/api/v1/passwordless_sms/authenticate",Gn=()=>"/api/v1/passwordless_sms/link",Hn=()=>"/api/v1/oauth/init",Vn=()=>"/api/v1/oauth/authenticate",jn=()=>"/api/v1/oauth/link",$n=()=>"/api/v1/siwe/unlink",zn=()=>"/api/v1/passwordless/unlink",qn=()=>"/api/v1/passwordless_sms/unlink",Zn=()=>"/api/v1/oauth/unlink";var Gt=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=Dn(),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 q(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=Un();return(await this.api.post(t,{email:this.meta.email,code:this.meta.emailCode})).data}catch(t){throw q(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=Nn();return(await this.api.post(o,{email:this.meta.email})).data}catch(o){throw q(o)}}};var dt=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=Vn(),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 q(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=jn();return(await this.api.post(t,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode})).data}catch(t){throw q(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=Hn();return(await this.api.post(t,{provider:this.meta.provider,redirect_to:window.location.href})).data}catch(t){throw q(t)}}};var pt=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(Mn(),{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 q(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(On(),{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 q(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(In(),{address:o});return this.preparedMessage=this.walletConnector.prepareMessage(r,o,n.data.nonce),this.preparedMessage}};var Ht=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=Fn(),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 q(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=Gn();return(await this.api.post(t,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode})).data}catch(t){throw q(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=Bn();return(await this.api.post(o,{phoneNumber:this.meta.phoneNumber})).data}catch(o){throw q(o)}}};import{getAddress as _c}from"@ethersproject/address";var Kn="1.19.0-beta.5";var Jn="https://api.privy.io/v0",ur=process.env.NEXT_PUBLIC_PRIVY_AUTH_URL||"https://auth.privy.io",po="4df5e2316331463a9130964bd6078dfa",Yn=1e4,ue=1400,fr=Kn;var ut="privy:token",uo="privy:refresh_token",Vt="privy:session_transfer_token",fo="privy:connectors",mr="walletconnect",Xn=3e4;var hr=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)}},gr=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 gl(){return typeof window<"u"&&window.localStorage?new gr:new hr}var B=gl();import Ll from"@coinbase/wallet-sdk";import{getAddress as Sl}from"@ethersproject/address";import{jsx as Qn,jsxs as bl}from"react/jsx-runtime";var fe=({style:e,...t})=>bl("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:[Qn("rect",{width:"1024",height:"1024",fill:"#0052FF",rx:100,ry:100}),Qn("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 xl}from"@ethersproject/address";import{Web3Provider as _l}from"@ethersproject/providers";import{ErrorCode as yl}from"@ethersproject/logger";var ft=class extends z{constructor(){super("Wallet timeout");this.type="wallet_error"}},qe=class extends z{constructor(){super("User rejected connection");this.type="wallet_error"}},Ee=e=>{if(e instanceof z)return e;if((e==null?void 0:e.code)&&(e==null?void 0:e.reason)){let t=new mt(e);return e.code===yl.ACTION_REJECTED&&(t.details=ze.E4001_USER_REJECTED_REQUEST),t}return e!=null&&e.code?new mt(e):new z("Unknown connector error",e)},br=class extends ye{constructor(o,r,n){super(o);this.type="provider_error";this.code=r,this.data=n}},mt=class extends br{constructor(o){var i,a,s;let r=o;super(r.message,r.code,r.data);let n=Object.values(ze).find(l=>l.eipCode===r.code);this.details=n||ze.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=ze.E32002_CONNECTION_ALREADY_PENDING:this.details=ze.E32002_REQUEST_ALREADY_PENDING:(s=r.message)!=null&&s.includes("Already processing")&&r.message.includes("eth_requestAccounts")&&(this.details=ze.E32002_WALLET_LOCKED))}},vl={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}},wl={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}},Cl={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}},ze={UNKNOWN_ERROR:{eipCode:0,message:"Unknown error",detail:"Unknown error",retryable:!0},...Cl,...wl},Ze={...vl,...ze};var El=12e4,yr=(e=new ft,t=El)=>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 z(`A wallet request of type ${t.method} was made before setting a wallet provider.`);return Promise.race([this.walletProvider.request(t),yr()]).catch(o=>{throw Ee(o)})}},Ke=class extends xe{constructor(o){super(o)}},mo=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 Te=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 ll=Object.create;var co=Object.defineProperty;var cl=Object.getOwnPropertyDescriptor;var dl=Object.getOwnPropertyNames;var pl=Object.getPrototypeOf,ul=Object.prototype.hasOwnProperty;var Ln=(e,t)=>()=>(e&&(t=e(e=0)),t);var ke=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Sn=(e,t)=>{for(var o in t)co(e,o,{get:t[o],enumerable:!0})},Pn=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of dl(t))!ul.call(e,n)&&n!==o&&co(e,n,{get:()=>t[n],enumerable:!(r=cl(t,n))||r.enumerable});return e};var fl=(e,t,o)=>(o=e!=null?ll(pl(e)):{},Pn(t||!e||!e.__esModule?co(o,"default",{value:e,enumerable:!0}):o,e)),An=e=>Pn(co({},"__esModule",{value:!0}),e);var Eo=ke((b2,Co)=>{var di,pi,ui,fi,mi,hi,gi,bi,yi,vo,Er,vi,wi,Ci,bt,Ei,xi,_i,Li,Si,Pi,Ai,ki,Ti,wo;(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])};di=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)},pi=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},ui=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},fi=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},mi=function(r,n){return function(i,a){n(i,a,r)}},hi=function(r,n){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,n)},gi=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(g){try{u(a.next(g))}catch(b){d(b)}}function f(g){try{u(a.throw(g))}catch(b){d(b)}}function u(g){g.done?l(g.value):s(g.value).then(h,f)}u((a=a.apply(r,n||[])).next())})},bi=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(g){return f([u,g])}}function f(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(g){u=[6,g],s=0}finally{a=l=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}},yi=function(r,n){for(var i in r)i!=="default"&&!Object.prototype.hasOwnProperty.call(n,i)&&wo(n,r,i)},wo=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]},vo=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.")},Er=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},vi=function(){for(var r=[],n=0;n<arguments.length;n++)r=r.concat(Er(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,h=l.length;d<h;d++,s++)a[s]=l[d];return a},Ci=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))},bt=function(r){return this instanceof bt?(this.v=r,this):new bt(r)},Ei=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(y){return new Promise(function(_,W){l.push([c,y,_,W])>1||h(c,y)})})}function h(c,y){try{f(a[c](y))}catch(_){b(l[0][3],_)}}function f(c){c.value instanceof bt?Promise.resolve(c.value.v).then(u,g):b(l[0][2],c)}function u(c){h("next",c)}function g(c){h("throw",c)}function b(c,y){c(y),l.shift(),l.length&&h(l[0][0],l[0][1])}},xi=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:bt(r[s](d)),done:s==="return"}:l?l(d):d}:l}},_i=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 vo=="function"?vo(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,f){d=r[l](d),s(h,f,d.done,d.value)})}}function s(l,d,h,f){Promise.resolve(f).then(function(u){l({value:u,done:h})},d)}},Li=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};Si=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)&&wo(n,r,i);return o(n,r),n},Pi=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)},ki=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},Ti=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",di),e("__assign",pi),e("__rest",ui),e("__decorate",fi),e("__param",mi),e("__metadata",hi),e("__awaiter",gi),e("__generator",bi),e("__exportStar",yi),e("__createBinding",wo),e("__values",vo),e("__read",Er),e("__spread",vi),e("__spreadArrays",wi),e("__spreadArray",Ci),e("__await",bt),e("__asyncGenerator",Ei),e("__asyncDelegator",xi),e("__asyncValues",_i),e("__makeTemplateObject",Li),e("__importStar",Si),e("__importDefault",Pi),e("__classPrivateFieldGet",Ai),e("__classPrivateFieldSet",ki),e("__classPrivateFieldIn",Ti)})});var xr=ke(O=>{"use strict";Object.defineProperty(O,"__esModule",{value:!0});O.getLocalStorage=O.getLocalStorageOrThrow=O.getCrypto=O.getCryptoOrThrow=O.getLocation=O.getLocationOrThrow=O.getNavigator=O.getNavigatorOrThrow=O.getDocument=O.getDocumentOrThrow=O.getFromWindowOrThrow=O.getFromWindow=void 0;function Ye(e){let t;return typeof window<"u"&&typeof window[e]<"u"&&(t=window[e]),t}O.getFromWindow=Ye;function yt(e){let t=Ye(e);if(!t)throw new Error(`${e} is not defined in Window`);return t}O.getFromWindowOrThrow=yt;function Bl(){return yt("document")}O.getDocumentOrThrow=Bl;function Fl(){return Ye("document")}O.getDocument=Fl;function Gl(){return yt("navigator")}O.getNavigatorOrThrow=Gl;function Hl(){return Ye("navigator")}O.getNavigator=Hl;function Vl(){return yt("location")}O.getLocationOrThrow=Vl;function jl(){return Ye("location")}O.getLocation=jl;function $l(){return yt("crypto")}O.getCryptoOrThrow=$l;function zl(){return Ye("crypto")}O.getCrypto=zl;function ql(){return yt("localStorage")}O.getLocalStorageOrThrow=ql;function Zl(){return Ye("localStorage")}O.getLocalStorage=Zl});var Ri=ke(xo=>{"use strict";Object.defineProperty(xo,"__esModule",{value:!0});xo.getWindowMetadata=void 0;var Wi=xr();function Kl(){let e,t;try{e=Wi.getDocumentOrThrow(),t=Wi.getLocationOrThrow()}catch{return null}function o(){let f=e.getElementsByTagName("link"),u=[];for(let g=0;g<f.length;g++){let b=f[g],c=b.getAttribute("rel");if(c&&c.toLowerCase().indexOf("icon")>-1){let y=b.getAttribute("href");if(y)if(y.toLowerCase().indexOf("https:")===-1&&y.toLowerCase().indexOf("http:")===-1&&y.indexOf("//")!==0){let _=t.protocol+"//"+t.host;if(y.indexOf("/")===0)_+=y;else{let W=t.pathname.split("/");W.pop(),_+=W.join("/")+"/"+y}u.push(_)}else if(y.indexOf("//")===0){let _=t.protocol+y;u.push(_)}else u.push(y)}}return u}function r(...f){let u=e.getElementsByTagName("meta");for(let g=0;g<u.length;g++){let b=u[g],c=["itemprop","property","name"].map(y=>b.getAttribute(y)).filter(y=>y?f.includes(y):!1);if(c.length&&c){let y=b.getAttribute("content");if(y)return y}}return""}function n(){let f=r("name","og:site_name","og:title","twitter:title");return f||(f=e.title),f}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}}xo.getWindowMetadata=Kl});var Vi={};Sn(Vi,{BotInfo:()=>Ui,BrowserInfo:()=>Oi,NodeInfo:()=>Ni,ReactNativeInfo:()=>Bi,SearchBotDeviceInfo:()=>Di,browserName:()=>tc,detect:()=>ec,detectOS:()=>Gi,getNodeVersion:()=>Hi,parseUserAgent:()=>_r});function ec(e){return e?_r(e):typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new Bi:typeof navigator<"u"?_r(navigator.userAgent):Hi()}function Fi(e){return e!==""&&Ql.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 tc(e){var t=Fi(e);return t?t[0]:null}function _r(e){var t=Fi(e);if(!t)return null;var o=t[0],r=t[1];if(o==="searchbot")return new Ui;var n=r[1]&&r[1].split(/[._]/).slice(0,3);n?n.length<Ii&&(n=Jl(n,oc(Ii-n.length))):n=[];var i=n.join("."),a=Gi(e),s=Xl.exec(e);return s&&s[1]?new Di(o,i,a,s[1]):new Oi(o,i,a)}function Gi(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 Hi(){var e=typeof process<"u"&&process.version;return e?new Ni(process.version.slice(1)):null}function oc(e){for(var t=[],o=0;o<e;o++)t.push("0");return t}var Jl,Oi,Ni,Di,Ui,Bi,Yl,Xl,Ii,Ql,Mi,ji=Ln(()=>{Jl=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},Oi=function(){function e(t,o,r){this.name=t,this.version=o,this.os=r,this.type="browser"}return e}(),Ni=function(){function e(t){this.version=t,this.type="node",this.name="node",this.os=process.platform}return e}(),Di=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}(),Ui=function(){function e(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return e}(),Bi=function(){function e(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return e}(),Yl=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,Xl=/(nuhk|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,Ii=3,Ql=[["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",Yl]],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 Sr=ke(E=>{"use strict";Object.defineProperty(E,"__esModule",{value:!0});E.getClientMeta=E.getLocalStorage=E.getLocalStorageOrThrow=E.getCrypto=E.getCryptoOrThrow=E.getLocation=E.getLocationOrThrow=E.getNavigator=E.getNavigatorOrThrow=E.getDocument=E.getDocumentOrThrow=E.getFromWindowOrThrow=E.getFromWindow=E.isBrowser=E.isNode=E.isMobile=E.isIOS=E.isAndroid=E.detectOS=E.detectEnv=void 0;var $i=Eo(),rc=$i.__importStar(Ri()),me=$i.__importStar(xr()),nc=(ji(),An(Vi));function Lr(e){return(0,nc.detect)(e)}E.detectEnv=Lr;function _o(){let e=Lr();return e&&e.os?e.os:void 0}E.detectOS=_o;function zi(){let e=_o();return e?e.toLowerCase().includes("android"):!1}E.isAndroid=zi;function qi(){let e=_o();return e?e.toLowerCase().includes("ios")||e.toLowerCase().includes("mac")&&navigator.maxTouchPoints>1:!1}E.isIOS=qi;function ic(){return _o()?zi()||qi():!1}E.isMobile=ic;function Zi(){let e=Lr();return e&&e.name?e.name.toLowerCase()==="node":!1}E.isNode=Zi;function ac(){return!Zi()&&!!(0,E.getNavigator)()}E.isBrowser=ac;E.getFromWindow=me.getFromWindow;E.getFromWindowOrThrow=me.getFromWindowOrThrow;E.getDocumentOrThrow=me.getDocumentOrThrow;E.getDocument=me.getDocument;E.getNavigatorOrThrow=me.getNavigatorOrThrow;E.getNavigator=me.getNavigator;E.getLocationOrThrow=me.getLocationOrThrow;E.getLocation=me.getLocation;E.getCryptoOrThrow=me.getCryptoOrThrow;E.getCrypto=me.getCrypto;E.getLocalStorageOrThrow=me.getLocalStorageOrThrow;E.getLocalStorage=me.getLocalStorage;function sc(){return rc.getWindowMetadata()}E.getClientMeta=sc});var Ki={};Sn(Ki,{safeJsonParse:()=>lc,safeJsonStringify:()=>cc});function lc(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 cc(e){return typeof e=="string"?e:JSON.stringify(e)}var Ji=Ln(()=>{});var Pr=ke(vt=>{"use strict";Object.defineProperty(vt,"__esModule",{value:!0});vt.safeJsonStringify=vt.safeJsonParse=void 0;var dc=Eo(),Yi=dc.__importStar((Ji(),An(Ki)));vt.safeJsonParse=Yi.safeJsonParse;vt.safeJsonStringify=Yi.safeJsonStringify});var kr=ke(De=>{"use strict";Object.defineProperty(De,"__esModule",{value:!0});De.removeLocal=De.getLocal=De.setLocal=void 0;var Xi=Pr(),Ar=Sr();function pc(e,t){let o=(0,Xi.safeJsonStringify)(t),r=(0,Ar.getLocalStorage)();r&&r.setItem(e,o)}De.setLocal=pc;function uc(e){let t=null,o=null,r=(0,Ar.getLocalStorage)();return r&&(o=r.getItem(e)),t=o&&(0,Xi.safeJsonParse)(o),t}De.getLocal=uc;function fc(e){let t=(0,Ar.getLocalStorage)();t&&t.removeItem(e)}De.removeLocal=fc});var ea=ke(se=>{"use strict";Object.defineProperty(se,"__esModule",{value:!0});se.getMobileLinkRegistry=se.getMobileRegistryEntry=se.saveMobileLinkInfo=se.formatIOSMobile=se.mobileLinkChoiceKey=void 0;var mc=kr();se.mobileLinkChoiceKey="WALLETCONNECT_DEEPLINK_CHOICE";function hc(e,t){let o=encodeURIComponent(e);return t.universalLink?`${t.universalLink}/wc?uri=${o}`:t.deepLink?`${t.deepLink}${t.deepLink.endsWith(":")?"//":"/"}wc?uri=${o}`:""}se.formatIOSMobile=hc;function gc(e){let t=e.href.split("?")[0];(0,mc.setLocal)(se.mobileLinkChoiceKey,Object.assign(Object.assign({},e),{href:t}))}se.saveMobileLinkInfo=gc;function Qi(e,t){return e.filter(o=>o.name.toLowerCase().includes(t.toLowerCase()))[0]}se.getMobileRegistryEntry=Qi;function bc(e,t){let o=e;return t&&(o=t.map(r=>Qi(e,r)).filter(Boolean)),o}se.getMobileLinkRegistry=bc});var ra=ke(_e=>{"use strict";Object.defineProperty(_e,"__esModule",{value:!0});_e.formatMobileRegistry=_e.formatMobileRegistryEntry=_e.getDappRegistryUrl=_e.getWalletRegistryUrl=void 0;var ta="https://registry.walletconnect.com";function yc(){return ta+"/api/v2/wallets"}_e.getWalletRegistryUrl=yc;function vc(){return ta+"/api/v2/dapps"}_e.getDappRegistryUrl=vc;function oa(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=oa;function wc(e,t="mobile"){return Object.values(e).filter(o=>!!o[t].universal||!!o[t].native).map(o=>oa(o,t))}_e.formatMobileRegistry=wc});var na=ke(Xe=>{"use strict";Object.defineProperty(Xe,"__esModule",{value:!0});var jt=Eo();jt.__exportStar(Sr(),Xe);jt.__exportStar(Pr(),Xe);jt.__exportStar(kr(),Xe);jt.__exportStar(ea(),Xe);jt.__exportStar(ra(),Xe)});import{Web3Provider as Kp}from"@ethersproject/providers";import{useEffect as xn,useState as Q}from"react";var C=()=>{throw new Error("You need to wrap your application with the <PrivyProvider> initialized with your app id.")};import ml from"axios";var ye=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}]`:""}`}},ct=class extends ye{constructor(o,r,n,i){super(n,i);this.type=o;this.status=r}},v=class extends ye{constructor(o,r){super(o,r);this.type="client_error"}};var z=class extends ye{constructor(o,r){super(o,r);this.type="connector_error"}},q=e=>{if(e instanceof ye)return e;if(!ml.isAxiosError(e))return pe(e);if(!e.response)return new ct("api_error",null,e.message,e);let{type:t,message:o,error:r}=e.response.data;return new ct(t||"ApiError",e.response.status,o||r,e)},pe=e=>e instanceof ye?e:e instanceof Error?new v(e.message,e):new v(`Internal error: ${e}`);var kn=()=>"/api/v1/sessions",Tn=()=>"/api/v1/sessions/logout",Wn=()=>"/api/v1/sessions/fork",Rn=()=>"/api/v1/sessions/fork/recover",In=()=>"/api/v1/siwe/init",Mn=()=>"/api/v1/siwe/authenticate",On=()=>"/api/v1/siwe/link",Nn=()=>"/api/v1/passwordless/init",Dn=()=>"/api/v1/passwordless/authenticate",Un=()=>"/api/v1/passwordless/link",Bn=()=>"/api/v1/passwordless_sms/init",Fn=()=>"/api/v1/passwordless_sms/authenticate",Gn=()=>"/api/v1/passwordless_sms/link",Hn=()=>"/api/v1/oauth/init",Vn=()=>"/api/v1/oauth/authenticate",jn=()=>"/api/v1/oauth/link",$n=()=>"/api/v1/siwe/unlink",zn=()=>"/api/v1/passwordless/unlink",qn=()=>"/api/v1/passwordless_sms/unlink",Zn=()=>"/api/v1/oauth/unlink";var Gt=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=Dn(),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 q(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=Un();return(await this.api.post(t,{email:this.meta.email,code:this.meta.emailCode})).data}catch(t){throw q(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=Nn();return(await this.api.post(o,{email:this.meta.email})).data}catch(o){throw q(o)}}};var dt=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=Vn(),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 q(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=jn();return(await this.api.post(t,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode})).data}catch(t){throw q(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=Hn();return(await this.api.post(t,{provider:this.meta.provider,redirect_to:window.location.href})).data}catch(t){throw q(t)}}};var pt=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(Mn(),{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 q(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(On(),{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 q(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(In(),{address:o});return this.preparedMessage=this.walletConnector.prepareMessage(r,o,n.data.nonce),this.preparedMessage}};var Ht=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=Fn(),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 q(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=Gn();return(await this.api.post(t,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode})).data}catch(t){throw q(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=Bn();return(await this.api.post(o,{phoneNumber:this.meta.phoneNumber})).data}catch(o){throw q(o)}}};import{getAddress as _c}from"@ethersproject/address";var Kn="1.19.0-beta.6";var Jn="https://api.privy.io/v0",ur=process.env.NEXT_PUBLIC_PRIVY_AUTH_URL||"https://auth.privy.io",po="4df5e2316331463a9130964bd6078dfa",Yn=1e4,ue=1400,fr=Kn;var ut="privy:token",uo="privy:refresh_token",Vt="privy:session_transfer_token",fo="privy:connectors",mr="walletconnect",Xn=3e4;var hr=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)}},gr=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 gl(){return typeof window<"u"&&window.localStorage?new gr:new hr}var B=gl();import Ll from"@coinbase/wallet-sdk";import{getAddress as Sl}from"@ethersproject/address";import{jsx as Qn,jsxs as bl}from"react/jsx-runtime";var fe=({style:e,...t})=>bl("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:[Qn("rect",{width:"1024",height:"1024",fill:"#0052FF",rx:100,ry:100}),Qn("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 xl}from"@ethersproject/address";import{Web3Provider as _l}from"@ethersproject/providers";import{ErrorCode as yl}from"@ethersproject/logger";var ft=class extends z{constructor(){super("Wallet timeout");this.type="wallet_error"}},qe=class extends z{constructor(){super("User rejected connection");this.type="wallet_error"}},Ee=e=>{if(e instanceof z)return e;if((e==null?void 0:e.code)&&(e==null?void 0:e.reason)){let t=new mt(e);return e.code===yl.ACTION_REJECTED&&(t.details=ze.E4001_USER_REJECTED_REQUEST),t}return e!=null&&e.code?new mt(e):new z("Unknown connector error",e)},br=class extends ye{constructor(o,r,n){super(o);this.type="provider_error";this.code=r,this.data=n}},mt=class extends br{constructor(o){var i,a,s;let r=o;super(r.message,r.code,r.data);let n=Object.values(ze).find(l=>l.eipCode===r.code);this.details=n||ze.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=ze.E32002_CONNECTION_ALREADY_PENDING:this.details=ze.E32002_REQUEST_ALREADY_PENDING:(s=r.message)!=null&&s.includes("Already processing")&&r.message.includes("eth_requestAccounts")&&(this.details=ze.E32002_WALLET_LOCKED))}},vl={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}},wl={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}},Cl={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}},ze={UNKNOWN_ERROR:{eipCode:0,message:"Unknown error",detail:"Unknown error",retryable:!0},...Cl,...wl},Ze={...vl,...ze};var El=12e4,yr=(e=new ft,t=El)=>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 z(`A wallet request of type ${t.method} was made before setting a wallet provider.`);return Promise.race([this.walletProvider.request(t),yr()]).catch(o=>{throw Ee(o)})}},Ke=class extends xe{constructor(o){super(o)}},mo=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 Te=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}
|
|
@@ -436,7 +436,7 @@ Resources:
|
|
|
436
436
|
}
|
|
437
437
|
`,rd=Jt.span`
|
|
438
438
|
word-break: break-all;
|
|
439
|
-
`;import{useEffect as id,useState as ad}from"react";import sd from"styled-components";import{isMobile as nd}from"react-device-detect";var Oa=e=>{let t=new URL(window.location.href);if(!wt()&&nd)return`https://go.cb-w.com/dapp?cb_url=${encodeURIComponent(`${t.href.replace(/\/$/g,"")}?privy_wallet_client=coinbase_wallet${e?`&privy_token=${e}`:""}`)}`};import{Fragment as cd,jsx as ot,jsxs as Na}from"react/jsx-runtime";var Da=()=>{let{forkSession:e,ready:t,authenticated:o}=F(),{closePrivyModal:r}=T(),[n,i]=ad("");id(()=>{t&&o&&e().then(
|
|
439
|
+
`;import{useEffect as id,useState as ad}from"react";import sd from"styled-components";import{isMobile as nd}from"react-device-detect";var Oa=e=>{let t=new URL(window.location.href);if(!wt()&&nd)return`https://go.cb-w.com/dapp?cb_url=${encodeURIComponent(`${t.href.replace(/\/$/g,"")}?privy_wallet_client=coinbase_wallet${e?`&privy_token=${e}`:""}`)}`};import{Fragment as cd,jsx as ot,jsxs as Na}from"react/jsx-runtime";var Da=()=>{let{forkSession:e,ready:t,authenticated:o}=F(),{closePrivyModal:r}=T(),[n,i]=ad("");id(()=>{t&&o&&e().then(l=>i(l))},[o,t]);let a=Oa(n),s={title:"Redirecting to Coinbase Wallet",description:"We'll take you to the Coinbase Wallet app to continue your login experience.",footnote:""};return t&&o&&(s.description="For the best experience, we'll automatically log you into the Coinbase Wallet in-app browser.",s.footnote="Once you're done, you can always return here and refresh to view your updated account."),Na(cd,{children:[ot(S,{},"header"),ot(Oo,{title:s.title,description:s.description}),Na(Se,{children:[ot(ld,{children:ot(fe,{style:{width:"72px",height:"72px"}})}),ot(ma,{href:a,onClick:()=>{r()},loading:t&&o&&!n,children:"Continue"}),s.footnote?ot("p",{children:s.footnote}):null]}),ot(G,{protectedByPrivy:!0})]})},ld=sd(Ro)`
|
|
440
440
|
margin: 16px auto;
|
|
441
441
|
`;import{useEffect as qr,useState as Do}from"react";import{isMobile as Ua}from"react-device-detect";import Zr from"styled-components";import{Fragment as Fa,jsx as ie,jsxs as Bo}from"react/jsx-runtime";var Uo=2,Fo={metamask:{name:"MetaMask",component:ve},coinbase_wallet:{name:"Coinbase Wallet",component:fe},wallet_connect:{name:"WalletConnect",component:gt}},dd=e=>(e==null?void 0:e.status)===422?Ze.ERROR_USER_EXISTS:e instanceof mt&&!e.details.default?e.details:e instanceof ft?Ze.ERROR_TIMED_OUT:e instanceof qe?Ze.ERROR_USER_REJECTED_CONNECTION:Ze.ERROR_WALLET_CONNECTION,Ba=()=>{var H,D,V;let[e,t]=Do(!1),[o,r]=Do(void 0),{navigate:n,navigateBack:i}=w(),{getAuthFlow:a,walletConnectionStatus:s,closePrivyModal:l,loginWithWallet:d}=T(),{walletConnectors:h}=F(),[f,u]=Do(0),{user:g}=F(),[b]=Do((g==null?void 0:g.linkedAccounts.length)||0),c=a(),y=Ua&&(c==null?void 0:c.meta.walletType)==="wallet_connect"||Ua&&(c==null?void 0:c.meta.walletType)==="coinbase_wallet",_=s==null?void 0:s.connected;qr(()=>{!c||y||!_||k().catch(M=>console.warn("Auto-prompted signature failed",M))},[f,_]),qr(()=>{if(g&&e){let M=setTimeout(l,ue);return()=>clearTimeout(M)}},[g,e]);let W=M=>{if((M==null?void 0:M.status)===401&&(M==null?void 0:M.message)==="User is not allowed to login to this app."){n("ALLOWLIST_REJECTION_SCREEN");return}r(dd(M))};async function k(){try{await d(),t(!0)}catch(M){W(M)}}qr(()=>{s!=null&&s.connectError&&W(s==null?void 0:s.connectError)},[s]);let R=(c==null?void 0:c.meta.walletType)||"metamask",I=((H=c==null?void 0:c.meta)==null?void 0:H.walletName)||Fo[R].name,ee=((D=c==null?void 0:c.meta)==null?void 0:D.walletIcon)||Fo[R].component,he=e?`Successfully connected with ${I}`:o?o.message:_?"Sign to verify":`Waiting for ${I}`,U="Don\u2019t see your wallet modal? Check your other browser windows.";if(e){let M=(g==null?void 0:g.linkedAccounts.length)||0;b===M?U="Wallet was already linked.":U="You\u2019re good to go!"}else f>=Uo&&o?U="Unable to connect wallet":o?U=o.detail:_&&y?U="Sign the message in your wallet to verify it belongs to you.":R==="metamask"?U="For the best experience, connect only one wallet at a time.":R==="wallet_connect"?U="Open your mobile wallet app to continue":R==="coinbase_wallet"&&(wt()||(Or(g)?U="Continue with the Coinbase app. Not the right wallet? Reset your connection below.":U="Open the Coinbase app on your phone to continue."));let K=(V=h==null?void 0:h.walletConnectors)==null?void 0:V.find(M=>M.walletType==="coinbase_wallet"),ge=R==="coinbase_wallet"&&(Or(g)||o===Ze.ERROR_USER_EXISTS);return Bo(Fa,{children:[ie(S,{backFn:i}),Bo(pd,{children:[ie(Kr,{walletLogo:ee,success:e,fail:!!o}),Bo(ud,{children:[ie("h3",{children:he}),ie("p",{children:U})]}),ge?ie(ne,{onClick:()=>K&&(K==null?void 0:K.disconnect()),invisible:e,disabled:e,children:"Use a different wallet"}):o==Ze.ERROR_USER_EXISTS?ie(ne,{onClick:i,children:"Use a different wallet"}):_&&!e&&y?ie(ne,{onClick:k,children:"Sign with your wallet"}):!e&&(o==null?void 0:o.retryable)&&f<Uo?ie(ne,{onClick:()=>{u(f+1),r(void 0),s==null||s.connectRetry()},invisible:e||!(o!=null&&o.retryable)||f>=Uo,disabled:!e&&(!(o!=null&&o.retryable)||f>=Uo),children:"Retry"}):ie(ne,{"aria-hidden":"true",invisible:!0,children:"Placeholder"})]})]})},pd=Zr.div`
|
|
442
442
|
display: flex;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var pl=Object.create;var Ao=Object.defineProperty;var ul=Object.getOwnPropertyDescriptor;var fl=Object.getOwnPropertyNames;var ml=Object.getPrototypeOf,hl=Object.prototype.hasOwnProperty;var Bn=(e,t)=>()=>(e&&(t=e(e=0)),t);var Ye=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Mr=(e,t)=>{for(var o in t)Ao(e,o,{get:t[o],enumerable:!0})},Fn=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of fl(t))!hl.call(e,n)&&n!==o&&Ao(e,n,{get:()=>t[n],enumerable:!(r=ul(t,n))||r.enumerable});return e};var _=(e,t,o)=>(o=e!=null?pl(ml(e)):{},Fn(t||!e||!e.__esModule?Ao(o,"default",{value:e,enumerable:!0}):o,e)),Or=e=>Fn(Ao({},"__esModule",{value:!0}),e);var Ho=Ye((bp,Go)=>{var ki,Ti,Wi,Ri,Ii,Mi,Oi,Ni,Di,Bo,$r,Ui,Bi,Fi,Ft,Gi,Hi,Vi,ji,$i,zi,qi,Zi,Ki,Fo;(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 Go=="object"&&typeof Go.exports=="object"?e(o(t,o(Go.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])};ki=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)},Ti=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},Wi=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},Ri=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},Ii=function(r,n){return function(i,a){n(i,a,r)}},Mi=function(r,n){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,n)},Oi=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(g){try{u(a.next(g))}catch(b){d(b)}}function f(g){try{u(a.throw(g))}catch(b){d(b)}}function u(g){g.done?l(g.value):s(g.value).then(h,f)}u((a=a.apply(r,n||[])).next())})},Ni=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(g){return f([u,g])}}function f(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(g){u=[6,g],s=0}finally{a=l=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}},Di=function(r,n){for(var i in r)i!=="default"&&!Object.prototype.hasOwnProperty.call(n,i)&&Fo(n,r,i)},Fo=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]},Bo=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.")},$r=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},Ui=function(){for(var r=[],n=0;n<arguments.length;n++)r=r.concat($r(arguments[n]));return r},Bi=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},Fi=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))},Ft=function(r){return this instanceof Ft?(this.v=r,this):new Ft(r)},Gi=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(y){return new Promise(function(P,I){l.push([c,y,P,I])>1||h(c,y)})})}function h(c,y){try{f(a[c](y))}catch(P){b(l[0][3],P)}}function f(c){c.value instanceof Ft?Promise.resolve(c.value.v).then(u,g):b(l[0][2],c)}function u(c){h("next",c)}function g(c){h("throw",c)}function b(c,y){c(y),l.shift(),l.length&&h(l[0][0],l[0][1])}},Hi=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:Ft(r[s](d)),done:s==="return"}:l?l(d):d}:l}},Vi=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 Bo=="function"?Bo(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,f){d=r[l](d),s(h,f,d.done,d.value)})}}function s(l,d,h,f){Promise.resolve(f).then(function(u){l({value:u,done:h})},d)}},ji=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};$i=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)&&Fo(n,r,i);return o(n,r),n},zi=function(r){return r&&r.__esModule?r:{default:r}},qi=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)},Zi=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},Ki=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",ki),e("__assign",Ti),e("__rest",Wi),e("__decorate",Ri),e("__param",Ii),e("__metadata",Mi),e("__awaiter",Oi),e("__generator",Ni),e("__exportStar",Di),e("__createBinding",Fo),e("__values",Bo),e("__read",$r),e("__spread",Ui),e("__spreadArrays",Bi),e("__spreadArray",Fi),e("__await",Ft),e("__asyncGenerator",Gi),e("__asyncDelegator",Hi),e("__asyncValues",Vi),e("__makeTemplateObject",ji),e("__importStar",$i),e("__importDefault",zi),e("__classPrivateFieldGet",qi),e("__classPrivateFieldSet",Zi),e("__classPrivateFieldIn",Ki)})});var zr=Ye(U=>{"use strict";Object.defineProperty(U,"__esModule",{value:!0});U.getLocalStorage=U.getLocalStorageOrThrow=U.getCrypto=U.getCryptoOrThrow=U.getLocation=U.getLocationOrThrow=U.getNavigator=U.getNavigatorOrThrow=U.getDocument=U.getDocumentOrThrow=U.getFromWindowOrThrow=U.getFromWindow=void 0;function Ct(e){let t;return typeof window<"u"&&typeof window[e]<"u"&&(t=window[e]),t}U.getFromWindow=Ct;function Gt(e){let t=Ct(e);if(!t)throw new Error(`${e} is not defined in Window`);return t}U.getFromWindowOrThrow=Gt;function _l(){return Gt("document")}U.getDocumentOrThrow=_l;function Ll(){return Ct("document")}U.getDocument=Ll;function Sl(){return Gt("navigator")}U.getNavigatorOrThrow=Sl;function Pl(){return Ct("navigator")}U.getNavigator=Pl;function Al(){return Gt("location")}U.getLocationOrThrow=Al;function kl(){return Ct("location")}U.getLocation=kl;function Tl(){return Gt("crypto")}U.getCryptoOrThrow=Tl;function Wl(){return Ct("crypto")}U.getCrypto=Wl;function Rl(){return Gt("localStorage")}U.getLocalStorageOrThrow=Rl;function Il(){return Ct("localStorage")}U.getLocalStorage=Il});var Yi=Ye(Vo=>{"use strict";Object.defineProperty(Vo,"__esModule",{value:!0});Vo.getWindowMetadata=void 0;var Ji=zr();function Ml(){let e,t;try{e=Ji.getDocumentOrThrow(),t=Ji.getLocationOrThrow()}catch{return null}function o(){let f=e.getElementsByTagName("link"),u=[];for(let g=0;g<f.length;g++){let b=f[g],c=b.getAttribute("rel");if(c&&c.toLowerCase().indexOf("icon")>-1){let y=b.getAttribute("href");if(y)if(y.toLowerCase().indexOf("https:")===-1&&y.toLowerCase().indexOf("http:")===-1&&y.indexOf("//")!==0){let P=t.protocol+"//"+t.host;if(y.indexOf("/")===0)P+=y;else{let I=t.pathname.split("/");I.pop(),P+=I.join("/")+"/"+y}u.push(P)}else if(y.indexOf("//")===0){let P=t.protocol+y;u.push(P)}else u.push(y)}}return u}function r(...f){let u=e.getElementsByTagName("meta");for(let g=0;g<u.length;g++){let b=u[g],c=["itemprop","property","name"].map(y=>b.getAttribute(y)).filter(y=>y?f.includes(y):!1);if(c.length&&c){let y=b.getAttribute("content");if(y)return y}}return""}function n(){let f=r("name","og:site_name","og:title","twitter:title");return f||(f=e.title),f}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}}Vo.getWindowMetadata=Ml});var la={};Mr(la,{BotInfo:()=>ra,BrowserInfo:()=>ea,NodeInfo:()=>ta,ReactNativeInfo:()=>na,SearchBotDeviceInfo:()=>oa,browserName:()=>Fl,detect:()=>Bl,detectOS:()=>aa,getNodeVersion:()=>sa,parseUserAgent:()=>qr});function Bl(e){return e?qr(e):typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new na:typeof navigator<"u"?qr(navigator.userAgent):sa()}function ia(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=ia(e);return t?t[0]:null}function qr(e){var t=ia(e);if(!t)return null;var o=t[0],r=t[1];if(o==="searchbot")return new ra;var n=r[1]&&r[1].split(/[._]/).slice(0,3);n?n.length<Xi&&(n=Ol(n,Gl(Xi-n.length))):n=[];var i=n.join("."),a=aa(e),s=Dl.exec(e);return s&&s[1]?new oa(o,i,a,s[1]):new ea(o,i,a)}function aa(e){for(var t=0,o=Qi.length;t<o;t++){var r=Qi[t],n=r[0],i=r[1],a=i.exec(e);if(a)return n}return null}function sa(){var e=typeof process<"u"&&process.version;return e?new ta(process.version.slice(1)):null}function Gl(e){for(var t=[],o=0;o<e;o++)t.push("0");return t}var Ol,ea,ta,oa,ra,na,Nl,Dl,Xi,Ul,Qi,ca=Bn(()=>{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},ea=function(){function e(t,o,r){this.name=t,this.version=o,this.os=r,this.type="browser"}return e}(),ta=function(){function e(t){this.version=t,this.type="node",this.name="node",this.os=process.platform}return e}(),oa=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}(),ra=function(){function e(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return e}(),na=function(){function e(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return e}(),Nl=/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)/,Xi=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",Nl]],Qi=[["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 Kr=Ye(L=>{"use strict";Object.defineProperty(L,"__esModule",{value:!0});L.getClientMeta=L.getLocalStorage=L.getLocalStorageOrThrow=L.getCrypto=L.getCryptoOrThrow=L.getLocation=L.getLocationOrThrow=L.getNavigator=L.getNavigatorOrThrow=L.getDocument=L.getDocumentOrThrow=L.getFromWindowOrThrow=L.getFromWindow=L.isBrowser=L.isNode=L.isMobile=L.isIOS=L.isAndroid=L.detectOS=L.detectEnv=void 0;var da=Ho(),Hl=da.__importStar(Yi()),Se=da.__importStar(zr()),Vl=(ca(),Or(la));function Zr(e){return(0,Vl.detect)(e)}L.detectEnv=Zr;function jo(){let e=Zr();return e&&e.os?e.os:void 0}L.detectOS=jo;function pa(){let e=jo();return e?e.toLowerCase().includes("android"):!1}L.isAndroid=pa;function ua(){let e=jo();return e?e.toLowerCase().includes("ios")||e.toLowerCase().includes("mac")&&navigator.maxTouchPoints>1:!1}L.isIOS=ua;function jl(){return jo()?pa()||ua():!1}L.isMobile=jl;function fa(){let e=Zr();return e&&e.name?e.name.toLowerCase()==="node":!1}L.isNode=fa;function $l(){return!fa()&&!!(0,L.getNavigator)()}L.isBrowser=$l;L.getFromWindow=Se.getFromWindow;L.getFromWindowOrThrow=Se.getFromWindowOrThrow;L.getDocumentOrThrow=Se.getDocumentOrThrow;L.getDocument=Se.getDocument;L.getNavigatorOrThrow=Se.getNavigatorOrThrow;L.getNavigator=Se.getNavigator;L.getLocationOrThrow=Se.getLocationOrThrow;L.getLocation=Se.getLocation;L.getCryptoOrThrow=Se.getCryptoOrThrow;L.getCrypto=Se.getCrypto;L.getLocalStorageOrThrow=Se.getLocalStorageOrThrow;L.getLocalStorage=Se.getLocalStorage;function zl(){return Hl.getWindowMetadata()}L.getClientMeta=zl});var ma={};Mr(ma,{safeJsonParse:()=>ql,safeJsonStringify:()=>Zl});function ql(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 Zl(e){return typeof e=="string"?e:JSON.stringify(e)}var ha=Bn(()=>{});var Jr=Ye(Ht=>{"use strict";Object.defineProperty(Ht,"__esModule",{value:!0});Ht.safeJsonStringify=Ht.safeJsonParse=void 0;var Kl=Ho(),ga=Kl.__importStar((ha(),Or(ma)));Ht.safeJsonParse=ga.safeJsonParse;Ht.safeJsonStringify=ga.safeJsonStringify});var Xr=Ye(it=>{"use strict";Object.defineProperty(it,"__esModule",{value:!0});it.removeLocal=it.getLocal=it.setLocal=void 0;var ba=Jr(),Yr=Kr();function Jl(e,t){let o=(0,ba.safeJsonStringify)(t),r=(0,Yr.getLocalStorage)();r&&r.setItem(e,o)}it.setLocal=Jl;function Yl(e){let t=null,o=null,r=(0,Yr.getLocalStorage)();return r&&(o=r.getItem(e)),t=o&&(0,ba.safeJsonParse)(o),t}it.getLocal=Yl;function Xl(e){let t=(0,Yr.getLocalStorage)();t&&t.removeItem(e)}it.removeLocal=Xl});var va=Ye(he=>{"use strict";Object.defineProperty(he,"__esModule",{value:!0});he.getMobileLinkRegistry=he.getMobileRegistryEntry=he.saveMobileLinkInfo=he.formatIOSMobile=he.mobileLinkChoiceKey=void 0;var Ql=Xr();he.mobileLinkChoiceKey="WALLETCONNECT_DEEPLINK_CHOICE";function ec(e,t){let o=encodeURIComponent(e);return t.universalLink?`${t.universalLink}/wc?uri=${o}`:t.deepLink?`${t.deepLink}${t.deepLink.endsWith(":")?"//":"/"}wc?uri=${o}`:""}he.formatIOSMobile=ec;function tc(e){let t=e.href.split("?")[0];(0,Ql.setLocal)(he.mobileLinkChoiceKey,Object.assign(Object.assign({},e),{href:t}))}he.saveMobileLinkInfo=tc;function ya(e,t){return e.filter(o=>o.name.toLowerCase().includes(t.toLowerCase()))[0]}he.getMobileRegistryEntry=ya;function oc(e,t){let o=e;return t&&(o=t.map(r=>ya(e,r)).filter(Boolean)),o}he.getMobileLinkRegistry=oc});var Ea=Ye(ze=>{"use strict";Object.defineProperty(ze,"__esModule",{value:!0});ze.formatMobileRegistry=ze.formatMobileRegistryEntry=ze.getDappRegistryUrl=ze.getWalletRegistryUrl=void 0;var wa="https://registry.walletconnect.com";function rc(){return wa+"/api/v2/wallets"}ze.getWalletRegistryUrl=rc;function nc(){return wa+"/api/v2/dapps"}ze.getDappRegistryUrl=nc;function Ca(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||""}}ze.formatMobileRegistryEntry=Ca;function ic(e,t="mobile"){return Object.values(e).filter(o=>!!o[t].universal||!!o[t].native).map(o=>Ca(o,t))}ze.formatMobileRegistry=ic});var xa=Ye(Et=>{"use strict";Object.defineProperty(Et,"__esModule",{value:!0});var mo=Ho();mo.__exportStar(Kr(),Et);mo.__exportStar(Jr(),Et);mo.__exportStar(Xr(),Et);mo.__exportStar(va(),Et);mo.__exportStar(Ea(),Et)});var b1={};Mr(b1,{AsExternalProvider:()=>nt,ConnectorManager:()=>Vt,PrivyClient:()=>$t,PrivyProvider:()=>al,PrivyProxyProvider:()=>Me,VERSION:()=>To,WalletConnector:()=>$e,getAccessToken:()=>il,usePrivy:()=>H});module.exports=Or(b1);var nl=require("@ethersproject/providers"),Y=require("react");var x=()=>{throw new Error("You need to wrap your application with the <PrivyProvider> initialized with your app id.")};var Gn=_(require("axios")),Ie=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}]`:""}`}},It=class extends Ie{constructor(o,r,n,i){super(n,i);this.type=o;this.status=r}},C=class extends Ie{constructor(o,r){super(o,r);this.type="client_error"}};var Q=class extends Ie{constructor(o,r){super(o,r);this.type="connector_error"}},ee=e=>{if(e instanceof Ie)return e;if(!Gn.default.isAxiosError(e))return xe(e);if(!e.response)return new It("api_error",null,e.message,e);let{type:t,message:o,error:r}=e.response.data;return new It(t||"ApiError",e.response.status,o||r,e)},xe=e=>e instanceof Ie?e:e instanceof Error?new C(e.message,e):new C(`Internal error: ${e}`);var Hn=()=>"/api/v1/sessions",Vn=()=>"/api/v1/sessions/logout",jn=()=>"/api/v1/sessions/fork",$n=()=>"/api/v1/sessions/fork/recover",zn=()=>"/api/v1/siwe/init",qn=()=>"/api/v1/siwe/authenticate",Zn=()=>"/api/v1/siwe/link",Kn=()=>"/api/v1/passwordless/init",Jn=()=>"/api/v1/passwordless/authenticate",Yn=()=>"/api/v1/passwordless/link",Xn=()=>"/api/v1/passwordless_sms/init",Qn=()=>"/api/v1/passwordless_sms/authenticate",ei=()=>"/api/v1/passwordless_sms/link",ti=()=>"/api/v1/oauth/init",oi=()=>"/api/v1/oauth/authenticate",ri=()=>"/api/v1/oauth/link",ni=()=>"/api/v1/siwe/unlink",ii=()=>"/api/v1/passwordless/unlink",ai=()=>"/api/v1/passwordless_sms/unlink",si=()=>"/api/v1/oauth/unlink";var co=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=Jn(),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 ee(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=Yn();return(await this.api.post(t,{email:this.meta.email,code:this.meta.emailCode})).data}catch(t){throw ee(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=Kn();return(await this.api.post(o,{email:this.meta.email})).data}catch(o){throw ee(o)}}};var Mt=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=oi(),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 ee(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=ri();return(await this.api.post(t,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode})).data}catch(t){throw ee(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=ti();return(await this.api.post(t,{provider:this.meta.provider,redirect_to:window.location.href})).data}catch(t){throw ee(t)}}};var Ot=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(qn(),{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 ee(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(Zn(),{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 ee(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(zn(),{address:o});return this.preparedMessage=this.walletConnector.prepareMessage(r,o,n.data.nonce),this.preparedMessage}};var po=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=Qn(),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 ee(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=ei();return(await this.api.post(t,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode})).data}catch(t){throw ee(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=Xn();return(await this.api.post(o,{phoneNumber:this.meta.phoneNumber})).data}catch(o){throw ee(o)}}};var Ta=require("@ethersproject/address");var li="1.19.0-beta.5";var ci="https://api.privy.io/v0",Nr=process.env.NEXT_PUBLIC_PRIVY_AUTH_URL||"https://auth.privy.io",ko="4df5e2316331463a9130964bd6078dfa",di=1e4,_e=1400,To=li;var Nt="privy:token",Wo="privy:refresh_token",uo="privy:session_transfer_token",Ro="privy:connectors",Dr="walletconnect",pi=3e4;var Ur=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)}},Br=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 bl(){return typeof window<"u"&&window.localStorage?new Br:new Ur}var $=bl();var hi=_(require("@coinbase/wallet-sdk")),gi=require("@ethersproject/address");var fo=require("react/jsx-runtime"),Le=({style:e,...t})=>(0,fo.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,fo.jsx)("rect",{width:"1024",height:"1024",fill:"#0052FF",rx:100,ry:100}),(0,fo.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 fi=require("@ethersproject/address"),mi=require("@ethersproject/providers");var ui=require("@ethersproject/logger");var Dt=class extends Q{constructor(){super("Wallet timeout");this.type="wallet_error"}},yt=class extends Q{constructor(){super("User rejected connection");this.type="wallet_error"}},je=e=>{if(e instanceof Q)return e;if((e==null?void 0:e.code)&&(e==null?void 0:e.reason)){let t=new Ut(e);return e.code===ui.ErrorCode.ACTION_REJECTED&&(t.details=bt.E4001_USER_REJECTED_REQUEST),t}return e!=null&&e.code?new Ut(e):new Q("Unknown connector error",e)},Fr=class extends Ie{constructor(o,r,n){super(o);this.type="provider_error";this.code=r,this.data=n}},Ut=class extends Fr{constructor(o){var i,a,s;let r=o;super(r.message,r.code,r.data);let n=Object.values(bt).find(l=>l.eipCode===r.code);this.details=n||bt.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=bt.E32002_CONNECTION_ALREADY_PENDING:this.details=bt.E32002_REQUEST_ALREADY_PENDING:(s=r.message)!=null&&s.includes("Already processing")&&r.message.includes("eth_requestAccounts")&&(this.details=bt.E32002_WALLET_LOCKED))}},yl={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}},vl={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}},wl={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}},bt={UNKNOWN_ERROR:{eipCode:0,message:"Unknown error",detail:"Unknown error",retryable:!0},...wl,...vl},vt={...yl,...bt};var Cl=12e4,Gr=(e=new Dt,t=Cl)=>new Promise((o,r)=>setTimeout(()=>{r(e)},t)),Me=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 Q(`A wallet request of type ${t.method} was made before setting a wallet provider.`);return Promise.race([this.walletProvider.request(t),Gr()]).catch(o=>{throw je(o)})}},nt=class extends Me{constructor(o){super(o)}},Io=class extends Me{constructor(t){super(t)}sendAsync(t,o){throw new Error("sendAsync is no longer supported by EIP-1193. Use the request method instead.")}};var $e=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 pl=Object.create;var Ao=Object.defineProperty;var ul=Object.getOwnPropertyDescriptor;var fl=Object.getOwnPropertyNames;var ml=Object.getPrototypeOf,hl=Object.prototype.hasOwnProperty;var Bn=(e,t)=>()=>(e&&(t=e(e=0)),t);var Ye=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Mr=(e,t)=>{for(var o in t)Ao(e,o,{get:t[o],enumerable:!0})},Fn=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of fl(t))!hl.call(e,n)&&n!==o&&Ao(e,n,{get:()=>t[n],enumerable:!(r=ul(t,n))||r.enumerable});return e};var _=(e,t,o)=>(o=e!=null?pl(ml(e)):{},Fn(t||!e||!e.__esModule?Ao(o,"default",{value:e,enumerable:!0}):o,e)),Or=e=>Fn(Ao({},"__esModule",{value:!0}),e);var Ho=Ye((bp,Go)=>{var ki,Ti,Wi,Ri,Ii,Mi,Oi,Ni,Di,Bo,$r,Ui,Bi,Fi,Ft,Gi,Hi,Vi,ji,$i,zi,qi,Zi,Ki,Fo;(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 Go=="object"&&typeof Go.exports=="object"?e(o(t,o(Go.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])};ki=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)},Ti=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},Wi=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},Ri=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},Ii=function(r,n){return function(i,a){n(i,a,r)}},Mi=function(r,n){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,n)},Oi=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(g){try{u(a.next(g))}catch(b){d(b)}}function f(g){try{u(a.throw(g))}catch(b){d(b)}}function u(g){g.done?l(g.value):s(g.value).then(h,f)}u((a=a.apply(r,n||[])).next())})},Ni=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(g){return f([u,g])}}function f(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(g){u=[6,g],s=0}finally{a=l=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}},Di=function(r,n){for(var i in r)i!=="default"&&!Object.prototype.hasOwnProperty.call(n,i)&&Fo(n,r,i)},Fo=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]},Bo=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.")},$r=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},Ui=function(){for(var r=[],n=0;n<arguments.length;n++)r=r.concat($r(arguments[n]));return r},Bi=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},Fi=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))},Ft=function(r){return this instanceof Ft?(this.v=r,this):new Ft(r)},Gi=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(y){return new Promise(function(P,I){l.push([c,y,P,I])>1||h(c,y)})})}function h(c,y){try{f(a[c](y))}catch(P){b(l[0][3],P)}}function f(c){c.value instanceof Ft?Promise.resolve(c.value.v).then(u,g):b(l[0][2],c)}function u(c){h("next",c)}function g(c){h("throw",c)}function b(c,y){c(y),l.shift(),l.length&&h(l[0][0],l[0][1])}},Hi=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:Ft(r[s](d)),done:s==="return"}:l?l(d):d}:l}},Vi=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 Bo=="function"?Bo(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,f){d=r[l](d),s(h,f,d.done,d.value)})}}function s(l,d,h,f){Promise.resolve(f).then(function(u){l({value:u,done:h})},d)}},ji=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};$i=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)&&Fo(n,r,i);return o(n,r),n},zi=function(r){return r&&r.__esModule?r:{default:r}},qi=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)},Zi=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},Ki=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",ki),e("__assign",Ti),e("__rest",Wi),e("__decorate",Ri),e("__param",Ii),e("__metadata",Mi),e("__awaiter",Oi),e("__generator",Ni),e("__exportStar",Di),e("__createBinding",Fo),e("__values",Bo),e("__read",$r),e("__spread",Ui),e("__spreadArrays",Bi),e("__spreadArray",Fi),e("__await",Ft),e("__asyncGenerator",Gi),e("__asyncDelegator",Hi),e("__asyncValues",Vi),e("__makeTemplateObject",ji),e("__importStar",$i),e("__importDefault",zi),e("__classPrivateFieldGet",qi),e("__classPrivateFieldSet",Zi),e("__classPrivateFieldIn",Ki)})});var zr=Ye(U=>{"use strict";Object.defineProperty(U,"__esModule",{value:!0});U.getLocalStorage=U.getLocalStorageOrThrow=U.getCrypto=U.getCryptoOrThrow=U.getLocation=U.getLocationOrThrow=U.getNavigator=U.getNavigatorOrThrow=U.getDocument=U.getDocumentOrThrow=U.getFromWindowOrThrow=U.getFromWindow=void 0;function Ct(e){let t;return typeof window<"u"&&typeof window[e]<"u"&&(t=window[e]),t}U.getFromWindow=Ct;function Gt(e){let t=Ct(e);if(!t)throw new Error(`${e} is not defined in Window`);return t}U.getFromWindowOrThrow=Gt;function _l(){return Gt("document")}U.getDocumentOrThrow=_l;function Ll(){return Ct("document")}U.getDocument=Ll;function Sl(){return Gt("navigator")}U.getNavigatorOrThrow=Sl;function Pl(){return Ct("navigator")}U.getNavigator=Pl;function Al(){return Gt("location")}U.getLocationOrThrow=Al;function kl(){return Ct("location")}U.getLocation=kl;function Tl(){return Gt("crypto")}U.getCryptoOrThrow=Tl;function Wl(){return Ct("crypto")}U.getCrypto=Wl;function Rl(){return Gt("localStorage")}U.getLocalStorageOrThrow=Rl;function Il(){return Ct("localStorage")}U.getLocalStorage=Il});var Yi=Ye(Vo=>{"use strict";Object.defineProperty(Vo,"__esModule",{value:!0});Vo.getWindowMetadata=void 0;var Ji=zr();function Ml(){let e,t;try{e=Ji.getDocumentOrThrow(),t=Ji.getLocationOrThrow()}catch{return null}function o(){let f=e.getElementsByTagName("link"),u=[];for(let g=0;g<f.length;g++){let b=f[g],c=b.getAttribute("rel");if(c&&c.toLowerCase().indexOf("icon")>-1){let y=b.getAttribute("href");if(y)if(y.toLowerCase().indexOf("https:")===-1&&y.toLowerCase().indexOf("http:")===-1&&y.indexOf("//")!==0){let P=t.protocol+"//"+t.host;if(y.indexOf("/")===0)P+=y;else{let I=t.pathname.split("/");I.pop(),P+=I.join("/")+"/"+y}u.push(P)}else if(y.indexOf("//")===0){let P=t.protocol+y;u.push(P)}else u.push(y)}}return u}function r(...f){let u=e.getElementsByTagName("meta");for(let g=0;g<u.length;g++){let b=u[g],c=["itemprop","property","name"].map(y=>b.getAttribute(y)).filter(y=>y?f.includes(y):!1);if(c.length&&c){let y=b.getAttribute("content");if(y)return y}}return""}function n(){let f=r("name","og:site_name","og:title","twitter:title");return f||(f=e.title),f}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}}Vo.getWindowMetadata=Ml});var la={};Mr(la,{BotInfo:()=>ra,BrowserInfo:()=>ea,NodeInfo:()=>ta,ReactNativeInfo:()=>na,SearchBotDeviceInfo:()=>oa,browserName:()=>Fl,detect:()=>Bl,detectOS:()=>aa,getNodeVersion:()=>sa,parseUserAgent:()=>qr});function Bl(e){return e?qr(e):typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new na:typeof navigator<"u"?qr(navigator.userAgent):sa()}function ia(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=ia(e);return t?t[0]:null}function qr(e){var t=ia(e);if(!t)return null;var o=t[0],r=t[1];if(o==="searchbot")return new ra;var n=r[1]&&r[1].split(/[._]/).slice(0,3);n?n.length<Xi&&(n=Ol(n,Gl(Xi-n.length))):n=[];var i=n.join("."),a=aa(e),s=Dl.exec(e);return s&&s[1]?new oa(o,i,a,s[1]):new ea(o,i,a)}function aa(e){for(var t=0,o=Qi.length;t<o;t++){var r=Qi[t],n=r[0],i=r[1],a=i.exec(e);if(a)return n}return null}function sa(){var e=typeof process<"u"&&process.version;return e?new ta(process.version.slice(1)):null}function Gl(e){for(var t=[],o=0;o<e;o++)t.push("0");return t}var Ol,ea,ta,oa,ra,na,Nl,Dl,Xi,Ul,Qi,ca=Bn(()=>{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},ea=function(){function e(t,o,r){this.name=t,this.version=o,this.os=r,this.type="browser"}return e}(),ta=function(){function e(t){this.version=t,this.type="node",this.name="node",this.os=process.platform}return e}(),oa=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}(),ra=function(){function e(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return e}(),na=function(){function e(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return e}(),Nl=/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)/,Xi=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",Nl]],Qi=[["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 Kr=Ye(L=>{"use strict";Object.defineProperty(L,"__esModule",{value:!0});L.getClientMeta=L.getLocalStorage=L.getLocalStorageOrThrow=L.getCrypto=L.getCryptoOrThrow=L.getLocation=L.getLocationOrThrow=L.getNavigator=L.getNavigatorOrThrow=L.getDocument=L.getDocumentOrThrow=L.getFromWindowOrThrow=L.getFromWindow=L.isBrowser=L.isNode=L.isMobile=L.isIOS=L.isAndroid=L.detectOS=L.detectEnv=void 0;var da=Ho(),Hl=da.__importStar(Yi()),Se=da.__importStar(zr()),Vl=(ca(),Or(la));function Zr(e){return(0,Vl.detect)(e)}L.detectEnv=Zr;function jo(){let e=Zr();return e&&e.os?e.os:void 0}L.detectOS=jo;function pa(){let e=jo();return e?e.toLowerCase().includes("android"):!1}L.isAndroid=pa;function ua(){let e=jo();return e?e.toLowerCase().includes("ios")||e.toLowerCase().includes("mac")&&navigator.maxTouchPoints>1:!1}L.isIOS=ua;function jl(){return jo()?pa()||ua():!1}L.isMobile=jl;function fa(){let e=Zr();return e&&e.name?e.name.toLowerCase()==="node":!1}L.isNode=fa;function $l(){return!fa()&&!!(0,L.getNavigator)()}L.isBrowser=$l;L.getFromWindow=Se.getFromWindow;L.getFromWindowOrThrow=Se.getFromWindowOrThrow;L.getDocumentOrThrow=Se.getDocumentOrThrow;L.getDocument=Se.getDocument;L.getNavigatorOrThrow=Se.getNavigatorOrThrow;L.getNavigator=Se.getNavigator;L.getLocationOrThrow=Se.getLocationOrThrow;L.getLocation=Se.getLocation;L.getCryptoOrThrow=Se.getCryptoOrThrow;L.getCrypto=Se.getCrypto;L.getLocalStorageOrThrow=Se.getLocalStorageOrThrow;L.getLocalStorage=Se.getLocalStorage;function zl(){return Hl.getWindowMetadata()}L.getClientMeta=zl});var ma={};Mr(ma,{safeJsonParse:()=>ql,safeJsonStringify:()=>Zl});function ql(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 Zl(e){return typeof e=="string"?e:JSON.stringify(e)}var ha=Bn(()=>{});var Jr=Ye(Ht=>{"use strict";Object.defineProperty(Ht,"__esModule",{value:!0});Ht.safeJsonStringify=Ht.safeJsonParse=void 0;var Kl=Ho(),ga=Kl.__importStar((ha(),Or(ma)));Ht.safeJsonParse=ga.safeJsonParse;Ht.safeJsonStringify=ga.safeJsonStringify});var Xr=Ye(it=>{"use strict";Object.defineProperty(it,"__esModule",{value:!0});it.removeLocal=it.getLocal=it.setLocal=void 0;var ba=Jr(),Yr=Kr();function Jl(e,t){let o=(0,ba.safeJsonStringify)(t),r=(0,Yr.getLocalStorage)();r&&r.setItem(e,o)}it.setLocal=Jl;function Yl(e){let t=null,o=null,r=(0,Yr.getLocalStorage)();return r&&(o=r.getItem(e)),t=o&&(0,ba.safeJsonParse)(o),t}it.getLocal=Yl;function Xl(e){let t=(0,Yr.getLocalStorage)();t&&t.removeItem(e)}it.removeLocal=Xl});var va=Ye(he=>{"use strict";Object.defineProperty(he,"__esModule",{value:!0});he.getMobileLinkRegistry=he.getMobileRegistryEntry=he.saveMobileLinkInfo=he.formatIOSMobile=he.mobileLinkChoiceKey=void 0;var Ql=Xr();he.mobileLinkChoiceKey="WALLETCONNECT_DEEPLINK_CHOICE";function ec(e,t){let o=encodeURIComponent(e);return t.universalLink?`${t.universalLink}/wc?uri=${o}`:t.deepLink?`${t.deepLink}${t.deepLink.endsWith(":")?"//":"/"}wc?uri=${o}`:""}he.formatIOSMobile=ec;function tc(e){let t=e.href.split("?")[0];(0,Ql.setLocal)(he.mobileLinkChoiceKey,Object.assign(Object.assign({},e),{href:t}))}he.saveMobileLinkInfo=tc;function ya(e,t){return e.filter(o=>o.name.toLowerCase().includes(t.toLowerCase()))[0]}he.getMobileRegistryEntry=ya;function oc(e,t){let o=e;return t&&(o=t.map(r=>ya(e,r)).filter(Boolean)),o}he.getMobileLinkRegistry=oc});var Ea=Ye(ze=>{"use strict";Object.defineProperty(ze,"__esModule",{value:!0});ze.formatMobileRegistry=ze.formatMobileRegistryEntry=ze.getDappRegistryUrl=ze.getWalletRegistryUrl=void 0;var wa="https://registry.walletconnect.com";function rc(){return wa+"/api/v2/wallets"}ze.getWalletRegistryUrl=rc;function nc(){return wa+"/api/v2/dapps"}ze.getDappRegistryUrl=nc;function Ca(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||""}}ze.formatMobileRegistryEntry=Ca;function ic(e,t="mobile"){return Object.values(e).filter(o=>!!o[t].universal||!!o[t].native).map(o=>Ca(o,t))}ze.formatMobileRegistry=ic});var xa=Ye(Et=>{"use strict";Object.defineProperty(Et,"__esModule",{value:!0});var mo=Ho();mo.__exportStar(Kr(),Et);mo.__exportStar(Jr(),Et);mo.__exportStar(Xr(),Et);mo.__exportStar(va(),Et);mo.__exportStar(Ea(),Et)});var b1={};Mr(b1,{AsExternalProvider:()=>nt,ConnectorManager:()=>Vt,PrivyClient:()=>$t,PrivyProvider:()=>al,PrivyProxyProvider:()=>Me,VERSION:()=>To,WalletConnector:()=>$e,getAccessToken:()=>il,usePrivy:()=>H});module.exports=Or(b1);var nl=require("@ethersproject/providers"),Y=require("react");var x=()=>{throw new Error("You need to wrap your application with the <PrivyProvider> initialized with your app id.")};var Gn=_(require("axios")),Ie=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}]`:""}`}},It=class extends Ie{constructor(o,r,n,i){super(n,i);this.type=o;this.status=r}},C=class extends Ie{constructor(o,r){super(o,r);this.type="client_error"}};var Q=class extends Ie{constructor(o,r){super(o,r);this.type="connector_error"}},ee=e=>{if(e instanceof Ie)return e;if(!Gn.default.isAxiosError(e))return xe(e);if(!e.response)return new It("api_error",null,e.message,e);let{type:t,message:o,error:r}=e.response.data;return new It(t||"ApiError",e.response.status,o||r,e)},xe=e=>e instanceof Ie?e:e instanceof Error?new C(e.message,e):new C(`Internal error: ${e}`);var Hn=()=>"/api/v1/sessions",Vn=()=>"/api/v1/sessions/logout",jn=()=>"/api/v1/sessions/fork",$n=()=>"/api/v1/sessions/fork/recover",zn=()=>"/api/v1/siwe/init",qn=()=>"/api/v1/siwe/authenticate",Zn=()=>"/api/v1/siwe/link",Kn=()=>"/api/v1/passwordless/init",Jn=()=>"/api/v1/passwordless/authenticate",Yn=()=>"/api/v1/passwordless/link",Xn=()=>"/api/v1/passwordless_sms/init",Qn=()=>"/api/v1/passwordless_sms/authenticate",ei=()=>"/api/v1/passwordless_sms/link",ti=()=>"/api/v1/oauth/init",oi=()=>"/api/v1/oauth/authenticate",ri=()=>"/api/v1/oauth/link",ni=()=>"/api/v1/siwe/unlink",ii=()=>"/api/v1/passwordless/unlink",ai=()=>"/api/v1/passwordless_sms/unlink",si=()=>"/api/v1/oauth/unlink";var co=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=Jn(),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 ee(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=Yn();return(await this.api.post(t,{email:this.meta.email,code:this.meta.emailCode})).data}catch(t){throw ee(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=Kn();return(await this.api.post(o,{email:this.meta.email})).data}catch(o){throw ee(o)}}};var Mt=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=oi(),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 ee(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=ri();return(await this.api.post(t,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode})).data}catch(t){throw ee(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=ti();return(await this.api.post(t,{provider:this.meta.provider,redirect_to:window.location.href})).data}catch(t){throw ee(t)}}};var Ot=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(qn(),{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 ee(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(Zn(),{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 ee(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(zn(),{address:o});return this.preparedMessage=this.walletConnector.prepareMessage(r,o,n.data.nonce),this.preparedMessage}};var po=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=Qn(),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 ee(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=ei();return(await this.api.post(t,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode})).data}catch(t){throw ee(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=Xn();return(await this.api.post(o,{phoneNumber:this.meta.phoneNumber})).data}catch(o){throw ee(o)}}};var Ta=require("@ethersproject/address");var li="1.19.0-beta.6";var ci="https://api.privy.io/v0",Nr=process.env.NEXT_PUBLIC_PRIVY_AUTH_URL||"https://auth.privy.io",ko="4df5e2316331463a9130964bd6078dfa",di=1e4,_e=1400,To=li;var Nt="privy:token",Wo="privy:refresh_token",uo="privy:session_transfer_token",Ro="privy:connectors",Dr="walletconnect",pi=3e4;var Ur=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)}},Br=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 bl(){return typeof window<"u"&&window.localStorage?new Br:new Ur}var $=bl();var hi=_(require("@coinbase/wallet-sdk")),gi=require("@ethersproject/address");var fo=require("react/jsx-runtime"),Le=({style:e,...t})=>(0,fo.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,fo.jsx)("rect",{width:"1024",height:"1024",fill:"#0052FF",rx:100,ry:100}),(0,fo.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 fi=require("@ethersproject/address"),mi=require("@ethersproject/providers");var ui=require("@ethersproject/logger");var Dt=class extends Q{constructor(){super("Wallet timeout");this.type="wallet_error"}},yt=class extends Q{constructor(){super("User rejected connection");this.type="wallet_error"}},je=e=>{if(e instanceof Q)return e;if((e==null?void 0:e.code)&&(e==null?void 0:e.reason)){let t=new Ut(e);return e.code===ui.ErrorCode.ACTION_REJECTED&&(t.details=bt.E4001_USER_REJECTED_REQUEST),t}return e!=null&&e.code?new Ut(e):new Q("Unknown connector error",e)},Fr=class extends Ie{constructor(o,r,n){super(o);this.type="provider_error";this.code=r,this.data=n}},Ut=class extends Fr{constructor(o){var i,a,s;let r=o;super(r.message,r.code,r.data);let n=Object.values(bt).find(l=>l.eipCode===r.code);this.details=n||bt.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=bt.E32002_CONNECTION_ALREADY_PENDING:this.details=bt.E32002_REQUEST_ALREADY_PENDING:(s=r.message)!=null&&s.includes("Already processing")&&r.message.includes("eth_requestAccounts")&&(this.details=bt.E32002_WALLET_LOCKED))}},yl={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}},vl={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}},wl={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}},bt={UNKNOWN_ERROR:{eipCode:0,message:"Unknown error",detail:"Unknown error",retryable:!0},...wl,...vl},vt={...yl,...bt};var Cl=12e4,Gr=(e=new Dt,t=Cl)=>new Promise((o,r)=>setTimeout(()=>{r(e)},t)),Me=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 Q(`A wallet request of type ${t.method} was made before setting a wallet provider.`);return Promise.race([this.walletProvider.request(t),Gr()]).catch(o=>{throw je(o)})}},nt=class extends Me{constructor(o){super(o)}},Io=class extends Me{constructor(t){super(t)}sendAsync(t,o){throw new Error("sendAsync is no longer supported by EIP-1193. Use the request method instead.")}};var $e=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}
|
|
@@ -436,7 +436,7 @@ Resources:
|
|
|
436
436
|
}
|
|
437
437
|
`,Sc=zt.default.span`
|
|
438
438
|
word-break: break-all;
|
|
439
|
-
`;var ar=require("react"),Ka=_(require("styled-components"));var qa=require("react-device-detect");var Za=e=>{let t=new URL(window.location.href);if(!jt()&&qa.isMobile)return`https://go.cb-w.com/dapp?cb_url=${encodeURIComponent(`${t.href.replace(/\/$/g,"")}?privy_wallet_client=coinbase_wallet${e?`&privy_token=${e}`:""}`)}`};var ge=require("react/jsx-runtime"),Ja=()=>{let{forkSession:e,ready:t,authenticated:o}=H(),{closePrivyModal:r}=W(),[n,i]=(0,ar.useState)("");(0,ar.useEffect)(()=>{t&&o&&e().then(
|
|
439
|
+
`;var ar=require("react"),Ka=_(require("styled-components"));var qa=require("react-device-detect");var Za=e=>{let t=new URL(window.location.href);if(!jt()&&qa.isMobile)return`https://go.cb-w.com/dapp?cb_url=${encodeURIComponent(`${t.href.replace(/\/$/g,"")}?privy_wallet_client=coinbase_wallet${e?`&privy_token=${e}`:""}`)}`};var ge=require("react/jsx-runtime"),Ja=()=>{let{forkSession:e,ready:t,authenticated:o}=H(),{closePrivyModal:r}=W(),[n,i]=(0,ar.useState)("");(0,ar.useEffect)(()=>{t&&o&&e().then(l=>i(l))},[o,t]);let a=Za(n),s={title:"Redirecting to Coinbase Wallet",description:"We'll take you to the Coinbase Wallet app to continue your login experience.",footnote:""};return t&&o&&(s.description="For the best experience, we'll automatically log you into the Coinbase Wallet in-app browser.",s.footnote="Once you're done, you can always return here and refresh to view your updated account."),(0,ge.jsxs)(ge.Fragment,{children:[(0,ge.jsx)(A,{},"header"),(0,ge.jsx)(ir,{title:s.title,description:s.description}),(0,ge.jsxs)(Ze,{children:[(0,ge.jsx)(Pc,{children:(0,ge.jsx)(Le,{style:{width:"72px",height:"72px"}})}),(0,ge.jsx)(Ia,{href:a,onClick:()=>{r()},loading:t&&o&&!n,children:"Continue"}),s.footnote?(0,ge.jsx)("p",{children:s.footnote}):null]}),(0,ge.jsx)(z,{protectedByPrivy:!0})]})},Pc=(0,Ka.default)(rr)`
|
|
440
440
|
margin: 16px auto;
|
|
441
441
|
`;var ot=require("react"),hn=require("react-device-detect"),cr=_(require("styled-components"));var V=require("react/jsx-runtime"),sr=2,lr={metamask:{name:"MetaMask",component:Oe},coinbase_wallet:{name:"Coinbase Wallet",component:Le},wallet_connect:{name:"WalletConnect",component:Bt}},Ac=e=>(e==null?void 0:e.status)===422?vt.ERROR_USER_EXISTS:e instanceof Ut&&!e.details.default?e.details:e instanceof Dt?vt.ERROR_TIMED_OUT:e instanceof yt?vt.ERROR_USER_REJECTED_CONNECTION:vt.ERROR_WALLET_CONNECTION,Ya=()=>{var q,G,Z;let[e,t]=(0,ot.useState)(!1),[o,r]=(0,ot.useState)(void 0),{navigate:n,navigateBack:i}=E(),{getAuthFlow:a,walletConnectionStatus:s,closePrivyModal:l,loginWithWallet:d}=W(),{walletConnectors:h}=H(),[f,u]=(0,ot.useState)(0),{user:g}=H(),[b]=(0,ot.useState)((g==null?void 0:g.linkedAccounts.length)||0),c=a(),y=hn.isMobile&&(c==null?void 0:c.meta.walletType)==="wallet_connect"||hn.isMobile&&(c==null?void 0:c.meta.walletType)==="coinbase_wallet",P=s==null?void 0:s.connected;(0,ot.useEffect)(()=>{!c||y||!P||T().catch(D=>console.warn("Auto-prompted signature failed",D))},[f,P]),(0,ot.useEffect)(()=>{if(g&&e){let D=setTimeout(l,_e);return()=>clearTimeout(D)}},[g,e]);let I=D=>{if((D==null?void 0:D.status)===401&&(D==null?void 0:D.message)==="User is not allowed to login to this app."){n("ALLOWLIST_REJECTION_SCREEN");return}r(Ac(D))};async function T(){try{await d(),t(!0)}catch(D){I(D)}}(0,ot.useEffect)(()=>{s!=null&&s.connectError&&I(s==null?void 0:s.connectError)},[s]);let M=(c==null?void 0:c.meta.walletType)||"metamask",N=((q=c==null?void 0:c.meta)==null?void 0:q.walletName)||lr[M].name,ce=((G=c==null?void 0:c.meta)==null?void 0:G.walletIcon)||lr[M].component,Te=e?`Successfully connected with ${N}`:o?o.message:P?"Sign to verify":`Waiting for ${N}`,j="Don\u2019t see your wallet modal? Check your other browser windows.";if(e){let D=(g==null?void 0:g.linkedAccounts.length)||0;b===D?j="Wallet was already linked.":j="You\u2019re good to go!"}else f>=sr&&o?j="Unable to connect wallet":o?j=o.detail:P&&y?j="Sign the message in your wallet to verify it belongs to you.":M==="metamask"?j="For the best experience, connect only one wallet at a time.":M==="wallet_connect"?j="Open your mobile wallet app to continue":M==="coinbase_wallet"&&(jt()||(rn(g)?j="Continue with the Coinbase app. Not the right wallet? Reset your connection below.":j="Open the Coinbase app on your phone to continue."));let ie=(Z=h==null?void 0:h.walletConnectors)==null?void 0:Z.find(D=>D.walletType==="coinbase_wallet"),We=M==="coinbase_wallet"&&(rn(g)||o===vt.ERROR_USER_EXISTS);return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(A,{backFn:i}),(0,V.jsxs)(kc,{children:[(0,V.jsx)(gn,{walletLogo:ce,success:e,fail:!!o}),(0,V.jsxs)(Tc,{children:[(0,V.jsx)("h3",{children:Te}),(0,V.jsx)("p",{children:j})]}),We?(0,V.jsx)(fe,{onClick:()=>ie&&(ie==null?void 0:ie.disconnect()),invisible:e,disabled:e,children:"Use a different wallet"}):o==vt.ERROR_USER_EXISTS?(0,V.jsx)(fe,{onClick:i,children:"Use a different wallet"}):P&&!e&&y?(0,V.jsx)(fe,{onClick:T,children:"Sign with your wallet"}):!e&&(o==null?void 0:o.retryable)&&f<sr?(0,V.jsx)(fe,{onClick:()=>{u(f+1),r(void 0),s==null||s.connectRetry()},invisible:e||!(o!=null&&o.retryable)||f>=sr,disabled:!e&&(!(o!=null&&o.retryable)||f>=sr),children:"Retry"}):(0,V.jsx)(fe,{"aria-hidden":"true",invisible:!0,children:"Placeholder"})]})]})},kc=cr.default.div`
|
|
442
442
|
display: flex;
|