@dcl/auth-site 4.5.0 → 4.5.1-21076090969.commit-a0de2fc
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/assets/{ConstantsUtil-C9UN5OW8.js → ConstantsUtil-B1B0nR9C.js} +1 -1
- package/assets/{ExchangeController-CTCmj_py.js → ExchangeController-CC-WA7h6.js} +1 -1
- package/assets/{HelpersUtil-tQe0dELY.js → HelpersUtil-DjLIrIEy.js} +1 -1
- package/assets/{NetworkUtil-DoMxfiFL.js → NetworkUtil-BB0TxE9p.js} +1 -1
- package/assets/{SwapController-DziEzr-W.js → SwapController-B1Yvx6c2.js} +1 -1
- package/assets/{biconomy-Ba9UGsWB.js → biconomy-DT6Iijj2.js} +1 -1
- package/assets/{ccip-yoWMFy22.js → ccip-xyxXL3L7.js} +1 -1
- package/assets/{data-capture-wqIUqrux.js → data-capture-FB6me-7p.js} +1 -1
- package/assets/{email-ChOw_WX1.js → email-BGLr_-QZ.js} +1 -1
- package/assets/{embedded-wallet-BUpVqq4X.js → embedded-wallet-2rN-oS7N.js} +1 -1
- package/assets/{engine-DE7r_Q8v.js → engine-DyumDdCT.js} +1 -1
- package/assets/{extractIPFS-CR4W5Mbp.js → extractIPFS-DKedTp8j.js} +1 -1
- package/assets/{features-CrkPfyGi.js → features-BqOwC9OI.js} +1 -1
- package/assets/{fortmatic-D6oZsnfa.js → fortmatic-CLJ1v6-L.js} +1 -1
- package/assets/{getInstalledModules-CA4bzEJN.js → getInstalledModules-BC2fBQQe.js} +1 -1
- package/assets/{if-defined-B1Jw6khG.js → if-defined-DIjTqkPc.js} +1 -1
- package/assets/{in-app-wallet-calls-XqgeRTaW.js → in-app-wallet-calls-BhbFXrXl.js} +1 -1
- package/assets/{index-BwWJWLAw.js → index-4uk83_lk.js} +1 -1
- package/assets/{index-DAuxJKMk.js → index-8h8RbWPq.js} +1 -1
- package/assets/{index-DImQgJD1.js → index-B07jRA_S.js} +1 -1
- package/assets/{index-47YmILpg.js → index-B2Nwx2Pb.js} +1 -1
- package/assets/{index-DoKQL3pU.js → index-B6wzw8J3.js} +1 -1
- package/assets/{index-CohvTBYG.js → index-BESy9fbZ.js} +1 -1
- package/assets/{index-aQ8wtUFq.js → index-BLZTaqiE.js} +1 -1
- package/assets/{index-tuDVNoGv.js → index-BLuyk03X.js} +1 -1
- package/assets/{index-DKNtuL07.js → index-BMPF0E7Y.js} +1 -1
- package/assets/{index-B5F3T-rr.js → index-BYUpM_QI.js} +1 -1
- package/assets/{index-CChdAfWe.js → index-Bd2WIJU8.js} +1 -1
- package/assets/{index-CIniIIbo.js → index-BmAbXTYm.js} +89 -89
- package/assets/{index-BYkddn8V.js → index-Bmd-CE-d.js} +1 -1
- package/assets/{index-CvTtch-X.js → index-Bp6eeWYt.js} +1 -1
- package/assets/{index-Udl5Izsn.js → index-BsNLqnCG.js} +1 -1
- package/assets/{index-byrfHRpT.js → index-Bsn7-UVq.js} +1 -1
- package/assets/index-C5Yg70-2.css +1 -0
- package/assets/{index-DgABva8-.js → index-C5bmKCwO.js} +1 -1
- package/assets/{index-Bx71DZZz.js → index-CFRccWRu.js} +1 -1
- package/assets/{index-DURrbpcn.js → index-CFqF0dbq.js} +1 -1
- package/assets/{index-CQLY6iOB.js → index-CwvvRQi8.js} +1 -1
- package/assets/{index-DJxXOIS_.js → index-D4P1pgAl.js} +1 -1
- package/assets/{index-CKKbm0ei.js → index-DGtrKwWB.js} +1 -1
- package/assets/{index-CRksOsLq.js → index-DHjdohiW.js} +1 -1
- package/assets/{index-D9bh6I8V.js → index-DLmsskrA.js} +1 -1
- package/assets/{index-BK536KDy.js → index-DY865o07.js} +3 -3
- package/assets/{index-NEmWiQwV.js → index-DhuV0cPI.js} +1 -1
- package/assets/{index-BDnUYgwY.js → index-DkatlhKa.js} +1 -1
- package/assets/{index-MhVrXzt5.js → index-Dt8v3lSJ.js} +1 -1
- package/assets/{index-fmZDJzEP.js → index-Dta7LIvX.js} +1 -1
- package/assets/{index-bK-WSxh_.js → index-DwCXEnCZ.js} +1 -1
- package/assets/{index-v3V9wPC3.js → index-DxlMu3ea.js} +1 -1
- package/assets/{index-CETaFDHt.js → index-EkVhGa1o.js} +1 -1
- package/assets/{index-Bw8xEiz8.js → index-GHgycunK.js} +1 -1
- package/assets/{index-Cdv58i9I.js → index-LAjLiS-K.js} +1 -1
- package/assets/{index-CsT1oR1v.js → index-TIhhvvUp.js} +1 -1
- package/assets/{index-CaSfTrpD.js → index-Wk9ccokW.js} +1 -1
- package/assets/{index-CB4Ua8hA.js → index-_w3EEN07.js} +4 -4
- package/assets/{index-BH_pjTK4.js → index-dB98qioB.js} +2 -2
- package/assets/{index-DXVxAJsf.js → index-g5szi6r5.js} +1 -1
- package/assets/{index-DYWA8d_Y.js → index-osg4Koy_.js} +1 -1
- package/assets/{index-qcIT86cn.js → index-rwQnv0hR.js} +1 -1
- package/assets/{networks-DFaQ4OO6.js → networks-BZeGWcbO.js} +1 -1
- package/assets/{onramp-fYckWqyy.js → onramp-DmW6Wpg-.js} +1 -1
- package/assets/{openzeppelin-CRo4Yjrb.js → openzeppelin-BNmbA-oY.js} +1 -1
- package/assets/{parse-typed-data-CgzX3Mze.js → parse-typed-data-BQrR5t4x.js} +1 -1
- package/assets/{passkeys-CuMOCn1_.js → passkeys-BUaL1P39.js} +1 -1
- package/assets/{pay-with-exchange-BpCbG70P.js → pay-with-exchange-C3dE_Jy4.js} +1 -1
- package/assets/{receive-BPjNw_Ia.js → receive-dmziTgvF.js} +1 -1
- package/assets/{ref-B_-wHf6j.js → ref-BywtPZ1y.js} +1 -1
- package/assets/{resolveImplementation-5Kejt_eO.js → resolveImplementation-DhSbBy2A.js} +1 -1
- package/assets/{secp256k1-wR1pBYt4.js → secp256k1--26K0RZe.js} +1 -1
- package/assets/{send-BqOjZg08.js → send-DmpGLDx_.js} +1 -1
- package/assets/{send-eip712-transaction-CfeQLo5q.js → send-eip712-transaction-CwJN_LGP.js} +1 -1
- package/assets/{send-gasless-transaction-DVc1bt-6.js → send-gasless-transaction-BIBw1EIq.js} +2 -2
- package/assets/{socials-wRT8srTH.js → socials-BgGTTjbV.js} +1 -1
- package/assets/{swaps-DvC4Fti7.js → swaps-B7bIgKjW.js} +1 -1
- package/assets/{thirdweb-BwBpt6_M.js → thirdweb-BXzAJI2R.js} +3 -3
- package/assets/{transactions-DJELlSxG.js → transactions-oExukfM1.js} +1 -1
- package/assets/{ui-ChwX0EnY.js → ui-BZVBOcI0.js} +4 -4
- package/assets/{ui-DYb7Iz87.css → ui-DRBd2XZm.css} +3 -3
- package/assets/{vendor-CmSDeRLW.js → vendor-BpyywBCn.js} +1 -1
- package/assets/{verifyHash-PCE7SAe4.js → verifyHash-B6UCi3Fq.js} +3 -3
- package/assets/{w3m-modal-BQ_U0Js5.js → w3m-modal-DLtaVZGd.js} +1 -1
- package/assets/{web-connector-BVyoVzQv.js → web-connector-BqX4xCDU.js} +3 -3
- package/index.html +6 -6
- package/package.json +3 -3
- package/assets/index-BGw80B-O.css +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-
|
|
2
|
-
import{p as wn,g as uy,_ as Dt,an as hy}from"./thirdweb-BwBpt6_M.js";import{C as U,L as py,a5 as Do,m as fy,s as ca,H as Mi,B as ff,ag as gy,ak as la,W as Xd,X as Qd,Y as eu,af as tu,_ as su,ah as nu,ai as ru,ac as iu,Z as ou,a7 as au,aj as cu,ae as lu,a2 as du,a3 as fl,ad as gl,aa as uu,a9 as hu,I as pu,$ as ml,a0 as fu,a4 as gu,a1 as mu,a6 as yu,V as wu,E as my,aA as yy,R as wy,aC as gf,aq as mf,p as Lo,aD as yf,at as Ey,av as by,aw as vy,ax as Cy,ay as _y,as as Ay,t as Eu}from"./NetworkUtil-DoMxfiFL.js";import{m as Sy,s as Gi,n as Mo,o as va,p as Iy,q as Ny,u as Ty,v as Ry,w as Oy,x as bu,I as fi,y as Py,z as Cs,A as Qt,B as Z,D as _n,E as xy,F as ky,G as Bi,J as yl,K as gi,L as Uy,M as $y,N as Dy,O as xr,P as Ly,Q as Hs,R as mi,S as md,T as My,U as yd,V as wd,W as Yi,X as Ed,Y as vu,Z as By,_ as jy,$ as pr,a0 as wf,a1 as an,a2 as Ws,a3 as In,a4 as Ef}from"./index-CIniIIbo.js";import{B as Pe,g as Ce}from"./ui-ChwX0EnY.js";const bf={isLowerCaseMatch(t,e){return(t==null?void 0:t.toLowerCase())===(e==null?void 0:e.toLowerCase())}};var Fy=20,qy=1,Ar=1e6,Cu=1e6,Wy=-7,Hy=21,Vy=!1,Co="[big.js] ",kr=Co+"Invalid ",Ja=kr+"decimal places",zy=kr+"rounding mode",vf=Co+"Division by zero",qe={},Ys=void 0,Ky=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function Cf(){function t(e){var s=this;if(!(s instanceof t))return e===Ys?Cf():new t(e);if(e instanceof t)s.s=e.s,s.e=e.e,s.c=e.c.slice();else{if(typeof e!="string"){if(t.strict===!0&&typeof e!="bigint")throw TypeError(kr+"value");e=e===0&&1/e<0?"-0":String(e)}Gy(s,e)}s.constructor=t}return t.prototype=qe,t.DP=Fy,t.RM=qy,t.NE=Wy,t.PE=Hy,t.strict=Vy,t.roundDown=0,t.roundHalfUp=1,t.roundHalfEven=2,t.roundUp=3,t}function Gy(t,e){var s,n,r;if(!Ky.test(e))throw Error(kr+"number");for(t.s=e.charAt(0)=="-"?(e=e.slice(1),-1):1,(s=e.indexOf("."))>-1&&(e=e.replace(".","")),(n=e.search(/e/i))>0?(s<0&&(s=n),s+=+e.slice(n+1),e=e.substring(0,n)):s<0&&(s=e.length),r=e.length,n=0;n<r&&e.charAt(n)=="0";)++n;if(n==r)t.c=[t.e=0];else{for(;r>0&&e.charAt(--r)=="0";);for(t.e=s-n-1,t.c=[],s=0;n<=r;)t.c[s++]=+e.charAt(n++)}return t}function Ur(t,e,s,n){var r=t.c;if(s===Ys&&(s=t.constructor.RM),s!==0&&s!==1&&s!==2&&s!==3)throw Error(zy);if(e<1)n=s===3&&(n||!!r[0])||e===0&&(s===1&&r[0]>=5||s===2&&(r[0]>5||r[0]===5&&(n||r[1]!==Ys))),r.length=1,n?(t.e=t.e-e+1,r[0]=1):r[0]=t.e=0;else if(e<r.length){if(n=s===1&&r[e]>=5||s===2&&(r[e]>5||r[e]===5&&(n||r[e+1]!==Ys||r[e-1]&1))||s===3&&(n||!!r[0]),r.length=e,n){for(;++r[--e]>9;)if(r[e]=0,e===0){++t.e,r.unshift(1);break}}for(e=r.length;!r[--e];)r.pop()}return t}function $r(t,e,s){var n=t.e,r=t.c.join(""),i=r.length;if(e)r=r.charAt(0)+(i>1?"."+r.slice(1):"")+(n<0?"e":"e+")+n;else if(n<0){for(;++n;)r="0"+r;r="0."+r}else if(n>0)if(++n>i)for(n-=i;n--;)r+="0";else n<i&&(r=r.slice(0,n)+"."+r.slice(n));else i>1&&(r=r.charAt(0)+"."+r.slice(1));return t.s<0&&s?"-"+r:r}qe.abs=function(){var t=new this.constructor(this);return t.s=1,t};qe.cmp=function(t){var e,s=this,n=s.c,r=(t=new s.constructor(t)).c,i=s.s,o=t.s,a=s.e,c=t.e;if(!n[0]||!r[0])return n[0]?i:r[0]?-o:0;if(i!=o)return i;if(e=i<0,a!=c)return a>c^e?1:-1;for(o=(a=n.length)<(c=r.length)?a:c,i=-1;++i<o;)if(n[i]!=r[i])return n[i]>r[i]^e?1:-1;return a==c?0:a>c^e?1:-1};qe.div=function(t){var e=this,s=e.constructor,n=e.c,r=(t=new s(t)).c,i=e.s==t.s?1:-1,o=s.DP;if(o!==~~o||o<0||o>Ar)throw Error(Ja);if(!r[0])throw Error(vf);if(!n[0])return t.s=i,t.c=[t.e=0],t;var a,c,l,d,u,h=r.slice(),p=a=r.length,g=n.length,f=n.slice(0,a),w=f.length,v=t,N=v.c=[],A=0,_=o+(v.e=e.e-t.e)+1;for(v.s=i,i=_<0?0:_,h.unshift(0);w++<a;)f.push(0);do{for(l=0;l<10;l++){if(a!=(w=f.length))d=a>w?1:-1;else for(u=-1,d=0;++u<a;)if(r[u]!=f[u]){d=r[u]>f[u]?1:-1;break}if(d<0){for(c=w==a?r:h;w;){if(f[--w]<c[w]){for(u=w;u&&!f[--u];)f[u]=9;--f[u],f[w]+=10}f[w]-=c[w]}for(;!f[0];)f.shift()}else break}N[A++]=d?l:++l,f[0]&&d?f[w]=n[p]||0:f=[n[p]]}while((p++<g||f[0]!==Ys)&&i--);return!N[0]&&A!=1&&(N.shift(),v.e--,_--),A>_&&Ur(v,_,s.RM,f[0]!==Ys),v};qe.eq=function(t){return this.cmp(t)===0};qe.gt=function(t){return this.cmp(t)>0};qe.gte=function(t){return this.cmp(t)>-1};qe.lt=function(t){return this.cmp(t)<0};qe.lte=function(t){return this.cmp(t)<1};qe.minus=qe.sub=function(t){var e,s,n,r,i=this,o=i.constructor,a=i.s,c=(t=new o(t)).s;if(a!=c)return t.s=-c,i.plus(t);var l=i.c.slice(),d=i.e,u=t.c,h=t.e;if(!l[0]||!u[0])return u[0]?t.s=-c:l[0]?t=new o(i):t.s=1,t;if(a=d-h){for((r=a<0)?(a=-a,n=l):(h=d,n=u),n.reverse(),c=a;c--;)n.push(0);n.reverse()}else for(s=((r=l.length<u.length)?l:u).length,a=c=0;c<s;c++)if(l[c]!=u[c]){r=l[c]<u[c];break}if(r&&(n=l,l=u,u=n,t.s=-t.s),(c=(s=u.length)-(e=l.length))>0)for(;c--;)l[e++]=0;for(c=e;s>a;){if(l[--s]<u[s]){for(e=s;e&&!l[--e];)l[e]=9;--l[e],l[s]+=10}l[s]-=u[s]}for(;l[--c]===0;)l.pop();for(;l[0]===0;)l.shift(),--h;return l[0]||(t.s=1,l=[h=0]),t.c=l,t.e=h,t};qe.mod=function(t){var e,s=this,n=s.constructor,r=s.s,i=(t=new n(t)).s;if(!t.c[0])throw Error(vf);return s.s=t.s=1,e=t.cmp(s)==1,s.s=r,t.s=i,e?new n(s):(r=n.DP,i=n.RM,n.DP=n.RM=0,s=s.div(t),n.DP=r,n.RM=i,this.minus(s.times(t)))};qe.neg=function(){var t=new this.constructor(this);return t.s=-t.s,t};qe.plus=qe.add=function(t){var e,s,n,r=this,i=r.constructor;if(t=new i(t),r.s!=t.s)return t.s=-t.s,r.minus(t);var o=r.e,a=r.c,c=t.e,l=t.c;if(!a[0]||!l[0])return l[0]||(a[0]?t=new i(r):t.s=r.s),t;if(a=a.slice(),e=o-c){for(e>0?(c=o,n=l):(e=-e,n=a),n.reverse();e--;)n.push(0);n.reverse()}for(a.length-l.length<0&&(n=l,l=a,a=n),e=l.length,s=0;e;a[e]%=10)s=(a[--e]=a[e]+l[e]+s)/10|0;for(s&&(a.unshift(s),++c),e=a.length;a[--e]===0;)a.pop();return t.c=a,t.e=c,t};qe.pow=function(t){var e=this,s=new e.constructor("1"),n=s,r=t<0;if(t!==~~t||t<-Cu||t>Cu)throw Error(kr+"exponent");for(r&&(t=-t);t&1&&(n=n.times(e)),t>>=1,!!t;)e=e.times(e);return r?s.div(n):n};qe.prec=function(t,e){if(t!==~~t||t<1||t>Ar)throw Error(kr+"precision");return Ur(new this.constructor(this),t,e)};qe.round=function(t,e){if(t===Ys)t=0;else if(t!==~~t||t<-Ar||t>Ar)throw Error(Ja);return Ur(new this.constructor(this),t+this.e+1,e)};qe.sqrt=function(){var t,e,s,n=this,r=n.constructor,i=n.s,o=n.e,a=new r("0.5");if(!n.c[0])return new r(n);if(i<0)throw Error(Co+"No square root");i=Math.sqrt(+$r(n,!0,!0)),i===0||i===1/0?(e=n.c.join(""),e.length+o&1||(e+="0"),i=Math.sqrt(e),o=((o+1)/2|0)-(o<0||o&1),t=new r((i==1/0?"5e":(i=i.toExponential()).slice(0,i.indexOf("e")+1))+o)):t=new r(i+""),o=t.e+(r.DP+=4);do s=t,t=a.times(s.plus(n.div(s)));while(s.c.slice(0,o).join("")!==t.c.slice(0,o).join(""));return Ur(t,(r.DP-=4)+t.e+1,r.RM)};qe.times=qe.mul=function(t){var e,s=this,n=s.constructor,r=s.c,i=(t=new n(t)).c,o=r.length,a=i.length,c=s.e,l=t.e;if(t.s=s.s==t.s?1:-1,!r[0]||!i[0])return t.c=[t.e=0],t;for(t.e=c+l,o<a&&(e=r,r=i,i=e,l=o,o=a,a=l),e=new Array(l=o+a);l--;)e[l]=0;for(c=a;c--;){for(a=0,l=o+c;l>c;)a=e[l]+i[c]*r[l-c-1]+a,e[l--]=a%10,a=a/10|0;e[l]=a}for(a?++t.e:e.shift(),c=e.length;!e[--c];)e.pop();return t.c=e,t};qe.toExponential=function(t,e){var s=this,n=s.c[0];if(t!==Ys){if(t!==~~t||t<0||t>Ar)throw Error(Ja);for(s=Ur(new s.constructor(s),++t,e);s.c.length<t;)s.c.push(0)}return $r(s,!0,!!n)};qe.toFixed=function(t,e){var s=this,n=s.c[0];if(t!==Ys){if(t!==~~t||t<0||t>Ar)throw Error(Ja);for(s=Ur(new s.constructor(s),t+s.e+1,e),t=t+s.e+1;s.c.length<t;)s.c.push(0)}return $r(s,!1,!!n)};qe[Symbol.for("nodejs.util.inspect.custom")]=qe.toJSON=qe.toString=function(){var t=this,e=t.constructor;return $r(t,t.e<=e.NE||t.e>=e.PE,!!t.c[0])};qe.toNumber=function(){var t=+$r(this,!0,!0);if(this.constructor.strict===!0&&!this.eq(t.toString()))throw Error(Co+"Imprecise conversion");return t};qe.toPrecision=function(t,e){var s=this,n=s.constructor,r=s.c[0];if(t!==Ys){if(t!==~~t||t<1||t>Ar)throw Error(kr+"precision");for(s=Ur(new n(s),t,e);s.c.length<t;)s.c.push(0)}return $r(s,t<=s.e||s.e<=n.NE||s.e>=n.PE,!!r)};qe.valueOf=function(){var t=this,e=t.constructor;if(e.strict===!0)throw Error(Co+"valueOf disallowed");return $r(t,t.e<=e.NE||t.e>=e.PE,!0)};var Nn=Cf();const Yy={bigNumber(t){return t?new Nn(t):new Nn(0)},multiply(t,e){if(t===void 0||e===void 0)return new Nn(0);const s=new Nn(t),n=new Nn(e);return s.times(n)},toFixed(t,e=2){return t===void 0||t===""?new Nn(0).toFixed(e):new Nn(t).toFixed(e)},formatNumberToLocalString(t,e=2){return t===void 0||t===""?"0.00":typeof t=="number"?t.toLocaleString("en-US",{maximumFractionDigits:e,minimumFractionDigits:e,roundingMode:"floor"}):parseFloat(t).toLocaleString("en-US",{maximumFractionDigits:e,minimumFractionDigits:e,roundingMode:"floor"})},parseLocalStringToNumber(t){if(t===void 0||t==="")return 0;const e=t.replace(/,/gu,"");return new Nn(e).toNumber()}},Zy=[{type:"function",name:"transfer",stateMutability:"nonpayable",inputs:[{name:"_to",type:"address"},{name:"_value",type:"uint256"}],outputs:[{name:"",type:"bool"}]},{type:"function",name:"transferFrom",stateMutability:"nonpayable",inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_value",type:"uint256"}],outputs:[{name:"",type:"bool"}]}],Jy=[{type:"function",name:"approve",stateMutability:"nonpayable",inputs:[{name:"spender",type:"address"},{name:"amount",type:"uint256"}],outputs:[{type:"bool"}]}],Xy=[{type:"function",name:"transfer",stateMutability:"nonpayable",inputs:[{name:"recipient",type:"address"},{name:"amount",type:"uint256"}],outputs:[]},{type:"function",name:"transferFrom",stateMutability:"nonpayable",inputs:[{name:"sender",type:"address"},{name:"recipient",type:"address"},{name:"amount",type:"uint256"}],outputs:[{name:"",type:"bool"}]}],Qy={getERC20Abi:t=>U.USDT_CONTRACT_ADDRESSES.includes(t)?Xy:Zy,getSwapAbi:()=>Jy},Mr={ConnectorExplorerIds:{[U.CONNECTOR_ID.COINBASE]:"fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa",[U.CONNECTOR_ID.COINBASE_SDK]:"fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa",[U.CONNECTOR_ID.BASE_ACCOUNT]:"fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa",[U.CONNECTOR_ID.SAFE]:"225affb176778569276e484e1b92637ad061b01e13a048b35a9d280c3b58970f",[U.CONNECTOR_ID.LEDGER]:"19177a98252e07ddfc9af2083ba8e07ef627cb6103467ffebb3f8f4205fd7927",[U.CONNECTOR_ID.OKX]:"971e689d0a5be527bac79629b4ee9b925e82208e5168b733496a09c0faed0709",[U.METMASK_CONNECTOR_NAME]:"c57ca95b47569778a828d19178114f4db188b89b763c899ba0be274e97267d96",[U.TRUST_CONNECTOR_NAME]:"4622a2b2d6af1c9844944291e5e7351a6aa24cd7b23099efac1b2fd875da31a0",[U.SOLFLARE_CONNECTOR_NAME]:"1ca0bdd4747578705b1939af023d120677c64fe6ca76add81fda36e350605e79",[U.PHANTOM_CONNECTOR_NAME]:"a797aa35c0fadbfc1a53e7f675162ed5226968b44a19ee3d24385c64d1d3c393",[U.COIN98_CONNECTOR_NAME]:"2a3c89040ac3b723a1972a33a125b1db11e258a6975d3a61252cd64e6ea5ea01",[U.MAGIC_EDEN_CONNECTOR_NAME]:"8b830a2b724a9c3fbab63af6f55ed29c9dfa8a55e732dc88c80a196a2ba136c6",[U.BACKPACK_CONNECTOR_NAME]:"2bd8c14e035c2d48f184aaa168559e86b0e3433228d3c4075900a221785019b0",[U.BITGET_CONNECTOR_NAME]:"38f5d18bd8522c244bdd70cb4a68e0e718865155811c043f052fb9f1c51de662",[U.FRONTIER_CONNECTOR_NAME]:"85db431492aa2e8672e93f4ea7acf10c88b97b867b0d373107af63dc4880f041",[U.XVERSE_CONNECTOR_NAME]:"2a87d74ae02e10bdd1f51f7ce6c4e1cc53cd5f2c0b6b5ad0d7b3007d2b13de7b",[U.LEATHER_CONNECTOR_NAME]:"483afe1df1df63daf313109971ff3ef8356ddf1cc4e45877d205eee0b7893a13",[U.OKX_CONNECTOR_NAME]:"971e689d0a5be527bac79629b4ee9b925e82208e5168b733496a09c0faed0709",[U.BINANCE_CONNECTOR_NAME]:"2fafea35bb471d22889ccb49c08d99dd0a18a37982602c33f696a5723934ba25"}},dt={validateCaipAddress(t){var e;if(((e=t.split(":"))==null?void 0:e.length)!==3)throw new Error("Invalid CAIP Address");return t},parseCaipAddress(t){const e=t.split(":");if(e.length!==3)throw new Error(`Invalid CAIP-10 address: ${t}`);const[s,n,r]=e;if(!s||!n||!r)throw new Error(`Invalid CAIP-10 address: ${t}`);return{chainNamespace:s,chainId:n,address:r}},parseCaipNetworkId(t){const e=t.split(":");if(e.length!==2)throw new Error(`Invalid CAIP-2 network id: ${t}`);const[s,n]=e;if(!s||!n)throw new Error(`Invalid CAIP-2 network id: ${t}`);return{chainNamespace:s,chainId:n}}},gn={RPC_ERROR_CODE:{USER_REJECTED_REQUEST:4001,USER_REJECTED_METHODS:5002,USER_REJECTED:5e3},PROVIDER_RPC_ERROR_NAME:{PROVIDER_RPC:"ProviderRpcError",USER_REJECTED_REQUEST:"UserRejectedRequestError"},isRpcProviderError(t){try{if(typeof t=="object"&&t!==null){const e=t,s=typeof e.message=="string",n=typeof e.code=="number";return s&&n}return!1}catch{return!1}},isUserRejectedMessage(t){return t.toLowerCase().includes("user rejected")||t.toLowerCase().includes("user cancelled")||t.toLowerCase().includes("user canceled")},isUserRejectedRequestError(t){if(gn.isRpcProviderError(t)){const e=t.code===gn.RPC_ERROR_CODE.USER_REJECTED_REQUEST,s=t.code===gn.RPC_ERROR_CODE.USER_REJECTED_METHODS;return e||s||gn.isUserRejectedMessage(t.message)}return t instanceof Error?gn.isUserRejectedMessage(t.message):!1}};class ew extends Error{constructor(e,s){super(s.message,{cause:e}),this.name=gn.PROVIDER_RPC_ERROR_NAME.PROVIDER_RPC,this.code=s.code}}class _f extends ew{constructor(e){super(e,{code:gn.RPC_ERROR_CODE.USER_REJECTED_REQUEST,message:"User rejected the request"}),this.name=gn.PROVIDER_RPC_ERROR_NAME.USER_REJECTED_REQUEST}}const le={WALLET_ID:"@appkit/wallet_id",WALLET_NAME:"@appkit/wallet_name",SOLANA_WALLET:"@appkit/solana_wallet",SOLANA_CAIP_CHAIN:"@appkit/solana_caip_chain",ACTIVE_CAIP_NETWORK_ID:"@appkit/active_caip_network_id",CONNECTED_SOCIAL:"@appkit/connected_social",CONNECTED_SOCIAL_USERNAME:"@appkit-wallet/SOCIAL_USERNAME",RECENT_WALLETS:"@appkit/recent_wallets",RECENT_WALLET:"@appkit/recent_wallet",DEEPLINK_CHOICE:"WALLETCONNECT_DEEPLINK_CHOICE",ACTIVE_NAMESPACE:"@appkit/active_namespace",CONNECTED_NAMESPACES:"@appkit/connected_namespaces",CONNECTION_STATUS:"@appkit/connection_status",SIWX_AUTH_TOKEN:"@appkit/siwx-auth-token",SIWX_NONCE_TOKEN:"@appkit/siwx-nonce-token",TELEGRAM_SOCIAL_PROVIDER:"@appkit/social_provider",NATIVE_BALANCE_CACHE:"@appkit/native_balance_cache",PORTFOLIO_CACHE:"@appkit/portfolio_cache",ENS_CACHE:"@appkit/ens_cache",IDENTITY_CACHE:"@appkit/identity_cache",PREFERRED_ACCOUNT_TYPES:"@appkit/preferred_account_types",CONNECTIONS:"@appkit/connections",DISCONNECTED_CONNECTOR_IDS:"@appkit/disconnected_connector_ids",HISTORY_TRANSACTIONS_CACHE:"@appkit/history_transactions_cache",TOKEN_PRICE_CACHE:"@appkit/token_price_cache",RECENT_EMAILS:"@appkit/recent_emails",LATEST_APPKIT_VERSION:"@appkit/latest_version",TON_WALLETS_CACHE:"@appkit/ton_wallets_cache"};function yc(t){if(!t)throw new Error("Namespace is required for CONNECTED_CONNECTOR_ID");return`@appkit/${t}:connected_connector_id`}const ae={setItem(t,e){xi()&&e!==void 0&&localStorage.setItem(t,e)},getItem(t){if(xi())return localStorage.getItem(t)||void 0},removeItem(t){xi()&&localStorage.removeItem(t)},clear(){xi()&&localStorage.clear()}};function xi(){return typeof window<"u"&&typeof localStorage<"u"}function Zi(t,e){const s=(t==null?void 0:t["--apkt-accent"])??(t==null?void 0:t["--w3m-accent"]);return e==="light"?{"--w3m-accent":s||"hsla(231, 100%, 70%, 1)","--w3m-background":"#fff"}:{"--w3m-accent":s||"hsla(230, 100%, 67%, 1)","--w3m-background":"#202020"}}const tw=Symbol(),_u=Object.getPrototypeOf,wl=new WeakMap,sw=t=>t&&(wl.has(t)?wl.get(t):_u(t)===Object.prototype||_u(t)===Array.prototype),nw=t=>sw(t)&&t[tw]||null,Au=(t,e=!0)=>{wl.set(t,e)},Ca={},bd=t=>typeof t=="object"&&t!==null,rw=t=>bd(t)&&!_o.has(t)&&(Array.isArray(t)||!(Symbol.iterator in t))&&!(t instanceof WeakMap)&&!(t instanceof WeakSet)&&!(t instanceof Error)&&!(t instanceof Number)&&!(t instanceof Date)&&!(t instanceof String)&&!(t instanceof RegExp)&&!(t instanceof ArrayBuffer)&&!(t instanceof Promise),Af=(t,e)=>{const s=El.get(t);if((s==null?void 0:s[0])===e)return s[1];const n=Array.isArray(t)?[]:Object.create(Object.getPrototypeOf(t));return Au(n,!0),El.set(t,[e,n]),Reflect.ownKeys(t).forEach(r=>{if(Object.getOwnPropertyDescriptor(n,r))return;const i=Reflect.get(t,r),{enumerable:o}=Reflect.getOwnPropertyDescriptor(t,r),a={value:i,enumerable:o,configurable:!0};if(_o.has(i))Au(i,!1);else if(Gn.has(i)){const[c,l]=Gn.get(i);a.value=Af(c,l())}Object.defineProperty(n,r,a)}),Object.preventExtensions(n)},iw=(t,e,s,n)=>({deleteProperty(r,i){const o=Reflect.get(r,i);s(i);const a=Reflect.deleteProperty(r,i);return a&&n(["delete",[i],o]),a},set(r,i,o,a){const c=!t()&&Reflect.has(r,i),l=Reflect.get(r,i,a);if(c&&(Su(l,o)||Ji.has(o)&&Su(l,Ji.get(o))))return!0;s(i),bd(o)&&(o=nw(o)||o);const d=!Gn.has(o)&&aw(o)?Ge(o):o;return e(i,d),Reflect.set(r,i,d,a),n(["set",[i],o,l]),!0}}),Gn=new WeakMap,_o=new WeakSet,El=new WeakMap,da=[1],Ji=new WeakMap;let Su=Object.is,ow=(t,e)=>new Proxy(t,e),aw=rw,cw=Af,lw=iw;function Ge(t={}){if(!bd(t))throw new Error("object required");const e=Ji.get(t);if(e)return e;let s=da[0];const n=new Set,r=(w,v=++da[0])=>{s!==v&&(i=s=v,n.forEach(N=>N(w,v)))};let i=s;const o=(w=da[0])=>(i!==w&&(i=w,c.forEach(([v])=>{const N=v[1](w);N>s&&(s=N)})),s),a=w=>(v,N)=>{const A=[...v];A[1]=[w,...A[1]],r(A,N)},c=new Map,l=(w,v)=>{const N=!_o.has(v)&&Gn.get(v);if(N){if((Ca?"production":void 0)!=="production"&&c.has(w))throw new Error("prop listener already exists");if(n.size){const A=N[2](a(w));c.set(w,[N,A])}else c.set(w,[N])}},d=w=>{var v;const N=c.get(w);N&&(c.delete(w),(v=N[1])==null||v.call(N))},u=w=>(n.add(w),n.size===1&&c.forEach(([N,A],_)=>{if((Ca?"production":void 0)!=="production"&&A)throw new Error("remove already exists");const P=N[2](a(_));c.set(_,[N,P])}),()=>{n.delete(w),n.size===0&&c.forEach(([N,A],_)=>{A&&(A(),c.set(_,[N]))})});let h=!0;const p=lw(()=>h,l,d,r),g=ow(t,p);Ji.set(t,g);const f=[t,o,u];return Gn.set(g,f),Reflect.ownKeys(t).forEach(w=>{const v=Object.getOwnPropertyDescriptor(t,w);"value"in v&&v.writable&&(g[w]=t[w])}),h=!1,g}function _t(t,e,s){const n=Gn.get(t);(Ca?"production":void 0)!=="production"&&!n&&console.warn("Please use proxy object");let r;const i=[],o=n[2];let a=!1;const l=o(d=>{i.push(d),r||(r=Promise.resolve().then(()=>{r=void 0,a&&e(i.splice(0))}))});return a=!0,()=>{a=!1,l()}}function Xi(t){const e=Gn.get(t);(Ca?"production":void 0)!=="production"&&!e&&console.warn("Please use proxy object");const[s,n]=e;return cw(s,n())}function Qi(t){return _o.add(t),t}function dw(){return{proxyStateMap:Gn,refSet:_o,snapCache:El,versionHolder:da,proxyCache:Ji}}function At(t,e,s,n){let r=t[e];return _t(t,()=>{const i=t[e];Object.is(r,i)||s(r=i)})}const{proxyStateMap:uw,snapCache:hw}=dw(),Bo=t=>uw.has(t);function pw(t){const e=[];let s=0;const n=new Map,r=new WeakMap,i=()=>{const l=hw.get(a),d=l==null?void 0:l[1];if(d&&!r.has(d)){const u=new Map(n);r.set(d,u)}},o=l=>r.get(l)||n,a={data:e,index:s,epoch:0,get size(){return Bo(this)||i(),o(this).size},get(l){const u=o(this).get(l);if(u===void 0){this.epoch;return}return this.data[u]},has(l){const d=o(this);return this.epoch,d.has(l)},set(l,d){if(!Bo(this))throw new Error("Cannot perform mutations on a snapshot");const u=n.get(l);return u===void 0?(n.set(l,this.index),this.data[this.index++]=d):this.data[u]=d,this.epoch++,this},delete(l){if(!Bo(this))throw new Error("Cannot perform mutations on a snapshot");const d=n.get(l);return d===void 0?!1:(delete this.data[d],n.delete(l),this.epoch++,!0)},clear(){if(!Bo(this))throw new Error("Cannot perform mutations on a snapshot");this.data.length=0,this.index=0,this.epoch++,n.clear()},forEach(l){this.epoch,o(this).forEach((u,h)=>{l(this.data[u],h,this)})},*entries(){this.epoch;const l=o(this);for(const[d,u]of l)yield[d,this.data[u]]},*keys(){this.epoch;const l=o(this);for(const d of l.keys())yield d},*values(){this.epoch;const l=o(this);for(const d of l.values())yield this.data[d]},[Symbol.iterator](){return this.entries()},get[Symbol.toStringTag](){return"Map"},toJSON(){return new Map(this.entries())}},c=Ge(a);return Object.defineProperties(c,{size:{enumerable:!1},index:{enumerable:!1},epoch:{enumerable:!1},data:{enumerable:!1},toJSON:{enumerable:!1}}),Object.seal(c),c}var Iu={};const wc=(typeof wn<"u"&&typeof Iu<"u"?Iu.NEXT_PUBLIC_SECURE_SITE_ORIGIN:void 0)||"https://secure.walletconnect.org",Sf=[{label:"Meld.io",name:"meld",feeRange:"1-2%",url:"https://meldcrypto.com",supportedChains:["eip155","solana"]}],fw="WXETMuFUQmqqybHuRkSgxv:25B8LJHSfpG6LVjR2ytU5Cwh7Z4Sch2ocoU",Ne={FOUR_MINUTES_MS:24e4,TEN_SEC_MS:1e4,FIVE_SEC_MS:5e3,THREE_SEC_MS:3e3,ONE_SEC_MS:1e3,SECURE_SITE:wc,SECURE_SITE_DASHBOARD:`${wc}/dashboard`,SECURE_SITE_FAVICON:`${wc}/images/favicon.png`,SOLANA_NATIVE_TOKEN_ADDRESS:"So11111111111111111111111111111111111111111",RESTRICTED_TIMEZONES:["ASIA/SHANGHAI","ASIA/URUMQI","ASIA/CHONGQING","ASIA/HARBIN","ASIA/KASHGAR","ASIA/MACAU","ASIA/HONG_KONG","ASIA/MACAO","ASIA/BEIJING","ASIA/HARBIN"],SWAP_SUGGESTED_TOKENS:["ETH","UNI","1INCH","AAVE","SOL","ADA","AVAX","DOT","LINK","NITRO","GAIA","MILK","TRX","NEAR","GNO","WBTC","DAI","WETH","USDC","USDT","ARB","BAL","BICO","CRV","ENS","MATIC","OP"],SWAP_POPULAR_TOKENS:["ETH","UNI","1INCH","AAVE","SOL","ADA","AVAX","DOT","LINK","NITRO","GAIA","MILK","TRX","NEAR","GNO","WBTC","DAI","WETH","USDC","USDT","ARB","BAL","BICO","CRV","ENS","MATIC","OP","METAL","DAI","CHAMP","WOLF","SALE","BAL","BUSD","MUST","BTCpx","ROUTE","HEX","WELT","amDAI","VSQ","VISION","AURUM","pSP","SNX","VC","LINK","CHP","amUSDT","SPHERE","FOX","GIDDY","GFC","OMEN","OX_OLD","DE","WNT"],SUGGESTED_TOKENS_BY_CHAIN:{"eip155:42161":["USD₮0"]},BALANCE_SUPPORTED_CHAINS:[U.CHAIN.EVM,U.CHAIN.SOLANA],SEND_PARAMS_SUPPORTED_CHAINS:[U.CHAIN.EVM],SWAP_SUPPORTED_NETWORKS:["eip155:1","eip155:42161","eip155:10","eip155:324","eip155:8453","eip155:56","eip155:137","eip155:100","eip155:43114","eip155:250","eip155:8217","eip155:1313161554"],NAMES_SUPPORTED_CHAIN_NAMESPACES:[U.CHAIN.EVM],ONRAMP_SUPPORTED_CHAIN_NAMESPACES:[U.CHAIN.EVM,U.CHAIN.SOLANA],PAY_WITH_EXCHANGE_SUPPORTED_CHAIN_NAMESPACES:[U.CHAIN.EVM,U.CHAIN.SOLANA],ACTIVITY_ENABLED_CHAIN_NAMESPACES:[U.CHAIN.EVM,U.CHAIN.TON],NATIVE_TOKEN_ADDRESS:{eip155:"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",solana:"So11111111111111111111111111111111111111111",polkadot:"0x",bip122:"0x",cosmos:"0x",sui:"0x",stacks:"0x",ton:"0x"},CONVERT_SLIPPAGE_TOLERANCE:1,CONNECT_LABELS:{MOBILE:"Open and continue in the wallet app",WEB:"Open and continue in the wallet app"},SEND_SUPPORTED_NAMESPACES:[U.CHAIN.EVM,U.CHAIN.SOLANA],DEFAULT_REMOTE_FEATURES:{swaps:["1inch"],onramp:["meld"],email:!0,socials:["google","x","discord","farcaster","github","apple","facebook"],activity:!0,reownBranding:!0,multiWallet:!1,emailCapture:!1,payWithExchange:!1,payments:!1,reownAuthentication:!1,headless:!1},DEFAULT_REMOTE_FEATURES_DISABLED:{email:!1,socials:!1,swaps:!1,onramp:!1,activity:!1,reownBranding:!1,emailCapture:!1,reownAuthentication:!1,headless:!1},DEFAULT_FEATURES:{receive:!0,send:!0,emailShowWallets:!0,connectorTypeOrder:["walletConnect","recent","injected","featured","custom","external","recommended"],analytics:!0,allWallets:!0,legalCheckbox:!1,smartSessions:!1,collapseWallets:!1,walletFeaturesOrder:["onramp","swaps","receive","send"],connectMethodsOrder:void 0,pay:!1,reownAuthentication:!1,headless:!1},DEFAULT_SOCIALS:["google","x","farcaster","discord","apple","github","facebook"],DEFAULT_ACCOUNT_TYPES:{bip122:"payment",eip155:"smartAccount",polkadot:"eoa",solana:"eoa",ton:"eoa"},ADAPTER_TYPES:{UNIVERSAL:"universal",SOLANA:"solana",WAGMI:"wagmi",ETHERS:"ethers",ETHERS5:"ethers5",BITCOIN:"bitcoin"},SIWX_DEFAULTS:{signOutOnDisconnect:!0},MANDATORY_WALLET_IDS_ON_MOBILE:[Mr.ConnectorExplorerIds[U.CONNECTOR_ID.COINBASE],Mr.ConnectorExplorerIds[U.CONNECTOR_ID.COINBASE_SDK],Mr.ConnectorExplorerIds[U.CONNECTOR_ID.BASE_ACCOUNT],Mr.ConnectorExplorerIds[U.SOLFLARE_CONNECTOR_NAME],Mr.ConnectorExplorerIds[U.PHANTOM_CONNECTOR_NAME],Mr.ConnectorExplorerIds[U.BINANCE_CONNECTOR_NAME]],DEFAULT_CONNECT_METHOD_ORDER:["email","social","wallet"]},F={cacheExpiry:{portfolio:3e4,nativeBalance:3e4,ens:3e5,identity:3e5,transactionsHistory:15e3,tokenPrice:15e3,latestAppKitVersion:6048e5,tonWallets:864e5},isCacheExpired(t,e){return Date.now()-t>e},getActiveNetworkProps(){const t=F.getActiveNamespace(),e=F.getActiveCaipNetworkId(),s=e?e.split(":")[1]:void 0,n=s?isNaN(Number(s))?s:Number(s):void 0;return{namespace:t,caipNetworkId:e,chainId:n}},setWalletConnectDeepLink({name:t,href:e}){try{ae.setItem(le.DEEPLINK_CHOICE,JSON.stringify({href:e,name:t}))}catch{console.info("Unable to set WalletConnect deep link")}},getWalletConnectDeepLink(){try{const t=ae.getItem(le.DEEPLINK_CHOICE);if(t)return JSON.parse(t)}catch{console.info("Unable to get WalletConnect deep link")}},deleteWalletConnectDeepLink(){try{ae.removeItem(le.DEEPLINK_CHOICE)}catch{console.info("Unable to delete WalletConnect deep link")}},setActiveNamespace(t){try{ae.setItem(le.ACTIVE_NAMESPACE,t)}catch{console.info("Unable to set active namespace")}},setActiveCaipNetworkId(t){try{ae.setItem(le.ACTIVE_CAIP_NETWORK_ID,t),F.setActiveNamespace(t.split(":")[0])}catch{console.info("Unable to set active caip network id")}},getActiveCaipNetworkId(){try{return ae.getItem(le.ACTIVE_CAIP_NETWORK_ID)}catch{console.info("Unable to get active caip network id");return}},deleteActiveCaipNetworkId(){try{ae.removeItem(le.ACTIVE_CAIP_NETWORK_ID)}catch{console.info("Unable to delete active caip network id")}},deleteConnectedConnectorId(t){try{const e=yc(t);ae.removeItem(e)}catch{console.info("Unable to delete connected connector id")}},setAppKitRecent(t){try{const e=F.getRecentWallets();e.find(n=>n.id===t.id)||(e.unshift(t),e.length>2&&e.pop(),ae.setItem(le.RECENT_WALLETS,JSON.stringify(e)),ae.setItem(le.RECENT_WALLET,JSON.stringify(t)))}catch{console.info("Unable to set AppKit recent")}},getRecentWallets(){try{const t=ae.getItem(le.RECENT_WALLETS);return t?JSON.parse(t):[]}catch{console.info("Unable to get AppKit recent")}return[]},getRecentWallet(){try{const t=ae.getItem(le.RECENT_WALLET);return t?JSON.parse(t):null}catch{console.info("Unable to get AppKit recent")}return null},deleteRecentWallet(){try{ae.removeItem(le.RECENT_WALLET)}catch{console.info("Unable to delete AppKit recent")}},setConnectedConnectorId(t,e){try{const s=yc(t);ae.setItem(s,e)}catch{console.info("Unable to set Connected Connector Id")}},getActiveNamespace(){try{return ae.getItem(le.ACTIVE_NAMESPACE)}catch{console.info("Unable to get active namespace")}},getConnectedConnectorId(t){if(t)try{const e=yc(t);return ae.getItem(e)}catch{console.info("Unable to get connected connector id in namespace",t)}},setConnectedSocialProvider(t){try{ae.setItem(le.CONNECTED_SOCIAL,t)}catch{console.info("Unable to set connected social provider")}},getConnectedSocialProvider(){try{return ae.getItem(le.CONNECTED_SOCIAL)}catch{console.info("Unable to get connected social provider")}},deleteConnectedSocialProvider(){try{ae.removeItem(le.CONNECTED_SOCIAL)}catch{console.info("Unable to delete connected social provider")}},getConnectedSocialUsername(){try{return ae.getItem(le.CONNECTED_SOCIAL_USERNAME)}catch{console.info("Unable to get connected social username")}},getStoredActiveCaipNetworkId(){var s;const t=ae.getItem(le.ACTIVE_CAIP_NETWORK_ID);return(s=t==null?void 0:t.split(":"))==null?void 0:s[1]},setConnectionStatus(t){try{ae.setItem(le.CONNECTION_STATUS,t)}catch{console.info("Unable to set connection status")}},getConnectionStatus(){try{return ae.getItem(le.CONNECTION_STATUS)}catch{return}},getConnectedNamespaces(){try{const t=ae.getItem(le.CONNECTED_NAMESPACES);return t!=null&&t.length?t.split(","):[]}catch{return[]}},setConnectedNamespaces(t){try{const e=Array.from(new Set(t));ae.setItem(le.CONNECTED_NAMESPACES,e.join(","))}catch{console.info("Unable to set namespaces in storage")}},addConnectedNamespace(t){try{const e=F.getConnectedNamespaces();e.includes(t)||(e.push(t),F.setConnectedNamespaces(e))}catch{console.info("Unable to add connected namespace")}},removeConnectedNamespace(t){try{const e=F.getConnectedNamespaces(),s=e.indexOf(t);s>-1&&(e.splice(s,1),F.setConnectedNamespaces(e))}catch{console.info("Unable to remove connected namespace")}},getTelegramSocialProvider(){try{return ae.getItem(le.TELEGRAM_SOCIAL_PROVIDER)}catch{return console.info("Unable to get telegram social provider"),null}},setTelegramSocialProvider(t){try{ae.setItem(le.TELEGRAM_SOCIAL_PROVIDER,t)}catch{console.info("Unable to set telegram social provider")}},removeTelegramSocialProvider(){try{ae.removeItem(le.TELEGRAM_SOCIAL_PROVIDER)}catch{console.info("Unable to remove telegram social provider")}},getBalanceCache(){let t={};try{const e=ae.getItem(le.PORTFOLIO_CACHE);t=e?JSON.parse(e):{}}catch{console.info("Unable to get balance cache")}return t},removeAddressFromBalanceCache(t){try{const e=F.getBalanceCache();ae.setItem(le.PORTFOLIO_CACHE,JSON.stringify({...e,[t]:void 0}))}catch{console.info("Unable to remove address from balance cache",t)}},getBalanceCacheForCaipAddress(t){try{const s=F.getBalanceCache()[t];if(s&&!this.isCacheExpired(s.timestamp,this.cacheExpiry.portfolio))return s.balance;F.removeAddressFromBalanceCache(t)}catch{console.info("Unable to get balance cache for address",t)}},updateBalanceCache(t){try{const e=F.getBalanceCache();e[t.caipAddress]=t,ae.setItem(le.PORTFOLIO_CACHE,JSON.stringify(e))}catch{console.info("Unable to update balance cache",t)}},getNativeBalanceCache(){let t={};try{const e=ae.getItem(le.NATIVE_BALANCE_CACHE);t=e?JSON.parse(e):{}}catch{console.info("Unable to get balance cache")}return t},removeAddressFromNativeBalanceCache(t){try{const e=F.getBalanceCache();ae.setItem(le.NATIVE_BALANCE_CACHE,JSON.stringify({...e,[t]:void 0}))}catch{console.info("Unable to remove address from balance cache",t)}},getNativeBalanceCacheForCaipAddress(t){try{const s=F.getNativeBalanceCache()[t];if(s&&!this.isCacheExpired(s.timestamp,this.cacheExpiry.nativeBalance))return s;console.info("Discarding cache for address",t),F.removeAddressFromBalanceCache(t)}catch{console.info("Unable to get balance cache for address",t)}},updateNativeBalanceCache(t){try{const e=F.getNativeBalanceCache();e[t.caipAddress]=t,ae.setItem(le.NATIVE_BALANCE_CACHE,JSON.stringify(e))}catch{console.info("Unable to update balance cache",t)}},getEnsCache(){let t={};try{const e=ae.getItem(le.ENS_CACHE);t=e?JSON.parse(e):{}}catch{console.info("Unable to get ens name cache")}return t},getEnsFromCacheForAddress(t){try{const s=F.getEnsCache()[t];if(s&&!this.isCacheExpired(s.timestamp,this.cacheExpiry.ens))return s.ens;F.removeEnsFromCache(t)}catch{console.info("Unable to get ens name from cache",t)}},updateEnsCache(t){try{const e=F.getEnsCache();e[t.address]=t,ae.setItem(le.ENS_CACHE,JSON.stringify(e))}catch{console.info("Unable to update ens name cache",t)}},removeEnsFromCache(t){try{const e=F.getEnsCache();ae.setItem(le.ENS_CACHE,JSON.stringify({...e,[t]:void 0}))}catch{console.info("Unable to remove ens name from cache",t)}},getIdentityCache(){let t={};try{const e=ae.getItem(le.IDENTITY_CACHE);t=e?JSON.parse(e):{}}catch{console.info("Unable to get identity cache")}return t},getIdentityFromCacheForAddress(t){try{const s=F.getIdentityCache()[t];if(s&&!this.isCacheExpired(s.timestamp,this.cacheExpiry.identity))return s.identity;F.removeIdentityFromCache(t)}catch{console.info("Unable to get identity from cache",t)}},updateIdentityCache(t){try{const e=F.getIdentityCache();e[t.address]={identity:t.identity,timestamp:t.timestamp},ae.setItem(le.IDENTITY_CACHE,JSON.stringify(e))}catch{console.info("Unable to update identity cache",t)}},removeIdentityFromCache(t){try{const e=F.getIdentityCache();ae.setItem(le.IDENTITY_CACHE,JSON.stringify({...e,[t]:void 0}))}catch{console.info("Unable to remove identity from cache",t)}},getTonWalletsCache(){try{const t=ae.getItem(le.TON_WALLETS_CACHE),e=t?JSON.parse(t):void 0;if(e&&!this.isCacheExpired(e.timestamp,this.cacheExpiry.tonWallets))return e;F.removeTonWalletsCache()}catch{console.info("Unable to get ton wallets cache")}},updateTonWalletsCache(t){try{const e=F.getTonWalletsCache()||{timestamp:0,wallets:[]};e.timestamp=new Date().getTime(),e.wallets=t,ae.setItem(le.TON_WALLETS_CACHE,JSON.stringify(e))}catch{console.info("Unable to update ton wallets cache",t)}},removeTonWalletsCache(){try{ae.removeItem(le.TON_WALLETS_CACHE)}catch{console.info("Unable to remove ton wallets cache")}},clearAddressCache(){try{ae.removeItem(le.PORTFOLIO_CACHE),ae.removeItem(le.NATIVE_BALANCE_CACHE),ae.removeItem(le.ENS_CACHE),ae.removeItem(le.IDENTITY_CACHE),ae.removeItem(le.HISTORY_TRANSACTIONS_CACHE)}catch{console.info("Unable to clear address cache")}},setPreferredAccountTypes(t){try{ae.setItem(le.PREFERRED_ACCOUNT_TYPES,JSON.stringify(t))}catch{console.info("Unable to set preferred account types",t)}},getPreferredAccountTypes(){try{const t=ae.getItem(le.PREFERRED_ACCOUNT_TYPES);return t?JSON.parse(t):{}}catch{console.info("Unable to get preferred account types")}return{}},setConnections(t,e){try{const s=F.getConnections(),n=s[e]??[],r=new Map;for(const o of n)r.set(o.connectorId,{...o});for(const o of t){const a=r.get(o.connectorId),c=o.connectorId===U.CONNECTOR_ID.AUTH;if(a&&!c){const l=new Set(a.accounts.map(u=>u.address.toLowerCase())),d=o.accounts.filter(u=>!l.has(u.address.toLowerCase()));a.accounts.push(...d)}else r.set(o.connectorId,{...o})}const i={...s,[e]:Array.from(r.values())};ae.setItem(le.CONNECTIONS,JSON.stringify(i))}catch(s){console.error("Unable to sync connections to storage",s)}},getConnections(){try{const t=ae.getItem(le.CONNECTIONS);return t?JSON.parse(t):{}}catch(t){return console.error("Unable to get connections from storage",t),{}}},deleteAddressFromConnection({connectorId:t,address:e,namespace:s}){try{const n=F.getConnections(),r=n[s]??[],i=new Map(r.map(a=>[a.connectorId,a])),o=i.get(t);o&&(o.accounts.filter(c=>c.address.toLowerCase()!==e.toLowerCase()).length===0?i.delete(t):i.set(t,{...o,accounts:o.accounts.filter(c=>c.address.toLowerCase()!==e.toLowerCase())})),ae.setItem(le.CONNECTIONS,JSON.stringify({...n,[s]:Array.from(i.values())}))}catch{console.error(`Unable to remove address "${e}" from connector "${t}" in namespace "${s}"`)}},getDisconnectedConnectorIds(){try{const t=ae.getItem(le.DISCONNECTED_CONNECTOR_IDS);return t?JSON.parse(t):{}}catch{console.info("Unable to get disconnected connector ids")}return{}},addDisconnectedConnectorId(t,e){try{const s=F.getDisconnectedConnectorIds(),n=s[e]??[];n.push(t),ae.setItem(le.DISCONNECTED_CONNECTOR_IDS,JSON.stringify({...s,[e]:Array.from(new Set(n))}))}catch{console.error(`Unable to set disconnected connector id "${t}" for namespace "${e}"`)}},removeDisconnectedConnectorId(t,e){try{const s=F.getDisconnectedConnectorIds();let n=s[e]??[];n=n.filter(r=>r.toLowerCase()!==t.toLowerCase()),ae.setItem(le.DISCONNECTED_CONNECTOR_IDS,JSON.stringify({...s,[e]:Array.from(new Set(n))}))}catch{console.error(`Unable to remove disconnected connector id "${t}" for namespace "${e}"`)}},isConnectorDisconnected(t,e){try{return(F.getDisconnectedConnectorIds()[e]??[]).some(r=>r.toLowerCase()===t.toLowerCase())}catch{console.info(`Unable to get disconnected connector id "${t}" for namespace "${e}"`)}return!1},getTransactionsCache(){try{const t=ae.getItem(le.HISTORY_TRANSACTIONS_CACHE);return t?JSON.parse(t):{}}catch{console.info("Unable to get transactions cache")}return{}},getTransactionsCacheForAddress({address:t,chainId:e=""}){var s;try{const r=(s=F.getTransactionsCache()[t])==null?void 0:s[e];if(r&&!this.isCacheExpired(r.timestamp,this.cacheExpiry.transactionsHistory))return r.transactions;F.removeTransactionsCache({address:t,chainId:e})}catch{console.info("Unable to get transactions cache")}},updateTransactionsCache({address:t,chainId:e="",timestamp:s,transactions:n}){try{const r=F.getTransactionsCache();r[t]={...r[t],[e]:{timestamp:s,transactions:n}},ae.setItem(le.HISTORY_TRANSACTIONS_CACHE,JSON.stringify(r))}catch{console.info("Unable to update transactions cache",{address:t,chainId:e,timestamp:s,transactions:n})}},removeTransactionsCache({address:t,chainId:e}){try{const s=F.getTransactionsCache(),n=(s==null?void 0:s[t])||{},{[e]:r,...i}=n;ae.setItem(le.HISTORY_TRANSACTIONS_CACHE,JSON.stringify({...s,[t]:i}))}catch{console.info("Unable to remove transactions cache",{address:t,chainId:e})}},getTokenPriceCache(){try{const t=ae.getItem(le.TOKEN_PRICE_CACHE);return t?JSON.parse(t):{}}catch{console.info("Unable to get token price cache")}return{}},getTokenPriceCacheForAddresses(t){try{const s=F.getTokenPriceCache()[t.join(",")];if(s&&!this.isCacheExpired(s.timestamp,this.cacheExpiry.tokenPrice))return s.tokenPrice;F.removeTokenPriceCache(t)}catch{console.info("Unable to get token price cache for addresses",t)}},updateTokenPriceCache(t){try{const e=F.getTokenPriceCache();e[t.addresses.join(",")]={timestamp:t.timestamp,tokenPrice:t.tokenPrice},ae.setItem(le.TOKEN_PRICE_CACHE,JSON.stringify(e))}catch{console.info("Unable to update token price cache",t)}},removeTokenPriceCache(t){try{const e=F.getTokenPriceCache();ae.setItem(le.TOKEN_PRICE_CACHE,JSON.stringify({...e,[t.join(",")]:void 0}))}catch{console.info("Unable to remove token price cache",t)}},getLatestAppKitVersion(){try{const t=this.getLatestAppKitVersionCache(),e=t==null?void 0:t.version;return e&&!this.isCacheExpired(t.timestamp,this.cacheExpiry.latestAppKitVersion)?e:void 0}catch{console.info("Unable to get latest AppKit version")}},getLatestAppKitVersionCache(){try{const t=ae.getItem(le.LATEST_APPKIT_VERSION);return t?JSON.parse(t):{}}catch{console.info("Unable to get latest AppKit version cache")}return{}},updateLatestAppKitVersion(t){try{const e=F.getLatestAppKitVersionCache();e.timestamp=t.timestamp,e.version=t.version,ae.setItem(le.LATEST_APPKIT_VERSION,JSON.stringify(e))}catch{console.info("Unable to update latest AppKit version on local storage",t)}}},X={getWindow(){if(!(typeof window>"u"))return window},isMobile(){var t;return this.isClient()?!!(window!=null&&window.matchMedia&&typeof window.matchMedia=="function"&&((t=window.matchMedia("(pointer:coarse)"))!=null&&t.matches)||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1},checkCaipNetwork(t,e=""){return t==null?void 0:t.caipNetworkId.toLocaleLowerCase().includes(e.toLowerCase())},isAndroid(){if(!this.isMobile())return!1;const t=window==null?void 0:window.navigator.userAgent.toLowerCase();return X.isMobile()&&t.includes("android")},isIos(){if(!this.isMobile())return!1;const t=window==null?void 0:window.navigator.userAgent.toLowerCase();return t.includes("iphone")||t.includes("ipad")},isSafari(){return this.isClient()?(window==null?void 0:window.navigator.userAgent.toLowerCase()).includes("safari"):!1},isClient(){return typeof window<"u"},isPairingExpired(t){return t?t-Date.now()<=Ne.TEN_SEC_MS:!0},isAllowedRetry(t,e=Ne.ONE_SEC_MS){return Date.now()-t>=e},copyToClopboard(t){navigator.clipboard.writeText(t)},isIframe(){try{return(window==null?void 0:window.self)!==(window==null?void 0:window.top)}catch{return!1}},isSafeApp(){var t,e;if(X.isClient()&&window.self!==window.top)try{const s=(e=(t=window==null?void 0:window.location)==null?void 0:t.ancestorOrigins)==null?void 0:e[0],n="https://app.safe.global";if(s){const r=new URL(s),i=new URL(n);return r.hostname===i.hostname}}catch{return!1}return!1},getPairingExpiry(){return Date.now()+Ne.FOUR_MINUTES_MS},getNetworkId(t){return t==null?void 0:t.split(":")[1]},getPlainAddress(t){return t==null?void 0:t.split(":")[2]},async wait(t){return new Promise(e=>{setTimeout(e,t)})},debounce(t,e=500){let s;return(...n)=>{function r(){t(...n)}s&&clearTimeout(s),s=setTimeout(r,e)}},isHttpUrl(t){return t.startsWith("http://")||t.startsWith("https://")},formatNativeUrl(t,e,s=null){if(X.isHttpUrl(t))return this.formatUniversalUrl(t,e);let n=t,r=s;n.includes("://")||(n=t.replaceAll("/","").replaceAll(":",""),n=`${n}://`),n.endsWith("/")||(n=`${n}/`),r&&!(r!=null&&r.endsWith("/"))&&(r=`${r}/`),this.isTelegram()&&this.isAndroid()&&(e=encodeURIComponent(e));const i=encodeURIComponent(e);return{redirect:`${n}wc?uri=${i}`,redirectUniversalLink:r?`${r}wc?uri=${i}`:void 0,href:n}},formatUniversalUrl(t,e){if(!X.isHttpUrl(t))return this.formatNativeUrl(t,e);let s=t;s.endsWith("/")||(s=`${s}/`);const n=encodeURIComponent(e);return{redirect:`${s}wc?uri=${n}`,href:s}},getOpenTargetForPlatform(t){return t==="popupWindow"?t:this.isTelegram()?F.getTelegramSocialProvider()?"_top":"_blank":t},openHref(t,e,s){window==null||window.open(t,this.getOpenTargetForPlatform(e),s||"noreferrer noopener")},returnOpenHref(t,e,s){return window==null?void 0:window.open(t,this.getOpenTargetForPlatform(e),s||"noreferrer noopener")},isTelegram(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)},isPWA(){var s,n;if(typeof window>"u")return!1;const t=window!=null&&window.matchMedia&&typeof window.matchMedia=="function"?(s=window.matchMedia("(display-mode: standalone)"))==null?void 0:s.matches:!1,e=(n=window==null?void 0:window.navigator)==null?void 0:n.standalone;return!!(t||e)},async preloadImage(t){const e=new Promise((s,n)=>{const r=new Image;r.onload=s,r.onerror=n,r.crossOrigin="anonymous",r.src=t});return Promise.race([e,X.wait(2e3)])},parseBalance(t,e){let s="0.000";if(typeof t=="string"){const c=Number(t);if(!isNaN(c)){const l=(Math.floor(c*1e3)/1e3).toFixed(3);l&&(s=l)}}const[n,r]=s.split("."),i=n||"0",o=r||"000";return{formattedText:`${i}.${o}${e?` ${e}`:""}`,value:i,decimals:o,symbol:e}},getApiUrl(){return U.W3M_API_URL},getBlockchainApiUrl(){return U.BLOCKCHAIN_API_RPC_URL},getAnalyticsUrl(){return U.PULSE_API_URL},getUUID(){return crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,t=>{const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})},parseError(t){var e,s;return typeof t=="string"?t:typeof((s=(e=t==null?void 0:t.issues)==null?void 0:e[0])==null?void 0:s.message)=="string"?t.issues[0].message:t instanceof Error?t.message:"Unknown error"},sortRequestedNetworks(t,e=[]){const s={};return e&&t&&(t.forEach((n,r)=>{s[n]=r}),e.sort((n,r)=>{const i=s[n.id],o=s[r.id];return i!==void 0&&o!==void 0?i-o:i!==void 0?-1:o!==void 0?1:0})),e},calculateBalance(t){let e=0;for(const s of t)e+=s.value??0;return e},formatTokenBalance(t){const e=t.toFixed(2),[s,n]=e.split(".");return{dollars:s,pennies:n}},isAddress(t,e="eip155"){switch(e){case"eip155":if(/^(?:0x)?[0-9a-f]{40}$/iu.test(t)){if(/^(?:0x)?[0-9a-f]{40}$/iu.test(t)||/^(?:0x)?[0-9A-F]{40}$/iu.test(t))return!0}else return!1;return!1;case"solana":return/[1-9A-HJ-NP-Za-km-z]{32,44}$/iu.test(t);default:return!1}},uniqueBy(t,e){const s=new Set;return t.filter(n=>{const r=n[e];return s.has(r)?!1:(s.add(r),!0)})},generateSdkVersion(t,e,s){const r=t.length===0?Ne.ADAPTER_TYPES.UNIVERSAL:t.map(i=>i.adapterType).join(",");return`${e}-${r}-${s}`},createAccount(t,e,s,n,r){return{namespace:t,address:e,type:s,publicKey:n,path:r}},isCaipAddress(t){if(typeof t!="string")return!1;const e=t.split(":"),s=e[0];return e.filter(Boolean).length===3&&s in U.CHAIN_NAME_MAP},getAccount(t){return t?typeof t=="string"?{address:t,chainId:void 0}:{address:t.address,chainId:t.chainId}:{address:void 0,chainId:void 0}},isMac(){const t=window==null?void 0:window.navigator.userAgent.toLowerCase();return t.includes("macintosh")&&!t.includes("safari")},formatTelegramSocialLoginUrl(t){const e=`--${encodeURIComponent(window==null?void 0:window.location.href)}`,s="state=";if(new URL(t).host==="auth.magic.link"){const r="provider_authorization_url=",i=t.substring(t.indexOf(r)+r.length),o=this.injectIntoUrl(decodeURIComponent(i),s,e);return t.replace(i,encodeURIComponent(o))}return this.injectIntoUrl(t,s,e)},injectIntoUrl(t,e,s){const n=t.indexOf(e);if(n===-1)throw new Error(`${e} parameter not found in the URL: ${t}`);const r=t.indexOf("&",n),i=e.length,o=r!==-1?r:t.length,a=t.substring(0,n+i),c=t.substring(n+i,o),l=t.substring(r),d=c+s;return a+d+l}};var ai={};const gw="https://secure.walletconnect.org/sdk",mw=(typeof wn<"u"&&typeof ai<"u"?ai.NEXT_PUBLIC_SECURE_SITE_SDK_URL:void 0)||gw,yw=(typeof wn<"u"&&typeof ai<"u"?ai.NEXT_PUBLIC_DEFAULT_LOG_LEVEL:void 0)||"error",ww=(typeof wn<"u"&&typeof ai<"u"?ai.NEXT_PUBLIC_SECURE_SITE_SDK_VERSION:void 0)||"4",oe={APP_EVENT_KEY:"@w3m-app/",FRAME_EVENT_KEY:"@w3m-frame/",RPC_METHOD_KEY:"RPC_",STORAGE_KEY:"@appkit-wallet/",SESSION_TOKEN_KEY:"SESSION_TOKEN_KEY",EMAIL_LOGIN_USED_KEY:"EMAIL_LOGIN_USED_KEY",LAST_USED_CHAIN_KEY:"LAST_USED_CHAIN_KEY",LAST_EMAIL_LOGIN_TIME:"LAST_EMAIL_LOGIN_TIME",EMAIL:"EMAIL",PREFERRED_ACCOUNT_TYPE:"PREFERRED_ACCOUNT_TYPE",SMART_ACCOUNT_ENABLED:"SMART_ACCOUNT_ENABLED",SMART_ACCOUNT_ENABLED_NETWORKS:"SMART_ACCOUNT_ENABLED_NETWORKS",SOCIAL_USERNAME:"SOCIAL_USERNAME",APP_SWITCH_NETWORK:"@w3m-app/SWITCH_NETWORK",APP_CONNECT_EMAIL:"@w3m-app/CONNECT_EMAIL",APP_CONNECT_DEVICE:"@w3m-app/CONNECT_DEVICE",APP_CONNECT_OTP:"@w3m-app/CONNECT_OTP",APP_CONNECT_SOCIAL:"@w3m-app/CONNECT_SOCIAL",APP_GET_SOCIAL_REDIRECT_URI:"@w3m-app/GET_SOCIAL_REDIRECT_URI",APP_GET_USER:"@w3m-app/GET_USER",APP_SIGN_OUT:"@w3m-app/SIGN_OUT",APP_IS_CONNECTED:"@w3m-app/IS_CONNECTED",APP_GET_CHAIN_ID:"@w3m-app/GET_CHAIN_ID",APP_RPC_REQUEST:"@w3m-app/RPC_REQUEST",APP_UPDATE_EMAIL:"@w3m-app/UPDATE_EMAIL",APP_UPDATE_EMAIL_PRIMARY_OTP:"@w3m-app/UPDATE_EMAIL_PRIMARY_OTP",APP_UPDATE_EMAIL_SECONDARY_OTP:"@w3m-app/UPDATE_EMAIL_SECONDARY_OTP",APP_AWAIT_UPDATE_EMAIL:"@w3m-app/AWAIT_UPDATE_EMAIL",APP_SYNC_THEME:"@w3m-app/SYNC_THEME",APP_SYNC_DAPP_DATA:"@w3m-app/SYNC_DAPP_DATA",APP_GET_SMART_ACCOUNT_ENABLED_NETWORKS:"@w3m-app/GET_SMART_ACCOUNT_ENABLED_NETWORKS",APP_INIT_SMART_ACCOUNT:"@w3m-app/INIT_SMART_ACCOUNT",APP_SET_PREFERRED_ACCOUNT:"@w3m-app/SET_PREFERRED_ACCOUNT",APP_CONNECT_FARCASTER:"@w3m-app/CONNECT_FARCASTER",APP_GET_FARCASTER_URI:"@w3m-app/GET_FARCASTER_URI",APP_RELOAD:"@w3m-app/RELOAD",APP_RPC_ABORT:"@w3m-app/RPC_ABORT",FRAME_SWITCH_NETWORK_ERROR:"@w3m-frame/SWITCH_NETWORK_ERROR",FRAME_SWITCH_NETWORK_SUCCESS:"@w3m-frame/SWITCH_NETWORK_SUCCESS",FRAME_CONNECT_EMAIL_ERROR:"@w3m-frame/CONNECT_EMAIL_ERROR",FRAME_CONNECT_EMAIL_SUCCESS:"@w3m-frame/CONNECT_EMAIL_SUCCESS",FRAME_CONNECT_DEVICE_ERROR:"@w3m-frame/CONNECT_DEVICE_ERROR",FRAME_CONNECT_DEVICE_SUCCESS:"@w3m-frame/CONNECT_DEVICE_SUCCESS",FRAME_CONNECT_OTP_SUCCESS:"@w3m-frame/CONNECT_OTP_SUCCESS",FRAME_CONNECT_OTP_ERROR:"@w3m-frame/CONNECT_OTP_ERROR",FRAME_CONNECT_SOCIAL_SUCCESS:"@w3m-frame/CONNECT_SOCIAL_SUCCESS",FRAME_CONNECT_SOCIAL_ERROR:"@w3m-frame/CONNECT_SOCIAL_ERROR",FRAME_CONNECT_FARCASTER_SUCCESS:"@w3m-frame/CONNECT_FARCASTER_SUCCESS",FRAME_CONNECT_FARCASTER_ERROR:"@w3m-frame/CONNECT_FARCASTER_ERROR",FRAME_GET_FARCASTER_URI_SUCCESS:"@w3m-frame/GET_FARCASTER_URI_SUCCESS",FRAME_GET_FARCASTER_URI_ERROR:"@w3m-frame/GET_FARCASTER_URI_ERROR",FRAME_GET_SOCIAL_REDIRECT_URI_SUCCESS:"@w3m-frame/GET_SOCIAL_REDIRECT_URI_SUCCESS",FRAME_GET_SOCIAL_REDIRECT_URI_ERROR:"@w3m-frame/GET_SOCIAL_REDIRECT_URI_ERROR",FRAME_GET_USER_SUCCESS:"@w3m-frame/GET_USER_SUCCESS",FRAME_GET_USER_ERROR:"@w3m-frame/GET_USER_ERROR",FRAME_SIGN_OUT_SUCCESS:"@w3m-frame/SIGN_OUT_SUCCESS",FRAME_SIGN_OUT_ERROR:"@w3m-frame/SIGN_OUT_ERROR",FRAME_IS_CONNECTED_SUCCESS:"@w3m-frame/IS_CONNECTED_SUCCESS",FRAME_IS_CONNECTED_ERROR:"@w3m-frame/IS_CONNECTED_ERROR",FRAME_GET_CHAIN_ID_SUCCESS:"@w3m-frame/GET_CHAIN_ID_SUCCESS",FRAME_GET_CHAIN_ID_ERROR:"@w3m-frame/GET_CHAIN_ID_ERROR",FRAME_RPC_REQUEST_SUCCESS:"@w3m-frame/RPC_REQUEST_SUCCESS",FRAME_RPC_REQUEST_ERROR:"@w3m-frame/RPC_REQUEST_ERROR",FRAME_SESSION_UPDATE:"@w3m-frame/SESSION_UPDATE",FRAME_UPDATE_EMAIL_SUCCESS:"@w3m-frame/UPDATE_EMAIL_SUCCESS",FRAME_UPDATE_EMAIL_ERROR:"@w3m-frame/UPDATE_EMAIL_ERROR",FRAME_UPDATE_EMAIL_PRIMARY_OTP_SUCCESS:"@w3m-frame/UPDATE_EMAIL_PRIMARY_OTP_SUCCESS",FRAME_UPDATE_EMAIL_PRIMARY_OTP_ERROR:"@w3m-frame/UPDATE_EMAIL_PRIMARY_OTP_ERROR",FRAME_UPDATE_EMAIL_SECONDARY_OTP_SUCCESS:"@w3m-frame/UPDATE_EMAIL_SECONDARY_OTP_SUCCESS",FRAME_UPDATE_EMAIL_SECONDARY_OTP_ERROR:"@w3m-frame/UPDATE_EMAIL_SECONDARY_OTP_ERROR",FRAME_SYNC_THEME_SUCCESS:"@w3m-frame/SYNC_THEME_SUCCESS",FRAME_SYNC_THEME_ERROR:"@w3m-frame/SYNC_THEME_ERROR",FRAME_SYNC_DAPP_DATA_SUCCESS:"@w3m-frame/SYNC_DAPP_DATA_SUCCESS",FRAME_SYNC_DAPP_DATA_ERROR:"@w3m-frame/SYNC_DAPP_DATA_ERROR",FRAME_GET_SMART_ACCOUNT_ENABLED_NETWORKS_SUCCESS:"@w3m-frame/GET_SMART_ACCOUNT_ENABLED_NETWORKS_SUCCESS",FRAME_GET_SMART_ACCOUNT_ENABLED_NETWORKS_ERROR:"@w3m-frame/GET_SMART_ACCOUNT_ENABLED_NETWORKS_ERROR",FRAME_INIT_SMART_ACCOUNT_SUCCESS:"@w3m-frame/INIT_SMART_ACCOUNT_SUCCESS",FRAME_INIT_SMART_ACCOUNT_ERROR:"@w3m-frame/INIT_SMART_ACCOUNT_ERROR",FRAME_SET_PREFERRED_ACCOUNT_SUCCESS:"@w3m-frame/SET_PREFERRED_ACCOUNT_SUCCESS",FRAME_SET_PREFERRED_ACCOUNT_ERROR:"@w3m-frame/SET_PREFERRED_ACCOUNT_ERROR",FRAME_READY:"@w3m-frame/READY",FRAME_RELOAD_SUCCESS:"@w3m-frame/RELOAD_SUCCESS",FRAME_RELOAD_ERROR:"@w3m-frame/RELOAD_ERROR",FRAME_RPC_ABORT_SUCCESS:"@w3m-frame/RPC_ABORT_SUCCESS",FRAME_RPC_ABORT_ERROR:"@w3m-frame/RPC_ABORT_ERROR",RPC_RESPONSE_TYPE_ERROR:"RPC_RESPONSE_ERROR",RPC_RESPONSE_TYPE_TX:"RPC_RESPONSE_TRANSACTION_HASH",RPC_RESPONSE_TYPE_OBJECT:"RPC_RESPONSE_OBJECT"},tt={SAFE_RPC_METHODS:["eth_accounts","eth_blockNumber","eth_call","eth_chainId","eth_estimateGas","eth_feeHistory","eth_gasPrice","eth_getAccount","eth_getBalance","eth_getBlockByHash","eth_getBlockByNumber","eth_getBlockReceipts","eth_getBlockTransactionCountByHash","eth_getBlockTransactionCountByNumber","eth_getCode","eth_getFilterChanges","eth_getFilterLogs","eth_getLogs","eth_getProof","eth_getStorageAt","eth_getTransactionByBlockHashAndIndex","eth_getTransactionByBlockNumberAndIndex","eth_getTransactionByHash","eth_getTransactionCount","eth_getTransactionReceipt","eth_getUncleCountByBlockHash","eth_getUncleCountByBlockNumber","eth_maxPriorityFeePerGas","eth_newBlockFilter","eth_newFilter","eth_newPendingTransactionFilter","eth_sendRawTransaction","eth_syncing","eth_uninstallFilter","wallet_getCapabilities","wallet_getCallsStatus","eth_getUserOperationReceipt","eth_estimateUserOperationGas","eth_getUserOperationByHash","eth_supportedEntryPoints","wallet_getAssets"],NOT_SAFE_RPC_METHODS:["personal_sign","eth_signTypedData_v4","eth_sendTransaction","solana_signMessage","solana_signTransaction","solana_signAllTransactions","solana_signAndSendTransaction","wallet_sendCalls","wallet_grantPermissions","wallet_revokePermissions","eth_sendUserOperation"],GET_CHAIN_ID:"eth_chainId",RPC_METHOD_NOT_ALLOWED_MESSAGE:"Requested RPC call is not allowed",RPC_METHOD_NOT_ALLOWED_UI_MESSAGE:"Action not allowed",ACCOUNT_TYPES:{EOA:"eoa",SMART_ACCOUNT:"smartAccount"}},Nu={transactionHash:/^0x(?:[A-Fa-f0-9]{64})$/u,signedMessage:/^0x(?:[a-fA-F0-9]{62,})$/u},lt={set(t,e){cs.isClient&&localStorage.setItem(`${oe.STORAGE_KEY}${t}`,e)},get(t){return cs.isClient?localStorage.getItem(`${oe.STORAGE_KEY}${t}`):null},delete(t,e){cs.isClient&&(e?localStorage.removeItem(t):localStorage.removeItem(`${oe.STORAGE_KEY}${t}`))}},jo=30*1e3,cs={checkIfAllowedToTriggerEmail(){const t=lt.get(oe.LAST_EMAIL_LOGIN_TIME);if(t){const e=Date.now()-Number(t);if(e<jo){const s=Math.ceil((jo-e)/1e3);throw new Error(`Please try again after ${s} seconds`)}}},getTimeToNextEmailLogin(){const t=lt.get(oe.LAST_EMAIL_LOGIN_TIME);if(t){const e=Date.now()-Number(t);if(e<jo)return Math.ceil((jo-e)/1e3)}return 0},checkIfRequestExists(t){return tt.NOT_SAFE_RPC_METHODS.includes(t.method)||tt.SAFE_RPC_METHODS.includes(t.method)},getResponseType(t){return typeof t=="string"&&((t==null?void 0:t.match(Nu.transactionHash))||(t==null?void 0:t.match(Nu.signedMessage)))?oe.RPC_RESPONSE_TYPE_TX:oe.RPC_RESPONSE_TYPE_OBJECT},checkIfRequestIsSafe(t){return tt.SAFE_RPC_METHODS.includes(t.method)},isClient:typeof window<"u"};var Me;(function(t){t.assertEqual=r=>r;function e(r){}t.assertIs=e;function s(r){throw new Error}t.assertNever=s,t.arrayToEnum=r=>{const i={};for(const o of r)i[o]=o;return i},t.getValidEnumValues=r=>{const i=t.objectKeys(r).filter(a=>typeof r[r[a]]!="number"),o={};for(const a of i)o[a]=r[a];return t.objectValues(o)},t.objectValues=r=>t.objectKeys(r).map(function(i){return r[i]}),t.objectKeys=typeof Object.keys=="function"?r=>Object.keys(r):r=>{const i=[];for(const o in r)Object.prototype.hasOwnProperty.call(r,o)&&i.push(o);return i},t.find=(r,i)=>{for(const o of r)if(i(o))return o},t.isInteger=typeof Number.isInteger=="function"?r=>Number.isInteger(r):r=>typeof r=="number"&&isFinite(r)&&Math.floor(r)===r;function n(r,i=" | "){return r.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}t.joinValues=n,t.jsonStringifyReplacer=(r,i)=>typeof i=="bigint"?i.toString():i})(Me||(Me={}));var bl;(function(t){t.mergeShapes=(e,s)=>({...e,...s})})(bl||(bl={}));const se=Me.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Mn=t=>{switch(typeof t){case"undefined":return se.undefined;case"string":return se.string;case"number":return isNaN(t)?se.nan:se.number;case"boolean":return se.boolean;case"function":return se.function;case"bigint":return se.bigint;case"symbol":return se.symbol;case"object":return Array.isArray(t)?se.array:t===null?se.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?se.promise:typeof Map<"u"&&t instanceof Map?se.map:typeof Set<"u"&&t instanceof Set?se.set:typeof Date<"u"&&t instanceof Date?se.date:se.object;default:return se.unknown}},K=Me.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Ew=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:");class ks extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const s=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,s):this.__proto__=s,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const s=e||function(i){return i.message},n={_errors:[]},r=i=>{for(const o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(r);else if(o.code==="invalid_return_type")r(o.returnTypeError);else if(o.code==="invalid_arguments")r(o.argumentsError);else if(o.path.length===0)n._errors.push(s(o));else{let a=n,c=0;for(;c<o.path.length;){const l=o.path[c];c===o.path.length-1?(a[l]=a[l]||{_errors:[]},a[l]._errors.push(s(o))):a[l]=a[l]||{_errors:[]},a=a[l],c++}}};return r(this),n}toString(){return this.message}get message(){return JSON.stringify(this.issues,Me.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=s=>s.message){const s={},n=[];for(const r of this.issues)r.path.length>0?(s[r.path[0]]=s[r.path[0]]||[],s[r.path[0]].push(e(r))):n.push(e(r));return{formErrors:n,fieldErrors:s}}get formErrors(){return this.flatten()}}ks.create=t=>new ks(t);const eo=(t,e)=>{let s;switch(t.code){case K.invalid_type:t.received===se.undefined?s="Required":s=`Expected ${t.expected}, received ${t.received}`;break;case K.invalid_literal:s=`Invalid literal value, expected ${JSON.stringify(t.expected,Me.jsonStringifyReplacer)}`;break;case K.unrecognized_keys:s=`Unrecognized key(s) in object: ${Me.joinValues(t.keys,", ")}`;break;case K.invalid_union:s="Invalid input";break;case K.invalid_union_discriminator:s=`Invalid discriminator value. Expected ${Me.joinValues(t.options)}`;break;case K.invalid_enum_value:s=`Invalid enum value. Expected ${Me.joinValues(t.options)}, received '${t.received}'`;break;case K.invalid_arguments:s="Invalid function arguments";break;case K.invalid_return_type:s="Invalid function return type";break;case K.invalid_date:s="Invalid date";break;case K.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(s=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(s=`${s} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?s=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?s=`Invalid input: must end with "${t.validation.endsWith}"`:Me.assertNever(t.validation):t.validation!=="regex"?s=`Invalid ${t.validation}`:s="Invalid";break;case K.too_small:t.type==="array"?s=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?s=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?s=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?s=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:s="Invalid input";break;case K.too_big:t.type==="array"?s=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?s=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?s=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?s=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?s=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:s="Invalid input";break;case K.custom:s="Invalid input";break;case K.invalid_intersection_types:s="Intersection results could not be merged";break;case K.not_multiple_of:s=`Number must be a multiple of ${t.multipleOf}`;break;case K.not_finite:s="Number must be finite";break;default:s=e.defaultError,Me.assertNever(t)}return{message:s}};let If=eo;function bw(t){If=t}function _a(){return If}const Aa=t=>{const{data:e,path:s,errorMaps:n,issueData:r}=t,i=[...s,...r.path||[]],o={...r,path:i};let a="";const c=n.filter(l=>!!l).slice().reverse();for(const l of c)a=l(o,{data:e,defaultError:a}).message;return{...r,path:i,message:r.message||a}},vw=[];function ie(t,e){const s=Aa({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,_a(),eo].filter(n=>!!n)});t.common.issues.push(s)}class kt{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,s){const n=[];for(const r of s){if(r.status==="aborted")return be;r.status==="dirty"&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,s){const n=[];for(const r of s)n.push({key:await r.key,value:await r.value});return kt.mergeObjectSync(e,n)}static mergeObjectSync(e,s){const n={};for(const r of s){const{key:i,value:o}=r;if(i.status==="aborted"||o.status==="aborted")return be;i.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||r.alwaysSet)&&(n[i.value]=o.value)}return{status:e.value,value:n}}}const be=Object.freeze({status:"aborted"}),Nf=t=>({status:"dirty",value:t}),Ft=t=>({status:"valid",value:t}),vl=t=>t.status==="aborted",Cl=t=>t.status==="dirty",to=t=>t.status==="valid",Sa=t=>typeof Promise<"u"&&t instanceof Promise;var pe;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(pe||(pe={}));class Xs{constructor(e,s,n,r){this._cachedPath=[],this.parent=e,this.data=s,this._path=n,this._key=r}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Tu=(t,e)=>{if(to(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const s=new ks(t.common.issues);return this._error=s,this._error}}};function _e(t){if(!t)return{};const{errorMap:e,invalid_type_error:s,required_error:n,description:r}=t;if(e&&(s||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:r}:{errorMap:(o,a)=>o.code!=="invalid_type"?{message:a.defaultError}:typeof a.data>"u"?{message:n??a.defaultError}:{message:s??a.defaultError},description:r}}class Se{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return Mn(e.data)}_getOrReturnCtx(e,s){return s||{common:e.parent.common,data:e.data,parsedType:Mn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new kt,ctx:{common:e.parent.common,data:e.data,parsedType:Mn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const s=this._parse(e);if(Sa(s))throw new Error("Synchronous parse encountered promise.");return s}_parseAsync(e){const s=this._parse(e);return Promise.resolve(s)}parse(e,s){const n=this.safeParse(e,s);if(n.success)return n.data;throw n.error}safeParse(e,s){var n;const r={common:{issues:[],async:(n=s==null?void 0:s.async)!==null&&n!==void 0?n:!1,contextualErrorMap:s==null?void 0:s.errorMap},path:(s==null?void 0:s.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Mn(e)},i=this._parseSync({data:e,path:r.path,parent:r});return Tu(r,i)}async parseAsync(e,s){const n=await this.safeParseAsync(e,s);if(n.success)return n.data;throw n.error}async safeParseAsync(e,s){const n={common:{issues:[],contextualErrorMap:s==null?void 0:s.errorMap,async:!0},path:(s==null?void 0:s.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Mn(e)},r=this._parse({data:e,path:n.path,parent:n}),i=await(Sa(r)?r:Promise.resolve(r));return Tu(n,i)}refine(e,s){const n=r=>typeof s=="string"||typeof s>"u"?{message:s}:typeof s=="function"?s(r):s;return this._refinement((r,i)=>{const o=e(r),a=()=>i.addIssue({code:K.custom,...n(r)});return typeof Promise<"u"&&o instanceof Promise?o.then(c=>c?!0:(a(),!1)):o?!0:(a(),!1)})}refinement(e,s){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof s=="function"?s(n,r):s),!1))}_refinement(e){return new Ds({schema:this,typeName:me.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return En.create(this,this._def)}nullable(){return Nr.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Us.create(this,this._def)}promise(){return li.create(this,this._def)}or(e){return io.create([this,e],this._def)}and(e){return oo.create(this,e,this._def)}transform(e){return new Ds({..._e(this._def),schema:this,typeName:me.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const s=typeof e=="function"?e:()=>e;return new ho({..._e(this._def),innerType:this,defaultValue:s,typeName:me.ZodDefault})}brand(){return new Rf({typeName:me.ZodBranded,type:this,..._e(this._def)})}catch(e){const s=typeof e=="function"?e:()=>e;return new Ra({..._e(this._def),innerType:this,catchValue:s,typeName:me.ZodCatch})}describe(e){const s=this.constructor;return new s({...this._def,description:e})}pipe(e){return Ao.create(this,e)}readonly(){return Pa.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Cw=/^c[^\s-]{8,}$/i,_w=/^[a-z][a-z0-9]*$/,Aw=/^[0-9A-HJKMNP-TV-Z]{26}$/,Sw=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Iw=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Nw="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Ec;const Tw=/^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/,Rw=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,Ow=t=>t.precision?t.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${t.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${t.precision}}Z$`):t.precision===0?t.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"):t.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$");function Pw(t,e){return!!((e==="v4"||!e)&&Tw.test(t)||(e==="v6"||!e)&&Rw.test(t))}class xs extends Se{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==se.string){const i=this._getOrReturnCtx(e);return ie(i,{code:K.invalid_type,expected:se.string,received:i.parsedType}),be}const n=new kt;let r;for(const i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(r=this._getOrReturnCtx(e,r),ie(r,{code:K.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="max")e.data.length>i.value&&(r=this._getOrReturnCtx(e,r),ie(r,{code:K.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="length"){const o=e.data.length>i.value,a=e.data.length<i.value;(o||a)&&(r=this._getOrReturnCtx(e,r),o?ie(r,{code:K.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):a&&ie(r,{code:K.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),n.dirty())}else if(i.kind==="email")Iw.test(e.data)||(r=this._getOrReturnCtx(e,r),ie(r,{validation:"email",code:K.invalid_string,message:i.message}),n.dirty());else if(i.kind==="emoji")Ec||(Ec=new RegExp(Nw,"u")),Ec.test(e.data)||(r=this._getOrReturnCtx(e,r),ie(r,{validation:"emoji",code:K.invalid_string,message:i.message}),n.dirty());else if(i.kind==="uuid")Sw.test(e.data)||(r=this._getOrReturnCtx(e,r),ie(r,{validation:"uuid",code:K.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid")Cw.test(e.data)||(r=this._getOrReturnCtx(e,r),ie(r,{validation:"cuid",code:K.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid2")_w.test(e.data)||(r=this._getOrReturnCtx(e,r),ie(r,{validation:"cuid2",code:K.invalid_string,message:i.message}),n.dirty());else if(i.kind==="ulid")Aw.test(e.data)||(r=this._getOrReturnCtx(e,r),ie(r,{validation:"ulid",code:K.invalid_string,message:i.message}),n.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{r=this._getOrReturnCtx(e,r),ie(r,{validation:"url",code:K.invalid_string,message:i.message}),n.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(r=this._getOrReturnCtx(e,r),ie(r,{validation:"regex",code:K.invalid_string,message:i.message}),n.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(r=this._getOrReturnCtx(e,r),ie(r,{code:K.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),n.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(r=this._getOrReturnCtx(e,r),ie(r,{code:K.invalid_string,validation:{startsWith:i.value},message:i.message}),n.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(r=this._getOrReturnCtx(e,r),ie(r,{code:K.invalid_string,validation:{endsWith:i.value},message:i.message}),n.dirty()):i.kind==="datetime"?Ow(i).test(e.data)||(r=this._getOrReturnCtx(e,r),ie(r,{code:K.invalid_string,validation:"datetime",message:i.message}),n.dirty()):i.kind==="ip"?Pw(e.data,i.version)||(r=this._getOrReturnCtx(e,r),ie(r,{validation:"ip",code:K.invalid_string,message:i.message}),n.dirty()):Me.assertNever(i);return{status:n.value,value:e.data}}_regex(e,s,n){return this.refinement(r=>e.test(r),{validation:s,code:K.invalid_string,...pe.errToObj(n)})}_addCheck(e){return new xs({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...pe.errToObj(e)})}url(e){return this._addCheck({kind:"url",...pe.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...pe.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...pe.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...pe.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...pe.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...pe.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...pe.errToObj(e)})}datetime(e){var s;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(s=e==null?void 0:e.offset)!==null&&s!==void 0?s:!1,...pe.errToObj(e==null?void 0:e.message)})}regex(e,s){return this._addCheck({kind:"regex",regex:e,...pe.errToObj(s)})}includes(e,s){return this._addCheck({kind:"includes",value:e,position:s==null?void 0:s.position,...pe.errToObj(s==null?void 0:s.message)})}startsWith(e,s){return this._addCheck({kind:"startsWith",value:e,...pe.errToObj(s)})}endsWith(e,s){return this._addCheck({kind:"endsWith",value:e,...pe.errToObj(s)})}min(e,s){return this._addCheck({kind:"min",value:e,...pe.errToObj(s)})}max(e,s){return this._addCheck({kind:"max",value:e,...pe.errToObj(s)})}length(e,s){return this._addCheck({kind:"length",value:e,...pe.errToObj(s)})}nonempty(e){return this.min(1,pe.errToObj(e))}trim(){return new xs({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new xs({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new xs({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get minLength(){let e=null;for(const s of this._def.checks)s.kind==="min"&&(e===null||s.value>e)&&(e=s.value);return e}get maxLength(){let e=null;for(const s of this._def.checks)s.kind==="max"&&(e===null||s.value<e)&&(e=s.value);return e}}xs.create=t=>{var e;return new xs({checks:[],typeName:me.ZodString,coerce:(e=t==null?void 0:t.coerce)!==null&&e!==void 0?e:!1,..._e(t)})};function xw(t,e){const s=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,r=s>n?s:n,i=parseInt(t.toFixed(r).replace(".","")),o=parseInt(e.toFixed(r).replace(".",""));return i%o/Math.pow(10,r)}class Yn extends Se{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==se.number){const i=this._getOrReturnCtx(e);return ie(i,{code:K.invalid_type,expected:se.number,received:i.parsedType}),be}let n;const r=new kt;for(const i of this._def.checks)i.kind==="int"?Me.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),ie(n,{code:K.invalid_type,expected:"integer",received:"float",message:i.message}),r.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),ie(n,{code:K.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),r.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),ie(n,{code:K.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),r.dirty()):i.kind==="multipleOf"?xw(e.data,i.value)!==0&&(n=this._getOrReturnCtx(e,n),ie(n,{code:K.not_multiple_of,multipleOf:i.value,message:i.message}),r.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),ie(n,{code:K.not_finite,message:i.message}),r.dirty()):Me.assertNever(i);return{status:r.value,value:e.data}}gte(e,s){return this.setLimit("min",e,!0,pe.toString(s))}gt(e,s){return this.setLimit("min",e,!1,pe.toString(s))}lte(e,s){return this.setLimit("max",e,!0,pe.toString(s))}lt(e,s){return this.setLimit("max",e,!1,pe.toString(s))}setLimit(e,s,n,r){return new Yn({...this._def,checks:[...this._def.checks,{kind:e,value:s,inclusive:n,message:pe.toString(r)}]})}_addCheck(e){return new Yn({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:pe.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:pe.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:pe.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:pe.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:pe.toString(e)})}multipleOf(e,s){return this._addCheck({kind:"multipleOf",value:e,message:pe.toString(s)})}finite(e){return this._addCheck({kind:"finite",message:pe.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:pe.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:pe.toString(e)})}get minValue(){let e=null;for(const s of this._def.checks)s.kind==="min"&&(e===null||s.value>e)&&(e=s.value);return e}get maxValue(){let e=null;for(const s of this._def.checks)s.kind==="max"&&(e===null||s.value<e)&&(e=s.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&Me.isInteger(e.value))}get isFinite(){let e=null,s=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(s===null||n.value>s)&&(s=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(s)&&Number.isFinite(e)}}Yn.create=t=>new Yn({checks:[],typeName:me.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,..._e(t)});class Zn extends Se{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==se.bigint){const i=this._getOrReturnCtx(e);return ie(i,{code:K.invalid_type,expected:se.bigint,received:i.parsedType}),be}let n;const r=new kt;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),ie(n,{code:K.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),r.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),ie(n,{code:K.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),r.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),ie(n,{code:K.not_multiple_of,multipleOf:i.value,message:i.message}),r.dirty()):Me.assertNever(i);return{status:r.value,value:e.data}}gte(e,s){return this.setLimit("min",e,!0,pe.toString(s))}gt(e,s){return this.setLimit("min",e,!1,pe.toString(s))}lte(e,s){return this.setLimit("max",e,!0,pe.toString(s))}lt(e,s){return this.setLimit("max",e,!1,pe.toString(s))}setLimit(e,s,n,r){return new Zn({...this._def,checks:[...this._def.checks,{kind:e,value:s,inclusive:n,message:pe.toString(r)}]})}_addCheck(e){return new Zn({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:pe.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:pe.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:pe.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:pe.toString(e)})}multipleOf(e,s){return this._addCheck({kind:"multipleOf",value:e,message:pe.toString(s)})}get minValue(){let e=null;for(const s of this._def.checks)s.kind==="min"&&(e===null||s.value>e)&&(e=s.value);return e}get maxValue(){let e=null;for(const s of this._def.checks)s.kind==="max"&&(e===null||s.value<e)&&(e=s.value);return e}}Zn.create=t=>{var e;return new Zn({checks:[],typeName:me.ZodBigInt,coerce:(e=t==null?void 0:t.coerce)!==null&&e!==void 0?e:!1,..._e(t)})};class so extends Se{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==se.boolean){const n=this._getOrReturnCtx(e);return ie(n,{code:K.invalid_type,expected:se.boolean,received:n.parsedType}),be}return Ft(e.data)}}so.create=t=>new so({typeName:me.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,..._e(t)});class Sr extends Se{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==se.date){const i=this._getOrReturnCtx(e);return ie(i,{code:K.invalid_type,expected:se.date,received:i.parsedType}),be}if(isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return ie(i,{code:K.invalid_date}),be}const n=new kt;let r;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(r=this._getOrReturnCtx(e,r),ie(r,{code:K.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),n.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(r=this._getOrReturnCtx(e,r),ie(r,{code:K.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),n.dirty()):Me.assertNever(i);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Sr({...this._def,checks:[...this._def.checks,e]})}min(e,s){return this._addCheck({kind:"min",value:e.getTime(),message:pe.toString(s)})}max(e,s){return this._addCheck({kind:"max",value:e.getTime(),message:pe.toString(s)})}get minDate(){let e=null;for(const s of this._def.checks)s.kind==="min"&&(e===null||s.value>e)&&(e=s.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const s of this._def.checks)s.kind==="max"&&(e===null||s.value<e)&&(e=s.value);return e!=null?new Date(e):null}}Sr.create=t=>new Sr({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:me.ZodDate,..._e(t)});class Ia extends Se{_parse(e){if(this._getType(e)!==se.symbol){const n=this._getOrReturnCtx(e);return ie(n,{code:K.invalid_type,expected:se.symbol,received:n.parsedType}),be}return Ft(e.data)}}Ia.create=t=>new Ia({typeName:me.ZodSymbol,..._e(t)});class no extends Se{_parse(e){if(this._getType(e)!==se.undefined){const n=this._getOrReturnCtx(e);return ie(n,{code:K.invalid_type,expected:se.undefined,received:n.parsedType}),be}return Ft(e.data)}}no.create=t=>new no({typeName:me.ZodUndefined,..._e(t)});class ro extends Se{_parse(e){if(this._getType(e)!==se.null){const n=this._getOrReturnCtx(e);return ie(n,{code:K.invalid_type,expected:se.null,received:n.parsedType}),be}return Ft(e.data)}}ro.create=t=>new ro({typeName:me.ZodNull,..._e(t)});class ci extends Se{constructor(){super(...arguments),this._any=!0}_parse(e){return Ft(e.data)}}ci.create=t=>new ci({typeName:me.ZodAny,..._e(t)});class vr extends Se{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Ft(e.data)}}vr.create=t=>new vr({typeName:me.ZodUnknown,..._e(t)});class An extends Se{_parse(e){const s=this._getOrReturnCtx(e);return ie(s,{code:K.invalid_type,expected:se.never,received:s.parsedType}),be}}An.create=t=>new An({typeName:me.ZodNever,..._e(t)});class Na extends Se{_parse(e){if(this._getType(e)!==se.undefined){const n=this._getOrReturnCtx(e);return ie(n,{code:K.invalid_type,expected:se.void,received:n.parsedType}),be}return Ft(e.data)}}Na.create=t=>new Na({typeName:me.ZodVoid,..._e(t)});class Us extends Se{_parse(e){const{ctx:s,status:n}=this._processInputParams(e),r=this._def;if(s.parsedType!==se.array)return ie(s,{code:K.invalid_type,expected:se.array,received:s.parsedType}),be;if(r.exactLength!==null){const o=s.data.length>r.exactLength.value,a=s.data.length<r.exactLength.value;(o||a)&&(ie(s,{code:o?K.too_big:K.too_small,minimum:a?r.exactLength.value:void 0,maximum:o?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(r.minLength!==null&&s.data.length<r.minLength.value&&(ie(s,{code:K.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),r.maxLength!==null&&s.data.length>r.maxLength.value&&(ie(s,{code:K.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),s.common.async)return Promise.all([...s.data].map((o,a)=>r.type._parseAsync(new Xs(s,o,s.path,a)))).then(o=>kt.mergeArray(n,o));const i=[...s.data].map((o,a)=>r.type._parseSync(new Xs(s,o,s.path,a)));return kt.mergeArray(n,i)}get element(){return this._def.type}min(e,s){return new Us({...this._def,minLength:{value:e,message:pe.toString(s)}})}max(e,s){return new Us({...this._def,maxLength:{value:e,message:pe.toString(s)}})}length(e,s){return new Us({...this._def,exactLength:{value:e,message:pe.toString(s)}})}nonempty(e){return this.min(1,e)}}Us.create=(t,e)=>new Us({type:t,minLength:null,maxLength:null,exactLength:null,typeName:me.ZodArray,..._e(e)});function zr(t){if(t instanceof Xe){const e={};for(const s in t.shape){const n=t.shape[s];e[s]=En.create(zr(n))}return new Xe({...t._def,shape:()=>e})}else return t instanceof Us?new Us({...t._def,type:zr(t.element)}):t instanceof En?En.create(zr(t.unwrap())):t instanceof Nr?Nr.create(zr(t.unwrap())):t instanceof Qs?Qs.create(t.items.map(e=>zr(e))):t}class Xe extends Se{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),s=Me.objectKeys(e);return this._cached={shape:e,keys:s}}_parse(e){if(this._getType(e)!==se.object){const l=this._getOrReturnCtx(e);return ie(l,{code:K.invalid_type,expected:se.object,received:l.parsedType}),be}const{status:n,ctx:r}=this._processInputParams(e),{shape:i,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof An&&this._def.unknownKeys==="strip"))for(const l in r.data)o.includes(l)||a.push(l);const c=[];for(const l of o){const d=i[l],u=r.data[l];c.push({key:{status:"valid",value:l},value:d._parse(new Xs(r,u,r.path,l)),alwaysSet:l in r.data})}if(this._def.catchall instanceof An){const l=this._def.unknownKeys;if(l==="passthrough")for(const d of a)c.push({key:{status:"valid",value:d},value:{status:"valid",value:r.data[d]}});else if(l==="strict")a.length>0&&(ie(r,{code:K.unrecognized_keys,keys:a}),n.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const l=this._def.catchall;for(const d of a){const u=r.data[d];c.push({key:{status:"valid",value:d},value:l._parse(new Xs(r,u,r.path,d)),alwaysSet:d in r.data})}}return r.common.async?Promise.resolve().then(async()=>{const l=[];for(const d of c){const u=await d.key;l.push({key:u,value:await d.value,alwaysSet:d.alwaysSet})}return l}).then(l=>kt.mergeObjectSync(n,l)):kt.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return pe.errToObj,new Xe({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(s,n)=>{var r,i,o,a;const c=(o=(i=(r=this._def).errorMap)===null||i===void 0?void 0:i.call(r,s,n).message)!==null&&o!==void 0?o:n.defaultError;return s.code==="unrecognized_keys"?{message:(a=pe.errToObj(e).message)!==null&&a!==void 0?a:c}:{message:c}}}:{}})}strip(){return new Xe({...this._def,unknownKeys:"strip"})}passthrough(){return new Xe({...this._def,unknownKeys:"passthrough"})}extend(e){return new Xe({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Xe({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:me.ZodObject})}setKey(e,s){return this.augment({[e]:s})}catchall(e){return new Xe({...this._def,catchall:e})}pick(e){const s={};return Me.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(s[n]=this.shape[n])}),new Xe({...this._def,shape:()=>s})}omit(e){const s={};return Me.objectKeys(this.shape).forEach(n=>{e[n]||(s[n]=this.shape[n])}),new Xe({...this._def,shape:()=>s})}deepPartial(){return zr(this)}partial(e){const s={};return Me.objectKeys(this.shape).forEach(n=>{const r=this.shape[n];e&&!e[n]?s[n]=r:s[n]=r.optional()}),new Xe({...this._def,shape:()=>s})}required(e){const s={};return Me.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])s[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof En;)i=i._def.innerType;s[n]=i}}),new Xe({...this._def,shape:()=>s})}keyof(){return Tf(Me.objectKeys(this.shape))}}Xe.create=(t,e)=>new Xe({shape:()=>t,unknownKeys:"strip",catchall:An.create(),typeName:me.ZodObject,..._e(e)});Xe.strictCreate=(t,e)=>new Xe({shape:()=>t,unknownKeys:"strict",catchall:An.create(),typeName:me.ZodObject,..._e(e)});Xe.lazycreate=(t,e)=>new Xe({shape:t,unknownKeys:"strip",catchall:An.create(),typeName:me.ZodObject,..._e(e)});class io extends Se{_parse(e){const{ctx:s}=this._processInputParams(e),n=this._def.options;function r(i){for(const a of i)if(a.result.status==="valid")return a.result;for(const a of i)if(a.result.status==="dirty")return s.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(a=>new ks(a.ctx.common.issues));return ie(s,{code:K.invalid_union,unionErrors:o}),be}if(s.common.async)return Promise.all(n.map(async i=>{const o={...s,common:{...s.common,issues:[]},parent:null};return{result:await i._parseAsync({data:s.data,path:s.path,parent:o}),ctx:o}})).then(r);{let i;const o=[];for(const c of n){const l={...s,common:{...s.common,issues:[]},parent:null},d=c._parseSync({data:s.data,path:s.path,parent:l});if(d.status==="valid")return d;d.status==="dirty"&&!i&&(i={result:d,ctx:l}),l.common.issues.length&&o.push(l.common.issues)}if(i)return s.common.issues.push(...i.ctx.common.issues),i.result;const a=o.map(c=>new ks(c));return ie(s,{code:K.invalid_union,unionErrors:a}),be}}get options(){return this._def.options}}io.create=(t,e)=>new io({options:t,typeName:me.ZodUnion,..._e(e)});const ua=t=>t instanceof co?ua(t.schema):t instanceof Ds?ua(t.innerType()):t instanceof lo?[t.value]:t instanceof Jn?t.options:t instanceof uo?Object.keys(t.enum):t instanceof ho?ua(t._def.innerType):t instanceof no?[void 0]:t instanceof ro?[null]:null;class Xa extends Se{_parse(e){const{ctx:s}=this._processInputParams(e);if(s.parsedType!==se.object)return ie(s,{code:K.invalid_type,expected:se.object,received:s.parsedType}),be;const n=this.discriminator,r=s.data[n],i=this.optionsMap.get(r);return i?s.common.async?i._parseAsync({data:s.data,path:s.path,parent:s}):i._parseSync({data:s.data,path:s.path,parent:s}):(ie(s,{code:K.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),be)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,s,n){const r=new Map;for(const i of s){const o=ua(i.shape[e]);if(!o)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const a of o){if(r.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);r.set(a,i)}}return new Xa({typeName:me.ZodDiscriminatedUnion,discriminator:e,options:s,optionsMap:r,..._e(n)})}}function _l(t,e){const s=Mn(t),n=Mn(e);if(t===e)return{valid:!0,data:t};if(s===se.object&&n===se.object){const r=Me.objectKeys(e),i=Me.objectKeys(t).filter(a=>r.indexOf(a)!==-1),o={...t,...e};for(const a of i){const c=_l(t[a],e[a]);if(!c.valid)return{valid:!1};o[a]=c.data}return{valid:!0,data:o}}else if(s===se.array&&n===se.array){if(t.length!==e.length)return{valid:!1};const r=[];for(let i=0;i<t.length;i++){const o=t[i],a=e[i],c=_l(o,a);if(!c.valid)return{valid:!1};r.push(c.data)}return{valid:!0,data:r}}else return s===se.date&&n===se.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class oo extends Se{_parse(e){const{status:s,ctx:n}=this._processInputParams(e),r=(i,o)=>{if(vl(i)||vl(o))return be;const a=_l(i.value,o.value);return a.valid?((Cl(i)||Cl(o))&&s.dirty(),{status:s.value,value:a.data}):(ie(n,{code:K.invalid_intersection_types}),be)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([i,o])=>r(i,o)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}oo.create=(t,e,s)=>new oo({left:t,right:e,typeName:me.ZodIntersection,..._e(s)});class Qs extends Se{_parse(e){const{status:s,ctx:n}=this._processInputParams(e);if(n.parsedType!==se.array)return ie(n,{code:K.invalid_type,expected:se.array,received:n.parsedType}),be;if(n.data.length<this._def.items.length)return ie(n,{code:K.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),be;!this._def.rest&&n.data.length>this._def.items.length&&(ie(n,{code:K.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),s.dirty());const i=[...n.data].map((o,a)=>{const c=this._def.items[a]||this._def.rest;return c?c._parse(new Xs(n,o,n.path,a)):null}).filter(o=>!!o);return n.common.async?Promise.all(i).then(o=>kt.mergeArray(s,o)):kt.mergeArray(s,i)}get items(){return this._def.items}rest(e){return new Qs({...this._def,rest:e})}}Qs.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Qs({items:t,typeName:me.ZodTuple,rest:null,..._e(e)})};class ao extends Se{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:s,ctx:n}=this._processInputParams(e);if(n.parsedType!==se.object)return ie(n,{code:K.invalid_type,expected:se.object,received:n.parsedType}),be;const r=[],i=this._def.keyType,o=this._def.valueType;for(const a in n.data)r.push({key:i._parse(new Xs(n,a,n.path,a)),value:o._parse(new Xs(n,n.data[a],n.path,a))});return n.common.async?kt.mergeObjectAsync(s,r):kt.mergeObjectSync(s,r)}get element(){return this._def.valueType}static create(e,s,n){return s instanceof Se?new ao({keyType:e,valueType:s,typeName:me.ZodRecord,..._e(n)}):new ao({keyType:xs.create(),valueType:e,typeName:me.ZodRecord,..._e(s)})}}class Ta extends Se{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:s,ctx:n}=this._processInputParams(e);if(n.parsedType!==se.map)return ie(n,{code:K.invalid_type,expected:se.map,received:n.parsedType}),be;const r=this._def.keyType,i=this._def.valueType,o=[...n.data.entries()].map(([a,c],l)=>({key:r._parse(new Xs(n,a,n.path,[l,"key"])),value:i._parse(new Xs(n,c,n.path,[l,"value"]))}));if(n.common.async){const a=new Map;return Promise.resolve().then(async()=>{for(const c of o){const l=await c.key,d=await c.value;if(l.status==="aborted"||d.status==="aborted")return be;(l.status==="dirty"||d.status==="dirty")&&s.dirty(),a.set(l.value,d.value)}return{status:s.value,value:a}})}else{const a=new Map;for(const c of o){const l=c.key,d=c.value;if(l.status==="aborted"||d.status==="aborted")return be;(l.status==="dirty"||d.status==="dirty")&&s.dirty(),a.set(l.value,d.value)}return{status:s.value,value:a}}}}Ta.create=(t,e,s)=>new Ta({valueType:e,keyType:t,typeName:me.ZodMap,..._e(s)});class Ir extends Se{_parse(e){const{status:s,ctx:n}=this._processInputParams(e);if(n.parsedType!==se.set)return ie(n,{code:K.invalid_type,expected:se.set,received:n.parsedType}),be;const r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&(ie(n,{code:K.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),s.dirty()),r.maxSize!==null&&n.data.size>r.maxSize.value&&(ie(n,{code:K.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),s.dirty());const i=this._def.valueType;function o(c){const l=new Set;for(const d of c){if(d.status==="aborted")return be;d.status==="dirty"&&s.dirty(),l.add(d.value)}return{status:s.value,value:l}}const a=[...n.data.values()].map((c,l)=>i._parse(new Xs(n,c,n.path,l)));return n.common.async?Promise.all(a).then(c=>o(c)):o(a)}min(e,s){return new Ir({...this._def,minSize:{value:e,message:pe.toString(s)}})}max(e,s){return new Ir({...this._def,maxSize:{value:e,message:pe.toString(s)}})}size(e,s){return this.min(e,s).max(e,s)}nonempty(e){return this.min(1,e)}}Ir.create=(t,e)=>new Ir({valueType:t,minSize:null,maxSize:null,typeName:me.ZodSet,..._e(e)});class ei extends Se{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:s}=this._processInputParams(e);if(s.parsedType!==se.function)return ie(s,{code:K.invalid_type,expected:se.function,received:s.parsedType}),be;function n(a,c){return Aa({data:a,path:s.path,errorMaps:[s.common.contextualErrorMap,s.schemaErrorMap,_a(),eo].filter(l=>!!l),issueData:{code:K.invalid_arguments,argumentsError:c}})}function r(a,c){return Aa({data:a,path:s.path,errorMaps:[s.common.contextualErrorMap,s.schemaErrorMap,_a(),eo].filter(l=>!!l),issueData:{code:K.invalid_return_type,returnTypeError:c}})}const i={errorMap:s.common.contextualErrorMap},o=s.data;if(this._def.returns instanceof li){const a=this;return Ft(async function(...c){const l=new ks([]),d=await a._def.args.parseAsync(c,i).catch(p=>{throw l.addIssue(n(c,p)),l}),u=await Reflect.apply(o,this,d);return await a._def.returns._def.type.parseAsync(u,i).catch(p=>{throw l.addIssue(r(u,p)),l})})}else{const a=this;return Ft(function(...c){const l=a._def.args.safeParse(c,i);if(!l.success)throw new ks([n(c,l.error)]);const d=Reflect.apply(o,this,l.data),u=a._def.returns.safeParse(d,i);if(!u.success)throw new ks([r(d,u.error)]);return u.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new ei({...this._def,args:Qs.create(e).rest(vr.create())})}returns(e){return new ei({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,s,n){return new ei({args:e||Qs.create([]).rest(vr.create()),returns:s||vr.create(),typeName:me.ZodFunction,..._e(n)})}}class co extends Se{get schema(){return this._def.getter()}_parse(e){const{ctx:s}=this._processInputParams(e);return this._def.getter()._parse({data:s.data,path:s.path,parent:s})}}co.create=(t,e)=>new co({getter:t,typeName:me.ZodLazy,..._e(e)});class lo extends Se{_parse(e){if(e.data!==this._def.value){const s=this._getOrReturnCtx(e);return ie(s,{received:s.data,code:K.invalid_literal,expected:this._def.value}),be}return{status:"valid",value:e.data}}get value(){return this._def.value}}lo.create=(t,e)=>new lo({value:t,typeName:me.ZodLiteral,..._e(e)});function Tf(t,e){return new Jn({values:t,typeName:me.ZodEnum,..._e(e)})}class Jn extends Se{_parse(e){if(typeof e.data!="string"){const s=this._getOrReturnCtx(e),n=this._def.values;return ie(s,{expected:Me.joinValues(n),received:s.parsedType,code:K.invalid_type}),be}if(this._def.values.indexOf(e.data)===-1){const s=this._getOrReturnCtx(e),n=this._def.values;return ie(s,{received:s.data,code:K.invalid_enum_value,options:n}),be}return Ft(e.data)}get options(){return this._def.values}get enum(){const e={};for(const s of this._def.values)e[s]=s;return e}get Values(){const e={};for(const s of this._def.values)e[s]=s;return e}get Enum(){const e={};for(const s of this._def.values)e[s]=s;return e}extract(e){return Jn.create(e)}exclude(e){return Jn.create(this.options.filter(s=>!e.includes(s)))}}Jn.create=Tf;class uo extends Se{_parse(e){const s=Me.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==se.string&&n.parsedType!==se.number){const r=Me.objectValues(s);return ie(n,{expected:Me.joinValues(r),received:n.parsedType,code:K.invalid_type}),be}if(s.indexOf(e.data)===-1){const r=Me.objectValues(s);return ie(n,{received:n.data,code:K.invalid_enum_value,options:r}),be}return Ft(e.data)}get enum(){return this._def.values}}uo.create=(t,e)=>new uo({values:t,typeName:me.ZodNativeEnum,..._e(e)});class li extends Se{unwrap(){return this._def.type}_parse(e){const{ctx:s}=this._processInputParams(e);if(s.parsedType!==se.promise&&s.common.async===!1)return ie(s,{code:K.invalid_type,expected:se.promise,received:s.parsedType}),be;const n=s.parsedType===se.promise?s.data:Promise.resolve(s.data);return Ft(n.then(r=>this._def.type.parseAsync(r,{path:s.path,errorMap:s.common.contextualErrorMap})))}}li.create=(t,e)=>new li({type:t,typeName:me.ZodPromise,..._e(e)});class Ds extends Se{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===me.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:s,ctx:n}=this._processInputParams(e),r=this._def.effect||null,i={addIssue:o=>{ie(n,o),o.fatal?s.abort():s.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),r.type==="preprocess"){const o=r.transform(n.data,i);return n.common.issues.length?{status:"dirty",value:n.data}:n.common.async?Promise.resolve(o).then(a=>this._def.schema._parseAsync({data:a,path:n.path,parent:n})):this._def.schema._parseSync({data:o,path:n.path,parent:n})}if(r.type==="refinement"){const o=a=>{const c=r.refinement(a,i);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(n.common.async===!1){const a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?be:(a.status==="dirty"&&s.dirty(),o(a.value),{status:s.value,value:a.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>a.status==="aborted"?be:(a.status==="dirty"&&s.dirty(),o(a.value).then(()=>({status:s.value,value:a.value}))))}if(r.type==="transform")if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!to(o))return o;const a=r.transform(o.value,i);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:s.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>to(o)?Promise.resolve(r.transform(o.value,i)).then(a=>({status:s.value,value:a})):o);Me.assertNever(r)}}Ds.create=(t,e,s)=>new Ds({schema:t,typeName:me.ZodEffects,effect:e,..._e(s)});Ds.createWithPreprocess=(t,e,s)=>new Ds({schema:e,effect:{type:"preprocess",transform:t},typeName:me.ZodEffects,..._e(s)});class En extends Se{_parse(e){return this._getType(e)===se.undefined?Ft(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}En.create=(t,e)=>new En({innerType:t,typeName:me.ZodOptional,..._e(e)});class Nr extends Se{_parse(e){return this._getType(e)===se.null?Ft(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Nr.create=(t,e)=>new Nr({innerType:t,typeName:me.ZodNullable,..._e(e)});class ho extends Se{_parse(e){const{ctx:s}=this._processInputParams(e);let n=s.data;return s.parsedType===se.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:s.path,parent:s})}removeDefault(){return this._def.innerType}}ho.create=(t,e)=>new ho({innerType:t,typeName:me.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,..._e(e)});class Ra extends Se{_parse(e){const{ctx:s}=this._processInputParams(e),n={...s,common:{...s.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Sa(r)?r.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new ks(n.common.issues)},input:n.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new ks(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}Ra.create=(t,e)=>new Ra({innerType:t,typeName:me.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,..._e(e)});class Oa extends Se{_parse(e){if(this._getType(e)!==se.nan){const n=this._getOrReturnCtx(e);return ie(n,{code:K.invalid_type,expected:se.nan,received:n.parsedType}),be}return{status:"valid",value:e.data}}}Oa.create=t=>new Oa({typeName:me.ZodNaN,..._e(t)});const kw=Symbol("zod_brand");class Rf extends Se{_parse(e){const{ctx:s}=this._processInputParams(e),n=s.data;return this._def.type._parse({data:n,path:s.path,parent:s})}unwrap(){return this._def.type}}class Ao extends Se{_parse(e){const{status:s,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?be:i.status==="dirty"?(s.dirty(),Nf(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})})();{const r=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return r.status==="aborted"?be:r.status==="dirty"?(s.dirty(),{status:"dirty",value:r.value}):this._def.out._parseSync({data:r.value,path:n.path,parent:n})}}static create(e,s){return new Ao({in:e,out:s,typeName:me.ZodPipeline})}}class Pa extends Se{_parse(e){const s=this._def.innerType._parse(e);return to(s)&&(s.value=Object.freeze(s.value)),s}}Pa.create=(t,e)=>new Pa({innerType:t,typeName:me.ZodReadonly,..._e(e)});const Of=(t,e={},s)=>t?ci.create().superRefine((n,r)=>{var i,o;if(!t(n)){const a=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,c=(o=(i=a.fatal)!==null&&i!==void 0?i:s)!==null&&o!==void 0?o:!0,l=typeof a=="string"?{message:a}:a;r.addIssue({code:"custom",...l,fatal:c})}}):ci.create(),Uw={object:Xe.lazycreate};var me;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(me||(me={}));const $w=(t,e={message:`Input not instance of ${t.name}`})=>Of(s=>s instanceof t,e),Pf=xs.create,xf=Yn.create,Dw=Oa.create,Lw=Zn.create,kf=so.create,Mw=Sr.create,Bw=Ia.create,jw=no.create,Fw=ro.create,qw=ci.create,Ww=vr.create,Hw=An.create,Vw=Na.create,zw=Us.create,Kw=Xe.create,Gw=Xe.strictCreate,Yw=io.create,Zw=Xa.create,Jw=oo.create,Xw=Qs.create,Qw=ao.create,eE=Ta.create,tE=Ir.create,sE=ei.create,nE=co.create,rE=lo.create,iE=Jn.create,oE=uo.create,aE=li.create,Ru=Ds.create,cE=En.create,lE=Nr.create,dE=Ds.createWithPreprocess,uE=Ao.create,hE=()=>Pf().optional(),pE=()=>xf().optional(),fE=()=>kf().optional(),gE={string:(t=>xs.create({...t,coerce:!0})),number:(t=>Yn.create({...t,coerce:!0})),boolean:(t=>so.create({...t,coerce:!0})),bigint:(t=>Zn.create({...t,coerce:!0})),date:(t=>Sr.create({...t,coerce:!0}))},mE=be;var m=Object.freeze({__proto__:null,defaultErrorMap:eo,setErrorMap:bw,getErrorMap:_a,makeIssue:Aa,EMPTY_PATH:vw,addIssueToContext:ie,ParseStatus:kt,INVALID:be,DIRTY:Nf,OK:Ft,isAborted:vl,isDirty:Cl,isValid:to,isAsync:Sa,get util(){return Me},get objectUtil(){return bl},ZodParsedType:se,getParsedType:Mn,ZodType:Se,ZodString:xs,ZodNumber:Yn,ZodBigInt:Zn,ZodBoolean:so,ZodDate:Sr,ZodSymbol:Ia,ZodUndefined:no,ZodNull:ro,ZodAny:ci,ZodUnknown:vr,ZodNever:An,ZodVoid:Na,ZodArray:Us,ZodObject:Xe,ZodUnion:io,ZodDiscriminatedUnion:Xa,ZodIntersection:oo,ZodTuple:Qs,ZodRecord:ao,ZodMap:Ta,ZodSet:Ir,ZodFunction:ei,ZodLazy:co,ZodLiteral:lo,ZodEnum:Jn,ZodNativeEnum:uo,ZodPromise:li,ZodEffects:Ds,ZodTransformer:Ds,ZodOptional:En,ZodNullable:Nr,ZodDefault:ho,ZodCatch:Ra,ZodNaN:Oa,BRAND:kw,ZodBranded:Rf,ZodPipeline:Ao,ZodReadonly:Pa,custom:Of,Schema:Se,ZodSchema:Se,late:Uw,get ZodFirstPartyTypeKind(){return me},coerce:gE,any:qw,array:zw,bigint:Lw,boolean:kf,date:Mw,discriminatedUnion:Zw,effect:Ru,enum:iE,function:sE,instanceof:$w,intersection:Jw,lazy:nE,literal:rE,map:eE,nan:Dw,nativeEnum:oE,never:Hw,null:Fw,nullable:lE,number:xf,object:Kw,oboolean:fE,onumber:pE,optional:cE,ostring:hE,pipeline:uE,preprocess:dE,promise:aE,record:Qw,set:tE,strictObject:Gw,string:Pf,symbol:Bw,transformer:Ru,tuple:Xw,undefined:jw,union:Yw,unknown:Ww,void:Vw,NEVER:mE,ZodIssueCode:K,quotelessJson:Ew,ZodError:ks});const Qe=m.object({message:m.string()});function ne(t){return m.literal(oe[t])}const Qa=m.object({serializedMessage:m.string().optional(),accountAddress:m.string(),chainId:m.string(),notBefore:m.string().optional(),domain:m.string(),uri:m.string(),version:m.string(),nonce:m.string(),statement:m.string().optional(),resources:m.array(m.string()).optional(),requestId:m.string().optional(),issuedAt:m.string().optional(),expirationTime:m.string().optional()});m.object({accessList:m.array(m.string()),blockHash:m.string().nullable(),blockNumber:m.string().nullable(),chainId:m.string().or(m.number()),from:m.string(),gas:m.string(),hash:m.string(),input:m.string().nullable(),maxFeePerGas:m.string(),maxPriorityFeePerGas:m.string(),nonce:m.string(),r:m.string(),s:m.string(),to:m.string(),transactionIndex:m.string().nullable(),type:m.string(),v:m.string(),value:m.string()});const yE=m.object({chainId:m.string().or(m.number()),rpcUrl:m.optional(m.string())}),wE=m.object({email:m.string().email()}),EE=m.object({otp:m.string()}),bE=m.object({uri:m.string(),preferredAccountType:m.optional(m.string()),chainId:m.optional(m.string().or(m.number())),siwxMessage:m.optional(Qa),rpcUrl:m.optional(m.string())}),vE=m.object({chainId:m.optional(m.string().or(m.number())),preferredAccountType:m.optional(m.string()),socialUri:m.optional(m.string()),siwxMessage:m.optional(Qa),rpcUrl:m.optional(m.string())}),CE=m.object({provider:m.enum(["google","github","apple","facebook","x","discord"])}),_E=m.object({email:m.string().email()}),AE=m.object({otp:m.string()}),SE=m.object({otp:m.string()}),IE=m.object({themeMode:m.optional(m.enum(["light","dark"])),themeVariables:m.optional(m.record(m.string(),m.string().or(m.number()))),w3mThemeVariables:m.optional(m.record(m.string(),m.string()))}),NE=m.object({metadata:m.object({name:m.string(),description:m.string(),url:m.string(),icons:m.array(m.string())}).optional(),sdkVersion:m.string().optional(),sdkType:m.string().optional(),projectId:m.string()}),TE=m.object({type:m.string()}),RE=m.object({action:m.enum(["VERIFY_DEVICE","VERIFY_OTP","CONNECT"])}),OE=m.object({url:m.string()}),PE=m.object({userName:m.string()}),xE=m.object({email:m.string().optional().nullable(),address:m.string(),chainId:m.string().or(m.number()),accounts:m.array(m.object({address:m.string(),type:m.enum([tt.ACCOUNT_TYPES.EOA,tt.ACCOUNT_TYPES.SMART_ACCOUNT])})).optional(),userName:m.string().optional().nullable(),preferredAccountType:m.optional(m.string()),signature:m.string().optional(),message:m.string().optional(),siwxMessage:m.optional(Qa)}),kE=m.object({action:m.enum(["VERIFY_PRIMARY_OTP","VERIFY_SECONDARY_OTP"])}),UE=m.object({email:m.string().email().optional().nullable(),address:m.string(),chainId:m.string().or(m.number()),smartAccountDeployed:m.optional(m.boolean()),accounts:m.array(m.object({address:m.string(),type:m.enum([tt.ACCOUNT_TYPES.EOA,tt.ACCOUNT_TYPES.SMART_ACCOUNT])})).optional(),preferredAccountType:m.optional(m.string()),signature:m.string().optional(),message:m.string().optional(),siwxMessage:m.optional(Qa)}),$E=m.object({uri:m.string()}),DE=m.object({isConnected:m.boolean()}),LE=m.object({chainId:m.string().or(m.number())}),ME=m.object({chainId:m.string().or(m.number())}),BE=m.object({newEmail:m.string().email()}),jE=m.object({smartAccountEnabledNetworks:m.array(m.number())});m.object({address:m.string(),isDeployed:m.boolean()});const FE=m.object({version:m.string().optional()}),qE=m.object({type:m.string(),address:m.string()}),WE=m.any(),HE=m.object({method:m.literal("eth_accounts")}),VE=m.object({method:m.literal("eth_blockNumber")}),zE=m.object({method:m.literal("eth_call"),params:m.array(m.any())}),KE=m.object({method:m.literal("eth_chainId")}),GE=m.object({method:m.literal("eth_estimateGas"),params:m.array(m.any())}),YE=m.object({method:m.literal("eth_feeHistory"),params:m.array(m.any())}),ZE=m.object({method:m.literal("eth_gasPrice")}),JE=m.object({method:m.literal("eth_getAccount"),params:m.array(m.any())}),XE=m.object({method:m.literal("eth_getBalance"),params:m.array(m.any())}),QE=m.object({method:m.literal("eth_getBlockByHash"),params:m.array(m.any())}),eb=m.object({method:m.literal("eth_getBlockByNumber"),params:m.array(m.any())}),tb=m.object({method:m.literal("eth_getBlockReceipts"),params:m.array(m.any())}),sb=m.object({method:m.literal("eth_getBlockTransactionCountByHash"),params:m.array(m.any())}),nb=m.object({method:m.literal("eth_getBlockTransactionCountByNumber"),params:m.array(m.any())}),rb=m.object({method:m.literal("eth_getCode"),params:m.array(m.any())}),ib=m.object({method:m.literal("eth_getFilterChanges"),params:m.array(m.any())}),ob=m.object({method:m.literal("eth_getFilterLogs"),params:m.array(m.any())}),ab=m.object({method:m.literal("eth_getLogs"),params:m.array(m.any())}),cb=m.object({method:m.literal("eth_getProof"),params:m.array(m.any())}),lb=m.object({method:m.literal("eth_getStorageAt"),params:m.array(m.any())}),db=m.object({method:m.literal("eth_getTransactionByBlockHashAndIndex"),params:m.array(m.any())}),ub=m.object({method:m.literal("eth_getTransactionByBlockNumberAndIndex"),params:m.array(m.any())}),hb=m.object({method:m.literal("eth_getTransactionByHash"),params:m.array(m.any())}),pb=m.object({method:m.literal("eth_getTransactionCount"),params:m.array(m.any())}),fb=m.object({method:m.literal("eth_getTransactionReceipt"),params:m.array(m.any())}),gb=m.object({method:m.literal("eth_getUncleCountByBlockHash"),params:m.array(m.any())}),mb=m.object({method:m.literal("eth_getUncleCountByBlockNumber"),params:m.array(m.any())}),yb=m.object({method:m.literal("eth_maxPriorityFeePerGas")}),wb=m.object({method:m.literal("eth_newBlockFilter")}),Eb=m.object({method:m.literal("eth_newFilter"),params:m.array(m.any())}),bb=m.object({method:m.literal("eth_newPendingTransactionFilter")}),vb=m.object({method:m.literal("eth_sendRawTransaction"),params:m.array(m.any())}),Cb=m.object({method:m.literal("eth_syncing"),params:m.array(m.any())}),_b=m.object({method:m.literal("eth_uninstallFilter"),params:m.array(m.any())}),Ou=m.object({method:m.literal("personal_sign"),params:m.array(m.any())}),Ab=m.object({method:m.literal("eth_signTypedData_v4"),params:m.array(m.any())}),Sb=m.object({method:m.literal("eth_sendTransaction"),params:m.array(m.any())}),Ib=m.object({method:m.literal("solana_signMessage"),params:m.object({message:m.string(),pubkey:m.string()})}),Nb=m.object({method:m.literal("solana_signTransaction"),params:m.object({transaction:m.string()})}),Tb=m.object({method:m.literal("solana_signAllTransactions"),params:m.object({transactions:m.array(m.string())})}),Rb=m.object({method:m.literal("solana_signAndSendTransaction"),params:m.object({transaction:m.string(),options:m.object({skipPreflight:m.boolean().optional(),preflightCommitment:m.enum(["processed","confirmed","finalized","recent","single","singleGossip","root","max"]).optional(),maxRetries:m.number().optional(),minContextSlot:m.number().optional()}).optional()})}),Ob=m.object({method:m.literal("wallet_sendCalls"),params:m.array(m.object({chainId:m.string().or(m.number()).optional(),from:m.string().optional(),version:m.string().optional(),capabilities:m.any().optional(),calls:m.array(m.object({to:m.string().startsWith("0x"),data:m.string().startsWith("0x").optional(),value:m.string().optional()}))}))}),Pb=m.object({method:m.literal("wallet_getCallsStatus"),params:m.array(m.string())}),xb=m.object({method:m.literal("wallet_getCapabilities"),params:m.array(m.string().or(m.number()).optional()).optional()}),kb=m.object({method:m.literal("wallet_grantPermissions"),params:m.array(m.any())}),Ub=m.object({method:m.literal("wallet_revokePermissions"),params:m.any()}),$b=m.object({method:m.literal("wallet_getAssets"),params:m.any()}),Pu=m.object({token:m.string()}),re=m.object({id:m.string().optional()}),bc={appEvent:re.extend({type:ne("APP_SWITCH_NETWORK"),payload:yE}).or(re.extend({type:ne("APP_CONNECT_EMAIL"),payload:wE})).or(re.extend({type:ne("APP_CONNECT_DEVICE")})).or(re.extend({type:ne("APP_CONNECT_OTP"),payload:EE})).or(re.extend({type:ne("APP_CONNECT_SOCIAL"),payload:bE})).or(re.extend({type:ne("APP_GET_FARCASTER_URI")})).or(re.extend({type:ne("APP_CONNECT_FARCASTER")})).or(re.extend({type:ne("APP_GET_USER"),payload:m.optional(vE)})).or(re.extend({type:ne("APP_GET_SOCIAL_REDIRECT_URI"),payload:CE})).or(re.extend({type:ne("APP_SIGN_OUT")})).or(re.extend({type:ne("APP_IS_CONNECTED"),payload:m.optional(Pu)})).or(re.extend({type:ne("APP_GET_CHAIN_ID")})).or(re.extend({type:ne("APP_GET_SMART_ACCOUNT_ENABLED_NETWORKS")})).or(re.extend({type:ne("APP_INIT_SMART_ACCOUNT")})).or(re.extend({type:ne("APP_SET_PREFERRED_ACCOUNT"),payload:TE})).or(re.extend({type:ne("APP_RPC_REQUEST"),payload:Ou.or($b).or(HE).or(VE).or(zE).or(KE).or(GE).or(YE).or(ZE).or(JE).or(XE).or(QE).or(eb).or(tb).or(sb).or(nb).or(rb).or(ib).or(ob).or(ab).or(cb).or(lb).or(db).or(ub).or(hb).or(pb).or(fb).or(gb).or(mb).or(yb).or(wb).or(Eb).or(bb).or(vb).or(Cb).or(_b).or(Ou).or(Ab).or(Sb).or(Ib).or(Nb).or(Tb).or(Rb).or(Pb).or(Ob).or(xb).or(kb).or(Ub).and(m.object({chainId:m.string().or(m.number()).optional(),chainNamespace:m.enum(["eip155","solana","polkadot","bip122","cosmos"]).optional(),rpcUrl:m.string().optional()}))})).or(re.extend({type:ne("APP_UPDATE_EMAIL"),payload:_E})).or(re.extend({type:ne("APP_UPDATE_EMAIL_PRIMARY_OTP"),payload:AE})).or(re.extend({type:ne("APP_UPDATE_EMAIL_SECONDARY_OTP"),payload:SE})).or(re.extend({type:ne("APP_SYNC_THEME"),payload:IE})).or(re.extend({type:ne("APP_SYNC_DAPP_DATA"),payload:NE})).or(re.extend({type:ne("APP_RELOAD")})).or(re.extend({type:ne("APP_RPC_ABORT")})),frameEvent:re.extend({type:ne("FRAME_SWITCH_NETWORK_ERROR"),payload:Qe}).or(re.extend({type:ne("FRAME_SWITCH_NETWORK_SUCCESS"),payload:ME})).or(re.extend({type:ne("FRAME_CONNECT_EMAIL_SUCCESS"),payload:RE})).or(re.extend({type:ne("FRAME_CONNECT_EMAIL_ERROR"),payload:Qe})).or(re.extend({type:ne("FRAME_GET_FARCASTER_URI_SUCCESS"),payload:OE})).or(re.extend({type:ne("FRAME_GET_FARCASTER_URI_ERROR"),payload:Qe})).or(re.extend({type:ne("FRAME_CONNECT_FARCASTER_SUCCESS"),payload:PE})).or(re.extend({type:ne("FRAME_CONNECT_FARCASTER_ERROR"),payload:Qe})).or(re.extend({type:ne("FRAME_CONNECT_OTP_ERROR"),payload:Qe})).or(re.extend({type:ne("FRAME_CONNECT_OTP_SUCCESS")})).or(re.extend({type:ne("FRAME_CONNECT_DEVICE_ERROR"),payload:Qe})).or(re.extend({type:ne("FRAME_CONNECT_DEVICE_SUCCESS")})).or(re.extend({type:ne("FRAME_CONNECT_SOCIAL_SUCCESS"),payload:xE})).or(re.extend({type:ne("FRAME_CONNECT_SOCIAL_ERROR"),payload:Qe})).or(re.extend({type:ne("FRAME_GET_USER_ERROR"),payload:Qe})).or(re.extend({type:ne("FRAME_GET_USER_SUCCESS"),payload:UE})).or(re.extend({type:ne("FRAME_GET_SOCIAL_REDIRECT_URI_ERROR"),payload:Qe})).or(re.extend({type:ne("FRAME_GET_SOCIAL_REDIRECT_URI_SUCCESS"),payload:$E})).or(re.extend({type:ne("FRAME_SIGN_OUT_ERROR"),payload:Qe})).or(re.extend({type:ne("FRAME_SIGN_OUT_SUCCESS")})).or(re.extend({type:ne("FRAME_IS_CONNECTED_ERROR"),payload:Qe})).or(re.extend({type:ne("FRAME_IS_CONNECTED_SUCCESS"),payload:DE})).or(re.extend({type:ne("FRAME_GET_CHAIN_ID_ERROR"),payload:Qe})).or(re.extend({type:ne("FRAME_GET_CHAIN_ID_SUCCESS"),payload:LE})).or(re.extend({type:ne("FRAME_RPC_REQUEST_ERROR"),payload:Qe})).or(re.extend({type:ne("FRAME_RPC_REQUEST_SUCCESS"),payload:WE})).or(re.extend({type:ne("FRAME_SESSION_UPDATE"),payload:Pu})).or(re.extend({type:ne("FRAME_UPDATE_EMAIL_ERROR"),payload:Qe})).or(re.extend({type:ne("FRAME_UPDATE_EMAIL_SUCCESS"),payload:kE})).or(re.extend({type:ne("FRAME_UPDATE_EMAIL_PRIMARY_OTP_ERROR"),payload:Qe})).or(re.extend({type:ne("FRAME_UPDATE_EMAIL_PRIMARY_OTP_SUCCESS")})).or(re.extend({type:ne("FRAME_UPDATE_EMAIL_SECONDARY_OTP_ERROR"),payload:Qe})).or(re.extend({type:ne("FRAME_UPDATE_EMAIL_SECONDARY_OTP_SUCCESS"),payload:BE})).or(re.extend({type:ne("FRAME_SYNC_THEME_ERROR"),payload:Qe})).or(re.extend({type:ne("FRAME_SYNC_THEME_SUCCESS")})).or(re.extend({type:ne("FRAME_SYNC_DAPP_DATA_ERROR"),payload:Qe})).or(re.extend({type:ne("FRAME_SYNC_DAPP_DATA_SUCCESS")})).or(re.extend({type:ne("FRAME_GET_SMART_ACCOUNT_ENABLED_NETWORKS_SUCCESS"),payload:jE})).or(re.extend({type:ne("FRAME_GET_SMART_ACCOUNT_ENABLED_NETWORKS_ERROR"),payload:Qe})).or(re.extend({type:ne("FRAME_INIT_SMART_ACCOUNT_ERROR"),payload:Qe})).or(re.extend({type:ne("FRAME_SET_PREFERRED_ACCOUNT_SUCCESS"),payload:qE})).or(re.extend({type:ne("FRAME_SET_PREFERRED_ACCOUNT_ERROR"),payload:Qe})).or(re.extend({type:ne("FRAME_READY"),payload:FE})).or(re.extend({type:ne("FRAME_RELOAD_ERROR"),payload:Qe})).or(re.extend({type:ne("FRAME_RELOAD_SUCCESS")}))};function vc(t,e={}){var s;return typeof(e==null?void 0:e.type)=="string"&&((s=e==null?void 0:e.type)==null?void 0:s.includes(t))}function Db({projectId:t,chainId:e,enableLogger:s,rpcUrl:n=U.BLOCKCHAIN_API_RPC_URL,enableCloudAuthAccount:r=!1}){const i=new URL(mw);i.searchParams.set("projectId",t),i.searchParams.set("chainId",String(e)),i.searchParams.set("version",ww),i.searchParams.set("enableLogger",String(s)),i.searchParams.set("rpcUrl",n);const o=lt.get("dapp_smart_account_version");return o&&(o==="v6"||o==="v7")&&(console.warn(">> AppKit - Forcing smart account version",o),i.searchParams.set("smartAccountVersion",o)),r&&i.searchParams.set("enableCloudAuthAccount","true"),i.toString()}class Lb{constructor({projectId:e,isAppClient:s=!1,chainId:n="eip155:1",enableLogger:r=!0,enableCloudAuthAccount:i=!1,rpcUrl:o=U.BLOCKCHAIN_API_RPC_URL}){if(this.iframe=null,this.iframeIsReady=!1,this.initFrame=()=>{const a=document.getElementById("w3m-iframe");this.iframe&&!a&&document.body.appendChild(this.iframe)},this.events={registerFrameEventHandler:(a,c,l)=>{function d({data:u}){var p;if(!vc(oe.FRAME_EVENT_KEY,u))return;const h=bc.frameEvent.safeParse(u);if(!h.success){console.warn("W3mFrame: invalid frame event",h.error.message);return}((p=h.data)==null?void 0:p.id)===a&&(c(h.data),window.removeEventListener("message",d))}cs.isClient&&(window.addEventListener("message",d),l.addEventListener("abort",()=>{window.removeEventListener("message",d)}))},onFrameEvent:a=>{cs.isClient&&window.addEventListener("message",({data:c})=>{if(!vc(oe.FRAME_EVENT_KEY,c))return;const l=bc.frameEvent.safeParse(c);l.success?a(l.data):console.warn("W3mFrame: invalid frame event",l.error.message)})},onAppEvent:a=>{cs.isClient&&window.addEventListener("message",({data:c})=>{if(!vc(oe.APP_EVENT_KEY,c))return;const l=bc.appEvent.safeParse(c);l.success||console.warn("W3mFrame: invalid app event",l.error.message),a(c)})},postAppEvent:a=>{var c;if(cs.isClient){if(!((c=this.iframe)!=null&&c.contentWindow))throw new Error("W3mFrame: iframe is not set");this.iframe.contentWindow.postMessage(a,"*")}},postFrameEvent:a=>{if(cs.isClient){if(!parent)throw new Error("W3mFrame: parent is not set");parent.postMessage(a,"*")}}},this.projectId=e,this.frameLoadPromise=new Promise((a,c)=>{this.frameLoadPromiseResolver={resolve:a,reject:c}}),this.rpcUrl=o,s&&(this.frameLoadPromise=new Promise((a,c)=>{this.frameLoadPromiseResolver={resolve:a,reject:c}}),cs.isClient)){const a=document.createElement("iframe");a.id="w3m-iframe",a.src=Db({projectId:e,chainId:n,enableLogger:r,rpcUrl:this.rpcUrl,enableCloudAuthAccount:i}),a.name="w3m-secure-iframe",a.style.position="fixed",a.style.zIndex="999999",a.style.display="none",a.style.border="none",a.style.animationDelay="0s, 50ms",a.style.borderBottomLeftRadius="clamp(0px, var(--apkt-borderRadius-8), 44px)",a.style.borderBottomRightRadius="clamp(0px, var(--apkt-borderRadius-8), 44px)",this.iframe=a,this.iframe.onerror=()=>{var c;(c=this.frameLoadPromiseResolver)==null||c.reject("Unable to load email login dependency")},this.events.onFrameEvent(c=>{var l;c.type==="@w3m-frame/READY"&&(this.iframeIsReady=!0,(l=this.frameLoadPromiseResolver)==null||l.resolve(void 0))})}}get networks(){const e=["eip155:1","eip155:5","eip155:11155111","eip155:10","eip155:420","eip155:42161","eip155:421613","eip155:137","eip155:80001","eip155:42220","eip155:1313161554","eip155:1313161555","eip155:56","eip155:97","eip155:43114","eip155:43113","eip155:324","eip155:280","eip155:100","eip155:8453","eip155:84531","eip155:84532","eip155:7777777","eip155:999","solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp","solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z","solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1"].map(s=>({[s]:{rpcUrl:`${this.rpcUrl}/v1/?chainId=${s}&projectId=${this.projectId}`,chainId:s}}));return Object.assign({},...e)}}var bi={exports:{}},xu;function Mb(){if(xu)return bi.exports;xu=1;const t=Sy();bi.exports=d;const e=T().console||{},s={mapHttpRequest:L,mapHttpResponse:L,wrapRequestSerializer:W,wrapResponseSerializer:W,wrapErrorSerializer:W,req:L,res:L,err:P,errWithCause:P};function n(y,b){return y==="silent"?1/0:b.levels.values[y]}const r=Symbol("pino.logFuncs"),i=Symbol("pino.hierarchy"),o={error:"log",fatal:"error",warn:"error",info:"log",debug:"log",trace:"log"};function a(y,b){const S={logger:b,parent:y[i]};b[i]=S}function c(y,b,S){const R={};b.forEach(C=>{R[C]=S[C]?S[C]:e[C]||e[o[C]||"log"]||k}),y[r]=R}function l(y,b){return Array.isArray(y)?y.filter(function(R){return R!=="!stdSerializers.err"}):y===!0?Object.keys(b):!1}function d(y){y=y||{},y.browser=y.browser||{};const b=y.browser.transmit;if(b&&typeof b.send!="function")throw Error("pino: transmit option must have a send function");const S=y.browser.write||e;y.browser.write&&(y.browser.asObject=!0);const R=y.serializers||{},C=l(y.browser.serialize,R);let O=y.browser.serialize;Array.isArray(y.browser.serialize)&&y.browser.serialize.indexOf("!stdSerializers.err")>-1&&(O=!1);const B=Object.keys(y.customLevels||{}),M=["error","fatal","warn","info","debug","trace"].concat(B);typeof S=="function"&&M.forEach(function(ve){S[ve]=S}),(y.enabled===!1||y.browser.disabled)&&(y.level="silent");const ce=y.level||"info",j=Object.create(S);j.log||(j.log=k),c(j,M,S),a({},j),Object.defineProperty(j,"levelVal",{get:he}),Object.defineProperty(j,"level",{get:ge,set:xe});const J={transmit:b,serialize:C,asObject:y.browser.asObject,asObjectBindingsOnly:y.browser.asObjectBindingsOnly,formatters:y.browser.formatters,levels:M,timestamp:D(y),messageKey:y.messageKey||"msg",onChild:y.onChild||k};j.levels=u(y),j.level=ce,j.isLevelEnabled=function(ve){return this.levels.values[ve]?this.levels.values[ve]>=this.levels.values[this.level]:!1},j.setMaxListeners=j.getMaxListeners=j.emit=j.addListener=j.on=j.prependListener=j.once=j.prependOnceListener=j.removeListener=j.removeAllListeners=j.listeners=j.listenerCount=j.eventNames=j.write=j.flush=k,j.serializers=R,j._serialize=C,j._stdErrSerialize=O,j.child=function(...ve){return ye.call(this,J,...ve)},b&&(j._logEvent=_());function he(){return n(this.level,this)}function ge(){return this._level}function xe(ve){if(ve!=="silent"&&!this.levels.values[ve])throw Error("unknown level "+ve);this._level=ve,g(this,J,j,"error"),g(this,J,j,"fatal"),g(this,J,j,"warn"),g(this,J,j,"info"),g(this,J,j,"debug"),g(this,J,j,"trace"),B.forEach(ze=>{g(this,J,j,ze)})}function ye(ve,ze,st){if(!ze)throw new Error("missing bindings for child Pino");st=st||{},C&&ze.serializers&&(st.serializers=ze.serializers);const ut=st.serializers;if(C&&ut){var wt=Object.assign({},R,ut),Ms=y.browser.serialize===!0?Object.keys(wt):C;delete ze.serializers,N([ze],Ms,wt,this._stdErrSerialize)}function tn($o){this._childLevel=($o._childLevel|0)+1,this.bindings=ze,wt&&(this.serializers=wt,this._serialize=Ms),b&&(this._logEvent=_([].concat($o._logEvent.bindings,ze)))}tn.prototype=this;const Ei=new tn(this);return a(this,Ei),Ei.child=function(...$o){return ye.call(this,ve,...$o)},Ei.level=st.level||this.level,ve.onChild(Ei),Ei}return j}function u(y){const b=y.customLevels||{},S=Object.assign({},d.levels.values,b),R=Object.assign({},d.levels.labels,h(b));return{values:S,labels:R}}function h(y){const b={};return Object.keys(y).forEach(function(S){b[y[S]]=S}),b}d.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}},d.stdSerializers=s,d.stdTimeFunctions=Object.assign({},{nullTime:q,epochTime:z,unixTime:x,isoTime:I});function p(y){const b=[];y.bindings&&b.push(y.bindings);let S=y[i];for(;S.parent;)S=S.parent,S.logger.bindings&&b.push(S.logger.bindings);return b.reverse()}function g(y,b,S,R){if(Object.defineProperty(y,R,{value:n(y.level,S)>n(R,S)?k:S[r][R],writable:!0,enumerable:!0,configurable:!0}),y[R]===k){if(!b.transmit)return;const O=b.transmit.level||y.level,B=n(O,S);if(n(R,S)<B)return}y[R]=w(y,b,S,R);const C=p(y);C.length!==0&&(y[R]=f(C,y[R]))}function f(y,b){return function(){return b.apply(this,[...y,...arguments])}}function w(y,b,S,R){return(function(C){return function(){const B=b.timestamp(),M=new Array(arguments.length),ce=Object.getPrototypeOf&&Object.getPrototypeOf(this)===e?e:this;for(var j=0;j<M.length;j++)M[j]=arguments[j];var J=!1;if(b.serialize&&(N(M,this._serialize,this.serializers,this._stdErrSerialize),J=!0),b.asObject||b.formatters?C.call(ce,...v(this,R,M,B,b)):C.apply(ce,M),b.transmit){const he=b.transmit.level||y._level,ge=n(he,S),xe=n(R,S);if(xe<ge)return;A(this,{ts:B,methodLevel:R,methodValue:xe,transmitValue:S.levels.values[b.transmit.level||y._level],send:b.transmit.send,val:n(y._level,S)},M,J)}}})(y[r][R])}function v(y,b,S,R,C){const{level:O,log:B=he=>he}=C.formatters||{},M=S.slice();let ce=M[0];const j={};let J=(y._childLevel|0)+1;if(J<1&&(J=1),R&&(j.time=R),O){const he=O(b,y.levels.values[b]);Object.assign(j,he)}else j.level=y.levels.values[b];if(C.asObjectBindingsOnly){if(ce!==null&&typeof ce=="object")for(;J--&&typeof M[0]=="object";)Object.assign(j,M.shift());return[B(j),...M]}else{if(ce!==null&&typeof ce=="object"){for(;J--&&typeof M[0]=="object";)Object.assign(j,M.shift());ce=M.length?t(M.shift(),M):void 0}else typeof ce=="string"&&(ce=t(M.shift(),M));return ce!==void 0&&(j[C.messageKey]=ce),[B(j)]}}function N(y,b,S,R){for(const C in y)if(R&&y[C]instanceof Error)y[C]=d.stdSerializers.err(y[C]);else if(typeof y[C]=="object"&&!Array.isArray(y[C])&&b)for(const O in y[C])b.indexOf(O)>-1&&O in S&&(y[C][O]=S[O](y[C][O]))}function A(y,b,S,R=!1){const C=b.send,O=b.ts,B=b.methodLevel,M=b.methodValue,ce=b.val,j=y._logEvent.bindings;R||N(S,y._serialize||Object.keys(y.serializers),y.serializers,y._stdErrSerialize===void 0?!0:y._stdErrSerialize),y._logEvent.ts=O,y._logEvent.messages=S.filter(function(J){return j.indexOf(J)===-1}),y._logEvent.level.label=B,y._logEvent.level.value=M,C(B,y._logEvent,ce),y._logEvent=_(j)}function _(y){return{ts:0,messages:[],bindings:y||[],level:{label:"",value:0}}}function P(y){const b={type:y.constructor.name,msg:y.message,stack:y.stack};for(const S in y)b[S]===void 0&&(b[S]=y[S]);return b}function D(y){return typeof y.timestamp=="function"?y.timestamp:y.timestamp===!1?q:z}function L(){return{}}function W(y){return y}function k(){}function q(){return!1}function z(){return Date.now()}function x(){return Math.round(Date.now()/1e3)}function I(){return new Date(Date.now()).toISOString()}function T(){function y(b){return typeof b<"u"&&b}try{return typeof globalThis<"u"||Object.defineProperty(Object.prototype,"globalThis",{get:function(){return delete Object.prototype.globalThis,this.globalThis=this},configurable:!0}),globalThis}catch{return y(self)||y(window)||y(this)||{}}}return bi.exports.default=d,bi.exports.pino=d,bi.exports}var Kr=Mb();const Uf=uy(Kr),Bb={level:"info"},ec="custom_context",vd=1e3*1024;var jb=Object.defineProperty,Fb=(t,e,s)=>e in t?jb(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Bn=(t,e,s)=>Fb(t,typeof e!="symbol"?e+"":e,s);let qb=class{constructor(e){Bn(this,"nodeValue"),Bn(this,"sizeInBytes"),Bn(this,"next"),this.nodeValue=e,this.sizeInBytes=new TextEncoder().encode(this.nodeValue).length,this.next=null}get value(){return this.nodeValue}get size(){return this.sizeInBytes}},ku=class{constructor(e){Bn(this,"lengthInNodes"),Bn(this,"sizeInBytes"),Bn(this,"head"),Bn(this,"tail"),Bn(this,"maxSizeInBytes"),this.head=null,this.tail=null,this.lengthInNodes=0,this.maxSizeInBytes=e,this.sizeInBytes=0}append(e){const s=new qb(e);if(s.size>this.maxSizeInBytes)throw new Error(`[LinkedList] Value too big to insert into list: ${e} with size ${s.size}`);for(;this.size+s.size>this.maxSizeInBytes;)this.shift();this.head?(this.tail&&(this.tail.next=s),this.tail=s):(this.head=s,this.tail=s),this.lengthInNodes++,this.sizeInBytes+=s.size}shift(){if(!this.head)return;const e=this.head;this.head=this.head.next,this.head||(this.tail=null),this.lengthInNodes--,this.sizeInBytes-=e.size}toArray(){const e=[];let s=this.head;for(;s!==null;)e.push(s.value),s=s.next;return e}get length(){return this.lengthInNodes}get size(){return this.sizeInBytes}toOrderedArray(){return Array.from(this)}[Symbol.iterator](){let e=this.head;return{next:()=>{if(!e)return{done:!0,value:null};const s=e.value;return e=e.next,{done:!1,value:s}}}}};var Wb=Object.defineProperty,Hb=(t,e,s)=>e in t?Wb(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Fo=(t,e,s)=>Hb(t,typeof e!="symbol"?e+"":e,s);let $f=class{constructor(e,s=vd){Fo(this,"logs"),Fo(this,"level"),Fo(this,"levelValue"),Fo(this,"MAX_LOG_SIZE_IN_BYTES"),this.level=e??"error",this.levelValue=Kr.levels.values[this.level],this.MAX_LOG_SIZE_IN_BYTES=s,this.logs=new ku(this.MAX_LOG_SIZE_IN_BYTES)}forwardToConsole(e,s){s===Kr.levels.values.error?console.error(e):s===Kr.levels.values.warn?console.warn(e):s===Kr.levels.values.debug?console.debug(e):s===Kr.levels.values.trace?console.trace(e):console.log(e)}appendToLogs(e){this.logs.append(Gi({timestamp:new Date().toISOString(),log:e}));const s=typeof e=="string"?JSON.parse(e).level:e.level;s>=this.levelValue&&this.forwardToConsole(e,s)}getLogs(){return this.logs}clearLogs(){this.logs=new ku(this.MAX_LOG_SIZE_IN_BYTES)}getLogArray(){return Array.from(this.logs)}logsToBlob(e){const s=this.getLogArray();return s.push(Gi({extraMetadata:e})),new Blob(s,{type:"application/json"})}};var Vb=Object.defineProperty,zb=(t,e,s)=>e in t?Vb(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Kb=(t,e,s)=>zb(t,e+"",s);let Gb=class{constructor(e,s=vd){Kb(this,"baseChunkLogger"),this.baseChunkLogger=new $f(e,s)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}downloadLogsBlobInBrowser(e){const s=URL.createObjectURL(this.logsToBlob(e)),n=document.createElement("a");n.href=s,n.download=`walletconnect-logs-${new Date().toISOString()}.txt`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(s)}};var Yb=Object.defineProperty,Zb=(t,e,s)=>e in t?Yb(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Jb=(t,e,s)=>Zb(t,e+"",s);let Xb=class{constructor(e,s=vd){Jb(this,"baseChunkLogger"),this.baseChunkLogger=new $f(e,s)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}};var Qb=Object.defineProperty,ev=Object.defineProperties,tv=Object.getOwnPropertyDescriptors,Uu=Object.getOwnPropertySymbols,sv=Object.prototype.hasOwnProperty,nv=Object.prototype.propertyIsEnumerable,$u=(t,e,s)=>e in t?Qb(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,xa=(t,e)=>{for(var s in e||(e={}))sv.call(e,s)&&$u(t,s,e[s]);if(Uu)for(var s of Uu(e))nv.call(e,s)&&$u(t,s,e[s]);return t},ka=(t,e)=>ev(t,tv(e));function Cd(t){return ka(xa({},t),{level:(t==null?void 0:t.level)||Bb.level})}function rv(t,e,s=ec){return t[s]=e,t}function es(t,e=ec){return t[e]||""}function iv(t,e,s=ec){const n=es(t,s);return n.trim()?`${n}/${e}`:e}function ts(t,e,s=ec){const n=iv(t,e,s),r=t.child({context:n});return rv(r,n,s)}function ov(t){var e,s;const n=new Gb((e=t.opts)==null?void 0:e.level,t.maxSizeInBytes);return{logger:Uf(ka(xa({},t.opts),{level:"trace",browser:ka(xa({},(s=t.opts)==null?void 0:s.browser),{write:r=>n.write(r)})})),chunkLoggerController:n}}function av(t){var e;const s=new Xb((e=t.opts)==null?void 0:e.level,t.maxSizeInBytes);return{logger:Uf(ka(xa({},t.opts),{level:"trace"}),s),chunkLoggerController:s}}function tc(t){return typeof t.loggerOverride<"u"&&typeof t.loggerOverride!="string"?{logger:t.loggerOverride,chunkLoggerController:null}:typeof window<"u"?ov(t):av(t)}class cv{constructor(e){var i;const s=Cd({level:yw}),{logger:n,chunkLoggerController:r}=tc({opts:s});this.logger=ts(n,this.constructor.name),this.chunkLoggerController=r,typeof window<"u"&&((i=this.chunkLoggerController)!=null&&i.downloadLogsBlobInBrowser)&&(window.downloadAppKitLogsBlob||(window.downloadAppKitLogsBlob={}),window.downloadAppKitLogsBlob.sdk=()=>{var o;(o=this.chunkLoggerController)!=null&&o.downloadLogsBlobInBrowser&&this.chunkLoggerController.downloadLogsBlobInBrowser({projectId:e})})}}class lv{constructor({projectId:e,chainId:s,enableLogger:n=!0,onTimeout:r,abortController:i,getActiveCaipNetwork:o,getCaipNetworks:a,enableCloudAuthAccount:c,metadata:l,sdkVersion:d,sdkType:u}){this.openRpcRequests=new Map,this.isInitialized=!1,n&&(this.w3mLogger=new cv(e)),this.abortController=i,this.getActiveCaipNetwork=o,this.getCaipNetworks=a;const h=this.getRpcUrl(s);this.projectId=e,this.sdkVersion=d,this.sdkType=u,this.metadata=l,this.w3mFrame=new Lb({projectId:e,isAppClient:!0,chainId:s,enableLogger:n,rpcUrl:h,enableCloudAuthAccount:c}),this.onTimeout=r,this.getLoginEmailUsed()&&this.createFrame()}async createFrame(){this.w3mFrame.initFrame(),this.initPromise=new Promise(e=>{this.w3mFrame.events.onFrameEvent(s=>{s.type===oe.FRAME_READY&&setTimeout(()=>{e()},500)})}),await this.initPromise,await this.syncDappData({metadata:this.metadata,projectId:this.projectId,sdkVersion:this.sdkVersion,sdkType:this.sdkType}),await this.getSmartAccountEnabledNetworks(),this.isInitialized=!0,this.initPromise=void 0}async init(){if(!this.isInitialized){if(this.initPromise){await this.initPromise;return}await this.createFrame()}}getLoginEmailUsed(){return!!lt.get(oe.EMAIL_LOGIN_USED_KEY)}getEmail(){return lt.get(oe.EMAIL)}getUsername(){return lt.get(oe.SOCIAL_USERNAME)}async reload(){var e;try{await this.appEvent({type:oe.APP_RELOAD})}catch(s){throw(e=this.w3mLogger)==null||e.logger.error({error:s},"Error reloading iframe"),s}}async connectEmail(e){var s;try{cs.checkIfAllowedToTriggerEmail(),await this.init();const n=await this.appEvent({type:oe.APP_CONNECT_EMAIL,payload:e});return this.setNewLastEmailLoginTime(),n}catch(n){throw(s=this.w3mLogger)==null||s.logger.error({error:n},"Error connecting email"),n}}async connectDevice(){var e;try{return this.appEvent({type:oe.APP_CONNECT_DEVICE})}catch(s){throw(e=this.w3mLogger)==null||e.logger.error({error:s},"Error connecting device"),s}}async connectOtp(e){var s;try{return this.appEvent({type:oe.APP_CONNECT_OTP,payload:e})}catch(n){throw(s=this.w3mLogger)==null||s.logger.error({error:n},"Error connecting otp"),n}}async isConnected(){var e;try{if(!this.getLoginEmailUsed())return{isConnected:!1};const s=await this.appEvent({type:oe.APP_IS_CONNECTED});return s!=null&&s.isConnected||this.deleteAuthLoginCache(),s}catch(s){throw this.deleteAuthLoginCache(),(e=this.w3mLogger)==null||e.logger.error({error:s},"Error checking connection"),s}}async getChainId(){var e;try{const s=await this.appEvent({type:oe.APP_GET_CHAIN_ID});return this.setLastUsedChainId(s.chainId),s}catch(s){throw(e=this.w3mLogger)==null||e.logger.error({error:s},"Error getting chain id"),s}}async getSocialRedirectUri(e){var s;try{return await this.init(),this.appEvent({type:oe.APP_GET_SOCIAL_REDIRECT_URI,payload:e})}catch(n){throw(s=this.w3mLogger)==null||s.logger.error({error:n},"Error getting social redirect uri"),n}}async updateEmail(e){var s;try{const n=await this.appEvent({type:oe.APP_UPDATE_EMAIL,payload:e});return this.setNewLastEmailLoginTime(),n}catch(n){throw(s=this.w3mLogger)==null||s.logger.error({error:n},"Error updating email"),n}}async updateEmailPrimaryOtp(e){var s;try{return this.appEvent({type:oe.APP_UPDATE_EMAIL_PRIMARY_OTP,payload:e})}catch(n){throw(s=this.w3mLogger)==null||s.logger.error({error:n},"Error updating email primary otp"),n}}async updateEmailSecondaryOtp(e){var s;try{const n=await this.appEvent({type:oe.APP_UPDATE_EMAIL_SECONDARY_OTP,payload:e});return this.setLoginSuccess(n.newEmail),n}catch(n){throw(s=this.w3mLogger)==null||s.logger.error({error:n},"Error updating email secondary otp"),n}}async syncTheme(e){var s;try{return this.appEvent({type:oe.APP_SYNC_THEME,payload:e})}catch(n){throw(s=this.w3mLogger)==null||s.logger.error({error:n},"Error syncing theme"),n}}async syncDappData(e){var s;try{return this.appEvent({type:oe.APP_SYNC_DAPP_DATA,payload:e})}catch(n){throw(s=this.w3mLogger)==null||s.logger.error({error:n},"Error syncing dapp data"),n}}async getSmartAccountEnabledNetworks(){var e;try{const s=await this.appEvent({type:oe.APP_GET_SMART_ACCOUNT_ENABLED_NETWORKS});return this.persistSmartAccountEnabledNetworks(s.smartAccountEnabledNetworks),s}catch(s){throw this.persistSmartAccountEnabledNetworks([]),(e=this.w3mLogger)==null||e.logger.error({error:s},"Error getting smart account enabled networks"),s}}async setPreferredAccount(e){var s;try{return this.appEvent({type:oe.APP_SET_PREFERRED_ACCOUNT,payload:{type:e}})}catch(n){throw(s=this.w3mLogger)==null||s.logger.error({error:n},"Error setting preferred account"),n}}async connect(e){var s,n;if(e!=null&&e.socialUri)try{await this.init();const r=this.getRpcUrl(e.chainId),i=await this.appEvent({type:oe.APP_CONNECT_SOCIAL,payload:{uri:e.socialUri,preferredAccountType:e.preferredAccountType,chainId:e.chainId,siwxMessage:e.siwxMessage,rpcUrl:r}});return i.userName&&this.setSocialLoginSuccess(i.userName),this.setLoginSuccess(i.email),this.setLastUsedChainId(i.chainId),this.user=i,i}catch(r){throw(s=this.w3mLogger)==null||s.logger.error({error:r},"Error connecting social"),r}else try{const r=(e==null?void 0:e.chainId)||this.getLastUsedChainId()||1,i=await this.getUser({chainId:r,preferredAccountType:e==null?void 0:e.preferredAccountType,siwxMessage:e==null?void 0:e.siwxMessage,rpcUrl:this.getRpcUrl(r)});return this.setLoginSuccess(i.email),this.setLastUsedChainId(i.chainId),this.user=i,i}catch(r){throw(n=this.w3mLogger)==null||n.logger.error({error:r},"Error connecting"),r}}async getUser(e){var s;try{await this.init();const n=(e==null?void 0:e.chainId)||this.getLastUsedChainId()||1,r=await this.appEvent({type:oe.APP_GET_USER,payload:{...e,chainId:n,rpcUrl:this.getRpcUrl(n)}});return this.user=r,r}catch(n){throw(s=this.w3mLogger)==null||s.logger.error({error:n},"Error connecting"),n}}async connectSocial({uri:e,chainId:s,preferredAccountType:n}){var r;try{await this.init();const i=this.getRpcUrl(s),o=await this.appEvent({type:oe.APP_CONNECT_SOCIAL,payload:{uri:e,chainId:s,rpcUrl:i,preferredAccountType:n}});return o.userName&&this.setSocialLoginSuccess(o.userName),o}catch(i){throw(r=this.w3mLogger)==null||r.logger.error({error:i},"Error connecting social"),i}}async getFarcasterUri(){var e;try{return await this.init(),await this.appEvent({type:oe.APP_GET_FARCASTER_URI})}catch(s){throw(e=this.w3mLogger)==null||e.logger.error({error:s},"Error getting farcaster uri"),s}}async connectFarcaster(){var e;try{const s=await this.appEvent({type:oe.APP_CONNECT_FARCASTER});return s.userName&&this.setSocialLoginSuccess(s.userName),s}catch(s){throw(e=this.w3mLogger)==null||e.logger.error({error:s},"Error connecting farcaster"),s}}async switchNetwork({chainId:e}){var s;try{const n=this.getRpcUrl(e),r=await this.appEvent({type:oe.APP_SWITCH_NETWORK,payload:{chainId:e,rpcUrl:n}});return this.setLastUsedChainId(r.chainId),r}catch(n){throw(s=this.w3mLogger)==null||s.logger.error({error:n},"Error switching network"),n}}async disconnect(){var e;try{return this.deleteAuthLoginCache(),await new Promise(async n=>{const r=setTimeout(()=>{n()},3e3);await this.appEvent({type:oe.APP_SIGN_OUT}),clearTimeout(r),n()})}catch(s){throw(e=this.w3mLogger)==null||e.logger.error({error:s},"Error disconnecting"),s}}async request(e){var n,r,i,o,a;const s=e;try{if(tt.GET_CHAIN_ID===e.method)return this.getLastUsedChainId();const c=e.chainNamespace||"eip155",l=(n=this.getActiveCaipNetwork(c))==null?void 0:n.id;s.chainNamespace=c,s.chainId=l,s.rpcUrl=this.getRpcUrl(l),(r=this.rpcRequestHandler)==null||r.call(this,e);const d=await this.appEvent({type:oe.APP_RPC_REQUEST,payload:s});return(i=this.rpcSuccessHandler)==null||i.call(this,d,s),d}catch(c){throw(o=this.rpcErrorHandler)==null||o.call(this,c,s),(a=this.w3mLogger)==null||a.logger.error({error:c},"Error requesting"),c}}onRpcRequest(e){this.rpcRequestHandler=e}onRpcSuccess(e){this.rpcSuccessHandler=e}onRpcError(e){this.rpcErrorHandler=e}onIsConnected(e){this.w3mFrame.events.onFrameEvent(s=>{s.type===oe.FRAME_IS_CONNECTED_SUCCESS&&s.payload.isConnected&&e()})}onNotConnected(e){this.w3mFrame.events.onFrameEvent(s=>{s.type===oe.FRAME_IS_CONNECTED_ERROR&&e(),s.type===oe.FRAME_IS_CONNECTED_SUCCESS&&!s.payload.isConnected&&e()})}onConnect(e){this.w3mFrame.events.onFrameEvent(s=>{s.type===oe.FRAME_GET_USER_SUCCESS&&e(s.payload)})}onSocialConnected(e){this.w3mFrame.events.onFrameEvent(s=>{s.type===oe.FRAME_CONNECT_SOCIAL_SUCCESS&&e(s.payload)})}async getCapabilities(){try{return await this.request({method:"wallet_getCapabilities"})||{}}catch{return{}}}onSetPreferredAccount(e){this.w3mFrame.events.onFrameEvent(s=>{s.type===oe.FRAME_SET_PREFERRED_ACCOUNT_SUCCESS?e(s.payload):s.type===oe.FRAME_SET_PREFERRED_ACCOUNT_ERROR&&e({type:tt.ACCOUNT_TYPES.EOA})})}getAvailableChainIds(){return Object.keys(this.w3mFrame.networks)}async rejectRpcRequests(){var e;try{await Promise.all(Array.from(this.openRpcRequests.values()).map(async({abortController:s,method:n})=>{tt.SAFE_RPC_METHODS.includes(n)||s.abort(),await this.appEvent({type:oe.APP_RPC_ABORT})})),this.openRpcRequests.clear()}catch(s){(e=this.w3mLogger)==null||e.logger.error({error:s},"Error aborting RPC request")}}async appEvent(e){let s,n;function r(c){return c.replace("@w3m-app/","")}const i=[oe.APP_SYNC_DAPP_DATA,oe.APP_SYNC_THEME,oe.APP_SET_PREFERRED_ACCOUNT],o=r(e.type);return!this.w3mFrame.iframeIsReady&&!i.includes(e.type)&&(n=setTimeout(()=>{var c;(c=this.onTimeout)==null||c.call(this,"iframe_load_failed"),this.abortController.abort()},2e4)),await this.w3mFrame.frameLoadPromise,clearTimeout(n),[oe.APP_CONNECT_EMAIL,oe.APP_CONNECT_DEVICE,oe.APP_CONNECT_OTP,oe.APP_CONNECT_SOCIAL,oe.APP_GET_SOCIAL_REDIRECT_URI].map(r).includes(o)&&(s=setTimeout(()=>{var c;(c=this.onTimeout)==null||c.call(this,"iframe_request_timeout"),this.abortController.abort()},12e4)),new Promise((c,l)=>{var p,g,f;const d=Math.random().toString(36).substring(7);(f=(p=this.w3mLogger)==null?void 0:(g=p.logger).info)==null||f.call(g,{event:e,id:d},"Sending app event"),this.w3mFrame.events.postAppEvent({...e,id:d});const u=new AbortController;if(o==="RPC_REQUEST"){const w=e;this.openRpcRequests.set(d,{...w.payload,abortController:u})}u.signal.addEventListener("abort",()=>{o==="RPC_REQUEST"?l(new Error("Request was aborted")):o!=="GET_FARCASTER_URI"&&l(new Error("Something went wrong"))});const h=(w,v)=>{var N,A,_;w.id===d&&((A=v==null?void 0:(N=v.logger).info)==null||A.call(N,{framEvent:w,id:d},"Received frame response"),this.openRpcRequests.delete(w.id),w.type===`@w3m-frame/${o}_SUCCESS`?(s&&clearTimeout(s),n&&clearTimeout(n),"payload"in w&&c(w.payload),c(void 0)):w.type===`@w3m-frame/${o}_ERROR`&&(s&&clearTimeout(s),n&&clearTimeout(n),"payload"in w&&l(new Error(((_=w.payload)==null?void 0:_.message)||"An error occurred")),l(new Error("An error occurred"))))};this.w3mFrame.events.registerFrameEventHandler(d,w=>h(w,this.w3mLogger),this.abortController.signal)})}setNewLastEmailLoginTime(){lt.set(oe.LAST_EMAIL_LOGIN_TIME,Date.now().toString())}setSocialLoginSuccess(e){lt.set(oe.SOCIAL_USERNAME,e)}setLoginSuccess(e){e&<.set(oe.EMAIL,e),lt.set(oe.EMAIL_LOGIN_USED_KEY,"true"),lt.delete(oe.LAST_EMAIL_LOGIN_TIME)}deleteAuthLoginCache(){lt.delete(oe.EMAIL_LOGIN_USED_KEY),lt.delete(oe.EMAIL),lt.delete(oe.LAST_USED_CHAIN_KEY),lt.delete(oe.SOCIAL_USERNAME)}setLastUsedChainId(e){e&<.set(oe.LAST_USED_CHAIN_KEY,String(e))}getLastUsedChainId(){const e=lt.get(oe.LAST_USED_CHAIN_KEY)??void 0,s=Number(e);return isNaN(s)?e:s}persistSmartAccountEnabledNetworks(e){lt.set(oe.SMART_ACCOUNT_ENABLED_NETWORKS,e.join(","))}getRpcUrl(e){var i,o;let s=e===void 0?void 0:"eip155";typeof e=="string"&&(e.includes(":")?s=(i=dt.parseCaipNetworkId(e))==null?void 0:i.chainNamespace:Number.isInteger(Number(e))?s="eip155":s="solana");const n=this.getCaipNetworks(s),r=e?n.find(a=>String(a.id)===String(e)||a.caipNetworkId===e):n[0];return(o=r==null?void 0:r.rpcUrls.default.http)==null?void 0:o[0]}}async function Df(t){return new Promise(e=>setTimeout(e,t))}function dv(t,{delay:e=100,retryCount:s=2,shouldRetry:n=()=>!0}={}){return new Promise((r,i)=>{const o=async({count:a=0}={})=>{const c=async({error:l})=>{const d=typeof e=="function"?e({count:a,error:l}):e;d&&await Df(d),o({count:a+1})};try{const l=await t();r(l)}catch(l){if(a<s&&await n({count:a,error:l}))return c({error:l});i(l)}};o()})}const Al=256;let qo=Al,Wo;function uv(t=11){if(!Wo||qo+t>Al*2){Wo="",qo=0;for(let e=0;e<Al;e++)Wo+=(256+Math.random()*256|0).toString(16).substring(1)}return Wo.substring(qo,qo+++t)}const Ho=new py(8192);function hv(t,{enabled:e=!0,id:s}){if(!e||!s)return t();if(Ho.get(s))return Ho.get(s);const n=t().finally(()=>Ho.delete(s));return Ho.set(s,n),n}function pv(t,e={}){return async(s,n={})=>{var u;const{dedupe:r=!1,methods:i,retryDelay:o=150,retryCount:a=3,uid:c}={...e,...n},{method:l}=s;if((u=i==null?void 0:i.exclude)!=null&&u.includes(l))throw new Do(new Error("method not supported"),{method:l});if(i!=null&&i.include&&!i.include.includes(l))throw new Do(new Error("method not supported"),{method:l});const d=r?fy(`${c}.${ca(s)}`):void 0;return hv(()=>dv(async()=>{try{return await t(s)}catch(h){const p=h;switch(p.code){case yu.code:throw new yu(p);case mu.code:throw new mu(p);case gu.code:throw new gu(p,{method:s.method});case fu.code:throw new fu(p);case ml.code:throw new ml(p);case pu.code:throw new pu(p);case hu.code:throw new hu(p);case uu.code:throw new uu(p);case gl.code:throw new gl(p);case Do.code:throw new Do(p,{method:s.method});case fl.code:throw new fl(p);case du.code:throw new du(p);case la.code:throw new la(p);case lu.code:throw new lu(p);case cu.code:throw new cu(p);case au.code:throw new au(p);case ou.code:throw new ou(p);case iu.code:throw new iu(p);case ru.code:throw new ru(p);case nu.code:throw new nu(p);case su.code:throw new su(p);case tu.code:throw new tu(p);case eu.code:throw new eu(p);case Qd.code:throw new Qd(p);case Xd.code:throw new Xd(p);case 5e3:throw new la(p);default:throw h instanceof ff?h:new gy(p)}}},{delay:({count:h,error:p})=>{var g;if(p&&p instanceof Mi){const f=(g=p==null?void 0:p.headers)==null?void 0:g.get("Retry-After");if(f!=null&&f.match(/\d/))return Number.parseInt(f,10)*1e3}return~~(1<<h)*o},retryCount:a,shouldRetry:({error:h})=>fv(h)}),{enabled:r,id:d})}}function fv(t){return"code"in t&&typeof t.code=="number"?t.code===-1||t.code===fl.code||t.code===ml.code:t instanceof Mi&&t.status?t.status===403||t.status===408||t.status===413||t.status===429||t.status===500||t.status===502||t.status===503||t.status===504:!0}function gv(t,{errorInstance:e=new Error("timed out"),timeout:s,signal:n}){return new Promise((r,i)=>{(async()=>{let o;try{const a=new AbortController;s>0&&(o=setTimeout(()=>{n&&a.abort()},s)),r(await t({signal:(a==null?void 0:a.signal)||null}))}catch(a){(a==null?void 0:a.name)==="AbortError"&&i(e),i(a)}finally{clearTimeout(o)}})()})}function mv(){return{current:0,take(){return this.current++},reset(){this.current=0}}}const Du=mv();function yv(t,e={}){return{async request(s){var h;const{body:n,fetchFn:r=e.fetchFn??fetch,onRequest:i=e.onRequest,onResponse:o=e.onResponse,timeout:a=e.timeout??1e4}=s,c={...e.fetchOptions??{},...s.fetchOptions??{}},{headers:l,method:d,signal:u}=c;try{const p=await gv(async({signal:f})=>{const w={...c,body:Array.isArray(n)?ca(n.map(_=>({jsonrpc:"2.0",id:_.id??Du.take(),..._}))):ca({jsonrpc:"2.0",id:n.id??Du.take(),...n}),headers:{"Content-Type":"application/json",...l},method:d||"POST",signal:u||(a>0?f:null)},v=new Request(t,w),N=await(i==null?void 0:i(v,w))??{...w,url:t};return await r(N.url??t,N)},{errorInstance:new wu({body:n,url:t}),timeout:a,signal:!0});o&&await o(p);let g;if((h=p.headers.get("Content-Type"))!=null&&h.startsWith("application/json"))g=await p.json();else{g=await p.text();try{g=JSON.parse(g||"{}")}catch(f){if(p.ok)throw f;g={error:g}}}if(!p.ok)throw new Mi({body:n,details:ca(g.error)||p.statusText,headers:p.headers,status:p.status,url:t});return g}catch(p){throw p instanceof Mi||p instanceof wu?p:new Mi({body:n,cause:p,url:t})}}}}function Lf({key:t,methods:e,name:s,request:n,retryCount:r=3,retryDelay:i=150,timeout:o,type:a},c){const l=uv();return{config:{key:t,methods:e,name:s,request:n,retryCount:r,retryDelay:i,timeout:o,type:a},request:pv(n,{methods:e,retryCount:r,retryDelay:i,uid:l}),value:c}}function Lu(t,e={}){const{key:s="fallback",name:n="Fallback",rank:r=!1,shouldThrow:i=wv,retryCount:o,retryDelay:a}=e;return(({chain:c,pollingInterval:l=4e3,timeout:d,...u})=>{let h=t,p=()=>{};const g=Lf({key:s,name:n,async request({method:f,params:w}){let v;const N=async(A=0)=>{const _=h[A]({...u,chain:c,retryCount:0,timeout:d});try{const P=await _.request({method:f,params:w});return p({method:f,params:w,response:P,transport:_,status:"success"}),P}catch(P){if(p({error:P,method:f,params:w,transport:_,status:"error"}),i(P)||A===h.length-1||(v??(v=h.slice(A+1).some(D=>{const{include:L,exclude:W}=D({chain:c}).config.methods||{};return L?L.includes(f):W?!W.includes(f):!0})),!v))throw P;return N(A+1)}};return N()},retryCount:o,retryDelay:a,type:"fallback"},{onResponse:f=>p=f,transports:h.map(f=>f({chain:c,retryCount:0}))});if(r){const f=typeof r=="object"?r:{};Ev({chain:c,interval:f.interval??l,onTransports:w=>h=w,ping:f.ping,sampleCount:f.sampleCount,timeout:f.timeout,transports:h,weights:f.weights})}return g})}function wv(t){return!!("code"in t&&typeof t.code=="number"&&(t.code===gl.code||t.code===la.code||my.nodeMessage.test(t.message)||t.code===5e3))}function Ev({chain:t,interval:e=4e3,onTransports:s,ping:n,sampleCount:r=10,timeout:i=1e3,transports:o,weights:a={}}){const{stability:c=.7,latency:l=.3}=a,d=[],u=async()=>{const h=await Promise.all(o.map(async f=>{const w=f({chain:t,retryCount:0,timeout:i}),v=Date.now();let N,A;try{await(n?n({transport:w}):w.request({method:"net_listening"})),A=1}catch{A=0}finally{N=Date.now()}return{latency:N-v,success:A}}));d.push(h),d.length>r&&d.shift();const p=Math.max(...d.map(f=>Math.max(...f.map(({latency:w})=>w)))),g=o.map((f,w)=>{const v=d.map(D=>D[w].latency),A=1-v.reduce((D,L)=>D+L,0)/v.length/p,_=d.map(D=>D[w].success),P=_.reduce((D,L)=>D+L,0)/_.length;return P===0?[0,w]:[l*A+c*P,w]}).sort((f,w)=>w[0]-f[0]);s(g.map(([,f])=>o[f])),await Df(e),u()};u()}class bv extends ff{constructor(){super("No URL was provided to the Transport. Please provide a valid RPC URL to the Transport.",{docsPath:"/docs/clients/intro",name:"UrlRequiredError"})}}function Vo(t,e={}){const{batch:s,fetchFn:n,fetchOptions:r,key:i="http",methods:o,name:a="HTTP JSON-RPC",onFetchRequest:c,onFetchResponse:l,retryDelay:d,raw:u}=e;return({chain:h,retryCount:p,timeout:g})=>{const{batchSize:f=1e3,wait:w=0}=typeof s=="object"?s:{},v=e.retryCount??p,N=g??e.timeout??1e4,A=t||(h==null?void 0:h.rpcUrls.default.http[0]);if(!A)throw new bv;const _=yv(A,{fetchFn:n,fetchOptions:r,onRequest:c,onResponse:l,timeout:N});return Lf({key:i,methods:o,name:a,async request({method:P,params:D}){const L={method:P,params:D},{schedule:W}=yy({id:A,wait:w,shouldSplitBatch(x){return x.length>f},fn:x=>_.request({body:x}),sort:(x,I)=>x.id-I.id}),k=async x=>s?W(x):[await _.request({body:x})],[{error:q,result:z}]=await k(L);if(u)return{error:q,result:z};if(q)throw new wy({body:L,error:q,url:A});return z},retryCount:v,retryDelay:d,timeout:N,type:"http"},{fetchOptions:r,url:A})}}async function vi(...t){const e=await fetch(...t);if(!e.ok)throw new Error(`HTTP status code: ${e.status}`,{cause:e});return e}class So{constructor({baseUrl:e,clientId:s}){this.baseUrl=e,this.clientId=s}async get({headers:e,signal:s,cache:n,...r}){const i=this.createUrl(r);return(await vi(i,{method:"GET",headers:e,signal:s,cache:n})).json()}async getBlob({headers:e,signal:s,...n}){const r=this.createUrl(n);return(await vi(r,{method:"GET",headers:e,signal:s})).blob()}async post({body:e,headers:s,signal:n,...r}){const i=this.createUrl(r);return(await vi(i,{method:"POST",headers:s,body:e?JSON.stringify(e):void 0,signal:n})).json()}async put({body:e,headers:s,signal:n,...r}){const i=this.createUrl(r);return(await vi(i,{method:"PUT",headers:s,body:e?JSON.stringify(e):void 0,signal:n})).json()}async delete({body:e,headers:s,signal:n,...r}){const i=this.createUrl(r);return(await vi(i,{method:"DELETE",headers:s,body:e?JSON.stringify(e):void 0,signal:n})).json()}createUrl({path:e,params:s}){const n=new URL(e,this.baseUrl);return s&&Object.entries(s).forEach(([r,i])=>{i&&n.searchParams.append(r,i)}),this.clientId&&n.searchParams.append("clientId",this.clientId),n}sendBeacon({body:e,...s}){const n=this.createUrl(s);return navigator.sendBeacon(n.toString(),e?JSON.stringify(e):void 0)}}const Sl={getFeatureValue(t,e){const s=e==null?void 0:e[t];return s===void 0?Ne.DEFAULT_FEATURES[t]:s},filterSocialsByPlatform(t){if(!t||!t.length)return t;let e=t;return X.isTelegram()&&(X.isIos()&&(e=e.filter(s=>s!=="google")),X.isMac()&&(e=e.filter(s=>s!=="x")),X.isAndroid()&&(e=e.filter(s=>!["facebook","x"].includes(s)))),X.isMobile()&&(e=e.filter(s=>s!=="facebook")),e},isSocialsEnabled(){var t,e,s,n;return Array.isArray((t=$.state.features)==null?void 0:t.socials)&&((e=$.state.features)==null?void 0:e.socials.length)>0||Array.isArray((s=$.state.remoteFeatures)==null?void 0:s.socials)&&((n=$.state.remoteFeatures)==null?void 0:n.socials.length)>0},isEmailEnabled(){var t,e;return!!((t=$.state.features)!=null&&t.email||(e=$.state.remoteFeatures)!=null&&e.email)}},de=Ge({features:Ne.DEFAULT_FEATURES,projectId:"",sdkType:"appkit",sdkVersion:"html-wagmi-undefined",defaultAccountTypes:Ne.DEFAULT_ACCOUNT_TYPES,enableNetworkSwitch:!0,experimental_preferUniversalLinks:!1,remoteFeatures:{},enableMobileFullScreen:!1,coinbasePreference:"all"}),$={state:de,subscribeKey(t,e){return At(de,t,e)},setOptions(t){Object.assign(de,t)},setRemoteFeatures(t){var s,n;if(!t)return;const e={...de.remoteFeatures,...t};de.remoteFeatures=e,(s=de.remoteFeatures)!=null&&s.socials&&(de.remoteFeatures.socials=Sl.filterSocialsByPlatform(de.remoteFeatures.socials)),(n=de.features)!=null&&n.pay&&(de.remoteFeatures.email=!1,de.remoteFeatures.socials=!1)},setFeatures(t){var s;if(!t)return;de.features||(de.features=Ne.DEFAULT_FEATURES);const e={...de.features,...t};de.features=e,(s=de.features)!=null&&s.pay&&de.remoteFeatures&&(de.remoteFeatures.email=!1,de.remoteFeatures.socials=!1)},setProjectId(t){de.projectId=t},setCustomRpcUrls(t){de.customRpcUrls=t},setAllWallets(t){de.allWallets=t},setIncludeWalletIds(t){de.includeWalletIds=t},setExcludeWalletIds(t){de.excludeWalletIds=t},setFeaturedWalletIds(t){de.featuredWalletIds=t},setTokens(t){de.tokens=t},setTermsConditionsUrl(t){de.termsConditionsUrl=t},setPrivacyPolicyUrl(t){de.privacyPolicyUrl=t},setCustomWallets(t){de.customWallets=t},setIsSiweEnabled(t){de.isSiweEnabled=t},setIsUniversalProvider(t){de.isUniversalProvider=t},setSdkVersion(t){de.sdkVersion=t},setMetadata(t){de.metadata=t},setDisableAppend(t){de.disableAppend=t},setEIP6963Enabled(t){de.enableEIP6963=t},setDebug(t){de.debug=t},setEnableWalletGuide(t){de.enableWalletGuide=t},setEnableAuthLogger(t){de.enableAuthLogger=t},setEnableWallets(t){de.enableWallets=t},setPreferUniversalLinks(t){de.experimental_preferUniversalLinks=t},setSIWX(t){if(t)for(const[e,s]of Object.entries(Ne.SIWX_DEFAULTS))t[e]??(t[e]=s);de.siwx=t},setConnectMethodsOrder(t){de.features={...de.features,connectMethodsOrder:t}},setWalletFeaturesOrder(t){de.features={...de.features,walletFeaturesOrder:t}},setSocialsOrder(t){de.remoteFeatures={...de.remoteFeatures,socials:t}},setCollapseWallets(t){de.features={...de.features,collapseWallets:t}},setEnableEmbedded(t){de.enableEmbedded=t},setAllowUnsupportedChain(t){de.allowUnsupportedChain=t},setManualWCControl(t){de.manualWCControl=t},setEnableNetworkSwitch(t){de.enableNetworkSwitch=t},setEnableMobileFullScreen(t){de.enableMobileFullScreen=X.isMobile()&&t},setEnableReconnect(t){de.enableReconnect=t},setCoinbasePreference(t){de.coinbasePreference=t},setDefaultAccountTypes(t={}){Object.entries(t).forEach(([e,s])=>{s&&(de.defaultAccountTypes[e]=s)})},setUniversalProviderConfigOverride(t){de.universalProviderConfigOverride=t},getUniversalProviderConfigOverride(){return de.universalProviderConfigOverride},getSnapshot(){return Xi(de)}},cr=Object.freeze({message:"",variant:"success",svg:void 0,open:!1,autoClose:!0}),at=Ge({...cr}),vv={state:at,subscribeKey(t,e){return At(at,t,e)},showLoading(t,e={}){this._showMessage({message:t,variant:"loading",...e})},showSuccess(t){this._showMessage({message:t,variant:"success"})},showSvg(t,e){this._showMessage({message:t,svg:e})},showError(t){const e=X.parseError(t);this._showMessage({message:e,variant:"error"})},hide(){at.message=cr.message,at.variant=cr.variant,at.svg=cr.svg,at.open=cr.open,at.autoClose=cr.autoClose},_showMessage({message:t,svg:e,variant:s="success",autoClose:n=cr.autoClose}){at.open?(at.open=!1,setTimeout(()=>{at.message=t,at.variant=s,at.svg=e,at.open=!0,at.autoClose=n},150)):(at.message=t,at.variant=s,at.svg=e,at.open=!0,at.autoClose=n)}},zs=vv,Cv={purchaseCurrencies:[{id:"2b92315d-eab7-5bef-84fa-089a131333f5",name:"USD Coin",symbol:"USDC",networks:[{name:"ethereum-mainnet",display_name:"Ethereum",chain_id:"1",contract_address:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},{name:"polygon-mainnet",display_name:"Polygon",chain_id:"137",contract_address:"0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174"}]},{id:"2b92315d-eab7-5bef-84fa-089a131333f5",name:"Ether",symbol:"ETH",networks:[{name:"ethereum-mainnet",display_name:"Ethereum",chain_id:"1",contract_address:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},{name:"polygon-mainnet",display_name:"Polygon",chain_id:"137",contract_address:"0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174"}]}],paymentCurrencies:[{id:"USD",payment_method_limits:[{id:"card",min:"10.00",max:"7500.00"},{id:"ach_bank_account",min:"10.00",max:"25000.00"}]},{id:"EUR",payment_method_limits:[{id:"card",min:"10.00",max:"7500.00"},{id:"ach_bank_account",min:"10.00",max:"25000.00"}]}]},Mf=X.getBlockchainApiUrl(),Ut=Ge({clientId:null,api:new So({baseUrl:Mf,clientId:null}),supportedChains:{http:[],ws:[]}}),fe={state:Ut,async get(t){const{st:e,sv:s}=fe.getSdkProperties(),n=$.state.projectId,r={...t.params||{},st:e,sv:s,projectId:n};return Ut.api.get({...t,params:r})},getSdkProperties(){const{sdkType:t,sdkVersion:e}=$.state;return{st:t||"unknown",sv:e||"unknown"}},async isNetworkSupported(t){if(!t)return!1;try{Ut.supportedChains.http.length||await fe.getSupportedNetworks()}catch{return!1}return Ut.supportedChains.http.includes(t)},async getSupportedNetworks(){try{const t=await fe.get({path:"v1/supported-chains"});return Ut.supportedChains=t,t}catch{return Ut.supportedChains}},async fetchIdentity({address:t}){const e=F.getIdentityFromCacheForAddress(t);if(e)return e;const s=await fe.get({path:`/v1/identity/${t}`,params:{sender:E.state.activeCaipAddress?X.getPlainAddress(E.state.activeCaipAddress):void 0}});return F.updateIdentityCache({address:t,identity:s,timestamp:Date.now()}),s},async fetchTransactions({account:t,cursor:e,signal:s,cache:n,chainId:r}){var c;if(!await fe.isNetworkSupported((c=E.state.activeCaipNetwork)==null?void 0:c.caipNetworkId))return{data:[],next:void 0};const o=F.getTransactionsCacheForAddress({address:t,chainId:r});if(o)return o;const a=await fe.get({path:`/v1/account/${t}/history`,params:{cursor:e,chainId:r},signal:s,cache:n});return F.updateTransactionsCache({address:t,chainId:r,timestamp:Date.now(),transactions:a}),a},async fetchSwapQuote({amount:t,userAddress:e,from:s,to:n,gasPrice:r}){var o;return await fe.isNetworkSupported((o=E.state.activeCaipNetwork)==null?void 0:o.caipNetworkId)?fe.get({path:"/v1/convert/quotes",headers:{"Content-Type":"application/json"},params:{amount:t,userAddress:e,from:s,to:n,gasPrice:r}}):{quotes:[]}},async fetchSwapTokens({chainId:t}){var s;return await fe.isNetworkSupported((s=E.state.activeCaipNetwork)==null?void 0:s.caipNetworkId)?fe.get({path:"/v1/convert/tokens",params:{chainId:t}}):{tokens:[]}},async getAddressBalance({caipNetworkId:t,address:e}){return Ut.api.post({path:`/v1?chainId=${t}&projectId=${$.state.projectId}`,body:{id:"1",jsonrpc:"2.0",method:"getAddressBalance",params:{address:e}}}).then(s=>s.result)},async fetchTokenPrice({addresses:t}){var r;if(!await fe.isNetworkSupported((r=E.state.activeCaipNetwork)==null?void 0:r.caipNetworkId))return{fungibles:[]};const s=F.getTokenPriceCacheForAddresses(t);if(s)return s;const n=await Ut.api.post({path:"/v1/fungible/price",body:{currency:"usd",addresses:t,projectId:$.state.projectId},headers:{"Content-Type":"application/json"}});return F.updateTokenPriceCache({addresses:t,timestamp:Date.now(),tokenPrice:n}),n},async fetchSwapAllowance({tokenAddress:t,userAddress:e}){var n;return await fe.isNetworkSupported((n=E.state.activeCaipNetwork)==null?void 0:n.caipNetworkId)?fe.get({path:"/v1/convert/allowance",params:{tokenAddress:t,userAddress:e},headers:{"Content-Type":"application/json"}}):{allowance:"0"}},async fetchGasPrice({chainId:t}){var r;const{st:e,sv:s}=fe.getSdkProperties();if(!await fe.isNetworkSupported((r=E.state.activeCaipNetwork)==null?void 0:r.caipNetworkId))throw new Error("Network not supported for Gas Price");return fe.get({path:"/v1/convert/gas-price",headers:{"Content-Type":"application/json"},params:{chainId:t,st:e,sv:s}})},async generateSwapCalldata({amount:t,from:e,to:s,userAddress:n,disableEstimate:r}){var o;if(!await fe.isNetworkSupported((o=E.state.activeCaipNetwork)==null?void 0:o.caipNetworkId))throw new Error("Network not supported for Swaps");return Ut.api.post({path:"/v1/convert/build-transaction",headers:{"Content-Type":"application/json"},body:{amount:t,eip155:{slippage:Ne.CONVERT_SLIPPAGE_TOLERANCE},projectId:$.state.projectId,from:e,to:s,userAddress:n,disableEstimate:r}})},async generateApproveCalldata({from:t,to:e,userAddress:s}){var o;const{st:n,sv:r}=fe.getSdkProperties();if(!await fe.isNetworkSupported((o=E.state.activeCaipNetwork)==null?void 0:o.caipNetworkId))throw new Error("Network not supported for Swaps");return fe.get({path:"/v1/convert/build-approve",headers:{"Content-Type":"application/json"},params:{userAddress:s,from:t,to:e,st:n,sv:r}})},async getBalance(t,e,s){var l;const{st:n,sv:r}=fe.getSdkProperties();if(!await fe.isNetworkSupported((l=E.state.activeCaipNetwork)==null?void 0:l.caipNetworkId))return zs.showError("Token Balance Unavailable"),{balances:[]};const o=`${e}:${t}`,a=F.getBalanceCacheForCaipAddress(o);if(a)return a;const c=await fe.get({path:`/v1/account/${t}/balance`,params:{currency:"usd",chainId:e,forceUpdate:s,st:n,sv:r}});return F.updateBalanceCache({caipAddress:o,balance:c,timestamp:Date.now()}),c},async lookupEnsName(t){var s;return await fe.isNetworkSupported((s=E.state.activeCaipNetwork)==null?void 0:s.caipNetworkId)?fe.get({path:`/v1/profile/account/${t}`,params:{apiVersion:"2"}}):{addresses:{},attributes:[]}},async reverseLookupEnsName({address:t}){var n,r;if(!await fe.isNetworkSupported((n=E.state.activeCaipNetwork)==null?void 0:n.caipNetworkId))return[];const s=(r=E.getAccountData())==null?void 0:r.address;return fe.get({path:`/v1/profile/reverse/${t}`,params:{sender:s,apiVersion:"2"}})},async getEnsNameSuggestions(t){var s;return await fe.isNetworkSupported((s=E.state.activeCaipNetwork)==null?void 0:s.caipNetworkId)?fe.get({path:`/v1/profile/suggestions/${t}`,params:{zone:"reown.id"}}):{suggestions:[]}},async registerEnsName({coinType:t,address:e,message:s,signature:n}){var i;return await fe.isNetworkSupported((i=E.state.activeCaipNetwork)==null?void 0:i.caipNetworkId)?Ut.api.post({path:"/v1/profile/account",body:{coin_type:t,address:e,message:s,signature:n},headers:{"Content-Type":"application/json"}}):{success:!1}},async generateOnRampURL({destinationWallets:t,partnerUserId:e,defaultNetwork:s,purchaseAmount:n,paymentAmount:r}){var a;return await fe.isNetworkSupported((a=E.state.activeCaipNetwork)==null?void 0:a.caipNetworkId)?(await Ut.api.post({path:"/v1/generators/onrampurl",params:{projectId:$.state.projectId},body:{destinationWallets:t,defaultNetwork:s,partnerUserId:e,defaultExperience:"buy",presetCryptoAmount:n,presetFiatAmount:r}})).url:""},async getOnrampOptions(){var e;if(!await fe.isNetworkSupported((e=E.state.activeCaipNetwork)==null?void 0:e.caipNetworkId))return{paymentCurrencies:[],purchaseCurrencies:[]};try{return await fe.get({path:"/v1/onramp/options"})}catch{return Cv}},async getOnrampQuote({purchaseCurrency:t,paymentCurrency:e,amount:s,network:n}){var r;try{return await fe.isNetworkSupported((r=E.state.activeCaipNetwork)==null?void 0:r.caipNetworkId)?await Ut.api.post({path:"/v1/onramp/quote",params:{projectId:$.state.projectId},body:{purchaseCurrency:t,paymentCurrency:e,amount:s,network:n}}):null}catch{return{networkFee:{amount:s,currency:e.id},paymentSubtotal:{amount:s,currency:e.id},paymentTotal:{amount:s,currency:e.id},purchaseAmount:{amount:s,currency:e.id},quoteId:"mocked-quote-id"}}},async getSmartSessions(t){var s;return await fe.isNetworkSupported((s=E.state.activeCaipNetwork)==null?void 0:s.caipNetworkId)?fe.get({path:`/v1/sessions/${t}`}):[]},async revokeSmartSession(t,e,s){var r;return await fe.isNetworkSupported((r=E.state.activeCaipNetwork)==null?void 0:r.caipNetworkId)?Ut.api.post({path:`/v1/sessions/${t}/revoke`,params:{projectId:$.state.projectId},body:{pci:e,signature:s}}):{success:!1}},setClientId(t){Ut.clientId=t,Ut.api=new So({baseUrl:Mf,clientId:t})}},ms={PHANTOM:{id:"a797aa35c0fadbfc1a53e7f675162ed5226968b44a19ee3d24385c64d1d3c393",url:"https://phantom.app"},SOLFLARE:{id:"1ca0bdd4747578705b1939af023d120677c64fe6ca76add81fda36e350605e79",url:"https://solflare.com"},COINBASE:{id:"fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa",url:"https://go.cb-w.com"},BINANCE:{id:"2fafea35bb471d22889ccb49c08d99dd0a18a37982602c33f696a5723934ba25",appId:"yFK5FCqYprrXDiVFbhyRx7",deeplink:"bnc://app.binance.com/mp/app",url:"https://app.binance.com/en/download"}},_v={handleMobileDeeplinkRedirect(t,e){const s=window.location.href,n=encodeURIComponent(s);if(t===ms.PHANTOM.id&&!("phantom"in window)){const r=s.startsWith("https")?"https":"http",i=s.split("/")[2],o=encodeURIComponent(`${r}://${i}`);window.location.href=`${ms.PHANTOM.url}/ul/browse/${n}?ref=${o}`}if(t===ms.SOLFLARE.id&&!("solflare"in window)&&(window.location.href=`${ms.SOLFLARE.url}/ul/v1/browse/${n}?ref=${n}`),e===U.CHAIN.SOLANA&&t===ms.COINBASE.id&&!("coinbaseSolana"in window)&&(window.location.href=`${ms.COINBASE.url}/dapp?cb_url=${n}`),e===U.CHAIN.BITCOIN&&t===ms.BINANCE.id&&!("binancew3w"in window)){const r=E.state.activeCaipNetwork,i=window.btoa("/pages/browser/index"),o=window.btoa(`url=${n}&defaultChainId=${(r==null?void 0:r.id)??1}`),a=new URL(ms.BINANCE.deeplink);a.searchParams.set("appId",ms.BINANCE.appId),a.searchParams.set("startPagePath",i),a.searchParams.set("startPageQuery",o);const c=new URL(ms.BINANCE.url);c.searchParams.set("_dp",window.btoa(a.toString())),window.location.href=c.toString()}}},Av=Object.freeze({enabled:!0,events:[]}),Sv=new So({baseUrl:X.getAnalyticsUrl(),clientId:null}),Iv=5,Nv=60*1e3,Tn=Ge({...Av}),Tv={state:Tn,subscribeKey(t,e){return At(Tn,t,e)},async sendError(t,e){if(!Tn.enabled)return;const s=Date.now();if(Tn.events.filter(i=>{const o=new Date(i.properties.timestamp||"").getTime();return s-o<Nv}).length>=Iv)return;const r={type:"error",event:e,properties:{errorType:t.name,errorMessage:t.message,stackTrace:t.stack,timestamp:new Date().toISOString()}};Tn.events.push(r);try{if(typeof window>"u")return;const{projectId:i,sdkType:o,sdkVersion:a}=$.state;await Sv.post({path:"/e",params:{projectId:i,st:o,sv:a||"html-wagmi-4.2.2"},body:{eventId:X.getUUID(),url:window.location.href,domain:window.location.hostname,timestamp:new Date().toISOString(),props:{type:"error",event:e,errorType:t.name,errorMessage:t.message,stackTrace:t.stack}}})}catch{}},enable(){Tn.enabled=!0},disable(){Tn.enabled=!1},clearEvents(){Tn.events=[]}};class Tr extends Error{constructor(e,s,n){super(e),this.originalName="AppKitError",this.name="AppKitError",this.category=s,this.originalError=n,n&&n instanceof Error&&(this.originalName=n.name),Object.setPrototypeOf(this,Tr.prototype);let r=!1;if(n instanceof Error&&typeof n.stack=="string"&&n.stack){const i=n.stack,o=i.indexOf(`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-B2Nwx2Pb.js","assets/verifyHash-B6UCi3Fq.js","assets/NetworkUtil-BB0TxE9p.js","assets/thirdweb-BXzAJI2R.js","assets/ccip-xyxXL3L7.js","assets/index-BmAbXTYm.js","assets/ui-BZVBOcI0.js","assets/vendor-BpyywBCn.js","assets/ui-DRBd2XZm.css","assets/index-C5Yg70-2.css","assets/features-BqOwC9OI.js","assets/embedded-wallet-2rN-oS7N.js","assets/index-8h8RbWPq.js","assets/index-Bmd-CE-d.js","assets/if-defined-DIjTqkPc.js","assets/ref-BywtPZ1y.js","assets/index-BYUpM_QI.js","assets/HelpersUtil-DjLIrIEy.js","assets/ConstantsUtil-B1B0nR9C.js","assets/index-osg4Koy_.js","assets/index-Dt8v3lSJ.js","assets/index-DHjdohiW.js","assets/index-C5bmKCwO.js","assets/index-BLZTaqiE.js","assets/NavigationUtil-DmfK5sOV.js","assets/email-BGLr_-QZ.js","assets/index-rwQnv0hR.js","assets/index-D4P1pgAl.js","assets/socials-BgGTTjbV.js","assets/index-DxlMu3ea.js","assets/index-Dta7LIvX.js","assets/index-4uk83_lk.js","assets/index-DwCXEnCZ.js","assets/index-DGtrKwWB.js","assets/swaps-B7bIgKjW.js","assets/index-Bp6eeWYt.js","assets/index-EkVhGa1o.js","assets/SwapController-B1Yvx6c2.js","assets/index-Bd2WIJU8.js","assets/send-DmpGLDx_.js","assets/index-LAjLiS-K.js","assets/index-B07jRA_S.js","assets/index-BLuyk03X.js","assets/index-TIhhvvUp.js","assets/receive-dmziTgvF.js","assets/onramp-DmW6Wpg-.js","assets/index-CFRccWRu.js","assets/index-BMPF0E7Y.js","assets/index-BESy9fbZ.js","assets/pay-with-exchange-C3dE_Jy4.js","assets/ExchangeController-CC-WA7h6.js","assets/transactions-oExukfM1.js","assets/index-Wk9ccokW.js","assets/index-DkatlhKa.js","assets/index-GHgycunK.js","assets/index-BsNLqnCG.js","assets/index-DhuV0cPI.js","assets/data-capture-FB6me-7p.js","assets/index-g5szi6r5.js","assets/index-Bsn7-UVq.js","assets/w3m-modal-DLtaVZGd.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{p as wn,g as uy,_ as Dt,an as hy}from"./thirdweb-BXzAJI2R.js";import{C as U,L as py,a5 as Do,m as fy,s as ca,H as Mi,B as ff,ag as gy,ak as la,W as Xd,X as Qd,Y as eu,af as tu,_ as su,ah as nu,ai as ru,ac as iu,Z as ou,a7 as au,aj as cu,ae as lu,a2 as du,a3 as fl,ad as gl,aa as uu,a9 as hu,I as pu,$ as ml,a0 as fu,a4 as gu,a1 as mu,a6 as yu,V as wu,E as my,aA as yy,R as wy,aC as gf,aq as mf,p as Lo,aD as yf,at as Ey,av as by,aw as vy,ax as Cy,ay as _y,as as Ay,t as Eu}from"./NetworkUtil-BB0TxE9p.js";import{m as Sy,s as Gi,n as Mo,o as va,p as Iy,q as Ny,u as Ty,v as Ry,w as Oy,x as bu,I as fi,y as Py,z as Cs,A as Qt,B as Z,D as _n,E as xy,F as ky,G as Bi,J as yl,K as gi,L as Uy,M as $y,N as Dy,O as xr,P as Ly,Q as Hs,R as mi,S as md,T as My,U as yd,V as wd,W as Yi,X as Ed,Y as vu,Z as By,_ as jy,$ as pr,a0 as wf,a1 as an,a2 as Ws,a3 as In,a4 as Ef}from"./index-BmAbXTYm.js";import{B as Pe,g as Ce}from"./ui-BZVBOcI0.js";const bf={isLowerCaseMatch(t,e){return(t==null?void 0:t.toLowerCase())===(e==null?void 0:e.toLowerCase())}};var Fy=20,qy=1,Ar=1e6,Cu=1e6,Wy=-7,Hy=21,Vy=!1,Co="[big.js] ",kr=Co+"Invalid ",Ja=kr+"decimal places",zy=kr+"rounding mode",vf=Co+"Division by zero",qe={},Ys=void 0,Ky=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function Cf(){function t(e){var s=this;if(!(s instanceof t))return e===Ys?Cf():new t(e);if(e instanceof t)s.s=e.s,s.e=e.e,s.c=e.c.slice();else{if(typeof e!="string"){if(t.strict===!0&&typeof e!="bigint")throw TypeError(kr+"value");e=e===0&&1/e<0?"-0":String(e)}Gy(s,e)}s.constructor=t}return t.prototype=qe,t.DP=Fy,t.RM=qy,t.NE=Wy,t.PE=Hy,t.strict=Vy,t.roundDown=0,t.roundHalfUp=1,t.roundHalfEven=2,t.roundUp=3,t}function Gy(t,e){var s,n,r;if(!Ky.test(e))throw Error(kr+"number");for(t.s=e.charAt(0)=="-"?(e=e.slice(1),-1):1,(s=e.indexOf("."))>-1&&(e=e.replace(".","")),(n=e.search(/e/i))>0?(s<0&&(s=n),s+=+e.slice(n+1),e=e.substring(0,n)):s<0&&(s=e.length),r=e.length,n=0;n<r&&e.charAt(n)=="0";)++n;if(n==r)t.c=[t.e=0];else{for(;r>0&&e.charAt(--r)=="0";);for(t.e=s-n-1,t.c=[],s=0;n<=r;)t.c[s++]=+e.charAt(n++)}return t}function Ur(t,e,s,n){var r=t.c;if(s===Ys&&(s=t.constructor.RM),s!==0&&s!==1&&s!==2&&s!==3)throw Error(zy);if(e<1)n=s===3&&(n||!!r[0])||e===0&&(s===1&&r[0]>=5||s===2&&(r[0]>5||r[0]===5&&(n||r[1]!==Ys))),r.length=1,n?(t.e=t.e-e+1,r[0]=1):r[0]=t.e=0;else if(e<r.length){if(n=s===1&&r[e]>=5||s===2&&(r[e]>5||r[e]===5&&(n||r[e+1]!==Ys||r[e-1]&1))||s===3&&(n||!!r[0]),r.length=e,n){for(;++r[--e]>9;)if(r[e]=0,e===0){++t.e,r.unshift(1);break}}for(e=r.length;!r[--e];)r.pop()}return t}function $r(t,e,s){var n=t.e,r=t.c.join(""),i=r.length;if(e)r=r.charAt(0)+(i>1?"."+r.slice(1):"")+(n<0?"e":"e+")+n;else if(n<0){for(;++n;)r="0"+r;r="0."+r}else if(n>0)if(++n>i)for(n-=i;n--;)r+="0";else n<i&&(r=r.slice(0,n)+"."+r.slice(n));else i>1&&(r=r.charAt(0)+"."+r.slice(1));return t.s<0&&s?"-"+r:r}qe.abs=function(){var t=new this.constructor(this);return t.s=1,t};qe.cmp=function(t){var e,s=this,n=s.c,r=(t=new s.constructor(t)).c,i=s.s,o=t.s,a=s.e,c=t.e;if(!n[0]||!r[0])return n[0]?i:r[0]?-o:0;if(i!=o)return i;if(e=i<0,a!=c)return a>c^e?1:-1;for(o=(a=n.length)<(c=r.length)?a:c,i=-1;++i<o;)if(n[i]!=r[i])return n[i]>r[i]^e?1:-1;return a==c?0:a>c^e?1:-1};qe.div=function(t){var e=this,s=e.constructor,n=e.c,r=(t=new s(t)).c,i=e.s==t.s?1:-1,o=s.DP;if(o!==~~o||o<0||o>Ar)throw Error(Ja);if(!r[0])throw Error(vf);if(!n[0])return t.s=i,t.c=[t.e=0],t;var a,c,l,d,u,h=r.slice(),p=a=r.length,g=n.length,f=n.slice(0,a),w=f.length,v=t,N=v.c=[],A=0,_=o+(v.e=e.e-t.e)+1;for(v.s=i,i=_<0?0:_,h.unshift(0);w++<a;)f.push(0);do{for(l=0;l<10;l++){if(a!=(w=f.length))d=a>w?1:-1;else for(u=-1,d=0;++u<a;)if(r[u]!=f[u]){d=r[u]>f[u]?1:-1;break}if(d<0){for(c=w==a?r:h;w;){if(f[--w]<c[w]){for(u=w;u&&!f[--u];)f[u]=9;--f[u],f[w]+=10}f[w]-=c[w]}for(;!f[0];)f.shift()}else break}N[A++]=d?l:++l,f[0]&&d?f[w]=n[p]||0:f=[n[p]]}while((p++<g||f[0]!==Ys)&&i--);return!N[0]&&A!=1&&(N.shift(),v.e--,_--),A>_&&Ur(v,_,s.RM,f[0]!==Ys),v};qe.eq=function(t){return this.cmp(t)===0};qe.gt=function(t){return this.cmp(t)>0};qe.gte=function(t){return this.cmp(t)>-1};qe.lt=function(t){return this.cmp(t)<0};qe.lte=function(t){return this.cmp(t)<1};qe.minus=qe.sub=function(t){var e,s,n,r,i=this,o=i.constructor,a=i.s,c=(t=new o(t)).s;if(a!=c)return t.s=-c,i.plus(t);var l=i.c.slice(),d=i.e,u=t.c,h=t.e;if(!l[0]||!u[0])return u[0]?t.s=-c:l[0]?t=new o(i):t.s=1,t;if(a=d-h){for((r=a<0)?(a=-a,n=l):(h=d,n=u),n.reverse(),c=a;c--;)n.push(0);n.reverse()}else for(s=((r=l.length<u.length)?l:u).length,a=c=0;c<s;c++)if(l[c]!=u[c]){r=l[c]<u[c];break}if(r&&(n=l,l=u,u=n,t.s=-t.s),(c=(s=u.length)-(e=l.length))>0)for(;c--;)l[e++]=0;for(c=e;s>a;){if(l[--s]<u[s]){for(e=s;e&&!l[--e];)l[e]=9;--l[e],l[s]+=10}l[s]-=u[s]}for(;l[--c]===0;)l.pop();for(;l[0]===0;)l.shift(),--h;return l[0]||(t.s=1,l=[h=0]),t.c=l,t.e=h,t};qe.mod=function(t){var e,s=this,n=s.constructor,r=s.s,i=(t=new n(t)).s;if(!t.c[0])throw Error(vf);return s.s=t.s=1,e=t.cmp(s)==1,s.s=r,t.s=i,e?new n(s):(r=n.DP,i=n.RM,n.DP=n.RM=0,s=s.div(t),n.DP=r,n.RM=i,this.minus(s.times(t)))};qe.neg=function(){var t=new this.constructor(this);return t.s=-t.s,t};qe.plus=qe.add=function(t){var e,s,n,r=this,i=r.constructor;if(t=new i(t),r.s!=t.s)return t.s=-t.s,r.minus(t);var o=r.e,a=r.c,c=t.e,l=t.c;if(!a[0]||!l[0])return l[0]||(a[0]?t=new i(r):t.s=r.s),t;if(a=a.slice(),e=o-c){for(e>0?(c=o,n=l):(e=-e,n=a),n.reverse();e--;)n.push(0);n.reverse()}for(a.length-l.length<0&&(n=l,l=a,a=n),e=l.length,s=0;e;a[e]%=10)s=(a[--e]=a[e]+l[e]+s)/10|0;for(s&&(a.unshift(s),++c),e=a.length;a[--e]===0;)a.pop();return t.c=a,t.e=c,t};qe.pow=function(t){var e=this,s=new e.constructor("1"),n=s,r=t<0;if(t!==~~t||t<-Cu||t>Cu)throw Error(kr+"exponent");for(r&&(t=-t);t&1&&(n=n.times(e)),t>>=1,!!t;)e=e.times(e);return r?s.div(n):n};qe.prec=function(t,e){if(t!==~~t||t<1||t>Ar)throw Error(kr+"precision");return Ur(new this.constructor(this),t,e)};qe.round=function(t,e){if(t===Ys)t=0;else if(t!==~~t||t<-Ar||t>Ar)throw Error(Ja);return Ur(new this.constructor(this),t+this.e+1,e)};qe.sqrt=function(){var t,e,s,n=this,r=n.constructor,i=n.s,o=n.e,a=new r("0.5");if(!n.c[0])return new r(n);if(i<0)throw Error(Co+"No square root");i=Math.sqrt(+$r(n,!0,!0)),i===0||i===1/0?(e=n.c.join(""),e.length+o&1||(e+="0"),i=Math.sqrt(e),o=((o+1)/2|0)-(o<0||o&1),t=new r((i==1/0?"5e":(i=i.toExponential()).slice(0,i.indexOf("e")+1))+o)):t=new r(i+""),o=t.e+(r.DP+=4);do s=t,t=a.times(s.plus(n.div(s)));while(s.c.slice(0,o).join("")!==t.c.slice(0,o).join(""));return Ur(t,(r.DP-=4)+t.e+1,r.RM)};qe.times=qe.mul=function(t){var e,s=this,n=s.constructor,r=s.c,i=(t=new n(t)).c,o=r.length,a=i.length,c=s.e,l=t.e;if(t.s=s.s==t.s?1:-1,!r[0]||!i[0])return t.c=[t.e=0],t;for(t.e=c+l,o<a&&(e=r,r=i,i=e,l=o,o=a,a=l),e=new Array(l=o+a);l--;)e[l]=0;for(c=a;c--;){for(a=0,l=o+c;l>c;)a=e[l]+i[c]*r[l-c-1]+a,e[l--]=a%10,a=a/10|0;e[l]=a}for(a?++t.e:e.shift(),c=e.length;!e[--c];)e.pop();return t.c=e,t};qe.toExponential=function(t,e){var s=this,n=s.c[0];if(t!==Ys){if(t!==~~t||t<0||t>Ar)throw Error(Ja);for(s=Ur(new s.constructor(s),++t,e);s.c.length<t;)s.c.push(0)}return $r(s,!0,!!n)};qe.toFixed=function(t,e){var s=this,n=s.c[0];if(t!==Ys){if(t!==~~t||t<0||t>Ar)throw Error(Ja);for(s=Ur(new s.constructor(s),t+s.e+1,e),t=t+s.e+1;s.c.length<t;)s.c.push(0)}return $r(s,!1,!!n)};qe[Symbol.for("nodejs.util.inspect.custom")]=qe.toJSON=qe.toString=function(){var t=this,e=t.constructor;return $r(t,t.e<=e.NE||t.e>=e.PE,!!t.c[0])};qe.toNumber=function(){var t=+$r(this,!0,!0);if(this.constructor.strict===!0&&!this.eq(t.toString()))throw Error(Co+"Imprecise conversion");return t};qe.toPrecision=function(t,e){var s=this,n=s.constructor,r=s.c[0];if(t!==Ys){if(t!==~~t||t<1||t>Ar)throw Error(kr+"precision");for(s=Ur(new n(s),t,e);s.c.length<t;)s.c.push(0)}return $r(s,t<=s.e||s.e<=n.NE||s.e>=n.PE,!!r)};qe.valueOf=function(){var t=this,e=t.constructor;if(e.strict===!0)throw Error(Co+"valueOf disallowed");return $r(t,t.e<=e.NE||t.e>=e.PE,!0)};var Nn=Cf();const Yy={bigNumber(t){return t?new Nn(t):new Nn(0)},multiply(t,e){if(t===void 0||e===void 0)return new Nn(0);const s=new Nn(t),n=new Nn(e);return s.times(n)},toFixed(t,e=2){return t===void 0||t===""?new Nn(0).toFixed(e):new Nn(t).toFixed(e)},formatNumberToLocalString(t,e=2){return t===void 0||t===""?"0.00":typeof t=="number"?t.toLocaleString("en-US",{maximumFractionDigits:e,minimumFractionDigits:e,roundingMode:"floor"}):parseFloat(t).toLocaleString("en-US",{maximumFractionDigits:e,minimumFractionDigits:e,roundingMode:"floor"})},parseLocalStringToNumber(t){if(t===void 0||t==="")return 0;const e=t.replace(/,/gu,"");return new Nn(e).toNumber()}},Zy=[{type:"function",name:"transfer",stateMutability:"nonpayable",inputs:[{name:"_to",type:"address"},{name:"_value",type:"uint256"}],outputs:[{name:"",type:"bool"}]},{type:"function",name:"transferFrom",stateMutability:"nonpayable",inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_value",type:"uint256"}],outputs:[{name:"",type:"bool"}]}],Jy=[{type:"function",name:"approve",stateMutability:"nonpayable",inputs:[{name:"spender",type:"address"},{name:"amount",type:"uint256"}],outputs:[{type:"bool"}]}],Xy=[{type:"function",name:"transfer",stateMutability:"nonpayable",inputs:[{name:"recipient",type:"address"},{name:"amount",type:"uint256"}],outputs:[]},{type:"function",name:"transferFrom",stateMutability:"nonpayable",inputs:[{name:"sender",type:"address"},{name:"recipient",type:"address"},{name:"amount",type:"uint256"}],outputs:[{name:"",type:"bool"}]}],Qy={getERC20Abi:t=>U.USDT_CONTRACT_ADDRESSES.includes(t)?Xy:Zy,getSwapAbi:()=>Jy},Mr={ConnectorExplorerIds:{[U.CONNECTOR_ID.COINBASE]:"fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa",[U.CONNECTOR_ID.COINBASE_SDK]:"fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa",[U.CONNECTOR_ID.BASE_ACCOUNT]:"fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa",[U.CONNECTOR_ID.SAFE]:"225affb176778569276e484e1b92637ad061b01e13a048b35a9d280c3b58970f",[U.CONNECTOR_ID.LEDGER]:"19177a98252e07ddfc9af2083ba8e07ef627cb6103467ffebb3f8f4205fd7927",[U.CONNECTOR_ID.OKX]:"971e689d0a5be527bac79629b4ee9b925e82208e5168b733496a09c0faed0709",[U.METMASK_CONNECTOR_NAME]:"c57ca95b47569778a828d19178114f4db188b89b763c899ba0be274e97267d96",[U.TRUST_CONNECTOR_NAME]:"4622a2b2d6af1c9844944291e5e7351a6aa24cd7b23099efac1b2fd875da31a0",[U.SOLFLARE_CONNECTOR_NAME]:"1ca0bdd4747578705b1939af023d120677c64fe6ca76add81fda36e350605e79",[U.PHANTOM_CONNECTOR_NAME]:"a797aa35c0fadbfc1a53e7f675162ed5226968b44a19ee3d24385c64d1d3c393",[U.COIN98_CONNECTOR_NAME]:"2a3c89040ac3b723a1972a33a125b1db11e258a6975d3a61252cd64e6ea5ea01",[U.MAGIC_EDEN_CONNECTOR_NAME]:"8b830a2b724a9c3fbab63af6f55ed29c9dfa8a55e732dc88c80a196a2ba136c6",[U.BACKPACK_CONNECTOR_NAME]:"2bd8c14e035c2d48f184aaa168559e86b0e3433228d3c4075900a221785019b0",[U.BITGET_CONNECTOR_NAME]:"38f5d18bd8522c244bdd70cb4a68e0e718865155811c043f052fb9f1c51de662",[U.FRONTIER_CONNECTOR_NAME]:"85db431492aa2e8672e93f4ea7acf10c88b97b867b0d373107af63dc4880f041",[U.XVERSE_CONNECTOR_NAME]:"2a87d74ae02e10bdd1f51f7ce6c4e1cc53cd5f2c0b6b5ad0d7b3007d2b13de7b",[U.LEATHER_CONNECTOR_NAME]:"483afe1df1df63daf313109971ff3ef8356ddf1cc4e45877d205eee0b7893a13",[U.OKX_CONNECTOR_NAME]:"971e689d0a5be527bac79629b4ee9b925e82208e5168b733496a09c0faed0709",[U.BINANCE_CONNECTOR_NAME]:"2fafea35bb471d22889ccb49c08d99dd0a18a37982602c33f696a5723934ba25"}},dt={validateCaipAddress(t){var e;if(((e=t.split(":"))==null?void 0:e.length)!==3)throw new Error("Invalid CAIP Address");return t},parseCaipAddress(t){const e=t.split(":");if(e.length!==3)throw new Error(`Invalid CAIP-10 address: ${t}`);const[s,n,r]=e;if(!s||!n||!r)throw new Error(`Invalid CAIP-10 address: ${t}`);return{chainNamespace:s,chainId:n,address:r}},parseCaipNetworkId(t){const e=t.split(":");if(e.length!==2)throw new Error(`Invalid CAIP-2 network id: ${t}`);const[s,n]=e;if(!s||!n)throw new Error(`Invalid CAIP-2 network id: ${t}`);return{chainNamespace:s,chainId:n}}},gn={RPC_ERROR_CODE:{USER_REJECTED_REQUEST:4001,USER_REJECTED_METHODS:5002,USER_REJECTED:5e3},PROVIDER_RPC_ERROR_NAME:{PROVIDER_RPC:"ProviderRpcError",USER_REJECTED_REQUEST:"UserRejectedRequestError"},isRpcProviderError(t){try{if(typeof t=="object"&&t!==null){const e=t,s=typeof e.message=="string",n=typeof e.code=="number";return s&&n}return!1}catch{return!1}},isUserRejectedMessage(t){return t.toLowerCase().includes("user rejected")||t.toLowerCase().includes("user cancelled")||t.toLowerCase().includes("user canceled")},isUserRejectedRequestError(t){if(gn.isRpcProviderError(t)){const e=t.code===gn.RPC_ERROR_CODE.USER_REJECTED_REQUEST,s=t.code===gn.RPC_ERROR_CODE.USER_REJECTED_METHODS;return e||s||gn.isUserRejectedMessage(t.message)}return t instanceof Error?gn.isUserRejectedMessage(t.message):!1}};class ew extends Error{constructor(e,s){super(s.message,{cause:e}),this.name=gn.PROVIDER_RPC_ERROR_NAME.PROVIDER_RPC,this.code=s.code}}class _f extends ew{constructor(e){super(e,{code:gn.RPC_ERROR_CODE.USER_REJECTED_REQUEST,message:"User rejected the request"}),this.name=gn.PROVIDER_RPC_ERROR_NAME.USER_REJECTED_REQUEST}}const le={WALLET_ID:"@appkit/wallet_id",WALLET_NAME:"@appkit/wallet_name",SOLANA_WALLET:"@appkit/solana_wallet",SOLANA_CAIP_CHAIN:"@appkit/solana_caip_chain",ACTIVE_CAIP_NETWORK_ID:"@appkit/active_caip_network_id",CONNECTED_SOCIAL:"@appkit/connected_social",CONNECTED_SOCIAL_USERNAME:"@appkit-wallet/SOCIAL_USERNAME",RECENT_WALLETS:"@appkit/recent_wallets",RECENT_WALLET:"@appkit/recent_wallet",DEEPLINK_CHOICE:"WALLETCONNECT_DEEPLINK_CHOICE",ACTIVE_NAMESPACE:"@appkit/active_namespace",CONNECTED_NAMESPACES:"@appkit/connected_namespaces",CONNECTION_STATUS:"@appkit/connection_status",SIWX_AUTH_TOKEN:"@appkit/siwx-auth-token",SIWX_NONCE_TOKEN:"@appkit/siwx-nonce-token",TELEGRAM_SOCIAL_PROVIDER:"@appkit/social_provider",NATIVE_BALANCE_CACHE:"@appkit/native_balance_cache",PORTFOLIO_CACHE:"@appkit/portfolio_cache",ENS_CACHE:"@appkit/ens_cache",IDENTITY_CACHE:"@appkit/identity_cache",PREFERRED_ACCOUNT_TYPES:"@appkit/preferred_account_types",CONNECTIONS:"@appkit/connections",DISCONNECTED_CONNECTOR_IDS:"@appkit/disconnected_connector_ids",HISTORY_TRANSACTIONS_CACHE:"@appkit/history_transactions_cache",TOKEN_PRICE_CACHE:"@appkit/token_price_cache",RECENT_EMAILS:"@appkit/recent_emails",LATEST_APPKIT_VERSION:"@appkit/latest_version",TON_WALLETS_CACHE:"@appkit/ton_wallets_cache"};function yc(t){if(!t)throw new Error("Namespace is required for CONNECTED_CONNECTOR_ID");return`@appkit/${t}:connected_connector_id`}const ae={setItem(t,e){xi()&&e!==void 0&&localStorage.setItem(t,e)},getItem(t){if(xi())return localStorage.getItem(t)||void 0},removeItem(t){xi()&&localStorage.removeItem(t)},clear(){xi()&&localStorage.clear()}};function xi(){return typeof window<"u"&&typeof localStorage<"u"}function Zi(t,e){const s=(t==null?void 0:t["--apkt-accent"])??(t==null?void 0:t["--w3m-accent"]);return e==="light"?{"--w3m-accent":s||"hsla(231, 100%, 70%, 1)","--w3m-background":"#fff"}:{"--w3m-accent":s||"hsla(230, 100%, 67%, 1)","--w3m-background":"#202020"}}const tw=Symbol(),_u=Object.getPrototypeOf,wl=new WeakMap,sw=t=>t&&(wl.has(t)?wl.get(t):_u(t)===Object.prototype||_u(t)===Array.prototype),nw=t=>sw(t)&&t[tw]||null,Au=(t,e=!0)=>{wl.set(t,e)},Ca={},bd=t=>typeof t=="object"&&t!==null,rw=t=>bd(t)&&!_o.has(t)&&(Array.isArray(t)||!(Symbol.iterator in t))&&!(t instanceof WeakMap)&&!(t instanceof WeakSet)&&!(t instanceof Error)&&!(t instanceof Number)&&!(t instanceof Date)&&!(t instanceof String)&&!(t instanceof RegExp)&&!(t instanceof ArrayBuffer)&&!(t instanceof Promise),Af=(t,e)=>{const s=El.get(t);if((s==null?void 0:s[0])===e)return s[1];const n=Array.isArray(t)?[]:Object.create(Object.getPrototypeOf(t));return Au(n,!0),El.set(t,[e,n]),Reflect.ownKeys(t).forEach(r=>{if(Object.getOwnPropertyDescriptor(n,r))return;const i=Reflect.get(t,r),{enumerable:o}=Reflect.getOwnPropertyDescriptor(t,r),a={value:i,enumerable:o,configurable:!0};if(_o.has(i))Au(i,!1);else if(Gn.has(i)){const[c,l]=Gn.get(i);a.value=Af(c,l())}Object.defineProperty(n,r,a)}),Object.preventExtensions(n)},iw=(t,e,s,n)=>({deleteProperty(r,i){const o=Reflect.get(r,i);s(i);const a=Reflect.deleteProperty(r,i);return a&&n(["delete",[i],o]),a},set(r,i,o,a){const c=!t()&&Reflect.has(r,i),l=Reflect.get(r,i,a);if(c&&(Su(l,o)||Ji.has(o)&&Su(l,Ji.get(o))))return!0;s(i),bd(o)&&(o=nw(o)||o);const d=!Gn.has(o)&&aw(o)?Ge(o):o;return e(i,d),Reflect.set(r,i,d,a),n(["set",[i],o,l]),!0}}),Gn=new WeakMap,_o=new WeakSet,El=new WeakMap,da=[1],Ji=new WeakMap;let Su=Object.is,ow=(t,e)=>new Proxy(t,e),aw=rw,cw=Af,lw=iw;function Ge(t={}){if(!bd(t))throw new Error("object required");const e=Ji.get(t);if(e)return e;let s=da[0];const n=new Set,r=(w,v=++da[0])=>{s!==v&&(i=s=v,n.forEach(N=>N(w,v)))};let i=s;const o=(w=da[0])=>(i!==w&&(i=w,c.forEach(([v])=>{const N=v[1](w);N>s&&(s=N)})),s),a=w=>(v,N)=>{const A=[...v];A[1]=[w,...A[1]],r(A,N)},c=new Map,l=(w,v)=>{const N=!_o.has(v)&&Gn.get(v);if(N){if((Ca?"production":void 0)!=="production"&&c.has(w))throw new Error("prop listener already exists");if(n.size){const A=N[2](a(w));c.set(w,[N,A])}else c.set(w,[N])}},d=w=>{var v;const N=c.get(w);N&&(c.delete(w),(v=N[1])==null||v.call(N))},u=w=>(n.add(w),n.size===1&&c.forEach(([N,A],_)=>{if((Ca?"production":void 0)!=="production"&&A)throw new Error("remove already exists");const P=N[2](a(_));c.set(_,[N,P])}),()=>{n.delete(w),n.size===0&&c.forEach(([N,A],_)=>{A&&(A(),c.set(_,[N]))})});let h=!0;const p=lw(()=>h,l,d,r),g=ow(t,p);Ji.set(t,g);const f=[t,o,u];return Gn.set(g,f),Reflect.ownKeys(t).forEach(w=>{const v=Object.getOwnPropertyDescriptor(t,w);"value"in v&&v.writable&&(g[w]=t[w])}),h=!1,g}function _t(t,e,s){const n=Gn.get(t);(Ca?"production":void 0)!=="production"&&!n&&console.warn("Please use proxy object");let r;const i=[],o=n[2];let a=!1;const l=o(d=>{i.push(d),r||(r=Promise.resolve().then(()=>{r=void 0,a&&e(i.splice(0))}))});return a=!0,()=>{a=!1,l()}}function Xi(t){const e=Gn.get(t);(Ca?"production":void 0)!=="production"&&!e&&console.warn("Please use proxy object");const[s,n]=e;return cw(s,n())}function Qi(t){return _o.add(t),t}function dw(){return{proxyStateMap:Gn,refSet:_o,snapCache:El,versionHolder:da,proxyCache:Ji}}function At(t,e,s,n){let r=t[e];return _t(t,()=>{const i=t[e];Object.is(r,i)||s(r=i)})}const{proxyStateMap:uw,snapCache:hw}=dw(),Bo=t=>uw.has(t);function pw(t){const e=[];let s=0;const n=new Map,r=new WeakMap,i=()=>{const l=hw.get(a),d=l==null?void 0:l[1];if(d&&!r.has(d)){const u=new Map(n);r.set(d,u)}},o=l=>r.get(l)||n,a={data:e,index:s,epoch:0,get size(){return Bo(this)||i(),o(this).size},get(l){const u=o(this).get(l);if(u===void 0){this.epoch;return}return this.data[u]},has(l){const d=o(this);return this.epoch,d.has(l)},set(l,d){if(!Bo(this))throw new Error("Cannot perform mutations on a snapshot");const u=n.get(l);return u===void 0?(n.set(l,this.index),this.data[this.index++]=d):this.data[u]=d,this.epoch++,this},delete(l){if(!Bo(this))throw new Error("Cannot perform mutations on a snapshot");const d=n.get(l);return d===void 0?!1:(delete this.data[d],n.delete(l),this.epoch++,!0)},clear(){if(!Bo(this))throw new Error("Cannot perform mutations on a snapshot");this.data.length=0,this.index=0,this.epoch++,n.clear()},forEach(l){this.epoch,o(this).forEach((u,h)=>{l(this.data[u],h,this)})},*entries(){this.epoch;const l=o(this);for(const[d,u]of l)yield[d,this.data[u]]},*keys(){this.epoch;const l=o(this);for(const d of l.keys())yield d},*values(){this.epoch;const l=o(this);for(const d of l.values())yield this.data[d]},[Symbol.iterator](){return this.entries()},get[Symbol.toStringTag](){return"Map"},toJSON(){return new Map(this.entries())}},c=Ge(a);return Object.defineProperties(c,{size:{enumerable:!1},index:{enumerable:!1},epoch:{enumerable:!1},data:{enumerable:!1},toJSON:{enumerable:!1}}),Object.seal(c),c}var Iu={};const wc=(typeof wn<"u"&&typeof Iu<"u"?Iu.NEXT_PUBLIC_SECURE_SITE_ORIGIN:void 0)||"https://secure.walletconnect.org",Sf=[{label:"Meld.io",name:"meld",feeRange:"1-2%",url:"https://meldcrypto.com",supportedChains:["eip155","solana"]}],fw="WXETMuFUQmqqybHuRkSgxv:25B8LJHSfpG6LVjR2ytU5Cwh7Z4Sch2ocoU",Ne={FOUR_MINUTES_MS:24e4,TEN_SEC_MS:1e4,FIVE_SEC_MS:5e3,THREE_SEC_MS:3e3,ONE_SEC_MS:1e3,SECURE_SITE:wc,SECURE_SITE_DASHBOARD:`${wc}/dashboard`,SECURE_SITE_FAVICON:`${wc}/images/favicon.png`,SOLANA_NATIVE_TOKEN_ADDRESS:"So11111111111111111111111111111111111111111",RESTRICTED_TIMEZONES:["ASIA/SHANGHAI","ASIA/URUMQI","ASIA/CHONGQING","ASIA/HARBIN","ASIA/KASHGAR","ASIA/MACAU","ASIA/HONG_KONG","ASIA/MACAO","ASIA/BEIJING","ASIA/HARBIN"],SWAP_SUGGESTED_TOKENS:["ETH","UNI","1INCH","AAVE","SOL","ADA","AVAX","DOT","LINK","NITRO","GAIA","MILK","TRX","NEAR","GNO","WBTC","DAI","WETH","USDC","USDT","ARB","BAL","BICO","CRV","ENS","MATIC","OP"],SWAP_POPULAR_TOKENS:["ETH","UNI","1INCH","AAVE","SOL","ADA","AVAX","DOT","LINK","NITRO","GAIA","MILK","TRX","NEAR","GNO","WBTC","DAI","WETH","USDC","USDT","ARB","BAL","BICO","CRV","ENS","MATIC","OP","METAL","DAI","CHAMP","WOLF","SALE","BAL","BUSD","MUST","BTCpx","ROUTE","HEX","WELT","amDAI","VSQ","VISION","AURUM","pSP","SNX","VC","LINK","CHP","amUSDT","SPHERE","FOX","GIDDY","GFC","OMEN","OX_OLD","DE","WNT"],SUGGESTED_TOKENS_BY_CHAIN:{"eip155:42161":["USD₮0"]},BALANCE_SUPPORTED_CHAINS:[U.CHAIN.EVM,U.CHAIN.SOLANA],SEND_PARAMS_SUPPORTED_CHAINS:[U.CHAIN.EVM],SWAP_SUPPORTED_NETWORKS:["eip155:1","eip155:42161","eip155:10","eip155:324","eip155:8453","eip155:56","eip155:137","eip155:100","eip155:43114","eip155:250","eip155:8217","eip155:1313161554"],NAMES_SUPPORTED_CHAIN_NAMESPACES:[U.CHAIN.EVM],ONRAMP_SUPPORTED_CHAIN_NAMESPACES:[U.CHAIN.EVM,U.CHAIN.SOLANA],PAY_WITH_EXCHANGE_SUPPORTED_CHAIN_NAMESPACES:[U.CHAIN.EVM,U.CHAIN.SOLANA],ACTIVITY_ENABLED_CHAIN_NAMESPACES:[U.CHAIN.EVM,U.CHAIN.TON],NATIVE_TOKEN_ADDRESS:{eip155:"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",solana:"So11111111111111111111111111111111111111111",polkadot:"0x",bip122:"0x",cosmos:"0x",sui:"0x",stacks:"0x",ton:"0x"},CONVERT_SLIPPAGE_TOLERANCE:1,CONNECT_LABELS:{MOBILE:"Open and continue in the wallet app",WEB:"Open and continue in the wallet app"},SEND_SUPPORTED_NAMESPACES:[U.CHAIN.EVM,U.CHAIN.SOLANA],DEFAULT_REMOTE_FEATURES:{swaps:["1inch"],onramp:["meld"],email:!0,socials:["google","x","discord","farcaster","github","apple","facebook"],activity:!0,reownBranding:!0,multiWallet:!1,emailCapture:!1,payWithExchange:!1,payments:!1,reownAuthentication:!1,headless:!1},DEFAULT_REMOTE_FEATURES_DISABLED:{email:!1,socials:!1,swaps:!1,onramp:!1,activity:!1,reownBranding:!1,emailCapture:!1,reownAuthentication:!1,headless:!1},DEFAULT_FEATURES:{receive:!0,send:!0,emailShowWallets:!0,connectorTypeOrder:["walletConnect","recent","injected","featured","custom","external","recommended"],analytics:!0,allWallets:!0,legalCheckbox:!1,smartSessions:!1,collapseWallets:!1,walletFeaturesOrder:["onramp","swaps","receive","send"],connectMethodsOrder:void 0,pay:!1,reownAuthentication:!1,headless:!1},DEFAULT_SOCIALS:["google","x","farcaster","discord","apple","github","facebook"],DEFAULT_ACCOUNT_TYPES:{bip122:"payment",eip155:"smartAccount",polkadot:"eoa",solana:"eoa",ton:"eoa"},ADAPTER_TYPES:{UNIVERSAL:"universal",SOLANA:"solana",WAGMI:"wagmi",ETHERS:"ethers",ETHERS5:"ethers5",BITCOIN:"bitcoin"},SIWX_DEFAULTS:{signOutOnDisconnect:!0},MANDATORY_WALLET_IDS_ON_MOBILE:[Mr.ConnectorExplorerIds[U.CONNECTOR_ID.COINBASE],Mr.ConnectorExplorerIds[U.CONNECTOR_ID.COINBASE_SDK],Mr.ConnectorExplorerIds[U.CONNECTOR_ID.BASE_ACCOUNT],Mr.ConnectorExplorerIds[U.SOLFLARE_CONNECTOR_NAME],Mr.ConnectorExplorerIds[U.PHANTOM_CONNECTOR_NAME],Mr.ConnectorExplorerIds[U.BINANCE_CONNECTOR_NAME]],DEFAULT_CONNECT_METHOD_ORDER:["email","social","wallet"]},F={cacheExpiry:{portfolio:3e4,nativeBalance:3e4,ens:3e5,identity:3e5,transactionsHistory:15e3,tokenPrice:15e3,latestAppKitVersion:6048e5,tonWallets:864e5},isCacheExpired(t,e){return Date.now()-t>e},getActiveNetworkProps(){const t=F.getActiveNamespace(),e=F.getActiveCaipNetworkId(),s=e?e.split(":")[1]:void 0,n=s?isNaN(Number(s))?s:Number(s):void 0;return{namespace:t,caipNetworkId:e,chainId:n}},setWalletConnectDeepLink({name:t,href:e}){try{ae.setItem(le.DEEPLINK_CHOICE,JSON.stringify({href:e,name:t}))}catch{console.info("Unable to set WalletConnect deep link")}},getWalletConnectDeepLink(){try{const t=ae.getItem(le.DEEPLINK_CHOICE);if(t)return JSON.parse(t)}catch{console.info("Unable to get WalletConnect deep link")}},deleteWalletConnectDeepLink(){try{ae.removeItem(le.DEEPLINK_CHOICE)}catch{console.info("Unable to delete WalletConnect deep link")}},setActiveNamespace(t){try{ae.setItem(le.ACTIVE_NAMESPACE,t)}catch{console.info("Unable to set active namespace")}},setActiveCaipNetworkId(t){try{ae.setItem(le.ACTIVE_CAIP_NETWORK_ID,t),F.setActiveNamespace(t.split(":")[0])}catch{console.info("Unable to set active caip network id")}},getActiveCaipNetworkId(){try{return ae.getItem(le.ACTIVE_CAIP_NETWORK_ID)}catch{console.info("Unable to get active caip network id");return}},deleteActiveCaipNetworkId(){try{ae.removeItem(le.ACTIVE_CAIP_NETWORK_ID)}catch{console.info("Unable to delete active caip network id")}},deleteConnectedConnectorId(t){try{const e=yc(t);ae.removeItem(e)}catch{console.info("Unable to delete connected connector id")}},setAppKitRecent(t){try{const e=F.getRecentWallets();e.find(n=>n.id===t.id)||(e.unshift(t),e.length>2&&e.pop(),ae.setItem(le.RECENT_WALLETS,JSON.stringify(e)),ae.setItem(le.RECENT_WALLET,JSON.stringify(t)))}catch{console.info("Unable to set AppKit recent")}},getRecentWallets(){try{const t=ae.getItem(le.RECENT_WALLETS);return t?JSON.parse(t):[]}catch{console.info("Unable to get AppKit recent")}return[]},getRecentWallet(){try{const t=ae.getItem(le.RECENT_WALLET);return t?JSON.parse(t):null}catch{console.info("Unable to get AppKit recent")}return null},deleteRecentWallet(){try{ae.removeItem(le.RECENT_WALLET)}catch{console.info("Unable to delete AppKit recent")}},setConnectedConnectorId(t,e){try{const s=yc(t);ae.setItem(s,e)}catch{console.info("Unable to set Connected Connector Id")}},getActiveNamespace(){try{return ae.getItem(le.ACTIVE_NAMESPACE)}catch{console.info("Unable to get active namespace")}},getConnectedConnectorId(t){if(t)try{const e=yc(t);return ae.getItem(e)}catch{console.info("Unable to get connected connector id in namespace",t)}},setConnectedSocialProvider(t){try{ae.setItem(le.CONNECTED_SOCIAL,t)}catch{console.info("Unable to set connected social provider")}},getConnectedSocialProvider(){try{return ae.getItem(le.CONNECTED_SOCIAL)}catch{console.info("Unable to get connected social provider")}},deleteConnectedSocialProvider(){try{ae.removeItem(le.CONNECTED_SOCIAL)}catch{console.info("Unable to delete connected social provider")}},getConnectedSocialUsername(){try{return ae.getItem(le.CONNECTED_SOCIAL_USERNAME)}catch{console.info("Unable to get connected social username")}},getStoredActiveCaipNetworkId(){var s;const t=ae.getItem(le.ACTIVE_CAIP_NETWORK_ID);return(s=t==null?void 0:t.split(":"))==null?void 0:s[1]},setConnectionStatus(t){try{ae.setItem(le.CONNECTION_STATUS,t)}catch{console.info("Unable to set connection status")}},getConnectionStatus(){try{return ae.getItem(le.CONNECTION_STATUS)}catch{return}},getConnectedNamespaces(){try{const t=ae.getItem(le.CONNECTED_NAMESPACES);return t!=null&&t.length?t.split(","):[]}catch{return[]}},setConnectedNamespaces(t){try{const e=Array.from(new Set(t));ae.setItem(le.CONNECTED_NAMESPACES,e.join(","))}catch{console.info("Unable to set namespaces in storage")}},addConnectedNamespace(t){try{const e=F.getConnectedNamespaces();e.includes(t)||(e.push(t),F.setConnectedNamespaces(e))}catch{console.info("Unable to add connected namespace")}},removeConnectedNamespace(t){try{const e=F.getConnectedNamespaces(),s=e.indexOf(t);s>-1&&(e.splice(s,1),F.setConnectedNamespaces(e))}catch{console.info("Unable to remove connected namespace")}},getTelegramSocialProvider(){try{return ae.getItem(le.TELEGRAM_SOCIAL_PROVIDER)}catch{return console.info("Unable to get telegram social provider"),null}},setTelegramSocialProvider(t){try{ae.setItem(le.TELEGRAM_SOCIAL_PROVIDER,t)}catch{console.info("Unable to set telegram social provider")}},removeTelegramSocialProvider(){try{ae.removeItem(le.TELEGRAM_SOCIAL_PROVIDER)}catch{console.info("Unable to remove telegram social provider")}},getBalanceCache(){let t={};try{const e=ae.getItem(le.PORTFOLIO_CACHE);t=e?JSON.parse(e):{}}catch{console.info("Unable to get balance cache")}return t},removeAddressFromBalanceCache(t){try{const e=F.getBalanceCache();ae.setItem(le.PORTFOLIO_CACHE,JSON.stringify({...e,[t]:void 0}))}catch{console.info("Unable to remove address from balance cache",t)}},getBalanceCacheForCaipAddress(t){try{const s=F.getBalanceCache()[t];if(s&&!this.isCacheExpired(s.timestamp,this.cacheExpiry.portfolio))return s.balance;F.removeAddressFromBalanceCache(t)}catch{console.info("Unable to get balance cache for address",t)}},updateBalanceCache(t){try{const e=F.getBalanceCache();e[t.caipAddress]=t,ae.setItem(le.PORTFOLIO_CACHE,JSON.stringify(e))}catch{console.info("Unable to update balance cache",t)}},getNativeBalanceCache(){let t={};try{const e=ae.getItem(le.NATIVE_BALANCE_CACHE);t=e?JSON.parse(e):{}}catch{console.info("Unable to get balance cache")}return t},removeAddressFromNativeBalanceCache(t){try{const e=F.getBalanceCache();ae.setItem(le.NATIVE_BALANCE_CACHE,JSON.stringify({...e,[t]:void 0}))}catch{console.info("Unable to remove address from balance cache",t)}},getNativeBalanceCacheForCaipAddress(t){try{const s=F.getNativeBalanceCache()[t];if(s&&!this.isCacheExpired(s.timestamp,this.cacheExpiry.nativeBalance))return s;console.info("Discarding cache for address",t),F.removeAddressFromBalanceCache(t)}catch{console.info("Unable to get balance cache for address",t)}},updateNativeBalanceCache(t){try{const e=F.getNativeBalanceCache();e[t.caipAddress]=t,ae.setItem(le.NATIVE_BALANCE_CACHE,JSON.stringify(e))}catch{console.info("Unable to update balance cache",t)}},getEnsCache(){let t={};try{const e=ae.getItem(le.ENS_CACHE);t=e?JSON.parse(e):{}}catch{console.info("Unable to get ens name cache")}return t},getEnsFromCacheForAddress(t){try{const s=F.getEnsCache()[t];if(s&&!this.isCacheExpired(s.timestamp,this.cacheExpiry.ens))return s.ens;F.removeEnsFromCache(t)}catch{console.info("Unable to get ens name from cache",t)}},updateEnsCache(t){try{const e=F.getEnsCache();e[t.address]=t,ae.setItem(le.ENS_CACHE,JSON.stringify(e))}catch{console.info("Unable to update ens name cache",t)}},removeEnsFromCache(t){try{const e=F.getEnsCache();ae.setItem(le.ENS_CACHE,JSON.stringify({...e,[t]:void 0}))}catch{console.info("Unable to remove ens name from cache",t)}},getIdentityCache(){let t={};try{const e=ae.getItem(le.IDENTITY_CACHE);t=e?JSON.parse(e):{}}catch{console.info("Unable to get identity cache")}return t},getIdentityFromCacheForAddress(t){try{const s=F.getIdentityCache()[t];if(s&&!this.isCacheExpired(s.timestamp,this.cacheExpiry.identity))return s.identity;F.removeIdentityFromCache(t)}catch{console.info("Unable to get identity from cache",t)}},updateIdentityCache(t){try{const e=F.getIdentityCache();e[t.address]={identity:t.identity,timestamp:t.timestamp},ae.setItem(le.IDENTITY_CACHE,JSON.stringify(e))}catch{console.info("Unable to update identity cache",t)}},removeIdentityFromCache(t){try{const e=F.getIdentityCache();ae.setItem(le.IDENTITY_CACHE,JSON.stringify({...e,[t]:void 0}))}catch{console.info("Unable to remove identity from cache",t)}},getTonWalletsCache(){try{const t=ae.getItem(le.TON_WALLETS_CACHE),e=t?JSON.parse(t):void 0;if(e&&!this.isCacheExpired(e.timestamp,this.cacheExpiry.tonWallets))return e;F.removeTonWalletsCache()}catch{console.info("Unable to get ton wallets cache")}},updateTonWalletsCache(t){try{const e=F.getTonWalletsCache()||{timestamp:0,wallets:[]};e.timestamp=new Date().getTime(),e.wallets=t,ae.setItem(le.TON_WALLETS_CACHE,JSON.stringify(e))}catch{console.info("Unable to update ton wallets cache",t)}},removeTonWalletsCache(){try{ae.removeItem(le.TON_WALLETS_CACHE)}catch{console.info("Unable to remove ton wallets cache")}},clearAddressCache(){try{ae.removeItem(le.PORTFOLIO_CACHE),ae.removeItem(le.NATIVE_BALANCE_CACHE),ae.removeItem(le.ENS_CACHE),ae.removeItem(le.IDENTITY_CACHE),ae.removeItem(le.HISTORY_TRANSACTIONS_CACHE)}catch{console.info("Unable to clear address cache")}},setPreferredAccountTypes(t){try{ae.setItem(le.PREFERRED_ACCOUNT_TYPES,JSON.stringify(t))}catch{console.info("Unable to set preferred account types",t)}},getPreferredAccountTypes(){try{const t=ae.getItem(le.PREFERRED_ACCOUNT_TYPES);return t?JSON.parse(t):{}}catch{console.info("Unable to get preferred account types")}return{}},setConnections(t,e){try{const s=F.getConnections(),n=s[e]??[],r=new Map;for(const o of n)r.set(o.connectorId,{...o});for(const o of t){const a=r.get(o.connectorId),c=o.connectorId===U.CONNECTOR_ID.AUTH;if(a&&!c){const l=new Set(a.accounts.map(u=>u.address.toLowerCase())),d=o.accounts.filter(u=>!l.has(u.address.toLowerCase()));a.accounts.push(...d)}else r.set(o.connectorId,{...o})}const i={...s,[e]:Array.from(r.values())};ae.setItem(le.CONNECTIONS,JSON.stringify(i))}catch(s){console.error("Unable to sync connections to storage",s)}},getConnections(){try{const t=ae.getItem(le.CONNECTIONS);return t?JSON.parse(t):{}}catch(t){return console.error("Unable to get connections from storage",t),{}}},deleteAddressFromConnection({connectorId:t,address:e,namespace:s}){try{const n=F.getConnections(),r=n[s]??[],i=new Map(r.map(a=>[a.connectorId,a])),o=i.get(t);o&&(o.accounts.filter(c=>c.address.toLowerCase()!==e.toLowerCase()).length===0?i.delete(t):i.set(t,{...o,accounts:o.accounts.filter(c=>c.address.toLowerCase()!==e.toLowerCase())})),ae.setItem(le.CONNECTIONS,JSON.stringify({...n,[s]:Array.from(i.values())}))}catch{console.error(`Unable to remove address "${e}" from connector "${t}" in namespace "${s}"`)}},getDisconnectedConnectorIds(){try{const t=ae.getItem(le.DISCONNECTED_CONNECTOR_IDS);return t?JSON.parse(t):{}}catch{console.info("Unable to get disconnected connector ids")}return{}},addDisconnectedConnectorId(t,e){try{const s=F.getDisconnectedConnectorIds(),n=s[e]??[];n.push(t),ae.setItem(le.DISCONNECTED_CONNECTOR_IDS,JSON.stringify({...s,[e]:Array.from(new Set(n))}))}catch{console.error(`Unable to set disconnected connector id "${t}" for namespace "${e}"`)}},removeDisconnectedConnectorId(t,e){try{const s=F.getDisconnectedConnectorIds();let n=s[e]??[];n=n.filter(r=>r.toLowerCase()!==t.toLowerCase()),ae.setItem(le.DISCONNECTED_CONNECTOR_IDS,JSON.stringify({...s,[e]:Array.from(new Set(n))}))}catch{console.error(`Unable to remove disconnected connector id "${t}" for namespace "${e}"`)}},isConnectorDisconnected(t,e){try{return(F.getDisconnectedConnectorIds()[e]??[]).some(r=>r.toLowerCase()===t.toLowerCase())}catch{console.info(`Unable to get disconnected connector id "${t}" for namespace "${e}"`)}return!1},getTransactionsCache(){try{const t=ae.getItem(le.HISTORY_TRANSACTIONS_CACHE);return t?JSON.parse(t):{}}catch{console.info("Unable to get transactions cache")}return{}},getTransactionsCacheForAddress({address:t,chainId:e=""}){var s;try{const r=(s=F.getTransactionsCache()[t])==null?void 0:s[e];if(r&&!this.isCacheExpired(r.timestamp,this.cacheExpiry.transactionsHistory))return r.transactions;F.removeTransactionsCache({address:t,chainId:e})}catch{console.info("Unable to get transactions cache")}},updateTransactionsCache({address:t,chainId:e="",timestamp:s,transactions:n}){try{const r=F.getTransactionsCache();r[t]={...r[t],[e]:{timestamp:s,transactions:n}},ae.setItem(le.HISTORY_TRANSACTIONS_CACHE,JSON.stringify(r))}catch{console.info("Unable to update transactions cache",{address:t,chainId:e,timestamp:s,transactions:n})}},removeTransactionsCache({address:t,chainId:e}){try{const s=F.getTransactionsCache(),n=(s==null?void 0:s[t])||{},{[e]:r,...i}=n;ae.setItem(le.HISTORY_TRANSACTIONS_CACHE,JSON.stringify({...s,[t]:i}))}catch{console.info("Unable to remove transactions cache",{address:t,chainId:e})}},getTokenPriceCache(){try{const t=ae.getItem(le.TOKEN_PRICE_CACHE);return t?JSON.parse(t):{}}catch{console.info("Unable to get token price cache")}return{}},getTokenPriceCacheForAddresses(t){try{const s=F.getTokenPriceCache()[t.join(",")];if(s&&!this.isCacheExpired(s.timestamp,this.cacheExpiry.tokenPrice))return s.tokenPrice;F.removeTokenPriceCache(t)}catch{console.info("Unable to get token price cache for addresses",t)}},updateTokenPriceCache(t){try{const e=F.getTokenPriceCache();e[t.addresses.join(",")]={timestamp:t.timestamp,tokenPrice:t.tokenPrice},ae.setItem(le.TOKEN_PRICE_CACHE,JSON.stringify(e))}catch{console.info("Unable to update token price cache",t)}},removeTokenPriceCache(t){try{const e=F.getTokenPriceCache();ae.setItem(le.TOKEN_PRICE_CACHE,JSON.stringify({...e,[t.join(",")]:void 0}))}catch{console.info("Unable to remove token price cache",t)}},getLatestAppKitVersion(){try{const t=this.getLatestAppKitVersionCache(),e=t==null?void 0:t.version;return e&&!this.isCacheExpired(t.timestamp,this.cacheExpiry.latestAppKitVersion)?e:void 0}catch{console.info("Unable to get latest AppKit version")}},getLatestAppKitVersionCache(){try{const t=ae.getItem(le.LATEST_APPKIT_VERSION);return t?JSON.parse(t):{}}catch{console.info("Unable to get latest AppKit version cache")}return{}},updateLatestAppKitVersion(t){try{const e=F.getLatestAppKitVersionCache();e.timestamp=t.timestamp,e.version=t.version,ae.setItem(le.LATEST_APPKIT_VERSION,JSON.stringify(e))}catch{console.info("Unable to update latest AppKit version on local storage",t)}}},X={getWindow(){if(!(typeof window>"u"))return window},isMobile(){var t;return this.isClient()?!!(window!=null&&window.matchMedia&&typeof window.matchMedia=="function"&&((t=window.matchMedia("(pointer:coarse)"))!=null&&t.matches)||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1},checkCaipNetwork(t,e=""){return t==null?void 0:t.caipNetworkId.toLocaleLowerCase().includes(e.toLowerCase())},isAndroid(){if(!this.isMobile())return!1;const t=window==null?void 0:window.navigator.userAgent.toLowerCase();return X.isMobile()&&t.includes("android")},isIos(){if(!this.isMobile())return!1;const t=window==null?void 0:window.navigator.userAgent.toLowerCase();return t.includes("iphone")||t.includes("ipad")},isSafari(){return this.isClient()?(window==null?void 0:window.navigator.userAgent.toLowerCase()).includes("safari"):!1},isClient(){return typeof window<"u"},isPairingExpired(t){return t?t-Date.now()<=Ne.TEN_SEC_MS:!0},isAllowedRetry(t,e=Ne.ONE_SEC_MS){return Date.now()-t>=e},copyToClopboard(t){navigator.clipboard.writeText(t)},isIframe(){try{return(window==null?void 0:window.self)!==(window==null?void 0:window.top)}catch{return!1}},isSafeApp(){var t,e;if(X.isClient()&&window.self!==window.top)try{const s=(e=(t=window==null?void 0:window.location)==null?void 0:t.ancestorOrigins)==null?void 0:e[0],n="https://app.safe.global";if(s){const r=new URL(s),i=new URL(n);return r.hostname===i.hostname}}catch{return!1}return!1},getPairingExpiry(){return Date.now()+Ne.FOUR_MINUTES_MS},getNetworkId(t){return t==null?void 0:t.split(":")[1]},getPlainAddress(t){return t==null?void 0:t.split(":")[2]},async wait(t){return new Promise(e=>{setTimeout(e,t)})},debounce(t,e=500){let s;return(...n)=>{function r(){t(...n)}s&&clearTimeout(s),s=setTimeout(r,e)}},isHttpUrl(t){return t.startsWith("http://")||t.startsWith("https://")},formatNativeUrl(t,e,s=null){if(X.isHttpUrl(t))return this.formatUniversalUrl(t,e);let n=t,r=s;n.includes("://")||(n=t.replaceAll("/","").replaceAll(":",""),n=`${n}://`),n.endsWith("/")||(n=`${n}/`),r&&!(r!=null&&r.endsWith("/"))&&(r=`${r}/`),this.isTelegram()&&this.isAndroid()&&(e=encodeURIComponent(e));const i=encodeURIComponent(e);return{redirect:`${n}wc?uri=${i}`,redirectUniversalLink:r?`${r}wc?uri=${i}`:void 0,href:n}},formatUniversalUrl(t,e){if(!X.isHttpUrl(t))return this.formatNativeUrl(t,e);let s=t;s.endsWith("/")||(s=`${s}/`);const n=encodeURIComponent(e);return{redirect:`${s}wc?uri=${n}`,href:s}},getOpenTargetForPlatform(t){return t==="popupWindow"?t:this.isTelegram()?F.getTelegramSocialProvider()?"_top":"_blank":t},openHref(t,e,s){window==null||window.open(t,this.getOpenTargetForPlatform(e),s||"noreferrer noopener")},returnOpenHref(t,e,s){return window==null?void 0:window.open(t,this.getOpenTargetForPlatform(e),s||"noreferrer noopener")},isTelegram(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)},isPWA(){var s,n;if(typeof window>"u")return!1;const t=window!=null&&window.matchMedia&&typeof window.matchMedia=="function"?(s=window.matchMedia("(display-mode: standalone)"))==null?void 0:s.matches:!1,e=(n=window==null?void 0:window.navigator)==null?void 0:n.standalone;return!!(t||e)},async preloadImage(t){const e=new Promise((s,n)=>{const r=new Image;r.onload=s,r.onerror=n,r.crossOrigin="anonymous",r.src=t});return Promise.race([e,X.wait(2e3)])},parseBalance(t,e){let s="0.000";if(typeof t=="string"){const c=Number(t);if(!isNaN(c)){const l=(Math.floor(c*1e3)/1e3).toFixed(3);l&&(s=l)}}const[n,r]=s.split("."),i=n||"0",o=r||"000";return{formattedText:`${i}.${o}${e?` ${e}`:""}`,value:i,decimals:o,symbol:e}},getApiUrl(){return U.W3M_API_URL},getBlockchainApiUrl(){return U.BLOCKCHAIN_API_RPC_URL},getAnalyticsUrl(){return U.PULSE_API_URL},getUUID(){return crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,t=>{const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})},parseError(t){var e,s;return typeof t=="string"?t:typeof((s=(e=t==null?void 0:t.issues)==null?void 0:e[0])==null?void 0:s.message)=="string"?t.issues[0].message:t instanceof Error?t.message:"Unknown error"},sortRequestedNetworks(t,e=[]){const s={};return e&&t&&(t.forEach((n,r)=>{s[n]=r}),e.sort((n,r)=>{const i=s[n.id],o=s[r.id];return i!==void 0&&o!==void 0?i-o:i!==void 0?-1:o!==void 0?1:0})),e},calculateBalance(t){let e=0;for(const s of t)e+=s.value??0;return e},formatTokenBalance(t){const e=t.toFixed(2),[s,n]=e.split(".");return{dollars:s,pennies:n}},isAddress(t,e="eip155"){switch(e){case"eip155":if(/^(?:0x)?[0-9a-f]{40}$/iu.test(t)){if(/^(?:0x)?[0-9a-f]{40}$/iu.test(t)||/^(?:0x)?[0-9A-F]{40}$/iu.test(t))return!0}else return!1;return!1;case"solana":return/[1-9A-HJ-NP-Za-km-z]{32,44}$/iu.test(t);default:return!1}},uniqueBy(t,e){const s=new Set;return t.filter(n=>{const r=n[e];return s.has(r)?!1:(s.add(r),!0)})},generateSdkVersion(t,e,s){const r=t.length===0?Ne.ADAPTER_TYPES.UNIVERSAL:t.map(i=>i.adapterType).join(",");return`${e}-${r}-${s}`},createAccount(t,e,s,n,r){return{namespace:t,address:e,type:s,publicKey:n,path:r}},isCaipAddress(t){if(typeof t!="string")return!1;const e=t.split(":"),s=e[0];return e.filter(Boolean).length===3&&s in U.CHAIN_NAME_MAP},getAccount(t){return t?typeof t=="string"?{address:t,chainId:void 0}:{address:t.address,chainId:t.chainId}:{address:void 0,chainId:void 0}},isMac(){const t=window==null?void 0:window.navigator.userAgent.toLowerCase();return t.includes("macintosh")&&!t.includes("safari")},formatTelegramSocialLoginUrl(t){const e=`--${encodeURIComponent(window==null?void 0:window.location.href)}`,s="state=";if(new URL(t).host==="auth.magic.link"){const r="provider_authorization_url=",i=t.substring(t.indexOf(r)+r.length),o=this.injectIntoUrl(decodeURIComponent(i),s,e);return t.replace(i,encodeURIComponent(o))}return this.injectIntoUrl(t,s,e)},injectIntoUrl(t,e,s){const n=t.indexOf(e);if(n===-1)throw new Error(`${e} parameter not found in the URL: ${t}`);const r=t.indexOf("&",n),i=e.length,o=r!==-1?r:t.length,a=t.substring(0,n+i),c=t.substring(n+i,o),l=t.substring(r),d=c+s;return a+d+l}};var ai={};const gw="https://secure.walletconnect.org/sdk",mw=(typeof wn<"u"&&typeof ai<"u"?ai.NEXT_PUBLIC_SECURE_SITE_SDK_URL:void 0)||gw,yw=(typeof wn<"u"&&typeof ai<"u"?ai.NEXT_PUBLIC_DEFAULT_LOG_LEVEL:void 0)||"error",ww=(typeof wn<"u"&&typeof ai<"u"?ai.NEXT_PUBLIC_SECURE_SITE_SDK_VERSION:void 0)||"4",oe={APP_EVENT_KEY:"@w3m-app/",FRAME_EVENT_KEY:"@w3m-frame/",RPC_METHOD_KEY:"RPC_",STORAGE_KEY:"@appkit-wallet/",SESSION_TOKEN_KEY:"SESSION_TOKEN_KEY",EMAIL_LOGIN_USED_KEY:"EMAIL_LOGIN_USED_KEY",LAST_USED_CHAIN_KEY:"LAST_USED_CHAIN_KEY",LAST_EMAIL_LOGIN_TIME:"LAST_EMAIL_LOGIN_TIME",EMAIL:"EMAIL",PREFERRED_ACCOUNT_TYPE:"PREFERRED_ACCOUNT_TYPE",SMART_ACCOUNT_ENABLED:"SMART_ACCOUNT_ENABLED",SMART_ACCOUNT_ENABLED_NETWORKS:"SMART_ACCOUNT_ENABLED_NETWORKS",SOCIAL_USERNAME:"SOCIAL_USERNAME",APP_SWITCH_NETWORK:"@w3m-app/SWITCH_NETWORK",APP_CONNECT_EMAIL:"@w3m-app/CONNECT_EMAIL",APP_CONNECT_DEVICE:"@w3m-app/CONNECT_DEVICE",APP_CONNECT_OTP:"@w3m-app/CONNECT_OTP",APP_CONNECT_SOCIAL:"@w3m-app/CONNECT_SOCIAL",APP_GET_SOCIAL_REDIRECT_URI:"@w3m-app/GET_SOCIAL_REDIRECT_URI",APP_GET_USER:"@w3m-app/GET_USER",APP_SIGN_OUT:"@w3m-app/SIGN_OUT",APP_IS_CONNECTED:"@w3m-app/IS_CONNECTED",APP_GET_CHAIN_ID:"@w3m-app/GET_CHAIN_ID",APP_RPC_REQUEST:"@w3m-app/RPC_REQUEST",APP_UPDATE_EMAIL:"@w3m-app/UPDATE_EMAIL",APP_UPDATE_EMAIL_PRIMARY_OTP:"@w3m-app/UPDATE_EMAIL_PRIMARY_OTP",APP_UPDATE_EMAIL_SECONDARY_OTP:"@w3m-app/UPDATE_EMAIL_SECONDARY_OTP",APP_AWAIT_UPDATE_EMAIL:"@w3m-app/AWAIT_UPDATE_EMAIL",APP_SYNC_THEME:"@w3m-app/SYNC_THEME",APP_SYNC_DAPP_DATA:"@w3m-app/SYNC_DAPP_DATA",APP_GET_SMART_ACCOUNT_ENABLED_NETWORKS:"@w3m-app/GET_SMART_ACCOUNT_ENABLED_NETWORKS",APP_INIT_SMART_ACCOUNT:"@w3m-app/INIT_SMART_ACCOUNT",APP_SET_PREFERRED_ACCOUNT:"@w3m-app/SET_PREFERRED_ACCOUNT",APP_CONNECT_FARCASTER:"@w3m-app/CONNECT_FARCASTER",APP_GET_FARCASTER_URI:"@w3m-app/GET_FARCASTER_URI",APP_RELOAD:"@w3m-app/RELOAD",APP_RPC_ABORT:"@w3m-app/RPC_ABORT",FRAME_SWITCH_NETWORK_ERROR:"@w3m-frame/SWITCH_NETWORK_ERROR",FRAME_SWITCH_NETWORK_SUCCESS:"@w3m-frame/SWITCH_NETWORK_SUCCESS",FRAME_CONNECT_EMAIL_ERROR:"@w3m-frame/CONNECT_EMAIL_ERROR",FRAME_CONNECT_EMAIL_SUCCESS:"@w3m-frame/CONNECT_EMAIL_SUCCESS",FRAME_CONNECT_DEVICE_ERROR:"@w3m-frame/CONNECT_DEVICE_ERROR",FRAME_CONNECT_DEVICE_SUCCESS:"@w3m-frame/CONNECT_DEVICE_SUCCESS",FRAME_CONNECT_OTP_SUCCESS:"@w3m-frame/CONNECT_OTP_SUCCESS",FRAME_CONNECT_OTP_ERROR:"@w3m-frame/CONNECT_OTP_ERROR",FRAME_CONNECT_SOCIAL_SUCCESS:"@w3m-frame/CONNECT_SOCIAL_SUCCESS",FRAME_CONNECT_SOCIAL_ERROR:"@w3m-frame/CONNECT_SOCIAL_ERROR",FRAME_CONNECT_FARCASTER_SUCCESS:"@w3m-frame/CONNECT_FARCASTER_SUCCESS",FRAME_CONNECT_FARCASTER_ERROR:"@w3m-frame/CONNECT_FARCASTER_ERROR",FRAME_GET_FARCASTER_URI_SUCCESS:"@w3m-frame/GET_FARCASTER_URI_SUCCESS",FRAME_GET_FARCASTER_URI_ERROR:"@w3m-frame/GET_FARCASTER_URI_ERROR",FRAME_GET_SOCIAL_REDIRECT_URI_SUCCESS:"@w3m-frame/GET_SOCIAL_REDIRECT_URI_SUCCESS",FRAME_GET_SOCIAL_REDIRECT_URI_ERROR:"@w3m-frame/GET_SOCIAL_REDIRECT_URI_ERROR",FRAME_GET_USER_SUCCESS:"@w3m-frame/GET_USER_SUCCESS",FRAME_GET_USER_ERROR:"@w3m-frame/GET_USER_ERROR",FRAME_SIGN_OUT_SUCCESS:"@w3m-frame/SIGN_OUT_SUCCESS",FRAME_SIGN_OUT_ERROR:"@w3m-frame/SIGN_OUT_ERROR",FRAME_IS_CONNECTED_SUCCESS:"@w3m-frame/IS_CONNECTED_SUCCESS",FRAME_IS_CONNECTED_ERROR:"@w3m-frame/IS_CONNECTED_ERROR",FRAME_GET_CHAIN_ID_SUCCESS:"@w3m-frame/GET_CHAIN_ID_SUCCESS",FRAME_GET_CHAIN_ID_ERROR:"@w3m-frame/GET_CHAIN_ID_ERROR",FRAME_RPC_REQUEST_SUCCESS:"@w3m-frame/RPC_REQUEST_SUCCESS",FRAME_RPC_REQUEST_ERROR:"@w3m-frame/RPC_REQUEST_ERROR",FRAME_SESSION_UPDATE:"@w3m-frame/SESSION_UPDATE",FRAME_UPDATE_EMAIL_SUCCESS:"@w3m-frame/UPDATE_EMAIL_SUCCESS",FRAME_UPDATE_EMAIL_ERROR:"@w3m-frame/UPDATE_EMAIL_ERROR",FRAME_UPDATE_EMAIL_PRIMARY_OTP_SUCCESS:"@w3m-frame/UPDATE_EMAIL_PRIMARY_OTP_SUCCESS",FRAME_UPDATE_EMAIL_PRIMARY_OTP_ERROR:"@w3m-frame/UPDATE_EMAIL_PRIMARY_OTP_ERROR",FRAME_UPDATE_EMAIL_SECONDARY_OTP_SUCCESS:"@w3m-frame/UPDATE_EMAIL_SECONDARY_OTP_SUCCESS",FRAME_UPDATE_EMAIL_SECONDARY_OTP_ERROR:"@w3m-frame/UPDATE_EMAIL_SECONDARY_OTP_ERROR",FRAME_SYNC_THEME_SUCCESS:"@w3m-frame/SYNC_THEME_SUCCESS",FRAME_SYNC_THEME_ERROR:"@w3m-frame/SYNC_THEME_ERROR",FRAME_SYNC_DAPP_DATA_SUCCESS:"@w3m-frame/SYNC_DAPP_DATA_SUCCESS",FRAME_SYNC_DAPP_DATA_ERROR:"@w3m-frame/SYNC_DAPP_DATA_ERROR",FRAME_GET_SMART_ACCOUNT_ENABLED_NETWORKS_SUCCESS:"@w3m-frame/GET_SMART_ACCOUNT_ENABLED_NETWORKS_SUCCESS",FRAME_GET_SMART_ACCOUNT_ENABLED_NETWORKS_ERROR:"@w3m-frame/GET_SMART_ACCOUNT_ENABLED_NETWORKS_ERROR",FRAME_INIT_SMART_ACCOUNT_SUCCESS:"@w3m-frame/INIT_SMART_ACCOUNT_SUCCESS",FRAME_INIT_SMART_ACCOUNT_ERROR:"@w3m-frame/INIT_SMART_ACCOUNT_ERROR",FRAME_SET_PREFERRED_ACCOUNT_SUCCESS:"@w3m-frame/SET_PREFERRED_ACCOUNT_SUCCESS",FRAME_SET_PREFERRED_ACCOUNT_ERROR:"@w3m-frame/SET_PREFERRED_ACCOUNT_ERROR",FRAME_READY:"@w3m-frame/READY",FRAME_RELOAD_SUCCESS:"@w3m-frame/RELOAD_SUCCESS",FRAME_RELOAD_ERROR:"@w3m-frame/RELOAD_ERROR",FRAME_RPC_ABORT_SUCCESS:"@w3m-frame/RPC_ABORT_SUCCESS",FRAME_RPC_ABORT_ERROR:"@w3m-frame/RPC_ABORT_ERROR",RPC_RESPONSE_TYPE_ERROR:"RPC_RESPONSE_ERROR",RPC_RESPONSE_TYPE_TX:"RPC_RESPONSE_TRANSACTION_HASH",RPC_RESPONSE_TYPE_OBJECT:"RPC_RESPONSE_OBJECT"},tt={SAFE_RPC_METHODS:["eth_accounts","eth_blockNumber","eth_call","eth_chainId","eth_estimateGas","eth_feeHistory","eth_gasPrice","eth_getAccount","eth_getBalance","eth_getBlockByHash","eth_getBlockByNumber","eth_getBlockReceipts","eth_getBlockTransactionCountByHash","eth_getBlockTransactionCountByNumber","eth_getCode","eth_getFilterChanges","eth_getFilterLogs","eth_getLogs","eth_getProof","eth_getStorageAt","eth_getTransactionByBlockHashAndIndex","eth_getTransactionByBlockNumberAndIndex","eth_getTransactionByHash","eth_getTransactionCount","eth_getTransactionReceipt","eth_getUncleCountByBlockHash","eth_getUncleCountByBlockNumber","eth_maxPriorityFeePerGas","eth_newBlockFilter","eth_newFilter","eth_newPendingTransactionFilter","eth_sendRawTransaction","eth_syncing","eth_uninstallFilter","wallet_getCapabilities","wallet_getCallsStatus","eth_getUserOperationReceipt","eth_estimateUserOperationGas","eth_getUserOperationByHash","eth_supportedEntryPoints","wallet_getAssets"],NOT_SAFE_RPC_METHODS:["personal_sign","eth_signTypedData_v4","eth_sendTransaction","solana_signMessage","solana_signTransaction","solana_signAllTransactions","solana_signAndSendTransaction","wallet_sendCalls","wallet_grantPermissions","wallet_revokePermissions","eth_sendUserOperation"],GET_CHAIN_ID:"eth_chainId",RPC_METHOD_NOT_ALLOWED_MESSAGE:"Requested RPC call is not allowed",RPC_METHOD_NOT_ALLOWED_UI_MESSAGE:"Action not allowed",ACCOUNT_TYPES:{EOA:"eoa",SMART_ACCOUNT:"smartAccount"}},Nu={transactionHash:/^0x(?:[A-Fa-f0-9]{64})$/u,signedMessage:/^0x(?:[a-fA-F0-9]{62,})$/u},lt={set(t,e){cs.isClient&&localStorage.setItem(`${oe.STORAGE_KEY}${t}`,e)},get(t){return cs.isClient?localStorage.getItem(`${oe.STORAGE_KEY}${t}`):null},delete(t,e){cs.isClient&&(e?localStorage.removeItem(t):localStorage.removeItem(`${oe.STORAGE_KEY}${t}`))}},jo=30*1e3,cs={checkIfAllowedToTriggerEmail(){const t=lt.get(oe.LAST_EMAIL_LOGIN_TIME);if(t){const e=Date.now()-Number(t);if(e<jo){const s=Math.ceil((jo-e)/1e3);throw new Error(`Please try again after ${s} seconds`)}}},getTimeToNextEmailLogin(){const t=lt.get(oe.LAST_EMAIL_LOGIN_TIME);if(t){const e=Date.now()-Number(t);if(e<jo)return Math.ceil((jo-e)/1e3)}return 0},checkIfRequestExists(t){return tt.NOT_SAFE_RPC_METHODS.includes(t.method)||tt.SAFE_RPC_METHODS.includes(t.method)},getResponseType(t){return typeof t=="string"&&((t==null?void 0:t.match(Nu.transactionHash))||(t==null?void 0:t.match(Nu.signedMessage)))?oe.RPC_RESPONSE_TYPE_TX:oe.RPC_RESPONSE_TYPE_OBJECT},checkIfRequestIsSafe(t){return tt.SAFE_RPC_METHODS.includes(t.method)},isClient:typeof window<"u"};var Me;(function(t){t.assertEqual=r=>r;function e(r){}t.assertIs=e;function s(r){throw new Error}t.assertNever=s,t.arrayToEnum=r=>{const i={};for(const o of r)i[o]=o;return i},t.getValidEnumValues=r=>{const i=t.objectKeys(r).filter(a=>typeof r[r[a]]!="number"),o={};for(const a of i)o[a]=r[a];return t.objectValues(o)},t.objectValues=r=>t.objectKeys(r).map(function(i){return r[i]}),t.objectKeys=typeof Object.keys=="function"?r=>Object.keys(r):r=>{const i=[];for(const o in r)Object.prototype.hasOwnProperty.call(r,o)&&i.push(o);return i},t.find=(r,i)=>{for(const o of r)if(i(o))return o},t.isInteger=typeof Number.isInteger=="function"?r=>Number.isInteger(r):r=>typeof r=="number"&&isFinite(r)&&Math.floor(r)===r;function n(r,i=" | "){return r.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}t.joinValues=n,t.jsonStringifyReplacer=(r,i)=>typeof i=="bigint"?i.toString():i})(Me||(Me={}));var bl;(function(t){t.mergeShapes=(e,s)=>({...e,...s})})(bl||(bl={}));const se=Me.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Mn=t=>{switch(typeof t){case"undefined":return se.undefined;case"string":return se.string;case"number":return isNaN(t)?se.nan:se.number;case"boolean":return se.boolean;case"function":return se.function;case"bigint":return se.bigint;case"symbol":return se.symbol;case"object":return Array.isArray(t)?se.array:t===null?se.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?se.promise:typeof Map<"u"&&t instanceof Map?se.map:typeof Set<"u"&&t instanceof Set?se.set:typeof Date<"u"&&t instanceof Date?se.date:se.object;default:return se.unknown}},K=Me.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Ew=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:");class ks extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const s=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,s):this.__proto__=s,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const s=e||function(i){return i.message},n={_errors:[]},r=i=>{for(const o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(r);else if(o.code==="invalid_return_type")r(o.returnTypeError);else if(o.code==="invalid_arguments")r(o.argumentsError);else if(o.path.length===0)n._errors.push(s(o));else{let a=n,c=0;for(;c<o.path.length;){const l=o.path[c];c===o.path.length-1?(a[l]=a[l]||{_errors:[]},a[l]._errors.push(s(o))):a[l]=a[l]||{_errors:[]},a=a[l],c++}}};return r(this),n}toString(){return this.message}get message(){return JSON.stringify(this.issues,Me.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=s=>s.message){const s={},n=[];for(const r of this.issues)r.path.length>0?(s[r.path[0]]=s[r.path[0]]||[],s[r.path[0]].push(e(r))):n.push(e(r));return{formErrors:n,fieldErrors:s}}get formErrors(){return this.flatten()}}ks.create=t=>new ks(t);const eo=(t,e)=>{let s;switch(t.code){case K.invalid_type:t.received===se.undefined?s="Required":s=`Expected ${t.expected}, received ${t.received}`;break;case K.invalid_literal:s=`Invalid literal value, expected ${JSON.stringify(t.expected,Me.jsonStringifyReplacer)}`;break;case K.unrecognized_keys:s=`Unrecognized key(s) in object: ${Me.joinValues(t.keys,", ")}`;break;case K.invalid_union:s="Invalid input";break;case K.invalid_union_discriminator:s=`Invalid discriminator value. Expected ${Me.joinValues(t.options)}`;break;case K.invalid_enum_value:s=`Invalid enum value. Expected ${Me.joinValues(t.options)}, received '${t.received}'`;break;case K.invalid_arguments:s="Invalid function arguments";break;case K.invalid_return_type:s="Invalid function return type";break;case K.invalid_date:s="Invalid date";break;case K.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(s=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(s=`${s} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?s=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?s=`Invalid input: must end with "${t.validation.endsWith}"`:Me.assertNever(t.validation):t.validation!=="regex"?s=`Invalid ${t.validation}`:s="Invalid";break;case K.too_small:t.type==="array"?s=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?s=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?s=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?s=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:s="Invalid input";break;case K.too_big:t.type==="array"?s=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?s=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?s=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?s=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?s=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:s="Invalid input";break;case K.custom:s="Invalid input";break;case K.invalid_intersection_types:s="Intersection results could not be merged";break;case K.not_multiple_of:s=`Number must be a multiple of ${t.multipleOf}`;break;case K.not_finite:s="Number must be finite";break;default:s=e.defaultError,Me.assertNever(t)}return{message:s}};let If=eo;function bw(t){If=t}function _a(){return If}const Aa=t=>{const{data:e,path:s,errorMaps:n,issueData:r}=t,i=[...s,...r.path||[]],o={...r,path:i};let a="";const c=n.filter(l=>!!l).slice().reverse();for(const l of c)a=l(o,{data:e,defaultError:a}).message;return{...r,path:i,message:r.message||a}},vw=[];function ie(t,e){const s=Aa({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,_a(),eo].filter(n=>!!n)});t.common.issues.push(s)}class kt{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,s){const n=[];for(const r of s){if(r.status==="aborted")return be;r.status==="dirty"&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,s){const n=[];for(const r of s)n.push({key:await r.key,value:await r.value});return kt.mergeObjectSync(e,n)}static mergeObjectSync(e,s){const n={};for(const r of s){const{key:i,value:o}=r;if(i.status==="aborted"||o.status==="aborted")return be;i.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||r.alwaysSet)&&(n[i.value]=o.value)}return{status:e.value,value:n}}}const be=Object.freeze({status:"aborted"}),Nf=t=>({status:"dirty",value:t}),Ft=t=>({status:"valid",value:t}),vl=t=>t.status==="aborted",Cl=t=>t.status==="dirty",to=t=>t.status==="valid",Sa=t=>typeof Promise<"u"&&t instanceof Promise;var pe;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(pe||(pe={}));class Xs{constructor(e,s,n,r){this._cachedPath=[],this.parent=e,this.data=s,this._path=n,this._key=r}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Tu=(t,e)=>{if(to(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const s=new ks(t.common.issues);return this._error=s,this._error}}};function _e(t){if(!t)return{};const{errorMap:e,invalid_type_error:s,required_error:n,description:r}=t;if(e&&(s||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:r}:{errorMap:(o,a)=>o.code!=="invalid_type"?{message:a.defaultError}:typeof a.data>"u"?{message:n??a.defaultError}:{message:s??a.defaultError},description:r}}class Se{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return Mn(e.data)}_getOrReturnCtx(e,s){return s||{common:e.parent.common,data:e.data,parsedType:Mn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new kt,ctx:{common:e.parent.common,data:e.data,parsedType:Mn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const s=this._parse(e);if(Sa(s))throw new Error("Synchronous parse encountered promise.");return s}_parseAsync(e){const s=this._parse(e);return Promise.resolve(s)}parse(e,s){const n=this.safeParse(e,s);if(n.success)return n.data;throw n.error}safeParse(e,s){var n;const r={common:{issues:[],async:(n=s==null?void 0:s.async)!==null&&n!==void 0?n:!1,contextualErrorMap:s==null?void 0:s.errorMap},path:(s==null?void 0:s.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Mn(e)},i=this._parseSync({data:e,path:r.path,parent:r});return Tu(r,i)}async parseAsync(e,s){const n=await this.safeParseAsync(e,s);if(n.success)return n.data;throw n.error}async safeParseAsync(e,s){const n={common:{issues:[],contextualErrorMap:s==null?void 0:s.errorMap,async:!0},path:(s==null?void 0:s.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Mn(e)},r=this._parse({data:e,path:n.path,parent:n}),i=await(Sa(r)?r:Promise.resolve(r));return Tu(n,i)}refine(e,s){const n=r=>typeof s=="string"||typeof s>"u"?{message:s}:typeof s=="function"?s(r):s;return this._refinement((r,i)=>{const o=e(r),a=()=>i.addIssue({code:K.custom,...n(r)});return typeof Promise<"u"&&o instanceof Promise?o.then(c=>c?!0:(a(),!1)):o?!0:(a(),!1)})}refinement(e,s){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof s=="function"?s(n,r):s),!1))}_refinement(e){return new Ds({schema:this,typeName:me.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return En.create(this,this._def)}nullable(){return Nr.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Us.create(this,this._def)}promise(){return li.create(this,this._def)}or(e){return io.create([this,e],this._def)}and(e){return oo.create(this,e,this._def)}transform(e){return new Ds({..._e(this._def),schema:this,typeName:me.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const s=typeof e=="function"?e:()=>e;return new ho({..._e(this._def),innerType:this,defaultValue:s,typeName:me.ZodDefault})}brand(){return new Rf({typeName:me.ZodBranded,type:this,..._e(this._def)})}catch(e){const s=typeof e=="function"?e:()=>e;return new Ra({..._e(this._def),innerType:this,catchValue:s,typeName:me.ZodCatch})}describe(e){const s=this.constructor;return new s({...this._def,description:e})}pipe(e){return Ao.create(this,e)}readonly(){return Pa.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Cw=/^c[^\s-]{8,}$/i,_w=/^[a-z][a-z0-9]*$/,Aw=/^[0-9A-HJKMNP-TV-Z]{26}$/,Sw=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Iw=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Nw="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Ec;const Tw=/^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/,Rw=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,Ow=t=>t.precision?t.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${t.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${t.precision}}Z$`):t.precision===0?t.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"):t.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$");function Pw(t,e){return!!((e==="v4"||!e)&&Tw.test(t)||(e==="v6"||!e)&&Rw.test(t))}class xs extends Se{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==se.string){const i=this._getOrReturnCtx(e);return ie(i,{code:K.invalid_type,expected:se.string,received:i.parsedType}),be}const n=new kt;let r;for(const i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(r=this._getOrReturnCtx(e,r),ie(r,{code:K.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="max")e.data.length>i.value&&(r=this._getOrReturnCtx(e,r),ie(r,{code:K.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="length"){const o=e.data.length>i.value,a=e.data.length<i.value;(o||a)&&(r=this._getOrReturnCtx(e,r),o?ie(r,{code:K.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):a&&ie(r,{code:K.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),n.dirty())}else if(i.kind==="email")Iw.test(e.data)||(r=this._getOrReturnCtx(e,r),ie(r,{validation:"email",code:K.invalid_string,message:i.message}),n.dirty());else if(i.kind==="emoji")Ec||(Ec=new RegExp(Nw,"u")),Ec.test(e.data)||(r=this._getOrReturnCtx(e,r),ie(r,{validation:"emoji",code:K.invalid_string,message:i.message}),n.dirty());else if(i.kind==="uuid")Sw.test(e.data)||(r=this._getOrReturnCtx(e,r),ie(r,{validation:"uuid",code:K.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid")Cw.test(e.data)||(r=this._getOrReturnCtx(e,r),ie(r,{validation:"cuid",code:K.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid2")_w.test(e.data)||(r=this._getOrReturnCtx(e,r),ie(r,{validation:"cuid2",code:K.invalid_string,message:i.message}),n.dirty());else if(i.kind==="ulid")Aw.test(e.data)||(r=this._getOrReturnCtx(e,r),ie(r,{validation:"ulid",code:K.invalid_string,message:i.message}),n.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{r=this._getOrReturnCtx(e,r),ie(r,{validation:"url",code:K.invalid_string,message:i.message}),n.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(r=this._getOrReturnCtx(e,r),ie(r,{validation:"regex",code:K.invalid_string,message:i.message}),n.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(r=this._getOrReturnCtx(e,r),ie(r,{code:K.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),n.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(r=this._getOrReturnCtx(e,r),ie(r,{code:K.invalid_string,validation:{startsWith:i.value},message:i.message}),n.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(r=this._getOrReturnCtx(e,r),ie(r,{code:K.invalid_string,validation:{endsWith:i.value},message:i.message}),n.dirty()):i.kind==="datetime"?Ow(i).test(e.data)||(r=this._getOrReturnCtx(e,r),ie(r,{code:K.invalid_string,validation:"datetime",message:i.message}),n.dirty()):i.kind==="ip"?Pw(e.data,i.version)||(r=this._getOrReturnCtx(e,r),ie(r,{validation:"ip",code:K.invalid_string,message:i.message}),n.dirty()):Me.assertNever(i);return{status:n.value,value:e.data}}_regex(e,s,n){return this.refinement(r=>e.test(r),{validation:s,code:K.invalid_string,...pe.errToObj(n)})}_addCheck(e){return new xs({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...pe.errToObj(e)})}url(e){return this._addCheck({kind:"url",...pe.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...pe.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...pe.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...pe.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...pe.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...pe.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...pe.errToObj(e)})}datetime(e){var s;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(s=e==null?void 0:e.offset)!==null&&s!==void 0?s:!1,...pe.errToObj(e==null?void 0:e.message)})}regex(e,s){return this._addCheck({kind:"regex",regex:e,...pe.errToObj(s)})}includes(e,s){return this._addCheck({kind:"includes",value:e,position:s==null?void 0:s.position,...pe.errToObj(s==null?void 0:s.message)})}startsWith(e,s){return this._addCheck({kind:"startsWith",value:e,...pe.errToObj(s)})}endsWith(e,s){return this._addCheck({kind:"endsWith",value:e,...pe.errToObj(s)})}min(e,s){return this._addCheck({kind:"min",value:e,...pe.errToObj(s)})}max(e,s){return this._addCheck({kind:"max",value:e,...pe.errToObj(s)})}length(e,s){return this._addCheck({kind:"length",value:e,...pe.errToObj(s)})}nonempty(e){return this.min(1,pe.errToObj(e))}trim(){return new xs({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new xs({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new xs({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get minLength(){let e=null;for(const s of this._def.checks)s.kind==="min"&&(e===null||s.value>e)&&(e=s.value);return e}get maxLength(){let e=null;for(const s of this._def.checks)s.kind==="max"&&(e===null||s.value<e)&&(e=s.value);return e}}xs.create=t=>{var e;return new xs({checks:[],typeName:me.ZodString,coerce:(e=t==null?void 0:t.coerce)!==null&&e!==void 0?e:!1,..._e(t)})};function xw(t,e){const s=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,r=s>n?s:n,i=parseInt(t.toFixed(r).replace(".","")),o=parseInt(e.toFixed(r).replace(".",""));return i%o/Math.pow(10,r)}class Yn extends Se{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==se.number){const i=this._getOrReturnCtx(e);return ie(i,{code:K.invalid_type,expected:se.number,received:i.parsedType}),be}let n;const r=new kt;for(const i of this._def.checks)i.kind==="int"?Me.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),ie(n,{code:K.invalid_type,expected:"integer",received:"float",message:i.message}),r.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),ie(n,{code:K.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),r.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),ie(n,{code:K.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),r.dirty()):i.kind==="multipleOf"?xw(e.data,i.value)!==0&&(n=this._getOrReturnCtx(e,n),ie(n,{code:K.not_multiple_of,multipleOf:i.value,message:i.message}),r.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),ie(n,{code:K.not_finite,message:i.message}),r.dirty()):Me.assertNever(i);return{status:r.value,value:e.data}}gte(e,s){return this.setLimit("min",e,!0,pe.toString(s))}gt(e,s){return this.setLimit("min",e,!1,pe.toString(s))}lte(e,s){return this.setLimit("max",e,!0,pe.toString(s))}lt(e,s){return this.setLimit("max",e,!1,pe.toString(s))}setLimit(e,s,n,r){return new Yn({...this._def,checks:[...this._def.checks,{kind:e,value:s,inclusive:n,message:pe.toString(r)}]})}_addCheck(e){return new Yn({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:pe.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:pe.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:pe.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:pe.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:pe.toString(e)})}multipleOf(e,s){return this._addCheck({kind:"multipleOf",value:e,message:pe.toString(s)})}finite(e){return this._addCheck({kind:"finite",message:pe.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:pe.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:pe.toString(e)})}get minValue(){let e=null;for(const s of this._def.checks)s.kind==="min"&&(e===null||s.value>e)&&(e=s.value);return e}get maxValue(){let e=null;for(const s of this._def.checks)s.kind==="max"&&(e===null||s.value<e)&&(e=s.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&Me.isInteger(e.value))}get isFinite(){let e=null,s=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(s===null||n.value>s)&&(s=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(s)&&Number.isFinite(e)}}Yn.create=t=>new Yn({checks:[],typeName:me.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,..._e(t)});class Zn extends Se{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==se.bigint){const i=this._getOrReturnCtx(e);return ie(i,{code:K.invalid_type,expected:se.bigint,received:i.parsedType}),be}let n;const r=new kt;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),ie(n,{code:K.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),r.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),ie(n,{code:K.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),r.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),ie(n,{code:K.not_multiple_of,multipleOf:i.value,message:i.message}),r.dirty()):Me.assertNever(i);return{status:r.value,value:e.data}}gte(e,s){return this.setLimit("min",e,!0,pe.toString(s))}gt(e,s){return this.setLimit("min",e,!1,pe.toString(s))}lte(e,s){return this.setLimit("max",e,!0,pe.toString(s))}lt(e,s){return this.setLimit("max",e,!1,pe.toString(s))}setLimit(e,s,n,r){return new Zn({...this._def,checks:[...this._def.checks,{kind:e,value:s,inclusive:n,message:pe.toString(r)}]})}_addCheck(e){return new Zn({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:pe.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:pe.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:pe.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:pe.toString(e)})}multipleOf(e,s){return this._addCheck({kind:"multipleOf",value:e,message:pe.toString(s)})}get minValue(){let e=null;for(const s of this._def.checks)s.kind==="min"&&(e===null||s.value>e)&&(e=s.value);return e}get maxValue(){let e=null;for(const s of this._def.checks)s.kind==="max"&&(e===null||s.value<e)&&(e=s.value);return e}}Zn.create=t=>{var e;return new Zn({checks:[],typeName:me.ZodBigInt,coerce:(e=t==null?void 0:t.coerce)!==null&&e!==void 0?e:!1,..._e(t)})};class so extends Se{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==se.boolean){const n=this._getOrReturnCtx(e);return ie(n,{code:K.invalid_type,expected:se.boolean,received:n.parsedType}),be}return Ft(e.data)}}so.create=t=>new so({typeName:me.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,..._e(t)});class Sr extends Se{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==se.date){const i=this._getOrReturnCtx(e);return ie(i,{code:K.invalid_type,expected:se.date,received:i.parsedType}),be}if(isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return ie(i,{code:K.invalid_date}),be}const n=new kt;let r;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(r=this._getOrReturnCtx(e,r),ie(r,{code:K.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),n.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(r=this._getOrReturnCtx(e,r),ie(r,{code:K.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),n.dirty()):Me.assertNever(i);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Sr({...this._def,checks:[...this._def.checks,e]})}min(e,s){return this._addCheck({kind:"min",value:e.getTime(),message:pe.toString(s)})}max(e,s){return this._addCheck({kind:"max",value:e.getTime(),message:pe.toString(s)})}get minDate(){let e=null;for(const s of this._def.checks)s.kind==="min"&&(e===null||s.value>e)&&(e=s.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const s of this._def.checks)s.kind==="max"&&(e===null||s.value<e)&&(e=s.value);return e!=null?new Date(e):null}}Sr.create=t=>new Sr({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:me.ZodDate,..._e(t)});class Ia extends Se{_parse(e){if(this._getType(e)!==se.symbol){const n=this._getOrReturnCtx(e);return ie(n,{code:K.invalid_type,expected:se.symbol,received:n.parsedType}),be}return Ft(e.data)}}Ia.create=t=>new Ia({typeName:me.ZodSymbol,..._e(t)});class no extends Se{_parse(e){if(this._getType(e)!==se.undefined){const n=this._getOrReturnCtx(e);return ie(n,{code:K.invalid_type,expected:se.undefined,received:n.parsedType}),be}return Ft(e.data)}}no.create=t=>new no({typeName:me.ZodUndefined,..._e(t)});class ro extends Se{_parse(e){if(this._getType(e)!==se.null){const n=this._getOrReturnCtx(e);return ie(n,{code:K.invalid_type,expected:se.null,received:n.parsedType}),be}return Ft(e.data)}}ro.create=t=>new ro({typeName:me.ZodNull,..._e(t)});class ci extends Se{constructor(){super(...arguments),this._any=!0}_parse(e){return Ft(e.data)}}ci.create=t=>new ci({typeName:me.ZodAny,..._e(t)});class vr extends Se{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Ft(e.data)}}vr.create=t=>new vr({typeName:me.ZodUnknown,..._e(t)});class An extends Se{_parse(e){const s=this._getOrReturnCtx(e);return ie(s,{code:K.invalid_type,expected:se.never,received:s.parsedType}),be}}An.create=t=>new An({typeName:me.ZodNever,..._e(t)});class Na extends Se{_parse(e){if(this._getType(e)!==se.undefined){const n=this._getOrReturnCtx(e);return ie(n,{code:K.invalid_type,expected:se.void,received:n.parsedType}),be}return Ft(e.data)}}Na.create=t=>new Na({typeName:me.ZodVoid,..._e(t)});class Us extends Se{_parse(e){const{ctx:s,status:n}=this._processInputParams(e),r=this._def;if(s.parsedType!==se.array)return ie(s,{code:K.invalid_type,expected:se.array,received:s.parsedType}),be;if(r.exactLength!==null){const o=s.data.length>r.exactLength.value,a=s.data.length<r.exactLength.value;(o||a)&&(ie(s,{code:o?K.too_big:K.too_small,minimum:a?r.exactLength.value:void 0,maximum:o?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(r.minLength!==null&&s.data.length<r.minLength.value&&(ie(s,{code:K.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),r.maxLength!==null&&s.data.length>r.maxLength.value&&(ie(s,{code:K.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),s.common.async)return Promise.all([...s.data].map((o,a)=>r.type._parseAsync(new Xs(s,o,s.path,a)))).then(o=>kt.mergeArray(n,o));const i=[...s.data].map((o,a)=>r.type._parseSync(new Xs(s,o,s.path,a)));return kt.mergeArray(n,i)}get element(){return this._def.type}min(e,s){return new Us({...this._def,minLength:{value:e,message:pe.toString(s)}})}max(e,s){return new Us({...this._def,maxLength:{value:e,message:pe.toString(s)}})}length(e,s){return new Us({...this._def,exactLength:{value:e,message:pe.toString(s)}})}nonempty(e){return this.min(1,e)}}Us.create=(t,e)=>new Us({type:t,minLength:null,maxLength:null,exactLength:null,typeName:me.ZodArray,..._e(e)});function zr(t){if(t instanceof Xe){const e={};for(const s in t.shape){const n=t.shape[s];e[s]=En.create(zr(n))}return new Xe({...t._def,shape:()=>e})}else return t instanceof Us?new Us({...t._def,type:zr(t.element)}):t instanceof En?En.create(zr(t.unwrap())):t instanceof Nr?Nr.create(zr(t.unwrap())):t instanceof Qs?Qs.create(t.items.map(e=>zr(e))):t}class Xe extends Se{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),s=Me.objectKeys(e);return this._cached={shape:e,keys:s}}_parse(e){if(this._getType(e)!==se.object){const l=this._getOrReturnCtx(e);return ie(l,{code:K.invalid_type,expected:se.object,received:l.parsedType}),be}const{status:n,ctx:r}=this._processInputParams(e),{shape:i,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof An&&this._def.unknownKeys==="strip"))for(const l in r.data)o.includes(l)||a.push(l);const c=[];for(const l of o){const d=i[l],u=r.data[l];c.push({key:{status:"valid",value:l},value:d._parse(new Xs(r,u,r.path,l)),alwaysSet:l in r.data})}if(this._def.catchall instanceof An){const l=this._def.unknownKeys;if(l==="passthrough")for(const d of a)c.push({key:{status:"valid",value:d},value:{status:"valid",value:r.data[d]}});else if(l==="strict")a.length>0&&(ie(r,{code:K.unrecognized_keys,keys:a}),n.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const l=this._def.catchall;for(const d of a){const u=r.data[d];c.push({key:{status:"valid",value:d},value:l._parse(new Xs(r,u,r.path,d)),alwaysSet:d in r.data})}}return r.common.async?Promise.resolve().then(async()=>{const l=[];for(const d of c){const u=await d.key;l.push({key:u,value:await d.value,alwaysSet:d.alwaysSet})}return l}).then(l=>kt.mergeObjectSync(n,l)):kt.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return pe.errToObj,new Xe({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(s,n)=>{var r,i,o,a;const c=(o=(i=(r=this._def).errorMap)===null||i===void 0?void 0:i.call(r,s,n).message)!==null&&o!==void 0?o:n.defaultError;return s.code==="unrecognized_keys"?{message:(a=pe.errToObj(e).message)!==null&&a!==void 0?a:c}:{message:c}}}:{}})}strip(){return new Xe({...this._def,unknownKeys:"strip"})}passthrough(){return new Xe({...this._def,unknownKeys:"passthrough"})}extend(e){return new Xe({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Xe({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:me.ZodObject})}setKey(e,s){return this.augment({[e]:s})}catchall(e){return new Xe({...this._def,catchall:e})}pick(e){const s={};return Me.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(s[n]=this.shape[n])}),new Xe({...this._def,shape:()=>s})}omit(e){const s={};return Me.objectKeys(this.shape).forEach(n=>{e[n]||(s[n]=this.shape[n])}),new Xe({...this._def,shape:()=>s})}deepPartial(){return zr(this)}partial(e){const s={};return Me.objectKeys(this.shape).forEach(n=>{const r=this.shape[n];e&&!e[n]?s[n]=r:s[n]=r.optional()}),new Xe({...this._def,shape:()=>s})}required(e){const s={};return Me.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])s[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof En;)i=i._def.innerType;s[n]=i}}),new Xe({...this._def,shape:()=>s})}keyof(){return Tf(Me.objectKeys(this.shape))}}Xe.create=(t,e)=>new Xe({shape:()=>t,unknownKeys:"strip",catchall:An.create(),typeName:me.ZodObject,..._e(e)});Xe.strictCreate=(t,e)=>new Xe({shape:()=>t,unknownKeys:"strict",catchall:An.create(),typeName:me.ZodObject,..._e(e)});Xe.lazycreate=(t,e)=>new Xe({shape:t,unknownKeys:"strip",catchall:An.create(),typeName:me.ZodObject,..._e(e)});class io extends Se{_parse(e){const{ctx:s}=this._processInputParams(e),n=this._def.options;function r(i){for(const a of i)if(a.result.status==="valid")return a.result;for(const a of i)if(a.result.status==="dirty")return s.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(a=>new ks(a.ctx.common.issues));return ie(s,{code:K.invalid_union,unionErrors:o}),be}if(s.common.async)return Promise.all(n.map(async i=>{const o={...s,common:{...s.common,issues:[]},parent:null};return{result:await i._parseAsync({data:s.data,path:s.path,parent:o}),ctx:o}})).then(r);{let i;const o=[];for(const c of n){const l={...s,common:{...s.common,issues:[]},parent:null},d=c._parseSync({data:s.data,path:s.path,parent:l});if(d.status==="valid")return d;d.status==="dirty"&&!i&&(i={result:d,ctx:l}),l.common.issues.length&&o.push(l.common.issues)}if(i)return s.common.issues.push(...i.ctx.common.issues),i.result;const a=o.map(c=>new ks(c));return ie(s,{code:K.invalid_union,unionErrors:a}),be}}get options(){return this._def.options}}io.create=(t,e)=>new io({options:t,typeName:me.ZodUnion,..._e(e)});const ua=t=>t instanceof co?ua(t.schema):t instanceof Ds?ua(t.innerType()):t instanceof lo?[t.value]:t instanceof Jn?t.options:t instanceof uo?Object.keys(t.enum):t instanceof ho?ua(t._def.innerType):t instanceof no?[void 0]:t instanceof ro?[null]:null;class Xa extends Se{_parse(e){const{ctx:s}=this._processInputParams(e);if(s.parsedType!==se.object)return ie(s,{code:K.invalid_type,expected:se.object,received:s.parsedType}),be;const n=this.discriminator,r=s.data[n],i=this.optionsMap.get(r);return i?s.common.async?i._parseAsync({data:s.data,path:s.path,parent:s}):i._parseSync({data:s.data,path:s.path,parent:s}):(ie(s,{code:K.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),be)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,s,n){const r=new Map;for(const i of s){const o=ua(i.shape[e]);if(!o)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const a of o){if(r.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);r.set(a,i)}}return new Xa({typeName:me.ZodDiscriminatedUnion,discriminator:e,options:s,optionsMap:r,..._e(n)})}}function _l(t,e){const s=Mn(t),n=Mn(e);if(t===e)return{valid:!0,data:t};if(s===se.object&&n===se.object){const r=Me.objectKeys(e),i=Me.objectKeys(t).filter(a=>r.indexOf(a)!==-1),o={...t,...e};for(const a of i){const c=_l(t[a],e[a]);if(!c.valid)return{valid:!1};o[a]=c.data}return{valid:!0,data:o}}else if(s===se.array&&n===se.array){if(t.length!==e.length)return{valid:!1};const r=[];for(let i=0;i<t.length;i++){const o=t[i],a=e[i],c=_l(o,a);if(!c.valid)return{valid:!1};r.push(c.data)}return{valid:!0,data:r}}else return s===se.date&&n===se.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class oo extends Se{_parse(e){const{status:s,ctx:n}=this._processInputParams(e),r=(i,o)=>{if(vl(i)||vl(o))return be;const a=_l(i.value,o.value);return a.valid?((Cl(i)||Cl(o))&&s.dirty(),{status:s.value,value:a.data}):(ie(n,{code:K.invalid_intersection_types}),be)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([i,o])=>r(i,o)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}oo.create=(t,e,s)=>new oo({left:t,right:e,typeName:me.ZodIntersection,..._e(s)});class Qs extends Se{_parse(e){const{status:s,ctx:n}=this._processInputParams(e);if(n.parsedType!==se.array)return ie(n,{code:K.invalid_type,expected:se.array,received:n.parsedType}),be;if(n.data.length<this._def.items.length)return ie(n,{code:K.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),be;!this._def.rest&&n.data.length>this._def.items.length&&(ie(n,{code:K.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),s.dirty());const i=[...n.data].map((o,a)=>{const c=this._def.items[a]||this._def.rest;return c?c._parse(new Xs(n,o,n.path,a)):null}).filter(o=>!!o);return n.common.async?Promise.all(i).then(o=>kt.mergeArray(s,o)):kt.mergeArray(s,i)}get items(){return this._def.items}rest(e){return new Qs({...this._def,rest:e})}}Qs.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Qs({items:t,typeName:me.ZodTuple,rest:null,..._e(e)})};class ao extends Se{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:s,ctx:n}=this._processInputParams(e);if(n.parsedType!==se.object)return ie(n,{code:K.invalid_type,expected:se.object,received:n.parsedType}),be;const r=[],i=this._def.keyType,o=this._def.valueType;for(const a in n.data)r.push({key:i._parse(new Xs(n,a,n.path,a)),value:o._parse(new Xs(n,n.data[a],n.path,a))});return n.common.async?kt.mergeObjectAsync(s,r):kt.mergeObjectSync(s,r)}get element(){return this._def.valueType}static create(e,s,n){return s instanceof Se?new ao({keyType:e,valueType:s,typeName:me.ZodRecord,..._e(n)}):new ao({keyType:xs.create(),valueType:e,typeName:me.ZodRecord,..._e(s)})}}class Ta extends Se{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:s,ctx:n}=this._processInputParams(e);if(n.parsedType!==se.map)return ie(n,{code:K.invalid_type,expected:se.map,received:n.parsedType}),be;const r=this._def.keyType,i=this._def.valueType,o=[...n.data.entries()].map(([a,c],l)=>({key:r._parse(new Xs(n,a,n.path,[l,"key"])),value:i._parse(new Xs(n,c,n.path,[l,"value"]))}));if(n.common.async){const a=new Map;return Promise.resolve().then(async()=>{for(const c of o){const l=await c.key,d=await c.value;if(l.status==="aborted"||d.status==="aborted")return be;(l.status==="dirty"||d.status==="dirty")&&s.dirty(),a.set(l.value,d.value)}return{status:s.value,value:a}})}else{const a=new Map;for(const c of o){const l=c.key,d=c.value;if(l.status==="aborted"||d.status==="aborted")return be;(l.status==="dirty"||d.status==="dirty")&&s.dirty(),a.set(l.value,d.value)}return{status:s.value,value:a}}}}Ta.create=(t,e,s)=>new Ta({valueType:e,keyType:t,typeName:me.ZodMap,..._e(s)});class Ir extends Se{_parse(e){const{status:s,ctx:n}=this._processInputParams(e);if(n.parsedType!==se.set)return ie(n,{code:K.invalid_type,expected:se.set,received:n.parsedType}),be;const r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&(ie(n,{code:K.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),s.dirty()),r.maxSize!==null&&n.data.size>r.maxSize.value&&(ie(n,{code:K.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),s.dirty());const i=this._def.valueType;function o(c){const l=new Set;for(const d of c){if(d.status==="aborted")return be;d.status==="dirty"&&s.dirty(),l.add(d.value)}return{status:s.value,value:l}}const a=[...n.data.values()].map((c,l)=>i._parse(new Xs(n,c,n.path,l)));return n.common.async?Promise.all(a).then(c=>o(c)):o(a)}min(e,s){return new Ir({...this._def,minSize:{value:e,message:pe.toString(s)}})}max(e,s){return new Ir({...this._def,maxSize:{value:e,message:pe.toString(s)}})}size(e,s){return this.min(e,s).max(e,s)}nonempty(e){return this.min(1,e)}}Ir.create=(t,e)=>new Ir({valueType:t,minSize:null,maxSize:null,typeName:me.ZodSet,..._e(e)});class ei extends Se{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:s}=this._processInputParams(e);if(s.parsedType!==se.function)return ie(s,{code:K.invalid_type,expected:se.function,received:s.parsedType}),be;function n(a,c){return Aa({data:a,path:s.path,errorMaps:[s.common.contextualErrorMap,s.schemaErrorMap,_a(),eo].filter(l=>!!l),issueData:{code:K.invalid_arguments,argumentsError:c}})}function r(a,c){return Aa({data:a,path:s.path,errorMaps:[s.common.contextualErrorMap,s.schemaErrorMap,_a(),eo].filter(l=>!!l),issueData:{code:K.invalid_return_type,returnTypeError:c}})}const i={errorMap:s.common.contextualErrorMap},o=s.data;if(this._def.returns instanceof li){const a=this;return Ft(async function(...c){const l=new ks([]),d=await a._def.args.parseAsync(c,i).catch(p=>{throw l.addIssue(n(c,p)),l}),u=await Reflect.apply(o,this,d);return await a._def.returns._def.type.parseAsync(u,i).catch(p=>{throw l.addIssue(r(u,p)),l})})}else{const a=this;return Ft(function(...c){const l=a._def.args.safeParse(c,i);if(!l.success)throw new ks([n(c,l.error)]);const d=Reflect.apply(o,this,l.data),u=a._def.returns.safeParse(d,i);if(!u.success)throw new ks([r(d,u.error)]);return u.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new ei({...this._def,args:Qs.create(e).rest(vr.create())})}returns(e){return new ei({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,s,n){return new ei({args:e||Qs.create([]).rest(vr.create()),returns:s||vr.create(),typeName:me.ZodFunction,..._e(n)})}}class co extends Se{get schema(){return this._def.getter()}_parse(e){const{ctx:s}=this._processInputParams(e);return this._def.getter()._parse({data:s.data,path:s.path,parent:s})}}co.create=(t,e)=>new co({getter:t,typeName:me.ZodLazy,..._e(e)});class lo extends Se{_parse(e){if(e.data!==this._def.value){const s=this._getOrReturnCtx(e);return ie(s,{received:s.data,code:K.invalid_literal,expected:this._def.value}),be}return{status:"valid",value:e.data}}get value(){return this._def.value}}lo.create=(t,e)=>new lo({value:t,typeName:me.ZodLiteral,..._e(e)});function Tf(t,e){return new Jn({values:t,typeName:me.ZodEnum,..._e(e)})}class Jn extends Se{_parse(e){if(typeof e.data!="string"){const s=this._getOrReturnCtx(e),n=this._def.values;return ie(s,{expected:Me.joinValues(n),received:s.parsedType,code:K.invalid_type}),be}if(this._def.values.indexOf(e.data)===-1){const s=this._getOrReturnCtx(e),n=this._def.values;return ie(s,{received:s.data,code:K.invalid_enum_value,options:n}),be}return Ft(e.data)}get options(){return this._def.values}get enum(){const e={};for(const s of this._def.values)e[s]=s;return e}get Values(){const e={};for(const s of this._def.values)e[s]=s;return e}get Enum(){const e={};for(const s of this._def.values)e[s]=s;return e}extract(e){return Jn.create(e)}exclude(e){return Jn.create(this.options.filter(s=>!e.includes(s)))}}Jn.create=Tf;class uo extends Se{_parse(e){const s=Me.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==se.string&&n.parsedType!==se.number){const r=Me.objectValues(s);return ie(n,{expected:Me.joinValues(r),received:n.parsedType,code:K.invalid_type}),be}if(s.indexOf(e.data)===-1){const r=Me.objectValues(s);return ie(n,{received:n.data,code:K.invalid_enum_value,options:r}),be}return Ft(e.data)}get enum(){return this._def.values}}uo.create=(t,e)=>new uo({values:t,typeName:me.ZodNativeEnum,..._e(e)});class li extends Se{unwrap(){return this._def.type}_parse(e){const{ctx:s}=this._processInputParams(e);if(s.parsedType!==se.promise&&s.common.async===!1)return ie(s,{code:K.invalid_type,expected:se.promise,received:s.parsedType}),be;const n=s.parsedType===se.promise?s.data:Promise.resolve(s.data);return Ft(n.then(r=>this._def.type.parseAsync(r,{path:s.path,errorMap:s.common.contextualErrorMap})))}}li.create=(t,e)=>new li({type:t,typeName:me.ZodPromise,..._e(e)});class Ds extends Se{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===me.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:s,ctx:n}=this._processInputParams(e),r=this._def.effect||null,i={addIssue:o=>{ie(n,o),o.fatal?s.abort():s.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),r.type==="preprocess"){const o=r.transform(n.data,i);return n.common.issues.length?{status:"dirty",value:n.data}:n.common.async?Promise.resolve(o).then(a=>this._def.schema._parseAsync({data:a,path:n.path,parent:n})):this._def.schema._parseSync({data:o,path:n.path,parent:n})}if(r.type==="refinement"){const o=a=>{const c=r.refinement(a,i);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(n.common.async===!1){const a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?be:(a.status==="dirty"&&s.dirty(),o(a.value),{status:s.value,value:a.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>a.status==="aborted"?be:(a.status==="dirty"&&s.dirty(),o(a.value).then(()=>({status:s.value,value:a.value}))))}if(r.type==="transform")if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!to(o))return o;const a=r.transform(o.value,i);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:s.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>to(o)?Promise.resolve(r.transform(o.value,i)).then(a=>({status:s.value,value:a})):o);Me.assertNever(r)}}Ds.create=(t,e,s)=>new Ds({schema:t,typeName:me.ZodEffects,effect:e,..._e(s)});Ds.createWithPreprocess=(t,e,s)=>new Ds({schema:e,effect:{type:"preprocess",transform:t},typeName:me.ZodEffects,..._e(s)});class En extends Se{_parse(e){return this._getType(e)===se.undefined?Ft(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}En.create=(t,e)=>new En({innerType:t,typeName:me.ZodOptional,..._e(e)});class Nr extends Se{_parse(e){return this._getType(e)===se.null?Ft(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Nr.create=(t,e)=>new Nr({innerType:t,typeName:me.ZodNullable,..._e(e)});class ho extends Se{_parse(e){const{ctx:s}=this._processInputParams(e);let n=s.data;return s.parsedType===se.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:s.path,parent:s})}removeDefault(){return this._def.innerType}}ho.create=(t,e)=>new ho({innerType:t,typeName:me.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,..._e(e)});class Ra extends Se{_parse(e){const{ctx:s}=this._processInputParams(e),n={...s,common:{...s.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Sa(r)?r.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new ks(n.common.issues)},input:n.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new ks(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}Ra.create=(t,e)=>new Ra({innerType:t,typeName:me.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,..._e(e)});class Oa extends Se{_parse(e){if(this._getType(e)!==se.nan){const n=this._getOrReturnCtx(e);return ie(n,{code:K.invalid_type,expected:se.nan,received:n.parsedType}),be}return{status:"valid",value:e.data}}}Oa.create=t=>new Oa({typeName:me.ZodNaN,..._e(t)});const kw=Symbol("zod_brand");class Rf extends Se{_parse(e){const{ctx:s}=this._processInputParams(e),n=s.data;return this._def.type._parse({data:n,path:s.path,parent:s})}unwrap(){return this._def.type}}class Ao extends Se{_parse(e){const{status:s,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?be:i.status==="dirty"?(s.dirty(),Nf(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})})();{const r=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return r.status==="aborted"?be:r.status==="dirty"?(s.dirty(),{status:"dirty",value:r.value}):this._def.out._parseSync({data:r.value,path:n.path,parent:n})}}static create(e,s){return new Ao({in:e,out:s,typeName:me.ZodPipeline})}}class Pa extends Se{_parse(e){const s=this._def.innerType._parse(e);return to(s)&&(s.value=Object.freeze(s.value)),s}}Pa.create=(t,e)=>new Pa({innerType:t,typeName:me.ZodReadonly,..._e(e)});const Of=(t,e={},s)=>t?ci.create().superRefine((n,r)=>{var i,o;if(!t(n)){const a=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,c=(o=(i=a.fatal)!==null&&i!==void 0?i:s)!==null&&o!==void 0?o:!0,l=typeof a=="string"?{message:a}:a;r.addIssue({code:"custom",...l,fatal:c})}}):ci.create(),Uw={object:Xe.lazycreate};var me;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(me||(me={}));const $w=(t,e={message:`Input not instance of ${t.name}`})=>Of(s=>s instanceof t,e),Pf=xs.create,xf=Yn.create,Dw=Oa.create,Lw=Zn.create,kf=so.create,Mw=Sr.create,Bw=Ia.create,jw=no.create,Fw=ro.create,qw=ci.create,Ww=vr.create,Hw=An.create,Vw=Na.create,zw=Us.create,Kw=Xe.create,Gw=Xe.strictCreate,Yw=io.create,Zw=Xa.create,Jw=oo.create,Xw=Qs.create,Qw=ao.create,eE=Ta.create,tE=Ir.create,sE=ei.create,nE=co.create,rE=lo.create,iE=Jn.create,oE=uo.create,aE=li.create,Ru=Ds.create,cE=En.create,lE=Nr.create,dE=Ds.createWithPreprocess,uE=Ao.create,hE=()=>Pf().optional(),pE=()=>xf().optional(),fE=()=>kf().optional(),gE={string:(t=>xs.create({...t,coerce:!0})),number:(t=>Yn.create({...t,coerce:!0})),boolean:(t=>so.create({...t,coerce:!0})),bigint:(t=>Zn.create({...t,coerce:!0})),date:(t=>Sr.create({...t,coerce:!0}))},mE=be;var m=Object.freeze({__proto__:null,defaultErrorMap:eo,setErrorMap:bw,getErrorMap:_a,makeIssue:Aa,EMPTY_PATH:vw,addIssueToContext:ie,ParseStatus:kt,INVALID:be,DIRTY:Nf,OK:Ft,isAborted:vl,isDirty:Cl,isValid:to,isAsync:Sa,get util(){return Me},get objectUtil(){return bl},ZodParsedType:se,getParsedType:Mn,ZodType:Se,ZodString:xs,ZodNumber:Yn,ZodBigInt:Zn,ZodBoolean:so,ZodDate:Sr,ZodSymbol:Ia,ZodUndefined:no,ZodNull:ro,ZodAny:ci,ZodUnknown:vr,ZodNever:An,ZodVoid:Na,ZodArray:Us,ZodObject:Xe,ZodUnion:io,ZodDiscriminatedUnion:Xa,ZodIntersection:oo,ZodTuple:Qs,ZodRecord:ao,ZodMap:Ta,ZodSet:Ir,ZodFunction:ei,ZodLazy:co,ZodLiteral:lo,ZodEnum:Jn,ZodNativeEnum:uo,ZodPromise:li,ZodEffects:Ds,ZodTransformer:Ds,ZodOptional:En,ZodNullable:Nr,ZodDefault:ho,ZodCatch:Ra,ZodNaN:Oa,BRAND:kw,ZodBranded:Rf,ZodPipeline:Ao,ZodReadonly:Pa,custom:Of,Schema:Se,ZodSchema:Se,late:Uw,get ZodFirstPartyTypeKind(){return me},coerce:gE,any:qw,array:zw,bigint:Lw,boolean:kf,date:Mw,discriminatedUnion:Zw,effect:Ru,enum:iE,function:sE,instanceof:$w,intersection:Jw,lazy:nE,literal:rE,map:eE,nan:Dw,nativeEnum:oE,never:Hw,null:Fw,nullable:lE,number:xf,object:Kw,oboolean:fE,onumber:pE,optional:cE,ostring:hE,pipeline:uE,preprocess:dE,promise:aE,record:Qw,set:tE,strictObject:Gw,string:Pf,symbol:Bw,transformer:Ru,tuple:Xw,undefined:jw,union:Yw,unknown:Ww,void:Vw,NEVER:mE,ZodIssueCode:K,quotelessJson:Ew,ZodError:ks});const Qe=m.object({message:m.string()});function ne(t){return m.literal(oe[t])}const Qa=m.object({serializedMessage:m.string().optional(),accountAddress:m.string(),chainId:m.string(),notBefore:m.string().optional(),domain:m.string(),uri:m.string(),version:m.string(),nonce:m.string(),statement:m.string().optional(),resources:m.array(m.string()).optional(),requestId:m.string().optional(),issuedAt:m.string().optional(),expirationTime:m.string().optional()});m.object({accessList:m.array(m.string()),blockHash:m.string().nullable(),blockNumber:m.string().nullable(),chainId:m.string().or(m.number()),from:m.string(),gas:m.string(),hash:m.string(),input:m.string().nullable(),maxFeePerGas:m.string(),maxPriorityFeePerGas:m.string(),nonce:m.string(),r:m.string(),s:m.string(),to:m.string(),transactionIndex:m.string().nullable(),type:m.string(),v:m.string(),value:m.string()});const yE=m.object({chainId:m.string().or(m.number()),rpcUrl:m.optional(m.string())}),wE=m.object({email:m.string().email()}),EE=m.object({otp:m.string()}),bE=m.object({uri:m.string(),preferredAccountType:m.optional(m.string()),chainId:m.optional(m.string().or(m.number())),siwxMessage:m.optional(Qa),rpcUrl:m.optional(m.string())}),vE=m.object({chainId:m.optional(m.string().or(m.number())),preferredAccountType:m.optional(m.string()),socialUri:m.optional(m.string()),siwxMessage:m.optional(Qa),rpcUrl:m.optional(m.string())}),CE=m.object({provider:m.enum(["google","github","apple","facebook","x","discord"])}),_E=m.object({email:m.string().email()}),AE=m.object({otp:m.string()}),SE=m.object({otp:m.string()}),IE=m.object({themeMode:m.optional(m.enum(["light","dark"])),themeVariables:m.optional(m.record(m.string(),m.string().or(m.number()))),w3mThemeVariables:m.optional(m.record(m.string(),m.string()))}),NE=m.object({metadata:m.object({name:m.string(),description:m.string(),url:m.string(),icons:m.array(m.string())}).optional(),sdkVersion:m.string().optional(),sdkType:m.string().optional(),projectId:m.string()}),TE=m.object({type:m.string()}),RE=m.object({action:m.enum(["VERIFY_DEVICE","VERIFY_OTP","CONNECT"])}),OE=m.object({url:m.string()}),PE=m.object({userName:m.string()}),xE=m.object({email:m.string().optional().nullable(),address:m.string(),chainId:m.string().or(m.number()),accounts:m.array(m.object({address:m.string(),type:m.enum([tt.ACCOUNT_TYPES.EOA,tt.ACCOUNT_TYPES.SMART_ACCOUNT])})).optional(),userName:m.string().optional().nullable(),preferredAccountType:m.optional(m.string()),signature:m.string().optional(),message:m.string().optional(),siwxMessage:m.optional(Qa)}),kE=m.object({action:m.enum(["VERIFY_PRIMARY_OTP","VERIFY_SECONDARY_OTP"])}),UE=m.object({email:m.string().email().optional().nullable(),address:m.string(),chainId:m.string().or(m.number()),smartAccountDeployed:m.optional(m.boolean()),accounts:m.array(m.object({address:m.string(),type:m.enum([tt.ACCOUNT_TYPES.EOA,tt.ACCOUNT_TYPES.SMART_ACCOUNT])})).optional(),preferredAccountType:m.optional(m.string()),signature:m.string().optional(),message:m.string().optional(),siwxMessage:m.optional(Qa)}),$E=m.object({uri:m.string()}),DE=m.object({isConnected:m.boolean()}),LE=m.object({chainId:m.string().or(m.number())}),ME=m.object({chainId:m.string().or(m.number())}),BE=m.object({newEmail:m.string().email()}),jE=m.object({smartAccountEnabledNetworks:m.array(m.number())});m.object({address:m.string(),isDeployed:m.boolean()});const FE=m.object({version:m.string().optional()}),qE=m.object({type:m.string(),address:m.string()}),WE=m.any(),HE=m.object({method:m.literal("eth_accounts")}),VE=m.object({method:m.literal("eth_blockNumber")}),zE=m.object({method:m.literal("eth_call"),params:m.array(m.any())}),KE=m.object({method:m.literal("eth_chainId")}),GE=m.object({method:m.literal("eth_estimateGas"),params:m.array(m.any())}),YE=m.object({method:m.literal("eth_feeHistory"),params:m.array(m.any())}),ZE=m.object({method:m.literal("eth_gasPrice")}),JE=m.object({method:m.literal("eth_getAccount"),params:m.array(m.any())}),XE=m.object({method:m.literal("eth_getBalance"),params:m.array(m.any())}),QE=m.object({method:m.literal("eth_getBlockByHash"),params:m.array(m.any())}),eb=m.object({method:m.literal("eth_getBlockByNumber"),params:m.array(m.any())}),tb=m.object({method:m.literal("eth_getBlockReceipts"),params:m.array(m.any())}),sb=m.object({method:m.literal("eth_getBlockTransactionCountByHash"),params:m.array(m.any())}),nb=m.object({method:m.literal("eth_getBlockTransactionCountByNumber"),params:m.array(m.any())}),rb=m.object({method:m.literal("eth_getCode"),params:m.array(m.any())}),ib=m.object({method:m.literal("eth_getFilterChanges"),params:m.array(m.any())}),ob=m.object({method:m.literal("eth_getFilterLogs"),params:m.array(m.any())}),ab=m.object({method:m.literal("eth_getLogs"),params:m.array(m.any())}),cb=m.object({method:m.literal("eth_getProof"),params:m.array(m.any())}),lb=m.object({method:m.literal("eth_getStorageAt"),params:m.array(m.any())}),db=m.object({method:m.literal("eth_getTransactionByBlockHashAndIndex"),params:m.array(m.any())}),ub=m.object({method:m.literal("eth_getTransactionByBlockNumberAndIndex"),params:m.array(m.any())}),hb=m.object({method:m.literal("eth_getTransactionByHash"),params:m.array(m.any())}),pb=m.object({method:m.literal("eth_getTransactionCount"),params:m.array(m.any())}),fb=m.object({method:m.literal("eth_getTransactionReceipt"),params:m.array(m.any())}),gb=m.object({method:m.literal("eth_getUncleCountByBlockHash"),params:m.array(m.any())}),mb=m.object({method:m.literal("eth_getUncleCountByBlockNumber"),params:m.array(m.any())}),yb=m.object({method:m.literal("eth_maxPriorityFeePerGas")}),wb=m.object({method:m.literal("eth_newBlockFilter")}),Eb=m.object({method:m.literal("eth_newFilter"),params:m.array(m.any())}),bb=m.object({method:m.literal("eth_newPendingTransactionFilter")}),vb=m.object({method:m.literal("eth_sendRawTransaction"),params:m.array(m.any())}),Cb=m.object({method:m.literal("eth_syncing"),params:m.array(m.any())}),_b=m.object({method:m.literal("eth_uninstallFilter"),params:m.array(m.any())}),Ou=m.object({method:m.literal("personal_sign"),params:m.array(m.any())}),Ab=m.object({method:m.literal("eth_signTypedData_v4"),params:m.array(m.any())}),Sb=m.object({method:m.literal("eth_sendTransaction"),params:m.array(m.any())}),Ib=m.object({method:m.literal("solana_signMessage"),params:m.object({message:m.string(),pubkey:m.string()})}),Nb=m.object({method:m.literal("solana_signTransaction"),params:m.object({transaction:m.string()})}),Tb=m.object({method:m.literal("solana_signAllTransactions"),params:m.object({transactions:m.array(m.string())})}),Rb=m.object({method:m.literal("solana_signAndSendTransaction"),params:m.object({transaction:m.string(),options:m.object({skipPreflight:m.boolean().optional(),preflightCommitment:m.enum(["processed","confirmed","finalized","recent","single","singleGossip","root","max"]).optional(),maxRetries:m.number().optional(),minContextSlot:m.number().optional()}).optional()})}),Ob=m.object({method:m.literal("wallet_sendCalls"),params:m.array(m.object({chainId:m.string().or(m.number()).optional(),from:m.string().optional(),version:m.string().optional(),capabilities:m.any().optional(),calls:m.array(m.object({to:m.string().startsWith("0x"),data:m.string().startsWith("0x").optional(),value:m.string().optional()}))}))}),Pb=m.object({method:m.literal("wallet_getCallsStatus"),params:m.array(m.string())}),xb=m.object({method:m.literal("wallet_getCapabilities"),params:m.array(m.string().or(m.number()).optional()).optional()}),kb=m.object({method:m.literal("wallet_grantPermissions"),params:m.array(m.any())}),Ub=m.object({method:m.literal("wallet_revokePermissions"),params:m.any()}),$b=m.object({method:m.literal("wallet_getAssets"),params:m.any()}),Pu=m.object({token:m.string()}),re=m.object({id:m.string().optional()}),bc={appEvent:re.extend({type:ne("APP_SWITCH_NETWORK"),payload:yE}).or(re.extend({type:ne("APP_CONNECT_EMAIL"),payload:wE})).or(re.extend({type:ne("APP_CONNECT_DEVICE")})).or(re.extend({type:ne("APP_CONNECT_OTP"),payload:EE})).or(re.extend({type:ne("APP_CONNECT_SOCIAL"),payload:bE})).or(re.extend({type:ne("APP_GET_FARCASTER_URI")})).or(re.extend({type:ne("APP_CONNECT_FARCASTER")})).or(re.extend({type:ne("APP_GET_USER"),payload:m.optional(vE)})).or(re.extend({type:ne("APP_GET_SOCIAL_REDIRECT_URI"),payload:CE})).or(re.extend({type:ne("APP_SIGN_OUT")})).or(re.extend({type:ne("APP_IS_CONNECTED"),payload:m.optional(Pu)})).or(re.extend({type:ne("APP_GET_CHAIN_ID")})).or(re.extend({type:ne("APP_GET_SMART_ACCOUNT_ENABLED_NETWORKS")})).or(re.extend({type:ne("APP_INIT_SMART_ACCOUNT")})).or(re.extend({type:ne("APP_SET_PREFERRED_ACCOUNT"),payload:TE})).or(re.extend({type:ne("APP_RPC_REQUEST"),payload:Ou.or($b).or(HE).or(VE).or(zE).or(KE).or(GE).or(YE).or(ZE).or(JE).or(XE).or(QE).or(eb).or(tb).or(sb).or(nb).or(rb).or(ib).or(ob).or(ab).or(cb).or(lb).or(db).or(ub).or(hb).or(pb).or(fb).or(gb).or(mb).or(yb).or(wb).or(Eb).or(bb).or(vb).or(Cb).or(_b).or(Ou).or(Ab).or(Sb).or(Ib).or(Nb).or(Tb).or(Rb).or(Pb).or(Ob).or(xb).or(kb).or(Ub).and(m.object({chainId:m.string().or(m.number()).optional(),chainNamespace:m.enum(["eip155","solana","polkadot","bip122","cosmos"]).optional(),rpcUrl:m.string().optional()}))})).or(re.extend({type:ne("APP_UPDATE_EMAIL"),payload:_E})).or(re.extend({type:ne("APP_UPDATE_EMAIL_PRIMARY_OTP"),payload:AE})).or(re.extend({type:ne("APP_UPDATE_EMAIL_SECONDARY_OTP"),payload:SE})).or(re.extend({type:ne("APP_SYNC_THEME"),payload:IE})).or(re.extend({type:ne("APP_SYNC_DAPP_DATA"),payload:NE})).or(re.extend({type:ne("APP_RELOAD")})).or(re.extend({type:ne("APP_RPC_ABORT")})),frameEvent:re.extend({type:ne("FRAME_SWITCH_NETWORK_ERROR"),payload:Qe}).or(re.extend({type:ne("FRAME_SWITCH_NETWORK_SUCCESS"),payload:ME})).or(re.extend({type:ne("FRAME_CONNECT_EMAIL_SUCCESS"),payload:RE})).or(re.extend({type:ne("FRAME_CONNECT_EMAIL_ERROR"),payload:Qe})).or(re.extend({type:ne("FRAME_GET_FARCASTER_URI_SUCCESS"),payload:OE})).or(re.extend({type:ne("FRAME_GET_FARCASTER_URI_ERROR"),payload:Qe})).or(re.extend({type:ne("FRAME_CONNECT_FARCASTER_SUCCESS"),payload:PE})).or(re.extend({type:ne("FRAME_CONNECT_FARCASTER_ERROR"),payload:Qe})).or(re.extend({type:ne("FRAME_CONNECT_OTP_ERROR"),payload:Qe})).or(re.extend({type:ne("FRAME_CONNECT_OTP_SUCCESS")})).or(re.extend({type:ne("FRAME_CONNECT_DEVICE_ERROR"),payload:Qe})).or(re.extend({type:ne("FRAME_CONNECT_DEVICE_SUCCESS")})).or(re.extend({type:ne("FRAME_CONNECT_SOCIAL_SUCCESS"),payload:xE})).or(re.extend({type:ne("FRAME_CONNECT_SOCIAL_ERROR"),payload:Qe})).or(re.extend({type:ne("FRAME_GET_USER_ERROR"),payload:Qe})).or(re.extend({type:ne("FRAME_GET_USER_SUCCESS"),payload:UE})).or(re.extend({type:ne("FRAME_GET_SOCIAL_REDIRECT_URI_ERROR"),payload:Qe})).or(re.extend({type:ne("FRAME_GET_SOCIAL_REDIRECT_URI_SUCCESS"),payload:$E})).or(re.extend({type:ne("FRAME_SIGN_OUT_ERROR"),payload:Qe})).or(re.extend({type:ne("FRAME_SIGN_OUT_SUCCESS")})).or(re.extend({type:ne("FRAME_IS_CONNECTED_ERROR"),payload:Qe})).or(re.extend({type:ne("FRAME_IS_CONNECTED_SUCCESS"),payload:DE})).or(re.extend({type:ne("FRAME_GET_CHAIN_ID_ERROR"),payload:Qe})).or(re.extend({type:ne("FRAME_GET_CHAIN_ID_SUCCESS"),payload:LE})).or(re.extend({type:ne("FRAME_RPC_REQUEST_ERROR"),payload:Qe})).or(re.extend({type:ne("FRAME_RPC_REQUEST_SUCCESS"),payload:WE})).or(re.extend({type:ne("FRAME_SESSION_UPDATE"),payload:Pu})).or(re.extend({type:ne("FRAME_UPDATE_EMAIL_ERROR"),payload:Qe})).or(re.extend({type:ne("FRAME_UPDATE_EMAIL_SUCCESS"),payload:kE})).or(re.extend({type:ne("FRAME_UPDATE_EMAIL_PRIMARY_OTP_ERROR"),payload:Qe})).or(re.extend({type:ne("FRAME_UPDATE_EMAIL_PRIMARY_OTP_SUCCESS")})).or(re.extend({type:ne("FRAME_UPDATE_EMAIL_SECONDARY_OTP_ERROR"),payload:Qe})).or(re.extend({type:ne("FRAME_UPDATE_EMAIL_SECONDARY_OTP_SUCCESS"),payload:BE})).or(re.extend({type:ne("FRAME_SYNC_THEME_ERROR"),payload:Qe})).or(re.extend({type:ne("FRAME_SYNC_THEME_SUCCESS")})).or(re.extend({type:ne("FRAME_SYNC_DAPP_DATA_ERROR"),payload:Qe})).or(re.extend({type:ne("FRAME_SYNC_DAPP_DATA_SUCCESS")})).or(re.extend({type:ne("FRAME_GET_SMART_ACCOUNT_ENABLED_NETWORKS_SUCCESS"),payload:jE})).or(re.extend({type:ne("FRAME_GET_SMART_ACCOUNT_ENABLED_NETWORKS_ERROR"),payload:Qe})).or(re.extend({type:ne("FRAME_INIT_SMART_ACCOUNT_ERROR"),payload:Qe})).or(re.extend({type:ne("FRAME_SET_PREFERRED_ACCOUNT_SUCCESS"),payload:qE})).or(re.extend({type:ne("FRAME_SET_PREFERRED_ACCOUNT_ERROR"),payload:Qe})).or(re.extend({type:ne("FRAME_READY"),payload:FE})).or(re.extend({type:ne("FRAME_RELOAD_ERROR"),payload:Qe})).or(re.extend({type:ne("FRAME_RELOAD_SUCCESS")}))};function vc(t,e={}){var s;return typeof(e==null?void 0:e.type)=="string"&&((s=e==null?void 0:e.type)==null?void 0:s.includes(t))}function Db({projectId:t,chainId:e,enableLogger:s,rpcUrl:n=U.BLOCKCHAIN_API_RPC_URL,enableCloudAuthAccount:r=!1}){const i=new URL(mw);i.searchParams.set("projectId",t),i.searchParams.set("chainId",String(e)),i.searchParams.set("version",ww),i.searchParams.set("enableLogger",String(s)),i.searchParams.set("rpcUrl",n);const o=lt.get("dapp_smart_account_version");return o&&(o==="v6"||o==="v7")&&(console.warn(">> AppKit - Forcing smart account version",o),i.searchParams.set("smartAccountVersion",o)),r&&i.searchParams.set("enableCloudAuthAccount","true"),i.toString()}class Lb{constructor({projectId:e,isAppClient:s=!1,chainId:n="eip155:1",enableLogger:r=!0,enableCloudAuthAccount:i=!1,rpcUrl:o=U.BLOCKCHAIN_API_RPC_URL}){if(this.iframe=null,this.iframeIsReady=!1,this.initFrame=()=>{const a=document.getElementById("w3m-iframe");this.iframe&&!a&&document.body.appendChild(this.iframe)},this.events={registerFrameEventHandler:(a,c,l)=>{function d({data:u}){var p;if(!vc(oe.FRAME_EVENT_KEY,u))return;const h=bc.frameEvent.safeParse(u);if(!h.success){console.warn("W3mFrame: invalid frame event",h.error.message);return}((p=h.data)==null?void 0:p.id)===a&&(c(h.data),window.removeEventListener("message",d))}cs.isClient&&(window.addEventListener("message",d),l.addEventListener("abort",()=>{window.removeEventListener("message",d)}))},onFrameEvent:a=>{cs.isClient&&window.addEventListener("message",({data:c})=>{if(!vc(oe.FRAME_EVENT_KEY,c))return;const l=bc.frameEvent.safeParse(c);l.success?a(l.data):console.warn("W3mFrame: invalid frame event",l.error.message)})},onAppEvent:a=>{cs.isClient&&window.addEventListener("message",({data:c})=>{if(!vc(oe.APP_EVENT_KEY,c))return;const l=bc.appEvent.safeParse(c);l.success||console.warn("W3mFrame: invalid app event",l.error.message),a(c)})},postAppEvent:a=>{var c;if(cs.isClient){if(!((c=this.iframe)!=null&&c.contentWindow))throw new Error("W3mFrame: iframe is not set");this.iframe.contentWindow.postMessage(a,"*")}},postFrameEvent:a=>{if(cs.isClient){if(!parent)throw new Error("W3mFrame: parent is not set");parent.postMessage(a,"*")}}},this.projectId=e,this.frameLoadPromise=new Promise((a,c)=>{this.frameLoadPromiseResolver={resolve:a,reject:c}}),this.rpcUrl=o,s&&(this.frameLoadPromise=new Promise((a,c)=>{this.frameLoadPromiseResolver={resolve:a,reject:c}}),cs.isClient)){const a=document.createElement("iframe");a.id="w3m-iframe",a.src=Db({projectId:e,chainId:n,enableLogger:r,rpcUrl:this.rpcUrl,enableCloudAuthAccount:i}),a.name="w3m-secure-iframe",a.style.position="fixed",a.style.zIndex="999999",a.style.display="none",a.style.border="none",a.style.animationDelay="0s, 50ms",a.style.borderBottomLeftRadius="clamp(0px, var(--apkt-borderRadius-8), 44px)",a.style.borderBottomRightRadius="clamp(0px, var(--apkt-borderRadius-8), 44px)",this.iframe=a,this.iframe.onerror=()=>{var c;(c=this.frameLoadPromiseResolver)==null||c.reject("Unable to load email login dependency")},this.events.onFrameEvent(c=>{var l;c.type==="@w3m-frame/READY"&&(this.iframeIsReady=!0,(l=this.frameLoadPromiseResolver)==null||l.resolve(void 0))})}}get networks(){const e=["eip155:1","eip155:5","eip155:11155111","eip155:10","eip155:420","eip155:42161","eip155:421613","eip155:137","eip155:80001","eip155:42220","eip155:1313161554","eip155:1313161555","eip155:56","eip155:97","eip155:43114","eip155:43113","eip155:324","eip155:280","eip155:100","eip155:8453","eip155:84531","eip155:84532","eip155:7777777","eip155:999","solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp","solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z","solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1"].map(s=>({[s]:{rpcUrl:`${this.rpcUrl}/v1/?chainId=${s}&projectId=${this.projectId}`,chainId:s}}));return Object.assign({},...e)}}var bi={exports:{}},xu;function Mb(){if(xu)return bi.exports;xu=1;const t=Sy();bi.exports=d;const e=T().console||{},s={mapHttpRequest:L,mapHttpResponse:L,wrapRequestSerializer:W,wrapResponseSerializer:W,wrapErrorSerializer:W,req:L,res:L,err:P,errWithCause:P};function n(y,b){return y==="silent"?1/0:b.levels.values[y]}const r=Symbol("pino.logFuncs"),i=Symbol("pino.hierarchy"),o={error:"log",fatal:"error",warn:"error",info:"log",debug:"log",trace:"log"};function a(y,b){const S={logger:b,parent:y[i]};b[i]=S}function c(y,b,S){const R={};b.forEach(C=>{R[C]=S[C]?S[C]:e[C]||e[o[C]||"log"]||k}),y[r]=R}function l(y,b){return Array.isArray(y)?y.filter(function(R){return R!=="!stdSerializers.err"}):y===!0?Object.keys(b):!1}function d(y){y=y||{},y.browser=y.browser||{};const b=y.browser.transmit;if(b&&typeof b.send!="function")throw Error("pino: transmit option must have a send function");const S=y.browser.write||e;y.browser.write&&(y.browser.asObject=!0);const R=y.serializers||{},C=l(y.browser.serialize,R);let O=y.browser.serialize;Array.isArray(y.browser.serialize)&&y.browser.serialize.indexOf("!stdSerializers.err")>-1&&(O=!1);const B=Object.keys(y.customLevels||{}),M=["error","fatal","warn","info","debug","trace"].concat(B);typeof S=="function"&&M.forEach(function(ve){S[ve]=S}),(y.enabled===!1||y.browser.disabled)&&(y.level="silent");const ce=y.level||"info",j=Object.create(S);j.log||(j.log=k),c(j,M,S),a({},j),Object.defineProperty(j,"levelVal",{get:he}),Object.defineProperty(j,"level",{get:ge,set:xe});const J={transmit:b,serialize:C,asObject:y.browser.asObject,asObjectBindingsOnly:y.browser.asObjectBindingsOnly,formatters:y.browser.formatters,levels:M,timestamp:D(y),messageKey:y.messageKey||"msg",onChild:y.onChild||k};j.levels=u(y),j.level=ce,j.isLevelEnabled=function(ve){return this.levels.values[ve]?this.levels.values[ve]>=this.levels.values[this.level]:!1},j.setMaxListeners=j.getMaxListeners=j.emit=j.addListener=j.on=j.prependListener=j.once=j.prependOnceListener=j.removeListener=j.removeAllListeners=j.listeners=j.listenerCount=j.eventNames=j.write=j.flush=k,j.serializers=R,j._serialize=C,j._stdErrSerialize=O,j.child=function(...ve){return ye.call(this,J,...ve)},b&&(j._logEvent=_());function he(){return n(this.level,this)}function ge(){return this._level}function xe(ve){if(ve!=="silent"&&!this.levels.values[ve])throw Error("unknown level "+ve);this._level=ve,g(this,J,j,"error"),g(this,J,j,"fatal"),g(this,J,j,"warn"),g(this,J,j,"info"),g(this,J,j,"debug"),g(this,J,j,"trace"),B.forEach(ze=>{g(this,J,j,ze)})}function ye(ve,ze,st){if(!ze)throw new Error("missing bindings for child Pino");st=st||{},C&&ze.serializers&&(st.serializers=ze.serializers);const ut=st.serializers;if(C&&ut){var wt=Object.assign({},R,ut),Ms=y.browser.serialize===!0?Object.keys(wt):C;delete ze.serializers,N([ze],Ms,wt,this._stdErrSerialize)}function tn($o){this._childLevel=($o._childLevel|0)+1,this.bindings=ze,wt&&(this.serializers=wt,this._serialize=Ms),b&&(this._logEvent=_([].concat($o._logEvent.bindings,ze)))}tn.prototype=this;const Ei=new tn(this);return a(this,Ei),Ei.child=function(...$o){return ye.call(this,ve,...$o)},Ei.level=st.level||this.level,ve.onChild(Ei),Ei}return j}function u(y){const b=y.customLevels||{},S=Object.assign({},d.levels.values,b),R=Object.assign({},d.levels.labels,h(b));return{values:S,labels:R}}function h(y){const b={};return Object.keys(y).forEach(function(S){b[y[S]]=S}),b}d.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}},d.stdSerializers=s,d.stdTimeFunctions=Object.assign({},{nullTime:q,epochTime:z,unixTime:x,isoTime:I});function p(y){const b=[];y.bindings&&b.push(y.bindings);let S=y[i];for(;S.parent;)S=S.parent,S.logger.bindings&&b.push(S.logger.bindings);return b.reverse()}function g(y,b,S,R){if(Object.defineProperty(y,R,{value:n(y.level,S)>n(R,S)?k:S[r][R],writable:!0,enumerable:!0,configurable:!0}),y[R]===k){if(!b.transmit)return;const O=b.transmit.level||y.level,B=n(O,S);if(n(R,S)<B)return}y[R]=w(y,b,S,R);const C=p(y);C.length!==0&&(y[R]=f(C,y[R]))}function f(y,b){return function(){return b.apply(this,[...y,...arguments])}}function w(y,b,S,R){return(function(C){return function(){const B=b.timestamp(),M=new Array(arguments.length),ce=Object.getPrototypeOf&&Object.getPrototypeOf(this)===e?e:this;for(var j=0;j<M.length;j++)M[j]=arguments[j];var J=!1;if(b.serialize&&(N(M,this._serialize,this.serializers,this._stdErrSerialize),J=!0),b.asObject||b.formatters?C.call(ce,...v(this,R,M,B,b)):C.apply(ce,M),b.transmit){const he=b.transmit.level||y._level,ge=n(he,S),xe=n(R,S);if(xe<ge)return;A(this,{ts:B,methodLevel:R,methodValue:xe,transmitValue:S.levels.values[b.transmit.level||y._level],send:b.transmit.send,val:n(y._level,S)},M,J)}}})(y[r][R])}function v(y,b,S,R,C){const{level:O,log:B=he=>he}=C.formatters||{},M=S.slice();let ce=M[0];const j={};let J=(y._childLevel|0)+1;if(J<1&&(J=1),R&&(j.time=R),O){const he=O(b,y.levels.values[b]);Object.assign(j,he)}else j.level=y.levels.values[b];if(C.asObjectBindingsOnly){if(ce!==null&&typeof ce=="object")for(;J--&&typeof M[0]=="object";)Object.assign(j,M.shift());return[B(j),...M]}else{if(ce!==null&&typeof ce=="object"){for(;J--&&typeof M[0]=="object";)Object.assign(j,M.shift());ce=M.length?t(M.shift(),M):void 0}else typeof ce=="string"&&(ce=t(M.shift(),M));return ce!==void 0&&(j[C.messageKey]=ce),[B(j)]}}function N(y,b,S,R){for(const C in y)if(R&&y[C]instanceof Error)y[C]=d.stdSerializers.err(y[C]);else if(typeof y[C]=="object"&&!Array.isArray(y[C])&&b)for(const O in y[C])b.indexOf(O)>-1&&O in S&&(y[C][O]=S[O](y[C][O]))}function A(y,b,S,R=!1){const C=b.send,O=b.ts,B=b.methodLevel,M=b.methodValue,ce=b.val,j=y._logEvent.bindings;R||N(S,y._serialize||Object.keys(y.serializers),y.serializers,y._stdErrSerialize===void 0?!0:y._stdErrSerialize),y._logEvent.ts=O,y._logEvent.messages=S.filter(function(J){return j.indexOf(J)===-1}),y._logEvent.level.label=B,y._logEvent.level.value=M,C(B,y._logEvent,ce),y._logEvent=_(j)}function _(y){return{ts:0,messages:[],bindings:y||[],level:{label:"",value:0}}}function P(y){const b={type:y.constructor.name,msg:y.message,stack:y.stack};for(const S in y)b[S]===void 0&&(b[S]=y[S]);return b}function D(y){return typeof y.timestamp=="function"?y.timestamp:y.timestamp===!1?q:z}function L(){return{}}function W(y){return y}function k(){}function q(){return!1}function z(){return Date.now()}function x(){return Math.round(Date.now()/1e3)}function I(){return new Date(Date.now()).toISOString()}function T(){function y(b){return typeof b<"u"&&b}try{return typeof globalThis<"u"||Object.defineProperty(Object.prototype,"globalThis",{get:function(){return delete Object.prototype.globalThis,this.globalThis=this},configurable:!0}),globalThis}catch{return y(self)||y(window)||y(this)||{}}}return bi.exports.default=d,bi.exports.pino=d,bi.exports}var Kr=Mb();const Uf=uy(Kr),Bb={level:"info"},ec="custom_context",vd=1e3*1024;var jb=Object.defineProperty,Fb=(t,e,s)=>e in t?jb(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Bn=(t,e,s)=>Fb(t,typeof e!="symbol"?e+"":e,s);let qb=class{constructor(e){Bn(this,"nodeValue"),Bn(this,"sizeInBytes"),Bn(this,"next"),this.nodeValue=e,this.sizeInBytes=new TextEncoder().encode(this.nodeValue).length,this.next=null}get value(){return this.nodeValue}get size(){return this.sizeInBytes}},ku=class{constructor(e){Bn(this,"lengthInNodes"),Bn(this,"sizeInBytes"),Bn(this,"head"),Bn(this,"tail"),Bn(this,"maxSizeInBytes"),this.head=null,this.tail=null,this.lengthInNodes=0,this.maxSizeInBytes=e,this.sizeInBytes=0}append(e){const s=new qb(e);if(s.size>this.maxSizeInBytes)throw new Error(`[LinkedList] Value too big to insert into list: ${e} with size ${s.size}`);for(;this.size+s.size>this.maxSizeInBytes;)this.shift();this.head?(this.tail&&(this.tail.next=s),this.tail=s):(this.head=s,this.tail=s),this.lengthInNodes++,this.sizeInBytes+=s.size}shift(){if(!this.head)return;const e=this.head;this.head=this.head.next,this.head||(this.tail=null),this.lengthInNodes--,this.sizeInBytes-=e.size}toArray(){const e=[];let s=this.head;for(;s!==null;)e.push(s.value),s=s.next;return e}get length(){return this.lengthInNodes}get size(){return this.sizeInBytes}toOrderedArray(){return Array.from(this)}[Symbol.iterator](){let e=this.head;return{next:()=>{if(!e)return{done:!0,value:null};const s=e.value;return e=e.next,{done:!1,value:s}}}}};var Wb=Object.defineProperty,Hb=(t,e,s)=>e in t?Wb(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Fo=(t,e,s)=>Hb(t,typeof e!="symbol"?e+"":e,s);let $f=class{constructor(e,s=vd){Fo(this,"logs"),Fo(this,"level"),Fo(this,"levelValue"),Fo(this,"MAX_LOG_SIZE_IN_BYTES"),this.level=e??"error",this.levelValue=Kr.levels.values[this.level],this.MAX_LOG_SIZE_IN_BYTES=s,this.logs=new ku(this.MAX_LOG_SIZE_IN_BYTES)}forwardToConsole(e,s){s===Kr.levels.values.error?console.error(e):s===Kr.levels.values.warn?console.warn(e):s===Kr.levels.values.debug?console.debug(e):s===Kr.levels.values.trace?console.trace(e):console.log(e)}appendToLogs(e){this.logs.append(Gi({timestamp:new Date().toISOString(),log:e}));const s=typeof e=="string"?JSON.parse(e).level:e.level;s>=this.levelValue&&this.forwardToConsole(e,s)}getLogs(){return this.logs}clearLogs(){this.logs=new ku(this.MAX_LOG_SIZE_IN_BYTES)}getLogArray(){return Array.from(this.logs)}logsToBlob(e){const s=this.getLogArray();return s.push(Gi({extraMetadata:e})),new Blob(s,{type:"application/json"})}};var Vb=Object.defineProperty,zb=(t,e,s)=>e in t?Vb(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Kb=(t,e,s)=>zb(t,e+"",s);let Gb=class{constructor(e,s=vd){Kb(this,"baseChunkLogger"),this.baseChunkLogger=new $f(e,s)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}downloadLogsBlobInBrowser(e){const s=URL.createObjectURL(this.logsToBlob(e)),n=document.createElement("a");n.href=s,n.download=`walletconnect-logs-${new Date().toISOString()}.txt`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(s)}};var Yb=Object.defineProperty,Zb=(t,e,s)=>e in t?Yb(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Jb=(t,e,s)=>Zb(t,e+"",s);let Xb=class{constructor(e,s=vd){Jb(this,"baseChunkLogger"),this.baseChunkLogger=new $f(e,s)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}};var Qb=Object.defineProperty,ev=Object.defineProperties,tv=Object.getOwnPropertyDescriptors,Uu=Object.getOwnPropertySymbols,sv=Object.prototype.hasOwnProperty,nv=Object.prototype.propertyIsEnumerable,$u=(t,e,s)=>e in t?Qb(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,xa=(t,e)=>{for(var s in e||(e={}))sv.call(e,s)&&$u(t,s,e[s]);if(Uu)for(var s of Uu(e))nv.call(e,s)&&$u(t,s,e[s]);return t},ka=(t,e)=>ev(t,tv(e));function Cd(t){return ka(xa({},t),{level:(t==null?void 0:t.level)||Bb.level})}function rv(t,e,s=ec){return t[s]=e,t}function es(t,e=ec){return t[e]||""}function iv(t,e,s=ec){const n=es(t,s);return n.trim()?`${n}/${e}`:e}function ts(t,e,s=ec){const n=iv(t,e,s),r=t.child({context:n});return rv(r,n,s)}function ov(t){var e,s;const n=new Gb((e=t.opts)==null?void 0:e.level,t.maxSizeInBytes);return{logger:Uf(ka(xa({},t.opts),{level:"trace",browser:ka(xa({},(s=t.opts)==null?void 0:s.browser),{write:r=>n.write(r)})})),chunkLoggerController:n}}function av(t){var e;const s=new Xb((e=t.opts)==null?void 0:e.level,t.maxSizeInBytes);return{logger:Uf(ka(xa({},t.opts),{level:"trace"}),s),chunkLoggerController:s}}function tc(t){return typeof t.loggerOverride<"u"&&typeof t.loggerOverride!="string"?{logger:t.loggerOverride,chunkLoggerController:null}:typeof window<"u"?ov(t):av(t)}class cv{constructor(e){var i;const s=Cd({level:yw}),{logger:n,chunkLoggerController:r}=tc({opts:s});this.logger=ts(n,this.constructor.name),this.chunkLoggerController=r,typeof window<"u"&&((i=this.chunkLoggerController)!=null&&i.downloadLogsBlobInBrowser)&&(window.downloadAppKitLogsBlob||(window.downloadAppKitLogsBlob={}),window.downloadAppKitLogsBlob.sdk=()=>{var o;(o=this.chunkLoggerController)!=null&&o.downloadLogsBlobInBrowser&&this.chunkLoggerController.downloadLogsBlobInBrowser({projectId:e})})}}class lv{constructor({projectId:e,chainId:s,enableLogger:n=!0,onTimeout:r,abortController:i,getActiveCaipNetwork:o,getCaipNetworks:a,enableCloudAuthAccount:c,metadata:l,sdkVersion:d,sdkType:u}){this.openRpcRequests=new Map,this.isInitialized=!1,n&&(this.w3mLogger=new cv(e)),this.abortController=i,this.getActiveCaipNetwork=o,this.getCaipNetworks=a;const h=this.getRpcUrl(s);this.projectId=e,this.sdkVersion=d,this.sdkType=u,this.metadata=l,this.w3mFrame=new Lb({projectId:e,isAppClient:!0,chainId:s,enableLogger:n,rpcUrl:h,enableCloudAuthAccount:c}),this.onTimeout=r,this.getLoginEmailUsed()&&this.createFrame()}async createFrame(){this.w3mFrame.initFrame(),this.initPromise=new Promise(e=>{this.w3mFrame.events.onFrameEvent(s=>{s.type===oe.FRAME_READY&&setTimeout(()=>{e()},500)})}),await this.initPromise,await this.syncDappData({metadata:this.metadata,projectId:this.projectId,sdkVersion:this.sdkVersion,sdkType:this.sdkType}),await this.getSmartAccountEnabledNetworks(),this.isInitialized=!0,this.initPromise=void 0}async init(){if(!this.isInitialized){if(this.initPromise){await this.initPromise;return}await this.createFrame()}}getLoginEmailUsed(){return!!lt.get(oe.EMAIL_LOGIN_USED_KEY)}getEmail(){return lt.get(oe.EMAIL)}getUsername(){return lt.get(oe.SOCIAL_USERNAME)}async reload(){var e;try{await this.appEvent({type:oe.APP_RELOAD})}catch(s){throw(e=this.w3mLogger)==null||e.logger.error({error:s},"Error reloading iframe"),s}}async connectEmail(e){var s;try{cs.checkIfAllowedToTriggerEmail(),await this.init();const n=await this.appEvent({type:oe.APP_CONNECT_EMAIL,payload:e});return this.setNewLastEmailLoginTime(),n}catch(n){throw(s=this.w3mLogger)==null||s.logger.error({error:n},"Error connecting email"),n}}async connectDevice(){var e;try{return this.appEvent({type:oe.APP_CONNECT_DEVICE})}catch(s){throw(e=this.w3mLogger)==null||e.logger.error({error:s},"Error connecting device"),s}}async connectOtp(e){var s;try{return this.appEvent({type:oe.APP_CONNECT_OTP,payload:e})}catch(n){throw(s=this.w3mLogger)==null||s.logger.error({error:n},"Error connecting otp"),n}}async isConnected(){var e;try{if(!this.getLoginEmailUsed())return{isConnected:!1};const s=await this.appEvent({type:oe.APP_IS_CONNECTED});return s!=null&&s.isConnected||this.deleteAuthLoginCache(),s}catch(s){throw this.deleteAuthLoginCache(),(e=this.w3mLogger)==null||e.logger.error({error:s},"Error checking connection"),s}}async getChainId(){var e;try{const s=await this.appEvent({type:oe.APP_GET_CHAIN_ID});return this.setLastUsedChainId(s.chainId),s}catch(s){throw(e=this.w3mLogger)==null||e.logger.error({error:s},"Error getting chain id"),s}}async getSocialRedirectUri(e){var s;try{return await this.init(),this.appEvent({type:oe.APP_GET_SOCIAL_REDIRECT_URI,payload:e})}catch(n){throw(s=this.w3mLogger)==null||s.logger.error({error:n},"Error getting social redirect uri"),n}}async updateEmail(e){var s;try{const n=await this.appEvent({type:oe.APP_UPDATE_EMAIL,payload:e});return this.setNewLastEmailLoginTime(),n}catch(n){throw(s=this.w3mLogger)==null||s.logger.error({error:n},"Error updating email"),n}}async updateEmailPrimaryOtp(e){var s;try{return this.appEvent({type:oe.APP_UPDATE_EMAIL_PRIMARY_OTP,payload:e})}catch(n){throw(s=this.w3mLogger)==null||s.logger.error({error:n},"Error updating email primary otp"),n}}async updateEmailSecondaryOtp(e){var s;try{const n=await this.appEvent({type:oe.APP_UPDATE_EMAIL_SECONDARY_OTP,payload:e});return this.setLoginSuccess(n.newEmail),n}catch(n){throw(s=this.w3mLogger)==null||s.logger.error({error:n},"Error updating email secondary otp"),n}}async syncTheme(e){var s;try{return this.appEvent({type:oe.APP_SYNC_THEME,payload:e})}catch(n){throw(s=this.w3mLogger)==null||s.logger.error({error:n},"Error syncing theme"),n}}async syncDappData(e){var s;try{return this.appEvent({type:oe.APP_SYNC_DAPP_DATA,payload:e})}catch(n){throw(s=this.w3mLogger)==null||s.logger.error({error:n},"Error syncing dapp data"),n}}async getSmartAccountEnabledNetworks(){var e;try{const s=await this.appEvent({type:oe.APP_GET_SMART_ACCOUNT_ENABLED_NETWORKS});return this.persistSmartAccountEnabledNetworks(s.smartAccountEnabledNetworks),s}catch(s){throw this.persistSmartAccountEnabledNetworks([]),(e=this.w3mLogger)==null||e.logger.error({error:s},"Error getting smart account enabled networks"),s}}async setPreferredAccount(e){var s;try{return this.appEvent({type:oe.APP_SET_PREFERRED_ACCOUNT,payload:{type:e}})}catch(n){throw(s=this.w3mLogger)==null||s.logger.error({error:n},"Error setting preferred account"),n}}async connect(e){var s,n;if(e!=null&&e.socialUri)try{await this.init();const r=this.getRpcUrl(e.chainId),i=await this.appEvent({type:oe.APP_CONNECT_SOCIAL,payload:{uri:e.socialUri,preferredAccountType:e.preferredAccountType,chainId:e.chainId,siwxMessage:e.siwxMessage,rpcUrl:r}});return i.userName&&this.setSocialLoginSuccess(i.userName),this.setLoginSuccess(i.email),this.setLastUsedChainId(i.chainId),this.user=i,i}catch(r){throw(s=this.w3mLogger)==null||s.logger.error({error:r},"Error connecting social"),r}else try{const r=(e==null?void 0:e.chainId)||this.getLastUsedChainId()||1,i=await this.getUser({chainId:r,preferredAccountType:e==null?void 0:e.preferredAccountType,siwxMessage:e==null?void 0:e.siwxMessage,rpcUrl:this.getRpcUrl(r)});return this.setLoginSuccess(i.email),this.setLastUsedChainId(i.chainId),this.user=i,i}catch(r){throw(n=this.w3mLogger)==null||n.logger.error({error:r},"Error connecting"),r}}async getUser(e){var s;try{await this.init();const n=(e==null?void 0:e.chainId)||this.getLastUsedChainId()||1,r=await this.appEvent({type:oe.APP_GET_USER,payload:{...e,chainId:n,rpcUrl:this.getRpcUrl(n)}});return this.user=r,r}catch(n){throw(s=this.w3mLogger)==null||s.logger.error({error:n},"Error connecting"),n}}async connectSocial({uri:e,chainId:s,preferredAccountType:n}){var r;try{await this.init();const i=this.getRpcUrl(s),o=await this.appEvent({type:oe.APP_CONNECT_SOCIAL,payload:{uri:e,chainId:s,rpcUrl:i,preferredAccountType:n}});return o.userName&&this.setSocialLoginSuccess(o.userName),o}catch(i){throw(r=this.w3mLogger)==null||r.logger.error({error:i},"Error connecting social"),i}}async getFarcasterUri(){var e;try{return await this.init(),await this.appEvent({type:oe.APP_GET_FARCASTER_URI})}catch(s){throw(e=this.w3mLogger)==null||e.logger.error({error:s},"Error getting farcaster uri"),s}}async connectFarcaster(){var e;try{const s=await this.appEvent({type:oe.APP_CONNECT_FARCASTER});return s.userName&&this.setSocialLoginSuccess(s.userName),s}catch(s){throw(e=this.w3mLogger)==null||e.logger.error({error:s},"Error connecting farcaster"),s}}async switchNetwork({chainId:e}){var s;try{const n=this.getRpcUrl(e),r=await this.appEvent({type:oe.APP_SWITCH_NETWORK,payload:{chainId:e,rpcUrl:n}});return this.setLastUsedChainId(r.chainId),r}catch(n){throw(s=this.w3mLogger)==null||s.logger.error({error:n},"Error switching network"),n}}async disconnect(){var e;try{return this.deleteAuthLoginCache(),await new Promise(async n=>{const r=setTimeout(()=>{n()},3e3);await this.appEvent({type:oe.APP_SIGN_OUT}),clearTimeout(r),n()})}catch(s){throw(e=this.w3mLogger)==null||e.logger.error({error:s},"Error disconnecting"),s}}async request(e){var n,r,i,o,a;const s=e;try{if(tt.GET_CHAIN_ID===e.method)return this.getLastUsedChainId();const c=e.chainNamespace||"eip155",l=(n=this.getActiveCaipNetwork(c))==null?void 0:n.id;s.chainNamespace=c,s.chainId=l,s.rpcUrl=this.getRpcUrl(l),(r=this.rpcRequestHandler)==null||r.call(this,e);const d=await this.appEvent({type:oe.APP_RPC_REQUEST,payload:s});return(i=this.rpcSuccessHandler)==null||i.call(this,d,s),d}catch(c){throw(o=this.rpcErrorHandler)==null||o.call(this,c,s),(a=this.w3mLogger)==null||a.logger.error({error:c},"Error requesting"),c}}onRpcRequest(e){this.rpcRequestHandler=e}onRpcSuccess(e){this.rpcSuccessHandler=e}onRpcError(e){this.rpcErrorHandler=e}onIsConnected(e){this.w3mFrame.events.onFrameEvent(s=>{s.type===oe.FRAME_IS_CONNECTED_SUCCESS&&s.payload.isConnected&&e()})}onNotConnected(e){this.w3mFrame.events.onFrameEvent(s=>{s.type===oe.FRAME_IS_CONNECTED_ERROR&&e(),s.type===oe.FRAME_IS_CONNECTED_SUCCESS&&!s.payload.isConnected&&e()})}onConnect(e){this.w3mFrame.events.onFrameEvent(s=>{s.type===oe.FRAME_GET_USER_SUCCESS&&e(s.payload)})}onSocialConnected(e){this.w3mFrame.events.onFrameEvent(s=>{s.type===oe.FRAME_CONNECT_SOCIAL_SUCCESS&&e(s.payload)})}async getCapabilities(){try{return await this.request({method:"wallet_getCapabilities"})||{}}catch{return{}}}onSetPreferredAccount(e){this.w3mFrame.events.onFrameEvent(s=>{s.type===oe.FRAME_SET_PREFERRED_ACCOUNT_SUCCESS?e(s.payload):s.type===oe.FRAME_SET_PREFERRED_ACCOUNT_ERROR&&e({type:tt.ACCOUNT_TYPES.EOA})})}getAvailableChainIds(){return Object.keys(this.w3mFrame.networks)}async rejectRpcRequests(){var e;try{await Promise.all(Array.from(this.openRpcRequests.values()).map(async({abortController:s,method:n})=>{tt.SAFE_RPC_METHODS.includes(n)||s.abort(),await this.appEvent({type:oe.APP_RPC_ABORT})})),this.openRpcRequests.clear()}catch(s){(e=this.w3mLogger)==null||e.logger.error({error:s},"Error aborting RPC request")}}async appEvent(e){let s,n;function r(c){return c.replace("@w3m-app/","")}const i=[oe.APP_SYNC_DAPP_DATA,oe.APP_SYNC_THEME,oe.APP_SET_PREFERRED_ACCOUNT],o=r(e.type);return!this.w3mFrame.iframeIsReady&&!i.includes(e.type)&&(n=setTimeout(()=>{var c;(c=this.onTimeout)==null||c.call(this,"iframe_load_failed"),this.abortController.abort()},2e4)),await this.w3mFrame.frameLoadPromise,clearTimeout(n),[oe.APP_CONNECT_EMAIL,oe.APP_CONNECT_DEVICE,oe.APP_CONNECT_OTP,oe.APP_CONNECT_SOCIAL,oe.APP_GET_SOCIAL_REDIRECT_URI].map(r).includes(o)&&(s=setTimeout(()=>{var c;(c=this.onTimeout)==null||c.call(this,"iframe_request_timeout"),this.abortController.abort()},12e4)),new Promise((c,l)=>{var p,g,f;const d=Math.random().toString(36).substring(7);(f=(p=this.w3mLogger)==null?void 0:(g=p.logger).info)==null||f.call(g,{event:e,id:d},"Sending app event"),this.w3mFrame.events.postAppEvent({...e,id:d});const u=new AbortController;if(o==="RPC_REQUEST"){const w=e;this.openRpcRequests.set(d,{...w.payload,abortController:u})}u.signal.addEventListener("abort",()=>{o==="RPC_REQUEST"?l(new Error("Request was aborted")):o!=="GET_FARCASTER_URI"&&l(new Error("Something went wrong"))});const h=(w,v)=>{var N,A,_;w.id===d&&((A=v==null?void 0:(N=v.logger).info)==null||A.call(N,{framEvent:w,id:d},"Received frame response"),this.openRpcRequests.delete(w.id),w.type===`@w3m-frame/${o}_SUCCESS`?(s&&clearTimeout(s),n&&clearTimeout(n),"payload"in w&&c(w.payload),c(void 0)):w.type===`@w3m-frame/${o}_ERROR`&&(s&&clearTimeout(s),n&&clearTimeout(n),"payload"in w&&l(new Error(((_=w.payload)==null?void 0:_.message)||"An error occurred")),l(new Error("An error occurred"))))};this.w3mFrame.events.registerFrameEventHandler(d,w=>h(w,this.w3mLogger),this.abortController.signal)})}setNewLastEmailLoginTime(){lt.set(oe.LAST_EMAIL_LOGIN_TIME,Date.now().toString())}setSocialLoginSuccess(e){lt.set(oe.SOCIAL_USERNAME,e)}setLoginSuccess(e){e&<.set(oe.EMAIL,e),lt.set(oe.EMAIL_LOGIN_USED_KEY,"true"),lt.delete(oe.LAST_EMAIL_LOGIN_TIME)}deleteAuthLoginCache(){lt.delete(oe.EMAIL_LOGIN_USED_KEY),lt.delete(oe.EMAIL),lt.delete(oe.LAST_USED_CHAIN_KEY),lt.delete(oe.SOCIAL_USERNAME)}setLastUsedChainId(e){e&<.set(oe.LAST_USED_CHAIN_KEY,String(e))}getLastUsedChainId(){const e=lt.get(oe.LAST_USED_CHAIN_KEY)??void 0,s=Number(e);return isNaN(s)?e:s}persistSmartAccountEnabledNetworks(e){lt.set(oe.SMART_ACCOUNT_ENABLED_NETWORKS,e.join(","))}getRpcUrl(e){var i,o;let s=e===void 0?void 0:"eip155";typeof e=="string"&&(e.includes(":")?s=(i=dt.parseCaipNetworkId(e))==null?void 0:i.chainNamespace:Number.isInteger(Number(e))?s="eip155":s="solana");const n=this.getCaipNetworks(s),r=e?n.find(a=>String(a.id)===String(e)||a.caipNetworkId===e):n[0];return(o=r==null?void 0:r.rpcUrls.default.http)==null?void 0:o[0]}}async function Df(t){return new Promise(e=>setTimeout(e,t))}function dv(t,{delay:e=100,retryCount:s=2,shouldRetry:n=()=>!0}={}){return new Promise((r,i)=>{const o=async({count:a=0}={})=>{const c=async({error:l})=>{const d=typeof e=="function"?e({count:a,error:l}):e;d&&await Df(d),o({count:a+1})};try{const l=await t();r(l)}catch(l){if(a<s&&await n({count:a,error:l}))return c({error:l});i(l)}};o()})}const Al=256;let qo=Al,Wo;function uv(t=11){if(!Wo||qo+t>Al*2){Wo="",qo=0;for(let e=0;e<Al;e++)Wo+=(256+Math.random()*256|0).toString(16).substring(1)}return Wo.substring(qo,qo+++t)}const Ho=new py(8192);function hv(t,{enabled:e=!0,id:s}){if(!e||!s)return t();if(Ho.get(s))return Ho.get(s);const n=t().finally(()=>Ho.delete(s));return Ho.set(s,n),n}function pv(t,e={}){return async(s,n={})=>{var u;const{dedupe:r=!1,methods:i,retryDelay:o=150,retryCount:a=3,uid:c}={...e,...n},{method:l}=s;if((u=i==null?void 0:i.exclude)!=null&&u.includes(l))throw new Do(new Error("method not supported"),{method:l});if(i!=null&&i.include&&!i.include.includes(l))throw new Do(new Error("method not supported"),{method:l});const d=r?fy(`${c}.${ca(s)}`):void 0;return hv(()=>dv(async()=>{try{return await t(s)}catch(h){const p=h;switch(p.code){case yu.code:throw new yu(p);case mu.code:throw new mu(p);case gu.code:throw new gu(p,{method:s.method});case fu.code:throw new fu(p);case ml.code:throw new ml(p);case pu.code:throw new pu(p);case hu.code:throw new hu(p);case uu.code:throw new uu(p);case gl.code:throw new gl(p);case Do.code:throw new Do(p,{method:s.method});case fl.code:throw new fl(p);case du.code:throw new du(p);case la.code:throw new la(p);case lu.code:throw new lu(p);case cu.code:throw new cu(p);case au.code:throw new au(p);case ou.code:throw new ou(p);case iu.code:throw new iu(p);case ru.code:throw new ru(p);case nu.code:throw new nu(p);case su.code:throw new su(p);case tu.code:throw new tu(p);case eu.code:throw new eu(p);case Qd.code:throw new Qd(p);case Xd.code:throw new Xd(p);case 5e3:throw new la(p);default:throw h instanceof ff?h:new gy(p)}}},{delay:({count:h,error:p})=>{var g;if(p&&p instanceof Mi){const f=(g=p==null?void 0:p.headers)==null?void 0:g.get("Retry-After");if(f!=null&&f.match(/\d/))return Number.parseInt(f,10)*1e3}return~~(1<<h)*o},retryCount:a,shouldRetry:({error:h})=>fv(h)}),{enabled:r,id:d})}}function fv(t){return"code"in t&&typeof t.code=="number"?t.code===-1||t.code===fl.code||t.code===ml.code:t instanceof Mi&&t.status?t.status===403||t.status===408||t.status===413||t.status===429||t.status===500||t.status===502||t.status===503||t.status===504:!0}function gv(t,{errorInstance:e=new Error("timed out"),timeout:s,signal:n}){return new Promise((r,i)=>{(async()=>{let o;try{const a=new AbortController;s>0&&(o=setTimeout(()=>{n&&a.abort()},s)),r(await t({signal:(a==null?void 0:a.signal)||null}))}catch(a){(a==null?void 0:a.name)==="AbortError"&&i(e),i(a)}finally{clearTimeout(o)}})()})}function mv(){return{current:0,take(){return this.current++},reset(){this.current=0}}}const Du=mv();function yv(t,e={}){return{async request(s){var h;const{body:n,fetchFn:r=e.fetchFn??fetch,onRequest:i=e.onRequest,onResponse:o=e.onResponse,timeout:a=e.timeout??1e4}=s,c={...e.fetchOptions??{},...s.fetchOptions??{}},{headers:l,method:d,signal:u}=c;try{const p=await gv(async({signal:f})=>{const w={...c,body:Array.isArray(n)?ca(n.map(_=>({jsonrpc:"2.0",id:_.id??Du.take(),..._}))):ca({jsonrpc:"2.0",id:n.id??Du.take(),...n}),headers:{"Content-Type":"application/json",...l},method:d||"POST",signal:u||(a>0?f:null)},v=new Request(t,w),N=await(i==null?void 0:i(v,w))??{...w,url:t};return await r(N.url??t,N)},{errorInstance:new wu({body:n,url:t}),timeout:a,signal:!0});o&&await o(p);let g;if((h=p.headers.get("Content-Type"))!=null&&h.startsWith("application/json"))g=await p.json();else{g=await p.text();try{g=JSON.parse(g||"{}")}catch(f){if(p.ok)throw f;g={error:g}}}if(!p.ok)throw new Mi({body:n,details:ca(g.error)||p.statusText,headers:p.headers,status:p.status,url:t});return g}catch(p){throw p instanceof Mi||p instanceof wu?p:new Mi({body:n,cause:p,url:t})}}}}function Lf({key:t,methods:e,name:s,request:n,retryCount:r=3,retryDelay:i=150,timeout:o,type:a},c){const l=uv();return{config:{key:t,methods:e,name:s,request:n,retryCount:r,retryDelay:i,timeout:o,type:a},request:pv(n,{methods:e,retryCount:r,retryDelay:i,uid:l}),value:c}}function Lu(t,e={}){const{key:s="fallback",name:n="Fallback",rank:r=!1,shouldThrow:i=wv,retryCount:o,retryDelay:a}=e;return(({chain:c,pollingInterval:l=4e3,timeout:d,...u})=>{let h=t,p=()=>{};const g=Lf({key:s,name:n,async request({method:f,params:w}){let v;const N=async(A=0)=>{const _=h[A]({...u,chain:c,retryCount:0,timeout:d});try{const P=await _.request({method:f,params:w});return p({method:f,params:w,response:P,transport:_,status:"success"}),P}catch(P){if(p({error:P,method:f,params:w,transport:_,status:"error"}),i(P)||A===h.length-1||(v??(v=h.slice(A+1).some(D=>{const{include:L,exclude:W}=D({chain:c}).config.methods||{};return L?L.includes(f):W?!W.includes(f):!0})),!v))throw P;return N(A+1)}};return N()},retryCount:o,retryDelay:a,type:"fallback"},{onResponse:f=>p=f,transports:h.map(f=>f({chain:c,retryCount:0}))});if(r){const f=typeof r=="object"?r:{};Ev({chain:c,interval:f.interval??l,onTransports:w=>h=w,ping:f.ping,sampleCount:f.sampleCount,timeout:f.timeout,transports:h,weights:f.weights})}return g})}function wv(t){return!!("code"in t&&typeof t.code=="number"&&(t.code===gl.code||t.code===la.code||my.nodeMessage.test(t.message)||t.code===5e3))}function Ev({chain:t,interval:e=4e3,onTransports:s,ping:n,sampleCount:r=10,timeout:i=1e3,transports:o,weights:a={}}){const{stability:c=.7,latency:l=.3}=a,d=[],u=async()=>{const h=await Promise.all(o.map(async f=>{const w=f({chain:t,retryCount:0,timeout:i}),v=Date.now();let N,A;try{await(n?n({transport:w}):w.request({method:"net_listening"})),A=1}catch{A=0}finally{N=Date.now()}return{latency:N-v,success:A}}));d.push(h),d.length>r&&d.shift();const p=Math.max(...d.map(f=>Math.max(...f.map(({latency:w})=>w)))),g=o.map((f,w)=>{const v=d.map(D=>D[w].latency),A=1-v.reduce((D,L)=>D+L,0)/v.length/p,_=d.map(D=>D[w].success),P=_.reduce((D,L)=>D+L,0)/_.length;return P===0?[0,w]:[l*A+c*P,w]}).sort((f,w)=>w[0]-f[0]);s(g.map(([,f])=>o[f])),await Df(e),u()};u()}class bv extends ff{constructor(){super("No URL was provided to the Transport. Please provide a valid RPC URL to the Transport.",{docsPath:"/docs/clients/intro",name:"UrlRequiredError"})}}function Vo(t,e={}){const{batch:s,fetchFn:n,fetchOptions:r,key:i="http",methods:o,name:a="HTTP JSON-RPC",onFetchRequest:c,onFetchResponse:l,retryDelay:d,raw:u}=e;return({chain:h,retryCount:p,timeout:g})=>{const{batchSize:f=1e3,wait:w=0}=typeof s=="object"?s:{},v=e.retryCount??p,N=g??e.timeout??1e4,A=t||(h==null?void 0:h.rpcUrls.default.http[0]);if(!A)throw new bv;const _=yv(A,{fetchFn:n,fetchOptions:r,onRequest:c,onResponse:l,timeout:N});return Lf({key:i,methods:o,name:a,async request({method:P,params:D}){const L={method:P,params:D},{schedule:W}=yy({id:A,wait:w,shouldSplitBatch(x){return x.length>f},fn:x=>_.request({body:x}),sort:(x,I)=>x.id-I.id}),k=async x=>s?W(x):[await _.request({body:x})],[{error:q,result:z}]=await k(L);if(u)return{error:q,result:z};if(q)throw new wy({body:L,error:q,url:A});return z},retryCount:v,retryDelay:d,timeout:N,type:"http"},{fetchOptions:r,url:A})}}async function vi(...t){const e=await fetch(...t);if(!e.ok)throw new Error(`HTTP status code: ${e.status}`,{cause:e});return e}class So{constructor({baseUrl:e,clientId:s}){this.baseUrl=e,this.clientId=s}async get({headers:e,signal:s,cache:n,...r}){const i=this.createUrl(r);return(await vi(i,{method:"GET",headers:e,signal:s,cache:n})).json()}async getBlob({headers:e,signal:s,...n}){const r=this.createUrl(n);return(await vi(r,{method:"GET",headers:e,signal:s})).blob()}async post({body:e,headers:s,signal:n,...r}){const i=this.createUrl(r);return(await vi(i,{method:"POST",headers:s,body:e?JSON.stringify(e):void 0,signal:n})).json()}async put({body:e,headers:s,signal:n,...r}){const i=this.createUrl(r);return(await vi(i,{method:"PUT",headers:s,body:e?JSON.stringify(e):void 0,signal:n})).json()}async delete({body:e,headers:s,signal:n,...r}){const i=this.createUrl(r);return(await vi(i,{method:"DELETE",headers:s,body:e?JSON.stringify(e):void 0,signal:n})).json()}createUrl({path:e,params:s}){const n=new URL(e,this.baseUrl);return s&&Object.entries(s).forEach(([r,i])=>{i&&n.searchParams.append(r,i)}),this.clientId&&n.searchParams.append("clientId",this.clientId),n}sendBeacon({body:e,...s}){const n=this.createUrl(s);return navigator.sendBeacon(n.toString(),e?JSON.stringify(e):void 0)}}const Sl={getFeatureValue(t,e){const s=e==null?void 0:e[t];return s===void 0?Ne.DEFAULT_FEATURES[t]:s},filterSocialsByPlatform(t){if(!t||!t.length)return t;let e=t;return X.isTelegram()&&(X.isIos()&&(e=e.filter(s=>s!=="google")),X.isMac()&&(e=e.filter(s=>s!=="x")),X.isAndroid()&&(e=e.filter(s=>!["facebook","x"].includes(s)))),X.isMobile()&&(e=e.filter(s=>s!=="facebook")),e},isSocialsEnabled(){var t,e,s,n;return Array.isArray((t=$.state.features)==null?void 0:t.socials)&&((e=$.state.features)==null?void 0:e.socials.length)>0||Array.isArray((s=$.state.remoteFeatures)==null?void 0:s.socials)&&((n=$.state.remoteFeatures)==null?void 0:n.socials.length)>0},isEmailEnabled(){var t,e;return!!((t=$.state.features)!=null&&t.email||(e=$.state.remoteFeatures)!=null&&e.email)}},de=Ge({features:Ne.DEFAULT_FEATURES,projectId:"",sdkType:"appkit",sdkVersion:"html-wagmi-undefined",defaultAccountTypes:Ne.DEFAULT_ACCOUNT_TYPES,enableNetworkSwitch:!0,experimental_preferUniversalLinks:!1,remoteFeatures:{},enableMobileFullScreen:!1,coinbasePreference:"all"}),$={state:de,subscribeKey(t,e){return At(de,t,e)},setOptions(t){Object.assign(de,t)},setRemoteFeatures(t){var s,n;if(!t)return;const e={...de.remoteFeatures,...t};de.remoteFeatures=e,(s=de.remoteFeatures)!=null&&s.socials&&(de.remoteFeatures.socials=Sl.filterSocialsByPlatform(de.remoteFeatures.socials)),(n=de.features)!=null&&n.pay&&(de.remoteFeatures.email=!1,de.remoteFeatures.socials=!1)},setFeatures(t){var s;if(!t)return;de.features||(de.features=Ne.DEFAULT_FEATURES);const e={...de.features,...t};de.features=e,(s=de.features)!=null&&s.pay&&de.remoteFeatures&&(de.remoteFeatures.email=!1,de.remoteFeatures.socials=!1)},setProjectId(t){de.projectId=t},setCustomRpcUrls(t){de.customRpcUrls=t},setAllWallets(t){de.allWallets=t},setIncludeWalletIds(t){de.includeWalletIds=t},setExcludeWalletIds(t){de.excludeWalletIds=t},setFeaturedWalletIds(t){de.featuredWalletIds=t},setTokens(t){de.tokens=t},setTermsConditionsUrl(t){de.termsConditionsUrl=t},setPrivacyPolicyUrl(t){de.privacyPolicyUrl=t},setCustomWallets(t){de.customWallets=t},setIsSiweEnabled(t){de.isSiweEnabled=t},setIsUniversalProvider(t){de.isUniversalProvider=t},setSdkVersion(t){de.sdkVersion=t},setMetadata(t){de.metadata=t},setDisableAppend(t){de.disableAppend=t},setEIP6963Enabled(t){de.enableEIP6963=t},setDebug(t){de.debug=t},setEnableWalletGuide(t){de.enableWalletGuide=t},setEnableAuthLogger(t){de.enableAuthLogger=t},setEnableWallets(t){de.enableWallets=t},setPreferUniversalLinks(t){de.experimental_preferUniversalLinks=t},setSIWX(t){if(t)for(const[e,s]of Object.entries(Ne.SIWX_DEFAULTS))t[e]??(t[e]=s);de.siwx=t},setConnectMethodsOrder(t){de.features={...de.features,connectMethodsOrder:t}},setWalletFeaturesOrder(t){de.features={...de.features,walletFeaturesOrder:t}},setSocialsOrder(t){de.remoteFeatures={...de.remoteFeatures,socials:t}},setCollapseWallets(t){de.features={...de.features,collapseWallets:t}},setEnableEmbedded(t){de.enableEmbedded=t},setAllowUnsupportedChain(t){de.allowUnsupportedChain=t},setManualWCControl(t){de.manualWCControl=t},setEnableNetworkSwitch(t){de.enableNetworkSwitch=t},setEnableMobileFullScreen(t){de.enableMobileFullScreen=X.isMobile()&&t},setEnableReconnect(t){de.enableReconnect=t},setCoinbasePreference(t){de.coinbasePreference=t},setDefaultAccountTypes(t={}){Object.entries(t).forEach(([e,s])=>{s&&(de.defaultAccountTypes[e]=s)})},setUniversalProviderConfigOverride(t){de.universalProviderConfigOverride=t},getUniversalProviderConfigOverride(){return de.universalProviderConfigOverride},getSnapshot(){return Xi(de)}},cr=Object.freeze({message:"",variant:"success",svg:void 0,open:!1,autoClose:!0}),at=Ge({...cr}),vv={state:at,subscribeKey(t,e){return At(at,t,e)},showLoading(t,e={}){this._showMessage({message:t,variant:"loading",...e})},showSuccess(t){this._showMessage({message:t,variant:"success"})},showSvg(t,e){this._showMessage({message:t,svg:e})},showError(t){const e=X.parseError(t);this._showMessage({message:e,variant:"error"})},hide(){at.message=cr.message,at.variant=cr.variant,at.svg=cr.svg,at.open=cr.open,at.autoClose=cr.autoClose},_showMessage({message:t,svg:e,variant:s="success",autoClose:n=cr.autoClose}){at.open?(at.open=!1,setTimeout(()=>{at.message=t,at.variant=s,at.svg=e,at.open=!0,at.autoClose=n},150)):(at.message=t,at.variant=s,at.svg=e,at.open=!0,at.autoClose=n)}},zs=vv,Cv={purchaseCurrencies:[{id:"2b92315d-eab7-5bef-84fa-089a131333f5",name:"USD Coin",symbol:"USDC",networks:[{name:"ethereum-mainnet",display_name:"Ethereum",chain_id:"1",contract_address:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},{name:"polygon-mainnet",display_name:"Polygon",chain_id:"137",contract_address:"0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174"}]},{id:"2b92315d-eab7-5bef-84fa-089a131333f5",name:"Ether",symbol:"ETH",networks:[{name:"ethereum-mainnet",display_name:"Ethereum",chain_id:"1",contract_address:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},{name:"polygon-mainnet",display_name:"Polygon",chain_id:"137",contract_address:"0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174"}]}],paymentCurrencies:[{id:"USD",payment_method_limits:[{id:"card",min:"10.00",max:"7500.00"},{id:"ach_bank_account",min:"10.00",max:"25000.00"}]},{id:"EUR",payment_method_limits:[{id:"card",min:"10.00",max:"7500.00"},{id:"ach_bank_account",min:"10.00",max:"25000.00"}]}]},Mf=X.getBlockchainApiUrl(),Ut=Ge({clientId:null,api:new So({baseUrl:Mf,clientId:null}),supportedChains:{http:[],ws:[]}}),fe={state:Ut,async get(t){const{st:e,sv:s}=fe.getSdkProperties(),n=$.state.projectId,r={...t.params||{},st:e,sv:s,projectId:n};return Ut.api.get({...t,params:r})},getSdkProperties(){const{sdkType:t,sdkVersion:e}=$.state;return{st:t||"unknown",sv:e||"unknown"}},async isNetworkSupported(t){if(!t)return!1;try{Ut.supportedChains.http.length||await fe.getSupportedNetworks()}catch{return!1}return Ut.supportedChains.http.includes(t)},async getSupportedNetworks(){try{const t=await fe.get({path:"v1/supported-chains"});return Ut.supportedChains=t,t}catch{return Ut.supportedChains}},async fetchIdentity({address:t}){const e=F.getIdentityFromCacheForAddress(t);if(e)return e;const s=await fe.get({path:`/v1/identity/${t}`,params:{sender:E.state.activeCaipAddress?X.getPlainAddress(E.state.activeCaipAddress):void 0}});return F.updateIdentityCache({address:t,identity:s,timestamp:Date.now()}),s},async fetchTransactions({account:t,cursor:e,signal:s,cache:n,chainId:r}){var c;if(!await fe.isNetworkSupported((c=E.state.activeCaipNetwork)==null?void 0:c.caipNetworkId))return{data:[],next:void 0};const o=F.getTransactionsCacheForAddress({address:t,chainId:r});if(o)return o;const a=await fe.get({path:`/v1/account/${t}/history`,params:{cursor:e,chainId:r},signal:s,cache:n});return F.updateTransactionsCache({address:t,chainId:r,timestamp:Date.now(),transactions:a}),a},async fetchSwapQuote({amount:t,userAddress:e,from:s,to:n,gasPrice:r}){var o;return await fe.isNetworkSupported((o=E.state.activeCaipNetwork)==null?void 0:o.caipNetworkId)?fe.get({path:"/v1/convert/quotes",headers:{"Content-Type":"application/json"},params:{amount:t,userAddress:e,from:s,to:n,gasPrice:r}}):{quotes:[]}},async fetchSwapTokens({chainId:t}){var s;return await fe.isNetworkSupported((s=E.state.activeCaipNetwork)==null?void 0:s.caipNetworkId)?fe.get({path:"/v1/convert/tokens",params:{chainId:t}}):{tokens:[]}},async getAddressBalance({caipNetworkId:t,address:e}){return Ut.api.post({path:`/v1?chainId=${t}&projectId=${$.state.projectId}`,body:{id:"1",jsonrpc:"2.0",method:"getAddressBalance",params:{address:e}}}).then(s=>s.result)},async fetchTokenPrice({addresses:t}){var r;if(!await fe.isNetworkSupported((r=E.state.activeCaipNetwork)==null?void 0:r.caipNetworkId))return{fungibles:[]};const s=F.getTokenPriceCacheForAddresses(t);if(s)return s;const n=await Ut.api.post({path:"/v1/fungible/price",body:{currency:"usd",addresses:t,projectId:$.state.projectId},headers:{"Content-Type":"application/json"}});return F.updateTokenPriceCache({addresses:t,timestamp:Date.now(),tokenPrice:n}),n},async fetchSwapAllowance({tokenAddress:t,userAddress:e}){var n;return await fe.isNetworkSupported((n=E.state.activeCaipNetwork)==null?void 0:n.caipNetworkId)?fe.get({path:"/v1/convert/allowance",params:{tokenAddress:t,userAddress:e},headers:{"Content-Type":"application/json"}}):{allowance:"0"}},async fetchGasPrice({chainId:t}){var r;const{st:e,sv:s}=fe.getSdkProperties();if(!await fe.isNetworkSupported((r=E.state.activeCaipNetwork)==null?void 0:r.caipNetworkId))throw new Error("Network not supported for Gas Price");return fe.get({path:"/v1/convert/gas-price",headers:{"Content-Type":"application/json"},params:{chainId:t,st:e,sv:s}})},async generateSwapCalldata({amount:t,from:e,to:s,userAddress:n,disableEstimate:r}){var o;if(!await fe.isNetworkSupported((o=E.state.activeCaipNetwork)==null?void 0:o.caipNetworkId))throw new Error("Network not supported for Swaps");return Ut.api.post({path:"/v1/convert/build-transaction",headers:{"Content-Type":"application/json"},body:{amount:t,eip155:{slippage:Ne.CONVERT_SLIPPAGE_TOLERANCE},projectId:$.state.projectId,from:e,to:s,userAddress:n,disableEstimate:r}})},async generateApproveCalldata({from:t,to:e,userAddress:s}){var o;const{st:n,sv:r}=fe.getSdkProperties();if(!await fe.isNetworkSupported((o=E.state.activeCaipNetwork)==null?void 0:o.caipNetworkId))throw new Error("Network not supported for Swaps");return fe.get({path:"/v1/convert/build-approve",headers:{"Content-Type":"application/json"},params:{userAddress:s,from:t,to:e,st:n,sv:r}})},async getBalance(t,e,s){var l;const{st:n,sv:r}=fe.getSdkProperties();if(!await fe.isNetworkSupported((l=E.state.activeCaipNetwork)==null?void 0:l.caipNetworkId))return zs.showError("Token Balance Unavailable"),{balances:[]};const o=`${e}:${t}`,a=F.getBalanceCacheForCaipAddress(o);if(a)return a;const c=await fe.get({path:`/v1/account/${t}/balance`,params:{currency:"usd",chainId:e,forceUpdate:s,st:n,sv:r}});return F.updateBalanceCache({caipAddress:o,balance:c,timestamp:Date.now()}),c},async lookupEnsName(t){var s;return await fe.isNetworkSupported((s=E.state.activeCaipNetwork)==null?void 0:s.caipNetworkId)?fe.get({path:`/v1/profile/account/${t}`,params:{apiVersion:"2"}}):{addresses:{},attributes:[]}},async reverseLookupEnsName({address:t}){var n,r;if(!await fe.isNetworkSupported((n=E.state.activeCaipNetwork)==null?void 0:n.caipNetworkId))return[];const s=(r=E.getAccountData())==null?void 0:r.address;return fe.get({path:`/v1/profile/reverse/${t}`,params:{sender:s,apiVersion:"2"}})},async getEnsNameSuggestions(t){var s;return await fe.isNetworkSupported((s=E.state.activeCaipNetwork)==null?void 0:s.caipNetworkId)?fe.get({path:`/v1/profile/suggestions/${t}`,params:{zone:"reown.id"}}):{suggestions:[]}},async registerEnsName({coinType:t,address:e,message:s,signature:n}){var i;return await fe.isNetworkSupported((i=E.state.activeCaipNetwork)==null?void 0:i.caipNetworkId)?Ut.api.post({path:"/v1/profile/account",body:{coin_type:t,address:e,message:s,signature:n},headers:{"Content-Type":"application/json"}}):{success:!1}},async generateOnRampURL({destinationWallets:t,partnerUserId:e,defaultNetwork:s,purchaseAmount:n,paymentAmount:r}){var a;return await fe.isNetworkSupported((a=E.state.activeCaipNetwork)==null?void 0:a.caipNetworkId)?(await Ut.api.post({path:"/v1/generators/onrampurl",params:{projectId:$.state.projectId},body:{destinationWallets:t,defaultNetwork:s,partnerUserId:e,defaultExperience:"buy",presetCryptoAmount:n,presetFiatAmount:r}})).url:""},async getOnrampOptions(){var e;if(!await fe.isNetworkSupported((e=E.state.activeCaipNetwork)==null?void 0:e.caipNetworkId))return{paymentCurrencies:[],purchaseCurrencies:[]};try{return await fe.get({path:"/v1/onramp/options"})}catch{return Cv}},async getOnrampQuote({purchaseCurrency:t,paymentCurrency:e,amount:s,network:n}){var r;try{return await fe.isNetworkSupported((r=E.state.activeCaipNetwork)==null?void 0:r.caipNetworkId)?await Ut.api.post({path:"/v1/onramp/quote",params:{projectId:$.state.projectId},body:{purchaseCurrency:t,paymentCurrency:e,amount:s,network:n}}):null}catch{return{networkFee:{amount:s,currency:e.id},paymentSubtotal:{amount:s,currency:e.id},paymentTotal:{amount:s,currency:e.id},purchaseAmount:{amount:s,currency:e.id},quoteId:"mocked-quote-id"}}},async getSmartSessions(t){var s;return await fe.isNetworkSupported((s=E.state.activeCaipNetwork)==null?void 0:s.caipNetworkId)?fe.get({path:`/v1/sessions/${t}`}):[]},async revokeSmartSession(t,e,s){var r;return await fe.isNetworkSupported((r=E.state.activeCaipNetwork)==null?void 0:r.caipNetworkId)?Ut.api.post({path:`/v1/sessions/${t}/revoke`,params:{projectId:$.state.projectId},body:{pci:e,signature:s}}):{success:!1}},setClientId(t){Ut.clientId=t,Ut.api=new So({baseUrl:Mf,clientId:t})}},ms={PHANTOM:{id:"a797aa35c0fadbfc1a53e7f675162ed5226968b44a19ee3d24385c64d1d3c393",url:"https://phantom.app"},SOLFLARE:{id:"1ca0bdd4747578705b1939af023d120677c64fe6ca76add81fda36e350605e79",url:"https://solflare.com"},COINBASE:{id:"fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa",url:"https://go.cb-w.com"},BINANCE:{id:"2fafea35bb471d22889ccb49c08d99dd0a18a37982602c33f696a5723934ba25",appId:"yFK5FCqYprrXDiVFbhyRx7",deeplink:"bnc://app.binance.com/mp/app",url:"https://app.binance.com/en/download"}},_v={handleMobileDeeplinkRedirect(t,e){const s=window.location.href,n=encodeURIComponent(s);if(t===ms.PHANTOM.id&&!("phantom"in window)){const r=s.startsWith("https")?"https":"http",i=s.split("/")[2],o=encodeURIComponent(`${r}://${i}`);window.location.href=`${ms.PHANTOM.url}/ul/browse/${n}?ref=${o}`}if(t===ms.SOLFLARE.id&&!("solflare"in window)&&(window.location.href=`${ms.SOLFLARE.url}/ul/v1/browse/${n}?ref=${n}`),e===U.CHAIN.SOLANA&&t===ms.COINBASE.id&&!("coinbaseSolana"in window)&&(window.location.href=`${ms.COINBASE.url}/dapp?cb_url=${n}`),e===U.CHAIN.BITCOIN&&t===ms.BINANCE.id&&!("binancew3w"in window)){const r=E.state.activeCaipNetwork,i=window.btoa("/pages/browser/index"),o=window.btoa(`url=${n}&defaultChainId=${(r==null?void 0:r.id)??1}`),a=new URL(ms.BINANCE.deeplink);a.searchParams.set("appId",ms.BINANCE.appId),a.searchParams.set("startPagePath",i),a.searchParams.set("startPageQuery",o);const c=new URL(ms.BINANCE.url);c.searchParams.set("_dp",window.btoa(a.toString())),window.location.href=c.toString()}}},Av=Object.freeze({enabled:!0,events:[]}),Sv=new So({baseUrl:X.getAnalyticsUrl(),clientId:null}),Iv=5,Nv=60*1e3,Tn=Ge({...Av}),Tv={state:Tn,subscribeKey(t,e){return At(Tn,t,e)},async sendError(t,e){if(!Tn.enabled)return;const s=Date.now();if(Tn.events.filter(i=>{const o=new Date(i.properties.timestamp||"").getTime();return s-o<Nv}).length>=Iv)return;const r={type:"error",event:e,properties:{errorType:t.name,errorMessage:t.message,stackTrace:t.stack,timestamp:new Date().toISOString()}};Tn.events.push(r);try{if(typeof window>"u")return;const{projectId:i,sdkType:o,sdkVersion:a}=$.state;await Sv.post({path:"/e",params:{projectId:i,st:o,sv:a||"html-wagmi-4.2.2"},body:{eventId:X.getUUID(),url:window.location.href,domain:window.location.hostname,timestamp:new Date().toISOString(),props:{type:"error",event:e,errorType:t.name,errorMessage:t.message,stackTrace:t.stack}}})}catch{}},enable(){Tn.enabled=!0},disable(){Tn.enabled=!1},clearEvents(){Tn.events=[]}};class Tr extends Error{constructor(e,s,n){super(e),this.originalName="AppKitError",this.name="AppKitError",this.category=s,this.originalError=n,n&&n instanceof Error&&(this.originalName=n.name),Object.setPrototypeOf(this,Tr.prototype);let r=!1;if(n instanceof Error&&typeof n.stack=="string"&&n.stack){const i=n.stack,o=i.indexOf(`
|
|
3
3
|
`);if(o>-1){const a=i.substring(o+1);this.stack=`${this.name}: ${this.message}
|
|
4
|
-
${a}`,r=!0}}r||(Error.captureStackTrace?Error.captureStackTrace(this,Tr):this.stack||(this.stack=`${this.name}: ${this.message}`))}}function Mu(t,e){let s="";try{t instanceof Error?s=t.message:typeof t=="string"?s=t:typeof t=="object"&&t!==null?Object.keys(t).length===0?s="Unknown error":s=(t==null?void 0:t.message)||JSON.stringify(t):s=String(t)}catch(r){s="Unknown error",console.error("Error parsing error message",r)}const n=t instanceof Tr?t:new Tr(s,e,t);throw Tv.sendError(n,n.category),n}function As(t,e="INTERNAL_SDK_ERROR"){const s={};return Object.keys(t).forEach(n=>{const r=t[n];if(typeof r=="function"){let i=r;r.constructor.name==="AsyncFunction"?i=async(...o)=>{try{return await r(...o)}catch(a){return Mu(a,e)}}:i=(...o)=>{try{return r(...o)}catch(a){return Mu(a,e)}},s[n]=i}else s[n]=r}),s}const ss=Ge({walletImages:{},networkImages:{},chainImages:{},connectorImages:{},tokenImages:{},currencyImages:{}}),Rv={state:ss,subscribeNetworkImages(t){return _t(ss.networkImages,()=>t(ss.networkImages))},subscribeKey(t,e){return At(ss,t,e)},subscribe(t){return _t(ss,()=>t(ss))},setWalletImage(t,e){ss.walletImages[t]=e},setNetworkImage(t,e){ss.networkImages[t]=e},setChainImage(t,e){ss.chainImages[t]=e},setConnectorImage(t,e){ss.connectorImages={...ss.connectorImages,[t]:e}},setTokenImage(t,e){ss.tokenImages[t]=e},setCurrencyImage(t,e){ss.currencyImages[t]=e}},bs=As(Rv),Bu={eip155:"ba0ba0cd-17c6-4806-ad93-f9d174f17900",solana:"a1b58899-f671-4276-6a5e-56ca5bd59700",polkadot:"",bip122:"0b4838db-0161-4ffe-022d-532bf03dba00",cosmos:"",sui:"",stacks:"",ton:"20f673c0-095e-49b2-07cf-eb5049dcf600"},Cc=Ge({networkImagePromises:{}}),Bf={async fetchWalletImage(t){if(t)return await te._fetchWalletImage(t),this.getWalletImageById(t)},async fetchNetworkImage(t){if(!t)return;const e=this.getNetworkImageById(t);return e||(Cc.networkImagePromises[t]||(Cc.networkImagePromises[t]=te._fetchNetworkImage(t)),await Cc.networkImagePromises[t],this.getNetworkImageById(t))},getWalletImageById(t){if(t)return bs.state.walletImages[t]},getWalletImage(t){if(t!=null&&t.image_url)return t==null?void 0:t.image_url;if(t!=null&&t.image_id)return bs.state.walletImages[t.image_id]},getNetworkImage(t){var e,s,n;if((e=t==null?void 0:t.assets)!=null&&e.imageUrl)return(s=t==null?void 0:t.assets)==null?void 0:s.imageUrl;if((n=t==null?void 0:t.assets)!=null&&n.imageId)return bs.state.networkImages[t.assets.imageId]},getNetworkImageById(t){if(t)return bs.state.networkImages[t]},getConnectorImage(t){var e;if(t!=null&&t.imageUrl)return t.imageUrl;if((e=t==null?void 0:t.info)!=null&&e.icon)return t.info.icon;if(t!=null&&t.imageId)return bs.state.connectorImages[t.imageId]},getChainImage(t){return bs.state.networkImages[Bu[t]]},getTokenImage(t){if(t)return bs.state.tokenImages[t]},getWalletImageUrl(t){if(!t)return"";const{projectId:e,sdkType:s,sdkVersion:n}=$.state,r=new URL(`${U.W3M_API_URL}/getWalletImage/${t}`);return r.searchParams.set("projectId",e),r.searchParams.set("st",s),r.searchParams.set("sv",n),r.toString()},getAssetImageUrl(t){if(!t)return"";const{projectId:e,sdkType:s,sdkVersion:n}=$.state,r=new URL(`${U.W3M_API_URL}/public/getAssetImage/${t}`);return r.searchParams.set("projectId",e),r.searchParams.set("st",s),r.searchParams.set("sv",n),r.toString()},getChainNamespaceImageUrl(t){return this.getAssetImageUrl(Bu[t])}},Ov=X.getAnalyticsUrl(),Pv=new So({baseUrl:Ov,clientId:null}),xv=["MODAL_CREATED"],kv=45,ju=1e3*10,et=Ge({timestamp:Date.now(),lastFlush:Date.now(),reportedErrors:{},data:{type:"track",event:"MODAL_CREATED"},pendingEvents:[],subscribedToVisibilityChange:!1,walletImpressions:[]}),Ee={state:et,subscribe(t){return _t(et,()=>t(et))},getSdkProperties(){const{projectId:t,sdkType:e,sdkVersion:s}=$.state;return{projectId:t,st:e,sv:s||"html-wagmi-4.2.2"}},shouldFlushEvents(){const t=JSON.stringify(et.pendingEvents).length/1024>kv,e=et.lastFlush+ju<Date.now();return t||e},_setPendingEvent(t){var e,s;try{let n=(e=E.getAccountData())==null?void 0:e.address;if("address"in t.data&&t.data.address&&(n=t.data.address),xv.includes(t.data.event)||typeof window>"u")return;const r=(s=E.getActiveCaipNetwork())==null?void 0:s.caipNetworkId;this.state.pendingEvents.push({eventId:X.getUUID(),url:window.location.href,domain:window.location.hostname,timestamp:t.timestamp,props:{...t.data,address:n,properties:{..."properties"in t.data?t.data.properties:{},caipNetworkId:r}}}),et.reportedErrors.FORBIDDEN=!1,Ee.shouldFlushEvents()&&Ee._submitPendingEvents()}catch(n){console.warn("_setPendingEvent",n)}},sendEvent(t){var s;et.timestamp=Date.now(),et.data=t;const e=["INITIALIZE","CONNECT_SUCCESS","SOCIAL_LOGIN_SUCCESS"];((s=$.state.features)!=null&&s.analytics||e.includes(t.event))&&Ee._setPendingEvent(et),this.subscribeToFlushTriggers()},sendWalletImpressionEvent(t){et.walletImpressions.push(t)},_transformPendingEventsForBatch(t){try{return t.filter(e=>e.props.event!=="WALLET_IMPRESSION_V2")}catch{return t}},_submitPendingEvents(){if(et.lastFlush=Date.now(),!(et.pendingEvents.length===0&&et.walletImpressions.length===0))try{const t=Ee._transformPendingEventsForBatch(et.pendingEvents);et.walletImpressions.length&&t.push({eventId:X.getUUID(),url:window.location.href,domain:window.location.hostname,timestamp:Date.now(),props:{type:"track",event:"WALLET_IMPRESSION_V2",items:[...et.walletImpressions]}}),Pv.sendBeacon({path:"/batch",params:Ee.getSdkProperties(),body:t}),et.reportedErrors.FORBIDDEN=!1,et.pendingEvents=[],et.walletImpressions=[]}catch{et.reportedErrors.FORBIDDEN=!0}},subscribeToFlushTriggers(){var t,e,s;et.subscribedToVisibilityChange||typeof document>"u"||(et.subscribedToVisibilityChange=!0,(t=document==null?void 0:document.addEventListener)==null||t.call(document,"visibilitychange",()=>{document.visibilityState==="hidden"&&Ee._submitPendingEvents()}),(e=document==null?void 0:document.addEventListener)==null||e.call(document,"freeze",()=>{Ee._submitPendingEvents()}),(s=window==null?void 0:window.addEventListener)==null||s.call(window,"pagehide",()=>{Ee._submitPendingEvents()}),setInterval(()=>{Ee._submitPendingEvents()},ju))}},Uv=X.getApiUrl(),$t=new So({baseUrl:Uv,clientId:null}),$v=40,Fu=4,Dv=20,we=Ge({promises:{},page:1,count:0,featured:[],allFeatured:[],recommended:[],allRecommended:[],wallets:[],filteredWallets:[],search:[],isAnalyticsEnabled:!1,excludedWallets:[],isFetchingRecommendedWallets:!1,explorerWallets:[],explorerFilteredWallets:[],plan:{tier:"none",hasExceededUsageLimit:!1,limits:{isAboveRpcLimit:!1,isAboveMauLimit:!1}}}),te={state:we,subscribeKey(t,e){return At(we,t,e)},_getSdkProperties(){const{projectId:t,sdkType:e,sdkVersion:s}=$.state;return{projectId:t,st:e||"appkit",sv:s||"html-wagmi-4.2.2"}},_filterOutExtensions(t){return $.state.isUniversalProvider?t.filter(e=>!!(e.mobile_link||e.desktop_link||e.webapp_link)):t},async _fetchWalletImage(t){const e=`${$t.baseUrl}/getWalletImage/${t}`,s=await $t.getBlob({path:e,params:te._getSdkProperties()});bs.setWalletImage(t,URL.createObjectURL(s))},async _fetchNetworkImage(t){const e=`${$t.baseUrl}/public/getAssetImage/${t}`,s=await $t.getBlob({path:e,params:te._getSdkProperties()});bs.setNetworkImage(t,URL.createObjectURL(s))},async _fetchConnectorImage(t){const e=`${$t.baseUrl}/public/getAssetImage/${t}`,s=await $t.getBlob({path:e,params:te._getSdkProperties()});bs.setConnectorImage(t,URL.createObjectURL(s))},async _fetchCurrencyImage(t){const e=`${$t.baseUrl}/public/getCurrencyImage/${t}`,s=await $t.getBlob({path:e,params:te._getSdkProperties()});bs.setCurrencyImage(t,URL.createObjectURL(s))},async _fetchTokenImage(t){const e=`${$t.baseUrl}/public/getTokenImage/${t}`,s=await $t.getBlob({path:e,params:te._getSdkProperties()});bs.setTokenImage(t,URL.createObjectURL(s))},_filterWalletsByPlatform(t){const e=t.length,s=X.isMobile()?t==null?void 0:t.filter(r=>r.mobile_link||r.webapp_link?!0:Object.values(ms).map(o=>o.id).includes(r.id)):t,n=e-s.length;return{filteredWallets:s,mobileFilteredOutWalletsLength:n}},async fetchProjectConfig(){return(await $t.get({path:"/appkit/v1/config",params:te._getSdkProperties()})).features},async fetchUsage(){try{const t=await $t.get({path:"/appkit/v1/project-limits",params:te._getSdkProperties()}),{tier:e,isAboveMauLimit:s,isAboveRpcLimit:n}=t.planLimits,r=e==="starter",i=s||n;te.state.plan={tier:e,hasExceededUsageLimit:r&&i,limits:{isAboveRpcLimit:n,isAboveMauLimit:s}}}catch(t){console.warn("Failed to fetch usage",t)}},async fetchAllowedOrigins(){try{const{allowedOrigins:t}=await $t.get({path:"/projects/v1/origins",params:te._getSdkProperties()});return t}catch(t){if(t instanceof Error&&t.cause instanceof Response){const e=t.cause.status;if(e===U.HTTP_STATUS_CODES.TOO_MANY_REQUESTS)throw new Error("RATE_LIMITED",{cause:t});if(e>=U.HTTP_STATUS_CODES.SERVER_ERROR&&e<600)throw new Error("SERVER_ERROR",{cause:t});return[]}return[]}},async fetchNetworkImages(){const t=E.getAllRequestedCaipNetworks(),e=t==null?void 0:t.map(({assets:s})=>s==null?void 0:s.imageId).filter(Boolean).filter(s=>!Bf.getNetworkImageById(s));e&&await Promise.allSettled(e.map(s=>te._fetchNetworkImage(s)))},async fetchConnectorImages(){const{connectors:t}=V.state,e=t.map(({imageId:s})=>s).filter(Boolean);await Promise.allSettled(e.map(s=>te._fetchConnectorImage(s)))},async fetchCurrencyImages(t=[]){await Promise.allSettled(t.map(e=>te._fetchCurrencyImage(e)))},async fetchTokenImages(t=[]){await Promise.allSettled(t.map(e=>te._fetchTokenImage(e)))},async fetchWallets(t){var o;const e=t.exclude??[];te._getSdkProperties().sv.startsWith("html-core-")&&e.push(...Object.values(ms).map(a=>a.id));const n=await $t.get({path:"/getWallets",params:{...te._getSdkProperties(),...t,page:String(t.page),entries:String(t.entries),include:(o=t.include)==null?void 0:o.join(","),exclude:e.join(",")}}),{filteredWallets:r,mobileFilteredOutWalletsLength:i}=te._filterWalletsByPlatform(n==null?void 0:n.data);return{data:r||[],count:n==null?void 0:n.count,mobileFilteredOutWalletsLength:i}},async prefetchWalletRanks(){const t=V.state.connectors;if(!(t!=null&&t.length))return;const e={page:1,entries:20,badge:"certified"};if(e.names=t.map(r=>r.name).join(","),E.state.activeChain===U.CHAIN.EVM){const r=[...t.flatMap(i=>{var o;return((o=i.connectors)==null?void 0:o.map(a=>{var c;return(c=a.info)==null?void 0:c.rdns}))||[]}),...t.map(i=>{var o;return(o=i.info)==null?void 0:o.rdns})].filter(i=>typeof i=="string"&&i.length>0);r.length&&(e.rdns=r.join(","))}const{data:s}=await te.fetchWallets(e);we.explorerWallets=s,V.extendConnectorsWithExplorerWallets(s);const n=E.getRequestedCaipNetworkIds().join(",");we.explorerFilteredWallets=s.filter(r=>{var i;return(i=r.chains)==null?void 0:i.some(o=>n.includes(o))})},async fetchFeaturedWallets(){const{featuredWalletIds:t}=$.state;if(t!=null&&t.length){const e={...te._getSdkProperties(),page:1,entries:(t==null?void 0:t.length)??Fu,include:t},{data:s}=await te.fetchWallets(e),n=[...s].sort((i,o)=>t.indexOf(i.id)-t.indexOf(o.id)),r=n.map(i=>i.image_id).filter(Boolean);await Promise.allSettled(r.map(i=>te._fetchWalletImage(i))),we.featured=n,we.allFeatured=n}},async fetchRecommendedWallets(){try{we.isFetchingRecommendedWallets=!0;const{includeWalletIds:t,excludeWalletIds:e,featuredWalletIds:s}=$.state,n=[...e??[],...s??[]].filter(Boolean),r=E.getRequestedCaipNetworkIds().join(","),i={page:1,entries:Fu,include:t,exclude:n,chains:r},{data:o,count:a}=await te.fetchWallets(i),c=F.getRecentWallets(),l=o.map(u=>u.image_id).filter(Boolean),d=c.map(u=>u.image_id).filter(Boolean);await Promise.allSettled([...l,...d].map(u=>te._fetchWalletImage(u))),we.recommended=o,we.allRecommended=o,we.count=a??0}catch{}finally{we.isFetchingRecommendedWallets=!1}},async fetchWalletsByPage({page:t}){const{includeWalletIds:e,excludeWalletIds:s,featuredWalletIds:n}=$.state,r=E.getRequestedCaipNetworkIds().join(","),i=[...we.recommended.map(({id:u})=>u),...s??[],...n??[]].filter(Boolean),o={page:t,entries:$v,include:e,exclude:i,chains:r},{data:a,count:c,mobileFilteredOutWalletsLength:l}=await te.fetchWallets(o);we.mobileFilteredOutWalletsLength=l+(we.mobileFilteredOutWalletsLength??0);const d=a.slice(0,Dv).map(u=>u.image_id).filter(Boolean);await Promise.allSettled(d.map(u=>te._fetchWalletImage(u))),we.wallets=X.uniqueBy([...we.wallets,...te._filterOutExtensions(a)],"id").filter(u=>{var h;return(h=u.chains)==null?void 0:h.some(p=>r.includes(p))}),we.count=c>we.count?c:we.count,we.page=t},async initializeExcludedWallets({ids:t}){const e={page:1,entries:t.length,include:t},{data:s}=await te.fetchWallets(e);s&&s.forEach(n=>{we.excludedWallets.push({rdns:n.rdns,name:n.name})})},async searchWallet({search:t,badge:e}){const{includeWalletIds:s,excludeWalletIds:n}=$.state,r=E.getRequestedCaipNetworkIds().join(",");we.search=[];const i={page:1,entries:100,search:t==null?void 0:t.trim(),badge_type:e,include:s,exclude:n,chains:r},{data:o}=await te.fetchWallets(i);Ee.sendEvent({type:"track",event:"SEARCH_WALLET",properties:{badge:e??"",search:t??""}});const a=o.map(c=>c.image_id).filter(Boolean);await Promise.allSettled([...a.map(c=>te._fetchWalletImage(c)),X.wait(300)]),we.search=te._filterOutExtensions(o)},initPromise(t,e){const s=we.promises[t];return s||(we.promises[t]=e())},prefetch({fetchConnectorImages:t=!0,fetchFeaturedWallets:e=!0,fetchRecommendedWallets:s=!0,fetchNetworkImages:n=!0,fetchWalletRanks:r=!0}={}){const i=[t&&te.initPromise("connectorImages",te.fetchConnectorImages),e&&te.initPromise("featuredWallets",te.fetchFeaturedWallets),s&&te.initPromise("recommendedWallets",te.fetchRecommendedWallets),n&&te.initPromise("networkImages",te.fetchNetworkImages),r&&te.initPromise("walletRanks",te.prefetchWalletRanks)].filter(Boolean);return Promise.allSettled(i)},prefetchAnalyticsConfig(){var t;(t=$.state.features)!=null&&t.analytics&&te.fetchAnalyticsConfig()},async fetchAnalyticsConfig(){try{const{isAnalyticsEnabled:t}=await $t.get({path:"/getAnalyticsConfig",params:te._getSdkProperties()});$.setFeatures({analytics:t})}catch{$.setFeatures({analytics:!1})}},filterByNamespaces(t){if(!(t!=null&&t.length)){we.featured=we.allFeatured,we.recommended=we.allRecommended;return}const e=E.getRequestedCaipNetworkIds().join(",");we.featured=we.allFeatured.filter(s=>{var n;return(n=s.chains)==null?void 0:n.some(r=>e.includes(r))}),we.recommended=we.allRecommended.filter(s=>{var n;return(n=s.chains)==null?void 0:n.some(r=>e.includes(r))}),we.filteredWallets=we.wallets.filter(s=>{var n;return(n=s.chains)==null?void 0:n.some(r=>e.includes(r))})},clearFilterByNamespaces(){we.filteredWallets=[]},setFilterByNamespace(t){if(!t){we.featured=we.allFeatured,we.recommended=we.allRecommended;return}const e=E.getRequestedCaipNetworkIds().join(",");we.featured=we.allFeatured.filter(s=>{var n;return(n=s.chains)==null?void 0:n.some(r=>e.includes(r))}),we.recommended=we.allRecommended.filter(s=>{var n;return(n=s.chains)==null?void 0:n.some(r=>e.includes(r))}),we.filteredWallets=we.wallets.filter(s=>{var n;return(n=s.chains)==null?void 0:n.some(r=>e.includes(r))})}},Lv=["ConnectingExternal","ConnectingMultiChain","ConnectingSocial","ConnectingFarcaster"],je=Ge({view:"Connect",history:["Connect"],transactionStack:[]}),Mv={state:je,subscribeKey(t,e){return At(je,t,e)},pushTransactionStack(t){je.transactionStack.push(t)},popTransactionStack(t){const e=je.transactionStack.pop();if(!e)return;const{onSuccess:s,onError:n,onCancel:r}=e;switch(t){case"success":s==null||s();break;case"error":n==null||n(),ue.goBack();break;case"cancel":r==null||r(),ue.goBack();break}},push(t,e){let s=t,n=e;te.state.plan.hasExceededUsageLimit&&Lv.includes(t)&&(s="UsageExceeded",n=void 0),s!==je.view&&(je.view=s,je.history.push(s),je.data=n)},reset(t,e){je.view=t,je.history=[t],je.data=e},replace(t,e){je.history.at(-1)===t||(je.view=t,je.history[je.history.length-1]=t,je.data=e)},goBack(){var n,r;const t=E.state.activeCaipAddress,e=ue.state.view==="ConnectingFarcaster",s=!t&&e;if(je.history.length>1){je.history.pop();const[i]=je.history.slice(-1);i&&(t&&i==="Connect"?je.view="Account":je.view=i)}else Te.close();(n=je.data)!=null&&n.wallet&&(je.data.wallet=void 0),(r=je.data)!=null&&r.redirectView&&(je.data.redirectView=void 0),setTimeout(()=>{var i,o,a;if(s){E.setAccountProp("farcasterUrl",void 0,E.state.activeChain);const c=V.getAuthConnector();(i=c==null?void 0:c.provider)==null||i.reload();const l=Xi($.state);(a=(o=c==null?void 0:c.provider)==null?void 0:o.syncDappData)==null||a.call(o,{metadata:l.metadata,sdkVersion:l.sdkVersion,projectId:l.projectId,sdkType:l.sdkType})}},100)},goBackToIndex(t){if(je.history.length>1){je.history=je.history.slice(0,t+1);const[e]=je.history.slice(-1);e&&(je.view=e)}},goBackOrCloseModal(){ue.state.history.length>1?ue.goBack():Te.close()}},ue=As(Mv),sn=Ge({themeMode:"dark",themeVariables:{},w3mThemeVariables:void 0}),Il={state:sn,subscribe(t){return _t(sn,()=>t(sn))},setThemeMode(t){sn.themeMode=t;try{const e=V.getAuthConnector();if(e){const s=Il.getSnapshot().themeVariables;e.provider.syncTheme({themeMode:t,themeVariables:s,w3mThemeVariables:Zi(s,t)})}}catch{console.info("Unable to sync theme to auth connector")}},setThemeVariables(t){sn.themeVariables={...sn.themeVariables,...t};try{const e=V.getAuthConnector();if(e){const s=Il.getSnapshot().themeVariables;e.provider.syncTheme({themeVariables:s,w3mThemeVariables:Zi(sn.themeVariables,sn.themeMode)})}}catch{console.info("Unable to sync theme to auth connector")}},getSnapshot(){return Xi(sn)}},Kt=As(Il),jf=Object.fromEntries(gf.map(t=>[t,void 0])),Bv=Object.fromEntries(gf.map(t=>[t,!0])),ke=Ge({allConnectors:[],connectors:[],activeConnector:void 0,filterByNamespace:void 0,activeConnectorIds:jf,filterByNamespaceMap:Bv}),jv={state:ke,subscribe(t){return _t(ke,()=>{t(ke)})},subscribeKey(t,e){return At(ke,t,e)},initialize(t){t.forEach(e=>{const s=F.getConnectedConnectorId(e);s&&V.setConnectorId(s,e)})},setActiveConnector(t){t&&(ke.activeConnector=Qi(t))},setConnectors(t){t.filter(r=>!ke.allConnectors.some(i=>i.id===r.id&&V.getConnectorName(i.name)===V.getConnectorName(r.name)&&i.chain===r.chain)).forEach(r=>{r.type!=="MULTI_CHAIN"&&ke.allConnectors.push(Qi(r))});const s=V.getEnabledNamespaces(),n=V.getEnabledConnectors(s);ke.connectors=V.mergeMultiChainConnectors(n)},filterByNamespaces(t){Object.keys(ke.filterByNamespaceMap).forEach(e=>{ke.filterByNamespaceMap[e]=!1}),t.forEach(e=>{ke.filterByNamespaceMap[e]=!0}),V.updateConnectorsForEnabledNamespaces()},filterByNamespace(t,e){ke.filterByNamespaceMap[t]=e,V.updateConnectorsForEnabledNamespaces()},updateConnectorsForEnabledNamespaces(){const t=V.getEnabledNamespaces(),e=V.getEnabledConnectors(t),s=V.areAllNamespacesEnabled();ke.connectors=V.mergeMultiChainConnectors(e),s?te.clearFilterByNamespaces():te.filterByNamespaces(t)},getEnabledNamespaces(){return Object.entries(ke.filterByNamespaceMap).filter(([t,e])=>e).map(([t])=>t)},getEnabledConnectors(t){return ke.allConnectors.filter(e=>t.includes(e.chain))},areAllNamespacesEnabled(){return Object.values(ke.filterByNamespaceMap).every(t=>t)},mergeMultiChainConnectors(t){const e=V.generateConnectorMapByName(t),s=[];return e.forEach(n=>{const r=n[0],i=(r==null?void 0:r.id)===U.CONNECTOR_ID.AUTH;n.length>1&&r?s.push({name:r.name,imageUrl:r.imageUrl,imageId:r.imageId,connectors:[...n],type:i?"AUTH":"MULTI_CHAIN",chain:"eip155",id:(r==null?void 0:r.id)||""}):r&&s.push(r)}),s},generateConnectorMapByName(t){const e=new Map;return t.forEach(s=>{const{name:n}=s,r=V.getConnectorName(n);if(!r)return;const i=e.get(r)||[];i.find(a=>a.chain===s.chain)||i.push(s),e.set(r,i)}),e},getConnectorName(t){return t&&({"Trust Wallet":"Trust"}[t]||t)},getUniqueConnectorsByName(t){const e=[];return t.forEach(s=>{e.find(n=>n.chain===s.chain)||e.push(s)}),e},addConnector(t){var e,s,n;if(t.id===U.CONNECTOR_ID.AUTH){const r=t,i=Xi($.state),o=Kt.getSnapshot().themeMode,a=Kt.getSnapshot().themeVariables;(s=(e=r==null?void 0:r.provider)==null?void 0:e.syncDappData)==null||s.call(e,{metadata:i.metadata,sdkVersion:i.sdkVersion,projectId:i.projectId,sdkType:i.sdkType}),(n=r==null?void 0:r.provider)==null||n.syncTheme({themeMode:o,themeVariables:a,w3mThemeVariables:Zi(a,o)}),V.setConnectors([t])}else V.setConnectors([t])},getAuthConnector(t){var n;const e=t||E.state.activeChain,s=ke.connectors.find(r=>r.id===U.CONNECTOR_ID.AUTH);if(s)return(n=s==null?void 0:s.connectors)!=null&&n.length?s.connectors.find(i=>i.chain===e):s},getAnnouncedConnectorRdns(){return ke.connectors.filter(t=>t.type==="ANNOUNCED").map(t=>{var e;return(e=t.info)==null?void 0:e.rdns})},getConnectorById(t){return ke.allConnectors.find(e=>e.id===t)},getConnector({id:t,namespace:e}){const s=e||E.state.activeChain;return ke.allConnectors.filter(i=>i.chain===s).find(i=>i.id===t||i.explorerId===t)},syncIfAuthConnector(t){var i,o;if(t.id!=="AUTH")return;const e=t,s=Xi($.state),n=Kt.getSnapshot().themeMode,r=Kt.getSnapshot().themeVariables;(o=(i=e==null?void 0:e.provider)==null?void 0:i.syncDappData)==null||o.call(i,{metadata:s.metadata,sdkVersion:s.sdkVersion,sdkType:s.sdkType,projectId:s.projectId}),e.provider.syncTheme({themeMode:n,themeVariables:r,w3mThemeVariables:Zi(r,n)})},getConnectorsByNamespace(t){const e=ke.allConnectors.filter(s=>s.chain===t);return V.mergeMultiChainConnectors(e)},canSwitchToSmartAccount(t){return E.checkIfSmartAccountEnabled()&&ls(t)===tt.ACCOUNT_TYPES.EOA},selectWalletConnector(t){var r;const e=(r=ue.state.data)==null?void 0:r.redirectView,s=E.state.activeChain,n=s?V.getConnector({id:t.id,namespace:s}):void 0;_v.handleMobileDeeplinkRedirect((n==null?void 0:n.explorerId)||t.id,E.state.activeChain),n?ue.push("ConnectingExternal",{connector:n,wallet:t,redirectView:e}):ue.push("ConnectingWalletConnect",{wallet:t,redirectView:e})},getConnectors(t){return t?V.getConnectorsByNamespace(t):V.mergeMultiChainConnectors(ke.allConnectors)},setFilterByNamespace(t){ke.filterByNamespace=t,ke.connectors=V.getConnectors(t),te.setFilterByNamespace(t)},setConnectorId(t,e){t&&(ke.activeConnectorIds={...ke.activeConnectorIds,[e]:t},F.setConnectedConnectorId(e,t))},removeConnectorId(t){ke.activeConnectorIds={...ke.activeConnectorIds,[t]:void 0},F.deleteConnectedConnectorId(t)},getConnectorId(t){if(t)return ke.activeConnectorIds[t]},isConnected(t){return t?!!ke.activeConnectorIds[t]:Object.values(ke.activeConnectorIds).some(e=>!!e)},resetConnectorIds(){ke.activeConnectorIds={...jf}},extendConnectorsWithExplorerWallets(t){ke.allConnectors.forEach(n=>{const r=t.find(i=>{var o;return i.id===n.id||i.rdns&&i.rdns===((o=n.info)==null?void 0:o.rdns)});r&&(n.explorerWallet=r)});const e=V.getEnabledNamespaces(),s=V.getEnabledConnectors(e);ke.connectors=V.mergeMultiChainConnectors(s)}},V=As(jv),Fv=1e3,Ci={checkNamespaceConnectorId(t,e){return V.getConnectorId(t)===e},isSocialProvider(t){return Ne.DEFAULT_REMOTE_FEATURES.socials.includes(t)},connectWalletConnect({walletConnect:t,connector:e,closeModalOnConnect:s=!0,redirectViewOnModalClose:n="Connect",onOpen:r,onConnect:i}){return new Promise((o,a)=>{if(t&&V.setActiveConnector(e),r==null||r(X.isMobile()&&t),n){const l=Te.subscribeKey("open",d=>{d||(ue.state.view!==n&&ue.replace(n),l(),a(new Error("Modal closed")))})}const c=E.subscribeKey("activeCaipAddress",l=>{l&&(i==null||i(),s&&Te.close(),c(),o(dt.parseCaipAddress(l)))})})},connectExternal(t){return new Promise((e,s)=>{const n=E.subscribeKey("activeCaipAddress",r=>{r&&(Te.close(),n(),e(dt.parseCaipAddress(r)))});G.connectExternal(t,t.chain).catch(()=>{n(),s(new Error("Connection rejected"))})})},connectSocial({social:t,namespace:e,closeModalOnConnect:s=!0,onOpenFarcaster:n,onConnect:r}){let i,o=!1,a=null;const c=e||E.state.activeChain,l=E.subscribeKey("activeCaipAddress",d=>{d&&(s&&Te.close(),l())});return new Promise((d,u)=>{async function h(g){var f;if((f=g.data)!=null&&f.resultUri)if(g.origin===U.SECURE_SITE_SDK_ORIGIN){window.removeEventListener("message",h,!1);try{const w=V.getAuthConnector(c);if(w&&!o){i&&i.close(),o=!0;const v=g.data.resultUri;Ee.sendEvent({type:"track",event:"SOCIAL_LOGIN_REQUEST_USER_DATA",properties:{provider:t}}),F.setConnectedSocialProvider(t),await G.connectExternal({id:w.id,type:w.type,socialUri:v},w.chain);const N=E.state.activeCaipAddress;if(!N){u(new Error("Failed to connect"));return}d(dt.parseCaipAddress(N)),Ee.sendEvent({type:"track",event:"SOCIAL_LOGIN_SUCCESS",properties:{provider:t}})}}catch(w){Ee.sendEvent({type:"track",event:"SOCIAL_LOGIN_ERROR",properties:{provider:t,message:X.parseError(w)}}),u(new Error("Failed to connect"))}}else Ee.sendEvent({type:"track",event:"SOCIAL_LOGIN_ERROR",properties:{provider:t,message:"Untrusted Origin"}})}async function p(){if(Ee.sendEvent({type:"track",event:"SOCIAL_LOGIN_STARTED",properties:{provider:t}}),t==="farcaster"){n==null||n();const g=Te.subscribeKey("open",w=>{!w&&t==="farcaster"&&(u(new Error("Popup closed")),r==null||r(),g())}),f=V.getAuthConnector();if(f){const w=E.getAccountData(c);if(!(w!=null&&w.farcasterUrl))try{const{url:v}=await f.provider.getFarcasterUri();E.setAccountProp("farcasterUrl",v,c)}catch{u(new Error("Failed to connect to farcaster"))}}}else{const g=V.getAuthConnector();a=X.returnOpenHref(`${U.SECURE_SITE_SDK_ORIGIN}/loading`,"popupWindow","width=600,height=800,scrollbars=yes");try{if(g){const{uri:f}=await g.provider.getSocialRedirectUri({provider:t});if(a&&f){a.location.href=f,i=a;const w=setInterval(()=>{i!=null&&i.closed&&!o&&(u(new Error("Popup closed")),clearInterval(w))},1e3);window.addEventListener("message",h,!1)}else a==null||a.close(),u(new Error("Failed to initiate social connection"))}}catch{u(new Error("Failed to initiate social connection")),a==null||a.close()}}}p()})},connectEmail({closeModalOnConnect:t=!0,redirectViewOnModalClose:e="Connect",onOpen:s,onConnect:n}){return new Promise((r,i)=>{if(s==null||s(),e){const a=Te.subscribeKey("open",c=>{c||(ue.state.view!==e&&ue.replace(e),a(),i(new Error("Modal closed")))})}const o=E.subscribeKey("activeCaipAddress",a=>{a&&(n==null||n(),t&&Te.close(),o(),r(dt.parseCaipAddress(a)))})})},async updateEmail(){const t=F.getConnectedConnectorId(E.state.activeChain),e=V.getAuthConnector();if(!e)throw new Error("No auth connector found");if(t!==U.CONNECTOR_ID.AUTH)throw new Error("Not connected to email or social");const s=e.provider.getEmail()??"";return await Te.open({view:"UpdateEmailWallet",data:{email:s,redirectView:void 0}}),new Promise((n,r)=>{const i=setInterval(()=>{const a=e.provider.getEmail()??"";a!==s&&(Te.close(),clearInterval(i),o(),n({email:a}))},Fv),o=Te.subscribeKey("open",a=>{a||(ue.state.view!=="Connect"&&ue.push("Connect"),clearInterval(i),o(),r(new Error("Modal closed")))})})},canSwitchToSmartAccount(t){return E.checkIfSmartAccountEnabled()&&ls(t)===tt.ACCOUNT_TYPES.EOA}};function Ff(){var n,r;const t=((n=E.state.activeCaipNetwork)==null?void 0:n.chainNamespace)||"eip155",e=((r=E.state.activeCaipNetwork)==null?void 0:r.id)||1,s=Ne.NATIVE_TOKEN_ADDRESS[t];return`${t}:${e}:${s}`}function ls(t){var s;return(s=E.getAccountData(t))==null?void 0:s.preferredAccountType}function ki(t){var e,s;return t?(s=(e=E.state.chains.get(t))==null?void 0:e.networkState)==null?void 0:s.caipNetwork:E.state.activeCaipNetwork}const Ua={getConnectionStatus(t,e){const s=V.state.activeConnectorIds[e],n=G.getConnections(e);return!!s&&t.connectorId===s?"connected":n.some(o=>o.connectorId.toLowerCase()===t.connectorId.toLowerCase())?"active":"disconnected"},excludeConnectorAddressFromConnections({connections:t,connectorId:e,addresses:s}){return t.map(n=>{if((e?n.connectorId.toLowerCase()===e.toLowerCase():!1)&&s){const i=n.accounts.filter(o=>!s.some(c=>c.toLowerCase()===o.address.toLowerCase()));return{...n,accounts:i}}return n})},excludeExistingConnections(t,e){const s=new Set(t);return e.filter(n=>!s.has(n.connectorId))},getConnectionsByConnectorId(t,e){return t.filter(s=>s.connectorId.toLowerCase()===e.toLowerCase())},getConnectionsData(t){var a;const e=!!((a=$.state.remoteFeatures)!=null&&a.multiWallet),s=V.state.activeConnectorIds[t],n=G.getConnections(t),i=(G.state.recentConnections.get(t)??[]).filter(c=>V.getConnectorById(c.connectorId)),o=Ua.excludeExistingConnections([...n.map(c=>c.connectorId),...s?[s]:[]],i);return e?{connections:n,recentConnections:o}:{connections:n.filter(c=>c.connectorId.toLowerCase()===(s==null?void 0:s.toLowerCase())),recentConnections:[]}},onConnectMobile(t){const e=G.state.wcUri;if(t!=null&&t.mobile_link&&e)try{G.setWcError(!1);const{mobile_link:s,link_mode:n,name:r}=t,{redirect:i,redirectUniversalLink:o,href:a}=X.formatNativeUrl(s,e,n),c=i,l=o,d=X.isIframe()?"_top":"_self";G.setWcLinking({name:r,href:a}),G.setRecentWallet(t),$.state.experimental_preferUniversalLinks&&l?X.openHref(l,d):X.openHref(c,d)}catch(s){Ee.sendEvent({type:"track",event:"CONNECT_PROXY_ERROR",properties:{message:s instanceof Error?s.message:"Error parsing the deep link",uri:e,mobile_link:t.mobile_link,name:t.name}}),G.setWcError(!0)}}},Br=Ge({loading:!1,open:!1,selectedNetworkId:void 0,activeChain:void 0,initialized:!1,connectingWallet:void 0}),ds={state:Br,subscribe(t){return _t(Br,()=>t(Br))},subscribeOpen(t){return At(Br,"open",t)},set(t){Object.assign(Br,{...Br,...t})}},Ye=Ge({transactions:[],transactionsByYear:{},lastNetworkInView:void 0,loading:!1,empty:!1,next:void 0}),qv={state:Ye,subscribe(t){return _t(Ye,()=>t(Ye))},setLastNetworkInView(t){Ye.lastNetworkInView=t},async fetchTransactions(t){var e;if(!t)throw new Error("Transactions can't be fetched without an accountAddress");Ye.loading=!0;try{const s=await fe.fetchTransactions({account:t,cursor:Ye.next,chainId:(e=E.state.activeCaipNetwork)==null?void 0:e.caipNetworkId}),n=ha.filterSpamTransactions(s.data),r=ha.filterByConnectedChain(n),i=[...Ye.transactions,...r];Ye.loading=!1,Ye.transactions=i,Ye.transactionsByYear=ha.groupTransactionsByYearAndMonth(Ye.transactionsByYear,r),Ye.empty=i.length===0,Ye.next=s.next?s.next:void 0}catch{const n=E.state.activeChain;Ee.sendEvent({type:"track",event:"ERROR_FETCH_TRANSACTIONS",properties:{address:t,projectId:$.state.projectId,cursor:Ye.next,isSmartAccount:ls(n)===tt.ACCOUNT_TYPES.SMART_ACCOUNT}}),zs.showError("Failed to fetch transactions"),Ye.loading=!1,Ye.empty=!0,Ye.next=void 0}},groupTransactionsByYearAndMonth(t={},e=[]){const s=t;return e.forEach(n=>{const r=new Date(n.metadata.minedAt).getFullYear(),i=new Date(n.metadata.minedAt).getMonth(),o=s[r]??{},c=(o[i]??[]).filter(l=>l.id!==n.id);s[r]={...o,[i]:[...c,n].sort((l,d)=>new Date(d.metadata.minedAt).getTime()-new Date(l.metadata.minedAt).getTime())}}),s},filterSpamTransactions(t){return t.filter(e=>{var n;return!((n=e.transfers)==null?void 0:n.every(r=>{var i;return((i=r.nft_info)==null?void 0:i.flags.is_spam)===!0}))})},filterByConnectedChain(t){var n;const e=(n=E.state.activeCaipNetwork)==null?void 0:n.caipNetworkId;return t.filter(r=>r.metadata.chain===e)},clearCursor(){Ye.next=void 0},resetTransactions(){Ye.transactions=[],Ye.transactionsByYear={},Ye.lastNetworkInView=void 0,Ye.loading=!1,Ye.empty=!1,Ye.next=void 0}},ha=As(qv,"API_ERROR"),Ie=Ge({connections:new Map,recentConnections:new Map,isSwitchingConnection:!1,wcError:!1,wcFetchingUri:!1,buffering:!1,status:"disconnected"});let sr;const Wv={state:Ie,subscribe(t){return _t(Ie,()=>t(Ie))},subscribeKey(t,e){return At(Ie,t,e)},_getClient(){return Ie._client},setClient(t){Ie._client=Qi(t)},initialize(t){const e=t.filter(s=>!!s.namespace).map(s=>s.namespace);G.syncStorageConnections(e)},syncStorageConnections(t){const e=F.getConnections(),s=t??Array.from(E.state.chains.keys());for(const n of s){const r=e[n]??[],i=new Map(Ie.recentConnections);i.set(n,r),Ie.recentConnections=i}},getConnections(t){return t?Ie.connections.get(t)??[]:[]},hasAnyConnection(t){const e=G.state.connections;return Array.from(e.values()).flatMap(s=>s).some(({connectorId:s})=>s===t)},async connectWalletConnect({cache:t="auto"}={}){var s,n,r,i;Ie.wcFetchingUri=!0;const e=X.isTelegram()||X.isSafari()&&X.isIos();if(t==="always"||t==="auto"&&e){if(sr){await sr,sr=void 0;return}if(!X.isPairingExpired(Ie==null?void 0:Ie.wcPairingExpiry)){const o=Ie.wcUri;Ie.wcUri=o;return}sr=(n=(s=G._getClient())==null?void 0:s.connectWalletConnect)==null?void 0:n.call(s).catch(()=>{}),G.state.status="connecting",await sr,sr=void 0,Ie.wcPairingExpiry=void 0,G.state.status="connected"}else await((i=(r=G._getClient())==null?void 0:r.connectWalletConnect)==null?void 0:i.call(r))},async connectExternal(t,e,s=!0){var o,a,c;const n=await((a=(o=G._getClient())==null?void 0:o.connectExternal)==null?void 0:a.call(o,t));s&&E.setActiveNamespace(e);const r=V.state.allConnectors.find(l=>l.id===(t==null?void 0:t.id)),i=t.type==="AUTH"?"email":"browser";return Ee.sendEvent({type:"track",event:"CONNECT_SUCCESS",properties:{method:i,name:(r==null?void 0:r.name)||"Unknown",view:ue.state.view,walletRank:(c=r==null?void 0:r.explorerWallet)==null?void 0:c.order}}),n},async reconnectExternal(t){var s,n;await((n=(s=G._getClient())==null?void 0:s.reconnectExternal)==null?void 0:n.call(s,t));const e=t.chain||E.state.activeChain;e&&V.setConnectorId(t.id,e)},async setPreferredAccountType(t,e){var n;if(!e)return;Te.setLoading(!0,E.state.activeChain);const s=V.getAuthConnector();s&&(E.setAccountProp("preferredAccountType",t,e),await s.provider.setPreferredAccount(t),F.setPreferredAccountTypes(Object.entries(E.state.chains).reduce((r,[i,o])=>{const a=i,c=ls(a);return c!==void 0&&(r[a]=c),r},{})),await G.reconnectExternal(s),Te.setLoading(!1,E.state.activeChain),Ee.sendEvent({type:"track",event:"SET_PREFERRED_ACCOUNT_TYPE",properties:{accountType:t,network:((n=E.state.activeCaipNetwork)==null?void 0:n.caipNetworkId)||""}}))},async signMessage(t){var e;return(e=G._getClient())==null?void 0:e.signMessage(t)},parseUnits(t,e){var s;return(s=G._getClient())==null?void 0:s.parseUnits(t,e)},formatUnits(t,e){var s;return(s=G._getClient())==null?void 0:s.formatUnits(t,e)},updateBalance(t){var e;return(e=G._getClient())==null?void 0:e.updateBalance(t)},async sendTransaction(t){var e;return(e=G._getClient())==null?void 0:e.sendTransaction(t)},async getCapabilities(t){var e;return(e=G._getClient())==null?void 0:e.getCapabilities(t)},async grantPermissions(t){var e;return(e=G._getClient())==null?void 0:e.grantPermissions(t)},async walletGetAssets(t){var e;return((e=G._getClient())==null?void 0:e.walletGetAssets(t))??{}},async estimateGas(t){var e;return(e=G._getClient())==null?void 0:e.estimateGas(t)},async writeContract(t){var e;return(e=G._getClient())==null?void 0:e.writeContract(t)},async getEnsAddress(t){var e;return(e=G._getClient())==null?void 0:e.getEnsAddress(t)},async getEnsAvatar(t){var e;return(e=G._getClient())==null?void 0:e.getEnsAvatar(t)},checkInstalled(t){var e,s;return((s=(e=G._getClient())==null?void 0:e.checkInstalled)==null?void 0:s.call(e,t))||!1},resetWcConnection(){Ie.wcUri=void 0,Ie.wcPairingExpiry=void 0,Ie.wcLinking=void 0,Ie.recentWallet=void 0,Ie.wcFetchingUri=!1,Ie.status="disconnected",ha.resetTransactions(),F.deleteWalletConnectDeepLink(),F.deleteRecentWallet(),ds.set({connectingWallet:void 0})},resetUri(){Ie.wcUri=void 0,Ie.wcPairingExpiry=void 0,sr=void 0,Ie.wcFetchingUri=!1,ds.set({connectingWallet:void 0})},finalizeWcConnection(t){var n,r;const{wcLinking:e,recentWallet:s}=G.state;e&&F.setWalletConnectDeepLink(e),s&&F.setAppKitRecent(s),t&&Ee.sendEvent({type:"track",event:"CONNECT_SUCCESS",address:t,properties:{method:e?"mobile":"qrcode",name:((r=(n=ue.state.data)==null?void 0:n.wallet)==null?void 0:r.name)||"Unknown",view:ue.state.view,walletRank:s==null?void 0:s.order}})},setWcBasic(t){Ie.wcBasic=t},setUri(t){Ie.wcUri=t,Ie.wcFetchingUri=!1,Ie.wcPairingExpiry=X.getPairingExpiry()},setWcLinking(t){Ie.wcLinking=t},setWcError(t){Ie.wcError=t,Ie.wcFetchingUri=!1,Ie.buffering=!1},setRecentWallet(t){Ie.recentWallet=t},setBuffering(t){Ie.buffering=t},setStatus(t){Ie.status=t},setIsSwitchingConnection(t){Ie.isSwitchingConnection=t},async disconnect({id:t,namespace:e,initialDisconnect:s}={}){var n;try{await((n=G._getClient())==null?void 0:n.disconnect({id:t,chainNamespace:e,initialDisconnect:s}))}catch(r){throw new Tr("Failed to disconnect","INTERNAL_SDK_ERROR",r)}},async disconnectConnector({id:t,namespace:e}){var s;try{await((s=G._getClient())==null?void 0:s.disconnectConnector({id:t,namespace:e}))}catch(n){throw new Tr("Failed to disconnect connector","INTERNAL_SDK_ERROR",n)}},setConnections(t,e){const s=new Map(Ie.connections);s.set(e,t),Ie.connections=s},async handleAuthAccountSwitch({address:t,namespace:e}){var i,o;const s=E.getAccountData(e),n=(o=(i=s==null?void 0:s.user)==null?void 0:i.accounts)==null?void 0:o.find(a=>a.type==="smartAccount"),r=n&&n.address.toLowerCase()===t.toLowerCase()&&Ci.canSwitchToSmartAccount(e)?"smartAccount":"eoa";await G.setPreferredAccountType(r,e)},async handleActiveConnection({connection:t,namespace:e,address:s}){const n=V.getConnectorById(t.connectorId),r=t.connectorId===U.CONNECTOR_ID.AUTH;if(!n)throw new Error(`No connector found for connection: ${t.connectorId}`);if(r)s&&await G.handleAuthAccountSwitch({address:s,namespace:e});else{const i=await G.connectExternal({id:n.id,type:n.type,provider:n.provider,address:s,chain:e},e);return i==null?void 0:i.address}return s},async handleDisconnectedConnection({connection:t,namespace:e,address:s,closeModalOnConnect:n}){var l,d;const r=V.getConnectorById(t.connectorId),i=(d=(l=t.auth)==null?void 0:l.name)==null?void 0:d.toLowerCase(),o=t.connectorId===U.CONNECTOR_ID.AUTH,a=t.connectorId===U.CONNECTOR_ID.WALLET_CONNECT;if(!r)throw new Error(`No connector found for connection: ${t.connectorId}`);let c;if(o)if(i&&Ci.isSocialProvider(i)){const{address:u}=await Ci.connectSocial({social:i,closeModalOnConnect:n,onOpenFarcaster(){Te.open({view:"ConnectingFarcaster"})},onConnect(){ue.replace("ProfileWallets")}});c=u}else{const{address:u}=await Ci.connectEmail({closeModalOnConnect:n,onOpen(){Te.open({view:"EmailLogin"})},onConnect(){ue.replace("ProfileWallets")}});c=u}else if(a){const{address:u}=await Ci.connectWalletConnect({walletConnect:!0,connector:r,closeModalOnConnect:n,onOpen(h){const p=h?"AllWallets":"ConnectingWalletConnect";Te.state.open?ue.push(p):Te.open({view:p})},onConnect(){ue.replace("ProfileWallets")}});c=u}else{const u=await G.connectExternal({id:r.id,type:r.type,provider:r.provider,chain:e},e);u&&(c=u.address)}return o&&s&&await G.handleAuthAccountSwitch({address:s,namespace:e}),c},async switchConnection({connection:t,address:e,namespace:s,closeModalOnConnect:n,onChange:r}){var c;let i;const o=(c=E.getAccountData(s))==null?void 0:c.caipAddress;if(o){const{address:l}=dt.parseCaipAddress(o);i=l}const a=Ua.getConnectionStatus(t,s);switch(a){case"connected":case"active":{const l=await G.handleActiveConnection({connection:t,namespace:s,address:e});if(i&&l){const d=l.toLowerCase()!==i.toLowerCase();r==null||r({address:l,namespace:s,hasSwitchedAccount:d,hasSwitchedWallet:a==="active"})}break}case"disconnected":{const l=await G.handleDisconnectedConnection({connection:t,namespace:s,address:e,closeModalOnConnect:n});l&&(r==null||r({address:l,namespace:s,hasSwitchedAccount:!0,hasSwitchedWallet:!0}));break}default:throw new Error(`Invalid connection status: ${a}`)}}},G=As(Wv),_c={createBalance(t,e){const s={name:t.metadata.name||"",symbol:t.metadata.symbol||"",decimals:t.metadata.decimals||0,value:t.metadata.value||0,price:t.metadata.price||0,iconUrl:t.metadata.iconUrl||""};return{name:s.name,symbol:s.symbol,chainId:e,address:t.address==="native"?void 0:this.convertAddressToCAIP10Address(t.address,e),value:s.value,price:s.price,quantity:{decimals:s.decimals.toString(),numeric:this.convertHexToBalance({hex:t.balance,decimals:s.decimals})},iconUrl:s.iconUrl}},convertHexToBalance({hex:t,decimals:e}){return mf(BigInt(t),e)},convertAddressToCAIP10Address(t,e){return`${e}:${t}`},createCAIP2ChainId(t,e){return`${e}:${parseInt(t,16)}`},getChainIdHexFromCAIP2ChainId(t){const e=t.split(":");if(e.length<2||!e[1])return"0x0";const s=e[1],n=parseInt(s,10);return isNaN(n)?"0x0":`0x${n.toString(16)}`},isWalletGetAssetsResponse(t){return typeof t!="object"||t===null?!1:Object.values(t).every(e=>Array.isArray(e)&&e.every(s=>this.isValidAsset(s)))},isValidAsset(t){return typeof t=="object"&&t!==null&&typeof t.address=="string"&&typeof t.balance=="string"&&(t.type==="ERC20"||t.type==="NATIVE")&&typeof t.metadata=="object"&&t.metadata!==null&&typeof t.metadata.name=="string"&&typeof t.metadata.symbol=="string"&&typeof t.metadata.decimals=="number"&&typeof t.metadata.price=="number"&&typeof t.metadata.iconUrl=="string"}};let Ac;async function qu(){if(!Ac){const{createPublicClient:t,http:e,defineChain:s}=await Dt(async()=>{const{createPublicClient:n,http:r,defineChain:i}=await import("./index-47YmILpg.js");return{createPublicClient:n,http:r,defineChain:i}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]));Ac={createPublicClient:t,http:e,defineChain:s}}return Ac}const Nl={getBlockchainApiRpcUrl(t,e){const s=new URL("https://rpc.walletconnect.org/v1/");return s.searchParams.set("chainId",t),s.searchParams.set("projectId",e),s.toString()},async getViemChain(t){const{defineChain:e}=await qu(),{chainId:s}=dt.parseCaipNetworkId(t.caipNetworkId);return e({...t,id:Number(s)})},async createViemPublicClient(t){const{createPublicClient:e,http:s}=await qu(),n=$.state.projectId,r=await Nl.getViemChain(t);if(!r)throw new Error(`Chain ${t.caipNetworkId} not found in viem/chains`);return e({chain:r,transport:s(Nl.getBlockchainApiRpcUrl(t.caipNetworkId,n))})}},_d={async getMyTokensWithBalance(t){var a;const e=(a=E.getAccountData())==null?void 0:a.address,s=E.state.activeCaipNetwork,n=V.getConnectorId("eip155")===U.CONNECTOR_ID.AUTH;if(!e||!s)return[];const r=`${s.caipNetworkId}:${e}`,i=F.getBalanceCacheForCaipAddress(r);if(i)return i.balances;if(s.chainNamespace===U.CHAIN.EVM&&n){const c=await this.getEIP155Balances(e,s);if(c)return this.filterLowQualityTokens(c)}const o=await fe.getBalance(e,s.caipNetworkId,t);return this.filterLowQualityTokens(o.balances)},async getEIP155Balances(t,e){var s,n;try{const r=_c.getChainIdHexFromCAIP2ChainId(e.caipNetworkId),i=await G.getCapabilities(t);if(!((n=(s=i==null?void 0:i[r])==null?void 0:s.assetDiscovery)!=null&&n.supported))return null;const o=await G.walletGetAssets({account:t,chainFilter:[r]});if(!_c.isWalletGetAssetsResponse(o))return null;const c=(o[r]||[]).map(l=>_c.createBalance(l,e.caipNetworkId));return F.updateBalanceCache({caipAddress:`${e.caipNetworkId}:${t}`,balance:{balances:c},timestamp:Date.now()}),c}catch{return null}},filterLowQualityTokens(t){return t.filter(e=>e.quantity.decimals!=="0")},async fetchERC20Balance({caipAddress:t,assetAddress:e,caipNetwork:s}){const n=await Nl.createViemPublicClient(s),{address:r}=dt.parseCaipAddress(t),[{result:i},{result:o},{result:a},{result:c}]=await n.multicall({contracts:[{address:e,functionName:"name",args:[],abi:Lo},{address:e,functionName:"symbol",args:[],abi:Lo},{address:e,functionName:"balanceOf",args:[r],abi:Lo},{address:e,functionName:"decimals",args:[],abi:Lo}]});return{name:i,symbol:o,decimals:c,balance:a&&c?mf(a,c):"0"}}},Sc={adapters:{}},qf={state:Sc,initialize(t){Sc.adapters={...t}},get(t){return Sc.adapters[t]}},$a={eip155:void 0,solana:void 0,polkadot:void 0,bip122:void 0,cosmos:void 0,sui:void 0,stacks:void 0,ton:void 0},qt=Ge({providers:{...$a},providerIds:{...$a}}),He={state:qt,subscribeKey(t,e){return At(qt,t,e)},subscribe(t){return _t(qt,()=>{t(qt)})},subscribeProviders(t){return _t(qt.providers,()=>t(qt.providers))},setProvider(t,e){t&&e&&(qt.providers[t]=Qi(e))},getProvider(t){if(t)return qt.providers[t]},setProviderId(t,e){e&&(qt.providerIds[t]=e)},getProviderId(t){if(t)return qt.providerIds[t]},reset(){qt.providers={...$a},qt.providerIds={...$a}},resetChain(t){qt.providers[t]=void 0,qt.providerIds[t]=void 0}},Hv={async getTokenList(t){var n;const e=await fe.fetchSwapTokens({chainId:t});return((n=e==null?void 0:e.tokens)==null?void 0:n.map(r=>({...r,eip2612:!1,quantity:{decimals:"0",numeric:"0"},price:0,value:0})))||[]},async fetchGasPrice(){var e;const t=E.state.activeCaipNetwork;if(!t)return null;try{switch(t.chainNamespace){case"solana":const s=(e=await(G==null?void 0:G.estimateGas({chainNamespace:"solana"})))==null?void 0:e.toString();return{standard:s,fast:s,instant:s};case"eip155":default:return await fe.fetchGasPrice({chainId:t.caipNetworkId})}}catch{return null}},async fetchSwapAllowance({tokenAddress:t,userAddress:e,sourceTokenAmount:s,sourceTokenDecimals:n}){const r=await fe.fetchSwapAllowance({tokenAddress:t,userAddress:e});if(r!=null&&r.allowance&&s&&n){const i=G.parseUnits(s,n)||0;return BigInt(r.allowance)>=i}return!1},async getMyTokensWithBalance(t){const e=await _d.getMyTokensWithBalance(t);return E.setAccountProp("tokenBalance",e,E.state.activeChain),this.mapBalancesToSwapTokens(e)},mapBalancesToSwapTokens(t){return(t==null?void 0:t.map(e=>({...e,address:e!=null&&e.address?e.address:Ff(),decimals:parseInt(e.quantity.decimals,10),logoUri:e.iconUrl,eip2612:!1})))||[]},async handleSwapError(t){var e,s;try{const n=t==null?void 0:t.cause;if(!(n!=null&&n.json))return;const r=await n.json(),i=(s=(e=r==null?void 0:r.reasons)==null?void 0:e[0])==null?void 0:s.description;return i!=null&&i.includes("insufficient liquidity")?"Insufficient liquidity":void 0}catch{return}}},Ue=Ge({tokenBalances:[],loading:!1}),Vv={state:Ue,subscribe(t){return _t(Ue,()=>t(Ue))},subscribeKey(t,e){return At(Ue,t,e)},setToken(t){t&&(Ue.token=Qi(t))},setTokenAmount(t){Ue.sendTokenAmount=t},setReceiverAddress(t){Ue.receiverAddress=t},setReceiverProfileImageUrl(t){Ue.receiverProfileImageUrl=t},setReceiverProfileName(t){Ue.receiverProfileName=t},setNetworkBalanceInUsd(t){Ue.networkBalanceInUSD=t},setLoading(t){Ue.loading=t},getSdkEventProperties(t){var e,s;return{message:X.parseError(t),isSmartAccount:ls(E.state.activeChain)===tt.ACCOUNT_TYPES.SMART_ACCOUNT,token:((e=Ue.token)==null?void 0:e.symbol)||"",amount:Ue.sendTokenAmount??0,network:((s=E.state.activeCaipNetwork)==null?void 0:s.caipNetworkId)||""}},async sendToken(){var t;try{switch(Ae.setLoading(!0),(t=E.state.activeCaipNetwork)==null?void 0:t.chainNamespace){case"eip155":await Ae.sendEvmToken();return;case"solana":await Ae.sendSolanaToken();return;default:throw new Error("Unsupported chain")}}catch(e){throw gn.isUserRejectedRequestError(e)?new _f(e):e}finally{Ae.setLoading(!1)}},async sendEvmToken(){var s,n,r;const t=E.state.activeChain;if(!t)throw new Error("SendController:sendEvmToken - activeChainNamespace is required");const e=ls(t);if(!Ae.state.sendTokenAmount||!Ae.state.receiverAddress)throw new Error("An amount and receiver address are required");if(!Ae.state.token)throw new Error("A token is required");if((s=Ae.state.token)!=null&&s.address){Ee.sendEvent({type:"track",event:"SEND_INITIATED",properties:{isSmartAccount:e===tt.ACCOUNT_TYPES.SMART_ACCOUNT,token:Ae.state.token.address,amount:Ae.state.sendTokenAmount,network:((n=E.state.activeCaipNetwork)==null?void 0:n.caipNetworkId)||""}});const{hash:i}=await Ae.sendERC20Token({receiverAddress:Ae.state.receiverAddress,tokenAddress:Ae.state.token.address,sendTokenAmount:Ae.state.sendTokenAmount,decimals:Ae.state.token.quantity.decimals});i&&(Ue.hash=i)}else{Ee.sendEvent({type:"track",event:"SEND_INITIATED",properties:{isSmartAccount:e===tt.ACCOUNT_TYPES.SMART_ACCOUNT,token:Ae.state.token.symbol||"",amount:Ae.state.sendTokenAmount,network:((r=E.state.activeCaipNetwork)==null?void 0:r.caipNetworkId)||""}});const{hash:i}=await Ae.sendNativeToken({receiverAddress:Ae.state.receiverAddress,sendTokenAmount:Ae.state.sendTokenAmount,decimals:Ae.state.token.quantity.decimals});i&&(Ue.hash=i)}},async fetchTokenBalance(t){var o,a,c;Ue.loading=!0;const e=E.state.activeChain,s=(o=E.state.activeCaipNetwork)==null?void 0:o.caipNetworkId,n=(a=E.state.activeCaipNetwork)==null?void 0:a.chainNamespace,r=((c=E.getAccountData(e))==null?void 0:c.caipAddress)??E.state.activeCaipAddress,i=r?X.getPlainAddress(r):void 0;if(Ue.lastRetry&&!X.isAllowedRetry(Ue.lastRetry,30*Ne.ONE_SEC_MS))return Ue.loading=!1,[];try{if(i&&s&&n){const l=await _d.getMyTokensWithBalance();return Ue.tokenBalances=l,Ue.lastRetry=void 0,l}}catch(l){Ue.lastRetry=Date.now(),t==null||t(l),zs.showError("Token Balance Unavailable")}finally{Ue.loading=!1}return[]},fetchNetworkBalance(){if(Ue.tokenBalances.length===0)return;const t=Hv.mapBalancesToSwapTokens(Ue.tokenBalances);if(!t)return;const e=t.find(s=>s.address===Ff());e&&(Ue.networkBalanceInUSD=e?Yy.multiply(e.quantity.numeric,e.price).toString():"0")},async sendNativeToken(t){var o,a,c,l;ue.pushTransactionStack({});const e=t.receiverAddress,s=(o=E.getAccountData())==null?void 0:o.address,n=G.parseUnits(t.sendTokenAmount.toString(),Number(t.decimals)),i=await G.sendTransaction({chainNamespace:U.CHAIN.EVM,to:e,address:s,data:"0x",value:n??BigInt(0)});return Ee.sendEvent({type:"track",event:"SEND_SUCCESS",properties:{isSmartAccount:ls("eip155")===tt.ACCOUNT_TYPES.SMART_ACCOUNT,token:((a=Ae.state.token)==null?void 0:a.symbol)||"",amount:t.sendTokenAmount,network:((c=E.state.activeCaipNetwork)==null?void 0:c.caipNetworkId)||"",hash:i||""}}),(l=G._getClient())==null||l.updateBalance("eip155"),Ae.resetSend(),{hash:i}},async sendERC20Token(t){var n,r,i;ue.pushTransactionStack({onSuccess(){ue.replace("Account")}});const e=G.parseUnits(t.sendTokenAmount.toString(),Number(t.decimals)),s=(n=E.getAccountData())==null?void 0:n.address;if(s&&t.sendTokenAmount&&t.receiverAddress&&t.tokenAddress){const o=X.getPlainAddress(t.tokenAddress);if(!o)throw new Error("SendController:sendERC20Token - tokenAddress is required");const a=await G.writeContract({fromAddress:s,tokenAddress:o,args:[t.receiverAddress,e??BigInt(0)],method:"transfer",abi:Qy.getERC20Abi(o),chainNamespace:U.CHAIN.EVM});return Ee.sendEvent({type:"track",event:"SEND_SUCCESS",properties:{isSmartAccount:ls("eip155")===tt.ACCOUNT_TYPES.SMART_ACCOUNT,token:((r=Ae.state.token)==null?void 0:r.symbol)||"",amount:t.sendTokenAmount,network:((i=E.state.activeCaipNetwork)==null?void 0:i.caipNetworkId)||"",hash:a||""}}),Ae.resetSend(),{hash:a}}return{hash:void 0}},async sendSolanaToken(){var s,n,r;if(!Ae.state.sendTokenAmount||!Ae.state.receiverAddress)throw new Error("An amount and receiver address are required");ue.pushTransactionStack({onSuccess(){ue.replace("Account")}});let t;Ae.state.token&&Ae.state.token.address!==Ne.SOLANA_NATIVE_TOKEN_ADDRESS&&(X.isCaipAddress(Ae.state.token.address)?t=X.getPlainAddress(Ae.state.token.address):t=Ae.state.token.address);const e=await G.sendTransaction({chainNamespace:"solana",tokenMint:t,to:Ae.state.receiverAddress,value:Ae.state.sendTokenAmount});e&&(Ue.hash=e),(s=G._getClient())==null||s.updateBalance("solana"),Ee.sendEvent({type:"track",event:"SEND_SUCCESS",properties:{isSmartAccount:!1,token:((n=Ae.state.token)==null?void 0:n.symbol)||"",amount:Ae.state.sendTokenAmount,network:((r=E.state.activeCaipNetwork)==null?void 0:r.caipNetworkId)||"",hash:e||""}}),Ae.resetSend()},resetSend(){Ue.token=void 0,Ue.sendTokenAmount=void 0,Ue.receiverAddress=void 0,Ue.receiverProfileImageUrl=void 0,Ue.receiverProfileName=void 0,Ue.loading=!1,Ue.tokenBalances=[]}},Ae=As(Vv),Ic={currentTab:0,tokenBalance:[],smartAccountDeployed:!1,addressLabels:new Map,user:void 0,preferredAccountType:void 0},zo={caipNetwork:void 0,supportsAllNetworks:!0,smartAccountEnabledNetworks:[]},Q=Ge({chains:pw(),activeCaipAddress:void 0,activeChain:void 0,activeCaipNetwork:void 0,noAdapters:!1,universalAdapter:{connectionControllerClient:void 0},isSwitchingNamespace:!1}),Wf={state:Q,subscribe(t){return _t(Q,()=>{t(Q)})},subscribeKey(t,e){return At(Q,t,e)},subscribeAccountStateProp(t,e,s){var r;const n=s||Q.activeChain;return n?At(((r=Q.chains.get(n))==null?void 0:r.accountState)||{},t,e):()=>{}},subscribeChainProp(t,e,s){let n;return _t(Q.chains,()=>{var i;const r=s||Q.activeChain;if(r){const o=(i=Q.chains.get(r))==null?void 0:i[t];n!==o&&(n=o,e(o))}})},initialize(t,e,s){const{chainId:n,namespace:r}=F.getActiveNetworkProps(),i=e==null?void 0:e.find(d=>d.id.toString()===(n==null?void 0:n.toString())),a=t.find(d=>(d==null?void 0:d.namespace)===r)||(t==null?void 0:t[0]),c=t.map(d=>d.namespace).filter(d=>d!==void 0),l=$.state.enableEmbedded?new Set([...c]):new Set([...(e==null?void 0:e.map(d=>d.chainNamespace))??[]]);((t==null?void 0:t.length)===0||!a)&&(Q.noAdapters=!0),Q.noAdapters||(Q.activeChain=a==null?void 0:a.namespace,Q.activeCaipNetwork=i,E.setChainNetworkData(a==null?void 0:a.namespace,{caipNetwork:i}),Q.activeChain&&ds.set({activeChain:a==null?void 0:a.namespace})),l.forEach(d=>{const u=e==null?void 0:e.filter(g=>g.chainNamespace===d),h=F.getPreferredAccountTypes()||{},p={...$.state.defaultAccountTypes,...h};E.state.chains.set(d,{namespace:d,networkState:Ge({...zo,caipNetwork:u==null?void 0:u[0]}),accountState:Ge({...Ic,preferredAccountType:p[d]}),caipNetworks:u??[],...s}),E.setRequestedCaipNetworks(u??[],d)})},removeAdapter(t){var e,s;if(Q.activeChain===t){const n=Array.from(Q.chains.entries()).find(([r])=>r!==t);if(n){const r=(s=(e=n[1])==null?void 0:e.caipNetworks)==null?void 0:s[0];r&&E.setActiveCaipNetwork(r)}}Q.chains.delete(t)},addAdapter(t,{connectionControllerClient:e},s){if(!t.namespace)throw new Error("ChainController:addAdapter - adapter must have a namespace");Q.chains.set(t.namespace,{namespace:t.namespace,networkState:{...zo,caipNetwork:s[0]},accountState:{...Ic},caipNetworks:s,connectionControllerClient:e}),E.setRequestedCaipNetworks((s==null?void 0:s.filter(n=>n.chainNamespace===t.namespace))??[],t.namespace)},addNetwork(t){var s;const e=Q.chains.get(t.chainNamespace);if(e){const n=[...e.caipNetworks||[]];(s=e.caipNetworks)!=null&&s.find(r=>r.id===t.id)||n.push(t),Q.chains.set(t.chainNamespace,{...e,caipNetworks:n}),E.setRequestedCaipNetworks(n,t.chainNamespace),V.filterByNamespace(t.chainNamespace,!0)}},removeNetwork(t,e){var n,r,i;const s=Q.chains.get(t);if(s){const o=((n=Q.activeCaipNetwork)==null?void 0:n.id)===e,a=[...((r=s.caipNetworks)==null?void 0:r.filter(c=>c.id!==e))||[]];o&&((i=s==null?void 0:s.caipNetworks)!=null&&i[0])&&E.setActiveCaipNetwork(s.caipNetworks[0]),Q.chains.set(t,{...s,caipNetworks:a}),E.setRequestedCaipNetworks(a||[],t),a.length===0&&V.filterByNamespace(t,!1)}},setAdapterNetworkState(t,e){const s=Q.chains.get(t);s&&(s.networkState={...s.networkState||zo,...e},Q.chains.set(t,s))},setChainAccountData(t,e,s=!0){if(!t)throw new Error("Chain is required to update chain account data");const n=Q.chains.get(t);if(n){const r={...n.accountState||Ic,...e};Q.chains.set(t,{...n,accountState:r}),(Q.chains.size===1||Q.activeChain===t)&&e.caipAddress&&(Q.activeCaipAddress=e.caipAddress)}},setChainNetworkData(t,e){if(!t)return;const s=Q.chains.get(t);if(s){const n={...s.networkState||zo,...e};Q.chains.set(t,{...s,networkState:n})}},setAccountProp(t,e,s,n=!0){E.setChainAccountData(s,{[t]:e},n)},setActiveNamespace(t){var n,r;Q.activeChain=t;const e=t?Q.chains.get(t):void 0,s=(n=e==null?void 0:e.networkState)==null?void 0:n.caipNetwork;s!=null&&s.id&&t&&(Q.activeCaipAddress=(r=e==null?void 0:e.accountState)==null?void 0:r.caipAddress,Q.activeCaipNetwork=s,E.setChainNetworkData(t,{caipNetwork:s}),F.setActiveCaipNetworkId(s==null?void 0:s.caipNetworkId),ds.set({activeChain:t,selectedNetworkId:s==null?void 0:s.caipNetworkId}))},setActiveCaipNetwork(t){var i,o;if(!t)return;const e=Q.activeChain===t.chainNamespace;e||E.setIsSwitchingNamespace(!0);const s=Q.chains.get(t.chainNamespace);Q.activeChain=t.chainNamespace,Q.activeCaipNetwork=t,E.setChainNetworkData(t.chainNamespace,{caipNetwork:t});let n=(i=s==null?void 0:s.accountState)==null?void 0:i.address;if(n)Q.activeCaipAddress=`${t.chainNamespace}:${t.id}:${n}`;else if(e&&Q.activeCaipAddress){const{address:a}=dt.parseCaipAddress(Q.activeCaipAddress);n=a,Q.activeCaipAddress=`${t.caipNetworkId}:${n}`}else Q.activeCaipAddress=void 0;E.setChainAccountData(t.chainNamespace,{address:n,caipAddress:Q.activeCaipAddress}),Ae.resetSend(),ds.set({activeChain:Q.activeChain,selectedNetworkId:(o=Q.activeCaipNetwork)==null?void 0:o.caipNetworkId}),F.setActiveCaipNetworkId(t.caipNetworkId),!E.checkIfSupportedNetwork(t.chainNamespace)&&$.state.enableNetworkSwitch&&!$.state.allowUnsupportedChain&&!G.state.wcBasic&&E.showUnsupportedChainUI()},addCaipNetwork(t){var s;if(!t)return;const e=Q.chains.get(t.chainNamespace);e&&((s=e==null?void 0:e.caipNetworks)==null||s.push(t))},async switchActiveNamespace(t){var r;if(!t)return;const e=t!==E.state.activeChain,s=(r=E.getNetworkData(t))==null?void 0:r.caipNetwork,n=E.getCaipNetworkByNamespace(t,s==null?void 0:s.id);e&&n&&await E.switchActiveNetwork(n)},async switchActiveNetwork(t,{throwOnFailure:e=!1}={}){var o;const s=E.state.activeChain;if(!s)throw new Error("ChainController:switchActiveNetwork - namespace is required");const n=He.getProviderId(Q.activeChain)==="AUTH",r=(o=E.getAccountData(s))==null?void 0:o.address,i=U.AUTH_CONNECTOR_SUPPORTED_CHAINS.includes(t.chainNamespace);try{if(r&&t.chainNamespace===s||n&&i){const a=qf.get(t.chainNamespace);if(!a)throw new Error("Adapter not found");await a.switchNetwork({caipNetwork:t})}E.setActiveCaipNetwork(t)}catch(a){if(e)throw a}Ee.sendEvent({type:"track",event:"SWITCH_NETWORK",properties:{network:t.caipNetworkId}})},getConnectionControllerClient(t){const e=t||Q.activeChain;if(!e)throw new Error("Chain is required to get connection controller client");const s=Q.chains.get(e);if(!(s!=null&&s.connectionControllerClient))throw new Error("ConnectionController client not set");return s.connectionControllerClient},getNetworkProp(t,e){var n;const s=(n=Q.chains.get(e))==null?void 0:n.networkState;if(s)return s[t]},getRequestedCaipNetworks(t){const e=Q.chains.get(t),{approvedCaipNetworkIds:s=[],requestedCaipNetworks:n=[]}=(e==null?void 0:e.networkState)||{};return X.sortRequestedNetworks(s,n).filter(o=>o==null?void 0:o.id)},getAllRequestedCaipNetworks(){const t=[];return Q.chains.forEach(e=>{if(!e.namespace)throw new Error("ChainController:getAllRequestedCaipNetworks - chainAdapter must have a namespace");const s=E.getRequestedCaipNetworks(e.namespace);t.push(...s)}),t},setRequestedCaipNetworks(t,e){E.setAdapterNetworkState(e,{requestedCaipNetworks:t});const n=E.getAllRequestedCaipNetworks().map(i=>i.chainNamespace),r=Array.from(new Set(n));V.filterByNamespaces(r)},getAllApprovedCaipNetworkIds(){const t=[];return Q.chains.forEach(e=>{if(!e.namespace)throw new Error("ChainController:getAllApprovedCaipNetworkIds - chainAdapter must have a namespace");const s=E.getApprovedCaipNetworkIds(e.namespace);t.push(...s)}),t},getActiveCaipNetwork(t){var e,s;return t?(s=(e=Q.chains.get(t))==null?void 0:e.networkState)==null?void 0:s.caipNetwork:Q.activeCaipNetwork},getActiveCaipAddress(){return Q.activeCaipAddress},getApprovedCaipNetworkIds(t){var n;const e=Q.chains.get(t);return((n=e==null?void 0:e.networkState)==null?void 0:n.approvedCaipNetworkIds)||[]},setApprovedCaipNetworksData(t,e){E.setAdapterNetworkState(t,e)},checkIfSupportedNetwork(t,e){var r;const s=e||((r=Q.activeCaipNetwork)==null?void 0:r.caipNetworkId),n=E.getRequestedCaipNetworks(t);return n.length?n==null?void 0:n.some(i=>i.caipNetworkId===s):!0},checkIfSupportedChainId(t){if(!Q.activeChain)return!0;const e=E.getRequestedCaipNetworks(Q.activeChain);return e==null?void 0:e.some(s=>s.id===t)},checkIfSmartAccountEnabled(){var n,r;const t=yf.caipNetworkIdToNumber((n=Q.activeCaipNetwork)==null?void 0:n.caipNetworkId);if(!Q.activeChain||!t)return!1;const s=((r=lt.get(oe.SMART_ACCOUNT_ENABLED_NETWORKS))==null?void 0:r.split(","))||[];return!!(s!=null&&s.includes(t.toString()))},showUnsupportedChainUI(){Te.open({view:"UnsupportedChain"})},checkIfNamesSupported(){const t=Q.activeCaipNetwork;return!!(t!=null&&t.chainNamespace&&Ne.NAMES_SUPPORTED_CHAIN_NAMESPACES.includes(t.chainNamespace))},resetNetwork(t){E.setAdapterNetworkState(t,{approvedCaipNetworkIds:void 0,supportsAllNetworks:!0})},resetAccount(t){var r,i;const e=t;if(!e)throw new Error("Chain is required to set account prop");const s=(i=(r=E.state.chains.get(e))==null?void 0:r.accountState)==null?void 0:i.preferredAccountType,n=$.state.defaultAccountTypes[e];Q.activeCaipAddress=void 0,E.setChainAccountData(e,{smartAccountDeployed:!1,currentTab:0,caipAddress:void 0,address:void 0,balance:void 0,balanceSymbol:void 0,profileName:void 0,profileImage:void 0,addressExplorerUrl:void 0,tokenBalance:[],connectedWalletInfo:void 0,preferredAccountType:n||s,socialProvider:void 0,socialWindow:void 0,farcasterUrl:void 0,user:void 0,status:"disconnected"}),V.removeConnectorId(e)},setIsSwitchingNamespace(t){Q.isSwitchingNamespace=t},getFirstCaipNetworkSupportsAuthConnector(){var s,n;const t=[];let e;if(Q.chains.forEach(r=>{U.AUTH_CONNECTOR_SUPPORTED_CHAINS.find(i=>i===r.namespace)&&r.namespace&&t.push(r.namespace)}),t.length>0){const r=t[0];return e=r?(n=(s=Q.chains.get(r))==null?void 0:s.caipNetworks)==null?void 0:n[0]:void 0,e}},getAccountData(t){var s;const e=t||Q.activeChain;if(e)return(s=E.state.chains.get(e))==null?void 0:s.accountState},getNetworkData(t){var s;const e=t||Q.activeChain;if(e)return(s=E.state.chains.get(e))==null?void 0:s.networkState},getCaipNetworkByNamespace(t,e){var r,i,o;if(!t)return;const s=E.state.chains.get(t),n=(r=s==null?void 0:s.caipNetworks)==null?void 0:r.find(a=>a.id.toString()===(e==null?void 0:e.toString()));return n||((i=s==null?void 0:s.networkState)==null?void 0:i.caipNetwork)||((o=s==null?void 0:s.caipNetworks)==null?void 0:o[0])},getRequestedCaipNetworkIds(){const t=V.state.filterByNamespace;return(t?[Q.chains.get(t)]:Array.from(Q.chains.values())).flatMap(s=>(s==null?void 0:s.caipNetworks)||[]).map(s=>s.caipNetworkId)},getCaipNetworks(t){return t?E.getRequestedCaipNetworks(t):E.getAllRequestedCaipNetworks()},getCaipNetworkById(t,e){return Wf.getCaipNetworks(e).find(s=>s.id.toString()===t.toString()||s.caipNetworkId.toString()===t.toString())},setLastConnectedSIWECaipNetwork(t){Q.lastConnectedSIWECaipNetwork=t},getLastConnectedSIWECaipNetwork(){return Q.lastConnectedSIWECaipNetwork},async fetchTokenBalance(t){var o,a;const e=E.getAccountData();if(!e)return[];const s=(o=E.state.activeCaipNetwork)==null?void 0:o.caipNetworkId,n=(a=E.state.activeCaipNetwork)==null?void 0:a.chainNamespace,r=E.state.activeCaipAddress,i=r?X.getPlainAddress(r):void 0;if(E.setAccountProp("balanceLoading",!0,n),e.lastRetry&&!X.isAllowedRetry(e.lastRetry,30*Ne.ONE_SEC_MS))return E.setAccountProp("balanceLoading",!1,n),[];try{if(i&&s&&n){const c=await _d.getMyTokensWithBalance();return E.setAccountProp("tokenBalance",c,n),E.setAccountProp("lastRetry",void 0,n),E.setAccountProp("balanceLoading",!1,n),c}}catch(c){E.setAccountProp("lastRetry",Date.now(),n),t==null||t(c),zs.showError("Token Balance Unavailable")}finally{E.setAccountProp("balanceLoading",!1,n)}return[]},isCaipNetworkDisabled(t){var c;const e=t.chainNamespace,s=!!((c=E.getAccountData(e))!=null&&c.caipAddress),n=E.getAllApprovedCaipNetworkIds(),r=E.getNetworkProp("supportsAllNetworks",e)!==!1,i=V.getConnectorId(e),o=V.getAuthConnector(),a=i===U.CONNECTOR_ID.AUTH&&o;return!s||r||a?!1:!(n!=null&&n.includes(t.caipNetworkId))}},E=As(Wf),zv={onSwitchNetwork({network:t,ignoreSwitchConfirmation:e=!1}){var h,p;const s=E.state.activeCaipNetwork,n=E.state.activeChain,r=ue.state.data;if(t.id===(s==null?void 0:s.id))return;const o=!!((h=E.getAccountData(n))!=null&&h.address),a=!!((p=E.getAccountData(t.chainNamespace))!=null&&p.address),c=t.chainNamespace!==n,d=V.getConnectorId(n)===U.CONNECTOR_ID.AUTH,u=U.AUTH_CONNECTOR_SUPPORTED_CHAINS.find(g=>g===t.chainNamespace);e||d&&u?ue.push("SwitchNetwork",{...r,network:t}):o&&c&&!a?ue.push("SwitchActiveChain",{switchToChain:t.chainNamespace,navigateTo:"Connect",navigateWithReplace:!0,network:t}):ue.push("SwitchNetwork",{...r,network:t})}},Wt=Ge({loading:!1,loadingNamespaceMap:new Map,open:!1,shake:!1,namespace:void 0}),Kv={state:Wt,subscribe(t){return _t(Wt,()=>t(Wt))},subscribeKey(t,e){return At(Wt,t,e)},async open(t){var o,a;const e=t==null?void 0:t.namespace,s=E.state.activeChain,n=e&&e!==s,r=(o=E.getAccountData(t==null?void 0:t.namespace))==null?void 0:o.caipAddress,i=E.state.noAdapters;if(G.state.wcBasic?te.prefetch({fetchNetworkImages:!1,fetchConnectorImages:!1,fetchWalletRanks:!1}):await te.prefetch(),V.setFilterByNamespace(t==null?void 0:t.namespace),Te.setLoading(!0,e),e&&n){const c=((a=E.getNetworkData(e))==null?void 0:a.caipNetwork)||E.getRequestedCaipNetworks(e)[0];c&&(i?(await E.switchActiveNetwork(c),ue.push("ConnectingWalletConnectBasic")):zv.onSwitchNetwork({network:c,ignoreSwitchConfirmation:!0}))}else $.state.manualWCControl||i&&!r?X.isMobile()?ue.reset("AllWallets"):ue.reset("ConnectingWalletConnectBasic"):t!=null&&t.view?ue.reset(t.view,t.data):r?ue.reset("Account"):ue.reset("Connect");Wt.open=!0,ds.set({open:!0}),Ee.sendEvent({type:"track",event:"MODAL_OPEN",properties:{connected:!!r}})},close(){const t=$.state.enableEmbedded,e=!!E.state.activeCaipAddress;Wt.open&&Ee.sendEvent({type:"track",event:"MODAL_CLOSE",properties:{connected:e}}),Wt.open=!1,ue.reset("Connect"),Te.clearLoading(),t?e?ue.replace("Account"):ue.push("Connect"):ds.set({open:!1}),G.resetUri()},setLoading(t,e){e&&Wt.loadingNamespaceMap.set(e,t),Wt.loading=t,ds.set({loading:t})},clearLoading(){Wt.loadingNamespaceMap.clear(),Wt.loading=!1,ds.set({loading:!1})},shake(){Wt.shake||(Wt.shake=!0,setTimeout(()=>{Wt.shake=!1},500))}},Te=As(Kv),ji={id:"2b92315d-eab7-5bef-84fa-089a131333f5",name:"USD Coin",symbol:"USDC",networks:[{name:"ethereum-mainnet",display_name:"Ethereum",chain_id:"1",contract_address:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},{name:"polygon-mainnet",display_name:"Polygon",chain_id:"137",contract_address:"0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174"}]},Tl={id:"USD",payment_method_limits:[{id:"card",min:"10.00",max:"7500.00"},{id:"ach_bank_account",min:"10.00",max:"25000.00"}]},Gv={providers:Sf,selectedProvider:null,error:null,purchaseCurrency:ji,paymentCurrency:Tl,purchaseCurrencies:[ji],paymentCurrencies:[],quotesLoading:!1},$e=Ge(Gv),Yv={state:$e,subscribe(t){return _t($e,()=>t($e))},subscribeKey(t,e){return At($e,t,e)},setSelectedProvider(t){var e,s;if(t&&t.name==="meld"){const n=E.state.activeChain,r=n===U.CHAIN.SOLANA?"SOL":"USDC",i=n?((s=(e=E.state.chains.get(n))==null?void 0:e.accountState)==null?void 0:s.address)??"":"",o=new URL(t.url);o.searchParams.append("publicKey",fw),o.searchParams.append("destinationCurrencyCode",r),o.searchParams.append("walletAddress",i),o.searchParams.append("externalCustomerId",$.state.projectId),$e.selectedProvider={...t,url:o.toString()}}else $e.selectedProvider=t},setOnrampProviders(t){if(Array.isArray(t)&&t.every(e=>typeof e=="string")){const e=t,s=Sf.filter(n=>e.includes(n.name));$e.providers=s}else $e.providers=[]},setPurchaseCurrency(t){$e.purchaseCurrency=t},setPaymentCurrency(t){$e.paymentCurrency=t},setPurchaseAmount(t){Rl.state.purchaseAmount=t},setPaymentAmount(t){Rl.state.paymentAmount=t},async getAvailableCurrencies(){const t=await fe.getOnrampOptions();$e.purchaseCurrencies=t.purchaseCurrencies,$e.paymentCurrencies=t.paymentCurrencies,$e.paymentCurrency=t.paymentCurrencies[0]||Tl,$e.purchaseCurrency=t.purchaseCurrencies[0]||ji,await te.fetchCurrencyImages(t.paymentCurrencies.map(e=>e.id)),await te.fetchTokenImages(t.purchaseCurrencies.map(e=>e.symbol))},async getQuote(){var t,e;$e.quotesLoading=!0;try{const s=await fe.getOnrampQuote({purchaseCurrency:$e.purchaseCurrency,paymentCurrency:$e.paymentCurrency,amount:((t=$e.paymentAmount)==null?void 0:t.toString())||"0",network:(e=$e.purchaseCurrency)==null?void 0:e.symbol});return $e.quotesLoading=!1,$e.purchaseAmount=Number(s==null?void 0:s.purchaseAmount.amount),s}catch(s){return $e.error=s.message,$e.quotesLoading=!1,null}finally{$e.quotesLoading=!1}},resetState(){$e.selectedProvider=null,$e.error=null,$e.purchaseCurrency=ji,$e.paymentCurrency=Tl,$e.purchaseCurrencies=[ji],$e.paymentCurrencies=[],$e.paymentAmount=void 0,$e.purchaseAmount=void 0,$e.quotesLoading=!1}},Rl=As(Yv);function Zv(t){return!t||typeof t.then!="function"?Promise.resolve(t):t}function ft(t,...e){try{return Zv(t(...e))}catch(s){return Promise.reject(s)}}function Jv(t){const e=typeof t;return t===null||e!=="object"&&e!=="function"}function Xv(t){const e=Object.getPrototypeOf(t);return!e||e.isPrototypeOf(Object)}function pa(t){if(Jv(t))return String(t);if(Xv(t)||Array.isArray(t))return JSON.stringify(t);if(typeof t.toJSON=="function")return pa(t.toJSON());throw new Error("[unstorage] Cannot stringify value!")}const Ol="base64:";function Qv(t){return typeof t=="string"?t:Ol+sC(t)}function eC(t){return typeof t!="string"||!t.startsWith(Ol)?t:tC(t.slice(Ol.length))}function tC(t){return globalThis.Buffer?Pe.from(t,"base64"):Uint8Array.from(globalThis.atob(t),e=>e.codePointAt(0))}function sC(t){return globalThis.Buffer?Pe.from(t).toString("base64"):globalThis.btoa(String.fromCodePoint(...t))}function Vt(t){var e;return t&&((e=t.split("?")[0])==null?void 0:e.replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,""))||""}function nC(...t){return Vt(t.join(":"))}function Ko(t){return t=Vt(t),t?t+":":""}function rC(t,e){if(e===void 0)return!0;let s=0,n=t.indexOf(":");for(;n>-1;)s++,n=t.indexOf(":",n+1);return s<=e}function iC(t,e){return e?t.startsWith(e)&&t[t.length-1]!=="$":t[t.length-1]!=="$"}const oC="memory",aC=()=>{const t=new Map;return{name:oC,getInstance:()=>t,hasItem(e){return t.has(e)},getItem(e){return t.get(e)??null},getItemRaw(e){return t.get(e)??null},setItem(e,s){t.set(e,s)},setItemRaw(e,s){t.set(e,s)},removeItem(e){t.delete(e)},getKeys(){return[...t.keys()]},clear(){t.clear()},dispose(){t.clear()}}};function cC(t={}){const e={mounts:{"":t.driver||aC()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},s=l=>{for(const d of e.mountpoints)if(l.startsWith(d))return{base:d,relativeKey:l.slice(d.length),driver:e.mounts[d]};return{base:"",relativeKey:l,driver:e.mounts[""]}},n=(l,d)=>e.mountpoints.filter(u=>u.startsWith(l)||d&&l.startsWith(u)).map(u=>({relativeBase:l.length>u.length?l.slice(u.length):void 0,mountpoint:u,driver:e.mounts[u]})),r=(l,d)=>{if(e.watching){d=Vt(d);for(const u of e.watchListeners)u(l,d)}},i=async()=>{if(!e.watching){e.watching=!0;for(const l in e.mounts)e.unwatch[l]=await Wu(e.mounts[l],r,l)}},o=async()=>{if(e.watching){for(const l in e.unwatch)await e.unwatch[l]();e.unwatch={},e.watching=!1}},a=(l,d,u)=>{const h=new Map,p=g=>{let f=h.get(g.base);return f||(f={driver:g.driver,base:g.base,items:[]},h.set(g.base,f)),f};for(const g of l){const f=typeof g=="string",w=Vt(f?g:g.key),v=f?void 0:g.value,N=f||!g.options?d:{...d,...g.options},A=s(w);p(A).items.push({key:w,value:v,relativeKey:A.relativeKey,options:N})}return Promise.all([...h.values()].map(g=>u(g))).then(g=>g.flat())},c={hasItem(l,d={}){l=Vt(l);const{relativeKey:u,driver:h}=s(l);return ft(h.hasItem,u,d)},getItem(l,d={}){l=Vt(l);const{relativeKey:u,driver:h}=s(l);return ft(h.getItem,u,d).then(p=>Mo(p))},getItems(l,d={}){return a(l,d,u=>u.driver.getItems?ft(u.driver.getItems,u.items.map(h=>({key:h.relativeKey,options:h.options})),d).then(h=>h.map(p=>({key:nC(u.base,p.key),value:Mo(p.value)}))):Promise.all(u.items.map(h=>ft(u.driver.getItem,h.relativeKey,h.options).then(p=>({key:h.key,value:Mo(p)})))))},getItemRaw(l,d={}){l=Vt(l);const{relativeKey:u,driver:h}=s(l);return h.getItemRaw?ft(h.getItemRaw,u,d):ft(h.getItem,u,d).then(p=>eC(p))},async setItem(l,d,u={}){if(d===void 0)return c.removeItem(l);l=Vt(l);const{relativeKey:h,driver:p}=s(l);p.setItem&&(await ft(p.setItem,h,pa(d),u),p.watch||r("update",l))},async setItems(l,d){await a(l,d,async u=>{if(u.driver.setItems)return ft(u.driver.setItems,u.items.map(h=>({key:h.relativeKey,value:pa(h.value),options:h.options})),d);u.driver.setItem&&await Promise.all(u.items.map(h=>ft(u.driver.setItem,h.relativeKey,pa(h.value),h.options)))})},async setItemRaw(l,d,u={}){if(d===void 0)return c.removeItem(l,u);l=Vt(l);const{relativeKey:h,driver:p}=s(l);if(p.setItemRaw)await ft(p.setItemRaw,h,d,u);else if(p.setItem)await ft(p.setItem,h,Qv(d),u);else return;p.watch||r("update",l)},async removeItem(l,d={}){typeof d=="boolean"&&(d={removeMeta:d}),l=Vt(l);const{relativeKey:u,driver:h}=s(l);h.removeItem&&(await ft(h.removeItem,u,d),(d.removeMeta||d.removeMata)&&await ft(h.removeItem,u+"$",d),h.watch||r("remove",l))},async getMeta(l,d={}){typeof d=="boolean"&&(d={nativeOnly:d}),l=Vt(l);const{relativeKey:u,driver:h}=s(l),p=Object.create(null);if(h.getMeta&&Object.assign(p,await ft(h.getMeta,u,d)),!d.nativeOnly){const g=await ft(h.getItem,u+"$",d).then(f=>Mo(f));g&&typeof g=="object"&&(typeof g.atime=="string"&&(g.atime=new Date(g.atime)),typeof g.mtime=="string"&&(g.mtime=new Date(g.mtime)),Object.assign(p,g))}return p},setMeta(l,d,u={}){return this.setItem(l+"$",d,u)},removeMeta(l,d={}){return this.removeItem(l+"$",d)},async getKeys(l,d={}){var w;l=Ko(l);const u=n(l,!0);let h=[];const p=[];let g=!0;for(const v of u){(w=v.driver.flags)!=null&&w.maxDepth||(g=!1);const N=await ft(v.driver.getKeys,v.relativeBase,d);for(const A of N){const _=v.mountpoint+Vt(A);h.some(P=>_.startsWith(P))||p.push(_)}h=[v.mountpoint,...h.filter(A=>!A.startsWith(v.mountpoint))]}const f=d.maxDepth!==void 0&&!g;return p.filter(v=>(!f||rC(v,d.maxDepth))&&iC(v,l))},async clear(l,d={}){l=Ko(l),await Promise.all(n(l,!1).map(async u=>{if(u.driver.clear)return ft(u.driver.clear,u.relativeBase,d);if(u.driver.removeItem){const h=await u.driver.getKeys(u.relativeBase||"",d);return Promise.all(h.map(p=>u.driver.removeItem(p,d)))}}))},async dispose(){await Promise.all(Object.values(e.mounts).map(l=>Hu(l)))},async watch(l){return await i(),e.watchListeners.push(l),async()=>{e.watchListeners=e.watchListeners.filter(d=>d!==l),e.watchListeners.length===0&&await o()}},async unwatch(){e.watchListeners=[],await o()},mount(l,d){if(l=Ko(l),l&&e.mounts[l])throw new Error(`already mounted at ${l}`);return l&&(e.mountpoints.push(l),e.mountpoints.sort((u,h)=>h.length-u.length)),e.mounts[l]=d,e.watching&&Promise.resolve(Wu(d,r,l)).then(u=>{e.unwatch[l]=u}).catch(console.error),c},async unmount(l,d=!0){var u,h;l=Ko(l),!(!l||!e.mounts[l])&&(e.watching&&l in e.unwatch&&((h=(u=e.unwatch)[l])==null||h.call(u),delete e.unwatch[l]),d&&await Hu(e.mounts[l]),e.mountpoints=e.mountpoints.filter(p=>p!==l),delete e.mounts[l])},getMount(l=""){l=Vt(l)+":";const d=s(l);return{driver:d.driver,base:d.base}},getMounts(l="",d={}){return l=Vt(l),n(l,d.parents).map(h=>({driver:h.driver,base:h.mountpoint}))},keys:(l,d={})=>c.getKeys(l,d),get:(l,d={})=>c.getItem(l,d),set:(l,d,u={})=>c.setItem(l,d,u),has:(l,d={})=>c.hasItem(l,d),del:(l,d={})=>c.removeItem(l,d),remove:(l,d={})=>c.removeItem(l,d)};return c}function Wu(t,e,s){return t.watch?t.watch((n,r)=>e(n,s+r)):()=>{}}async function Hu(t){typeof t.dispose=="function"&&await ft(t.dispose)}const lC="idb-keyval";var dC=(t={})=>{const e=t.base&&t.base.length>0?`${t.base}:`:"",s=r=>e+r;let n;return t.dbName&&t.storeName&&(n=Iy(t.dbName,t.storeName)),{name:lC,options:t,async hasItem(r){return!(typeof await bu(s(r),n)>"u")},async getItem(r){return await bu(s(r),n)??null},setItem(r,i){return Oy(s(r),i,n)},removeItem(r){return Ry(s(r),n)},getKeys(){return Ty(n)},clear(){return Ny(n)}}};const uC="WALLET_CONNECT_V2_INDEXED_DB",hC="keyvaluestorage";let pC=class{constructor(){this.indexedDb=cC({driver:dC({dbName:uC,storeName:hC})})}async getKeys(){return this.indexedDb.getKeys()}async getEntries(){return(await this.indexedDb.getItems(await this.indexedDb.getKeys())).map(e=>[e.key,e.value])}async getItem(e){const s=await this.indexedDb.getItem(e);if(s!==null)return s}async setItem(e,s){await this.indexedDb.setItem(e,Gi(s))}async removeItem(e){await this.indexedDb.removeItem(e)}};var Nc=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof Ce<"u"?Ce:typeof self<"u"?self:{},fa={exports:{}};(function(){let t;function e(){}t=e,t.prototype.getItem=function(s){return this.hasOwnProperty(s)?String(this[s]):null},t.prototype.setItem=function(s,n){this[s]=String(n)},t.prototype.removeItem=function(s){delete this[s]},t.prototype.clear=function(){const s=this;Object.keys(s).forEach(function(n){s[n]=void 0,delete s[n]})},t.prototype.key=function(s){return s=s||0,Object.keys(this)[s]},t.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof Nc<"u"&&Nc.localStorage?fa.exports=Nc.localStorage:typeof window<"u"&&window.localStorage?fa.exports=window.localStorage:fa.exports=new e})();function fC(t){var e;return[t[0],va((e=t[1])!=null?e:"")]}let gC=class{constructor(){this.localStorage=fa.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(fC)}async getItem(e){const s=this.localStorage.getItem(e);if(s!==null)return va(s)}async setItem(e,s){this.localStorage.setItem(e,Gi(s))}async removeItem(e){this.localStorage.removeItem(e)}};const mC="wc_storage_version",Vu=1,yC=async(t,e,s)=>{const n=mC,r=await e.getItem(n);if(r&&r>=Vu){s(e);return}const i=await t.getKeys();if(!i.length){s(e);return}const o=[];for(;i.length;){const a=i.shift();if(!a)continue;const c=a.toLowerCase();if(c.includes("wc@")||c.includes("walletconnect")||c.includes("wc_")||c.includes("wallet_connect")){const l=await t.getItem(a);await e.setItem(a,l),o.push(a)}}await e.setItem(n,Vu),s(e),wC(t,o)},wC=async(t,e)=>{e.length&&e.forEach(async s=>{await t.removeItem(s)})};let EC=class{constructor(){this.initialized=!1,this.setInitialized=s=>{this.storage=s,this.initialized=!0};const e=new gC;this.storage=e;try{const s=new pC;yC(e,s,this.setInitialized)}catch{this.initialized=!0}}async getKeys(){return await this.initialize(),this.storage.getKeys()}async getEntries(){return await this.initialize(),this.storage.getEntries()}async getItem(e){return await this.initialize(),this.storage.getItem(e)}async setItem(e,s){return await this.initialize(),this.storage.setItem(e,s)}async removeItem(e){return await this.initialize(),this.storage.removeItem(e)}async initialize(){this.initialized||await new Promise(e=>{const s=setInterval(()=>{this.initialized&&(clearInterval(s),e())},20)})}};var bC=Object.defineProperty,vC=(t,e,s)=>e in t?bC(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,zu=(t,e,s)=>vC(t,typeof e!="symbol"?e+"":e,s);let CC=class extends fi{constructor(e){super(),this.opts=e,zu(this,"protocol","wc"),zu(this,"version",2)}};var _C=Object.defineProperty,AC=(t,e,s)=>e in t?_C(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,SC=(t,e,s)=>AC(t,e+"",s);let IC=class extends fi{constructor(e,s){super(),this.core=e,this.logger=s,SC(this,"records",new Map)}},NC=class{constructor(e,s){this.logger=e,this.core=s}},TC=class extends fi{constructor(e,s){super(),this.relayer=e,this.logger=s}},RC=class extends fi{constructor(e){super()}},OC=class{constructor(e,s,n,r){this.core=e,this.logger=s,this.name=n}},PC=class extends fi{constructor(e,s){super(),this.relayer=e,this.logger=s}},xC=class extends fi{constructor(e,s){super(),this.core=e,this.logger=s}},kC=class{constructor(e,s,n){this.core=e,this.logger=s,this.store=n}};class UC{constructor(e,s){this.projectId=e,this.logger=s}}let $C=class{constructor(e,s,n){this.core=e,this.logger=s,this.telemetryEnabled=n}};var DC=Object.defineProperty,LC=(t,e,s)=>e in t?DC(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Ku=(t,e,s)=>LC(t,typeof e!="symbol"?e+"":e,s);let MC=class{constructor(e){this.opts=e,Ku(this,"protocol","wc"),Ku(this,"version",2)}},BC=class{constructor(e){this.client=e}};const jC="0.1.1";function FC(){return jC}class Je extends Error{constructor(e,s={}){const n=(()=>{var c;if(s.cause instanceof Je){if(s.cause.details)return s.cause.details;if(s.cause.shortMessage)return s.cause.shortMessage}return s.cause&&"details"in s.cause&&typeof s.cause.details=="string"?s.cause.details:(c=s.cause)!=null&&c.message?s.cause.message:s.details})(),r=s.cause instanceof Je&&s.cause.docsPath||s.docsPath,o=`https://oxlib.sh${r??""}`,a=[e||"An error occurred.",...s.metaMessages?["",...s.metaMessages]:[],...n||r?["",n?`Details: ${n}`:void 0,r?`See: ${o}`:void 0]:[]].filter(c=>typeof c=="string").join(`
|
|
4
|
+
${a}`,r=!0}}r||(Error.captureStackTrace?Error.captureStackTrace(this,Tr):this.stack||(this.stack=`${this.name}: ${this.message}`))}}function Mu(t,e){let s="";try{t instanceof Error?s=t.message:typeof t=="string"?s=t:typeof t=="object"&&t!==null?Object.keys(t).length===0?s="Unknown error":s=(t==null?void 0:t.message)||JSON.stringify(t):s=String(t)}catch(r){s="Unknown error",console.error("Error parsing error message",r)}const n=t instanceof Tr?t:new Tr(s,e,t);throw Tv.sendError(n,n.category),n}function As(t,e="INTERNAL_SDK_ERROR"){const s={};return Object.keys(t).forEach(n=>{const r=t[n];if(typeof r=="function"){let i=r;r.constructor.name==="AsyncFunction"?i=async(...o)=>{try{return await r(...o)}catch(a){return Mu(a,e)}}:i=(...o)=>{try{return r(...o)}catch(a){return Mu(a,e)}},s[n]=i}else s[n]=r}),s}const ss=Ge({walletImages:{},networkImages:{},chainImages:{},connectorImages:{},tokenImages:{},currencyImages:{}}),Rv={state:ss,subscribeNetworkImages(t){return _t(ss.networkImages,()=>t(ss.networkImages))},subscribeKey(t,e){return At(ss,t,e)},subscribe(t){return _t(ss,()=>t(ss))},setWalletImage(t,e){ss.walletImages[t]=e},setNetworkImage(t,e){ss.networkImages[t]=e},setChainImage(t,e){ss.chainImages[t]=e},setConnectorImage(t,e){ss.connectorImages={...ss.connectorImages,[t]:e}},setTokenImage(t,e){ss.tokenImages[t]=e},setCurrencyImage(t,e){ss.currencyImages[t]=e}},bs=As(Rv),Bu={eip155:"ba0ba0cd-17c6-4806-ad93-f9d174f17900",solana:"a1b58899-f671-4276-6a5e-56ca5bd59700",polkadot:"",bip122:"0b4838db-0161-4ffe-022d-532bf03dba00",cosmos:"",sui:"",stacks:"",ton:"20f673c0-095e-49b2-07cf-eb5049dcf600"},Cc=Ge({networkImagePromises:{}}),Bf={async fetchWalletImage(t){if(t)return await te._fetchWalletImage(t),this.getWalletImageById(t)},async fetchNetworkImage(t){if(!t)return;const e=this.getNetworkImageById(t);return e||(Cc.networkImagePromises[t]||(Cc.networkImagePromises[t]=te._fetchNetworkImage(t)),await Cc.networkImagePromises[t],this.getNetworkImageById(t))},getWalletImageById(t){if(t)return bs.state.walletImages[t]},getWalletImage(t){if(t!=null&&t.image_url)return t==null?void 0:t.image_url;if(t!=null&&t.image_id)return bs.state.walletImages[t.image_id]},getNetworkImage(t){var e,s,n;if((e=t==null?void 0:t.assets)!=null&&e.imageUrl)return(s=t==null?void 0:t.assets)==null?void 0:s.imageUrl;if((n=t==null?void 0:t.assets)!=null&&n.imageId)return bs.state.networkImages[t.assets.imageId]},getNetworkImageById(t){if(t)return bs.state.networkImages[t]},getConnectorImage(t){var e;if(t!=null&&t.imageUrl)return t.imageUrl;if((e=t==null?void 0:t.info)!=null&&e.icon)return t.info.icon;if(t!=null&&t.imageId)return bs.state.connectorImages[t.imageId]},getChainImage(t){return bs.state.networkImages[Bu[t]]},getTokenImage(t){if(t)return bs.state.tokenImages[t]},getWalletImageUrl(t){if(!t)return"";const{projectId:e,sdkType:s,sdkVersion:n}=$.state,r=new URL(`${U.W3M_API_URL}/getWalletImage/${t}`);return r.searchParams.set("projectId",e),r.searchParams.set("st",s),r.searchParams.set("sv",n),r.toString()},getAssetImageUrl(t){if(!t)return"";const{projectId:e,sdkType:s,sdkVersion:n}=$.state,r=new URL(`${U.W3M_API_URL}/public/getAssetImage/${t}`);return r.searchParams.set("projectId",e),r.searchParams.set("st",s),r.searchParams.set("sv",n),r.toString()},getChainNamespaceImageUrl(t){return this.getAssetImageUrl(Bu[t])}},Ov=X.getAnalyticsUrl(),Pv=new So({baseUrl:Ov,clientId:null}),xv=["MODAL_CREATED"],kv=45,ju=1e3*10,et=Ge({timestamp:Date.now(),lastFlush:Date.now(),reportedErrors:{},data:{type:"track",event:"MODAL_CREATED"},pendingEvents:[],subscribedToVisibilityChange:!1,walletImpressions:[]}),Ee={state:et,subscribe(t){return _t(et,()=>t(et))},getSdkProperties(){const{projectId:t,sdkType:e,sdkVersion:s}=$.state;return{projectId:t,st:e,sv:s||"html-wagmi-4.2.2"}},shouldFlushEvents(){const t=JSON.stringify(et.pendingEvents).length/1024>kv,e=et.lastFlush+ju<Date.now();return t||e},_setPendingEvent(t){var e,s;try{let n=(e=E.getAccountData())==null?void 0:e.address;if("address"in t.data&&t.data.address&&(n=t.data.address),xv.includes(t.data.event)||typeof window>"u")return;const r=(s=E.getActiveCaipNetwork())==null?void 0:s.caipNetworkId;this.state.pendingEvents.push({eventId:X.getUUID(),url:window.location.href,domain:window.location.hostname,timestamp:t.timestamp,props:{...t.data,address:n,properties:{..."properties"in t.data?t.data.properties:{},caipNetworkId:r}}}),et.reportedErrors.FORBIDDEN=!1,Ee.shouldFlushEvents()&&Ee._submitPendingEvents()}catch(n){console.warn("_setPendingEvent",n)}},sendEvent(t){var s;et.timestamp=Date.now(),et.data=t;const e=["INITIALIZE","CONNECT_SUCCESS","SOCIAL_LOGIN_SUCCESS"];((s=$.state.features)!=null&&s.analytics||e.includes(t.event))&&Ee._setPendingEvent(et),this.subscribeToFlushTriggers()},sendWalletImpressionEvent(t){et.walletImpressions.push(t)},_transformPendingEventsForBatch(t){try{return t.filter(e=>e.props.event!=="WALLET_IMPRESSION_V2")}catch{return t}},_submitPendingEvents(){if(et.lastFlush=Date.now(),!(et.pendingEvents.length===0&&et.walletImpressions.length===0))try{const t=Ee._transformPendingEventsForBatch(et.pendingEvents);et.walletImpressions.length&&t.push({eventId:X.getUUID(),url:window.location.href,domain:window.location.hostname,timestamp:Date.now(),props:{type:"track",event:"WALLET_IMPRESSION_V2",items:[...et.walletImpressions]}}),Pv.sendBeacon({path:"/batch",params:Ee.getSdkProperties(),body:t}),et.reportedErrors.FORBIDDEN=!1,et.pendingEvents=[],et.walletImpressions=[]}catch{et.reportedErrors.FORBIDDEN=!0}},subscribeToFlushTriggers(){var t,e,s;et.subscribedToVisibilityChange||typeof document>"u"||(et.subscribedToVisibilityChange=!0,(t=document==null?void 0:document.addEventListener)==null||t.call(document,"visibilitychange",()=>{document.visibilityState==="hidden"&&Ee._submitPendingEvents()}),(e=document==null?void 0:document.addEventListener)==null||e.call(document,"freeze",()=>{Ee._submitPendingEvents()}),(s=window==null?void 0:window.addEventListener)==null||s.call(window,"pagehide",()=>{Ee._submitPendingEvents()}),setInterval(()=>{Ee._submitPendingEvents()},ju))}},Uv=X.getApiUrl(),$t=new So({baseUrl:Uv,clientId:null}),$v=40,Fu=4,Dv=20,we=Ge({promises:{},page:1,count:0,featured:[],allFeatured:[],recommended:[],allRecommended:[],wallets:[],filteredWallets:[],search:[],isAnalyticsEnabled:!1,excludedWallets:[],isFetchingRecommendedWallets:!1,explorerWallets:[],explorerFilteredWallets:[],plan:{tier:"none",hasExceededUsageLimit:!1,limits:{isAboveRpcLimit:!1,isAboveMauLimit:!1}}}),te={state:we,subscribeKey(t,e){return At(we,t,e)},_getSdkProperties(){const{projectId:t,sdkType:e,sdkVersion:s}=$.state;return{projectId:t,st:e||"appkit",sv:s||"html-wagmi-4.2.2"}},_filterOutExtensions(t){return $.state.isUniversalProvider?t.filter(e=>!!(e.mobile_link||e.desktop_link||e.webapp_link)):t},async _fetchWalletImage(t){const e=`${$t.baseUrl}/getWalletImage/${t}`,s=await $t.getBlob({path:e,params:te._getSdkProperties()});bs.setWalletImage(t,URL.createObjectURL(s))},async _fetchNetworkImage(t){const e=`${$t.baseUrl}/public/getAssetImage/${t}`,s=await $t.getBlob({path:e,params:te._getSdkProperties()});bs.setNetworkImage(t,URL.createObjectURL(s))},async _fetchConnectorImage(t){const e=`${$t.baseUrl}/public/getAssetImage/${t}`,s=await $t.getBlob({path:e,params:te._getSdkProperties()});bs.setConnectorImage(t,URL.createObjectURL(s))},async _fetchCurrencyImage(t){const e=`${$t.baseUrl}/public/getCurrencyImage/${t}`,s=await $t.getBlob({path:e,params:te._getSdkProperties()});bs.setCurrencyImage(t,URL.createObjectURL(s))},async _fetchTokenImage(t){const e=`${$t.baseUrl}/public/getTokenImage/${t}`,s=await $t.getBlob({path:e,params:te._getSdkProperties()});bs.setTokenImage(t,URL.createObjectURL(s))},_filterWalletsByPlatform(t){const e=t.length,s=X.isMobile()?t==null?void 0:t.filter(r=>r.mobile_link||r.webapp_link?!0:Object.values(ms).map(o=>o.id).includes(r.id)):t,n=e-s.length;return{filteredWallets:s,mobileFilteredOutWalletsLength:n}},async fetchProjectConfig(){return(await $t.get({path:"/appkit/v1/config",params:te._getSdkProperties()})).features},async fetchUsage(){try{const t=await $t.get({path:"/appkit/v1/project-limits",params:te._getSdkProperties()}),{tier:e,isAboveMauLimit:s,isAboveRpcLimit:n}=t.planLimits,r=e==="starter",i=s||n;te.state.plan={tier:e,hasExceededUsageLimit:r&&i,limits:{isAboveRpcLimit:n,isAboveMauLimit:s}}}catch(t){console.warn("Failed to fetch usage",t)}},async fetchAllowedOrigins(){try{const{allowedOrigins:t}=await $t.get({path:"/projects/v1/origins",params:te._getSdkProperties()});return t}catch(t){if(t instanceof Error&&t.cause instanceof Response){const e=t.cause.status;if(e===U.HTTP_STATUS_CODES.TOO_MANY_REQUESTS)throw new Error("RATE_LIMITED",{cause:t});if(e>=U.HTTP_STATUS_CODES.SERVER_ERROR&&e<600)throw new Error("SERVER_ERROR",{cause:t});return[]}return[]}},async fetchNetworkImages(){const t=E.getAllRequestedCaipNetworks(),e=t==null?void 0:t.map(({assets:s})=>s==null?void 0:s.imageId).filter(Boolean).filter(s=>!Bf.getNetworkImageById(s));e&&await Promise.allSettled(e.map(s=>te._fetchNetworkImage(s)))},async fetchConnectorImages(){const{connectors:t}=V.state,e=t.map(({imageId:s})=>s).filter(Boolean);await Promise.allSettled(e.map(s=>te._fetchConnectorImage(s)))},async fetchCurrencyImages(t=[]){await Promise.allSettled(t.map(e=>te._fetchCurrencyImage(e)))},async fetchTokenImages(t=[]){await Promise.allSettled(t.map(e=>te._fetchTokenImage(e)))},async fetchWallets(t){var o;const e=t.exclude??[];te._getSdkProperties().sv.startsWith("html-core-")&&e.push(...Object.values(ms).map(a=>a.id));const n=await $t.get({path:"/getWallets",params:{...te._getSdkProperties(),...t,page:String(t.page),entries:String(t.entries),include:(o=t.include)==null?void 0:o.join(","),exclude:e.join(",")}}),{filteredWallets:r,mobileFilteredOutWalletsLength:i}=te._filterWalletsByPlatform(n==null?void 0:n.data);return{data:r||[],count:n==null?void 0:n.count,mobileFilteredOutWalletsLength:i}},async prefetchWalletRanks(){const t=V.state.connectors;if(!(t!=null&&t.length))return;const e={page:1,entries:20,badge:"certified"};if(e.names=t.map(r=>r.name).join(","),E.state.activeChain===U.CHAIN.EVM){const r=[...t.flatMap(i=>{var o;return((o=i.connectors)==null?void 0:o.map(a=>{var c;return(c=a.info)==null?void 0:c.rdns}))||[]}),...t.map(i=>{var o;return(o=i.info)==null?void 0:o.rdns})].filter(i=>typeof i=="string"&&i.length>0);r.length&&(e.rdns=r.join(","))}const{data:s}=await te.fetchWallets(e);we.explorerWallets=s,V.extendConnectorsWithExplorerWallets(s);const n=E.getRequestedCaipNetworkIds().join(",");we.explorerFilteredWallets=s.filter(r=>{var i;return(i=r.chains)==null?void 0:i.some(o=>n.includes(o))})},async fetchFeaturedWallets(){const{featuredWalletIds:t}=$.state;if(t!=null&&t.length){const e={...te._getSdkProperties(),page:1,entries:(t==null?void 0:t.length)??Fu,include:t},{data:s}=await te.fetchWallets(e),n=[...s].sort((i,o)=>t.indexOf(i.id)-t.indexOf(o.id)),r=n.map(i=>i.image_id).filter(Boolean);await Promise.allSettled(r.map(i=>te._fetchWalletImage(i))),we.featured=n,we.allFeatured=n}},async fetchRecommendedWallets(){try{we.isFetchingRecommendedWallets=!0;const{includeWalletIds:t,excludeWalletIds:e,featuredWalletIds:s}=$.state,n=[...e??[],...s??[]].filter(Boolean),r=E.getRequestedCaipNetworkIds().join(","),i={page:1,entries:Fu,include:t,exclude:n,chains:r},{data:o,count:a}=await te.fetchWallets(i),c=F.getRecentWallets(),l=o.map(u=>u.image_id).filter(Boolean),d=c.map(u=>u.image_id).filter(Boolean);await Promise.allSettled([...l,...d].map(u=>te._fetchWalletImage(u))),we.recommended=o,we.allRecommended=o,we.count=a??0}catch{}finally{we.isFetchingRecommendedWallets=!1}},async fetchWalletsByPage({page:t}){const{includeWalletIds:e,excludeWalletIds:s,featuredWalletIds:n}=$.state,r=E.getRequestedCaipNetworkIds().join(","),i=[...we.recommended.map(({id:u})=>u),...s??[],...n??[]].filter(Boolean),o={page:t,entries:$v,include:e,exclude:i,chains:r},{data:a,count:c,mobileFilteredOutWalletsLength:l}=await te.fetchWallets(o);we.mobileFilteredOutWalletsLength=l+(we.mobileFilteredOutWalletsLength??0);const d=a.slice(0,Dv).map(u=>u.image_id).filter(Boolean);await Promise.allSettled(d.map(u=>te._fetchWalletImage(u))),we.wallets=X.uniqueBy([...we.wallets,...te._filterOutExtensions(a)],"id").filter(u=>{var h;return(h=u.chains)==null?void 0:h.some(p=>r.includes(p))}),we.count=c>we.count?c:we.count,we.page=t},async initializeExcludedWallets({ids:t}){const e={page:1,entries:t.length,include:t},{data:s}=await te.fetchWallets(e);s&&s.forEach(n=>{we.excludedWallets.push({rdns:n.rdns,name:n.name})})},async searchWallet({search:t,badge:e}){const{includeWalletIds:s,excludeWalletIds:n}=$.state,r=E.getRequestedCaipNetworkIds().join(",");we.search=[];const i={page:1,entries:100,search:t==null?void 0:t.trim(),badge_type:e,include:s,exclude:n,chains:r},{data:o}=await te.fetchWallets(i);Ee.sendEvent({type:"track",event:"SEARCH_WALLET",properties:{badge:e??"",search:t??""}});const a=o.map(c=>c.image_id).filter(Boolean);await Promise.allSettled([...a.map(c=>te._fetchWalletImage(c)),X.wait(300)]),we.search=te._filterOutExtensions(o)},initPromise(t,e){const s=we.promises[t];return s||(we.promises[t]=e())},prefetch({fetchConnectorImages:t=!0,fetchFeaturedWallets:e=!0,fetchRecommendedWallets:s=!0,fetchNetworkImages:n=!0,fetchWalletRanks:r=!0}={}){const i=[t&&te.initPromise("connectorImages",te.fetchConnectorImages),e&&te.initPromise("featuredWallets",te.fetchFeaturedWallets),s&&te.initPromise("recommendedWallets",te.fetchRecommendedWallets),n&&te.initPromise("networkImages",te.fetchNetworkImages),r&&te.initPromise("walletRanks",te.prefetchWalletRanks)].filter(Boolean);return Promise.allSettled(i)},prefetchAnalyticsConfig(){var t;(t=$.state.features)!=null&&t.analytics&&te.fetchAnalyticsConfig()},async fetchAnalyticsConfig(){try{const{isAnalyticsEnabled:t}=await $t.get({path:"/getAnalyticsConfig",params:te._getSdkProperties()});$.setFeatures({analytics:t})}catch{$.setFeatures({analytics:!1})}},filterByNamespaces(t){if(!(t!=null&&t.length)){we.featured=we.allFeatured,we.recommended=we.allRecommended;return}const e=E.getRequestedCaipNetworkIds().join(",");we.featured=we.allFeatured.filter(s=>{var n;return(n=s.chains)==null?void 0:n.some(r=>e.includes(r))}),we.recommended=we.allRecommended.filter(s=>{var n;return(n=s.chains)==null?void 0:n.some(r=>e.includes(r))}),we.filteredWallets=we.wallets.filter(s=>{var n;return(n=s.chains)==null?void 0:n.some(r=>e.includes(r))})},clearFilterByNamespaces(){we.filteredWallets=[]},setFilterByNamespace(t){if(!t){we.featured=we.allFeatured,we.recommended=we.allRecommended;return}const e=E.getRequestedCaipNetworkIds().join(",");we.featured=we.allFeatured.filter(s=>{var n;return(n=s.chains)==null?void 0:n.some(r=>e.includes(r))}),we.recommended=we.allRecommended.filter(s=>{var n;return(n=s.chains)==null?void 0:n.some(r=>e.includes(r))}),we.filteredWallets=we.wallets.filter(s=>{var n;return(n=s.chains)==null?void 0:n.some(r=>e.includes(r))})}},Lv=["ConnectingExternal","ConnectingMultiChain","ConnectingSocial","ConnectingFarcaster"],je=Ge({view:"Connect",history:["Connect"],transactionStack:[]}),Mv={state:je,subscribeKey(t,e){return At(je,t,e)},pushTransactionStack(t){je.transactionStack.push(t)},popTransactionStack(t){const e=je.transactionStack.pop();if(!e)return;const{onSuccess:s,onError:n,onCancel:r}=e;switch(t){case"success":s==null||s();break;case"error":n==null||n(),ue.goBack();break;case"cancel":r==null||r(),ue.goBack();break}},push(t,e){let s=t,n=e;te.state.plan.hasExceededUsageLimit&&Lv.includes(t)&&(s="UsageExceeded",n=void 0),s!==je.view&&(je.view=s,je.history.push(s),je.data=n)},reset(t,e){je.view=t,je.history=[t],je.data=e},replace(t,e){je.history.at(-1)===t||(je.view=t,je.history[je.history.length-1]=t,je.data=e)},goBack(){var n,r;const t=E.state.activeCaipAddress,e=ue.state.view==="ConnectingFarcaster",s=!t&&e;if(je.history.length>1){je.history.pop();const[i]=je.history.slice(-1);i&&(t&&i==="Connect"?je.view="Account":je.view=i)}else Te.close();(n=je.data)!=null&&n.wallet&&(je.data.wallet=void 0),(r=je.data)!=null&&r.redirectView&&(je.data.redirectView=void 0),setTimeout(()=>{var i,o,a;if(s){E.setAccountProp("farcasterUrl",void 0,E.state.activeChain);const c=V.getAuthConnector();(i=c==null?void 0:c.provider)==null||i.reload();const l=Xi($.state);(a=(o=c==null?void 0:c.provider)==null?void 0:o.syncDappData)==null||a.call(o,{metadata:l.metadata,sdkVersion:l.sdkVersion,projectId:l.projectId,sdkType:l.sdkType})}},100)},goBackToIndex(t){if(je.history.length>1){je.history=je.history.slice(0,t+1);const[e]=je.history.slice(-1);e&&(je.view=e)}},goBackOrCloseModal(){ue.state.history.length>1?ue.goBack():Te.close()}},ue=As(Mv),sn=Ge({themeMode:"dark",themeVariables:{},w3mThemeVariables:void 0}),Il={state:sn,subscribe(t){return _t(sn,()=>t(sn))},setThemeMode(t){sn.themeMode=t;try{const e=V.getAuthConnector();if(e){const s=Il.getSnapshot().themeVariables;e.provider.syncTheme({themeMode:t,themeVariables:s,w3mThemeVariables:Zi(s,t)})}}catch{console.info("Unable to sync theme to auth connector")}},setThemeVariables(t){sn.themeVariables={...sn.themeVariables,...t};try{const e=V.getAuthConnector();if(e){const s=Il.getSnapshot().themeVariables;e.provider.syncTheme({themeVariables:s,w3mThemeVariables:Zi(sn.themeVariables,sn.themeMode)})}}catch{console.info("Unable to sync theme to auth connector")}},getSnapshot(){return Xi(sn)}},Kt=As(Il),jf=Object.fromEntries(gf.map(t=>[t,void 0])),Bv=Object.fromEntries(gf.map(t=>[t,!0])),ke=Ge({allConnectors:[],connectors:[],activeConnector:void 0,filterByNamespace:void 0,activeConnectorIds:jf,filterByNamespaceMap:Bv}),jv={state:ke,subscribe(t){return _t(ke,()=>{t(ke)})},subscribeKey(t,e){return At(ke,t,e)},initialize(t){t.forEach(e=>{const s=F.getConnectedConnectorId(e);s&&V.setConnectorId(s,e)})},setActiveConnector(t){t&&(ke.activeConnector=Qi(t))},setConnectors(t){t.filter(r=>!ke.allConnectors.some(i=>i.id===r.id&&V.getConnectorName(i.name)===V.getConnectorName(r.name)&&i.chain===r.chain)).forEach(r=>{r.type!=="MULTI_CHAIN"&&ke.allConnectors.push(Qi(r))});const s=V.getEnabledNamespaces(),n=V.getEnabledConnectors(s);ke.connectors=V.mergeMultiChainConnectors(n)},filterByNamespaces(t){Object.keys(ke.filterByNamespaceMap).forEach(e=>{ke.filterByNamespaceMap[e]=!1}),t.forEach(e=>{ke.filterByNamespaceMap[e]=!0}),V.updateConnectorsForEnabledNamespaces()},filterByNamespace(t,e){ke.filterByNamespaceMap[t]=e,V.updateConnectorsForEnabledNamespaces()},updateConnectorsForEnabledNamespaces(){const t=V.getEnabledNamespaces(),e=V.getEnabledConnectors(t),s=V.areAllNamespacesEnabled();ke.connectors=V.mergeMultiChainConnectors(e),s?te.clearFilterByNamespaces():te.filterByNamespaces(t)},getEnabledNamespaces(){return Object.entries(ke.filterByNamespaceMap).filter(([t,e])=>e).map(([t])=>t)},getEnabledConnectors(t){return ke.allConnectors.filter(e=>t.includes(e.chain))},areAllNamespacesEnabled(){return Object.values(ke.filterByNamespaceMap).every(t=>t)},mergeMultiChainConnectors(t){const e=V.generateConnectorMapByName(t),s=[];return e.forEach(n=>{const r=n[0],i=(r==null?void 0:r.id)===U.CONNECTOR_ID.AUTH;n.length>1&&r?s.push({name:r.name,imageUrl:r.imageUrl,imageId:r.imageId,connectors:[...n],type:i?"AUTH":"MULTI_CHAIN",chain:"eip155",id:(r==null?void 0:r.id)||""}):r&&s.push(r)}),s},generateConnectorMapByName(t){const e=new Map;return t.forEach(s=>{const{name:n}=s,r=V.getConnectorName(n);if(!r)return;const i=e.get(r)||[];i.find(a=>a.chain===s.chain)||i.push(s),e.set(r,i)}),e},getConnectorName(t){return t&&({"Trust Wallet":"Trust"}[t]||t)},getUniqueConnectorsByName(t){const e=[];return t.forEach(s=>{e.find(n=>n.chain===s.chain)||e.push(s)}),e},addConnector(t){var e,s,n;if(t.id===U.CONNECTOR_ID.AUTH){const r=t,i=Xi($.state),o=Kt.getSnapshot().themeMode,a=Kt.getSnapshot().themeVariables;(s=(e=r==null?void 0:r.provider)==null?void 0:e.syncDappData)==null||s.call(e,{metadata:i.metadata,sdkVersion:i.sdkVersion,projectId:i.projectId,sdkType:i.sdkType}),(n=r==null?void 0:r.provider)==null||n.syncTheme({themeMode:o,themeVariables:a,w3mThemeVariables:Zi(a,o)}),V.setConnectors([t])}else V.setConnectors([t])},getAuthConnector(t){var n;const e=t||E.state.activeChain,s=ke.connectors.find(r=>r.id===U.CONNECTOR_ID.AUTH);if(s)return(n=s==null?void 0:s.connectors)!=null&&n.length?s.connectors.find(i=>i.chain===e):s},getAnnouncedConnectorRdns(){return ke.connectors.filter(t=>t.type==="ANNOUNCED").map(t=>{var e;return(e=t.info)==null?void 0:e.rdns})},getConnectorById(t){return ke.allConnectors.find(e=>e.id===t)},getConnector({id:t,namespace:e}){const s=e||E.state.activeChain;return ke.allConnectors.filter(i=>i.chain===s).find(i=>i.id===t||i.explorerId===t)},syncIfAuthConnector(t){var i,o;if(t.id!=="AUTH")return;const e=t,s=Xi($.state),n=Kt.getSnapshot().themeMode,r=Kt.getSnapshot().themeVariables;(o=(i=e==null?void 0:e.provider)==null?void 0:i.syncDappData)==null||o.call(i,{metadata:s.metadata,sdkVersion:s.sdkVersion,sdkType:s.sdkType,projectId:s.projectId}),e.provider.syncTheme({themeMode:n,themeVariables:r,w3mThemeVariables:Zi(r,n)})},getConnectorsByNamespace(t){const e=ke.allConnectors.filter(s=>s.chain===t);return V.mergeMultiChainConnectors(e)},canSwitchToSmartAccount(t){return E.checkIfSmartAccountEnabled()&&ls(t)===tt.ACCOUNT_TYPES.EOA},selectWalletConnector(t){var r;const e=(r=ue.state.data)==null?void 0:r.redirectView,s=E.state.activeChain,n=s?V.getConnector({id:t.id,namespace:s}):void 0;_v.handleMobileDeeplinkRedirect((n==null?void 0:n.explorerId)||t.id,E.state.activeChain),n?ue.push("ConnectingExternal",{connector:n,wallet:t,redirectView:e}):ue.push("ConnectingWalletConnect",{wallet:t,redirectView:e})},getConnectors(t){return t?V.getConnectorsByNamespace(t):V.mergeMultiChainConnectors(ke.allConnectors)},setFilterByNamespace(t){ke.filterByNamespace=t,ke.connectors=V.getConnectors(t),te.setFilterByNamespace(t)},setConnectorId(t,e){t&&(ke.activeConnectorIds={...ke.activeConnectorIds,[e]:t},F.setConnectedConnectorId(e,t))},removeConnectorId(t){ke.activeConnectorIds={...ke.activeConnectorIds,[t]:void 0},F.deleteConnectedConnectorId(t)},getConnectorId(t){if(t)return ke.activeConnectorIds[t]},isConnected(t){return t?!!ke.activeConnectorIds[t]:Object.values(ke.activeConnectorIds).some(e=>!!e)},resetConnectorIds(){ke.activeConnectorIds={...jf}},extendConnectorsWithExplorerWallets(t){ke.allConnectors.forEach(n=>{const r=t.find(i=>{var o;return i.id===n.id||i.rdns&&i.rdns===((o=n.info)==null?void 0:o.rdns)});r&&(n.explorerWallet=r)});const e=V.getEnabledNamespaces(),s=V.getEnabledConnectors(e);ke.connectors=V.mergeMultiChainConnectors(s)}},V=As(jv),Fv=1e3,Ci={checkNamespaceConnectorId(t,e){return V.getConnectorId(t)===e},isSocialProvider(t){return Ne.DEFAULT_REMOTE_FEATURES.socials.includes(t)},connectWalletConnect({walletConnect:t,connector:e,closeModalOnConnect:s=!0,redirectViewOnModalClose:n="Connect",onOpen:r,onConnect:i}){return new Promise((o,a)=>{if(t&&V.setActiveConnector(e),r==null||r(X.isMobile()&&t),n){const l=Te.subscribeKey("open",d=>{d||(ue.state.view!==n&&ue.replace(n),l(),a(new Error("Modal closed")))})}const c=E.subscribeKey("activeCaipAddress",l=>{l&&(i==null||i(),s&&Te.close(),c(),o(dt.parseCaipAddress(l)))})})},connectExternal(t){return new Promise((e,s)=>{const n=E.subscribeKey("activeCaipAddress",r=>{r&&(Te.close(),n(),e(dt.parseCaipAddress(r)))});G.connectExternal(t,t.chain).catch(()=>{n(),s(new Error("Connection rejected"))})})},connectSocial({social:t,namespace:e,closeModalOnConnect:s=!0,onOpenFarcaster:n,onConnect:r}){let i,o=!1,a=null;const c=e||E.state.activeChain,l=E.subscribeKey("activeCaipAddress",d=>{d&&(s&&Te.close(),l())});return new Promise((d,u)=>{async function h(g){var f;if((f=g.data)!=null&&f.resultUri)if(g.origin===U.SECURE_SITE_SDK_ORIGIN){window.removeEventListener("message",h,!1);try{const w=V.getAuthConnector(c);if(w&&!o){i&&i.close(),o=!0;const v=g.data.resultUri;Ee.sendEvent({type:"track",event:"SOCIAL_LOGIN_REQUEST_USER_DATA",properties:{provider:t}}),F.setConnectedSocialProvider(t),await G.connectExternal({id:w.id,type:w.type,socialUri:v},w.chain);const N=E.state.activeCaipAddress;if(!N){u(new Error("Failed to connect"));return}d(dt.parseCaipAddress(N)),Ee.sendEvent({type:"track",event:"SOCIAL_LOGIN_SUCCESS",properties:{provider:t}})}}catch(w){Ee.sendEvent({type:"track",event:"SOCIAL_LOGIN_ERROR",properties:{provider:t,message:X.parseError(w)}}),u(new Error("Failed to connect"))}}else Ee.sendEvent({type:"track",event:"SOCIAL_LOGIN_ERROR",properties:{provider:t,message:"Untrusted Origin"}})}async function p(){if(Ee.sendEvent({type:"track",event:"SOCIAL_LOGIN_STARTED",properties:{provider:t}}),t==="farcaster"){n==null||n();const g=Te.subscribeKey("open",w=>{!w&&t==="farcaster"&&(u(new Error("Popup closed")),r==null||r(),g())}),f=V.getAuthConnector();if(f){const w=E.getAccountData(c);if(!(w!=null&&w.farcasterUrl))try{const{url:v}=await f.provider.getFarcasterUri();E.setAccountProp("farcasterUrl",v,c)}catch{u(new Error("Failed to connect to farcaster"))}}}else{const g=V.getAuthConnector();a=X.returnOpenHref(`${U.SECURE_SITE_SDK_ORIGIN}/loading`,"popupWindow","width=600,height=800,scrollbars=yes");try{if(g){const{uri:f}=await g.provider.getSocialRedirectUri({provider:t});if(a&&f){a.location.href=f,i=a;const w=setInterval(()=>{i!=null&&i.closed&&!o&&(u(new Error("Popup closed")),clearInterval(w))},1e3);window.addEventListener("message",h,!1)}else a==null||a.close(),u(new Error("Failed to initiate social connection"))}}catch{u(new Error("Failed to initiate social connection")),a==null||a.close()}}}p()})},connectEmail({closeModalOnConnect:t=!0,redirectViewOnModalClose:e="Connect",onOpen:s,onConnect:n}){return new Promise((r,i)=>{if(s==null||s(),e){const a=Te.subscribeKey("open",c=>{c||(ue.state.view!==e&&ue.replace(e),a(),i(new Error("Modal closed")))})}const o=E.subscribeKey("activeCaipAddress",a=>{a&&(n==null||n(),t&&Te.close(),o(),r(dt.parseCaipAddress(a)))})})},async updateEmail(){const t=F.getConnectedConnectorId(E.state.activeChain),e=V.getAuthConnector();if(!e)throw new Error("No auth connector found");if(t!==U.CONNECTOR_ID.AUTH)throw new Error("Not connected to email or social");const s=e.provider.getEmail()??"";return await Te.open({view:"UpdateEmailWallet",data:{email:s,redirectView:void 0}}),new Promise((n,r)=>{const i=setInterval(()=>{const a=e.provider.getEmail()??"";a!==s&&(Te.close(),clearInterval(i),o(),n({email:a}))},Fv),o=Te.subscribeKey("open",a=>{a||(ue.state.view!=="Connect"&&ue.push("Connect"),clearInterval(i),o(),r(new Error("Modal closed")))})})},canSwitchToSmartAccount(t){return E.checkIfSmartAccountEnabled()&&ls(t)===tt.ACCOUNT_TYPES.EOA}};function Ff(){var n,r;const t=((n=E.state.activeCaipNetwork)==null?void 0:n.chainNamespace)||"eip155",e=((r=E.state.activeCaipNetwork)==null?void 0:r.id)||1,s=Ne.NATIVE_TOKEN_ADDRESS[t];return`${t}:${e}:${s}`}function ls(t){var s;return(s=E.getAccountData(t))==null?void 0:s.preferredAccountType}function ki(t){var e,s;return t?(s=(e=E.state.chains.get(t))==null?void 0:e.networkState)==null?void 0:s.caipNetwork:E.state.activeCaipNetwork}const Ua={getConnectionStatus(t,e){const s=V.state.activeConnectorIds[e],n=G.getConnections(e);return!!s&&t.connectorId===s?"connected":n.some(o=>o.connectorId.toLowerCase()===t.connectorId.toLowerCase())?"active":"disconnected"},excludeConnectorAddressFromConnections({connections:t,connectorId:e,addresses:s}){return t.map(n=>{if((e?n.connectorId.toLowerCase()===e.toLowerCase():!1)&&s){const i=n.accounts.filter(o=>!s.some(c=>c.toLowerCase()===o.address.toLowerCase()));return{...n,accounts:i}}return n})},excludeExistingConnections(t,e){const s=new Set(t);return e.filter(n=>!s.has(n.connectorId))},getConnectionsByConnectorId(t,e){return t.filter(s=>s.connectorId.toLowerCase()===e.toLowerCase())},getConnectionsData(t){var a;const e=!!((a=$.state.remoteFeatures)!=null&&a.multiWallet),s=V.state.activeConnectorIds[t],n=G.getConnections(t),i=(G.state.recentConnections.get(t)??[]).filter(c=>V.getConnectorById(c.connectorId)),o=Ua.excludeExistingConnections([...n.map(c=>c.connectorId),...s?[s]:[]],i);return e?{connections:n,recentConnections:o}:{connections:n.filter(c=>c.connectorId.toLowerCase()===(s==null?void 0:s.toLowerCase())),recentConnections:[]}},onConnectMobile(t){const e=G.state.wcUri;if(t!=null&&t.mobile_link&&e)try{G.setWcError(!1);const{mobile_link:s,link_mode:n,name:r}=t,{redirect:i,redirectUniversalLink:o,href:a}=X.formatNativeUrl(s,e,n),c=i,l=o,d=X.isIframe()?"_top":"_self";G.setWcLinking({name:r,href:a}),G.setRecentWallet(t),$.state.experimental_preferUniversalLinks&&l?X.openHref(l,d):X.openHref(c,d)}catch(s){Ee.sendEvent({type:"track",event:"CONNECT_PROXY_ERROR",properties:{message:s instanceof Error?s.message:"Error parsing the deep link",uri:e,mobile_link:t.mobile_link,name:t.name}}),G.setWcError(!0)}}},Br=Ge({loading:!1,open:!1,selectedNetworkId:void 0,activeChain:void 0,initialized:!1,connectingWallet:void 0}),ds={state:Br,subscribe(t){return _t(Br,()=>t(Br))},subscribeOpen(t){return At(Br,"open",t)},set(t){Object.assign(Br,{...Br,...t})}},Ye=Ge({transactions:[],transactionsByYear:{},lastNetworkInView:void 0,loading:!1,empty:!1,next:void 0}),qv={state:Ye,subscribe(t){return _t(Ye,()=>t(Ye))},setLastNetworkInView(t){Ye.lastNetworkInView=t},async fetchTransactions(t){var e;if(!t)throw new Error("Transactions can't be fetched without an accountAddress");Ye.loading=!0;try{const s=await fe.fetchTransactions({account:t,cursor:Ye.next,chainId:(e=E.state.activeCaipNetwork)==null?void 0:e.caipNetworkId}),n=ha.filterSpamTransactions(s.data),r=ha.filterByConnectedChain(n),i=[...Ye.transactions,...r];Ye.loading=!1,Ye.transactions=i,Ye.transactionsByYear=ha.groupTransactionsByYearAndMonth(Ye.transactionsByYear,r),Ye.empty=i.length===0,Ye.next=s.next?s.next:void 0}catch{const n=E.state.activeChain;Ee.sendEvent({type:"track",event:"ERROR_FETCH_TRANSACTIONS",properties:{address:t,projectId:$.state.projectId,cursor:Ye.next,isSmartAccount:ls(n)===tt.ACCOUNT_TYPES.SMART_ACCOUNT}}),zs.showError("Failed to fetch transactions"),Ye.loading=!1,Ye.empty=!0,Ye.next=void 0}},groupTransactionsByYearAndMonth(t={},e=[]){const s=t;return e.forEach(n=>{const r=new Date(n.metadata.minedAt).getFullYear(),i=new Date(n.metadata.minedAt).getMonth(),o=s[r]??{},c=(o[i]??[]).filter(l=>l.id!==n.id);s[r]={...o,[i]:[...c,n].sort((l,d)=>new Date(d.metadata.minedAt).getTime()-new Date(l.metadata.minedAt).getTime())}}),s},filterSpamTransactions(t){return t.filter(e=>{var n;return!((n=e.transfers)==null?void 0:n.every(r=>{var i;return((i=r.nft_info)==null?void 0:i.flags.is_spam)===!0}))})},filterByConnectedChain(t){var n;const e=(n=E.state.activeCaipNetwork)==null?void 0:n.caipNetworkId;return t.filter(r=>r.metadata.chain===e)},clearCursor(){Ye.next=void 0},resetTransactions(){Ye.transactions=[],Ye.transactionsByYear={},Ye.lastNetworkInView=void 0,Ye.loading=!1,Ye.empty=!1,Ye.next=void 0}},ha=As(qv,"API_ERROR"),Ie=Ge({connections:new Map,recentConnections:new Map,isSwitchingConnection:!1,wcError:!1,wcFetchingUri:!1,buffering:!1,status:"disconnected"});let sr;const Wv={state:Ie,subscribe(t){return _t(Ie,()=>t(Ie))},subscribeKey(t,e){return At(Ie,t,e)},_getClient(){return Ie._client},setClient(t){Ie._client=Qi(t)},initialize(t){const e=t.filter(s=>!!s.namespace).map(s=>s.namespace);G.syncStorageConnections(e)},syncStorageConnections(t){const e=F.getConnections(),s=t??Array.from(E.state.chains.keys());for(const n of s){const r=e[n]??[],i=new Map(Ie.recentConnections);i.set(n,r),Ie.recentConnections=i}},getConnections(t){return t?Ie.connections.get(t)??[]:[]},hasAnyConnection(t){const e=G.state.connections;return Array.from(e.values()).flatMap(s=>s).some(({connectorId:s})=>s===t)},async connectWalletConnect({cache:t="auto"}={}){var s,n,r,i;Ie.wcFetchingUri=!0;const e=X.isTelegram()||X.isSafari()&&X.isIos();if(t==="always"||t==="auto"&&e){if(sr){await sr,sr=void 0;return}if(!X.isPairingExpired(Ie==null?void 0:Ie.wcPairingExpiry)){const o=Ie.wcUri;Ie.wcUri=o;return}sr=(n=(s=G._getClient())==null?void 0:s.connectWalletConnect)==null?void 0:n.call(s).catch(()=>{}),G.state.status="connecting",await sr,sr=void 0,Ie.wcPairingExpiry=void 0,G.state.status="connected"}else await((i=(r=G._getClient())==null?void 0:r.connectWalletConnect)==null?void 0:i.call(r))},async connectExternal(t,e,s=!0){var o,a,c;const n=await((a=(o=G._getClient())==null?void 0:o.connectExternal)==null?void 0:a.call(o,t));s&&E.setActiveNamespace(e);const r=V.state.allConnectors.find(l=>l.id===(t==null?void 0:t.id)),i=t.type==="AUTH"?"email":"browser";return Ee.sendEvent({type:"track",event:"CONNECT_SUCCESS",properties:{method:i,name:(r==null?void 0:r.name)||"Unknown",view:ue.state.view,walletRank:(c=r==null?void 0:r.explorerWallet)==null?void 0:c.order}}),n},async reconnectExternal(t){var s,n;await((n=(s=G._getClient())==null?void 0:s.reconnectExternal)==null?void 0:n.call(s,t));const e=t.chain||E.state.activeChain;e&&V.setConnectorId(t.id,e)},async setPreferredAccountType(t,e){var n;if(!e)return;Te.setLoading(!0,E.state.activeChain);const s=V.getAuthConnector();s&&(E.setAccountProp("preferredAccountType",t,e),await s.provider.setPreferredAccount(t),F.setPreferredAccountTypes(Object.entries(E.state.chains).reduce((r,[i,o])=>{const a=i,c=ls(a);return c!==void 0&&(r[a]=c),r},{})),await G.reconnectExternal(s),Te.setLoading(!1,E.state.activeChain),Ee.sendEvent({type:"track",event:"SET_PREFERRED_ACCOUNT_TYPE",properties:{accountType:t,network:((n=E.state.activeCaipNetwork)==null?void 0:n.caipNetworkId)||""}}))},async signMessage(t){var e;return(e=G._getClient())==null?void 0:e.signMessage(t)},parseUnits(t,e){var s;return(s=G._getClient())==null?void 0:s.parseUnits(t,e)},formatUnits(t,e){var s;return(s=G._getClient())==null?void 0:s.formatUnits(t,e)},updateBalance(t){var e;return(e=G._getClient())==null?void 0:e.updateBalance(t)},async sendTransaction(t){var e;return(e=G._getClient())==null?void 0:e.sendTransaction(t)},async getCapabilities(t){var e;return(e=G._getClient())==null?void 0:e.getCapabilities(t)},async grantPermissions(t){var e;return(e=G._getClient())==null?void 0:e.grantPermissions(t)},async walletGetAssets(t){var e;return((e=G._getClient())==null?void 0:e.walletGetAssets(t))??{}},async estimateGas(t){var e;return(e=G._getClient())==null?void 0:e.estimateGas(t)},async writeContract(t){var e;return(e=G._getClient())==null?void 0:e.writeContract(t)},async getEnsAddress(t){var e;return(e=G._getClient())==null?void 0:e.getEnsAddress(t)},async getEnsAvatar(t){var e;return(e=G._getClient())==null?void 0:e.getEnsAvatar(t)},checkInstalled(t){var e,s;return((s=(e=G._getClient())==null?void 0:e.checkInstalled)==null?void 0:s.call(e,t))||!1},resetWcConnection(){Ie.wcUri=void 0,Ie.wcPairingExpiry=void 0,Ie.wcLinking=void 0,Ie.recentWallet=void 0,Ie.wcFetchingUri=!1,Ie.status="disconnected",ha.resetTransactions(),F.deleteWalletConnectDeepLink(),F.deleteRecentWallet(),ds.set({connectingWallet:void 0})},resetUri(){Ie.wcUri=void 0,Ie.wcPairingExpiry=void 0,sr=void 0,Ie.wcFetchingUri=!1,ds.set({connectingWallet:void 0})},finalizeWcConnection(t){var n,r;const{wcLinking:e,recentWallet:s}=G.state;e&&F.setWalletConnectDeepLink(e),s&&F.setAppKitRecent(s),t&&Ee.sendEvent({type:"track",event:"CONNECT_SUCCESS",address:t,properties:{method:e?"mobile":"qrcode",name:((r=(n=ue.state.data)==null?void 0:n.wallet)==null?void 0:r.name)||"Unknown",view:ue.state.view,walletRank:s==null?void 0:s.order}})},setWcBasic(t){Ie.wcBasic=t},setUri(t){Ie.wcUri=t,Ie.wcFetchingUri=!1,Ie.wcPairingExpiry=X.getPairingExpiry()},setWcLinking(t){Ie.wcLinking=t},setWcError(t){Ie.wcError=t,Ie.wcFetchingUri=!1,Ie.buffering=!1},setRecentWallet(t){Ie.recentWallet=t},setBuffering(t){Ie.buffering=t},setStatus(t){Ie.status=t},setIsSwitchingConnection(t){Ie.isSwitchingConnection=t},async disconnect({id:t,namespace:e,initialDisconnect:s}={}){var n;try{await((n=G._getClient())==null?void 0:n.disconnect({id:t,chainNamespace:e,initialDisconnect:s}))}catch(r){throw new Tr("Failed to disconnect","INTERNAL_SDK_ERROR",r)}},async disconnectConnector({id:t,namespace:e}){var s;try{await((s=G._getClient())==null?void 0:s.disconnectConnector({id:t,namespace:e}))}catch(n){throw new Tr("Failed to disconnect connector","INTERNAL_SDK_ERROR",n)}},setConnections(t,e){const s=new Map(Ie.connections);s.set(e,t),Ie.connections=s},async handleAuthAccountSwitch({address:t,namespace:e}){var i,o;const s=E.getAccountData(e),n=(o=(i=s==null?void 0:s.user)==null?void 0:i.accounts)==null?void 0:o.find(a=>a.type==="smartAccount"),r=n&&n.address.toLowerCase()===t.toLowerCase()&&Ci.canSwitchToSmartAccount(e)?"smartAccount":"eoa";await G.setPreferredAccountType(r,e)},async handleActiveConnection({connection:t,namespace:e,address:s}){const n=V.getConnectorById(t.connectorId),r=t.connectorId===U.CONNECTOR_ID.AUTH;if(!n)throw new Error(`No connector found for connection: ${t.connectorId}`);if(r)s&&await G.handleAuthAccountSwitch({address:s,namespace:e});else{const i=await G.connectExternal({id:n.id,type:n.type,provider:n.provider,address:s,chain:e},e);return i==null?void 0:i.address}return s},async handleDisconnectedConnection({connection:t,namespace:e,address:s,closeModalOnConnect:n}){var l,d;const r=V.getConnectorById(t.connectorId),i=(d=(l=t.auth)==null?void 0:l.name)==null?void 0:d.toLowerCase(),o=t.connectorId===U.CONNECTOR_ID.AUTH,a=t.connectorId===U.CONNECTOR_ID.WALLET_CONNECT;if(!r)throw new Error(`No connector found for connection: ${t.connectorId}`);let c;if(o)if(i&&Ci.isSocialProvider(i)){const{address:u}=await Ci.connectSocial({social:i,closeModalOnConnect:n,onOpenFarcaster(){Te.open({view:"ConnectingFarcaster"})},onConnect(){ue.replace("ProfileWallets")}});c=u}else{const{address:u}=await Ci.connectEmail({closeModalOnConnect:n,onOpen(){Te.open({view:"EmailLogin"})},onConnect(){ue.replace("ProfileWallets")}});c=u}else if(a){const{address:u}=await Ci.connectWalletConnect({walletConnect:!0,connector:r,closeModalOnConnect:n,onOpen(h){const p=h?"AllWallets":"ConnectingWalletConnect";Te.state.open?ue.push(p):Te.open({view:p})},onConnect(){ue.replace("ProfileWallets")}});c=u}else{const u=await G.connectExternal({id:r.id,type:r.type,provider:r.provider,chain:e},e);u&&(c=u.address)}return o&&s&&await G.handleAuthAccountSwitch({address:s,namespace:e}),c},async switchConnection({connection:t,address:e,namespace:s,closeModalOnConnect:n,onChange:r}){var c;let i;const o=(c=E.getAccountData(s))==null?void 0:c.caipAddress;if(o){const{address:l}=dt.parseCaipAddress(o);i=l}const a=Ua.getConnectionStatus(t,s);switch(a){case"connected":case"active":{const l=await G.handleActiveConnection({connection:t,namespace:s,address:e});if(i&&l){const d=l.toLowerCase()!==i.toLowerCase();r==null||r({address:l,namespace:s,hasSwitchedAccount:d,hasSwitchedWallet:a==="active"})}break}case"disconnected":{const l=await G.handleDisconnectedConnection({connection:t,namespace:s,address:e,closeModalOnConnect:n});l&&(r==null||r({address:l,namespace:s,hasSwitchedAccount:!0,hasSwitchedWallet:!0}));break}default:throw new Error(`Invalid connection status: ${a}`)}}},G=As(Wv),_c={createBalance(t,e){const s={name:t.metadata.name||"",symbol:t.metadata.symbol||"",decimals:t.metadata.decimals||0,value:t.metadata.value||0,price:t.metadata.price||0,iconUrl:t.metadata.iconUrl||""};return{name:s.name,symbol:s.symbol,chainId:e,address:t.address==="native"?void 0:this.convertAddressToCAIP10Address(t.address,e),value:s.value,price:s.price,quantity:{decimals:s.decimals.toString(),numeric:this.convertHexToBalance({hex:t.balance,decimals:s.decimals})},iconUrl:s.iconUrl}},convertHexToBalance({hex:t,decimals:e}){return mf(BigInt(t),e)},convertAddressToCAIP10Address(t,e){return`${e}:${t}`},createCAIP2ChainId(t,e){return`${e}:${parseInt(t,16)}`},getChainIdHexFromCAIP2ChainId(t){const e=t.split(":");if(e.length<2||!e[1])return"0x0";const s=e[1],n=parseInt(s,10);return isNaN(n)?"0x0":`0x${n.toString(16)}`},isWalletGetAssetsResponse(t){return typeof t!="object"||t===null?!1:Object.values(t).every(e=>Array.isArray(e)&&e.every(s=>this.isValidAsset(s)))},isValidAsset(t){return typeof t=="object"&&t!==null&&typeof t.address=="string"&&typeof t.balance=="string"&&(t.type==="ERC20"||t.type==="NATIVE")&&typeof t.metadata=="object"&&t.metadata!==null&&typeof t.metadata.name=="string"&&typeof t.metadata.symbol=="string"&&typeof t.metadata.decimals=="number"&&typeof t.metadata.price=="number"&&typeof t.metadata.iconUrl=="string"}};let Ac;async function qu(){if(!Ac){const{createPublicClient:t,http:e,defineChain:s}=await Dt(async()=>{const{createPublicClient:n,http:r,defineChain:i}=await import("./index-B2Nwx2Pb.js");return{createPublicClient:n,http:r,defineChain:i}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]));Ac={createPublicClient:t,http:e,defineChain:s}}return Ac}const Nl={getBlockchainApiRpcUrl(t,e){const s=new URL("https://rpc.walletconnect.org/v1/");return s.searchParams.set("chainId",t),s.searchParams.set("projectId",e),s.toString()},async getViemChain(t){const{defineChain:e}=await qu(),{chainId:s}=dt.parseCaipNetworkId(t.caipNetworkId);return e({...t,id:Number(s)})},async createViemPublicClient(t){const{createPublicClient:e,http:s}=await qu(),n=$.state.projectId,r=await Nl.getViemChain(t);if(!r)throw new Error(`Chain ${t.caipNetworkId} not found in viem/chains`);return e({chain:r,transport:s(Nl.getBlockchainApiRpcUrl(t.caipNetworkId,n))})}},_d={async getMyTokensWithBalance(t){var a;const e=(a=E.getAccountData())==null?void 0:a.address,s=E.state.activeCaipNetwork,n=V.getConnectorId("eip155")===U.CONNECTOR_ID.AUTH;if(!e||!s)return[];const r=`${s.caipNetworkId}:${e}`,i=F.getBalanceCacheForCaipAddress(r);if(i)return i.balances;if(s.chainNamespace===U.CHAIN.EVM&&n){const c=await this.getEIP155Balances(e,s);if(c)return this.filterLowQualityTokens(c)}const o=await fe.getBalance(e,s.caipNetworkId,t);return this.filterLowQualityTokens(o.balances)},async getEIP155Balances(t,e){var s,n;try{const r=_c.getChainIdHexFromCAIP2ChainId(e.caipNetworkId),i=await G.getCapabilities(t);if(!((n=(s=i==null?void 0:i[r])==null?void 0:s.assetDiscovery)!=null&&n.supported))return null;const o=await G.walletGetAssets({account:t,chainFilter:[r]});if(!_c.isWalletGetAssetsResponse(o))return null;const c=(o[r]||[]).map(l=>_c.createBalance(l,e.caipNetworkId));return F.updateBalanceCache({caipAddress:`${e.caipNetworkId}:${t}`,balance:{balances:c},timestamp:Date.now()}),c}catch{return null}},filterLowQualityTokens(t){return t.filter(e=>e.quantity.decimals!=="0")},async fetchERC20Balance({caipAddress:t,assetAddress:e,caipNetwork:s}){const n=await Nl.createViemPublicClient(s),{address:r}=dt.parseCaipAddress(t),[{result:i},{result:o},{result:a},{result:c}]=await n.multicall({contracts:[{address:e,functionName:"name",args:[],abi:Lo},{address:e,functionName:"symbol",args:[],abi:Lo},{address:e,functionName:"balanceOf",args:[r],abi:Lo},{address:e,functionName:"decimals",args:[],abi:Lo}]});return{name:i,symbol:o,decimals:c,balance:a&&c?mf(a,c):"0"}}},Sc={adapters:{}},qf={state:Sc,initialize(t){Sc.adapters={...t}},get(t){return Sc.adapters[t]}},$a={eip155:void 0,solana:void 0,polkadot:void 0,bip122:void 0,cosmos:void 0,sui:void 0,stacks:void 0,ton:void 0},qt=Ge({providers:{...$a},providerIds:{...$a}}),He={state:qt,subscribeKey(t,e){return At(qt,t,e)},subscribe(t){return _t(qt,()=>{t(qt)})},subscribeProviders(t){return _t(qt.providers,()=>t(qt.providers))},setProvider(t,e){t&&e&&(qt.providers[t]=Qi(e))},getProvider(t){if(t)return qt.providers[t]},setProviderId(t,e){e&&(qt.providerIds[t]=e)},getProviderId(t){if(t)return qt.providerIds[t]},reset(){qt.providers={...$a},qt.providerIds={...$a}},resetChain(t){qt.providers[t]=void 0,qt.providerIds[t]=void 0}},Hv={async getTokenList(t){var n;const e=await fe.fetchSwapTokens({chainId:t});return((n=e==null?void 0:e.tokens)==null?void 0:n.map(r=>({...r,eip2612:!1,quantity:{decimals:"0",numeric:"0"},price:0,value:0})))||[]},async fetchGasPrice(){var e;const t=E.state.activeCaipNetwork;if(!t)return null;try{switch(t.chainNamespace){case"solana":const s=(e=await(G==null?void 0:G.estimateGas({chainNamespace:"solana"})))==null?void 0:e.toString();return{standard:s,fast:s,instant:s};case"eip155":default:return await fe.fetchGasPrice({chainId:t.caipNetworkId})}}catch{return null}},async fetchSwapAllowance({tokenAddress:t,userAddress:e,sourceTokenAmount:s,sourceTokenDecimals:n}){const r=await fe.fetchSwapAllowance({tokenAddress:t,userAddress:e});if(r!=null&&r.allowance&&s&&n){const i=G.parseUnits(s,n)||0;return BigInt(r.allowance)>=i}return!1},async getMyTokensWithBalance(t){const e=await _d.getMyTokensWithBalance(t);return E.setAccountProp("tokenBalance",e,E.state.activeChain),this.mapBalancesToSwapTokens(e)},mapBalancesToSwapTokens(t){return(t==null?void 0:t.map(e=>({...e,address:e!=null&&e.address?e.address:Ff(),decimals:parseInt(e.quantity.decimals,10),logoUri:e.iconUrl,eip2612:!1})))||[]},async handleSwapError(t){var e,s;try{const n=t==null?void 0:t.cause;if(!(n!=null&&n.json))return;const r=await n.json(),i=(s=(e=r==null?void 0:r.reasons)==null?void 0:e[0])==null?void 0:s.description;return i!=null&&i.includes("insufficient liquidity")?"Insufficient liquidity":void 0}catch{return}}},Ue=Ge({tokenBalances:[],loading:!1}),Vv={state:Ue,subscribe(t){return _t(Ue,()=>t(Ue))},subscribeKey(t,e){return At(Ue,t,e)},setToken(t){t&&(Ue.token=Qi(t))},setTokenAmount(t){Ue.sendTokenAmount=t},setReceiverAddress(t){Ue.receiverAddress=t},setReceiverProfileImageUrl(t){Ue.receiverProfileImageUrl=t},setReceiverProfileName(t){Ue.receiverProfileName=t},setNetworkBalanceInUsd(t){Ue.networkBalanceInUSD=t},setLoading(t){Ue.loading=t},getSdkEventProperties(t){var e,s;return{message:X.parseError(t),isSmartAccount:ls(E.state.activeChain)===tt.ACCOUNT_TYPES.SMART_ACCOUNT,token:((e=Ue.token)==null?void 0:e.symbol)||"",amount:Ue.sendTokenAmount??0,network:((s=E.state.activeCaipNetwork)==null?void 0:s.caipNetworkId)||""}},async sendToken(){var t;try{switch(Ae.setLoading(!0),(t=E.state.activeCaipNetwork)==null?void 0:t.chainNamespace){case"eip155":await Ae.sendEvmToken();return;case"solana":await Ae.sendSolanaToken();return;default:throw new Error("Unsupported chain")}}catch(e){throw gn.isUserRejectedRequestError(e)?new _f(e):e}finally{Ae.setLoading(!1)}},async sendEvmToken(){var s,n,r;const t=E.state.activeChain;if(!t)throw new Error("SendController:sendEvmToken - activeChainNamespace is required");const e=ls(t);if(!Ae.state.sendTokenAmount||!Ae.state.receiverAddress)throw new Error("An amount and receiver address are required");if(!Ae.state.token)throw new Error("A token is required");if((s=Ae.state.token)!=null&&s.address){Ee.sendEvent({type:"track",event:"SEND_INITIATED",properties:{isSmartAccount:e===tt.ACCOUNT_TYPES.SMART_ACCOUNT,token:Ae.state.token.address,amount:Ae.state.sendTokenAmount,network:((n=E.state.activeCaipNetwork)==null?void 0:n.caipNetworkId)||""}});const{hash:i}=await Ae.sendERC20Token({receiverAddress:Ae.state.receiverAddress,tokenAddress:Ae.state.token.address,sendTokenAmount:Ae.state.sendTokenAmount,decimals:Ae.state.token.quantity.decimals});i&&(Ue.hash=i)}else{Ee.sendEvent({type:"track",event:"SEND_INITIATED",properties:{isSmartAccount:e===tt.ACCOUNT_TYPES.SMART_ACCOUNT,token:Ae.state.token.symbol||"",amount:Ae.state.sendTokenAmount,network:((r=E.state.activeCaipNetwork)==null?void 0:r.caipNetworkId)||""}});const{hash:i}=await Ae.sendNativeToken({receiverAddress:Ae.state.receiverAddress,sendTokenAmount:Ae.state.sendTokenAmount,decimals:Ae.state.token.quantity.decimals});i&&(Ue.hash=i)}},async fetchTokenBalance(t){var o,a,c;Ue.loading=!0;const e=E.state.activeChain,s=(o=E.state.activeCaipNetwork)==null?void 0:o.caipNetworkId,n=(a=E.state.activeCaipNetwork)==null?void 0:a.chainNamespace,r=((c=E.getAccountData(e))==null?void 0:c.caipAddress)??E.state.activeCaipAddress,i=r?X.getPlainAddress(r):void 0;if(Ue.lastRetry&&!X.isAllowedRetry(Ue.lastRetry,30*Ne.ONE_SEC_MS))return Ue.loading=!1,[];try{if(i&&s&&n){const l=await _d.getMyTokensWithBalance();return Ue.tokenBalances=l,Ue.lastRetry=void 0,l}}catch(l){Ue.lastRetry=Date.now(),t==null||t(l),zs.showError("Token Balance Unavailable")}finally{Ue.loading=!1}return[]},fetchNetworkBalance(){if(Ue.tokenBalances.length===0)return;const t=Hv.mapBalancesToSwapTokens(Ue.tokenBalances);if(!t)return;const e=t.find(s=>s.address===Ff());e&&(Ue.networkBalanceInUSD=e?Yy.multiply(e.quantity.numeric,e.price).toString():"0")},async sendNativeToken(t){var o,a,c,l;ue.pushTransactionStack({});const e=t.receiverAddress,s=(o=E.getAccountData())==null?void 0:o.address,n=G.parseUnits(t.sendTokenAmount.toString(),Number(t.decimals)),i=await G.sendTransaction({chainNamespace:U.CHAIN.EVM,to:e,address:s,data:"0x",value:n??BigInt(0)});return Ee.sendEvent({type:"track",event:"SEND_SUCCESS",properties:{isSmartAccount:ls("eip155")===tt.ACCOUNT_TYPES.SMART_ACCOUNT,token:((a=Ae.state.token)==null?void 0:a.symbol)||"",amount:t.sendTokenAmount,network:((c=E.state.activeCaipNetwork)==null?void 0:c.caipNetworkId)||"",hash:i||""}}),(l=G._getClient())==null||l.updateBalance("eip155"),Ae.resetSend(),{hash:i}},async sendERC20Token(t){var n,r,i;ue.pushTransactionStack({onSuccess(){ue.replace("Account")}});const e=G.parseUnits(t.sendTokenAmount.toString(),Number(t.decimals)),s=(n=E.getAccountData())==null?void 0:n.address;if(s&&t.sendTokenAmount&&t.receiverAddress&&t.tokenAddress){const o=X.getPlainAddress(t.tokenAddress);if(!o)throw new Error("SendController:sendERC20Token - tokenAddress is required");const a=await G.writeContract({fromAddress:s,tokenAddress:o,args:[t.receiverAddress,e??BigInt(0)],method:"transfer",abi:Qy.getERC20Abi(o),chainNamespace:U.CHAIN.EVM});return Ee.sendEvent({type:"track",event:"SEND_SUCCESS",properties:{isSmartAccount:ls("eip155")===tt.ACCOUNT_TYPES.SMART_ACCOUNT,token:((r=Ae.state.token)==null?void 0:r.symbol)||"",amount:t.sendTokenAmount,network:((i=E.state.activeCaipNetwork)==null?void 0:i.caipNetworkId)||"",hash:a||""}}),Ae.resetSend(),{hash:a}}return{hash:void 0}},async sendSolanaToken(){var s,n,r;if(!Ae.state.sendTokenAmount||!Ae.state.receiverAddress)throw new Error("An amount and receiver address are required");ue.pushTransactionStack({onSuccess(){ue.replace("Account")}});let t;Ae.state.token&&Ae.state.token.address!==Ne.SOLANA_NATIVE_TOKEN_ADDRESS&&(X.isCaipAddress(Ae.state.token.address)?t=X.getPlainAddress(Ae.state.token.address):t=Ae.state.token.address);const e=await G.sendTransaction({chainNamespace:"solana",tokenMint:t,to:Ae.state.receiverAddress,value:Ae.state.sendTokenAmount});e&&(Ue.hash=e),(s=G._getClient())==null||s.updateBalance("solana"),Ee.sendEvent({type:"track",event:"SEND_SUCCESS",properties:{isSmartAccount:!1,token:((n=Ae.state.token)==null?void 0:n.symbol)||"",amount:Ae.state.sendTokenAmount,network:((r=E.state.activeCaipNetwork)==null?void 0:r.caipNetworkId)||"",hash:e||""}}),Ae.resetSend()},resetSend(){Ue.token=void 0,Ue.sendTokenAmount=void 0,Ue.receiverAddress=void 0,Ue.receiverProfileImageUrl=void 0,Ue.receiverProfileName=void 0,Ue.loading=!1,Ue.tokenBalances=[]}},Ae=As(Vv),Ic={currentTab:0,tokenBalance:[],smartAccountDeployed:!1,addressLabels:new Map,user:void 0,preferredAccountType:void 0},zo={caipNetwork:void 0,supportsAllNetworks:!0,smartAccountEnabledNetworks:[]},Q=Ge({chains:pw(),activeCaipAddress:void 0,activeChain:void 0,activeCaipNetwork:void 0,noAdapters:!1,universalAdapter:{connectionControllerClient:void 0},isSwitchingNamespace:!1}),Wf={state:Q,subscribe(t){return _t(Q,()=>{t(Q)})},subscribeKey(t,e){return At(Q,t,e)},subscribeAccountStateProp(t,e,s){var r;const n=s||Q.activeChain;return n?At(((r=Q.chains.get(n))==null?void 0:r.accountState)||{},t,e):()=>{}},subscribeChainProp(t,e,s){let n;return _t(Q.chains,()=>{var i;const r=s||Q.activeChain;if(r){const o=(i=Q.chains.get(r))==null?void 0:i[t];n!==o&&(n=o,e(o))}})},initialize(t,e,s){const{chainId:n,namespace:r}=F.getActiveNetworkProps(),i=e==null?void 0:e.find(d=>d.id.toString()===(n==null?void 0:n.toString())),a=t.find(d=>(d==null?void 0:d.namespace)===r)||(t==null?void 0:t[0]),c=t.map(d=>d.namespace).filter(d=>d!==void 0),l=$.state.enableEmbedded?new Set([...c]):new Set([...(e==null?void 0:e.map(d=>d.chainNamespace))??[]]);((t==null?void 0:t.length)===0||!a)&&(Q.noAdapters=!0),Q.noAdapters||(Q.activeChain=a==null?void 0:a.namespace,Q.activeCaipNetwork=i,E.setChainNetworkData(a==null?void 0:a.namespace,{caipNetwork:i}),Q.activeChain&&ds.set({activeChain:a==null?void 0:a.namespace})),l.forEach(d=>{const u=e==null?void 0:e.filter(g=>g.chainNamespace===d),h=F.getPreferredAccountTypes()||{},p={...$.state.defaultAccountTypes,...h};E.state.chains.set(d,{namespace:d,networkState:Ge({...zo,caipNetwork:u==null?void 0:u[0]}),accountState:Ge({...Ic,preferredAccountType:p[d]}),caipNetworks:u??[],...s}),E.setRequestedCaipNetworks(u??[],d)})},removeAdapter(t){var e,s;if(Q.activeChain===t){const n=Array.from(Q.chains.entries()).find(([r])=>r!==t);if(n){const r=(s=(e=n[1])==null?void 0:e.caipNetworks)==null?void 0:s[0];r&&E.setActiveCaipNetwork(r)}}Q.chains.delete(t)},addAdapter(t,{connectionControllerClient:e},s){if(!t.namespace)throw new Error("ChainController:addAdapter - adapter must have a namespace");Q.chains.set(t.namespace,{namespace:t.namespace,networkState:{...zo,caipNetwork:s[0]},accountState:{...Ic},caipNetworks:s,connectionControllerClient:e}),E.setRequestedCaipNetworks((s==null?void 0:s.filter(n=>n.chainNamespace===t.namespace))??[],t.namespace)},addNetwork(t){var s;const e=Q.chains.get(t.chainNamespace);if(e){const n=[...e.caipNetworks||[]];(s=e.caipNetworks)!=null&&s.find(r=>r.id===t.id)||n.push(t),Q.chains.set(t.chainNamespace,{...e,caipNetworks:n}),E.setRequestedCaipNetworks(n,t.chainNamespace),V.filterByNamespace(t.chainNamespace,!0)}},removeNetwork(t,e){var n,r,i;const s=Q.chains.get(t);if(s){const o=((n=Q.activeCaipNetwork)==null?void 0:n.id)===e,a=[...((r=s.caipNetworks)==null?void 0:r.filter(c=>c.id!==e))||[]];o&&((i=s==null?void 0:s.caipNetworks)!=null&&i[0])&&E.setActiveCaipNetwork(s.caipNetworks[0]),Q.chains.set(t,{...s,caipNetworks:a}),E.setRequestedCaipNetworks(a||[],t),a.length===0&&V.filterByNamespace(t,!1)}},setAdapterNetworkState(t,e){const s=Q.chains.get(t);s&&(s.networkState={...s.networkState||zo,...e},Q.chains.set(t,s))},setChainAccountData(t,e,s=!0){if(!t)throw new Error("Chain is required to update chain account data");const n=Q.chains.get(t);if(n){const r={...n.accountState||Ic,...e};Q.chains.set(t,{...n,accountState:r}),(Q.chains.size===1||Q.activeChain===t)&&e.caipAddress&&(Q.activeCaipAddress=e.caipAddress)}},setChainNetworkData(t,e){if(!t)return;const s=Q.chains.get(t);if(s){const n={...s.networkState||zo,...e};Q.chains.set(t,{...s,networkState:n})}},setAccountProp(t,e,s,n=!0){E.setChainAccountData(s,{[t]:e},n)},setActiveNamespace(t){var n,r;Q.activeChain=t;const e=t?Q.chains.get(t):void 0,s=(n=e==null?void 0:e.networkState)==null?void 0:n.caipNetwork;s!=null&&s.id&&t&&(Q.activeCaipAddress=(r=e==null?void 0:e.accountState)==null?void 0:r.caipAddress,Q.activeCaipNetwork=s,E.setChainNetworkData(t,{caipNetwork:s}),F.setActiveCaipNetworkId(s==null?void 0:s.caipNetworkId),ds.set({activeChain:t,selectedNetworkId:s==null?void 0:s.caipNetworkId}))},setActiveCaipNetwork(t){var i,o;if(!t)return;const e=Q.activeChain===t.chainNamespace;e||E.setIsSwitchingNamespace(!0);const s=Q.chains.get(t.chainNamespace);Q.activeChain=t.chainNamespace,Q.activeCaipNetwork=t,E.setChainNetworkData(t.chainNamespace,{caipNetwork:t});let n=(i=s==null?void 0:s.accountState)==null?void 0:i.address;if(n)Q.activeCaipAddress=`${t.chainNamespace}:${t.id}:${n}`;else if(e&&Q.activeCaipAddress){const{address:a}=dt.parseCaipAddress(Q.activeCaipAddress);n=a,Q.activeCaipAddress=`${t.caipNetworkId}:${n}`}else Q.activeCaipAddress=void 0;E.setChainAccountData(t.chainNamespace,{address:n,caipAddress:Q.activeCaipAddress}),Ae.resetSend(),ds.set({activeChain:Q.activeChain,selectedNetworkId:(o=Q.activeCaipNetwork)==null?void 0:o.caipNetworkId}),F.setActiveCaipNetworkId(t.caipNetworkId),!E.checkIfSupportedNetwork(t.chainNamespace)&&$.state.enableNetworkSwitch&&!$.state.allowUnsupportedChain&&!G.state.wcBasic&&E.showUnsupportedChainUI()},addCaipNetwork(t){var s;if(!t)return;const e=Q.chains.get(t.chainNamespace);e&&((s=e==null?void 0:e.caipNetworks)==null||s.push(t))},async switchActiveNamespace(t){var r;if(!t)return;const e=t!==E.state.activeChain,s=(r=E.getNetworkData(t))==null?void 0:r.caipNetwork,n=E.getCaipNetworkByNamespace(t,s==null?void 0:s.id);e&&n&&await E.switchActiveNetwork(n)},async switchActiveNetwork(t,{throwOnFailure:e=!1}={}){var o;const s=E.state.activeChain;if(!s)throw new Error("ChainController:switchActiveNetwork - namespace is required");const n=He.getProviderId(Q.activeChain)==="AUTH",r=(o=E.getAccountData(s))==null?void 0:o.address,i=U.AUTH_CONNECTOR_SUPPORTED_CHAINS.includes(t.chainNamespace);try{if(r&&t.chainNamespace===s||n&&i){const a=qf.get(t.chainNamespace);if(!a)throw new Error("Adapter not found");await a.switchNetwork({caipNetwork:t})}E.setActiveCaipNetwork(t)}catch(a){if(e)throw a}Ee.sendEvent({type:"track",event:"SWITCH_NETWORK",properties:{network:t.caipNetworkId}})},getConnectionControllerClient(t){const e=t||Q.activeChain;if(!e)throw new Error("Chain is required to get connection controller client");const s=Q.chains.get(e);if(!(s!=null&&s.connectionControllerClient))throw new Error("ConnectionController client not set");return s.connectionControllerClient},getNetworkProp(t,e){var n;const s=(n=Q.chains.get(e))==null?void 0:n.networkState;if(s)return s[t]},getRequestedCaipNetworks(t){const e=Q.chains.get(t),{approvedCaipNetworkIds:s=[],requestedCaipNetworks:n=[]}=(e==null?void 0:e.networkState)||{};return X.sortRequestedNetworks(s,n).filter(o=>o==null?void 0:o.id)},getAllRequestedCaipNetworks(){const t=[];return Q.chains.forEach(e=>{if(!e.namespace)throw new Error("ChainController:getAllRequestedCaipNetworks - chainAdapter must have a namespace");const s=E.getRequestedCaipNetworks(e.namespace);t.push(...s)}),t},setRequestedCaipNetworks(t,e){E.setAdapterNetworkState(e,{requestedCaipNetworks:t});const n=E.getAllRequestedCaipNetworks().map(i=>i.chainNamespace),r=Array.from(new Set(n));V.filterByNamespaces(r)},getAllApprovedCaipNetworkIds(){const t=[];return Q.chains.forEach(e=>{if(!e.namespace)throw new Error("ChainController:getAllApprovedCaipNetworkIds - chainAdapter must have a namespace");const s=E.getApprovedCaipNetworkIds(e.namespace);t.push(...s)}),t},getActiveCaipNetwork(t){var e,s;return t?(s=(e=Q.chains.get(t))==null?void 0:e.networkState)==null?void 0:s.caipNetwork:Q.activeCaipNetwork},getActiveCaipAddress(){return Q.activeCaipAddress},getApprovedCaipNetworkIds(t){var n;const e=Q.chains.get(t);return((n=e==null?void 0:e.networkState)==null?void 0:n.approvedCaipNetworkIds)||[]},setApprovedCaipNetworksData(t,e){E.setAdapterNetworkState(t,e)},checkIfSupportedNetwork(t,e){var r;const s=e||((r=Q.activeCaipNetwork)==null?void 0:r.caipNetworkId),n=E.getRequestedCaipNetworks(t);return n.length?n==null?void 0:n.some(i=>i.caipNetworkId===s):!0},checkIfSupportedChainId(t){if(!Q.activeChain)return!0;const e=E.getRequestedCaipNetworks(Q.activeChain);return e==null?void 0:e.some(s=>s.id===t)},checkIfSmartAccountEnabled(){var n,r;const t=yf.caipNetworkIdToNumber((n=Q.activeCaipNetwork)==null?void 0:n.caipNetworkId);if(!Q.activeChain||!t)return!1;const s=((r=lt.get(oe.SMART_ACCOUNT_ENABLED_NETWORKS))==null?void 0:r.split(","))||[];return!!(s!=null&&s.includes(t.toString()))},showUnsupportedChainUI(){Te.open({view:"UnsupportedChain"})},checkIfNamesSupported(){const t=Q.activeCaipNetwork;return!!(t!=null&&t.chainNamespace&&Ne.NAMES_SUPPORTED_CHAIN_NAMESPACES.includes(t.chainNamespace))},resetNetwork(t){E.setAdapterNetworkState(t,{approvedCaipNetworkIds:void 0,supportsAllNetworks:!0})},resetAccount(t){var r,i;const e=t;if(!e)throw new Error("Chain is required to set account prop");const s=(i=(r=E.state.chains.get(e))==null?void 0:r.accountState)==null?void 0:i.preferredAccountType,n=$.state.defaultAccountTypes[e];Q.activeCaipAddress=void 0,E.setChainAccountData(e,{smartAccountDeployed:!1,currentTab:0,caipAddress:void 0,address:void 0,balance:void 0,balanceSymbol:void 0,profileName:void 0,profileImage:void 0,addressExplorerUrl:void 0,tokenBalance:[],connectedWalletInfo:void 0,preferredAccountType:n||s,socialProvider:void 0,socialWindow:void 0,farcasterUrl:void 0,user:void 0,status:"disconnected"}),V.removeConnectorId(e)},setIsSwitchingNamespace(t){Q.isSwitchingNamespace=t},getFirstCaipNetworkSupportsAuthConnector(){var s,n;const t=[];let e;if(Q.chains.forEach(r=>{U.AUTH_CONNECTOR_SUPPORTED_CHAINS.find(i=>i===r.namespace)&&r.namespace&&t.push(r.namespace)}),t.length>0){const r=t[0];return e=r?(n=(s=Q.chains.get(r))==null?void 0:s.caipNetworks)==null?void 0:n[0]:void 0,e}},getAccountData(t){var s;const e=t||Q.activeChain;if(e)return(s=E.state.chains.get(e))==null?void 0:s.accountState},getNetworkData(t){var s;const e=t||Q.activeChain;if(e)return(s=E.state.chains.get(e))==null?void 0:s.networkState},getCaipNetworkByNamespace(t,e){var r,i,o;if(!t)return;const s=E.state.chains.get(t),n=(r=s==null?void 0:s.caipNetworks)==null?void 0:r.find(a=>a.id.toString()===(e==null?void 0:e.toString()));return n||((i=s==null?void 0:s.networkState)==null?void 0:i.caipNetwork)||((o=s==null?void 0:s.caipNetworks)==null?void 0:o[0])},getRequestedCaipNetworkIds(){const t=V.state.filterByNamespace;return(t?[Q.chains.get(t)]:Array.from(Q.chains.values())).flatMap(s=>(s==null?void 0:s.caipNetworks)||[]).map(s=>s.caipNetworkId)},getCaipNetworks(t){return t?E.getRequestedCaipNetworks(t):E.getAllRequestedCaipNetworks()},getCaipNetworkById(t,e){return Wf.getCaipNetworks(e).find(s=>s.id.toString()===t.toString()||s.caipNetworkId.toString()===t.toString())},setLastConnectedSIWECaipNetwork(t){Q.lastConnectedSIWECaipNetwork=t},getLastConnectedSIWECaipNetwork(){return Q.lastConnectedSIWECaipNetwork},async fetchTokenBalance(t){var o,a;const e=E.getAccountData();if(!e)return[];const s=(o=E.state.activeCaipNetwork)==null?void 0:o.caipNetworkId,n=(a=E.state.activeCaipNetwork)==null?void 0:a.chainNamespace,r=E.state.activeCaipAddress,i=r?X.getPlainAddress(r):void 0;if(E.setAccountProp("balanceLoading",!0,n),e.lastRetry&&!X.isAllowedRetry(e.lastRetry,30*Ne.ONE_SEC_MS))return E.setAccountProp("balanceLoading",!1,n),[];try{if(i&&s&&n){const c=await _d.getMyTokensWithBalance();return E.setAccountProp("tokenBalance",c,n),E.setAccountProp("lastRetry",void 0,n),E.setAccountProp("balanceLoading",!1,n),c}}catch(c){E.setAccountProp("lastRetry",Date.now(),n),t==null||t(c),zs.showError("Token Balance Unavailable")}finally{E.setAccountProp("balanceLoading",!1,n)}return[]},isCaipNetworkDisabled(t){var c;const e=t.chainNamespace,s=!!((c=E.getAccountData(e))!=null&&c.caipAddress),n=E.getAllApprovedCaipNetworkIds(),r=E.getNetworkProp("supportsAllNetworks",e)!==!1,i=V.getConnectorId(e),o=V.getAuthConnector(),a=i===U.CONNECTOR_ID.AUTH&&o;return!s||r||a?!1:!(n!=null&&n.includes(t.caipNetworkId))}},E=As(Wf),zv={onSwitchNetwork({network:t,ignoreSwitchConfirmation:e=!1}){var h,p;const s=E.state.activeCaipNetwork,n=E.state.activeChain,r=ue.state.data;if(t.id===(s==null?void 0:s.id))return;const o=!!((h=E.getAccountData(n))!=null&&h.address),a=!!((p=E.getAccountData(t.chainNamespace))!=null&&p.address),c=t.chainNamespace!==n,d=V.getConnectorId(n)===U.CONNECTOR_ID.AUTH,u=U.AUTH_CONNECTOR_SUPPORTED_CHAINS.find(g=>g===t.chainNamespace);e||d&&u?ue.push("SwitchNetwork",{...r,network:t}):o&&c&&!a?ue.push("SwitchActiveChain",{switchToChain:t.chainNamespace,navigateTo:"Connect",navigateWithReplace:!0,network:t}):ue.push("SwitchNetwork",{...r,network:t})}},Wt=Ge({loading:!1,loadingNamespaceMap:new Map,open:!1,shake:!1,namespace:void 0}),Kv={state:Wt,subscribe(t){return _t(Wt,()=>t(Wt))},subscribeKey(t,e){return At(Wt,t,e)},async open(t){var o,a;const e=t==null?void 0:t.namespace,s=E.state.activeChain,n=e&&e!==s,r=(o=E.getAccountData(t==null?void 0:t.namespace))==null?void 0:o.caipAddress,i=E.state.noAdapters;if(G.state.wcBasic?te.prefetch({fetchNetworkImages:!1,fetchConnectorImages:!1,fetchWalletRanks:!1}):await te.prefetch(),V.setFilterByNamespace(t==null?void 0:t.namespace),Te.setLoading(!0,e),e&&n){const c=((a=E.getNetworkData(e))==null?void 0:a.caipNetwork)||E.getRequestedCaipNetworks(e)[0];c&&(i?(await E.switchActiveNetwork(c),ue.push("ConnectingWalletConnectBasic")):zv.onSwitchNetwork({network:c,ignoreSwitchConfirmation:!0}))}else $.state.manualWCControl||i&&!r?X.isMobile()?ue.reset("AllWallets"):ue.reset("ConnectingWalletConnectBasic"):t!=null&&t.view?ue.reset(t.view,t.data):r?ue.reset("Account"):ue.reset("Connect");Wt.open=!0,ds.set({open:!0}),Ee.sendEvent({type:"track",event:"MODAL_OPEN",properties:{connected:!!r}})},close(){const t=$.state.enableEmbedded,e=!!E.state.activeCaipAddress;Wt.open&&Ee.sendEvent({type:"track",event:"MODAL_CLOSE",properties:{connected:e}}),Wt.open=!1,ue.reset("Connect"),Te.clearLoading(),t?e?ue.replace("Account"):ue.push("Connect"):ds.set({open:!1}),G.resetUri()},setLoading(t,e){e&&Wt.loadingNamespaceMap.set(e,t),Wt.loading=t,ds.set({loading:t})},clearLoading(){Wt.loadingNamespaceMap.clear(),Wt.loading=!1,ds.set({loading:!1})},shake(){Wt.shake||(Wt.shake=!0,setTimeout(()=>{Wt.shake=!1},500))}},Te=As(Kv),ji={id:"2b92315d-eab7-5bef-84fa-089a131333f5",name:"USD Coin",symbol:"USDC",networks:[{name:"ethereum-mainnet",display_name:"Ethereum",chain_id:"1",contract_address:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},{name:"polygon-mainnet",display_name:"Polygon",chain_id:"137",contract_address:"0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174"}]},Tl={id:"USD",payment_method_limits:[{id:"card",min:"10.00",max:"7500.00"},{id:"ach_bank_account",min:"10.00",max:"25000.00"}]},Gv={providers:Sf,selectedProvider:null,error:null,purchaseCurrency:ji,paymentCurrency:Tl,purchaseCurrencies:[ji],paymentCurrencies:[],quotesLoading:!1},$e=Ge(Gv),Yv={state:$e,subscribe(t){return _t($e,()=>t($e))},subscribeKey(t,e){return At($e,t,e)},setSelectedProvider(t){var e,s;if(t&&t.name==="meld"){const n=E.state.activeChain,r=n===U.CHAIN.SOLANA?"SOL":"USDC",i=n?((s=(e=E.state.chains.get(n))==null?void 0:e.accountState)==null?void 0:s.address)??"":"",o=new URL(t.url);o.searchParams.append("publicKey",fw),o.searchParams.append("destinationCurrencyCode",r),o.searchParams.append("walletAddress",i),o.searchParams.append("externalCustomerId",$.state.projectId),$e.selectedProvider={...t,url:o.toString()}}else $e.selectedProvider=t},setOnrampProviders(t){if(Array.isArray(t)&&t.every(e=>typeof e=="string")){const e=t,s=Sf.filter(n=>e.includes(n.name));$e.providers=s}else $e.providers=[]},setPurchaseCurrency(t){$e.purchaseCurrency=t},setPaymentCurrency(t){$e.paymentCurrency=t},setPurchaseAmount(t){Rl.state.purchaseAmount=t},setPaymentAmount(t){Rl.state.paymentAmount=t},async getAvailableCurrencies(){const t=await fe.getOnrampOptions();$e.purchaseCurrencies=t.purchaseCurrencies,$e.paymentCurrencies=t.paymentCurrencies,$e.paymentCurrency=t.paymentCurrencies[0]||Tl,$e.purchaseCurrency=t.purchaseCurrencies[0]||ji,await te.fetchCurrencyImages(t.paymentCurrencies.map(e=>e.id)),await te.fetchTokenImages(t.purchaseCurrencies.map(e=>e.symbol))},async getQuote(){var t,e;$e.quotesLoading=!0;try{const s=await fe.getOnrampQuote({purchaseCurrency:$e.purchaseCurrency,paymentCurrency:$e.paymentCurrency,amount:((t=$e.paymentAmount)==null?void 0:t.toString())||"0",network:(e=$e.purchaseCurrency)==null?void 0:e.symbol});return $e.quotesLoading=!1,$e.purchaseAmount=Number(s==null?void 0:s.purchaseAmount.amount),s}catch(s){return $e.error=s.message,$e.quotesLoading=!1,null}finally{$e.quotesLoading=!1}},resetState(){$e.selectedProvider=null,$e.error=null,$e.purchaseCurrency=ji,$e.paymentCurrency=Tl,$e.purchaseCurrencies=[ji],$e.paymentCurrencies=[],$e.paymentAmount=void 0,$e.purchaseAmount=void 0,$e.quotesLoading=!1}},Rl=As(Yv);function Zv(t){return!t||typeof t.then!="function"?Promise.resolve(t):t}function ft(t,...e){try{return Zv(t(...e))}catch(s){return Promise.reject(s)}}function Jv(t){const e=typeof t;return t===null||e!=="object"&&e!=="function"}function Xv(t){const e=Object.getPrototypeOf(t);return!e||e.isPrototypeOf(Object)}function pa(t){if(Jv(t))return String(t);if(Xv(t)||Array.isArray(t))return JSON.stringify(t);if(typeof t.toJSON=="function")return pa(t.toJSON());throw new Error("[unstorage] Cannot stringify value!")}const Ol="base64:";function Qv(t){return typeof t=="string"?t:Ol+sC(t)}function eC(t){return typeof t!="string"||!t.startsWith(Ol)?t:tC(t.slice(Ol.length))}function tC(t){return globalThis.Buffer?Pe.from(t,"base64"):Uint8Array.from(globalThis.atob(t),e=>e.codePointAt(0))}function sC(t){return globalThis.Buffer?Pe.from(t).toString("base64"):globalThis.btoa(String.fromCodePoint(...t))}function Vt(t){var e;return t&&((e=t.split("?")[0])==null?void 0:e.replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,""))||""}function nC(...t){return Vt(t.join(":"))}function Ko(t){return t=Vt(t),t?t+":":""}function rC(t,e){if(e===void 0)return!0;let s=0,n=t.indexOf(":");for(;n>-1;)s++,n=t.indexOf(":",n+1);return s<=e}function iC(t,e){return e?t.startsWith(e)&&t[t.length-1]!=="$":t[t.length-1]!=="$"}const oC="memory",aC=()=>{const t=new Map;return{name:oC,getInstance:()=>t,hasItem(e){return t.has(e)},getItem(e){return t.get(e)??null},getItemRaw(e){return t.get(e)??null},setItem(e,s){t.set(e,s)},setItemRaw(e,s){t.set(e,s)},removeItem(e){t.delete(e)},getKeys(){return[...t.keys()]},clear(){t.clear()},dispose(){t.clear()}}};function cC(t={}){const e={mounts:{"":t.driver||aC()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},s=l=>{for(const d of e.mountpoints)if(l.startsWith(d))return{base:d,relativeKey:l.slice(d.length),driver:e.mounts[d]};return{base:"",relativeKey:l,driver:e.mounts[""]}},n=(l,d)=>e.mountpoints.filter(u=>u.startsWith(l)||d&&l.startsWith(u)).map(u=>({relativeBase:l.length>u.length?l.slice(u.length):void 0,mountpoint:u,driver:e.mounts[u]})),r=(l,d)=>{if(e.watching){d=Vt(d);for(const u of e.watchListeners)u(l,d)}},i=async()=>{if(!e.watching){e.watching=!0;for(const l in e.mounts)e.unwatch[l]=await Wu(e.mounts[l],r,l)}},o=async()=>{if(e.watching){for(const l in e.unwatch)await e.unwatch[l]();e.unwatch={},e.watching=!1}},a=(l,d,u)=>{const h=new Map,p=g=>{let f=h.get(g.base);return f||(f={driver:g.driver,base:g.base,items:[]},h.set(g.base,f)),f};for(const g of l){const f=typeof g=="string",w=Vt(f?g:g.key),v=f?void 0:g.value,N=f||!g.options?d:{...d,...g.options},A=s(w);p(A).items.push({key:w,value:v,relativeKey:A.relativeKey,options:N})}return Promise.all([...h.values()].map(g=>u(g))).then(g=>g.flat())},c={hasItem(l,d={}){l=Vt(l);const{relativeKey:u,driver:h}=s(l);return ft(h.hasItem,u,d)},getItem(l,d={}){l=Vt(l);const{relativeKey:u,driver:h}=s(l);return ft(h.getItem,u,d).then(p=>Mo(p))},getItems(l,d={}){return a(l,d,u=>u.driver.getItems?ft(u.driver.getItems,u.items.map(h=>({key:h.relativeKey,options:h.options})),d).then(h=>h.map(p=>({key:nC(u.base,p.key),value:Mo(p.value)}))):Promise.all(u.items.map(h=>ft(u.driver.getItem,h.relativeKey,h.options).then(p=>({key:h.key,value:Mo(p)})))))},getItemRaw(l,d={}){l=Vt(l);const{relativeKey:u,driver:h}=s(l);return h.getItemRaw?ft(h.getItemRaw,u,d):ft(h.getItem,u,d).then(p=>eC(p))},async setItem(l,d,u={}){if(d===void 0)return c.removeItem(l);l=Vt(l);const{relativeKey:h,driver:p}=s(l);p.setItem&&(await ft(p.setItem,h,pa(d),u),p.watch||r("update",l))},async setItems(l,d){await a(l,d,async u=>{if(u.driver.setItems)return ft(u.driver.setItems,u.items.map(h=>({key:h.relativeKey,value:pa(h.value),options:h.options})),d);u.driver.setItem&&await Promise.all(u.items.map(h=>ft(u.driver.setItem,h.relativeKey,pa(h.value),h.options)))})},async setItemRaw(l,d,u={}){if(d===void 0)return c.removeItem(l,u);l=Vt(l);const{relativeKey:h,driver:p}=s(l);if(p.setItemRaw)await ft(p.setItemRaw,h,d,u);else if(p.setItem)await ft(p.setItem,h,Qv(d),u);else return;p.watch||r("update",l)},async removeItem(l,d={}){typeof d=="boolean"&&(d={removeMeta:d}),l=Vt(l);const{relativeKey:u,driver:h}=s(l);h.removeItem&&(await ft(h.removeItem,u,d),(d.removeMeta||d.removeMata)&&await ft(h.removeItem,u+"$",d),h.watch||r("remove",l))},async getMeta(l,d={}){typeof d=="boolean"&&(d={nativeOnly:d}),l=Vt(l);const{relativeKey:u,driver:h}=s(l),p=Object.create(null);if(h.getMeta&&Object.assign(p,await ft(h.getMeta,u,d)),!d.nativeOnly){const g=await ft(h.getItem,u+"$",d).then(f=>Mo(f));g&&typeof g=="object"&&(typeof g.atime=="string"&&(g.atime=new Date(g.atime)),typeof g.mtime=="string"&&(g.mtime=new Date(g.mtime)),Object.assign(p,g))}return p},setMeta(l,d,u={}){return this.setItem(l+"$",d,u)},removeMeta(l,d={}){return this.removeItem(l+"$",d)},async getKeys(l,d={}){var w;l=Ko(l);const u=n(l,!0);let h=[];const p=[];let g=!0;for(const v of u){(w=v.driver.flags)!=null&&w.maxDepth||(g=!1);const N=await ft(v.driver.getKeys,v.relativeBase,d);for(const A of N){const _=v.mountpoint+Vt(A);h.some(P=>_.startsWith(P))||p.push(_)}h=[v.mountpoint,...h.filter(A=>!A.startsWith(v.mountpoint))]}const f=d.maxDepth!==void 0&&!g;return p.filter(v=>(!f||rC(v,d.maxDepth))&&iC(v,l))},async clear(l,d={}){l=Ko(l),await Promise.all(n(l,!1).map(async u=>{if(u.driver.clear)return ft(u.driver.clear,u.relativeBase,d);if(u.driver.removeItem){const h=await u.driver.getKeys(u.relativeBase||"",d);return Promise.all(h.map(p=>u.driver.removeItem(p,d)))}}))},async dispose(){await Promise.all(Object.values(e.mounts).map(l=>Hu(l)))},async watch(l){return await i(),e.watchListeners.push(l),async()=>{e.watchListeners=e.watchListeners.filter(d=>d!==l),e.watchListeners.length===0&&await o()}},async unwatch(){e.watchListeners=[],await o()},mount(l,d){if(l=Ko(l),l&&e.mounts[l])throw new Error(`already mounted at ${l}`);return l&&(e.mountpoints.push(l),e.mountpoints.sort((u,h)=>h.length-u.length)),e.mounts[l]=d,e.watching&&Promise.resolve(Wu(d,r,l)).then(u=>{e.unwatch[l]=u}).catch(console.error),c},async unmount(l,d=!0){var u,h;l=Ko(l),!(!l||!e.mounts[l])&&(e.watching&&l in e.unwatch&&((h=(u=e.unwatch)[l])==null||h.call(u),delete e.unwatch[l]),d&&await Hu(e.mounts[l]),e.mountpoints=e.mountpoints.filter(p=>p!==l),delete e.mounts[l])},getMount(l=""){l=Vt(l)+":";const d=s(l);return{driver:d.driver,base:d.base}},getMounts(l="",d={}){return l=Vt(l),n(l,d.parents).map(h=>({driver:h.driver,base:h.mountpoint}))},keys:(l,d={})=>c.getKeys(l,d),get:(l,d={})=>c.getItem(l,d),set:(l,d,u={})=>c.setItem(l,d,u),has:(l,d={})=>c.hasItem(l,d),del:(l,d={})=>c.removeItem(l,d),remove:(l,d={})=>c.removeItem(l,d)};return c}function Wu(t,e,s){return t.watch?t.watch((n,r)=>e(n,s+r)):()=>{}}async function Hu(t){typeof t.dispose=="function"&&await ft(t.dispose)}const lC="idb-keyval";var dC=(t={})=>{const e=t.base&&t.base.length>0?`${t.base}:`:"",s=r=>e+r;let n;return t.dbName&&t.storeName&&(n=Iy(t.dbName,t.storeName)),{name:lC,options:t,async hasItem(r){return!(typeof await bu(s(r),n)>"u")},async getItem(r){return await bu(s(r),n)??null},setItem(r,i){return Oy(s(r),i,n)},removeItem(r){return Ry(s(r),n)},getKeys(){return Ty(n)},clear(){return Ny(n)}}};const uC="WALLET_CONNECT_V2_INDEXED_DB",hC="keyvaluestorage";let pC=class{constructor(){this.indexedDb=cC({driver:dC({dbName:uC,storeName:hC})})}async getKeys(){return this.indexedDb.getKeys()}async getEntries(){return(await this.indexedDb.getItems(await this.indexedDb.getKeys())).map(e=>[e.key,e.value])}async getItem(e){const s=await this.indexedDb.getItem(e);if(s!==null)return s}async setItem(e,s){await this.indexedDb.setItem(e,Gi(s))}async removeItem(e){await this.indexedDb.removeItem(e)}};var Nc=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof Ce<"u"?Ce:typeof self<"u"?self:{},fa={exports:{}};(function(){let t;function e(){}t=e,t.prototype.getItem=function(s){return this.hasOwnProperty(s)?String(this[s]):null},t.prototype.setItem=function(s,n){this[s]=String(n)},t.prototype.removeItem=function(s){delete this[s]},t.prototype.clear=function(){const s=this;Object.keys(s).forEach(function(n){s[n]=void 0,delete s[n]})},t.prototype.key=function(s){return s=s||0,Object.keys(this)[s]},t.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof Nc<"u"&&Nc.localStorage?fa.exports=Nc.localStorage:typeof window<"u"&&window.localStorage?fa.exports=window.localStorage:fa.exports=new e})();function fC(t){var e;return[t[0],va((e=t[1])!=null?e:"")]}let gC=class{constructor(){this.localStorage=fa.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(fC)}async getItem(e){const s=this.localStorage.getItem(e);if(s!==null)return va(s)}async setItem(e,s){this.localStorage.setItem(e,Gi(s))}async removeItem(e){this.localStorage.removeItem(e)}};const mC="wc_storage_version",Vu=1,yC=async(t,e,s)=>{const n=mC,r=await e.getItem(n);if(r&&r>=Vu){s(e);return}const i=await t.getKeys();if(!i.length){s(e);return}const o=[];for(;i.length;){const a=i.shift();if(!a)continue;const c=a.toLowerCase();if(c.includes("wc@")||c.includes("walletconnect")||c.includes("wc_")||c.includes("wallet_connect")){const l=await t.getItem(a);await e.setItem(a,l),o.push(a)}}await e.setItem(n,Vu),s(e),wC(t,o)},wC=async(t,e)=>{e.length&&e.forEach(async s=>{await t.removeItem(s)})};let EC=class{constructor(){this.initialized=!1,this.setInitialized=s=>{this.storage=s,this.initialized=!0};const e=new gC;this.storage=e;try{const s=new pC;yC(e,s,this.setInitialized)}catch{this.initialized=!0}}async getKeys(){return await this.initialize(),this.storage.getKeys()}async getEntries(){return await this.initialize(),this.storage.getEntries()}async getItem(e){return await this.initialize(),this.storage.getItem(e)}async setItem(e,s){return await this.initialize(),this.storage.setItem(e,s)}async removeItem(e){return await this.initialize(),this.storage.removeItem(e)}async initialize(){this.initialized||await new Promise(e=>{const s=setInterval(()=>{this.initialized&&(clearInterval(s),e())},20)})}};var bC=Object.defineProperty,vC=(t,e,s)=>e in t?bC(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,zu=(t,e,s)=>vC(t,typeof e!="symbol"?e+"":e,s);let CC=class extends fi{constructor(e){super(),this.opts=e,zu(this,"protocol","wc"),zu(this,"version",2)}};var _C=Object.defineProperty,AC=(t,e,s)=>e in t?_C(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,SC=(t,e,s)=>AC(t,e+"",s);let IC=class extends fi{constructor(e,s){super(),this.core=e,this.logger=s,SC(this,"records",new Map)}},NC=class{constructor(e,s){this.logger=e,this.core=s}},TC=class extends fi{constructor(e,s){super(),this.relayer=e,this.logger=s}},RC=class extends fi{constructor(e){super()}},OC=class{constructor(e,s,n,r){this.core=e,this.logger=s,this.name=n}},PC=class extends fi{constructor(e,s){super(),this.relayer=e,this.logger=s}},xC=class extends fi{constructor(e,s){super(),this.core=e,this.logger=s}},kC=class{constructor(e,s,n){this.core=e,this.logger=s,this.store=n}};class UC{constructor(e,s){this.projectId=e,this.logger=s}}let $C=class{constructor(e,s,n){this.core=e,this.logger=s,this.telemetryEnabled=n}};var DC=Object.defineProperty,LC=(t,e,s)=>e in t?DC(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Ku=(t,e,s)=>LC(t,typeof e!="symbol"?e+"":e,s);let MC=class{constructor(e){this.opts=e,Ku(this,"protocol","wc"),Ku(this,"version",2)}},BC=class{constructor(e){this.client=e}};const jC="0.1.1";function FC(){return jC}class Je extends Error{constructor(e,s={}){const n=(()=>{var c;if(s.cause instanceof Je){if(s.cause.details)return s.cause.details;if(s.cause.shortMessage)return s.cause.shortMessage}return s.cause&&"details"in s.cause&&typeof s.cause.details=="string"?s.cause.details:(c=s.cause)!=null&&c.message?s.cause.message:s.details})(),r=s.cause instanceof Je&&s.cause.docsPath||s.docsPath,o=`https://oxlib.sh${r??""}`,a=[e||"An error occurred.",...s.metaMessages?["",...s.metaMessages]:[],...n||r?["",n?`Details: ${n}`:void 0,r?`See: ${o}`:void 0]:[]].filter(c=>typeof c=="string").join(`
|
|
5
5
|
`);super(a,s.cause?{cause:s.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:`ox@${FC()}`}),this.cause=s.cause,this.details=n,this.docs=o,this.docsPath=r,this.shortMessage=e}walk(e){return Hf(this,e)}}function Hf(t,e){return e!=null&&e(t)?t:t&&typeof t=="object"&&"cause"in t&&t.cause?Hf(t.cause,e):e?null:t}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ad=BigInt(0),Pl=BigInt(1);function Io(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Sd(t){if(!Io(t))throw new Error("Uint8Array expected")}function po(t,e){if(typeof e!="boolean")throw new Error(t+" boolean expected, got "+e)}function Go(t){const e=t.toString(16);return e.length&1?"0"+e:e}function Vf(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?Ad:BigInt("0x"+t)}const zf=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",qC=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function fo(t){if(Sd(t),zf)return t.toHex();let e="";for(let s=0;s<t.length;s++)e+=qC[t[s]];return e}const nn={_0:48,_9:57,A:65,F:70,a:97,f:102};function Gu(t){if(t>=nn._0&&t<=nn._9)return t-nn._0;if(t>=nn.A&&t<=nn.F)return t-(nn.A-10);if(t>=nn.a&&t<=nn.f)return t-(nn.a-10)}function Da(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);if(zf)return Uint8Array.fromHex(t);const e=t.length,s=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const n=new Uint8Array(s);for(let r=0,i=0;r<s;r++,i+=2){const o=Gu(t.charCodeAt(i)),a=Gu(t.charCodeAt(i+1));if(o===void 0||a===void 0){const c=t[i]+t[i+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+i)}n[r]=o*16+a}return n}function Cr(t){return Vf(fo(t))}function Kf(t){return Sd(t),Vf(fo(Uint8Array.from(t).reverse()))}function No(t,e){return Da(t.toString(16).padStart(e*2,"0"))}function Gf(t,e){return No(t,e).reverse()}function ws(t,e,s){let n;if(typeof e=="string")try{n=Da(e)}catch(i){throw new Error(t+" must be hex string or Uint8Array, cause: "+i)}else if(Io(e))n=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");const r=n.length;if(typeof s=="number"&&r!==s)throw new Error(t+" of length "+s+" expected, got "+r);return n}function La(...t){let e=0;for(let n=0;n<t.length;n++){const r=t[n];Sd(r),e+=r.length}const s=new Uint8Array(e);for(let n=0,r=0;n<t.length;n++){const i=t[n];s.set(i,r),r+=i.length}return s}const Tc=t=>typeof t=="bigint"&&Ad<=t;function Id(t,e,s){return Tc(t)&&Tc(e)&&Tc(s)&&e<=t&&t<s}function ti(t,e,s,n){if(!Id(e,s,n))throw new Error("expected valid "+t+": "+s+" <= n < "+n+", got "+e)}function WC(t){let e;for(e=0;t>Ad;t>>=Pl,e+=1);return e}const sc=t=>(Pl<<BigInt(t))-Pl,Rc=t=>new Uint8Array(t),Yu=t=>Uint8Array.from(t);function HC(t,e,s){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof s!="function")throw new Error("hmacFn must be a function");let n=Rc(t),r=Rc(t),i=0;const o=()=>{n.fill(1),r.fill(0),i=0},a=(...u)=>s(r,n,...u),c=(u=Rc(0))=>{r=a(Yu([0]),u),n=a(),u.length!==0&&(r=a(Yu([1]),u),n=a())},l=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let u=0;const h=[];for(;u<e;){n=a();const p=n.slice();h.push(p),u+=n.length}return La(...h)};return(u,h)=>{o(),c(u);let p;for(;!(p=h(l()));)c();return o(),p}}const VC={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||Io(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function nc(t,e,s={}){const n=(r,i,o)=>{const a=VC[i];if(typeof a!="function")throw new Error("invalid validator function");const c=t[r];if(!(o&&c===void 0)&&!a(c,t))throw new Error("param "+String(r)+" is invalid. Expected "+i+", got "+c)};for(const[r,i]of Object.entries(e))n(r,i,!1);for(const[r,i]of Object.entries(s))n(r,i,!0);return t}function Zu(t){const e=new WeakMap;return(s,...n)=>{const r=e.get(s);if(r!==void 0)return r;const i=t(s,...n);return e.set(s,i),i}}function zC(t,e){if(eh(t)>e)throw new p_({givenSize:eh(t),maxSize:e})}const rn={zero:48,nine:57,A:65,F:70,a:97,f:102};function Ju(t){if(t>=rn.zero&&t<=rn.nine)return t-rn.zero;if(t>=rn.A&&t<=rn.F)return t-(rn.A-10);if(t>=rn.a&&t<=rn.f)return t-(rn.a-10)}function KC(t,e={}){const{dir:s,size:n=32}=e;if(n===0)return t;if(t.length>n)throw new f_({size:t.length,targetSize:n,type:"Bytes"});const r=new Uint8Array(n);for(let i=0;i<n;i++){const o=s==="right";r[o?i:n-i-1]=t[o?i:t.length-i-1]}return r}function Yf(t,e){if(Xn(t)>e)throw new n_({givenSize:Xn(t),maxSize:e})}function GC(t,e){if(typeof e=="number"&&e>0&&e>Xn(t)-1)throw new Xf({offset:e,position:"start",size:Xn(t)})}function YC(t,e,s){if(typeof e=="number"&&typeof s=="number"&&Xn(t)!==s-e)throw new Xf({offset:s,position:"end",size:Xn(t)})}function Zf(t,e={}){const{dir:s,size:n=32}=e;if(n===0)return t;const r=t.replace("0x","");if(r.length>n*2)throw new r_({size:Math.ceil(r.length/2),targetSize:n,type:"Hex"});return`0x${r[s==="right"?"padEnd":"padStart"](n*2,"0")}`}const ZC="#__bigint";function Nd(t,e,s){return JSON.stringify(t,(n,r)=>typeof r=="bigint"?r.toString()+ZC:r,s)}const JC=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function XC(t,e={}){const{strict:s=!1}=e;if(!t)throw new Xu(t);if(typeof t!="string")throw new Xu(t);if(s&&!/^0x[0-9a-fA-F]*$/.test(t))throw new Qu(t);if(!t.startsWith("0x"))throw new Qu(t)}function QC(...t){return`0x${t.reduce((e,s)=>e+s.replace("0x",""),"")}`}function Td(t){return t instanceof Uint8Array?Ma(t):Array.isArray(t)?Ma(new Uint8Array(t)):t}function Ma(t,e={}){let s="";for(let r=0;r<t.length;r++)s+=JC[t[r]];const n=`0x${s}`;return typeof e.size=="number"?(Yf(n,e.size),Jf(n,e.size)):n}function Oc(t,e={}){const{signed:s,size:n}=e,r=BigInt(t);let i;n?s?i=(1n<<BigInt(n)*8n-1n)-1n:i=2n**(BigInt(n)*8n)-1n:typeof t=="number"&&(i=BigInt(Number.MAX_SAFE_INTEGER));const o=typeof i=="bigint"&&s?-i-1n:0;if(i&&r>i||r<o){const l=typeof t=="bigint"?"n":"";throw new s_({max:i?`${i}${l}`:void 0,min:`${o}${l}`,signed:s,size:n,value:`${t}${l}`})}const c=`0x${(s&&r<0?(1n<<BigInt(n*8))+BigInt(r):r).toString(16)}`;return n?e_(c,n):c}function e_(t,e){return Zf(t,{dir:"left",size:e})}function Jf(t,e){return Zf(t,{dir:"right",size:e})}function un(t,e,s,n={}){const{strict:r}=n;GC(t,e);const i=`0x${t.replace("0x","").slice((e??0)*2,(s??t.length)*2)}`;return r&&YC(i,e,s),i}function Xn(t){return Math.ceil((t.length-2)/2)}function t_(t,e={}){const{strict:s=!1}=e;try{return XC(t,{strict:s}),!0}catch{return!1}}class s_ extends Je{constructor({max:e,min:s,signed:n,size:r,value:i}){super(`Number \`${i}\` is not in safe${r?` ${r*8}-bit`:""}${n?" signed":" unsigned"} integer range ${e?`(\`${s}\` to \`${e}\`)`:`(above \`${s}\`)`}`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.IntegerOutOfRangeError"})}}class Xu extends Je{constructor(e){super(`Value \`${typeof e=="object"?Nd(e):e}\` of type \`${typeof e}\` is an invalid hex type.`,{metaMessages:['Hex types must be represented as `"0x${string}"`.']}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.InvalidHexTypeError"})}}class Qu extends Je{constructor(e){super(`Value \`${e}\` is an invalid hex value.`,{metaMessages:['Hex values must start with `"0x"` and contain only hexadecimal characters (0-9, a-f, A-F).']}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.InvalidHexValueError"})}}let n_=class extends Je{constructor({givenSize:e,maxSize:s}){super(`Size cannot exceed \`${s}\` bytes. Given size: \`${e}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeOverflowError"})}};class Xf extends Je{constructor({offset:e,position:s,size:n}){super(`Slice ${s==="start"?"starting":"ending"} at offset \`${e}\` is out-of-bounds (size: \`${n}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SliceOffsetOutOfBoundsError"})}}let r_=class extends Je{constructor({size:e,targetSize:s,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (\`${e}\`) exceeds padding size (\`${s}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeExceedsPaddingSizeError"})}};const i_=new TextEncoder;function o_(t){if(!(t instanceof Uint8Array)){if(!t)throw new Yo(t);if(typeof t!="object")throw new Yo(t);if(!("BYTES_PER_ELEMENT"in t))throw new Yo(t);if(t.BYTES_PER_ELEMENT!==1||t.constructor.name!=="Uint8Array")throw new Yo(t)}}function a_(t){return t instanceof Uint8Array?t:typeof t=="string"?l_(t):c_(t)}function c_(t){return t instanceof Uint8Array?t:new Uint8Array(t)}function l_(t,e={}){const{size:s}=e;let n=t;s&&(Yf(t,s),n=Jf(t,s));let r=n.slice(2);r.length%2&&(r=`0${r}`);const i=r.length/2,o=new Uint8Array(i);for(let a=0,c=0;a<i;a++){const l=Ju(r.charCodeAt(c++)),d=Ju(r.charCodeAt(c++));if(l===void 0||d===void 0)throw new Je(`Invalid byte sequence ("${r[c-2]}${r[c-1]}" in "${r}").`);o[a]=l*16+d}return o}function d_(t,e={}){const{size:s}=e,n=i_.encode(t);return typeof s=="number"?(zC(n,s),u_(n,s)):n}function u_(t,e){return KC(t,{dir:"right",size:e})}function eh(t){return t.length}function h_(t){try{return o_(t),!0}catch{return!1}}class Yo extends Je{constructor(e){super(`Value \`${typeof e=="object"?Nd(e):e}\` of type \`${typeof e}\` is an invalid Bytes value.`,{metaMessages:["Bytes values must be of type `Bytes`."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.InvalidBytesTypeError"})}}class p_ extends Je{constructor({givenSize:e,maxSize:s}){super(`Size cannot exceed \`${s}\` bytes. Given size: \`${e}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeOverflowError"})}}class f_ extends Je{constructor({size:e,targetSize:s,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (\`${e}\`) exceeds padding size (\`${s}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeExceedsPaddingSizeError"})}}function Qf(t,e={}){const{as:s=typeof t=="string"?"Hex":"Bytes"}=e,n=Ey(a_(t));return s==="Bytes"?n:Ma(n)}class g_ extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const s=super.get(e);return super.has(e)&&s!==void 0&&(this.delete(e),super.set(e,s)),s}set(e,s){if(super.set(e,s),this.maxSize&&this.size>this.maxSize){const n=this.keys().next().value;n&&this.delete(n)}return this}}const m_={checksum:new g_(8192)},Pc=m_.checksum;function eg(t,e={}){const{compressed:s}=e,{prefix:n,x:r,y:i}=t;if(s===!1||typeof r=="bigint"&&typeof i=="bigint"){if(n!==4)throw new th({prefix:n,cause:new C_});return}if(s===!0||typeof r=="bigint"&&typeof i>"u"){if(n!==3&&n!==2)throw new th({prefix:n,cause:new v_});return}throw new b_({publicKey:t})}function y_(t){const e=(()=>{if(t_(t))return tg(t);if(h_(t))return w_(t);const{prefix:s,x:n,y:r}=t;return typeof n=="bigint"&&typeof r=="bigint"?{prefix:s??4,x:n,y:r}:{prefix:s,x:n}})();return eg(e),e}function w_(t){return tg(Ma(t))}function tg(t){if(t.length!==132&&t.length!==130&&t.length!==68)throw new __({publicKey:t});if(t.length===130){const n=BigInt(un(t,0,32)),r=BigInt(un(t,32,64));return{prefix:4,x:n,y:r}}if(t.length===132){const n=Number(un(t,0,1)),r=BigInt(un(t,1,33)),i=BigInt(un(t,33,65));return{prefix:n,x:r,y:i}}const e=Number(un(t,0,1)),s=BigInt(un(t,1,33));return{prefix:e,x:s}}function E_(t,e={}){eg(t);const{prefix:s,x:n,y:r}=t,{includePrefix:i=!0}=e;return QC(i?Oc(s,{size:1}):"0x",Oc(n,{size:32}),typeof r=="bigint"?Oc(r,{size:32}):"0x")}class b_ extends Je{constructor({publicKey:e}){super(`Value \`${Nd(e)}\` is not a valid public key.`,{metaMessages:["Public key must contain:","- an `x` and `prefix` value (compressed)","- an `x`, `y`, and `prefix` value (uncompressed)"]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidError"})}}class th extends Je{constructor({prefix:e,cause:s}){super(`Prefix "${e}" is invalid.`,{cause:s}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidPrefixError"})}}class v_ extends Je{constructor(){super("Prefix must be 2 or 3 for compressed public keys."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidCompressedPrefixError"})}}class C_ extends Je{constructor(){super("Prefix must be 4 for uncompressed public keys."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidUncompressedPrefixError"})}}let __=class extends Je{constructor({publicKey:e}){super(`Value \`${e}\` is an invalid public key size.`,{metaMessages:["Expected: 33 bytes (compressed + prefix), 64 bytes (uncompressed) or 65 bytes (uncompressed + prefix).",`Received ${Xn(Td(e))} bytes.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidSerializedSizeError"})}};const A_=/^0x[a-fA-F0-9]{40}$/;function sg(t,e={}){const{strict:s=!0}=e;if(!A_.test(t))throw new sh({address:t,cause:new N_});if(s){if(t.toLowerCase()===t)return;if(ng(t)!==t)throw new sh({address:t,cause:new T_})}}function ng(t){if(Pc.has(t))return Pc.get(t);sg(t,{strict:!1});const e=t.substring(2).toLowerCase(),s=Qf(d_(e),{as:"Bytes"}),n=e.split("");for(let i=0;i<40;i+=2)s[i>>1]>>4>=8&&n[i]&&(n[i]=n[i].toUpperCase()),(s[i>>1]&15)>=8&&n[i+1]&&(n[i+1]=n[i+1].toUpperCase());const r=`0x${n.join("")}`;return Pc.set(t,r),r}function S_(t,e={}){const{checksum:s=!1}=e;return sg(t),s?ng(t):t}function I_(t,e={}){const s=Qf(`0x${E_(t).slice(4)}`).substring(26);return S_(`0x${s}`,e)}class sh extends Je{constructor({address:e,cause:s}){super(`Address "${e}" is invalid.`,{cause:s}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidAddressError"})}}class N_ extends Je{constructor(){super("Address is not a 20 byte (40 hexadecimal character) value."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidInputError"})}}class T_ extends Je{constructor(){super("Address does not match its checksum counterpart."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidChecksumError"})}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Jt=BigInt(0),Mt=BigInt(1),fr=BigInt(2),R_=BigInt(3),rg=BigInt(4),ig=BigInt(5),og=BigInt(8);function Gt(t,e){const s=t%e;return s>=Jt?s:e+s}function hs(t,e,s){let n=t;for(;e-- >Jt;)n*=n,n%=s;return n}function xl(t,e){if(t===Jt)throw new Error("invert: expected non-zero number");if(e<=Jt)throw new Error("invert: expected positive modulus, got "+e);let s=Gt(t,e),n=e,r=Jt,i=Mt;for(;s!==Jt;){const a=n/s,c=n%s,l=r-i*a;n=s,s=c,r=i,i=l}if(n!==Mt)throw new Error("invert: does not exist");return Gt(r,e)}function ag(t,e){const s=(t.ORDER+Mt)/rg,n=t.pow(e,s);if(!t.eql(t.sqr(n),e))throw new Error("Cannot find square root");return n}function O_(t,e){const s=(t.ORDER-ig)/og,n=t.mul(e,fr),r=t.pow(n,s),i=t.mul(e,r),o=t.mul(t.mul(i,fr),r),a=t.mul(i,t.sub(o,t.ONE));if(!t.eql(t.sqr(a),e))throw new Error("Cannot find square root");return a}function P_(t){if(t<BigInt(3))throw new Error("sqrt is not defined for small field");let e=t-Mt,s=0;for(;e%fr===Jt;)e/=fr,s++;let n=fr;const r=Rd(t);for(;nh(r,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(s===1)return ag;let i=r.pow(n,e);const o=(e+Mt)/fr;return function(c,l){if(c.is0(l))return l;if(nh(c,l)!==1)throw new Error("Cannot find square root");let d=s,u=c.mul(c.ONE,i),h=c.pow(l,e),p=c.pow(l,o);for(;!c.eql(h,c.ONE);){if(c.is0(h))return c.ZERO;let g=1,f=c.sqr(h);for(;!c.eql(f,c.ONE);)if(g++,f=c.sqr(f),g===d)throw new Error("Cannot find square root");const w=Mt<<BigInt(d-g-1),v=c.pow(u,w);d=g,u=c.sqr(v),h=c.mul(h,u),p=c.mul(p,v)}return p}}function x_(t){return t%rg===R_?ag:t%og===ig?O_:P_(t)}const k_=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function U_(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},s=k_.reduce((n,r)=>(n[r]="function",n),e);return nc(t,s)}function $_(t,e,s){if(s<Jt)throw new Error("invalid exponent, negatives unsupported");if(s===Jt)return t.ONE;if(s===Mt)return e;let n=t.ONE,r=e;for(;s>Jt;)s&Mt&&(n=t.mul(n,r)),r=t.sqr(r),s>>=Mt;return n}function cg(t,e,s=!1){const n=new Array(e.length).fill(s?t.ZERO:void 0),r=e.reduce((o,a,c)=>t.is0(a)?o:(n[c]=o,t.mul(o,a)),t.ONE),i=t.inv(r);return e.reduceRight((o,a,c)=>t.is0(a)?o:(n[c]=t.mul(o,n[c]),t.mul(o,a)),i),n}function nh(t,e){const s=(t.ORDER-Mt)/fr,n=t.pow(e,s),r=t.eql(n,t.ONE),i=t.eql(n,t.ZERO),o=t.eql(n,t.neg(t.ONE));if(!r&&!i&&!o)throw new Error("invalid Legendre symbol result");return r?1:i?0:-1}function lg(t,e){e!==void 0&&by(e);const s=e!==void 0?e:t.toString(2).length,n=Math.ceil(s/8);return{nBitLength:s,nByteLength:n}}function Rd(t,e,s=!1,n={}){if(t<=Jt)throw new Error("invalid field: expected ORDER > 0, got "+t);const{nBitLength:r,nByteLength:i}=lg(t,e);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let o;const a=Object.freeze({ORDER:t,isLE:s,BITS:r,BYTES:i,MASK:sc(r),ZERO:Jt,ONE:Mt,create:c=>Gt(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return Jt<=c&&c<t},is0:c=>c===Jt,isOdd:c=>(c&Mt)===Mt,neg:c=>Gt(-c,t),eql:(c,l)=>c===l,sqr:c=>Gt(c*c,t),add:(c,l)=>Gt(c+l,t),sub:(c,l)=>Gt(c-l,t),mul:(c,l)=>Gt(c*l,t),pow:(c,l)=>$_(a,c,l),div:(c,l)=>Gt(c*xl(l,t),t),sqrN:c=>c*c,addN:(c,l)=>c+l,subN:(c,l)=>c-l,mulN:(c,l)=>c*l,inv:c=>xl(c,t),sqrt:n.sqrt||(c=>(o||(o=x_(t)),o(a,c))),toBytes:c=>s?Gf(c,i):No(c,i),fromBytes:c=>{if(c.length!==i)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+c.length);return s?Kf(c):Cr(c)},invertBatch:c=>cg(a,c),cmov:(c,l,d)=>d?l:c});return Object.freeze(a)}function dg(t){if(typeof t!="bigint")throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function ug(t){const e=dg(t);return e+Math.ceil(e/2)}function D_(t,e,s=!1){const n=t.length,r=dg(e),i=ug(e);if(n<16||n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);const o=s?Kf(t):Cr(t),a=Gt(o,e-Mt)+Mt;return s?Gf(a,r):No(a,r)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const rh=BigInt(0),kl=BigInt(1);function xc(t,e){const s=e.negate();return t?s:e}function hg(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function kc(t,e){hg(t,e);const s=Math.ceil(e/t)+1,n=2**(t-1),r=2**t,i=sc(t),o=BigInt(t);return{windows:s,windowSize:n,mask:i,maxNumber:r,shiftBy:o}}function ih(t,e,s){const{windowSize:n,mask:r,maxNumber:i,shiftBy:o}=s;let a=Number(t&r),c=t>>o;a>n&&(a-=i,c+=kl);const l=e*n,d=l+Math.abs(a)-1,u=a===0,h=a<0,p=e%2!==0;return{nextN:c,offset:d,isZero:u,isNeg:h,isNegF:p,offsetF:l}}function L_(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((s,n)=>{if(!(s instanceof e))throw new Error("invalid point at index "+n)})}function M_(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((s,n)=>{if(!e.isValid(s))throw new Error("invalid scalar at index "+n)})}const Uc=new WeakMap,pg=new WeakMap;function $c(t){return pg.get(t)||1}function B_(t,e){return{constTimeNegate:xc,hasPrecomputes(s){return $c(s)!==1},unsafeLadder(s,n,r=t.ZERO){let i=s;for(;n>rh;)n&kl&&(r=r.add(i)),i=i.double(),n>>=kl;return r},precomputeWindow(s,n){const{windows:r,windowSize:i}=kc(n,e),o=[];let a=s,c=a;for(let l=0;l<r;l++){c=a,o.push(c);for(let d=1;d<i;d++)c=c.add(a),o.push(c);a=c.double()}return o},wNAF(s,n,r){let i=t.ZERO,o=t.BASE;const a=kc(s,e);for(let c=0;c<a.windows;c++){const{nextN:l,offset:d,isZero:u,isNeg:h,isNegF:p,offsetF:g}=ih(r,c,a);r=l,u?o=o.add(xc(p,n[g])):i=i.add(xc(h,n[d]))}return{p:i,f:o}},wNAFUnsafe(s,n,r,i=t.ZERO){const o=kc(s,e);for(let a=0;a<o.windows&&r!==rh;a++){const{nextN:c,offset:l,isZero:d,isNeg:u}=ih(r,a,o);if(r=c,!d){const h=n[l];i=i.add(u?h.negate():h)}}return i},getPrecomputes(s,n,r){let i=Uc.get(n);return i||(i=this.precomputeWindow(n,s),s!==1&&Uc.set(n,r(i))),i},wNAFCached(s,n,r){const i=$c(s);return this.wNAF(i,this.getPrecomputes(i,s,r),n)},wNAFCachedUnsafe(s,n,r,i){const o=$c(s);return o===1?this.unsafeLadder(s,n,i):this.wNAFUnsafe(o,this.getPrecomputes(o,s,r),n,i)},setWindowSize(s,n){hg(n,e),pg.set(s,n),Uc.delete(s)}}}function j_(t,e,s,n){L_(s,t),M_(n,e);const r=s.length,i=n.length;if(r!==i)throw new Error("arrays of points and scalars must have equal length");const o=t.ZERO,a=WC(BigInt(r));let c=1;a>12?c=a-3:a>4?c=a-2:a>0&&(c=2);const l=sc(c),d=new Array(Number(l)+1).fill(o),u=Math.floor((e.BITS-1)/c)*c;let h=o;for(let p=u;p>=0;p-=c){d.fill(o);for(let f=0;f<i;f++){const w=n[f],v=Number(w>>BigInt(p)&l);d[v]=d[v].add(s[f])}let g=o;for(let f=d.length-1,w=o;f>0;f--)w=w.add(d[f]),g=g.add(w);if(h=h.add(g),p!==0)for(let f=0;f<c;f++)h=h.double()}return h}function fg(t){return U_(t.Fp),nc(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...lg(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function oh(t){t.lowS!==void 0&&po("lowS",t.lowS),t.prehash!==void 0&&po("prehash",t.prehash)}function F_(t){const e=fg(t);nc(e,{a:"field",b:"field"},{allowInfinityPoint:"boolean",allowedPrivateKeyLengths:"array",clearCofactor:"function",fromBytes:"function",isTorsionFree:"function",toBytes:"function",wrapPrivateKey:"boolean"});const{endo:s,Fp:n,a:r}=e;if(s){if(!n.eql(r,n.ZERO))throw new Error("invalid endo: CURVE.a must be 0");if(typeof s!="object"||typeof s.beta!="bigint"||typeof s.splitScalar!="function")throw new Error('invalid endo: expected "beta": bigint and "splitScalar": function')}return Object.freeze({...e})}class q_ extends Error{constructor(e=""){super(e)}}const pn={Err:q_,_tlv:{encode:(t,e)=>{const{Err:s}=pn;if(t<0||t>256)throw new s("tlv.encode: wrong tag");if(e.length&1)throw new s("tlv.encode: unpadded data");const n=e.length/2,r=Go(n);if(r.length/2&128)throw new s("tlv.encode: long form length too big");const i=n>127?Go(r.length/2|128):"";return Go(t)+i+r+e},decode(t,e){const{Err:s}=pn;let n=0;if(t<0||t>256)throw new s("tlv.encode: wrong tag");if(e.length<2||e[n++]!==t)throw new s("tlv.decode: wrong tlv");const r=e[n++],i=!!(r&128);let o=0;if(!i)o=r;else{const c=r&127;if(!c)throw new s("tlv.decode(long): indefinite length not supported");if(c>4)throw new s("tlv.decode(long): byte length is too big");const l=e.subarray(n,n+c);if(l.length!==c)throw new s("tlv.decode: length bytes not complete");if(l[0]===0)throw new s("tlv.decode(long): zero leftmost byte");for(const d of l)o=o<<8|d;if(n+=c,o<128)throw new s("tlv.decode(long): not minimal encoding")}const a=e.subarray(n,n+o);if(a.length!==o)throw new s("tlv.decode: wrong value length");return{v:a,l:e.subarray(n+o)}}},_int:{encode(t){const{Err:e}=pn;if(t<mn)throw new e("integer: negative integers are not allowed");let s=Go(t);if(Number.parseInt(s[0],16)&8&&(s="00"+s),s.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return s},decode(t){const{Err:e}=pn;if(t[0]&128)throw new e("invalid signature integer: negative");if(t[0]===0&&!(t[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return Cr(t)}},toSig(t){const{Err:e,_int:s,_tlv:n}=pn,r=ws("signature",t),{v:i,l:o}=n.decode(48,r);if(o.length)throw new e("invalid signature: left bytes after parsing");const{v:a,l:c}=n.decode(2,i),{v:l,l:d}=n.decode(2,c);if(d.length)throw new e("invalid signature: left bytes after parsing");return{r:s.decode(a),s:s.decode(l)}},hexFromSig(t){const{_tlv:e,_int:s}=pn,n=e.encode(2,s.encode(t.r)),r=e.encode(2,s.encode(t.s)),i=n+r;return e.encode(48,i)}};function Dc(t,e){return fo(No(t,e))}const mn=BigInt(0),gt=BigInt(1);BigInt(2);const Lc=BigInt(3),W_=BigInt(4);function H_(t){const e=F_(t),{Fp:s}=e,n=Rd(e.n,e.nBitLength),r=e.toBytes||((A,_,P)=>{const D=_.toAffine();return La(Uint8Array.from([4]),s.toBytes(D.x),s.toBytes(D.y))}),i=e.fromBytes||(A=>{const _=A.subarray(1),P=s.fromBytes(_.subarray(0,s.BYTES)),D=s.fromBytes(_.subarray(s.BYTES,2*s.BYTES));return{x:P,y:D}});function o(A){const{a:_,b:P}=e,D=s.sqr(A),L=s.mul(D,A);return s.add(s.add(L,s.mul(A,_)),P)}function a(A,_){const P=s.sqr(_),D=o(A);return s.eql(P,D)}if(!a(e.Gx,e.Gy))throw new Error("bad curve params: generator point");const c=s.mul(s.pow(e.a,Lc),W_),l=s.mul(s.sqr(e.b),BigInt(27));if(s.is0(s.add(c,l)))throw new Error("bad curve params: a or b");function d(A){return Id(A,gt,e.n)}function u(A){const{allowedPrivateKeyLengths:_,nByteLength:P,wrapPrivateKey:D,n:L}=e;if(_&&typeof A!="bigint"){if(Io(A)&&(A=fo(A)),typeof A!="string"||!_.includes(A.length))throw new Error("invalid private key");A=A.padStart(P*2,"0")}let W;try{W=typeof A=="bigint"?A:Cr(ws("private key",A,P))}catch{throw new Error("invalid private key, expected hex or "+P+" bytes, got "+typeof A)}return D&&(W=Gt(W,L)),ti("private key",W,gt,L),W}function h(A){if(!(A instanceof f))throw new Error("ProjectivePoint expected")}const p=Zu((A,_)=>{const{px:P,py:D,pz:L}=A;if(s.eql(L,s.ONE))return{x:P,y:D};const W=A.is0();_==null&&(_=W?s.ONE:s.inv(L));const k=s.mul(P,_),q=s.mul(D,_),z=s.mul(L,_);if(W)return{x:s.ZERO,y:s.ZERO};if(!s.eql(z,s.ONE))throw new Error("invZ was invalid");return{x:k,y:q}}),g=Zu(A=>{if(A.is0()){if(e.allowInfinityPoint&&!s.is0(A.py))return;throw new Error("bad point: ZERO")}const{x:_,y:P}=A.toAffine();if(!s.isValid(_)||!s.isValid(P))throw new Error("bad point: x or y not FE");if(!a(_,P))throw new Error("bad point: equation left != right");if(!A.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class f{constructor(_,P,D){if(_==null||!s.isValid(_))throw new Error("x required");if(P==null||!s.isValid(P)||s.is0(P))throw new Error("y required");if(D==null||!s.isValid(D))throw new Error("z required");this.px=_,this.py=P,this.pz=D,Object.freeze(this)}static fromAffine(_){const{x:P,y:D}=_||{};if(!_||!s.isValid(P)||!s.isValid(D))throw new Error("invalid affine point");if(_ instanceof f)throw new Error("projective point not allowed");const L=W=>s.eql(W,s.ZERO);return L(P)&&L(D)?f.ZERO:new f(P,D,s.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(_){const P=cg(s,_.map(D=>D.pz));return _.map((D,L)=>D.toAffine(P[L])).map(f.fromAffine)}static fromHex(_){const P=f.fromAffine(i(ws("pointHex",_)));return P.assertValidity(),P}static fromPrivateKey(_){return f.BASE.multiply(u(_))}static msm(_,P){return j_(f,n,_,P)}_setWindowSize(_){N.setWindowSize(this,_)}assertValidity(){g(this)}hasEvenY(){const{y:_}=this.toAffine();if(s.isOdd)return!s.isOdd(_);throw new Error("Field doesn't support isOdd")}equals(_){h(_);const{px:P,py:D,pz:L}=this,{px:W,py:k,pz:q}=_,z=s.eql(s.mul(P,q),s.mul(W,L)),x=s.eql(s.mul(D,q),s.mul(k,L));return z&&x}negate(){return new f(this.px,s.neg(this.py),this.pz)}double(){const{a:_,b:P}=e,D=s.mul(P,Lc),{px:L,py:W,pz:k}=this;let q=s.ZERO,z=s.ZERO,x=s.ZERO,I=s.mul(L,L),T=s.mul(W,W),y=s.mul(k,k),b=s.mul(L,W);return b=s.add(b,b),x=s.mul(L,k),x=s.add(x,x),q=s.mul(_,x),z=s.mul(D,y),z=s.add(q,z),q=s.sub(T,z),z=s.add(T,z),z=s.mul(q,z),q=s.mul(b,q),x=s.mul(D,x),y=s.mul(_,y),b=s.sub(I,y),b=s.mul(_,b),b=s.add(b,x),x=s.add(I,I),I=s.add(x,I),I=s.add(I,y),I=s.mul(I,b),z=s.add(z,I),y=s.mul(W,k),y=s.add(y,y),I=s.mul(y,b),q=s.sub(q,I),x=s.mul(y,T),x=s.add(x,x),x=s.add(x,x),new f(q,z,x)}add(_){h(_);const{px:P,py:D,pz:L}=this,{px:W,py:k,pz:q}=_;let z=s.ZERO,x=s.ZERO,I=s.ZERO;const T=e.a,y=s.mul(e.b,Lc);let b=s.mul(P,W),S=s.mul(D,k),R=s.mul(L,q),C=s.add(P,D),O=s.add(W,k);C=s.mul(C,O),O=s.add(b,S),C=s.sub(C,O),O=s.add(P,L);let B=s.add(W,q);return O=s.mul(O,B),B=s.add(b,R),O=s.sub(O,B),B=s.add(D,L),z=s.add(k,q),B=s.mul(B,z),z=s.add(S,R),B=s.sub(B,z),I=s.mul(T,O),z=s.mul(y,R),I=s.add(z,I),z=s.sub(S,I),I=s.add(S,I),x=s.mul(z,I),S=s.add(b,b),S=s.add(S,b),R=s.mul(T,R),O=s.mul(y,O),S=s.add(S,R),R=s.sub(b,R),R=s.mul(T,R),O=s.add(O,R),b=s.mul(S,O),x=s.add(x,b),b=s.mul(B,O),z=s.mul(C,z),z=s.sub(z,b),b=s.mul(C,S),I=s.mul(B,I),I=s.add(I,b),new f(z,x,I)}subtract(_){return this.add(_.negate())}is0(){return this.equals(f.ZERO)}wNAF(_){return N.wNAFCached(this,_,f.normalizeZ)}multiplyUnsafe(_){const{endo:P,n:D}=e;ti("scalar",_,mn,D);const L=f.ZERO;if(_===mn)return L;if(this.is0()||_===gt)return this;if(!P||N.hasPrecomputes(this))return N.wNAFCachedUnsafe(this,_,f.normalizeZ);let{k1neg:W,k1:k,k2neg:q,k2:z}=P.splitScalar(_),x=L,I=L,T=this;for(;k>mn||z>mn;)k>&&(x=x.add(T)),z>&&(I=I.add(T)),T=T.double(),k>>=gt,z>>=gt;return W&&(x=x.negate()),q&&(I=I.negate()),I=new f(s.mul(I.px,P.beta),I.py,I.pz),x.add(I)}multiply(_){const{endo:P,n:D}=e;ti("scalar",_,gt,D);let L,W;if(P){const{k1neg:k,k1:q,k2neg:z,k2:x}=P.splitScalar(_);let{p:I,f:T}=this.wNAF(q),{p:y,f:b}=this.wNAF(x);I=N.constTimeNegate(k,I),y=N.constTimeNegate(z,y),y=new f(s.mul(y.px,P.beta),y.py,y.pz),L=I.add(y),W=T.add(b)}else{const{p:k,f:q}=this.wNAF(_);L=k,W=q}return f.normalizeZ([L,W])[0]}multiplyAndAddUnsafe(_,P,D){const L=f.BASE,W=(q,z)=>z===mn||z===gt||!q.equals(L)?q.multiplyUnsafe(z):q.multiply(z),k=W(this,P).add(W(_,D));return k.is0()?void 0:k}toAffine(_){return p(this,_)}isTorsionFree(){const{h:_,isTorsionFree:P}=e;if(_===gt)return!0;if(P)return P(f,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:_,clearCofactor:P}=e;return _===gt?this:P?P(f,this):this.multiplyUnsafe(e.h)}toRawBytes(_=!0){return po("isCompressed",_),this.assertValidity(),r(f,this,_)}toHex(_=!0){return po("isCompressed",_),fo(this.toRawBytes(_))}}f.BASE=new f(e.Gx,e.Gy,s.ONE),f.ZERO=new f(s.ZERO,s.ONE,s.ZERO);const{endo:w,nBitLength:v}=e,N=B_(f,w?Math.ceil(v/2):v);return{CURVE:e,ProjectivePoint:f,normPrivateKeyToScalar:u,weierstrassEquation:o,isWithinCurveOrder:d}}function V_(t){const e=fg(t);return nc(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function z_(t){const e=V_(t),{Fp:s,n,nByteLength:r,nBitLength:i}=e,o=s.BYTES+1,a=2*s.BYTES+1;function c(y){return Gt(y,n)}function l(y){return xl(y,n)}const{ProjectivePoint:d,normPrivateKeyToScalar:u,weierstrassEquation:h,isWithinCurveOrder:p}=H_({...e,toBytes(y,b,S){const R=b.toAffine(),C=s.toBytes(R.x),O=La;return po("isCompressed",S),S?O(Uint8Array.from([b.hasEvenY()?2:3]),C):O(Uint8Array.from([4]),C,s.toBytes(R.y))},fromBytes(y){const b=y.length,S=y[0],R=y.subarray(1);if(b===o&&(S===2||S===3)){const C=Cr(R);if(!Id(C,gt,s.ORDER))throw new Error("Point is not on curve");const O=h(C);let B;try{B=s.sqrt(O)}catch(j){const J=j instanceof Error?": "+j.message:"";throw new Error("Point is not on curve"+J)}const M=(B>)===gt;return(S&1)===1!==M&&(B=s.neg(B)),{x:C,y:B}}else if(b===a&&S===4){const C=s.fromBytes(R.subarray(0,s.BYTES)),O=s.fromBytes(R.subarray(s.BYTES,2*s.BYTES));return{x:C,y:O}}else{const C=o,O=a;throw new Error("invalid Point, expected length of "+C+", or uncompressed "+O+", got "+b)}}});function g(y){const b=n>>gt;return y>b}function f(y){return g(y)?c(-y):y}const w=(y,b,S)=>Cr(y.slice(b,S));class v{constructor(b,S,R){ti("r",b,gt,n),ti("s",S,gt,n),this.r=b,this.s=S,R!=null&&(this.recovery=R),Object.freeze(this)}static fromCompact(b){const S=r;return b=ws("compactSignature",b,S*2),new v(w(b,0,S),w(b,S,2*S))}static fromDER(b){const{r:S,s:R}=pn.toSig(ws("DER",b));return new v(S,R)}assertValidity(){}addRecoveryBit(b){return new v(this.r,this.s,b)}recoverPublicKey(b){const{r:S,s:R,recovery:C}=this,O=L(ws("msgHash",b));if(C==null||![0,1,2,3].includes(C))throw new Error("recovery id invalid");const B=C===2||C===3?S+e.n:S;if(B>=s.ORDER)throw new Error("recovery id 2 or 3 invalid");const M=(C&1)===0?"02":"03",ce=d.fromHex(M+Dc(B,s.BYTES)),j=l(B),J=c(-O*j),he=c(R*j),ge=d.BASE.multiplyAndAddUnsafe(ce,J,he);if(!ge)throw new Error("point at infinify");return ge.assertValidity(),ge}hasHighS(){return g(this.s)}normalizeS(){return this.hasHighS()?new v(this.r,c(-this.s),this.recovery):this}toDERRawBytes(){return Da(this.toDERHex())}toDERHex(){return pn.hexFromSig(this)}toCompactRawBytes(){return Da(this.toCompactHex())}toCompactHex(){const b=r;return Dc(this.r,b)+Dc(this.s,b)}}const N={isValidPrivateKey(y){try{return u(y),!0}catch{return!1}},normPrivateKeyToScalar:u,randomPrivateKey:()=>{const y=ug(e.n);return D_(e.randomBytes(y),e.n)},precompute(y=8,b=d.BASE){return b._setWindowSize(y),b.multiply(BigInt(3)),b}};function A(y,b=!0){return d.fromPrivateKey(y).toRawBytes(b)}function _(y){if(typeof y=="bigint")return!1;if(y instanceof d)return!0;const S=ws("key",y).length,R=s.BYTES,C=R+1,O=2*R+1;if(!(e.allowedPrivateKeyLengths||r===C))return S===C||S===O}function P(y,b,S=!0){if(_(y)===!0)throw new Error("first arg must be private key");if(_(b)===!1)throw new Error("second arg must be public key");return d.fromHex(b).multiply(u(y)).toRawBytes(S)}const D=e.bits2int||function(y){if(y.length>8192)throw new Error("input is too large");const b=Cr(y),S=y.length*8-i;return S>0?b>>BigInt(S):b},L=e.bits2int_modN||function(y){return c(D(y))},W=sc(i);function k(y){return ti("num < 2^"+i,y,mn,W),No(y,r)}function q(y,b,S=z){if(["recovered","canonical"].some(ye=>ye in S))throw new Error("sign() legacy options not supported");const{hash:R,randomBytes:C}=e;let{lowS:O,prehash:B,extraEntropy:M}=S;O==null&&(O=!0),y=ws("msgHash",y),oh(S),B&&(y=ws("prehashed msgHash",R(y)));const ce=L(y),j=u(b),J=[k(j),k(ce)];if(M!=null&&M!==!1){const ye=M===!0?C(s.BYTES):M;J.push(ws("extraEntropy",ye))}const he=La(...J),ge=ce;function xe(ye){const ve=D(ye);if(!p(ve))return;const ze=l(ve),st=d.BASE.multiply(ve).toAffine(),ut=c(st.x);if(ut===mn)return;const wt=c(ze*c(ge+ut*j));if(wt===mn)return;let Ms=(st.x===ut?0:2)|Number(st.y>),tn=wt;return O&&g(wt)&&(tn=f(wt),Ms^=1),new v(ut,tn,Ms)}return{seed:he,k2sig:xe}}const z={lowS:e.lowS,prehash:!1},x={lowS:e.lowS,prehash:!1};function I(y,b,S=z){const{seed:R,k2sig:C}=q(y,b,S),O=e;return HC(O.hash.outputLen,O.nByteLength,O.hmac)(R,C)}d.BASE._setWindowSize(8);function T(y,b,S,R=x){var Ms;const C=y;b=ws("msgHash",b),S=ws("publicKey",S);const{lowS:O,prehash:B,format:M}=R;if(oh(R),"strict"in R)throw new Error("options.strict was renamed to lowS");if(M!==void 0&&M!=="compact"&&M!=="der")throw new Error("format must be compact or der");const ce=typeof C=="string"||Io(C),j=!ce&&!M&&typeof C=="object"&&C!==null&&typeof C.r=="bigint"&&typeof C.s=="bigint";if(!ce&&!j)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let J,he;try{if(j&&(J=new v(C.r,C.s)),ce){try{M!=="compact"&&(J=v.fromDER(C))}catch(tn){if(!(tn instanceof pn.Err))throw tn}!J&&M!=="der"&&(J=v.fromCompact(C))}he=d.fromHex(S)}catch{return!1}if(!J||O&&J.hasHighS())return!1;B&&(b=e.hash(b));const{r:ge,s:xe}=J,ye=L(b),ve=l(xe),ze=c(ye*ve),st=c(ge*ve),ut=(Ms=d.BASE.multiplyAndAddUnsafe(he,ze,st))==null?void 0:Ms.toAffine();return ut?c(ut.x)===ge:!1}return{CURVE:e,getPublicKey:A,getSharedSecret:P,sign:I,verify:T,ProjectivePoint:d,Signature:v,utils:N}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function K_(t){return{hash:t,hmac:(e,...s)=>Cy(t,e,_y(...s)),randomBytes:vy}}function G_(t,e){const s=n=>z_({...t,...K_(n)});return{...s(e),create:s}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const gg=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),ah=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Y_=BigInt(0),Z_=BigInt(1),Ul=BigInt(2),ch=(t,e)=>(t+e/Ul)/e;function J_(t){const e=gg,s=BigInt(3),n=BigInt(6),r=BigInt(11),i=BigInt(22),o=BigInt(23),a=BigInt(44),c=BigInt(88),l=t*t*t%e,d=l*l*t%e,u=hs(d,s,e)*d%e,h=hs(u,s,e)*d%e,p=hs(h,Ul,e)*l%e,g=hs(p,r,e)*p%e,f=hs(g,i,e)*g%e,w=hs(f,a,e)*f%e,v=hs(w,c,e)*w%e,N=hs(v,a,e)*f%e,A=hs(N,s,e)*d%e,_=hs(A,o,e)*g%e,P=hs(_,n,e)*l%e,D=hs(P,Ul,e);if(!$l.eql($l.sqr(D),t))throw new Error("Cannot find square root");return D}const $l=Rd(gg,void 0,void 0,{sqrt:J_}),X_=G_({a:Y_,b:BigInt(7),Fp:$l,n:ah,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{const e=ah,s=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-Z_*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),r=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=s,o=BigInt("0x100000000000000000000000000000000"),a=ch(i*t,e),c=ch(-n*t,e);let l=Gt(t-a*s-c*r,e),d=Gt(-a*n-c*i,e);const u=l>o,h=d>o;if(u&&(l=e-l),h&&(d=e-d),l>o||d>o)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:u,k1:l,k2neg:h,k2:d}}}},Ay);function Q_(t){if(t.length!==130&&t.length!==132)throw new t0({signature:t});const e=BigInt(un(t,0,32)),s=BigInt(un(t,32,64)),n=(()=>{const r=+`0x${t.slice(130)}`;if(!Number.isNaN(r))try{return e0(r)}catch{throw new s0({value:r})}})();return typeof n>"u"?{r:e,s}:{r:e,s,yParity:n}}function e0(t){if(t===0||t===27)return 0;if(t===1||t===28)return 1;if(t>=35)return t%2===0?1:0;throw new n0({value:t})}class t0 extends Je{constructor({signature:e}){super(`Value \`${e}\` is an invalid signature size.`,{metaMessages:["Expected: 64 bytes or 65 bytes.",`Received ${Xn(Td(e))} bytes.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidSerializedSizeError"})}}class s0 extends Je{constructor({value:e}){super(`Value \`${e}\` is an invalid y-parity value. Y-parity must be 0 or 1.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidYParityError"})}}class n0 extends Je{constructor({value:e}){super(`Value \`${e}\` is an invalid v value. v must be 27, 28 or >=35.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidVError"})}}function r0(t){return I_(i0(t))}function i0(t){const{payload:e,signature:s}=t,{r:n,s:r,yParity:i}=s,a=new X_.Signature(BigInt(n),BigInt(r)).addRecoveryBit(i).recoverPublicKey(Td(e).substring(2));return y_(a)}var o0={};const a0=":";function bn(t){const[e,s]=t.split(a0);return{namespace:e,reference:s}}function mg(t,e){return t.includes(":")?[t]:e.chains||[]}var c0=Object.defineProperty,l0=Object.defineProperties,d0=Object.getOwnPropertyDescriptors,lh=Object.getOwnPropertySymbols,u0=Object.prototype.hasOwnProperty,h0=Object.prototype.propertyIsEnumerable,Dl=(t,e,s)=>e in t?c0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,dh=(t,e)=>{for(var s in e||(e={}))u0.call(e,s)&&Dl(t,s,e[s]);if(lh)for(var s of lh(e))h0.call(e,s)&&Dl(t,s,e[s]);return t},p0=(t,e)=>l0(t,d0(e)),uh=(t,e,s)=>Dl(t,typeof e!="symbol"?e+"":e,s);const f0="ReactNative",us={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},g0="js";function Ba(){return typeof wn<"u"&&typeof wn.versions<"u"&&typeof wn.versions.node<"u"}function er(){return!_n.getDocument()&&!!_n.getNavigator()&&navigator.product===f0}function m0(){return er()&&typeof Ce<"u"&&typeof(Ce==null?void 0:Ce.Platform)<"u"&&(Ce==null?void 0:Ce.Platform.OS)==="android"}function y0(){return er()&&typeof Ce<"u"&&typeof(Ce==null?void 0:Ce.Platform)<"u"&&(Ce==null?void 0:Ce.Platform.OS)==="ios"}function yi(){return!Ba()&&!!_n.getNavigator()&&!!_n.getDocument()}function To(){return er()?us.reactNative:Ba()?us.node:yi()?us.browser:us.unknown}function hh(){var t;try{return er()&&typeof Ce<"u"&&typeof(Ce==null?void 0:Ce.Application)<"u"?(t=Ce.Application)==null?void 0:t.applicationId:void 0}catch{return}}function w0(t,e){const s=new URLSearchParams(t);return Object.entries(e).sort(([n],[r])=>n.localeCompare(r)).forEach(([n,r])=>{r!=null&&s.set(n,String(r))}),s.toString()}function E0(t){var e,s;const n=yg();try{return t!=null&&t.url&&n.url&&new URL(t.url).host!==new URL(n.url).host&&(console.warn(`The configured WalletConnect 'metadata.url':${t.url} differs from the actual page url:${n.url}. This is probably unintended and can lead to issues.`),t.url=n.url),(e=t==null?void 0:t.icons)!=null&&e.length&&t.icons.length>0&&(t.icons=t.icons.filter(r=>r!=="")),p0(dh(dh({},n),t),{url:(t==null?void 0:t.url)||n.url,name:(t==null?void 0:t.name)||n.name,description:(t==null?void 0:t.description)||n.description,icons:(s=t==null?void 0:t.icons)!=null&&s.length&&t.icons.length>0?t.icons:n.icons})}catch(r){return console.warn("Error populating app metadata",r),t||n}}function yg(){return Py.getWindowMetadata()||{name:"",description:"",url:"",icons:[""]}}function b0(){if(To()===us.reactNative&&typeof Ce<"u"&&typeof(Ce==null?void 0:Ce.Platform)<"u"){const{OS:s,Version:n}=Ce.Platform;return[s,n].join("-")}const t=ky();if(t===null)return"unknown";const e=t.os?t.os.replace(" ","").toLowerCase():"unknown";return t.type==="browser"?[e,t.name,t.version].join("-"):[e,t.version].join("-")}function v0(){var t;const e=To();return e===us.browser?[e,((t=_n.getLocation())==null?void 0:t.host)||"unknown"].join(":"):e}function wg(t,e,s){const n=b0(),r=v0();return[[t,e].join("-"),[g0,s].join("-"),n,r].join("/")}function C0({protocol:t,version:e,relayUrl:s,sdkVersion:n,auth:r,projectId:i,useOnCloseEvent:o,bundleId:a,packageName:c}){const l=s.split("?"),d=wg(t,e,n),u={auth:r,ua:d,projectId:i,useOnCloseEvent:o,packageName:c||void 0,bundleId:a||void 0},h=w0(l[1]||"",u);return l[0]+"?"+h}function gr(t,e){return t.filter(s=>e.includes(s)).length===t.length}function Ll(t){return Object.fromEntries(t.entries())}function Ml(t){return new Map(Object.entries(t))}function lr(t=Z.FIVE_MINUTES,e){const s=Z.toMiliseconds(t||Z.FIVE_MINUTES);let n,r,i,o;return{resolve:a=>{i&&n&&(clearTimeout(i),n(a),o=Promise.resolve(a))},reject:a=>{i&&r&&(clearTimeout(i),r(a))},done:()=>new Promise((a,c)=>{if(o)return a(o);i=setTimeout(()=>{const l=new Error(e);o=Promise.reject(l),c(l)},s),n=a,r=c})}}function Ks(t,e,s){return new Promise(async(n,r)=>{const i=setTimeout(()=>r(new Error(s)),e);try{const o=await t;n(o)}catch(o){r(o)}clearTimeout(i)})}function Eg(t,e){if(typeof e=="string"&&e.startsWith(`${t}:`))return e;if(t.toLowerCase()==="topic"){if(typeof e!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${e}`}else if(t.toLowerCase()==="id"){if(typeof e!="number")throw new Error('Value must be "number" for expirer target type: id');return`id:${e}`}throw new Error(`Unknown expirer target type: ${t}`)}function _0(t){return Eg("topic",t)}function A0(t){return Eg("id",t)}function bg(t){const[e,s]=t.split(":"),n={id:void 0,topic:void 0};if(e==="topic"&&typeof s=="string")n.topic=s;else if(e==="id"&&Number.isInteger(Number(s)))n.id=Number(s);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${s}`);return n}function rt(t,e){return Z.fromMiliseconds(Date.now()+Z.toMiliseconds(t))}function Vs(t){return Date.now()>=Z.toMiliseconds(t)}function Fe(t,e){return`${t}${e?`:${e}`:""}`}function Zs(t=[],e=[]){return[...new Set([...t,...e])]}async function S0({id:t,topic:e,wcDeepLink:s}){var n;try{if(!s)return;const r=typeof s=="string"?JSON.parse(s):s,i=r==null?void 0:r.href;if(typeof i!="string")return;const o=I0(i,t,e),a=To();if(a===us.browser){if(!((n=_n.getDocument())!=null&&n.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}N0(o)}else a===us.reactNative&&typeof(Ce==null?void 0:Ce.Linking)<"u"&&await Ce.Linking.openURL(o)}catch(r){console.error(r)}}function I0(t,e,s){const n=`requestId=${e}&sessionTopic=${s}`;t.endsWith("/")&&(t=t.slice(0,-1));let r=`${t}`;if(t.startsWith("https://t.me")){const i=t.includes("?")?"&startapp=":"?startapp=";r=`${r}${i}${P0(n,!0)}`}else r=`${r}/wc?${n}`;return r}function N0(t){let e="_self";O0()?e="_top":(R0()||t.startsWith("https://")||t.startsWith("http://"))&&(e="_blank"),window.open(t,e,"noreferrer noopener")}async function T0(t,e){let s="";try{if(yi()&&(s=localStorage.getItem(e),s))return s;s=await t.getItem(e)}catch(n){console.error(n)}return s}function ph(t,e){if(!t.includes(e))return null;const s=t.split(/([&,?,=])/),n=s.indexOf(e);return s[n+2]}function fh(){return typeof crypto<"u"&&crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,t=>{const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})}function Od(){return typeof wn<"u"&&o0.IS_VITEST==="true"}function R0(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function O0(){try{return window.self!==window.top}catch{return!1}}function P0(t,e=!1){const s=Pe.from(t).toString("base64");return e?s.replace(/[=]/g,""):s}function vg(t){return Pe.from(t,"base64").toString("utf-8")}function x0(t){return new Promise(e=>setTimeout(e,t))}let k0=class{constructor({limit:e}){uh(this,"limit"),uh(this,"set"),this.limit=e,this.set=new Set}add(e){if(!this.set.has(e)){if(this.set.size>=this.limit){const s=this.set.values().next().value;s&&this.set.delete(s)}this.set.add(e)}}has(e){return this.set.has(e)}};const Zo=BigInt(2**32-1),gh=BigInt(32);function Cg(t,e=!1){return e?{h:Number(t&Zo),l:Number(t>>gh&Zo)}:{h:Number(t>>gh&Zo)|0,l:Number(t&Zo)|0}}function _g(t,e=!1){const s=t.length;let n=new Uint32Array(s),r=new Uint32Array(s);for(let i=0;i<s;i++){const{h:o,l:a}=Cg(t[i],e);[n[i],r[i]]=[o,a]}return[n,r]}const mh=(t,e,s)=>t>>>s,yh=(t,e,s)=>t<<32-s|e>>>s,$n=(t,e,s)=>t>>>s|e<<32-s,Dn=(t,e,s)=>t<<32-s|e>>>s,Ui=(t,e,s)=>t<<64-s|e>>>s-32,$i=(t,e,s)=>t>>>s-32|e<<64-s,U0=(t,e)=>e,$0=(t,e)=>t,D0=(t,e,s)=>t<<s|e>>>32-s,L0=(t,e,s)=>e<<s|t>>>32-s,M0=(t,e,s)=>e<<s-32|t>>>64-s,B0=(t,e,s)=>t<<s-32|e>>>64-s;function Rs(t,e,s,n){const r=(e>>>0)+(n>>>0);return{h:t+s+(r/2**32|0)|0,l:r|0}}const Pd=(t,e,s)=>(t>>>0)+(e>>>0)+(s>>>0),xd=(t,e,s,n)=>e+s+n+(t/2**32|0)|0,j0=(t,e,s,n)=>(t>>>0)+(e>>>0)+(s>>>0)+(n>>>0),F0=(t,e,s,n,r)=>e+s+n+r+(t/2**32|0)|0,q0=(t,e,s,n,r)=>(t>>>0)+(e>>>0)+(s>>>0)+(n>>>0)+(r>>>0),W0=(t,e,s,n,r,i)=>e+s+n+r+i+(t/2**32|0)|0,jr=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function rc(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Sn(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function Ls(t,...e){if(!rc(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function ic(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");Sn(t.outputLen),Sn(t.blockLen)}function Qn(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function kd(t,e){Ls(t);const s=e.outputLen;if(t.length<s)throw new Error("digestInto() expects output buffer of length at least "+s)}function go(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function _s(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function Mc(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function Bs(t,e){return t<<32-e|t>>>e}const Ag=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Sg(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}const cn=Ag?t=>t:t=>Sg(t);function H0(t){for(let e=0;e<t.length;e++)t[e]=Sg(t[e]);return t}const Ln=Ag?t=>t:H0,Ig=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",V0=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function si(t){if(Ls(t),Ig)return t.toHex();let e="";for(let s=0;s<t.length;s++)e+=V0[t[s]];return e}const on={_0:48,_9:57,A:65,F:70,a:97,f:102};function wh(t){if(t>=on._0&&t<=on._9)return t-on._0;if(t>=on.A&&t<=on.F)return t-(on.A-10);if(t>=on.a&&t<=on.f)return t-(on.a-10)}function ja(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);if(Ig)return Uint8Array.fromHex(t);const e=t.length,s=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const n=new Uint8Array(s);for(let r=0,i=0;r<s;r++,i+=2){const o=wh(t.charCodeAt(i)),a=wh(t.charCodeAt(i+1));if(o===void 0||a===void 0){const c=t[i]+t[i+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+i)}n[r]=o*16+a}return n}function Ng(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function $s(t){return typeof t=="string"&&(t=Ng(t)),Ls(t),t}function jn(...t){let e=0;for(let n=0;n<t.length;n++){const r=t[n];Ls(r),e+=r.length}const s=new Uint8Array(e);for(let n=0,r=0;n<t.length;n++){const i=t[n];s.set(i,r),r+=i.length}return s}let oc=class{};function Ro(t){const e=n=>t().update($s(n)).digest(),s=t();return e.outputLen=s.outputLen,e.blockLen=s.blockLen,e.create=()=>t(),e}function z0(t){const e=(n,r)=>t(r).update($s(n)).digest(),s=t({});return e.outputLen=s.outputLen,e.blockLen=s.blockLen,e.create=n=>t(n),e}function Dr(t=32){if(jr&&typeof jr.getRandomValues=="function")return jr.getRandomValues(new Uint8Array(t));if(jr&&typeof jr.randomBytes=="function")return Uint8Array.from(jr.randomBytes(t));throw new Error("crypto.getRandomValues must be defined")}const K0=BigInt(0),_i=BigInt(1),G0=BigInt(2),Y0=BigInt(7),Z0=BigInt(256),J0=BigInt(113),Tg=[],Rg=[],Og=[];for(let t=0,e=_i,s=1,n=0;t<24;t++){[s,n]=[n,(2*s+3*n)%5],Tg.push(2*(5*n+s)),Rg.push((t+1)*(t+2)/2%64);let r=K0;for(let i=0;i<7;i++)e=(e<<_i^(e>>Y0)*J0)%Z0,e&G0&&(r^=_i<<(_i<<BigInt(i))-_i);Og.push(r)}const Pg=_g(Og,!0),X0=Pg[0],Q0=Pg[1],Eh=(t,e,s)=>s>32?M0(t,e,s):D0(t,e,s),bh=(t,e,s)=>s>32?B0(t,e,s):L0(t,e,s);function eA(t,e=24){const s=new Uint32Array(10);for(let n=24-e;n<24;n++){for(let o=0;o<10;o++)s[o]=t[o]^t[o+10]^t[o+20]^t[o+30]^t[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,l=s[c],d=s[c+1],u=Eh(l,d,1)^s[a],h=bh(l,d,1)^s[a+1];for(let p=0;p<50;p+=10)t[o+p]^=u,t[o+p+1]^=h}let r=t[2],i=t[3];for(let o=0;o<24;o++){const a=Rg[o],c=Eh(r,i,a),l=bh(r,i,a),d=Tg[o];r=t[d],i=t[d+1],t[d]=c,t[d+1]=l}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)s[a]=t[o+a];for(let a=0;a<10;a++)t[o+a]^=~s[(a+2)%10]&s[(a+4)%10]}t[0]^=X0[n],t[1]^=Q0[n]}_s(s)}let tA=class xg extends oc{constructor(e,s,n,r=!1,i=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=e,this.suffix=s,this.outputLen=n,this.enableXOF=r,this.rounds=i,Sn(n),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=go(this.state)}clone(){return this._cloneInto()}keccak(){Ln(this.state32),eA(this.state32,this.rounds),Ln(this.state32),this.posOut=0,this.pos=0}update(e){Qn(this),e=$s(e),Ls(e);const{blockLen:s,state:n}=this,r=e.length;for(let i=0;i<r;){const o=Math.min(s-this.pos,r-i);for(let a=0;a<o;a++)n[this.pos++]^=e[i++];this.pos===s&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:s,pos:n,blockLen:r}=this;e[n]^=s,(s&128)!==0&&n===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){Qn(this,!1),Ls(e),this.finish();const s=this.state,{blockLen:n}=this;for(let r=0,i=e.length;r<i;){this.posOut>=n&&this.keccak();const o=Math.min(n-this.posOut,i-r);e.set(s.subarray(this.posOut,this.posOut+o),r),this.posOut+=o,r+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Sn(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(kd(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,_s(this.state)}_cloneInto(e){const{blockLen:s,suffix:n,outputLen:r,rounds:i,enableXOF:o}=this;return e||(e=new xg(s,n,r,o,i)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=i,e.suffix=n,e.outputLen=r,e.enableXOF=o,e.destroyed=this.destroyed,e}};const sA=(t,e,s)=>Ro(()=>new tA(e,t,s)),nA=sA(1,136,256/8);function rA(t,e,s,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,s,n);const r=BigInt(32),i=BigInt(4294967295),o=Number(s>>r&i),a=Number(s&i),c=n?4:0,l=n?0:4;t.setUint32(e+c,o,n),t.setUint32(e+l,a,n)}function iA(t,e,s){return t&e^~t&s}function oA(t,e,s){return t&e^t&s^e&s}let kg=class extends oc{constructor(e,s,n,r){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=s,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(e),this.view=Mc(this.buffer)}update(e){Qn(this),e=$s(e),Ls(e);const{view:s,buffer:n,blockLen:r}=this,i=e.length;for(let o=0;o<i;){const a=Math.min(r-this.pos,i-o);if(a===r){const c=Mc(e);for(;r<=i-o;o+=r)this.process(c,o);continue}n.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===r&&(this.process(s,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Qn(this),kd(e,this),this.finished=!0;const{buffer:s,view:n,blockLen:r,isLE:i}=this;let{pos:o}=this;s[o++]=128,_s(this.buffer.subarray(o)),this.padOffset>r-o&&(this.process(n,0),o=0);for(let u=o;u<r;u++)s[u]=0;rA(n,r-8,BigInt(this.length*8),i),this.process(n,0);const a=Mc(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=c/4,d=this.get();if(l>d.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<l;u++)a.setUint32(4*u,d[u],i)}digest(){const{buffer:e,outputLen:s}=this;this.digestInto(e);const n=e.slice(0,s);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:s,buffer:n,length:r,finished:i,destroyed:o,pos:a}=this;return e.destroyed=o,e.finished=i,e.length=r,e.pos=a,r%s&&e.buffer.set(n),e}clone(){return this._cloneInto()}};const Rn=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),It=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),Nt=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),aA=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),On=new Uint32Array(64);class cA extends kg{constructor(e=32){super(64,e,8,!1),this.A=Rn[0]|0,this.B=Rn[1]|0,this.C=Rn[2]|0,this.D=Rn[3]|0,this.E=Rn[4]|0,this.F=Rn[5]|0,this.G=Rn[6]|0,this.H=Rn[7]|0}get(){const{A:e,B:s,C:n,D:r,E:i,F:o,G:a,H:c}=this;return[e,s,n,r,i,o,a,c]}set(e,s,n,r,i,o,a,c){this.A=e|0,this.B=s|0,this.C=n|0,this.D=r|0,this.E=i|0,this.F=o|0,this.G=a|0,this.H=c|0}process(e,s){for(let u=0;u<16;u++,s+=4)On[u]=e.getUint32(s,!1);for(let u=16;u<64;u++){const h=On[u-15],p=On[u-2],g=Bs(h,7)^Bs(h,18)^h>>>3,f=Bs(p,17)^Bs(p,19)^p>>>10;On[u]=f+On[u-7]+g+On[u-16]|0}let{A:n,B:r,C:i,D:o,E:a,F:c,G:l,H:d}=this;for(let u=0;u<64;u++){const h=Bs(a,6)^Bs(a,11)^Bs(a,25),p=d+h+iA(a,c,l)+aA[u]+On[u]|0,g=(Bs(n,2)^Bs(n,13)^Bs(n,22))+oA(n,r,i)|0;d=l,l=c,c=a,a=o+p|0,o=i,i=r,r=n,n=p+g|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,o=o+this.D|0,a=a+this.E|0,c=c+this.F|0,l=l+this.G|0,d=d+this.H|0,this.set(n,r,i,o,a,c,l,d)}roundClean(){_s(On)}destroy(){this.set(0,0,0,0,0,0,0,0),_s(this.buffer)}}const Ug=_g(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),lA=Ug[0],dA=Ug[1],Pn=new Uint32Array(80),xn=new Uint32Array(80);let Ud=class extends kg{constructor(e=64){super(128,e,16,!1),this.Ah=Nt[0]|0,this.Al=Nt[1]|0,this.Bh=Nt[2]|0,this.Bl=Nt[3]|0,this.Ch=Nt[4]|0,this.Cl=Nt[5]|0,this.Dh=Nt[6]|0,this.Dl=Nt[7]|0,this.Eh=Nt[8]|0,this.El=Nt[9]|0,this.Fh=Nt[10]|0,this.Fl=Nt[11]|0,this.Gh=Nt[12]|0,this.Gl=Nt[13]|0,this.Hh=Nt[14]|0,this.Hl=Nt[15]|0}get(){const{Ah:e,Al:s,Bh:n,Bl:r,Ch:i,Cl:o,Dh:a,Dl:c,Eh:l,El:d,Fh:u,Fl:h,Gh:p,Gl:g,Hh:f,Hl:w}=this;return[e,s,n,r,i,o,a,c,l,d,u,h,p,g,f,w]}set(e,s,n,r,i,o,a,c,l,d,u,h,p,g,f,w){this.Ah=e|0,this.Al=s|0,this.Bh=n|0,this.Bl=r|0,this.Ch=i|0,this.Cl=o|0,this.Dh=a|0,this.Dl=c|0,this.Eh=l|0,this.El=d|0,this.Fh=u|0,this.Fl=h|0,this.Gh=p|0,this.Gl=g|0,this.Hh=f|0,this.Hl=w|0}process(e,s){for(let A=0;A<16;A++,s+=4)Pn[A]=e.getUint32(s),xn[A]=e.getUint32(s+=4);for(let A=16;A<80;A++){const _=Pn[A-15]|0,P=xn[A-15]|0,D=$n(_,P,1)^$n(_,P,8)^mh(_,P,7),L=Dn(_,P,1)^Dn(_,P,8)^yh(_,P,7),W=Pn[A-2]|0,k=xn[A-2]|0,q=$n(W,k,19)^Ui(W,k,61)^mh(W,k,6),z=Dn(W,k,19)^$i(W,k,61)^yh(W,k,6),x=j0(L,z,xn[A-7],xn[A-16]),I=F0(x,D,q,Pn[A-7],Pn[A-16]);Pn[A]=I|0,xn[A]=x|0}let{Ah:n,Al:r,Bh:i,Bl:o,Ch:a,Cl:c,Dh:l,Dl:d,Eh:u,El:h,Fh:p,Fl:g,Gh:f,Gl:w,Hh:v,Hl:N}=this;for(let A=0;A<80;A++){const _=$n(u,h,14)^$n(u,h,18)^Ui(u,h,41),P=Dn(u,h,14)^Dn(u,h,18)^$i(u,h,41),D=u&p^~u&f,L=h&g^~h&w,W=q0(N,P,L,dA[A],xn[A]),k=W0(W,v,_,D,lA[A],Pn[A]),q=W|0,z=$n(n,r,28)^Ui(n,r,34)^Ui(n,r,39),x=Dn(n,r,28)^$i(n,r,34)^$i(n,r,39),I=n&i^n&a^i&a,T=r&o^r&c^o&c;v=f|0,N=w|0,f=p|0,w=g|0,p=u|0,g=h|0,{h:u,l:h}=Rs(l|0,d|0,k|0,q|0),l=a|0,d=c|0,a=i|0,c=o|0,i=n|0,o=r|0;const y=Pd(q,x,T);n=xd(y,k,z,I),r=y|0}({h:n,l:r}=Rs(this.Ah|0,this.Al|0,n|0,r|0)),{h:i,l:o}=Rs(this.Bh|0,this.Bl|0,i|0,o|0),{h:a,l:c}=Rs(this.Ch|0,this.Cl|0,a|0,c|0),{h:l,l:d}=Rs(this.Dh|0,this.Dl|0,l|0,d|0),{h:u,l:h}=Rs(this.Eh|0,this.El|0,u|0,h|0),{h:p,l:g}=Rs(this.Fh|0,this.Fl|0,p|0,g|0),{h:f,l:w}=Rs(this.Gh|0,this.Gl|0,f|0,w|0),{h:v,l:N}=Rs(this.Hh|0,this.Hl|0,v|0,N|0),this.set(n,r,i,o,a,c,l,d,u,h,p,g,f,w,v,N)}roundClean(){_s(Pn,xn)}destroy(){_s(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};class uA extends Ud{constructor(){super(48),this.Ah=It[0]|0,this.Al=It[1]|0,this.Bh=It[2]|0,this.Bl=It[3]|0,this.Ch=It[4]|0,this.Cl=It[5]|0,this.Dh=It[6]|0,this.Dl=It[7]|0,this.Eh=It[8]|0,this.El=It[9]|0,this.Fh=It[10]|0,this.Fl=It[11]|0,this.Gh=It[12]|0,this.Gl=It[13]|0,this.Hh=It[14]|0,this.Hl=It[15]|0}}const Tt=Uint32Array.from([573645204,4230739756,2673172387,3360449730,596883563,1867755857,2520282905,1497426621,2519219938,2827943907,3193839141,1401305490,721525244,746961066,246885852,2177182882]);class hA extends Ud{constructor(){super(32),this.Ah=Tt[0]|0,this.Al=Tt[1]|0,this.Bh=Tt[2]|0,this.Bl=Tt[3]|0,this.Ch=Tt[4]|0,this.Cl=Tt[5]|0,this.Dh=Tt[6]|0,this.Dl=Tt[7]|0,this.Eh=Tt[8]|0,this.El=Tt[9]|0,this.Fh=Tt[10]|0,this.Fl=Tt[11]|0,this.Gh=Tt[12]|0,this.Gl=Tt[13]|0,this.Hh=Tt[14]|0,this.Hl=Tt[15]|0}}const ac=Ro(()=>new cA),pA=Ro(()=>new Ud),fA=Ro(()=>new uA),gA=Ro(()=>new hA),mA=Uint8Array.from([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9]),ct=Uint32Array.from([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),ee=new Uint32Array(32);function kn(t,e,s,n,r,i){const o=r[i],a=r[i+1];let c=ee[2*t],l=ee[2*t+1],d=ee[2*e],u=ee[2*e+1],h=ee[2*s],p=ee[2*s+1],g=ee[2*n],f=ee[2*n+1],w=Pd(c,d,o);l=xd(w,l,u,a),c=w|0,{Dh:f,Dl:g}={Dh:f^l,Dl:g^c},{Dh:f,Dl:g}={Dh:U0(f,g),Dl:$0(f)},{h:p,l:h}=Rs(p,h,f,g),{Bh:u,Bl:d}={Bh:u^p,Bl:d^h},{Bh:u,Bl:d}={Bh:$n(u,d,24),Bl:Dn(u,d,24)},ee[2*t]=c,ee[2*t+1]=l,ee[2*e]=d,ee[2*e+1]=u,ee[2*s]=h,ee[2*s+1]=p,ee[2*n]=g,ee[2*n+1]=f}function Un(t,e,s,n,r,i){const o=r[i],a=r[i+1];let c=ee[2*t],l=ee[2*t+1],d=ee[2*e],u=ee[2*e+1],h=ee[2*s],p=ee[2*s+1],g=ee[2*n],f=ee[2*n+1],w=Pd(c,d,o);l=xd(w,l,u,a),c=w|0,{Dh:f,Dl:g}={Dh:f^l,Dl:g^c},{Dh:f,Dl:g}={Dh:$n(f,g,16),Dl:Dn(f,g,16)},{h:p,l:h}=Rs(p,h,f,g),{Bh:u,Bl:d}={Bh:u^p,Bl:d^h},{Bh:u,Bl:d}={Bh:Ui(u,d,63),Bl:$i(u,d,63)},ee[2*t]=c,ee[2*t+1]=l,ee[2*e]=d,ee[2*e+1]=u,ee[2*s]=h,ee[2*s+1]=p,ee[2*n]=g,ee[2*n+1]=f}function yA(t,e={},s,n,r){if(Sn(s),t<0||t>s)throw new Error("outputLen bigger than keyLen");const{key:i,salt:o,personalization:a}=e;if(i!==void 0&&(i.length<1||i.length>s))throw new Error("key length must be undefined or 1.."+s);if(o!==void 0&&o.length!==n)throw new Error("salt must be undefined or "+n);if(a!==void 0&&a.length!==r)throw new Error("personalization must be undefined or "+r)}class wA extends oc{constructor(e,s){super(),this.finished=!1,this.destroyed=!1,this.length=0,this.pos=0,Sn(e),Sn(s),this.blockLen=e,this.outputLen=s,this.buffer=new Uint8Array(e),this.buffer32=go(this.buffer)}update(e){Qn(this),e=$s(e),Ls(e);const{blockLen:s,buffer:n,buffer32:r}=this,i=e.length,o=e.byteOffset,a=e.buffer;for(let c=0;c<i;){this.pos===s&&(Ln(r),this.compress(r,0,!1),Ln(r),this.pos=0);const l=Math.min(s-this.pos,i-c),d=o+c;if(l===s&&!(d%4)&&c+l<i){const u=new Uint32Array(a,d,Math.floor((i-c)/4));Ln(u);for(let h=0;c+s<i;h+=r.length,c+=s)this.length+=s,this.compress(u,h,!1);Ln(u);continue}n.set(e.subarray(c,c+l),this.pos),this.pos+=l,this.length+=l,c+=l}return this}digestInto(e){Qn(this),kd(e,this);const{pos:s,buffer32:n}=this;this.finished=!0,_s(this.buffer.subarray(s)),Ln(n),this.compress(n,0,!0),Ln(n);const r=go(e);this.get().forEach((i,o)=>r[o]=cn(i))}digest(){const{buffer:e,outputLen:s}=this;this.digestInto(e);const n=e.slice(0,s);return this.destroy(),n}_cloneInto(e){const{buffer:s,length:n,finished:r,destroyed:i,outputLen:o,pos:a}=this;return e||(e=new this.constructor({dkLen:o})),e.set(...this.get()),e.buffer.set(s),e.destroyed=i,e.finished=r,e.length=n,e.pos=a,e.outputLen=o,e}clone(){return this._cloneInto()}}class EA extends wA{constructor(e={}){const s=e.dkLen===void 0?64:e.dkLen;super(128,s),this.v0l=ct[0]|0,this.v0h=ct[1]|0,this.v1l=ct[2]|0,this.v1h=ct[3]|0,this.v2l=ct[4]|0,this.v2h=ct[5]|0,this.v3l=ct[6]|0,this.v3h=ct[7]|0,this.v4l=ct[8]|0,this.v4h=ct[9]|0,this.v5l=ct[10]|0,this.v5h=ct[11]|0,this.v6l=ct[12]|0,this.v6h=ct[13]|0,this.v7l=ct[14]|0,this.v7h=ct[15]|0,yA(s,e,64,16,16);let{key:n,personalization:r,salt:i}=e,o=0;if(n!==void 0&&(n=$s(n),o=n.length),this.v0l^=this.outputLen|o<<8|65536|1<<24,i!==void 0){i=$s(i);const a=go(i);this.v4l^=cn(a[0]),this.v4h^=cn(a[1]),this.v5l^=cn(a[2]),this.v5h^=cn(a[3])}if(r!==void 0){r=$s(r);const a=go(r);this.v6l^=cn(a[0]),this.v6h^=cn(a[1]),this.v7l^=cn(a[2]),this.v7h^=cn(a[3])}if(n!==void 0){const a=new Uint8Array(this.blockLen);a.set(n),this.update(a)}}get(){let{v0l:e,v0h:s,v1l:n,v1h:r,v2l:i,v2h:o,v3l:a,v3h:c,v4l:l,v4h:d,v5l:u,v5h:h,v6l:p,v6h:g,v7l:f,v7h:w}=this;return[e,s,n,r,i,o,a,c,l,d,u,h,p,g,f,w]}set(e,s,n,r,i,o,a,c,l,d,u,h,p,g,f,w){this.v0l=e|0,this.v0h=s|0,this.v1l=n|0,this.v1h=r|0,this.v2l=i|0,this.v2h=o|0,this.v3l=a|0,this.v3h=c|0,this.v4l=l|0,this.v4h=d|0,this.v5l=u|0,this.v5h=h|0,this.v6l=p|0,this.v6h=g|0,this.v7l=f|0,this.v7h=w|0}compress(e,s,n){this.get().forEach((c,l)=>ee[l]=c),ee.set(ct,16);let{h:r,l:i}=Cg(BigInt(this.length));ee[24]=ct[8]^i,ee[25]=ct[9]^r,n&&(ee[28]=~ee[28],ee[29]=~ee[29]);let o=0;const a=mA;for(let c=0;c<12;c++)kn(0,4,8,12,e,s+2*a[o++]),Un(0,4,8,12,e,s+2*a[o++]),kn(1,5,9,13,e,s+2*a[o++]),Un(1,5,9,13,e,s+2*a[o++]),kn(2,6,10,14,e,s+2*a[o++]),Un(2,6,10,14,e,s+2*a[o++]),kn(3,7,11,15,e,s+2*a[o++]),Un(3,7,11,15,e,s+2*a[o++]),kn(0,5,10,15,e,s+2*a[o++]),Un(0,5,10,15,e,s+2*a[o++]),kn(1,6,11,12,e,s+2*a[o++]),Un(1,6,11,12,e,s+2*a[o++]),kn(2,7,8,13,e,s+2*a[o++]),Un(2,7,8,13,e,s+2*a[o++]),kn(3,4,9,14,e,s+2*a[o++]),Un(3,4,9,14,e,s+2*a[o++]);this.v0l^=ee[0]^ee[16],this.v0h^=ee[1]^ee[17],this.v1l^=ee[2]^ee[18],this.v1h^=ee[3]^ee[19],this.v2l^=ee[4]^ee[20],this.v2h^=ee[5]^ee[21],this.v3l^=ee[6]^ee[22],this.v3h^=ee[7]^ee[23],this.v4l^=ee[8]^ee[24],this.v4h^=ee[9]^ee[25],this.v5l^=ee[10]^ee[26],this.v5h^=ee[11]^ee[27],this.v6l^=ee[12]^ee[28],this.v6h^=ee[13]^ee[29],this.v7l^=ee[14]^ee[30],this.v7h^=ee[15]^ee[31],_s(ee)}destroy(){this.destroyed=!0,_s(this.buffer32),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const bA=z0(t=>new EA(t)),vA="https://rpc.walletconnect.org/v1";function $g(t){const e=`Ethereum Signed Message:
|
|
6
6
|
${t.length}`,s=new TextEncoder().encode(e+t);return"0x"+Pe.from(nA(s)).toString("hex")}async function CA(t,e,s,n,r,i){switch(s.t){case"eip191":return await _A(t,e,s.s);case"eip1271":return await AA(t,e,s.s,n,r,i);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${s.t}`)}}function _A(t,e,s){const n=Q_(s);return r0({payload:$g(e),signature:n}).toLowerCase()===t.toLowerCase()}async function AA(t,e,s,n,r,i){const o=bn(n);if(!o.namespace||!o.reference)throw new Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${n}`);try{const a="0x1626ba7e",c="0000000000000000000000000000000000000000000000000000000000000040",l=s.substring(2),d=(l.length/2).toString(16).padStart(64,"0"),u=(e.startsWith("0x")?e:$g(e)).substring(2),h=a+u+c+d+l,p=await fetch(`${i||vA}/?chainId=${n}&projectId=${r}`,{headers:{"Content-Type":"application/json"},method:"POST",body:JSON.stringify({id:SA(),jsonrpc:"2.0",method:"eth_call",params:[{to:t,data:h},"latest"]})}),{result:g}=await p.json();return g?g.slice(0,a.length).toLowerCase()===a.toLowerCase():!1}catch(a){return console.error("isValidEip1271Signature: ",a),!1}}function SA(){return Date.now()+Math.floor(Math.random()*1e3)}function IA(t){const e=atob(t),s=new Uint8Array(e.length);for(let o=0;o<e.length;o++)s[o]=e.charCodeAt(o);const n=s[0];if(n===0)throw new Error("No signatures found");const r=1+n*64;if(s.length<r)throw new Error("Transaction data too short for claimed signature count");if(s.length<100)throw new Error("Transaction too short");const i=Pe.from(t,"base64").slice(1,65);return gi.encode(i)}function NA(t){const e=new Uint8Array(Pe.from(t,"base64")),s=Array.from("TransactionData::").map(i=>i.charCodeAt(0)),n=new Uint8Array(s.length+e.length);n.set(s),n.set(e,s.length);const r=bA(n,{dkLen:32});return gi.encode(r)}function vh(t){const e=new Uint8Array(ac(TA(t)));return gi.encode(e)}function TA(t){if(t instanceof Uint8Array)return t;if(Array.isArray(t))return new Uint8Array(t);if(typeof t=="object"&&t!=null&&t.data)return new Uint8Array(Object.values(t.data));if(typeof t=="object"&&t)return new Uint8Array(Object.values(t));throw new Error("getNearUint8ArrayFromBytes: Unexpected result type from bytes array")}function Ch(t){const e=Pe.from(t,"base64"),s=Uy(e).txn;if(!s)throw new Error("Invalid signed transaction: missing 'txn' field");const n=$y(s),r=Pe.from("TX"),i=Pe.concat([r,Pe.from(n)]),o=gA(i);return hy.encode(o).replace(/=+$/,"")}function Bc(t){const e=[];let s=BigInt(t);for(;s>=BigInt(128);)e.push(Number(s&BigInt(127)|BigInt(128))),s>>=BigInt(7);return e.push(Number(s)),Pe.from(e)}function RA(t){const e=Pe.from(t.signed.bodyBytes,"base64"),s=Pe.from(t.signed.authInfoBytes,"base64"),n=Pe.from(t.signature.signature,"base64"),r=[];r.push(Pe.from([10])),r.push(Bc(e.length)),r.push(e),r.push(Pe.from([18])),r.push(Bc(s.length)),r.push(s),r.push(Pe.from([26])),r.push(Bc(n.length)),r.push(n);const i=Pe.concat(r),o=ac(i);return Pe.from(o).toString("hex").toUpperCase()}function OA(t){var e,s;const n=[];try{if(typeof t=="string")return n.push(t),n;if(typeof t!="object")return n;t!=null&&t.id&&n.push(t.id);const r=(s=(e=t==null?void 0:t.capabilities)==null?void 0:e.caip345)==null?void 0:s.transactionHashes;r&&n.push(...r)}catch(r){console.warn("getWalletSendCallsHashes failed: ",r)}return n}var PA=Object.defineProperty,xA=Object.defineProperties,kA=Object.getOwnPropertyDescriptors,_h=Object.getOwnPropertySymbols,UA=Object.prototype.hasOwnProperty,$A=Object.prototype.propertyIsEnumerable,Ah=(t,e,s)=>e in t?PA(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,DA=(t,e)=>{for(var s in e||(e={}))UA.call(e,s)&&Ah(t,s,e[s]);if(_h)for(var s of _h(e))$A.call(e,s)&&Ah(t,s,e[s]);return t},LA=(t,e)=>xA(t,kA(e));const Dg="did:pkh:",MA={eip155:"Ethereum",solana:"Solana",bip122:"Bitcoin"},BA=t=>t?MA[t]||t:"",cc=t=>t==null?void 0:t.split(":"),jA=t=>{const e=t&&cc(t);if(e)return t.includes(Dg)?e[3]:e[1]},FA=t=>{const e=t&&cc(t);if(e)return t.includes(Dg)?e[2]:e[0]},Bl=t=>{const e=t&&cc(t);if(e)return e[2]+":"+e[3]},Fa=t=>{const e=t&&cc(t);if(e)return e.pop()};async function Sh(t){const{cacao:e,projectId:s}=t,{s:n,p:r}=e,i=Lg(r,r.iss),o=Fa(r.iss);return await CA(o,i,n,Bl(r.iss),s)}const Lg=(t,e)=>{const s=FA(e);if(!s)throw new Error("Invalid issuer: "+e);const n=`${t.domain} wants you to sign in with your ${BA(s)} account:`,r=Fa(e);if(!t.aud&&!t.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let i=t.statement||void 0;const o=`URI: ${t.aud||t.uri}`,a=`Version: ${t.version}`,c=`Chain ID: ${jA(e)}`,l=`Nonce: ${t.nonce}`,d=`Issued At: ${t.iat}`,u=t.exp?`Expiration Time: ${t.exp}`:void 0,h=t.nbf?`Not Before: ${t.nbf}`:void 0,p=t.requestId?`Request ID: ${t.requestId}`:void 0,g=t.resources?`Resources:${t.resources.map(w=>`
|
|
7
7
|
- ${w}`).join("")}`:void 0,f=ga(t.resources);if(f){const w=mo(f);i=ZA(i,w)}return[n,r,"",i,"",o,a,c,l,d,u,h,p,g].filter(w=>w!=null).join(`
|
|
@@ -245,4 +245,4 @@ NPM Registry: https://www.npmjs.com/package/@reown/appkit`}},qx={NetworkImageIds
|
|
|
245
245
|
outline: none;
|
|
246
246
|
appearance: none;
|
|
247
247
|
}
|
|
248
|
-
`,Li={ERROR_CODE_UNRECOGNIZED_CHAIN_ID:4902,ERROR_CODE_DEFAULT:5e3,ERROR_INVALID_CHAIN_ID:32603};class bk extends bx{async setUniversalProvider(e){if(!this.namespace)throw new Error("UniversalAdapter:setUniversalProvider - namespace is required");return this.addConnector(new vx({provider:e,caipNetworks:this.getCaipNetworks(),namespace:this.namespace})),Promise.resolve()}async connect(e){return Promise.resolve({id:"WALLET_CONNECT",type:"WALLET_CONNECT",chainId:Number(e.chainId),provider:this.provider,address:""})}async disconnect(){try{await this.getWalletConnectConnector().disconnect(),this.emit("disconnect")}catch(e){console.warn("UniversalAdapter:disconnect - error",e)}return{connections:[]}}syncConnections(){return Promise.resolve()}async getAccounts({namespace:e}){var r,i,o,a;const s=this.provider,n=((a=(o=(i=(r=s==null?void 0:s.session)==null?void 0:r.namespaces)==null?void 0:i[e])==null?void 0:o.accounts)==null?void 0:a.map(c=>{const[,,l]=c.split(":");return l}).filter((c,l,d)=>d.indexOf(c)===l))||[];return Promise.resolve({accounts:n.map(c=>X.createAccount(e,c,e==="bip122"?"payment":"eoa"))})}async syncConnectors(){return Promise.resolve()}async getBalance(e){var o,a,c,l,d;if(!(e.caipNetwork&&Ne.BALANCE_SUPPORTED_CHAINS.includes((o=e.caipNetwork)==null?void 0:o.chainNamespace))||(a=e.caipNetwork)!=null&&a.testnet)return{balance:"0.00",symbol:((c=e.caipNetwork)==null?void 0:c.nativeCurrency.symbol)||""};const n=E.getAccountData();if(n!=null&&n.balanceLoading&&e.chainId===((l=E.state.activeCaipNetwork)==null?void 0:l.id))return{balance:(n==null?void 0:n.balance)||"0.00",symbol:(n==null?void 0:n.balanceSymbol)||""};const i=(await E.fetchTokenBalance()).find(u=>{var h,p;return u.chainId===`${(h=e.caipNetwork)==null?void 0:h.chainNamespace}:${e.chainId}`&&u.symbol===((p=e.caipNetwork)==null?void 0:p.nativeCurrency.symbol)});return{balance:(i==null?void 0:i.quantity.numeric)||"0.00",symbol:(i==null?void 0:i.symbol)||((d=e.caipNetwork)==null?void 0:d.nativeCurrency.symbol)||""}}async signMessage(e){var o,a,c;const{provider:s,message:n,address:r}=e;if(!s)throw new Error("UniversalAdapter:signMessage - provider is undefined");let i="";return((o=E.state.activeCaipNetwork)==null?void 0:o.chainNamespace)===U.CHAIN.SOLANA?i=(await s.request({method:"solana_signMessage",params:{message:gi.encode(new TextEncoder().encode(n)),pubkey:r}},(a=E.state.activeCaipNetwork)==null?void 0:a.caipNetworkId)).signature:i=await s.request({method:"personal_sign",params:[n,r]},(c=E.state.activeCaipNetwork)==null?void 0:c.caipNetworkId),{signature:i}}async estimateGas(){return Promise.resolve({gas:BigInt(0)})}async sendTransaction(){return Promise.resolve({hash:""})}walletGetAssets(e){return Promise.resolve({})}async writeContract(){return Promise.resolve({hash:""})}emitFirstAvailableConnection(){}parseUnits(){return 0n}formatUnits(){return"0"}async getCapabilities(){return Promise.resolve({})}async grantPermissions(){return Promise.resolve({})}async revokePermissions(){return Promise.resolve("0x")}async syncConnection(){return Promise.resolve({id:"WALLET_CONNECT",type:"WALLET_CONNECT",chainId:1,provider:this.provider,address:""})}async switchNetwork(e){var r,i,o,a,c,l;const{caipNetwork:s}=e,n=this.getWalletConnectConnector();if(s.chainNamespace===U.CHAIN.EVM)try{await((r=n.provider)==null?void 0:r.request({method:"wallet_switchEthereumChain",params:[{chainId:Eu(s.id)}]}))}catch(d){if(d.code===Li.ERROR_CODE_UNRECOGNIZED_CHAIN_ID||d.code===Li.ERROR_INVALID_CHAIN_ID||d.code===Li.ERROR_CODE_DEFAULT||((o=(i=d==null?void 0:d.data)==null?void 0:i.originalError)==null?void 0:o.code)===Li.ERROR_CODE_UNRECOGNIZED_CHAIN_ID)try{await((l=n.provider)==null?void 0:l.request({method:"wallet_addEthereumChain",params:[{chainId:Eu(s.id),rpcUrls:[(a=s==null?void 0:s.rpcUrls.chainDefault)==null?void 0:a.http],chainName:s.name,nativeCurrency:s.nativeCurrency,blockExplorerUrls:[(c=s.blockExplorers)==null?void 0:c.default.url]}]}))}catch{throw new Error("Chain is not supported")}}n.provider.setDefaultChain(s.caipNetworkId)}getWalletConnectProvider(){const e=this.connectors.find(n=>n.type==="WALLET_CONNECT");return e==null?void 0:e.provider}}const vk=["email","socials","swaps","onramp","activity","reownBranding","multiWallet","emailCapture","payWithExchange","payments","reownAuthentication","headless"],aa={email:{apiFeatureName:"social_login",localFeatureName:"email",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>{if(!(t!=null&&t.config))return!1;const e=t.config;return!!t.isEnabled&&e.includes("email")},processFallback:t=>t===void 0?Ne.DEFAULT_REMOTE_FEATURES.email:!!t},socials:{apiFeatureName:"social_login",localFeatureName:"socials",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>{if(!(t!=null&&t.config))return!1;const e=t.config;return t.isEnabled&&e.length>0?e.filter(s=>s!=="email"):!1},processFallback:t=>t===void 0?Ne.DEFAULT_REMOTE_FEATURES.socials:typeof t=="boolean"?t?Ne.DEFAULT_REMOTE_FEATURES.socials:!1:t},swaps:{apiFeatureName:"swap",localFeatureName:"swaps",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>{if(!(t!=null&&t.config))return!1;const e=t.config;return t.isEnabled&&e.length>0?e:!1},processFallback:t=>t===void 0?Ne.DEFAULT_REMOTE_FEATURES.swaps:typeof t=="boolean"?t?Ne.DEFAULT_REMOTE_FEATURES.swaps:!1:t},onramp:{apiFeatureName:"onramp",localFeatureName:"onramp",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>{if(!(t!=null&&t.config))return!1;const e=t.config;return t.isEnabled&&e.length>0?e:!1},processFallback:t=>t===void 0?Ne.DEFAULT_REMOTE_FEATURES.onramp:typeof t=="boolean"?t?Ne.DEFAULT_REMOTE_FEATURES.onramp:!1:t},activity:{apiFeatureName:"activity",localFeatureName:"history",returnType:!1,isLegacy:!0,isAvailableOnBasic:!1,processApi:t=>!!t.isEnabled,processFallback:t=>t===void 0?Ne.DEFAULT_REMOTE_FEATURES.activity:!!t},reownBranding:{apiFeatureName:"reown_branding",localFeatureName:"reownBranding",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>!!t.isEnabled,processFallback:t=>t===void 0?Ne.DEFAULT_REMOTE_FEATURES.reownBranding:!!t},emailCapture:{apiFeatureName:"email_capture",localFeatureName:"emailCapture",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>t.isEnabled&&(t.config??[]),processFallback:t=>!1},multiWallet:{apiFeatureName:"multi_wallet",localFeatureName:"multiWallet",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>!!t.isEnabled,processFallback:()=>Ne.DEFAULT_REMOTE_FEATURES.multiWallet},payWithExchange:{apiFeatureName:"fund_from_exchange",localFeatureName:"payWithExchange",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>!!t.isEnabled,processFallback:()=>Ne.DEFAULT_REMOTE_FEATURES.payWithExchange},payments:{apiFeatureName:"payments",localFeatureName:"payments",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>!!t.isEnabled,processFallback:()=>Ne.DEFAULT_REMOTE_FEATURES.payments},reownAuthentication:{apiFeatureName:"reown_authentication",localFeatureName:"reownAuthentication",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>!!t.isEnabled,processFallback:t=>typeof t>"u"?Ne.DEFAULT_REMOTE_FEATURES.reownAuthentication:!!t},headless:{apiFeatureName:"headless",localFeatureName:"headless",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>!!t.isEnabled,processFallback:()=>Ne.DEFAULT_REMOTE_FEATURES.headless}},Ck={localSettingsOverridden:new Set,getApiConfig(t,e){return e==null?void 0:e.find(s=>s.id===t)},addWarning(t,e){if(t!==void 0){const s=aa[e],n=s.isLegacy?`"features.${s.localFeatureName}" (now "${e}")`:`"features.${e}"`;this.localSettingsOverridden.add(n)}},processFeature(t,e,s,n,r){const i=aa[t],o=e[i.localFeatureName];if(r&&!i.isAvailableOnBasic)return!1;if(n){const a=this.getApiConfig(i.apiFeatureName,s);return(a==null?void 0:a.config)===null?this.processFallbackFeature(t,o):a!=null&&a.config?(o!==void 0&&this.addWarning(o,t),this.processApiFeature(t,a)):!1}return this.processFallbackFeature(t,o)},processApiFeature(t,e){return aa[t].processApi(e)},processFallbackFeature(t,e){return aa[t].processFallback(e)},async fetchRemoteFeatures(t){const e=t.basic??!1,s=t.features||{};this.localSettingsOverridden.clear();let n=null,r=!1;try{n=await te.fetchProjectConfig(),r=n!=null}catch(o){console.warn("[Reown Config] Failed to fetch remote project configuration. Using local/default values.",o)}const i=r&&!e?Ne.DEFAULT_REMOTE_FEATURES:Ne.DEFAULT_REMOTE_FEATURES_DISABLED;try{for(const o of vk){const a=this.processFeature(o,s,n,r,e);Object.assign(i,{[o]:a})}}catch(o){return console.warn("[Reown Config] Failed to process the configuration from Cloud. Using default values.",o),Ne.DEFAULT_REMOTE_FEATURES}if(r&&this.localSettingsOverridden.size>0){const o=`Your local configuration for ${Array.from(this.localSettingsOverridden).join(", ")} was ignored because a remote configuration was successfully fetched. Please manage these features via your project dashboard on dashboard.reown.com.`;Ot.open({debugMessage:Pt.ALERT_WARNINGS.LOCAL_CONFIGURATION_IGNORED.debugMessage(o)},"warning")}return i}};class _k{constructor(e){this.chainNamespaces=[],this.features={},this.remoteFeatures={},this.reportedAlertErrors={},this.getCaipNetwork=(s,n)=>{var r,i,o;if(s){const a=(r=E.getCaipNetworks(s))==null?void 0:r.find(d=>d.id===n);if(a)return a;const c=(i=E.getNetworkData(s))==null?void 0:i.caipNetwork;return c||((o=E.getRequestedCaipNetworks(s).filter(d=>d.chainNamespace===s))==null?void 0:o[0])}return E.state.activeCaipNetwork||this.defaultCaipNetwork},this.getCaipNetworkId=()=>{const s=this.getCaipNetwork();if(s)return s.id},this.getCaipNetworks=s=>E.getCaipNetworks(s),this.getActiveChainNamespace=()=>E.state.activeChain,this.setRequestedCaipNetworks=(s,n)=>{E.setRequestedCaipNetworks(s,n)},this.getApprovedCaipNetworkIds=()=>E.getAllApprovedCaipNetworkIds(),this.getCaipAddress=s=>{var n,r;return E.state.activeChain===s||!s?E.state.activeCaipAddress:(r=(n=E.state.chains.get(s))==null?void 0:n.accountState)==null?void 0:r.caipAddress},this.setClientId=s=>{fe.setClientId(s)},this.getProvider=s=>He.getProvider(s),this.getProviderType=s=>He.getProviderId(s),this.getPreferredAccountType=s=>ls(s),this.setCaipAddress=(s,n,r=!1)=>{E.setAccountProp("caipAddress",s,n,r),E.setAccountProp("address",X.getPlainAddress(s),n,r)},this.setBalance=(s,n,r)=>{E.setAccountProp("balance",s,r),E.setAccountProp("balanceSymbol",n,r)},this.setProfileName=(s,n)=>{E.setAccountProp("profileName",s,n)},this.setProfileImage=(s,n)=>{E.setAccountProp("profileImage",s,n)},this.setUser=(s,n)=>{E.setAccountProp("user",s,n)},this.resetAccount=s=>{E.resetAccount(s)},this.setCaipNetwork=s=>{E.setActiveCaipNetwork(s)},this.setCaipNetworkOfNamespace=(s,n)=>{E.setChainNetworkData(n,{caipNetwork:s})},this.setStatus=(s,n)=>{E.setAccountProp("status",s,n),V.isConnected()?F.setConnectionStatus("connected"):F.setConnectionStatus("disconnected")},this.getAddressByChainNamespace=s=>{var n;return(n=E.getAccountData(s))==null?void 0:n.address},this.setConnectors=s=>{const n=[...V.state.allConnectors,...s];V.setConnectors(n)},this.setConnections=(s,n)=>{F.setConnections(s,n),G.setConnections(s,n)},this.fetchIdentity=s=>fe.fetchIdentity(s),this.getReownName=s=>Hi.getNamesForAddress(s),this.getConnectors=()=>V.getConnectors(),this.getConnectorImage=s=>Bf.getConnectorImage(s),this.getConnections=s=>this.remoteFeatures.multiWallet?Ua.getConnectionsData(s).connections:(Ot.open(U.REMOTE_FEATURES_ALERTS.MULTI_WALLET_NOT_ENABLED.DEFAULT,"info"),[]),this.getRecentConnections=s=>this.remoteFeatures.multiWallet?Ua.getConnectionsData(s).recentConnections:(Ot.open(U.REMOTE_FEATURES_ALERTS.MULTI_WALLET_NOT_ENABLED.DEFAULT,"info"),[]),this.switchConnection=async s=>{if(!this.remoteFeatures.multiWallet){Ot.open(U.REMOTE_FEATURES_ALERTS.MULTI_WALLET_NOT_ENABLED.DEFAULT,"info");return}await G.switchConnection(s)},this.deleteConnection=s=>{if(!this.remoteFeatures.multiWallet){Ot.open(U.REMOTE_FEATURES_ALERTS.MULTI_WALLET_NOT_ENABLED.DEFAULT,"info");return}F.deleteAddressFromConnection(s),G.syncStorageConnections()},this.setConnectedWalletInfo=(s,n)=>{const r=He.getProviderId(n),i=s?{...s,type:r}:void 0;E.setAccountProp("connectedWalletInfo",i,n)},this.getIsConnectedState=()=>!!E.state.activeCaipAddress,this.addAddressLabel=(s,n,r)=>{var o;const i=((o=E.getAccountData(r))==null?void 0:o.addressLabels)||{};E.setAccountProp("addressLabels",{...i,[s]:n},r)},this.removeAddressLabel=(s,n)=>{var i;const r=((i=E.getAccountData(n))==null?void 0:i.addressLabels)||{};E.setAccountProp("addressLabels",{...r,[s]:void 0},n)},this.getAddress=s=>{var r;const n=s||E.state.activeChain;return(r=E.getAccountData(n))==null?void 0:r.address},this.resetNetwork=s=>{E.resetNetwork(s)},this.addConnector=s=>{V.addConnector(s)},this.resetWcConnection=()=>{G.resetWcConnection()},this.setAddressExplorerUrl=(s,n)=>{E.setAccountProp("addressExplorerUrl",s,n)},this.setSmartAccountDeployed=(s,n)=>{E.setAccountProp("smartAccountDeployed",s,n)},this.setPreferredAccountType=(s,n)=>{E.setAccountProp("preferredAccountType",s,n)},this.setEIP6963Enabled=s=>{$.setEIP6963Enabled(s)},this.handleUnsafeRPCRequest=()=>{if(this.isOpen()){if(this.isTransactionStackEmpty())return;this.redirect("ApproveTransaction")}else this.open({view:"ApproveTransaction"})},this.options=e,this.version=e.sdkVersion,this.caipNetworks=this.extendCaipNetworks(e),this.chainNamespaces=this.getChainNamespacesSet(e.adapters,this.caipNetworks),this.defaultCaipNetwork=this.extendDefaultCaipNetwork(e),this.chainAdapters=this.createAdapters(e.adapters),this.readyPromise=this.initialize(e)}getChainNamespacesSet(e,s){const n=e==null?void 0:e.map(i=>i.namespace).filter(i=>!!i);if(n!=null&&n.length)return[...new Set(n)];const r=s==null?void 0:s.map(i=>i.chainNamespace);return[...new Set(r)]}async initialize(e){var s,n,r,i,o,a;if(this.initializeProjectSettings(e),this.initControllers(e),await this.initChainAdapters(),this.sendInitializeEvent(e),(s=e.features)!=null&&s.headless&&!Ps.hasInjectedConnectors()&&te.prefetch({fetchNetworkImages:!1,fetchConnectorImages:!1,fetchWalletRanks:!1,fetchRecommendedWallets:!0}),$.state.enableReconnect?(await this.syncExistingConnection(),await this.syncAdapterConnections()):await this.unSyncExistingConnection(),!e.basic&&!e.manualWCControl&&(this.remoteFeatures=await Ck.fetchRemoteFeatures(e)),await te.fetchUsage(),$.setRemoteFeatures(this.remoteFeatures),this.remoteFeatures.onramp&&Rl.setOnrampProviders(this.remoteFeatures.onramp),((n=$.state.remoteFeatures)!=null&&n.email||Array.isArray((r=$.state.remoteFeatures)==null?void 0:r.socials)&&((i=$.state.remoteFeatures)==null?void 0:i.socials.length)>0)&&await this.checkAllowedOrigins(),(o=$.state.features)!=null&&o.reownAuthentication||(a=$.state.remoteFeatures)!=null&&a.reownAuthentication){const{ReownAuthentication:c}=await Dt(async()=>{const{ReownAuthentication:d}=await import("./features-CrkPfyGi.js");return{ReownAuthentication:d}},__vite__mapDeps([10,2,3,5,6,7,8,9])),l=$.state.siwx;l instanceof c||(l&&console.warn("ReownAuthentication option is enabled, SIWX configuration will be overridden."),$.setSIWX(new c))}}async openSend(e){var i;const s=e.namespace||E.state.activeChain,n=this.getCaipAddress(s),r=(i=this.getCaipNetwork(s))==null?void 0:i.id;if(!n)throw new Error("openSend: caipAddress not found");if((r==null?void 0:r.toString())!==e.chainId.toString()){const o=E.getCaipNetworkById(e.chainId,s);if(!o)throw new Error(`openSend: caipNetwork with chainId ${e.chainId} not found`);await this.switchNetwork(o,{throwOnFailure:!0})}try{const o=sy.getTokenSymbolByAddress(e.assetAddress);o&&await te.fetchTokenImages([o])}catch{}return await Te.open({view:"WalletSend",data:{send:e}}),new Promise((o,a)=>{const c=Ae.subscribeKey("hash",u=>{u&&(d(),o({hash:u}))}),l=Te.subscribe(u=>{u.open||(d(),a(new Error("Modal closed")))}),d=this.createCleanupHandler([c,l])})}toModalOptions(){function e(n){return(n==null?void 0:n.view)==="Swap"}function s(n){return(n==null?void 0:n.view)==="WalletSend"}return{isSwap:e,isSend:s}}async checkAllowedOrigins(){try{const e=await te.fetchAllowedOrigins();if(!X.isClient())return;const s=window.location.origin;zn.isOriginAllowed(s,e,U.DEFAULT_ALLOWED_ANCESTORS)||Ot.open(Pt.ALERT_ERRORS.ORIGIN_NOT_ALLOWED,"error")}catch(e){if(!(e instanceof Error))return;switch(e.message){case"RATE_LIMITED":Ot.open(Pt.ALERT_ERRORS.RATE_LIMITED_APP_CONFIGURATION,"error");break;case"SERVER_ERROR":{const s=e.cause instanceof Error?e.cause:e;Ot.open({displayMessage:Pt.ALERT_ERRORS.SERVER_ERROR_APP_CONFIGURATION.displayMessage,debugMessage:Pt.ALERT_ERRORS.SERVER_ERROR_APP_CONFIGURATION.debugMessage(s.message)},"error");break}}}}createCleanupHandler(e){return()=>{e.forEach(s=>{try{s()}catch{}})}}sendInitializeEvent(e){var n;const{...s}=e;delete s.adapters,delete s.universalProvider,Ee.sendEvent({type:"track",event:"INITIALIZE",properties:{...s,networks:e.networks.map(r=>r.id),siweConfig:{options:((n=e.siweConfig)==null?void 0:n.options)||{}}}})}initControllers(e){this.initializeOptionsController(e),this.initializeChainController(e),this.initializeThemeController(e),this.initializeConnectionController(e),this.initializeConnectorController()}initAdapterController(){qf.initialize(this.chainAdapters)}initializeThemeController(e){e.themeMode&&Kt.setThemeMode(e.themeMode),e.themeVariables&&Kt.setThemeVariables(e.themeVariables)}initializeChainController(e){if(!this.connectionControllerClient)throw new Error("ConnectionControllerClient must be set");E.initialize(e.adapters??[],this.caipNetworks,{connectionControllerClient:this.connectionControllerClient});const s=this.getDefaultNetwork();s&&E.setActiveCaipNetwork(s)}initializeConnectionController(e){G.initialize(e.adapters??[]),G.setWcBasic(e.basic??!1)}initializeConnectorController(){V.initialize(this.chainNamespaces)}initializeProjectSettings(e){$.setProjectId(e.projectId),$.setSdkVersion(e.sdkVersion)}initializeOptionsController(e){var r;$.setDebug(e.debug!==!1),$.setEnableWalletGuide(e.enableWalletGuide!==!1),$.setEnableWallets(e.enableWallets!==!1),$.setEIP6963Enabled(e.enableEIP6963!==!1),$.setEnableNetworkSwitch(e.enableNetworkSwitch!==!1),$.setEnableReconnect(e.enableReconnect!==!1),$.setEnableMobileFullScreen(e.enableMobileFullScreen===!0),$.setCoinbasePreference(e.coinbasePreference),$.setEnableAuthLogger(e.enableAuthLogger!==!1),$.setCustomRpcUrls(e.customRpcUrls),$.setEnableEmbedded(e.enableEmbedded),$.setAllWallets(e.allWallets),$.setIncludeWalletIds(e.includeWalletIds),$.setExcludeWalletIds(e.excludeWalletIds),$.setFeaturedWalletIds(e.featuredWalletIds),$.setTokens(e.tokens),$.setTermsConditionsUrl(e.termsConditionsUrl),$.setPrivacyPolicyUrl(e.privacyPolicyUrl),$.setCustomWallets(e.customWallets),$.setFeatures(e.features),$.setAllowUnsupportedChain(e.allowUnsupportedChain),$.setUniversalProviderConfigOverride(e.universalProviderConfigOverride),$.setPreferUniversalLinks(e.experimental_preferUniversalLinks),$.setDefaultAccountTypes(e.defaultAccountTypes);const s=this.getDefaultMetaData();if(!e.metadata&&s&&(e.metadata=s),$.setMetadata(e.metadata),$.setDisableAppend(e.disableAppend),$.setEnableEmbedded(e.enableEmbedded),$.setSIWX(e.siwx),this.features=$.state.features??{},!e.projectId){Ot.open(Pt.ALERT_ERRORS.PROJECT_ID_NOT_CONFIGURED,"error");return}if(((r=e.adapters)==null?void 0:r.find(i=>i.namespace===U.CHAIN.EVM))&&e.siweConfig){if(e.siwx)throw new Error("Cannot set both `siweConfig` and `siwx` options");$.setSIWX(e.siweConfig.mapToSIWX())}}getDefaultMetaData(){var e,s,n,r;return X.isClient()?{name:((s=(e=document.getElementsByTagName("title"))==null?void 0:e[0])==null?void 0:s.textContent)||"",description:((n=document.querySelector('meta[property="og:description"]'))==null?void 0:n.content)||"",url:window.location.origin,icons:[((r=document.querySelector('link[rel~="icon"]'))==null?void 0:r.href)||""]}:null}setUnsupportedNetwork(e){const s=this.getActiveChainNamespace();if(s){const n=Gr.getUnsupportedNetwork(`${s}:${e}`);E.setActiveCaipNetwork(n)}}getDefaultNetwork(){return Gr.getCaipNetworkFromStorage(this.defaultCaipNetwork)}extendCaipNetwork(e,s){return Gr.extendCaipNetwork(e,{customNetworkImageUrls:s.chainImages,projectId:s.projectId})}extendCaipNetworks(e){return Gr.extendCaipNetworks(e.networks,{customNetworkImageUrls:e.chainImages,customRpcUrls:e.customRpcUrls,projectId:e.projectId})}extendDefaultCaipNetwork(e){const s=e.networks.find(r=>{var i;return r.id===((i=e.defaultNetwork)==null?void 0:i.id)});return s?Gr.extendCaipNetwork(s,{customNetworkImageUrls:e.chainImages,customRpcUrls:e.customRpcUrls,projectId:e.projectId}):void 0}async disconnectConnector(e,s){var n,r;try{this.setLoading(!0,e);let i={connections:[]};const o=this.getAdapter(e);return(((r=(n=E.state.chains.get(e))==null?void 0:n.accountState)==null?void 0:r.caipAddress)||!$.state.enableReconnect)&&(o!=null&&o.disconnect)&&(i=await o.disconnect({id:s})),this.setLoading(!1,e),i}catch(i){throw this.setLoading(!1,e),new Error(`Failed to disconnect chains: ${i.message}`)}}createClients(){this.connectionControllerClient={connectWalletConnect:async()=>{var l;const e=E.state.activeChain,s=this.getAdapter(e),n=(l=this.getCaipNetwork(e))==null?void 0:l.id,r=G.getConnections(e),i=this.remoteFeatures.multiWallet,o=r.length>0;if(!s)throw new Error("Adapter not found");const a=await s.connectWalletConnect(n);(!o||!i)&&this.close(),this.setClientId((a==null?void 0:a.clientId)||null),F.setConnectedNamespaces([...E.state.chains.keys()]),await this.syncWalletConnectAccount(),await vs.initializeIfEnabled()},connectExternal:async e=>{const s=await this.onConnectExternal(e);return await this.connectInactiveNamespaces(e,s),s?{address:s.address}:void 0},reconnectExternal:async({id:e,info:s,type:n,provider:r})=>{var a;const i=E.state.activeChain,o=this.getAdapter(i);if(!i)throw new Error("reconnectExternal: namespace not found");if(!o)throw new Error("reconnectExternal: adapter not found");o!=null&&o.reconnect&&(await(o==null?void 0:o.reconnect({id:e,info:s,type:n,provider:r,chainId:(a=this.getCaipNetwork())==null?void 0:a.id})),F.addConnectedNamespace(i),this.syncConnectedWalletInfo(i))},disconnectConnector:async e=>{await this.disconnectConnector(e.namespace,e.id)},disconnect:async e=>{var l;const{id:s,chainNamespace:n,initialDisconnect:r}=e||{},i=n||E.state.activeChain,o=V.getConnectorId(i),a=s===U.CONNECTOR_ID.AUTH||o===U.CONNECTOR_ID.AUTH,c=s===U.CONNECTOR_ID.WALLET_CONNECT||o===U.CONNECTOR_ID.WALLET_CONNECT;try{const d=Array.from(E.state.chains.keys());let u=n?[n]:d;(c||a)&&(u=d);const h=u.map(async f=>{const w=V.getConnectorId(f),v=s||w,N=await this.disconnectConnector(f,v);N&&(a&&F.deleteConnectedSocialProvider(),N.connections.forEach(A=>{F.addDisconnectedConnectorId(A.connectorId,f)})),r&&this.onDisconnectNamespace({chainNamespace:f,closeModal:!1})}),p=await Promise.allSettled(h);Ae.resetSend(),G.resetWcConnection(),(l=vs.getSIWX())!=null&&l.signOutOnDisconnect&&await vs.clearSessions(),V.setFilterByNamespace(void 0),G.syncStorageConnections();const g=p.filter(f=>f.status==="rejected");if(g.length>0)throw new Error(g.map(f=>f.reason.message).join(", "));Ee.sendEvent({type:"track",event:"DISCONNECT_SUCCESS",properties:{namespace:n||"all"}})}catch(d){throw new Error(`Failed to disconnect chains: ${d.message}`)}},checkInstalled:e=>e?e.some(s=>{var n;return!!((n=window.ethereum)!=null&&n[String(s)])}):!!window.ethereum,signMessage:async e=>{const s=E.state.activeChain,n=this.getAdapter(E.state.activeChain);if(!s)throw new Error("signMessage: namespace not found");if(!n)throw new Error("signMessage: adapter not found");const r=this.getAddress(s);if(!r)throw new Error("signMessage: address not found");const i=await(n==null?void 0:n.signMessage({message:e,address:r,provider:He.getProvider(s)}));return(i==null?void 0:i.signature)||""},sendTransaction:async e=>{const s=e.chainNamespace;if(!s)throw new Error("sendTransaction: namespace not found");if(Ne.SEND_SUPPORTED_NAMESPACES.includes(s)){const n=this.getAdapter(s);if(!n)throw new Error("sendTransaction: adapter not found");const r=He.getProvider(s),i=await(n==null?void 0:n.sendTransaction({...e,caipNetwork:this.getCaipNetwork(),provider:r}));return(i==null?void 0:i.hash)||""}return""},estimateGas:async e=>{const s=e.chainNamespace;if(s===U.CHAIN.EVM){const n=this.getAdapter(s);if(!n)throw new Error("estimateGas: adapter is required but got undefined");const r=He.getProvider(s),i=this.getCaipNetwork();if(!i)throw new Error("estimateGas: caipNetwork is required but got undefined");const o=await(n==null?void 0:n.estimateGas({...e,provider:r,caipNetwork:i}));return(o==null?void 0:o.gas)||0n}return 0n},getEnsAvatar:async()=>{var r;const e=E.state.activeChain;if(!e)throw new Error("getEnsAvatar: namespace is required but got undefined");const s=this.getAddress(e);if(!s)throw new Error("getEnsAvatar: address not found");await this.syncIdentity({address:s,chainId:Number((r=this.getCaipNetwork())==null?void 0:r.id),chainNamespace:e});const n=E.getAccountData();return(n==null?void 0:n.profileImage)||!1},getEnsAddress:async e=>await zn.resolveReownName(e),writeContract:async e=>{const s=E.state.activeChain,n=this.getAdapter(s);if(!s)throw new Error("writeContract: namespace is required but got undefined");if(!n)throw new Error("writeContract: adapter is required but got undefined");const r=this.getCaipNetwork(),i=this.getCaipAddress(),o=He.getProvider(s);if(!r||!i)throw new Error("writeContract: caipNetwork or caipAddress is required but got undefined");const a=await(n==null?void 0:n.writeContract({...e,caipNetwork:r,provider:o,caipAddress:i}));return a==null?void 0:a.hash},parseUnits:(e,s)=>{const n=this.getAdapter(E.state.activeChain);if(!n)throw new Error("parseUnits: adapter is required but got undefined");return(n==null?void 0:n.parseUnits({value:e,decimals:s}))??0n},formatUnits:(e,s)=>{const n=this.getAdapter(E.state.activeChain);if(!n)throw new Error("formatUnits: adapter is required but got undefined");return(n==null?void 0:n.formatUnits({value:e,decimals:s}))??"0"},getCapabilities:async e=>{const s=this.getAdapter(E.state.activeChain);if(!s)throw new Error("getCapabilities: adapter is required but got undefined");return await(s==null?void 0:s.getCapabilities(e))},grantPermissions:async e=>{const s=this.getAdapter(E.state.activeChain);if(!s)throw new Error("grantPermissions: adapter is required but got undefined");return await(s==null?void 0:s.grantPermissions(e))},revokePermissions:async e=>{const s=this.getAdapter(E.state.activeChain);if(!s)throw new Error("revokePermissions: adapter is required but got undefined");return s!=null&&s.revokePermissions?await s.revokePermissions(e):"0x"},walletGetAssets:async e=>{const s=this.getAdapter(E.state.activeChain);if(!s)throw new Error("walletGetAssets: adapter is required but got undefined");return await(s==null?void 0:s.walletGetAssets(e))??{}},updateBalance:e=>{const s=this.getAddress(e),n=this.getCaipNetwork(e);!n||!s||this.updateNativeBalance(s,n==null?void 0:n.id,e)}},G.setClient(this.connectionControllerClient)}async onConnectExternal(e){var l,d,u,h,p,g,f,w;const s=E.state.activeChain,n=e.chain||s,r=this.getAdapter(n);let i=!0;if(e.type===Lt.CONNECTOR_TYPE_AUTH&&U.AUTH_CONNECTOR_SUPPORTED_CHAINS.some(A=>V.getConnectorId(A)===U.CONNECTOR_ID.AUTH)&&e.chain!==s&&(i=!1),e.chain&&e.chain!==s&&!e.caipNetwork){const v=this.getCaipNetworks().find(N=>N.chainNamespace===e.chain);v&&i&&this.setCaipNetwork(v)}if(!n)throw new Error("connectExternal: namespace not found");if(!r)throw new Error("connectExternal: adapter not found");const o=this.getCaipNetwork(n),a=e.caipNetwork||o,c=await r.connect({id:e.id,address:e.address,info:e.info,type:e.type,provider:e.provider,socialUri:e.socialUri,chainId:((l=e.caipNetwork)==null?void 0:l.id)||(o==null?void 0:o.id),rpcUrl:((p=(h=(u=(d=e.caipNetwork)==null?void 0:d.rpcUrls)==null?void 0:u.default)==null?void 0:h.http)==null?void 0:p[0])||((w=(f=(g=o==null?void 0:o.rpcUrls)==null?void 0:g.default)==null?void 0:f.http)==null?void 0:w[0])});if(c)return F.addConnectedNamespace(n),this.syncProvider({...c,chainNamespace:n}),this.setStatus("connected",n),this.syncConnectedWalletInfo(n),F.removeDisconnectedConnectorId(e.id,n),{address:c.address,connectedCaipNetwork:a}}async connectInactiveNamespaces(e,s){var a;const n=e.type===Lt.CONNECTOR_TYPE_AUTH,r=wo.getOtherAuthNamespaces((a=s==null?void 0:s.connectedCaipNetwork)==null?void 0:a.chainNamespace),i=E.state.activeCaipNetwork,o=this.getAdapter(i==null?void 0:i.chainNamespace);n&&(await Promise.all(r.map(async c=>{var l,d,u;try{const h=He.getProvider(c),p=this.getCaipNetwork(c),g=this.getAdapter(c);await(g==null?void 0:g.connect({...e,provider:h,socialUri:void 0,chainId:p==null?void 0:p.id,rpcUrl:(u=(d=(l=p==null?void 0:p.rpcUrls)==null?void 0:l.default)==null?void 0:d.http)==null?void 0:u[0]}))&&(F.addConnectedNamespace(c),F.removeDisconnectedConnectorId(e.id,c),this.setStatus("connected",c),this.syncConnectedWalletInfo(c))}catch(h){Ot.warn(Pt.ALERT_WARNINGS.INACTIVE_NAMESPACE_NOT_CONNECTED.displayMessage,Pt.ALERT_WARNINGS.INACTIVE_NAMESPACE_NOT_CONNECTED.debugMessage(c,h instanceof Error?h.message:void 0),Pt.ALERT_WARNINGS.INACTIVE_NAMESPACE_NOT_CONNECTED.code)}})),i&&await(o==null?void 0:o.switchNetwork({caipNetwork:i})))}getApprovedCaipNetworksData(){var s,n,r,i,o;if(He.getProviderId(E.state.activeChain)===Lt.CONNECTOR_TYPE_WALLET_CONNECT){const a=(n=(s=this.universalProvider)==null?void 0:s.session)==null?void 0:n.namespaces;return{supportsAllNetworks:((o=(i=(r=this.universalProvider)==null?void 0:r.session)==null?void 0:i.peer)==null?void 0:o.metadata.name)==="MetaMask Wallet",approvedCaipNetworkIds:this.getChainsFromNamespaces(a)}}return{supportsAllNetworks:!0,approvedCaipNetworkIds:[]}}async switchCaipNetwork(e){const s=e.chainNamespace;if(this.getAddressByChainNamespace(e.chainNamespace)){const r=He.getProviderId(s);if(e.chainNamespace===E.state.activeChain){const i=this.getAdapter(s);await(i==null?void 0:i.switchNetwork({caipNetwork:e}))}else if(this.setCaipNetwork(e),r===Lt.CONNECTOR_TYPE_WALLET_CONNECT)this.syncWalletConnectAccount();else{const i=this.getAddressByChainNamespace(s);i&&this.syncAccount({address:i,chainId:e.id,chainNamespace:s})}}else this.setCaipNetwork(e)}getChainsFromNamespaces(e={}){return Object.values(e).flatMap(s=>{const n=s.chains||[],r=s.accounts.map(i=>{const{chainId:o,chainNamespace:a}=dt.parseCaipAddress(i);return`${a}:${o}`});return Array.from(new Set([...n,...r]))})}createAdapters(e){return this.createClients(),this.chainNamespaces.reduce((s,n)=>{var i,o;const r=e==null?void 0:e.find(a=>a.namespace===n);return r?(r.construct({namespace:n,projectId:(i=this.options)==null?void 0:i.projectId,networks:(o=this.caipNetworks)==null?void 0:o.filter(({chainNamespace:a})=>a===n)}),s[n]=r):s[n]=new bk({namespace:n,networks:this.getCaipNetworks()}),s},{})}async initChainAdapter(e){this.onConnectors(e),this.listenAdapter(e);const s=this.getAdapter(e);if(!s)throw new Error("adapter not found");await s.syncConnectors(),await this.createUniversalProviderForAdapter(e)}async initChainAdapters(){await Promise.all(this.chainNamespaces.map(async e=>{await this.initChainAdapter(e)})),this.initAdapterController()}onConnectors(e){const s=this.getAdapter(e);s==null||s.on("connectors",this.setConnectors.bind(this))}listenAdapter(e){const s=this.getAdapter(e);if(!s)return;const n=F.getConnectionStatus();$.state.enableReconnect===!1?this.setStatus("disconnected",e):n==="connected"?this.setStatus("connecting",e):n==="disconnected"?(F.clearAddressCache(),this.setStatus(n,e)):this.setStatus(n,e),s.on("switchNetwork",({address:r,chainId:i})=>{var l,d;const o=this.getCaipNetworks().find(u=>u.id.toString()===i.toString()||u.caipNetworkId.toString()===i.toString()),a=E.state.activeChain===e,c=(d=(l=E.state.chains.get(e))==null?void 0:l.accountState)==null?void 0:d.address;if(o){const u=a&&r?r:c;u&&this.syncAccount({address:u,chainId:o.id,chainNamespace:e})}else this.setUnsupportedNetwork(i)}),s.on("disconnect",()=>{const r=this.remoteFeatures.multiWallet,i=Array.from(G.state.connections.values()).flat();this.onDisconnectNamespace({chainNamespace:e,closeModal:!r||i.length===0})}),s.on("connections",r=>{this.setConnections(r,e)}),s.on("pendingTransactions",()=>{const r=this.getAddress(e),i=E.state.activeCaipNetwork;!r||!(i!=null&&i.id)||this.updateNativeBalance(r,i.id,i.chainNamespace)}),s.on("accountChanged",({address:r,chainId:i,connector:o})=>{var d,u;this.handlePreviousConnectorConnection(o);const a=E.state.activeChain===e;o!=null&&o.provider&&(this.syncProvider({id:o.id,type:o.type,provider:o==null?void 0:o.provider,chainNamespace:e}),this.syncConnectedWalletInfo(e));const c=(u=(d=E.getNetworkData(e))==null?void 0:d.caipNetwork)==null?void 0:u.id,l=i||c;a&&l?this.syncAccount({address:r,chainId:l,chainNamespace:e}):!a&&l?(this.syncAccountInfo(r,l,e),this.syncBalance({address:r,chainId:l,chainNamespace:e})):this.syncAccountInfo(r,i,e),F.addConnectedNamespace(e)})}async handlePreviousConnectorConnection(e){var c;const s=e==null?void 0:e.chain,n=e==null?void 0:e.id,r=V.getConnectorId(s),i=(c=$.state.remoteFeatures)==null?void 0:c.multiWallet,a=s&&n&&r&&r!==n&&!i;try{a&&await G.disconnect({id:r,namespace:s})}catch(l){console.warn("Error disconnecting previous connector",l)}}async createUniversalProviderForAdapter(e){var s,n,r;await this.getUniversalProvider(),this.universalProvider&&await((r=(n=(s=this.chainAdapters)==null?void 0:s[e])==null?void 0:n.setUniversalProvider)==null?void 0:r.call(n,this.universalProvider))}async syncExistingConnection(){await Promise.allSettled(this.chainNamespaces.map(e=>this.syncNamespaceConnection(e)))}async unSyncExistingConnection(){try{await Promise.allSettled(this.chainNamespaces.map(e=>G.disconnect({namespace:e,initialDisconnect:!0})))}catch(e){console.error("Error disconnecting existing connections:",e)}}async reconnectWalletConnect(){await this.syncWalletConnectAccount();const e=this.getAddress();this.getCaipAddress()||F.deleteRecentWallet();const s=F.getRecentWallet();Ee.sendEvent({type:"track",event:"CONNECT_SUCCESS",address:e,properties:{method:X.isMobile()?"mobile":"qrcode",name:(s==null?void 0:s.name)||"Unknown",reconnect:!0,view:ue.state.view,walletRank:s==null?void 0:s.order}})}async syncNamespaceConnection(e){try{e===U.CHAIN.EVM&&X.isSafeApp()&&V.setConnectorId(U.CONNECTOR_ID.SAFE,e);const s=V.getConnectorId(e);switch(this.setStatus("connecting",e),s){case U.CONNECTOR_ID.WALLET_CONNECT:await this.reconnectWalletConnect();break;case U.CONNECTOR_ID.AUTH:break;default:await this.syncAdapterConnection(e)}}catch(s){console.warn("AppKit couldn't sync existing connection",s),this.setStatus("disconnected",e)}}onDisconnectNamespace(e){const{chainNamespace:s,closeModal:n}=e||{};E.resetAccount(s),E.resetNetwork(s),F.removeConnectedNamespace(s);const r=Array.from(E.state.chains.keys());(s?[s]:r).forEach(o=>F.addDisconnectedConnectorId(V.getConnectorId(o)||"",o)),V.removeConnectorId(s),He.resetChain(s),this.setUser(null,s),this.setStatus("disconnected",s),this.setConnectedWalletInfo(null,s),n!==!1&&Te.close()}async syncAdapterConnections(){await Promise.allSettled(this.chainNamespaces.map(e=>{const s=this.getAdapter(e),n=this.getCaipAddress(e),r=this.getCaipNetwork(e);return s==null?void 0:s.syncConnections({connectToFirstConnector:!n,caipNetwork:r})}))}async syncAdapterConnection(e){var a,c,l,d,u;const s=this.getAdapter(e),n=this.getCaipNetwork(e),r=V.getConnectorId(e),o=V.getConnectors(e).find(h=>h.id===r);try{if(!s||!o)throw new Error(`Adapter or connector not found for namespace ${e}`);if(!(n!=null&&n.id))throw new Error("CaipNetwork not found");const h=await(s==null?void 0:s.syncConnection({namespace:e,id:o.id,chainId:n.id,rpcUrl:(l=(c=(a=n==null?void 0:n.rpcUrls)==null?void 0:a.default)==null?void 0:c.http)==null?void 0:l[0]}));h?(this.syncProvider({...h,chainNamespace:e}),await this.syncAccount({...h,chainNamespace:e}),this.setStatus("connected",e),Ee.sendEvent({type:"track",event:"CONNECT_SUCCESS",address:h.address,properties:{method:"browser",name:((d=o.info)==null?void 0:d.name)||o.name||"Unknown",reconnect:!0,view:ue.state.view,walletRank:(u=o==null?void 0:o.explorerWallet)==null?void 0:u.order}})):this.setStatus("disconnected",e)}catch{this.onDisconnectNamespace({chainNamespace:e,closeModal:!1})}}async syncWalletConnectAccount(){var n,r;const e=Object.keys(((r=(n=this.universalProvider)==null?void 0:n.session)==null?void 0:r.namespaces)||{}),s=this.chainNamespaces.map(async i=>{var u,h,p,g,f;const o=this.getAdapter(i);if(!o)return;const a=((g=(p=(h=(u=this.universalProvider)==null?void 0:u.session)==null?void 0:h.namespaces)==null?void 0:p[i])==null?void 0:g.accounts)||[],c=(f=E.state.activeCaipNetwork)==null?void 0:f.id,l=a.find(w=>{const{chainId:v}=dt.parseCaipAddress(w);return v===(c==null?void 0:c.toString())})||a[0];if(l){const w=dt.validateCaipAddress(l),{chainId:v,address:N}=dt.parseCaipAddress(w);if(He.setProviderId(i,Lt.CONNECTOR_TYPE_WALLET_CONNECT),this.caipNetworks&&E.state.activeCaipNetwork&&o.namespace!==U.CHAIN.EVM){const A=o.getWalletConnectProvider({caipNetworks:this.getCaipNetworks(),provider:this.universalProvider,activeCaipNetwork:E.state.activeCaipNetwork});He.setProvider(i,A)}else He.setProvider(i,this.universalProvider);V.setConnectorId(U.CONNECTOR_ID.WALLET_CONNECT,i),F.addConnectedNamespace(i),await this.syncAccount({address:N,chainId:v,chainNamespace:i})}else e.includes(i)&&this.setStatus("disconnected",i);const d=this.getApprovedCaipNetworksData();this.syncConnectedWalletInfo(i),E.setApprovedCaipNetworksData(i,{approvedCaipNetworkIds:d.approvedCaipNetworkIds,supportsAllNetworks:d.supportsAllNetworks})});await Promise.all(s)}syncProvider({type:e,provider:s,id:n,chainNamespace:r}){He.setProviderId(r,e),He.setProvider(r,s),V.setConnectorId(n,r)}async syncAccount(e){var u,h;const s=e.chainNamespace===E.state.activeChain,n=E.getCaipNetworkByNamespace(e.chainNamespace,e.chainId),{address:r,chainId:i,chainNamespace:o}=e,{chainId:a}=F.getActiveNetworkProps(),c=(n==null?void 0:n.id)||a,l=((u=E.state.activeCaipNetwork)==null?void 0:u.name)===U.UNSUPPORTED_NETWORK_NAME,d=E.getNetworkProp("supportsAllNetworks",o);if(this.setStatus("connected",o),!(l&&!d)&&c){let p=this.getCaipNetworks().find(v=>v.id.toString()===c.toString()),g=this.getCaipNetworks().find(v=>v.chainNamespace===o);if(!d&&!p&&!g){const v=this.getApprovedCaipNetworkIds()||[],N=v.find(_=>{var P;return((P=dt.parseCaipNetworkId(_))==null?void 0:P.chainId)===c.toString()}),A=v.find(_=>{var P;return((P=dt.parseCaipNetworkId(_))==null?void 0:P.chainNamespace)===o});p=this.getCaipNetworks().find(_=>_.caipNetworkId===N),g=this.getCaipNetworks().find(_=>_.caipNetworkId===A||"deprecatedCaipNetworkId"in _&&_.deprecatedCaipNetworkId===A)}const f=p||g;(f==null?void 0:f.chainNamespace)===E.state.activeChain?$.state.enableNetworkSwitch&&!$.state.allowUnsupportedChain&&((h=E.state.activeCaipNetwork)==null?void 0:h.name)===U.UNSUPPORTED_NETWORK_NAME?E.showUnsupportedChainUI():this.setCaipNetwork(f):s||n&&this.setCaipNetworkOfNamespace(n,o),this.syncConnectedWalletInfo(o);const w=this.getAddress(o);wo.isLowerCaseMatch(r,w)||this.syncAccountInfo(r,f==null?void 0:f.id,o),s?await this.syncBalance({address:r,chainId:f==null?void 0:f.id,chainNamespace:o}):await this.syncBalance({address:r,chainId:n==null?void 0:n.id,chainNamespace:o}),this.syncIdentity({address:r,chainId:i,chainNamespace:o})}}async syncAccountInfo(e,s,n){const r=this.getCaipAddress(n),i=s||(r==null?void 0:r.split(":")[1]);if(!i)return;const o=`${n}:${i}:${e}`;this.setCaipAddress(o,n,!0),await this.syncIdentity({address:e,chainId:i,chainNamespace:n})}async syncReownName(e,s){try{const n=await this.getReownName(e);if(n[0]){const r=n[0];this.setProfileName(r.name,s)}else this.setProfileName(null,s)}catch{this.setProfileName(null,s)}}syncConnectedWalletInfo(e){var r;const s=V.getConnectorId(e),n=He.getProviderId(e);if(n===Lt.CONNECTOR_TYPE_ANNOUNCED||n===Lt.CONNECTOR_TYPE_INJECTED){if(s){const o=this.getConnectors().find(a=>{var u,h;const c=a.id===s,l=((u=a.info)==null?void 0:u.rdns)===s,d=(h=a.connectors)==null?void 0:h.some(p=>{var g;return p.id===s||((g=p.info)==null?void 0:g.rdns)===s});return c||l||!!d});if(o){const{info:a,name:c,imageUrl:l}=o,d=l||this.getConnectorImage(o);this.setConnectedWalletInfo({name:c,icon:d,...a},e)}}}else if(n===Lt.CONNECTOR_TYPE_WALLET_CONNECT){const i=He.getProvider(e);i!=null&&i.session&&this.setConnectedWalletInfo({...i.session.peer.metadata,name:i.session.peer.metadata.name,icon:(r=i.session.peer.metadata.icons)==null?void 0:r[0]},e)}else if(s&&(s===U.CONNECTOR_ID.COINBASE_SDK||s===U.CONNECTOR_ID.COINBASE)){const i=this.getConnectors().find(l=>l.id===s),o=(i==null?void 0:i.name)||"Coinbase Wallet",a=(i==null?void 0:i.imageUrl)||this.getConnectorImage(i),c=i==null?void 0:i.info;this.setConnectedWalletInfo({...c,name:o,icon:a},e)}}async syncBalance(e){!yf.getNetworksByNamespace(this.getCaipNetworks(),e.chainNamespace).find(n=>{var r;return n.id.toString()===((r=e.chainId)==null?void 0:r.toString())})||!e.chainId||await this.updateNativeBalance(e.address,e.chainId,e.chainNamespace)}async ready(){await this.readyPromise}async updateNativeBalance(e,s,n){const r=this.getAdapter(n),i=E.getCaipNetworkByNamespace(n,s);if(r){const o=await r.getBalance({address:e,chainId:s,caipNetwork:i,tokens:this.options.tokens});return this.setBalance(o.balance,o.symbol,n),o}}async initializeUniversalAdapter(){var r,i,o,a,c,l,d,u,h,p;const e=Hx.createLogger((g,...f)=>{g&&this.handleAlertError(g),console.error(...f)}),s={projectId:(r=this.options)==null?void 0:r.projectId,metadata:{name:(i=this.options)!=null&&i.metadata?(o=this.options)==null?void 0:o.metadata.name:"",description:(a=this.options)!=null&&a.metadata?(c=this.options)==null?void 0:c.metadata.description:"",url:(l=this.options)!=null&&l.metadata?(d=this.options)==null?void 0:d.metadata.url:"",icons:(u=this.options)!=null&&u.metadata?(h=this.options)==null?void 0:h.metadata.icons:[""]},logger:e};$.setManualWCControl(!!((p=this.options)!=null&&p.manualWCControl)),this.universalProvider=this.options.universalProvider??await ux.init(s);const n=this.universalProvider.disconnect.bind(this.universalProvider);this.universalProvider.disconnect=async()=>{try{return await n()}catch(g){if(g instanceof Error&&g.message.includes("Missing or invalid. Record was recently deleted"))return;throw g}},$.state.enableReconnect===!1&&this.universalProvider.session&&await this.universalProvider.disconnect(),this.listenWalletConnect()}listenWalletConnect(){this.universalProvider&&this.chainNamespaces.forEach(e=>{zn.listenWcProvider({universalProvider:this.universalProvider,namespace:e,onDisplayUri:s=>{G.setUri(s)},onConnect:s=>{const{address:n}=X.getAccount(s[0]);G.finalizeWcConnection(n)},onDisconnect:()=>{E.state.noAdapters&&this.resetAccount(e),G.resetWcConnection()},onChainChanged:s=>{const n=E.state.activeChain,r=n&&V.state.activeConnectorIds[n]===U.CONNECTOR_ID.WALLET_CONNECT;if(n===e&&(E.state.noAdapters||r)){const i=this.getCaipNetworks().find(a=>a.id.toString()===s.toString()||a.caipNetworkId.toString()===s.toString()),o=this.getCaipNetwork();if(!i){this.setUnsupportedNetwork(s);return}(o==null?void 0:o.id.toString())!==(i==null?void 0:i.id.toString())&&(o==null?void 0:o.chainNamespace)===(i==null?void 0:i.chainNamespace)&&this.setCaipNetwork(i)}},onAccountsChanged:s=>{const n=E.state.activeChain,r=n&&V.state.activeConnectorIds[n]===U.CONNECTOR_ID.WALLET_CONNECT;if(n===e&&(E.state.noAdapters||r)){const i=s==null?void 0:s[0];i&&this.syncAccount({address:i.address,chainId:i.chainId,chainNamespace:i.chainNamespace})}}})})}createUniversalProvider(){var e;return!this.universalProviderInitPromise&&X.isClient()&&((e=this.options)!=null&&e.projectId)&&(this.universalProviderInitPromise=this.initializeUniversalAdapter()),this.universalProviderInitPromise}async getUniversalProvider(){if(!this.universalProvider)try{await this.createUniversalProvider()}catch(e){Ee.sendEvent({type:"error",event:"INTERNAL_SDK_ERROR",properties:{errorType:"UniversalProviderInitError",errorMessage:e instanceof Error?e.message:"Unknown",uncaught:!1}}),console.error("AppKit:getUniversalProvider - Cannot create provider",e)}return this.universalProvider}getDisabledCaipNetworks(){const e=E.getAllApprovedCaipNetworkIds(),s=E.getAllRequestedCaipNetworks();return X.sortRequestedNetworks(e,s).filter(r=>E.isCaipNetworkDisabled(r))}handleAlertError(e){const s=Object.entries(Pt.UniversalProviderErrors).find(([,{message:a}])=>e.message.includes(a)),[n,r]=s??[],{message:i,alertErrorKey:o}=r??{};if(n&&i&&!this.reportedAlertErrors[n]){const a=Pt.ALERT_ERRORS[o];a&&(Ot.open(a,"error"),this.reportedAlertErrors[n]=!0)}}getAdapter(e){var s;if(e)return(s=this.chainAdapters)==null?void 0:s[e]}createAdapter(e){var r,i;if(!e)return;const s=e.namespace;if(!s)return;this.createClients();const n=e;n.namespace=s,n.construct({namespace:s,projectId:(r=this.options)==null?void 0:r.projectId,networks:(i=this.caipNetworks)==null?void 0:i.filter(({chainNamespace:o})=>o===s)}),this.chainNamespaces.includes(s)||this.chainNamespaces.push(s),this.chainAdapters&&(this.chainAdapters[s]=n)}async open(e){await this.injectModalUi(),e!=null&&e.uri&&G.setUri(e.uri);const{isSwap:s,isSend:n}=this.toModalOptions();return s(e)?Te.open({...e,data:{swap:e.arguments}}):n(e)&&e.arguments?this.openSend(e.arguments):Te.open(e)}async close(){await this.injectModalUi(),Te.close()}setLoading(e,s){Te.setLoading(e,s)}async disconnect(e){await G.disconnect({namespace:e})}getSIWX(){return $.state.siwx}getError(){return""}getChainId(){var e;return(e=E.state.activeCaipNetwork)==null?void 0:e.id}async switchNetwork(e,{throwOnFailure:s=!1}={}){const n=this.getCaipNetworks().find(r=>r.id===e.id);if(!n){Ot.open(Pt.ALERT_ERRORS.SWITCH_NETWORK_NOT_FOUND,"error");return}await E.switchActiveNetwork(n,{throwOnFailure:s})}getWalletProvider(){return E.state.activeChain?He.state.providers[E.state.activeChain]:null}getWalletProviderType(){return He.getProviderId(E.state.activeChain)}subscribeProviders(e){return He.subscribeProviders(e)}getThemeMode(){return Kt.state.themeMode}getThemeVariables(){return Kt.state.themeVariables}setThemeMode(e){Kt.setThemeMode(e),gd(Kt.state.themeMode)}setTermsConditionsUrl(e){$.setTermsConditionsUrl(e)}setPrivacyPolicyUrl(e){$.setPrivacyPolicyUrl(e)}setThemeVariables(e){Kt.setThemeVariables(e),Ek(Kt.state.themeVariables)}subscribeTheme(e){return Kt.subscribe(e)}subscribeConnections(e){return this.remoteFeatures.multiWallet?G.subscribe(e):(Ot.open(U.REMOTE_FEATURES_ALERTS.MULTI_WALLET_NOT_ENABLED.DEFAULT,"info"),()=>{})}getWalletInfo(e){var n,r;if(e)return(r=(n=E.state.chains.get(e))==null?void 0:n.accountState)==null?void 0:r.connectedWalletInfo;const s=E.getAccountData();return s==null?void 0:s.connectedWalletInfo}getAccount(e){const s=e||E.state.activeChain,n=V.getAuthConnector(s),r=E.getAccountData(s),i=F.getConnectedConnectorId(E.state.activeChain),o=G.getConnections(s);if(!s)throw new Error("AppKit:getAccount - namespace is required");const a=o.flatMap(c=>c.accounts.map(({address:l,type:d,publicKey:u})=>X.createAccount(s,l,d||"eoa",u)));if(r)return{allAccounts:a,caipAddress:r.caipAddress,address:X.getPlainAddress(r.caipAddress),isConnected:!!r.caipAddress,status:r.status,embeddedWalletInfo:n&&i===U.CONNECTOR_ID.AUTH?{user:r.user?{...r.user,username:F.getConnectedSocialUsername()}:void 0,authProvider:r.socialProvider||"email",accountType:ls(s),isSmartAccountDeployed:!!r.smartAccountDeployed}:void 0}}subscribeAccount(e,s){const n=()=>{const r=this.getAccount(s);r&&e(r)};s?E.subscribeChainProp("accountState",n,s):E.subscribe(n),V.subscribe(n)}subscribeNetwork(e){return E.subscribe(({activeCaipNetwork:s})=>{e({caipNetwork:s,chainId:s==null?void 0:s.id,caipNetworkId:s==null?void 0:s.caipNetworkId})})}subscribeWalletInfo(e,s){return s?E.subscribeChainProp("accountState",n=>e(n==null?void 0:n.connectedWalletInfo),s):E.subscribeChainProp("accountState",n=>e(n==null?void 0:n.connectedWalletInfo))}subscribeShouldUpdateToAddress(e){E.subscribeChainProp("accountState",s=>e(s==null?void 0:s.shouldUpdateToAddress))}subscribeCaipNetworkChange(e){E.subscribeKey("activeCaipNetwork",e)}getState(){return ds.state}getRemoteFeatures(){return $.state.remoteFeatures}subscribeState(e){return ds.subscribe(e)}subscribeRemoteFeatures(e){return $.subscribeKey("remoteFeatures",e)}showErrorMessage(e){zs.showError(e)}showSuccessMessage(e){zs.showSuccess(e)}getEvent(){return{...Ee.state}}subscribeEvents(e){return Ee.subscribe(e)}replace(e){ue.replace(e)}redirect(e){ue.push(e)}popTransactionStack(e){ue.popTransactionStack(e)}isOpen(){return Te.state.open}isTransactionStackEmpty(){return ue.state.transactionStack.length===0}static getInstance(){return this.instance}updateFeatures(e){$.setFeatures(e)}updateRemoteFeatures(e){$.setRemoteFeatures(e)}updateOptions(e){const n={...$.state||{},...e};$.setOptions(n)}setConnectMethodsOrder(e){$.setConnectMethodsOrder(e)}setWalletFeaturesOrder(e){$.setWalletFeaturesOrder(e)}setCollapseWallets(e){$.setCollapseWallets(e)}setSocialsOrder(e){$.setSocialsOrder(e)}getConnectMethodsOrder(){return Hn.getConnectOrderMethod($.state.features,V.getConnectors())}addNetwork(e,s){if(this.chainAdapters&&!this.chainAdapters[e])throw new Error(`Adapter for namespace ${e} doesn't exist`);const n=this.extendCaipNetwork(s,this.options);this.getCaipNetworks().find(r=>r.id===n.id)||E.addNetwork(n)}removeNetwork(e,s){if(this.chainAdapters&&!this.chainAdapters[e])throw new Error(`Adapter for namespace ${e} doesn't exist`);this.getCaipNetworks().find(r=>r.id===s)&&E.removeNetwork(e,s)}}let hf=!1;class dy extends _k{async onAuthProviderConnected(e){const s=wo.userChainIdToChainNamespace(e==null?void 0:e.chainId);if(e.message&&e.signature&&e.siwxMessage&&await vs.addEmbeddedWalletSession({chainId:e.siwxMessage.chainId,accountAddress:e.address,notBefore:e.siwxMessage.notBefore,statement:e.siwxMessage.statement,resources:e.siwxMessage.resources,requestId:e.siwxMessage.requestId,issuedAt:e.siwxMessage.issuedAt,domain:e.siwxMessage.domain,uri:e.siwxMessage.uri,version:e.siwxMessage.version,nonce:e.siwxMessage.nonce},e.message,e.signature),!s)throw new Error("AppKit:onAuthProviderConnected - namespace is required");const n=s===U.CHAIN.EVM?`eip155:${e.chainId}:${e.address}`:`${e.chainId}:${e.address}`,r=$.state.defaultAccountTypes[s],i=ls(s),o=e.preferredAccountType||i||r;this.setCaipAddress(n,s);const{signature:a,siwxMessage:c,message:l,...d}=e,u=E.getAccountData(s);this.setUser({...(u==null?void 0:u.user)||{},...d},s),this.setSmartAccountDeployed(!!e.smartAccountDeployed,s),this.setPreferredAccountType(o,s),await Promise.all([this.syncAuthConnectorTheme(this.authProvider),this.syncAccount({address:e.address,chainId:e.chainId,chainNamespace:s})]),this.setLoading(!1,s)}setupAuthConnectorListeners(e){e.onRpcRequest(s=>{cs.checkIfRequestExists(s)?cs.checkIfRequestIsSafe(s)||this.handleUnsafeRPCRequest():(this.open(),console.error(tt.RPC_METHOD_NOT_ALLOWED_MESSAGE,{method:s.method}),setTimeout(()=>{this.showErrorMessage(tt.RPC_METHOD_NOT_ALLOWED_UI_MESSAGE)},300),e.rejectRpcRequests())}),e.onRpcError(()=>{this.isOpen()&&(this.isTransactionStackEmpty()?this.close():this.popTransactionStack("error"))}),e.onRpcSuccess((s,n)=>{const r=cs.checkIfRequestIsSafe(n),i=this.getAddress(),o=E.state.activeCaipNetwork;r||(i&&(o!=null&&o.id)&&this.updateNativeBalance(i,o.id,o.chainNamespace),this.isTransactionStackEmpty()?this.close():this.popTransactionStack("success"))}),e.onNotConnected(()=>{const s=E.state.activeChain;if(!s)throw new Error("AppKit:onNotConnected - namespace is required");V.getConnectorId(s)===U.CONNECTOR_ID.AUTH&&(this.setCaipAddress(null,s),this.setLoading(!1,s))}),e.onConnect(this.onAuthProviderConnected.bind(this)),e.onSocialConnected(this.onAuthProviderConnected.bind(this)),e.onSetPreferredAccount(({address:s,type:n})=>{const r=E.state.activeChain;if(!r)throw new Error("AppKit:onSetPreferredAccount - namespace is required");s&&this.setPreferredAccountType(n,r)})}async syncAuthConnectorTheme(e){if(!e)return;const s=Kt.getSnapshot();await e.syncTheme({themeMode:s.themeMode,themeVariables:s.themeVariables,w3mThemeVariables:Zi(s.themeVariables,s.themeMode)})}async syncAuthConnector(e,s){var d,u,h,p,g,f,w,v,N;const n=U.AUTH_CONNECTOR_SUPPORTED_CHAINS.includes(s),r=s===E.state.activeChain;if(!n)return;this.setLoading(!0,s);const i=e.getLoginEmailUsed();this.setLoading(i,s),i&&this.setStatus("connecting",s);const o=e.getEmail(),a=e.getUsername(),c=((d=E.getAccountData(s))==null?void 0:d.user)||{};this.setUser({...c,username:a,email:o},s),this.setupAuthConnectorListeners(e);const{isConnected:l}=await e.isConnected();if(s&&n&&r)if(l&&((u=this.connectionControllerClient)!=null&&u.connectExternal)){await e.init(),await this.syncAuthConnectorTheme(e),await((g=this.connectionControllerClient)==null?void 0:g.connectExternal({id:U.CONNECTOR_ID.AUTH,info:{name:U.CONNECTOR_ID.AUTH},type:Lt.CONNECTOR_TYPE_AUTH,provider:e,chainId:(p=(h=E.getNetworkData(s))==null?void 0:h.caipNetwork)==null?void 0:p.id,chain:s})),this.setStatus("connected",s);const A=F.getConnectedSocialProvider();A?Ee.sendEvent({type:"track",event:"SOCIAL_LOGIN_SUCCESS",address:this.getAddress(),properties:{provider:A,reconnect:!0}}):Ee.sendEvent({type:"track",event:"CONNECT_SUCCESS",address:this.getAddress(),properties:{method:"email",name:((N=(v=(w=(f=this.universalProvider)==null?void 0:f.session)==null?void 0:w.peer)==null?void 0:v.metadata)==null?void 0:N.name)||"Unknown",reconnect:!0,view:ue.state.view,walletRank:void 0}})}else V.getConnectorId(s)===U.CONNECTOR_ID.AUTH&&(this.setStatus("disconnected",s),F.removeConnectedNamespace(s));this.setLoading(!1,s)}async checkExistingTelegramSocialConnection(e){var s;try{if(!X.isTelegram())return;const n=F.getTelegramSocialProvider();if(!n||!X.isClient())return;const i=new URL(window.location.href).searchParams.get("result_uri");if(!i)return;n&&E.setAccountProp("socialProvider",n,e),await((s=this.authProvider)==null?void 0:s.init());const o=V.getAuthConnector();n&&o&&(this.setLoading(!0,e),await G.connectExternal({id:o.id,type:o.type,socialUri:i},o.chain),F.setConnectedSocialProvider(n),F.removeTelegramSocialProvider(),Ee.sendEvent({type:"track",event:"SOCIAL_LOGIN_SUCCESS",properties:{provider:n}}))}catch(n){this.setLoading(!1,e),console.error("checkExistingSTelegramocialConnection error",n)}try{const n=new URL(window.location.href);n.searchParams.delete("result_uri"),window.history.replaceState({},document.title,n.toString())}catch(n){console.error("tma social login failed",n)}}createAuthProvider(e){var l,d,u,h;if(!U.AUTH_CONNECTOR_SUPPORTED_CHAINS.includes(e))return;const n=(l=this.remoteFeatures)==null?void 0:l.email,r=Array.isArray((d=this.remoteFeatures)==null?void 0:d.socials)&&this.remoteFeatures.socials.length>0,i=n||r,a=wo.getActiveNamespaceConnectedToAuth()||e;!this.authProvider&&((u=this.options)!=null&&u.projectId)&&i&&(this.authProvider=Vi.getInstance({projectId:this.options.projectId,enableLogger:this.options.enableAuthLogger,chainId:(h=this.getCaipNetwork(a))==null?void 0:h.caipNetworkId,abortController:Pt.EmbeddedWalletAbortController,onTimeout:p=>{p==="iframe_load_failed"?Ot.open(Pt.ALERT_ERRORS.IFRAME_LOAD_FAILED,"error"):p==="iframe_request_timeout"?Ot.open(Pt.ALERT_ERRORS.IFRAME_REQUEST_TIMEOUT,"error"):p==="unverified_domain"&&Ot.open(Pt.ALERT_ERRORS.UNVERIFIED_DOMAIN,"error")},getActiveCaipNetwork:p=>ki(p),getCaipNetworks:p=>E.getCaipNetworks(p)}),ds.subscribeOpen(p=>{var g;!p&&this.isTransactionStackEmpty()&&((g=this.authProvider)==null||g.rejectRpcRequests())}));const c=e===E.state.activeChain&&$.state.enableReconnect;$.state.enableReconnect===!1?this.syncAuthConnectorTheme(this.authProvider):this.authProvider&&c&&(this.syncAuthConnector(this.authProvider,e),this.checkExistingTelegramSocialConnection(e))}createAuthProviderForAdapter(e){var s,n,r;this.createAuthProvider(e),this.authProvider&&((r=(n=(s=this.chainAdapters)==null?void 0:s[e])==null?void 0:n.setAuthProvider)==null||r.call(n,this.authProvider))}initControllers(e){super.initControllers(e),this.options.excludeWalletIds&&te.initializeExcludedWallets({ids:this.options.excludeWalletIds})}async switchCaipNetwork(e){var o,a,c;if(!e)return;const s=E.state.activeChain,n=e.chainNamespace,r=this.getAddressByChainNamespace(n);if(n===s&&((o=E.getAccountData(n))!=null&&o.caipAddress)){const l=this.getAdapter(n);await(l==null?void 0:l.switchNetwork({caipNetwork:e})),this.setCaipNetwork(e)}else{const d=He.getProviderId(s)===Lt.CONNECTOR_TYPE_AUTH,u=He.getProviderId(n),h=u===Lt.CONNECTOR_TYPE_AUTH,p=U.AUTH_CONNECTOR_SUPPORTED_CHAINS.includes(n);if(!n)throw new Error("AppKit:switchCaipNetwork - networkNamespace is required");if((d&&u===void 0||h)&&p)try{if(E.state.activeChain=e.chainNamespace,r){const g=this.getAdapter(n);await(g==null?void 0:g.switchNetwork({caipNetwork:e}))}else await((c=(a=this.connectionControllerClient)==null?void 0:a.connectExternal)==null?void 0:c.call(a,{id:U.CONNECTOR_ID.AUTH,provider:this.authProvider,chain:n,chainId:e.id,type:Lt.CONNECTOR_TYPE_AUTH,caipNetwork:e}));this.setCaipNetwork(e)}catch{const f=this.getAdapter(n);await(f==null?void 0:f.switchNetwork({caipNetwork:e}))}else if(u===Lt.CONNECTOR_TYPE_WALLET_CONNECT){if(!E.state.noAdapters){const g=this.getAdapter(n);await(g==null?void 0:g.switchNetwork({caipNetwork:e}))}this.setCaipNetwork(e),this.syncWalletConnectAccount()}else this.setCaipNetwork(e),r&&this.syncAccount({address:r,chainId:e.id,chainNamespace:n})}}async initialize(e){var s;await super.initialize(e),(s=this.chainNamespaces)==null||s.forEach(n=>{this.createAuthProviderForAdapter(n)}),await this.injectModalUi(),ds.set({initialized:!0})}async syncIdentity({address:e,chainId:s,chainNamespace:n}){var a;const r=`${n}:${s}`,i=(a=this.caipNetworks)==null?void 0:a.find(c=>c.caipNetworkId===r);if(i!=null&&i.testnet){this.setProfileName(null,n),this.setProfileImage(null,n);return}const o=V.getConnectorId(n)===U.CONNECTOR_ID.AUTH;try{const{name:c,avatar:l}=await this.fetchIdentity({address:e});!c&&o?await this.syncReownName(e,n):(this.setProfileName(c,n),this.setProfileImage(l,n))}catch{s!==1&&this.setProfileImage(null,n)}}syncConnectedWalletInfo(e){const s=He.getProviderId(e);if(s===Lt.CONNECTOR_TYPE_AUTH){const n=this.authProvider;if(n){const r=F.getConnectedSocialProvider()??"email",i=n.getEmail()??n.getUsername();this.setConnectedWalletInfo({name:s,identifier:i,social:r},e)}}else super.syncConnectedWalletInfo(e)}async injectModalUi(){if(X.isClient()&&!hf)try{const e={...Ne.DEFAULT_FEATURES,...this.options.features},s=this.remoteFeatures;if(await this.loadModalComponents(e,s),X.isClient()&&!document.querySelector("w3m-modal")){const r=document.createElement("w3m-modal");!$.state.disableAppend&&!$.state.enableEmbedded&&document.body.insertAdjacentElement("beforeend",r)}hf=!0}catch(e){console.error("Error injecting modal UI:",e)}}async loadModalComponents(e,s){if(!X.isClient())return;const n=[];(s.email||s.socials&&s.socials.length>0)&&n.push(Dt(()=>import("./embedded-wallet-BUpVqq4X.js"),__vite__mapDeps([11,12,3,13,14,2,15,16,17,18,19,20,21,22,23,24,5,6,7,8,9]))),s.email&&n.push(Dt(()=>import("./email-ChOw_WX1.js"),__vite__mapDeps([25,12,3,26,23,16,22,14,15,21,27,19,2,5,6,7,8,9]))),s.socials&&n.push(Dt(()=>import("./socials-wRT8srTH.js"),__vite__mapDeps([28,12,3,14,29,15,30,2,22,31,18,21,16,32,13,5,6,7,8,9,33]))),s.swaps&&s.swaps.length>0&&n.push(Dt(()=>import("./swaps-DvC4Fti7.js"),__vite__mapDeps([34,12,3,21,16,22,14,35,36,37,2,33,38,13,19,15,5,6,7,8,9]))),e.send&&n.push(Dt(()=>import("./send-BqOjZg08.js"),__vite__mapDeps([39,12,3,21,16,22,14,40,15,41,23,38,13,33,37,2,19,42,43,5,6,7,8,9]))),e.receive&&n.push(Dt(()=>import("./receive-BPjNw_Ia.js"),__vite__mapDeps([44,12,3,14,13,32,5,6,7,8,9,2]))),s.onramp&&s.onramp.length>0&&n.push(Dt(()=>import("./onramp-fYckWqyy.js"),__vite__mapDeps([45,12,3,14,46,16,29,15,13,47,48,23,21,22,31,19,2,5,6,7,8,9]))),s.payWithExchange&&n.push(Dt(()=>import("./pay-with-exchange-BpCbG70P.js"),__vite__mapDeps([49,12,3,14,13,20,46,16,33,21,41,15,23,50,22,19,42,40,2,5,6,7,8,9]))),s.activity&&n.push(Dt(()=>import("./transactions-DJELlSxG.js"),__vite__mapDeps([51,12,3,52,6,7,8,22,14,23,13,33,2,5,9]))),(e.pay||s.payments)&&n.push(Dt(()=>import("./index-BDnUYgwY.js"),__vite__mapDeps([53,12,3,14,21,16,54,20,13,46,55,40,56,22,2,31,5,6,7,8,9]))),s.emailCapture&&n.push(Dt(()=>import("./data-capture-wqIUqrux.js"),__vite__mapDeps([57,12,3,26,23,16,10,2,5,6,7,8,9]))),await Promise.all([...n,Dt(()=>import("./index-DXVxAJsf.js"),__vite__mapDeps([58,12,3,14,13,16,43,22,59,48,23,17,18,2,56,20,46,21,50,52,6,7,8,33,42,35,36,40,15,19,55,27,29,30,31,32,5,9,24,47])),Dt(()=>import("./w3m-modal-BQ_U0Js5.js"),__vite__mapDeps([60,12,3,14,54,13,17,18,2,16,22,36,59,48,23,56,37,21,5,6,7,8,9]))])}}const Ak="1.8.15";function Sk(t){return new dy({...t,sdkVersion:X.generateSdkVersion(t.adapters??[],"html",Ak)})}const w2=Object.freeze(Object.defineProperty({__proto__:null,AppKit:dy,CoreHelperUtil:X,WcConstantsUtil:Li,createAppKit:Sk},Symbol.toStringTag,{value:"Module"}));export{Hi as $,yt as A,fe as B,E as C,p2 as D,Ee as E,Qi as F,F as G,cs as H,ae as I,le as J,Lt as K,te as L,Te as M,Yy as N,$ as O,lv as P,Pt as Q,ue as R,zs as S,Kt as T,dt as U,He as V,tt as W,Qy as X,Zi as Y,lt as Z,Ae as _,X as a,Rl as a0,bs as a1,Tr as a2,gn as a3,ha as a4,vs as a5,g2 as a6,qf as a7,ry as a8,pd as a9,hi as aa,Df as ab,uv as ac,dv as ad,Lf as ae,Lu as af,wv as ag,Vo as ah,bv as ai,gv as aj,Ps as ak,Ua as al,wo as am,Hn as an,Gr as ao,zv as ap,ki as aq,w2 as ar,o2 as b,i2 as c,Ne as d,Ff as e,c2 as f,a2 as g,l2 as h,_t as i,f2 as j,y2 as k,ba as l,h2 as m,qn as n,G as o,Ge as p,ls as q,m2 as r,At as s,Hv as t,Ot as u,wk as v,As as w,_d as x,V as y,Bf as z};
|
|
248
|
+
`,Li={ERROR_CODE_UNRECOGNIZED_CHAIN_ID:4902,ERROR_CODE_DEFAULT:5e3,ERROR_INVALID_CHAIN_ID:32603};class bk extends bx{async setUniversalProvider(e){if(!this.namespace)throw new Error("UniversalAdapter:setUniversalProvider - namespace is required");return this.addConnector(new vx({provider:e,caipNetworks:this.getCaipNetworks(),namespace:this.namespace})),Promise.resolve()}async connect(e){return Promise.resolve({id:"WALLET_CONNECT",type:"WALLET_CONNECT",chainId:Number(e.chainId),provider:this.provider,address:""})}async disconnect(){try{await this.getWalletConnectConnector().disconnect(),this.emit("disconnect")}catch(e){console.warn("UniversalAdapter:disconnect - error",e)}return{connections:[]}}syncConnections(){return Promise.resolve()}async getAccounts({namespace:e}){var r,i,o,a;const s=this.provider,n=((a=(o=(i=(r=s==null?void 0:s.session)==null?void 0:r.namespaces)==null?void 0:i[e])==null?void 0:o.accounts)==null?void 0:a.map(c=>{const[,,l]=c.split(":");return l}).filter((c,l,d)=>d.indexOf(c)===l))||[];return Promise.resolve({accounts:n.map(c=>X.createAccount(e,c,e==="bip122"?"payment":"eoa"))})}async syncConnectors(){return Promise.resolve()}async getBalance(e){var o,a,c,l,d;if(!(e.caipNetwork&&Ne.BALANCE_SUPPORTED_CHAINS.includes((o=e.caipNetwork)==null?void 0:o.chainNamespace))||(a=e.caipNetwork)!=null&&a.testnet)return{balance:"0.00",symbol:((c=e.caipNetwork)==null?void 0:c.nativeCurrency.symbol)||""};const n=E.getAccountData();if(n!=null&&n.balanceLoading&&e.chainId===((l=E.state.activeCaipNetwork)==null?void 0:l.id))return{balance:(n==null?void 0:n.balance)||"0.00",symbol:(n==null?void 0:n.balanceSymbol)||""};const i=(await E.fetchTokenBalance()).find(u=>{var h,p;return u.chainId===`${(h=e.caipNetwork)==null?void 0:h.chainNamespace}:${e.chainId}`&&u.symbol===((p=e.caipNetwork)==null?void 0:p.nativeCurrency.symbol)});return{balance:(i==null?void 0:i.quantity.numeric)||"0.00",symbol:(i==null?void 0:i.symbol)||((d=e.caipNetwork)==null?void 0:d.nativeCurrency.symbol)||""}}async signMessage(e){var o,a,c;const{provider:s,message:n,address:r}=e;if(!s)throw new Error("UniversalAdapter:signMessage - provider is undefined");let i="";return((o=E.state.activeCaipNetwork)==null?void 0:o.chainNamespace)===U.CHAIN.SOLANA?i=(await s.request({method:"solana_signMessage",params:{message:gi.encode(new TextEncoder().encode(n)),pubkey:r}},(a=E.state.activeCaipNetwork)==null?void 0:a.caipNetworkId)).signature:i=await s.request({method:"personal_sign",params:[n,r]},(c=E.state.activeCaipNetwork)==null?void 0:c.caipNetworkId),{signature:i}}async estimateGas(){return Promise.resolve({gas:BigInt(0)})}async sendTransaction(){return Promise.resolve({hash:""})}walletGetAssets(e){return Promise.resolve({})}async writeContract(){return Promise.resolve({hash:""})}emitFirstAvailableConnection(){}parseUnits(){return 0n}formatUnits(){return"0"}async getCapabilities(){return Promise.resolve({})}async grantPermissions(){return Promise.resolve({})}async revokePermissions(){return Promise.resolve("0x")}async syncConnection(){return Promise.resolve({id:"WALLET_CONNECT",type:"WALLET_CONNECT",chainId:1,provider:this.provider,address:""})}async switchNetwork(e){var r,i,o,a,c,l;const{caipNetwork:s}=e,n=this.getWalletConnectConnector();if(s.chainNamespace===U.CHAIN.EVM)try{await((r=n.provider)==null?void 0:r.request({method:"wallet_switchEthereumChain",params:[{chainId:Eu(s.id)}]}))}catch(d){if(d.code===Li.ERROR_CODE_UNRECOGNIZED_CHAIN_ID||d.code===Li.ERROR_INVALID_CHAIN_ID||d.code===Li.ERROR_CODE_DEFAULT||((o=(i=d==null?void 0:d.data)==null?void 0:i.originalError)==null?void 0:o.code)===Li.ERROR_CODE_UNRECOGNIZED_CHAIN_ID)try{await((l=n.provider)==null?void 0:l.request({method:"wallet_addEthereumChain",params:[{chainId:Eu(s.id),rpcUrls:[(a=s==null?void 0:s.rpcUrls.chainDefault)==null?void 0:a.http],chainName:s.name,nativeCurrency:s.nativeCurrency,blockExplorerUrls:[(c=s.blockExplorers)==null?void 0:c.default.url]}]}))}catch{throw new Error("Chain is not supported")}}n.provider.setDefaultChain(s.caipNetworkId)}getWalletConnectProvider(){const e=this.connectors.find(n=>n.type==="WALLET_CONNECT");return e==null?void 0:e.provider}}const vk=["email","socials","swaps","onramp","activity","reownBranding","multiWallet","emailCapture","payWithExchange","payments","reownAuthentication","headless"],aa={email:{apiFeatureName:"social_login",localFeatureName:"email",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>{if(!(t!=null&&t.config))return!1;const e=t.config;return!!t.isEnabled&&e.includes("email")},processFallback:t=>t===void 0?Ne.DEFAULT_REMOTE_FEATURES.email:!!t},socials:{apiFeatureName:"social_login",localFeatureName:"socials",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>{if(!(t!=null&&t.config))return!1;const e=t.config;return t.isEnabled&&e.length>0?e.filter(s=>s!=="email"):!1},processFallback:t=>t===void 0?Ne.DEFAULT_REMOTE_FEATURES.socials:typeof t=="boolean"?t?Ne.DEFAULT_REMOTE_FEATURES.socials:!1:t},swaps:{apiFeatureName:"swap",localFeatureName:"swaps",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>{if(!(t!=null&&t.config))return!1;const e=t.config;return t.isEnabled&&e.length>0?e:!1},processFallback:t=>t===void 0?Ne.DEFAULT_REMOTE_FEATURES.swaps:typeof t=="boolean"?t?Ne.DEFAULT_REMOTE_FEATURES.swaps:!1:t},onramp:{apiFeatureName:"onramp",localFeatureName:"onramp",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>{if(!(t!=null&&t.config))return!1;const e=t.config;return t.isEnabled&&e.length>0?e:!1},processFallback:t=>t===void 0?Ne.DEFAULT_REMOTE_FEATURES.onramp:typeof t=="boolean"?t?Ne.DEFAULT_REMOTE_FEATURES.onramp:!1:t},activity:{apiFeatureName:"activity",localFeatureName:"history",returnType:!1,isLegacy:!0,isAvailableOnBasic:!1,processApi:t=>!!t.isEnabled,processFallback:t=>t===void 0?Ne.DEFAULT_REMOTE_FEATURES.activity:!!t},reownBranding:{apiFeatureName:"reown_branding",localFeatureName:"reownBranding",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>!!t.isEnabled,processFallback:t=>t===void 0?Ne.DEFAULT_REMOTE_FEATURES.reownBranding:!!t},emailCapture:{apiFeatureName:"email_capture",localFeatureName:"emailCapture",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>t.isEnabled&&(t.config??[]),processFallback:t=>!1},multiWallet:{apiFeatureName:"multi_wallet",localFeatureName:"multiWallet",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>!!t.isEnabled,processFallback:()=>Ne.DEFAULT_REMOTE_FEATURES.multiWallet},payWithExchange:{apiFeatureName:"fund_from_exchange",localFeatureName:"payWithExchange",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>!!t.isEnabled,processFallback:()=>Ne.DEFAULT_REMOTE_FEATURES.payWithExchange},payments:{apiFeatureName:"payments",localFeatureName:"payments",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>!!t.isEnabled,processFallback:()=>Ne.DEFAULT_REMOTE_FEATURES.payments},reownAuthentication:{apiFeatureName:"reown_authentication",localFeatureName:"reownAuthentication",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>!!t.isEnabled,processFallback:t=>typeof t>"u"?Ne.DEFAULT_REMOTE_FEATURES.reownAuthentication:!!t},headless:{apiFeatureName:"headless",localFeatureName:"headless",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>!!t.isEnabled,processFallback:()=>Ne.DEFAULT_REMOTE_FEATURES.headless}},Ck={localSettingsOverridden:new Set,getApiConfig(t,e){return e==null?void 0:e.find(s=>s.id===t)},addWarning(t,e){if(t!==void 0){const s=aa[e],n=s.isLegacy?`"features.${s.localFeatureName}" (now "${e}")`:`"features.${e}"`;this.localSettingsOverridden.add(n)}},processFeature(t,e,s,n,r){const i=aa[t],o=e[i.localFeatureName];if(r&&!i.isAvailableOnBasic)return!1;if(n){const a=this.getApiConfig(i.apiFeatureName,s);return(a==null?void 0:a.config)===null?this.processFallbackFeature(t,o):a!=null&&a.config?(o!==void 0&&this.addWarning(o,t),this.processApiFeature(t,a)):!1}return this.processFallbackFeature(t,o)},processApiFeature(t,e){return aa[t].processApi(e)},processFallbackFeature(t,e){return aa[t].processFallback(e)},async fetchRemoteFeatures(t){const e=t.basic??!1,s=t.features||{};this.localSettingsOverridden.clear();let n=null,r=!1;try{n=await te.fetchProjectConfig(),r=n!=null}catch(o){console.warn("[Reown Config] Failed to fetch remote project configuration. Using local/default values.",o)}const i=r&&!e?Ne.DEFAULT_REMOTE_FEATURES:Ne.DEFAULT_REMOTE_FEATURES_DISABLED;try{for(const o of vk){const a=this.processFeature(o,s,n,r,e);Object.assign(i,{[o]:a})}}catch(o){return console.warn("[Reown Config] Failed to process the configuration from Cloud. Using default values.",o),Ne.DEFAULT_REMOTE_FEATURES}if(r&&this.localSettingsOverridden.size>0){const o=`Your local configuration for ${Array.from(this.localSettingsOverridden).join(", ")} was ignored because a remote configuration was successfully fetched. Please manage these features via your project dashboard on dashboard.reown.com.`;Ot.open({debugMessage:Pt.ALERT_WARNINGS.LOCAL_CONFIGURATION_IGNORED.debugMessage(o)},"warning")}return i}};class _k{constructor(e){this.chainNamespaces=[],this.features={},this.remoteFeatures={},this.reportedAlertErrors={},this.getCaipNetwork=(s,n)=>{var r,i,o;if(s){const a=(r=E.getCaipNetworks(s))==null?void 0:r.find(d=>d.id===n);if(a)return a;const c=(i=E.getNetworkData(s))==null?void 0:i.caipNetwork;return c||((o=E.getRequestedCaipNetworks(s).filter(d=>d.chainNamespace===s))==null?void 0:o[0])}return E.state.activeCaipNetwork||this.defaultCaipNetwork},this.getCaipNetworkId=()=>{const s=this.getCaipNetwork();if(s)return s.id},this.getCaipNetworks=s=>E.getCaipNetworks(s),this.getActiveChainNamespace=()=>E.state.activeChain,this.setRequestedCaipNetworks=(s,n)=>{E.setRequestedCaipNetworks(s,n)},this.getApprovedCaipNetworkIds=()=>E.getAllApprovedCaipNetworkIds(),this.getCaipAddress=s=>{var n,r;return E.state.activeChain===s||!s?E.state.activeCaipAddress:(r=(n=E.state.chains.get(s))==null?void 0:n.accountState)==null?void 0:r.caipAddress},this.setClientId=s=>{fe.setClientId(s)},this.getProvider=s=>He.getProvider(s),this.getProviderType=s=>He.getProviderId(s),this.getPreferredAccountType=s=>ls(s),this.setCaipAddress=(s,n,r=!1)=>{E.setAccountProp("caipAddress",s,n,r),E.setAccountProp("address",X.getPlainAddress(s),n,r)},this.setBalance=(s,n,r)=>{E.setAccountProp("balance",s,r),E.setAccountProp("balanceSymbol",n,r)},this.setProfileName=(s,n)=>{E.setAccountProp("profileName",s,n)},this.setProfileImage=(s,n)=>{E.setAccountProp("profileImage",s,n)},this.setUser=(s,n)=>{E.setAccountProp("user",s,n)},this.resetAccount=s=>{E.resetAccount(s)},this.setCaipNetwork=s=>{E.setActiveCaipNetwork(s)},this.setCaipNetworkOfNamespace=(s,n)=>{E.setChainNetworkData(n,{caipNetwork:s})},this.setStatus=(s,n)=>{E.setAccountProp("status",s,n),V.isConnected()?F.setConnectionStatus("connected"):F.setConnectionStatus("disconnected")},this.getAddressByChainNamespace=s=>{var n;return(n=E.getAccountData(s))==null?void 0:n.address},this.setConnectors=s=>{const n=[...V.state.allConnectors,...s];V.setConnectors(n)},this.setConnections=(s,n)=>{F.setConnections(s,n),G.setConnections(s,n)},this.fetchIdentity=s=>fe.fetchIdentity(s),this.getReownName=s=>Hi.getNamesForAddress(s),this.getConnectors=()=>V.getConnectors(),this.getConnectorImage=s=>Bf.getConnectorImage(s),this.getConnections=s=>this.remoteFeatures.multiWallet?Ua.getConnectionsData(s).connections:(Ot.open(U.REMOTE_FEATURES_ALERTS.MULTI_WALLET_NOT_ENABLED.DEFAULT,"info"),[]),this.getRecentConnections=s=>this.remoteFeatures.multiWallet?Ua.getConnectionsData(s).recentConnections:(Ot.open(U.REMOTE_FEATURES_ALERTS.MULTI_WALLET_NOT_ENABLED.DEFAULT,"info"),[]),this.switchConnection=async s=>{if(!this.remoteFeatures.multiWallet){Ot.open(U.REMOTE_FEATURES_ALERTS.MULTI_WALLET_NOT_ENABLED.DEFAULT,"info");return}await G.switchConnection(s)},this.deleteConnection=s=>{if(!this.remoteFeatures.multiWallet){Ot.open(U.REMOTE_FEATURES_ALERTS.MULTI_WALLET_NOT_ENABLED.DEFAULT,"info");return}F.deleteAddressFromConnection(s),G.syncStorageConnections()},this.setConnectedWalletInfo=(s,n)=>{const r=He.getProviderId(n),i=s?{...s,type:r}:void 0;E.setAccountProp("connectedWalletInfo",i,n)},this.getIsConnectedState=()=>!!E.state.activeCaipAddress,this.addAddressLabel=(s,n,r)=>{var o;const i=((o=E.getAccountData(r))==null?void 0:o.addressLabels)||{};E.setAccountProp("addressLabels",{...i,[s]:n},r)},this.removeAddressLabel=(s,n)=>{var i;const r=((i=E.getAccountData(n))==null?void 0:i.addressLabels)||{};E.setAccountProp("addressLabels",{...r,[s]:void 0},n)},this.getAddress=s=>{var r;const n=s||E.state.activeChain;return(r=E.getAccountData(n))==null?void 0:r.address},this.resetNetwork=s=>{E.resetNetwork(s)},this.addConnector=s=>{V.addConnector(s)},this.resetWcConnection=()=>{G.resetWcConnection()},this.setAddressExplorerUrl=(s,n)=>{E.setAccountProp("addressExplorerUrl",s,n)},this.setSmartAccountDeployed=(s,n)=>{E.setAccountProp("smartAccountDeployed",s,n)},this.setPreferredAccountType=(s,n)=>{E.setAccountProp("preferredAccountType",s,n)},this.setEIP6963Enabled=s=>{$.setEIP6963Enabled(s)},this.handleUnsafeRPCRequest=()=>{if(this.isOpen()){if(this.isTransactionStackEmpty())return;this.redirect("ApproveTransaction")}else this.open({view:"ApproveTransaction"})},this.options=e,this.version=e.sdkVersion,this.caipNetworks=this.extendCaipNetworks(e),this.chainNamespaces=this.getChainNamespacesSet(e.adapters,this.caipNetworks),this.defaultCaipNetwork=this.extendDefaultCaipNetwork(e),this.chainAdapters=this.createAdapters(e.adapters),this.readyPromise=this.initialize(e)}getChainNamespacesSet(e,s){const n=e==null?void 0:e.map(i=>i.namespace).filter(i=>!!i);if(n!=null&&n.length)return[...new Set(n)];const r=s==null?void 0:s.map(i=>i.chainNamespace);return[...new Set(r)]}async initialize(e){var s,n,r,i,o,a;if(this.initializeProjectSettings(e),this.initControllers(e),await this.initChainAdapters(),this.sendInitializeEvent(e),(s=e.features)!=null&&s.headless&&!Ps.hasInjectedConnectors()&&te.prefetch({fetchNetworkImages:!1,fetchConnectorImages:!1,fetchWalletRanks:!1,fetchRecommendedWallets:!0}),$.state.enableReconnect?(await this.syncExistingConnection(),await this.syncAdapterConnections()):await this.unSyncExistingConnection(),!e.basic&&!e.manualWCControl&&(this.remoteFeatures=await Ck.fetchRemoteFeatures(e)),await te.fetchUsage(),$.setRemoteFeatures(this.remoteFeatures),this.remoteFeatures.onramp&&Rl.setOnrampProviders(this.remoteFeatures.onramp),((n=$.state.remoteFeatures)!=null&&n.email||Array.isArray((r=$.state.remoteFeatures)==null?void 0:r.socials)&&((i=$.state.remoteFeatures)==null?void 0:i.socials.length)>0)&&await this.checkAllowedOrigins(),(o=$.state.features)!=null&&o.reownAuthentication||(a=$.state.remoteFeatures)!=null&&a.reownAuthentication){const{ReownAuthentication:c}=await Dt(async()=>{const{ReownAuthentication:d}=await import("./features-BqOwC9OI.js");return{ReownAuthentication:d}},__vite__mapDeps([10,2,3,5,6,7,8,9])),l=$.state.siwx;l instanceof c||(l&&console.warn("ReownAuthentication option is enabled, SIWX configuration will be overridden."),$.setSIWX(new c))}}async openSend(e){var i;const s=e.namespace||E.state.activeChain,n=this.getCaipAddress(s),r=(i=this.getCaipNetwork(s))==null?void 0:i.id;if(!n)throw new Error("openSend: caipAddress not found");if((r==null?void 0:r.toString())!==e.chainId.toString()){const o=E.getCaipNetworkById(e.chainId,s);if(!o)throw new Error(`openSend: caipNetwork with chainId ${e.chainId} not found`);await this.switchNetwork(o,{throwOnFailure:!0})}try{const o=sy.getTokenSymbolByAddress(e.assetAddress);o&&await te.fetchTokenImages([o])}catch{}return await Te.open({view:"WalletSend",data:{send:e}}),new Promise((o,a)=>{const c=Ae.subscribeKey("hash",u=>{u&&(d(),o({hash:u}))}),l=Te.subscribe(u=>{u.open||(d(),a(new Error("Modal closed")))}),d=this.createCleanupHandler([c,l])})}toModalOptions(){function e(n){return(n==null?void 0:n.view)==="Swap"}function s(n){return(n==null?void 0:n.view)==="WalletSend"}return{isSwap:e,isSend:s}}async checkAllowedOrigins(){try{const e=await te.fetchAllowedOrigins();if(!X.isClient())return;const s=window.location.origin;zn.isOriginAllowed(s,e,U.DEFAULT_ALLOWED_ANCESTORS)||Ot.open(Pt.ALERT_ERRORS.ORIGIN_NOT_ALLOWED,"error")}catch(e){if(!(e instanceof Error))return;switch(e.message){case"RATE_LIMITED":Ot.open(Pt.ALERT_ERRORS.RATE_LIMITED_APP_CONFIGURATION,"error");break;case"SERVER_ERROR":{const s=e.cause instanceof Error?e.cause:e;Ot.open({displayMessage:Pt.ALERT_ERRORS.SERVER_ERROR_APP_CONFIGURATION.displayMessage,debugMessage:Pt.ALERT_ERRORS.SERVER_ERROR_APP_CONFIGURATION.debugMessage(s.message)},"error");break}}}}createCleanupHandler(e){return()=>{e.forEach(s=>{try{s()}catch{}})}}sendInitializeEvent(e){var n;const{...s}=e;delete s.adapters,delete s.universalProvider,Ee.sendEvent({type:"track",event:"INITIALIZE",properties:{...s,networks:e.networks.map(r=>r.id),siweConfig:{options:((n=e.siweConfig)==null?void 0:n.options)||{}}}})}initControllers(e){this.initializeOptionsController(e),this.initializeChainController(e),this.initializeThemeController(e),this.initializeConnectionController(e),this.initializeConnectorController()}initAdapterController(){qf.initialize(this.chainAdapters)}initializeThemeController(e){e.themeMode&&Kt.setThemeMode(e.themeMode),e.themeVariables&&Kt.setThemeVariables(e.themeVariables)}initializeChainController(e){if(!this.connectionControllerClient)throw new Error("ConnectionControllerClient must be set");E.initialize(e.adapters??[],this.caipNetworks,{connectionControllerClient:this.connectionControllerClient});const s=this.getDefaultNetwork();s&&E.setActiveCaipNetwork(s)}initializeConnectionController(e){G.initialize(e.adapters??[]),G.setWcBasic(e.basic??!1)}initializeConnectorController(){V.initialize(this.chainNamespaces)}initializeProjectSettings(e){$.setProjectId(e.projectId),$.setSdkVersion(e.sdkVersion)}initializeOptionsController(e){var r;$.setDebug(e.debug!==!1),$.setEnableWalletGuide(e.enableWalletGuide!==!1),$.setEnableWallets(e.enableWallets!==!1),$.setEIP6963Enabled(e.enableEIP6963!==!1),$.setEnableNetworkSwitch(e.enableNetworkSwitch!==!1),$.setEnableReconnect(e.enableReconnect!==!1),$.setEnableMobileFullScreen(e.enableMobileFullScreen===!0),$.setCoinbasePreference(e.coinbasePreference),$.setEnableAuthLogger(e.enableAuthLogger!==!1),$.setCustomRpcUrls(e.customRpcUrls),$.setEnableEmbedded(e.enableEmbedded),$.setAllWallets(e.allWallets),$.setIncludeWalletIds(e.includeWalletIds),$.setExcludeWalletIds(e.excludeWalletIds),$.setFeaturedWalletIds(e.featuredWalletIds),$.setTokens(e.tokens),$.setTermsConditionsUrl(e.termsConditionsUrl),$.setPrivacyPolicyUrl(e.privacyPolicyUrl),$.setCustomWallets(e.customWallets),$.setFeatures(e.features),$.setAllowUnsupportedChain(e.allowUnsupportedChain),$.setUniversalProviderConfigOverride(e.universalProviderConfigOverride),$.setPreferUniversalLinks(e.experimental_preferUniversalLinks),$.setDefaultAccountTypes(e.defaultAccountTypes);const s=this.getDefaultMetaData();if(!e.metadata&&s&&(e.metadata=s),$.setMetadata(e.metadata),$.setDisableAppend(e.disableAppend),$.setEnableEmbedded(e.enableEmbedded),$.setSIWX(e.siwx),this.features=$.state.features??{},!e.projectId){Ot.open(Pt.ALERT_ERRORS.PROJECT_ID_NOT_CONFIGURED,"error");return}if(((r=e.adapters)==null?void 0:r.find(i=>i.namespace===U.CHAIN.EVM))&&e.siweConfig){if(e.siwx)throw new Error("Cannot set both `siweConfig` and `siwx` options");$.setSIWX(e.siweConfig.mapToSIWX())}}getDefaultMetaData(){var e,s,n,r;return X.isClient()?{name:((s=(e=document.getElementsByTagName("title"))==null?void 0:e[0])==null?void 0:s.textContent)||"",description:((n=document.querySelector('meta[property="og:description"]'))==null?void 0:n.content)||"",url:window.location.origin,icons:[((r=document.querySelector('link[rel~="icon"]'))==null?void 0:r.href)||""]}:null}setUnsupportedNetwork(e){const s=this.getActiveChainNamespace();if(s){const n=Gr.getUnsupportedNetwork(`${s}:${e}`);E.setActiveCaipNetwork(n)}}getDefaultNetwork(){return Gr.getCaipNetworkFromStorage(this.defaultCaipNetwork)}extendCaipNetwork(e,s){return Gr.extendCaipNetwork(e,{customNetworkImageUrls:s.chainImages,projectId:s.projectId})}extendCaipNetworks(e){return Gr.extendCaipNetworks(e.networks,{customNetworkImageUrls:e.chainImages,customRpcUrls:e.customRpcUrls,projectId:e.projectId})}extendDefaultCaipNetwork(e){const s=e.networks.find(r=>{var i;return r.id===((i=e.defaultNetwork)==null?void 0:i.id)});return s?Gr.extendCaipNetwork(s,{customNetworkImageUrls:e.chainImages,customRpcUrls:e.customRpcUrls,projectId:e.projectId}):void 0}async disconnectConnector(e,s){var n,r;try{this.setLoading(!0,e);let i={connections:[]};const o=this.getAdapter(e);return(((r=(n=E.state.chains.get(e))==null?void 0:n.accountState)==null?void 0:r.caipAddress)||!$.state.enableReconnect)&&(o!=null&&o.disconnect)&&(i=await o.disconnect({id:s})),this.setLoading(!1,e),i}catch(i){throw this.setLoading(!1,e),new Error(`Failed to disconnect chains: ${i.message}`)}}createClients(){this.connectionControllerClient={connectWalletConnect:async()=>{var l;const e=E.state.activeChain,s=this.getAdapter(e),n=(l=this.getCaipNetwork(e))==null?void 0:l.id,r=G.getConnections(e),i=this.remoteFeatures.multiWallet,o=r.length>0;if(!s)throw new Error("Adapter not found");const a=await s.connectWalletConnect(n);(!o||!i)&&this.close(),this.setClientId((a==null?void 0:a.clientId)||null),F.setConnectedNamespaces([...E.state.chains.keys()]),await this.syncWalletConnectAccount(),await vs.initializeIfEnabled()},connectExternal:async e=>{const s=await this.onConnectExternal(e);return await this.connectInactiveNamespaces(e,s),s?{address:s.address}:void 0},reconnectExternal:async({id:e,info:s,type:n,provider:r})=>{var a;const i=E.state.activeChain,o=this.getAdapter(i);if(!i)throw new Error("reconnectExternal: namespace not found");if(!o)throw new Error("reconnectExternal: adapter not found");o!=null&&o.reconnect&&(await(o==null?void 0:o.reconnect({id:e,info:s,type:n,provider:r,chainId:(a=this.getCaipNetwork())==null?void 0:a.id})),F.addConnectedNamespace(i),this.syncConnectedWalletInfo(i))},disconnectConnector:async e=>{await this.disconnectConnector(e.namespace,e.id)},disconnect:async e=>{var l;const{id:s,chainNamespace:n,initialDisconnect:r}=e||{},i=n||E.state.activeChain,o=V.getConnectorId(i),a=s===U.CONNECTOR_ID.AUTH||o===U.CONNECTOR_ID.AUTH,c=s===U.CONNECTOR_ID.WALLET_CONNECT||o===U.CONNECTOR_ID.WALLET_CONNECT;try{const d=Array.from(E.state.chains.keys());let u=n?[n]:d;(c||a)&&(u=d);const h=u.map(async f=>{const w=V.getConnectorId(f),v=s||w,N=await this.disconnectConnector(f,v);N&&(a&&F.deleteConnectedSocialProvider(),N.connections.forEach(A=>{F.addDisconnectedConnectorId(A.connectorId,f)})),r&&this.onDisconnectNamespace({chainNamespace:f,closeModal:!1})}),p=await Promise.allSettled(h);Ae.resetSend(),G.resetWcConnection(),(l=vs.getSIWX())!=null&&l.signOutOnDisconnect&&await vs.clearSessions(),V.setFilterByNamespace(void 0),G.syncStorageConnections();const g=p.filter(f=>f.status==="rejected");if(g.length>0)throw new Error(g.map(f=>f.reason.message).join(", "));Ee.sendEvent({type:"track",event:"DISCONNECT_SUCCESS",properties:{namespace:n||"all"}})}catch(d){throw new Error(`Failed to disconnect chains: ${d.message}`)}},checkInstalled:e=>e?e.some(s=>{var n;return!!((n=window.ethereum)!=null&&n[String(s)])}):!!window.ethereum,signMessage:async e=>{const s=E.state.activeChain,n=this.getAdapter(E.state.activeChain);if(!s)throw new Error("signMessage: namespace not found");if(!n)throw new Error("signMessage: adapter not found");const r=this.getAddress(s);if(!r)throw new Error("signMessage: address not found");const i=await(n==null?void 0:n.signMessage({message:e,address:r,provider:He.getProvider(s)}));return(i==null?void 0:i.signature)||""},sendTransaction:async e=>{const s=e.chainNamespace;if(!s)throw new Error("sendTransaction: namespace not found");if(Ne.SEND_SUPPORTED_NAMESPACES.includes(s)){const n=this.getAdapter(s);if(!n)throw new Error("sendTransaction: adapter not found");const r=He.getProvider(s),i=await(n==null?void 0:n.sendTransaction({...e,caipNetwork:this.getCaipNetwork(),provider:r}));return(i==null?void 0:i.hash)||""}return""},estimateGas:async e=>{const s=e.chainNamespace;if(s===U.CHAIN.EVM){const n=this.getAdapter(s);if(!n)throw new Error("estimateGas: adapter is required but got undefined");const r=He.getProvider(s),i=this.getCaipNetwork();if(!i)throw new Error("estimateGas: caipNetwork is required but got undefined");const o=await(n==null?void 0:n.estimateGas({...e,provider:r,caipNetwork:i}));return(o==null?void 0:o.gas)||0n}return 0n},getEnsAvatar:async()=>{var r;const e=E.state.activeChain;if(!e)throw new Error("getEnsAvatar: namespace is required but got undefined");const s=this.getAddress(e);if(!s)throw new Error("getEnsAvatar: address not found");await this.syncIdentity({address:s,chainId:Number((r=this.getCaipNetwork())==null?void 0:r.id),chainNamespace:e});const n=E.getAccountData();return(n==null?void 0:n.profileImage)||!1},getEnsAddress:async e=>await zn.resolveReownName(e),writeContract:async e=>{const s=E.state.activeChain,n=this.getAdapter(s);if(!s)throw new Error("writeContract: namespace is required but got undefined");if(!n)throw new Error("writeContract: adapter is required but got undefined");const r=this.getCaipNetwork(),i=this.getCaipAddress(),o=He.getProvider(s);if(!r||!i)throw new Error("writeContract: caipNetwork or caipAddress is required but got undefined");const a=await(n==null?void 0:n.writeContract({...e,caipNetwork:r,provider:o,caipAddress:i}));return a==null?void 0:a.hash},parseUnits:(e,s)=>{const n=this.getAdapter(E.state.activeChain);if(!n)throw new Error("parseUnits: adapter is required but got undefined");return(n==null?void 0:n.parseUnits({value:e,decimals:s}))??0n},formatUnits:(e,s)=>{const n=this.getAdapter(E.state.activeChain);if(!n)throw new Error("formatUnits: adapter is required but got undefined");return(n==null?void 0:n.formatUnits({value:e,decimals:s}))??"0"},getCapabilities:async e=>{const s=this.getAdapter(E.state.activeChain);if(!s)throw new Error("getCapabilities: adapter is required but got undefined");return await(s==null?void 0:s.getCapabilities(e))},grantPermissions:async e=>{const s=this.getAdapter(E.state.activeChain);if(!s)throw new Error("grantPermissions: adapter is required but got undefined");return await(s==null?void 0:s.grantPermissions(e))},revokePermissions:async e=>{const s=this.getAdapter(E.state.activeChain);if(!s)throw new Error("revokePermissions: adapter is required but got undefined");return s!=null&&s.revokePermissions?await s.revokePermissions(e):"0x"},walletGetAssets:async e=>{const s=this.getAdapter(E.state.activeChain);if(!s)throw new Error("walletGetAssets: adapter is required but got undefined");return await(s==null?void 0:s.walletGetAssets(e))??{}},updateBalance:e=>{const s=this.getAddress(e),n=this.getCaipNetwork(e);!n||!s||this.updateNativeBalance(s,n==null?void 0:n.id,e)}},G.setClient(this.connectionControllerClient)}async onConnectExternal(e){var l,d,u,h,p,g,f,w;const s=E.state.activeChain,n=e.chain||s,r=this.getAdapter(n);let i=!0;if(e.type===Lt.CONNECTOR_TYPE_AUTH&&U.AUTH_CONNECTOR_SUPPORTED_CHAINS.some(A=>V.getConnectorId(A)===U.CONNECTOR_ID.AUTH)&&e.chain!==s&&(i=!1),e.chain&&e.chain!==s&&!e.caipNetwork){const v=this.getCaipNetworks().find(N=>N.chainNamespace===e.chain);v&&i&&this.setCaipNetwork(v)}if(!n)throw new Error("connectExternal: namespace not found");if(!r)throw new Error("connectExternal: adapter not found");const o=this.getCaipNetwork(n),a=e.caipNetwork||o,c=await r.connect({id:e.id,address:e.address,info:e.info,type:e.type,provider:e.provider,socialUri:e.socialUri,chainId:((l=e.caipNetwork)==null?void 0:l.id)||(o==null?void 0:o.id),rpcUrl:((p=(h=(u=(d=e.caipNetwork)==null?void 0:d.rpcUrls)==null?void 0:u.default)==null?void 0:h.http)==null?void 0:p[0])||((w=(f=(g=o==null?void 0:o.rpcUrls)==null?void 0:g.default)==null?void 0:f.http)==null?void 0:w[0])});if(c)return F.addConnectedNamespace(n),this.syncProvider({...c,chainNamespace:n}),this.setStatus("connected",n),this.syncConnectedWalletInfo(n),F.removeDisconnectedConnectorId(e.id,n),{address:c.address,connectedCaipNetwork:a}}async connectInactiveNamespaces(e,s){var a;const n=e.type===Lt.CONNECTOR_TYPE_AUTH,r=wo.getOtherAuthNamespaces((a=s==null?void 0:s.connectedCaipNetwork)==null?void 0:a.chainNamespace),i=E.state.activeCaipNetwork,o=this.getAdapter(i==null?void 0:i.chainNamespace);n&&(await Promise.all(r.map(async c=>{var l,d,u;try{const h=He.getProvider(c),p=this.getCaipNetwork(c),g=this.getAdapter(c);await(g==null?void 0:g.connect({...e,provider:h,socialUri:void 0,chainId:p==null?void 0:p.id,rpcUrl:(u=(d=(l=p==null?void 0:p.rpcUrls)==null?void 0:l.default)==null?void 0:d.http)==null?void 0:u[0]}))&&(F.addConnectedNamespace(c),F.removeDisconnectedConnectorId(e.id,c),this.setStatus("connected",c),this.syncConnectedWalletInfo(c))}catch(h){Ot.warn(Pt.ALERT_WARNINGS.INACTIVE_NAMESPACE_NOT_CONNECTED.displayMessage,Pt.ALERT_WARNINGS.INACTIVE_NAMESPACE_NOT_CONNECTED.debugMessage(c,h instanceof Error?h.message:void 0),Pt.ALERT_WARNINGS.INACTIVE_NAMESPACE_NOT_CONNECTED.code)}})),i&&await(o==null?void 0:o.switchNetwork({caipNetwork:i})))}getApprovedCaipNetworksData(){var s,n,r,i,o;if(He.getProviderId(E.state.activeChain)===Lt.CONNECTOR_TYPE_WALLET_CONNECT){const a=(n=(s=this.universalProvider)==null?void 0:s.session)==null?void 0:n.namespaces;return{supportsAllNetworks:((o=(i=(r=this.universalProvider)==null?void 0:r.session)==null?void 0:i.peer)==null?void 0:o.metadata.name)==="MetaMask Wallet",approvedCaipNetworkIds:this.getChainsFromNamespaces(a)}}return{supportsAllNetworks:!0,approvedCaipNetworkIds:[]}}async switchCaipNetwork(e){const s=e.chainNamespace;if(this.getAddressByChainNamespace(e.chainNamespace)){const r=He.getProviderId(s);if(e.chainNamespace===E.state.activeChain){const i=this.getAdapter(s);await(i==null?void 0:i.switchNetwork({caipNetwork:e}))}else if(this.setCaipNetwork(e),r===Lt.CONNECTOR_TYPE_WALLET_CONNECT)this.syncWalletConnectAccount();else{const i=this.getAddressByChainNamespace(s);i&&this.syncAccount({address:i,chainId:e.id,chainNamespace:s})}}else this.setCaipNetwork(e)}getChainsFromNamespaces(e={}){return Object.values(e).flatMap(s=>{const n=s.chains||[],r=s.accounts.map(i=>{const{chainId:o,chainNamespace:a}=dt.parseCaipAddress(i);return`${a}:${o}`});return Array.from(new Set([...n,...r]))})}createAdapters(e){return this.createClients(),this.chainNamespaces.reduce((s,n)=>{var i,o;const r=e==null?void 0:e.find(a=>a.namespace===n);return r?(r.construct({namespace:n,projectId:(i=this.options)==null?void 0:i.projectId,networks:(o=this.caipNetworks)==null?void 0:o.filter(({chainNamespace:a})=>a===n)}),s[n]=r):s[n]=new bk({namespace:n,networks:this.getCaipNetworks()}),s},{})}async initChainAdapter(e){this.onConnectors(e),this.listenAdapter(e);const s=this.getAdapter(e);if(!s)throw new Error("adapter not found");await s.syncConnectors(),await this.createUniversalProviderForAdapter(e)}async initChainAdapters(){await Promise.all(this.chainNamespaces.map(async e=>{await this.initChainAdapter(e)})),this.initAdapterController()}onConnectors(e){const s=this.getAdapter(e);s==null||s.on("connectors",this.setConnectors.bind(this))}listenAdapter(e){const s=this.getAdapter(e);if(!s)return;const n=F.getConnectionStatus();$.state.enableReconnect===!1?this.setStatus("disconnected",e):n==="connected"?this.setStatus("connecting",e):n==="disconnected"?(F.clearAddressCache(),this.setStatus(n,e)):this.setStatus(n,e),s.on("switchNetwork",({address:r,chainId:i})=>{var l,d;const o=this.getCaipNetworks().find(u=>u.id.toString()===i.toString()||u.caipNetworkId.toString()===i.toString()),a=E.state.activeChain===e,c=(d=(l=E.state.chains.get(e))==null?void 0:l.accountState)==null?void 0:d.address;if(o){const u=a&&r?r:c;u&&this.syncAccount({address:u,chainId:o.id,chainNamespace:e})}else this.setUnsupportedNetwork(i)}),s.on("disconnect",()=>{const r=this.remoteFeatures.multiWallet,i=Array.from(G.state.connections.values()).flat();this.onDisconnectNamespace({chainNamespace:e,closeModal:!r||i.length===0})}),s.on("connections",r=>{this.setConnections(r,e)}),s.on("pendingTransactions",()=>{const r=this.getAddress(e),i=E.state.activeCaipNetwork;!r||!(i!=null&&i.id)||this.updateNativeBalance(r,i.id,i.chainNamespace)}),s.on("accountChanged",({address:r,chainId:i,connector:o})=>{var d,u;this.handlePreviousConnectorConnection(o);const a=E.state.activeChain===e;o!=null&&o.provider&&(this.syncProvider({id:o.id,type:o.type,provider:o==null?void 0:o.provider,chainNamespace:e}),this.syncConnectedWalletInfo(e));const c=(u=(d=E.getNetworkData(e))==null?void 0:d.caipNetwork)==null?void 0:u.id,l=i||c;a&&l?this.syncAccount({address:r,chainId:l,chainNamespace:e}):!a&&l?(this.syncAccountInfo(r,l,e),this.syncBalance({address:r,chainId:l,chainNamespace:e})):this.syncAccountInfo(r,i,e),F.addConnectedNamespace(e)})}async handlePreviousConnectorConnection(e){var c;const s=e==null?void 0:e.chain,n=e==null?void 0:e.id,r=V.getConnectorId(s),i=(c=$.state.remoteFeatures)==null?void 0:c.multiWallet,a=s&&n&&r&&r!==n&&!i;try{a&&await G.disconnect({id:r,namespace:s})}catch(l){console.warn("Error disconnecting previous connector",l)}}async createUniversalProviderForAdapter(e){var s,n,r;await this.getUniversalProvider(),this.universalProvider&&await((r=(n=(s=this.chainAdapters)==null?void 0:s[e])==null?void 0:n.setUniversalProvider)==null?void 0:r.call(n,this.universalProvider))}async syncExistingConnection(){await Promise.allSettled(this.chainNamespaces.map(e=>this.syncNamespaceConnection(e)))}async unSyncExistingConnection(){try{await Promise.allSettled(this.chainNamespaces.map(e=>G.disconnect({namespace:e,initialDisconnect:!0})))}catch(e){console.error("Error disconnecting existing connections:",e)}}async reconnectWalletConnect(){await this.syncWalletConnectAccount();const e=this.getAddress();this.getCaipAddress()||F.deleteRecentWallet();const s=F.getRecentWallet();Ee.sendEvent({type:"track",event:"CONNECT_SUCCESS",address:e,properties:{method:X.isMobile()?"mobile":"qrcode",name:(s==null?void 0:s.name)||"Unknown",reconnect:!0,view:ue.state.view,walletRank:s==null?void 0:s.order}})}async syncNamespaceConnection(e){try{e===U.CHAIN.EVM&&X.isSafeApp()&&V.setConnectorId(U.CONNECTOR_ID.SAFE,e);const s=V.getConnectorId(e);switch(this.setStatus("connecting",e),s){case U.CONNECTOR_ID.WALLET_CONNECT:await this.reconnectWalletConnect();break;case U.CONNECTOR_ID.AUTH:break;default:await this.syncAdapterConnection(e)}}catch(s){console.warn("AppKit couldn't sync existing connection",s),this.setStatus("disconnected",e)}}onDisconnectNamespace(e){const{chainNamespace:s,closeModal:n}=e||{};E.resetAccount(s),E.resetNetwork(s),F.removeConnectedNamespace(s);const r=Array.from(E.state.chains.keys());(s?[s]:r).forEach(o=>F.addDisconnectedConnectorId(V.getConnectorId(o)||"",o)),V.removeConnectorId(s),He.resetChain(s),this.setUser(null,s),this.setStatus("disconnected",s),this.setConnectedWalletInfo(null,s),n!==!1&&Te.close()}async syncAdapterConnections(){await Promise.allSettled(this.chainNamespaces.map(e=>{const s=this.getAdapter(e),n=this.getCaipAddress(e),r=this.getCaipNetwork(e);return s==null?void 0:s.syncConnections({connectToFirstConnector:!n,caipNetwork:r})}))}async syncAdapterConnection(e){var a,c,l,d,u;const s=this.getAdapter(e),n=this.getCaipNetwork(e),r=V.getConnectorId(e),o=V.getConnectors(e).find(h=>h.id===r);try{if(!s||!o)throw new Error(`Adapter or connector not found for namespace ${e}`);if(!(n!=null&&n.id))throw new Error("CaipNetwork not found");const h=await(s==null?void 0:s.syncConnection({namespace:e,id:o.id,chainId:n.id,rpcUrl:(l=(c=(a=n==null?void 0:n.rpcUrls)==null?void 0:a.default)==null?void 0:c.http)==null?void 0:l[0]}));h?(this.syncProvider({...h,chainNamespace:e}),await this.syncAccount({...h,chainNamespace:e}),this.setStatus("connected",e),Ee.sendEvent({type:"track",event:"CONNECT_SUCCESS",address:h.address,properties:{method:"browser",name:((d=o.info)==null?void 0:d.name)||o.name||"Unknown",reconnect:!0,view:ue.state.view,walletRank:(u=o==null?void 0:o.explorerWallet)==null?void 0:u.order}})):this.setStatus("disconnected",e)}catch{this.onDisconnectNamespace({chainNamespace:e,closeModal:!1})}}async syncWalletConnectAccount(){var n,r;const e=Object.keys(((r=(n=this.universalProvider)==null?void 0:n.session)==null?void 0:r.namespaces)||{}),s=this.chainNamespaces.map(async i=>{var u,h,p,g,f;const o=this.getAdapter(i);if(!o)return;const a=((g=(p=(h=(u=this.universalProvider)==null?void 0:u.session)==null?void 0:h.namespaces)==null?void 0:p[i])==null?void 0:g.accounts)||[],c=(f=E.state.activeCaipNetwork)==null?void 0:f.id,l=a.find(w=>{const{chainId:v}=dt.parseCaipAddress(w);return v===(c==null?void 0:c.toString())})||a[0];if(l){const w=dt.validateCaipAddress(l),{chainId:v,address:N}=dt.parseCaipAddress(w);if(He.setProviderId(i,Lt.CONNECTOR_TYPE_WALLET_CONNECT),this.caipNetworks&&E.state.activeCaipNetwork&&o.namespace!==U.CHAIN.EVM){const A=o.getWalletConnectProvider({caipNetworks:this.getCaipNetworks(),provider:this.universalProvider,activeCaipNetwork:E.state.activeCaipNetwork});He.setProvider(i,A)}else He.setProvider(i,this.universalProvider);V.setConnectorId(U.CONNECTOR_ID.WALLET_CONNECT,i),F.addConnectedNamespace(i),await this.syncAccount({address:N,chainId:v,chainNamespace:i})}else e.includes(i)&&this.setStatus("disconnected",i);const d=this.getApprovedCaipNetworksData();this.syncConnectedWalletInfo(i),E.setApprovedCaipNetworksData(i,{approvedCaipNetworkIds:d.approvedCaipNetworkIds,supportsAllNetworks:d.supportsAllNetworks})});await Promise.all(s)}syncProvider({type:e,provider:s,id:n,chainNamespace:r}){He.setProviderId(r,e),He.setProvider(r,s),V.setConnectorId(n,r)}async syncAccount(e){var u,h;const s=e.chainNamespace===E.state.activeChain,n=E.getCaipNetworkByNamespace(e.chainNamespace,e.chainId),{address:r,chainId:i,chainNamespace:o}=e,{chainId:a}=F.getActiveNetworkProps(),c=(n==null?void 0:n.id)||a,l=((u=E.state.activeCaipNetwork)==null?void 0:u.name)===U.UNSUPPORTED_NETWORK_NAME,d=E.getNetworkProp("supportsAllNetworks",o);if(this.setStatus("connected",o),!(l&&!d)&&c){let p=this.getCaipNetworks().find(v=>v.id.toString()===c.toString()),g=this.getCaipNetworks().find(v=>v.chainNamespace===o);if(!d&&!p&&!g){const v=this.getApprovedCaipNetworkIds()||[],N=v.find(_=>{var P;return((P=dt.parseCaipNetworkId(_))==null?void 0:P.chainId)===c.toString()}),A=v.find(_=>{var P;return((P=dt.parseCaipNetworkId(_))==null?void 0:P.chainNamespace)===o});p=this.getCaipNetworks().find(_=>_.caipNetworkId===N),g=this.getCaipNetworks().find(_=>_.caipNetworkId===A||"deprecatedCaipNetworkId"in _&&_.deprecatedCaipNetworkId===A)}const f=p||g;(f==null?void 0:f.chainNamespace)===E.state.activeChain?$.state.enableNetworkSwitch&&!$.state.allowUnsupportedChain&&((h=E.state.activeCaipNetwork)==null?void 0:h.name)===U.UNSUPPORTED_NETWORK_NAME?E.showUnsupportedChainUI():this.setCaipNetwork(f):s||n&&this.setCaipNetworkOfNamespace(n,o),this.syncConnectedWalletInfo(o);const w=this.getAddress(o);wo.isLowerCaseMatch(r,w)||this.syncAccountInfo(r,f==null?void 0:f.id,o),s?await this.syncBalance({address:r,chainId:f==null?void 0:f.id,chainNamespace:o}):await this.syncBalance({address:r,chainId:n==null?void 0:n.id,chainNamespace:o}),this.syncIdentity({address:r,chainId:i,chainNamespace:o})}}async syncAccountInfo(e,s,n){const r=this.getCaipAddress(n),i=s||(r==null?void 0:r.split(":")[1]);if(!i)return;const o=`${n}:${i}:${e}`;this.setCaipAddress(o,n,!0),await this.syncIdentity({address:e,chainId:i,chainNamespace:n})}async syncReownName(e,s){try{const n=await this.getReownName(e);if(n[0]){const r=n[0];this.setProfileName(r.name,s)}else this.setProfileName(null,s)}catch{this.setProfileName(null,s)}}syncConnectedWalletInfo(e){var r;const s=V.getConnectorId(e),n=He.getProviderId(e);if(n===Lt.CONNECTOR_TYPE_ANNOUNCED||n===Lt.CONNECTOR_TYPE_INJECTED){if(s){const o=this.getConnectors().find(a=>{var u,h;const c=a.id===s,l=((u=a.info)==null?void 0:u.rdns)===s,d=(h=a.connectors)==null?void 0:h.some(p=>{var g;return p.id===s||((g=p.info)==null?void 0:g.rdns)===s});return c||l||!!d});if(o){const{info:a,name:c,imageUrl:l}=o,d=l||this.getConnectorImage(o);this.setConnectedWalletInfo({name:c,icon:d,...a},e)}}}else if(n===Lt.CONNECTOR_TYPE_WALLET_CONNECT){const i=He.getProvider(e);i!=null&&i.session&&this.setConnectedWalletInfo({...i.session.peer.metadata,name:i.session.peer.metadata.name,icon:(r=i.session.peer.metadata.icons)==null?void 0:r[0]},e)}else if(s&&(s===U.CONNECTOR_ID.COINBASE_SDK||s===U.CONNECTOR_ID.COINBASE)){const i=this.getConnectors().find(l=>l.id===s),o=(i==null?void 0:i.name)||"Coinbase Wallet",a=(i==null?void 0:i.imageUrl)||this.getConnectorImage(i),c=i==null?void 0:i.info;this.setConnectedWalletInfo({...c,name:o,icon:a},e)}}async syncBalance(e){!yf.getNetworksByNamespace(this.getCaipNetworks(),e.chainNamespace).find(n=>{var r;return n.id.toString()===((r=e.chainId)==null?void 0:r.toString())})||!e.chainId||await this.updateNativeBalance(e.address,e.chainId,e.chainNamespace)}async ready(){await this.readyPromise}async updateNativeBalance(e,s,n){const r=this.getAdapter(n),i=E.getCaipNetworkByNamespace(n,s);if(r){const o=await r.getBalance({address:e,chainId:s,caipNetwork:i,tokens:this.options.tokens});return this.setBalance(o.balance,o.symbol,n),o}}async initializeUniversalAdapter(){var r,i,o,a,c,l,d,u,h,p;const e=Hx.createLogger((g,...f)=>{g&&this.handleAlertError(g),console.error(...f)}),s={projectId:(r=this.options)==null?void 0:r.projectId,metadata:{name:(i=this.options)!=null&&i.metadata?(o=this.options)==null?void 0:o.metadata.name:"",description:(a=this.options)!=null&&a.metadata?(c=this.options)==null?void 0:c.metadata.description:"",url:(l=this.options)!=null&&l.metadata?(d=this.options)==null?void 0:d.metadata.url:"",icons:(u=this.options)!=null&&u.metadata?(h=this.options)==null?void 0:h.metadata.icons:[""]},logger:e};$.setManualWCControl(!!((p=this.options)!=null&&p.manualWCControl)),this.universalProvider=this.options.universalProvider??await ux.init(s);const n=this.universalProvider.disconnect.bind(this.universalProvider);this.universalProvider.disconnect=async()=>{try{return await n()}catch(g){if(g instanceof Error&&g.message.includes("Missing or invalid. Record was recently deleted"))return;throw g}},$.state.enableReconnect===!1&&this.universalProvider.session&&await this.universalProvider.disconnect(),this.listenWalletConnect()}listenWalletConnect(){this.universalProvider&&this.chainNamespaces.forEach(e=>{zn.listenWcProvider({universalProvider:this.universalProvider,namespace:e,onDisplayUri:s=>{G.setUri(s)},onConnect:s=>{const{address:n}=X.getAccount(s[0]);G.finalizeWcConnection(n)},onDisconnect:()=>{E.state.noAdapters&&this.resetAccount(e),G.resetWcConnection()},onChainChanged:s=>{const n=E.state.activeChain,r=n&&V.state.activeConnectorIds[n]===U.CONNECTOR_ID.WALLET_CONNECT;if(n===e&&(E.state.noAdapters||r)){const i=this.getCaipNetworks().find(a=>a.id.toString()===s.toString()||a.caipNetworkId.toString()===s.toString()),o=this.getCaipNetwork();if(!i){this.setUnsupportedNetwork(s);return}(o==null?void 0:o.id.toString())!==(i==null?void 0:i.id.toString())&&(o==null?void 0:o.chainNamespace)===(i==null?void 0:i.chainNamespace)&&this.setCaipNetwork(i)}},onAccountsChanged:s=>{const n=E.state.activeChain,r=n&&V.state.activeConnectorIds[n]===U.CONNECTOR_ID.WALLET_CONNECT;if(n===e&&(E.state.noAdapters||r)){const i=s==null?void 0:s[0];i&&this.syncAccount({address:i.address,chainId:i.chainId,chainNamespace:i.chainNamespace})}}})})}createUniversalProvider(){var e;return!this.universalProviderInitPromise&&X.isClient()&&((e=this.options)!=null&&e.projectId)&&(this.universalProviderInitPromise=this.initializeUniversalAdapter()),this.universalProviderInitPromise}async getUniversalProvider(){if(!this.universalProvider)try{await this.createUniversalProvider()}catch(e){Ee.sendEvent({type:"error",event:"INTERNAL_SDK_ERROR",properties:{errorType:"UniversalProviderInitError",errorMessage:e instanceof Error?e.message:"Unknown",uncaught:!1}}),console.error("AppKit:getUniversalProvider - Cannot create provider",e)}return this.universalProvider}getDisabledCaipNetworks(){const e=E.getAllApprovedCaipNetworkIds(),s=E.getAllRequestedCaipNetworks();return X.sortRequestedNetworks(e,s).filter(r=>E.isCaipNetworkDisabled(r))}handleAlertError(e){const s=Object.entries(Pt.UniversalProviderErrors).find(([,{message:a}])=>e.message.includes(a)),[n,r]=s??[],{message:i,alertErrorKey:o}=r??{};if(n&&i&&!this.reportedAlertErrors[n]){const a=Pt.ALERT_ERRORS[o];a&&(Ot.open(a,"error"),this.reportedAlertErrors[n]=!0)}}getAdapter(e){var s;if(e)return(s=this.chainAdapters)==null?void 0:s[e]}createAdapter(e){var r,i;if(!e)return;const s=e.namespace;if(!s)return;this.createClients();const n=e;n.namespace=s,n.construct({namespace:s,projectId:(r=this.options)==null?void 0:r.projectId,networks:(i=this.caipNetworks)==null?void 0:i.filter(({chainNamespace:o})=>o===s)}),this.chainNamespaces.includes(s)||this.chainNamespaces.push(s),this.chainAdapters&&(this.chainAdapters[s]=n)}async open(e){await this.injectModalUi(),e!=null&&e.uri&&G.setUri(e.uri);const{isSwap:s,isSend:n}=this.toModalOptions();return s(e)?Te.open({...e,data:{swap:e.arguments}}):n(e)&&e.arguments?this.openSend(e.arguments):Te.open(e)}async close(){await this.injectModalUi(),Te.close()}setLoading(e,s){Te.setLoading(e,s)}async disconnect(e){await G.disconnect({namespace:e})}getSIWX(){return $.state.siwx}getError(){return""}getChainId(){var e;return(e=E.state.activeCaipNetwork)==null?void 0:e.id}async switchNetwork(e,{throwOnFailure:s=!1}={}){const n=this.getCaipNetworks().find(r=>r.id===e.id);if(!n){Ot.open(Pt.ALERT_ERRORS.SWITCH_NETWORK_NOT_FOUND,"error");return}await E.switchActiveNetwork(n,{throwOnFailure:s})}getWalletProvider(){return E.state.activeChain?He.state.providers[E.state.activeChain]:null}getWalletProviderType(){return He.getProviderId(E.state.activeChain)}subscribeProviders(e){return He.subscribeProviders(e)}getThemeMode(){return Kt.state.themeMode}getThemeVariables(){return Kt.state.themeVariables}setThemeMode(e){Kt.setThemeMode(e),gd(Kt.state.themeMode)}setTermsConditionsUrl(e){$.setTermsConditionsUrl(e)}setPrivacyPolicyUrl(e){$.setPrivacyPolicyUrl(e)}setThemeVariables(e){Kt.setThemeVariables(e),Ek(Kt.state.themeVariables)}subscribeTheme(e){return Kt.subscribe(e)}subscribeConnections(e){return this.remoteFeatures.multiWallet?G.subscribe(e):(Ot.open(U.REMOTE_FEATURES_ALERTS.MULTI_WALLET_NOT_ENABLED.DEFAULT,"info"),()=>{})}getWalletInfo(e){var n,r;if(e)return(r=(n=E.state.chains.get(e))==null?void 0:n.accountState)==null?void 0:r.connectedWalletInfo;const s=E.getAccountData();return s==null?void 0:s.connectedWalletInfo}getAccount(e){const s=e||E.state.activeChain,n=V.getAuthConnector(s),r=E.getAccountData(s),i=F.getConnectedConnectorId(E.state.activeChain),o=G.getConnections(s);if(!s)throw new Error("AppKit:getAccount - namespace is required");const a=o.flatMap(c=>c.accounts.map(({address:l,type:d,publicKey:u})=>X.createAccount(s,l,d||"eoa",u)));if(r)return{allAccounts:a,caipAddress:r.caipAddress,address:X.getPlainAddress(r.caipAddress),isConnected:!!r.caipAddress,status:r.status,embeddedWalletInfo:n&&i===U.CONNECTOR_ID.AUTH?{user:r.user?{...r.user,username:F.getConnectedSocialUsername()}:void 0,authProvider:r.socialProvider||"email",accountType:ls(s),isSmartAccountDeployed:!!r.smartAccountDeployed}:void 0}}subscribeAccount(e,s){const n=()=>{const r=this.getAccount(s);r&&e(r)};s?E.subscribeChainProp("accountState",n,s):E.subscribe(n),V.subscribe(n)}subscribeNetwork(e){return E.subscribe(({activeCaipNetwork:s})=>{e({caipNetwork:s,chainId:s==null?void 0:s.id,caipNetworkId:s==null?void 0:s.caipNetworkId})})}subscribeWalletInfo(e,s){return s?E.subscribeChainProp("accountState",n=>e(n==null?void 0:n.connectedWalletInfo),s):E.subscribeChainProp("accountState",n=>e(n==null?void 0:n.connectedWalletInfo))}subscribeShouldUpdateToAddress(e){E.subscribeChainProp("accountState",s=>e(s==null?void 0:s.shouldUpdateToAddress))}subscribeCaipNetworkChange(e){E.subscribeKey("activeCaipNetwork",e)}getState(){return ds.state}getRemoteFeatures(){return $.state.remoteFeatures}subscribeState(e){return ds.subscribe(e)}subscribeRemoteFeatures(e){return $.subscribeKey("remoteFeatures",e)}showErrorMessage(e){zs.showError(e)}showSuccessMessage(e){zs.showSuccess(e)}getEvent(){return{...Ee.state}}subscribeEvents(e){return Ee.subscribe(e)}replace(e){ue.replace(e)}redirect(e){ue.push(e)}popTransactionStack(e){ue.popTransactionStack(e)}isOpen(){return Te.state.open}isTransactionStackEmpty(){return ue.state.transactionStack.length===0}static getInstance(){return this.instance}updateFeatures(e){$.setFeatures(e)}updateRemoteFeatures(e){$.setRemoteFeatures(e)}updateOptions(e){const n={...$.state||{},...e};$.setOptions(n)}setConnectMethodsOrder(e){$.setConnectMethodsOrder(e)}setWalletFeaturesOrder(e){$.setWalletFeaturesOrder(e)}setCollapseWallets(e){$.setCollapseWallets(e)}setSocialsOrder(e){$.setSocialsOrder(e)}getConnectMethodsOrder(){return Hn.getConnectOrderMethod($.state.features,V.getConnectors())}addNetwork(e,s){if(this.chainAdapters&&!this.chainAdapters[e])throw new Error(`Adapter for namespace ${e} doesn't exist`);const n=this.extendCaipNetwork(s,this.options);this.getCaipNetworks().find(r=>r.id===n.id)||E.addNetwork(n)}removeNetwork(e,s){if(this.chainAdapters&&!this.chainAdapters[e])throw new Error(`Adapter for namespace ${e} doesn't exist`);this.getCaipNetworks().find(r=>r.id===s)&&E.removeNetwork(e,s)}}let hf=!1;class dy extends _k{async onAuthProviderConnected(e){const s=wo.userChainIdToChainNamespace(e==null?void 0:e.chainId);if(e.message&&e.signature&&e.siwxMessage&&await vs.addEmbeddedWalletSession({chainId:e.siwxMessage.chainId,accountAddress:e.address,notBefore:e.siwxMessage.notBefore,statement:e.siwxMessage.statement,resources:e.siwxMessage.resources,requestId:e.siwxMessage.requestId,issuedAt:e.siwxMessage.issuedAt,domain:e.siwxMessage.domain,uri:e.siwxMessage.uri,version:e.siwxMessage.version,nonce:e.siwxMessage.nonce},e.message,e.signature),!s)throw new Error("AppKit:onAuthProviderConnected - namespace is required");const n=s===U.CHAIN.EVM?`eip155:${e.chainId}:${e.address}`:`${e.chainId}:${e.address}`,r=$.state.defaultAccountTypes[s],i=ls(s),o=e.preferredAccountType||i||r;this.setCaipAddress(n,s);const{signature:a,siwxMessage:c,message:l,...d}=e,u=E.getAccountData(s);this.setUser({...(u==null?void 0:u.user)||{},...d},s),this.setSmartAccountDeployed(!!e.smartAccountDeployed,s),this.setPreferredAccountType(o,s),await Promise.all([this.syncAuthConnectorTheme(this.authProvider),this.syncAccount({address:e.address,chainId:e.chainId,chainNamespace:s})]),this.setLoading(!1,s)}setupAuthConnectorListeners(e){e.onRpcRequest(s=>{cs.checkIfRequestExists(s)?cs.checkIfRequestIsSafe(s)||this.handleUnsafeRPCRequest():(this.open(),console.error(tt.RPC_METHOD_NOT_ALLOWED_MESSAGE,{method:s.method}),setTimeout(()=>{this.showErrorMessage(tt.RPC_METHOD_NOT_ALLOWED_UI_MESSAGE)},300),e.rejectRpcRequests())}),e.onRpcError(()=>{this.isOpen()&&(this.isTransactionStackEmpty()?this.close():this.popTransactionStack("error"))}),e.onRpcSuccess((s,n)=>{const r=cs.checkIfRequestIsSafe(n),i=this.getAddress(),o=E.state.activeCaipNetwork;r||(i&&(o!=null&&o.id)&&this.updateNativeBalance(i,o.id,o.chainNamespace),this.isTransactionStackEmpty()?this.close():this.popTransactionStack("success"))}),e.onNotConnected(()=>{const s=E.state.activeChain;if(!s)throw new Error("AppKit:onNotConnected - namespace is required");V.getConnectorId(s)===U.CONNECTOR_ID.AUTH&&(this.setCaipAddress(null,s),this.setLoading(!1,s))}),e.onConnect(this.onAuthProviderConnected.bind(this)),e.onSocialConnected(this.onAuthProviderConnected.bind(this)),e.onSetPreferredAccount(({address:s,type:n})=>{const r=E.state.activeChain;if(!r)throw new Error("AppKit:onSetPreferredAccount - namespace is required");s&&this.setPreferredAccountType(n,r)})}async syncAuthConnectorTheme(e){if(!e)return;const s=Kt.getSnapshot();await e.syncTheme({themeMode:s.themeMode,themeVariables:s.themeVariables,w3mThemeVariables:Zi(s.themeVariables,s.themeMode)})}async syncAuthConnector(e,s){var d,u,h,p,g,f,w,v,N;const n=U.AUTH_CONNECTOR_SUPPORTED_CHAINS.includes(s),r=s===E.state.activeChain;if(!n)return;this.setLoading(!0,s);const i=e.getLoginEmailUsed();this.setLoading(i,s),i&&this.setStatus("connecting",s);const o=e.getEmail(),a=e.getUsername(),c=((d=E.getAccountData(s))==null?void 0:d.user)||{};this.setUser({...c,username:a,email:o},s),this.setupAuthConnectorListeners(e);const{isConnected:l}=await e.isConnected();if(s&&n&&r)if(l&&((u=this.connectionControllerClient)!=null&&u.connectExternal)){await e.init(),await this.syncAuthConnectorTheme(e),await((g=this.connectionControllerClient)==null?void 0:g.connectExternal({id:U.CONNECTOR_ID.AUTH,info:{name:U.CONNECTOR_ID.AUTH},type:Lt.CONNECTOR_TYPE_AUTH,provider:e,chainId:(p=(h=E.getNetworkData(s))==null?void 0:h.caipNetwork)==null?void 0:p.id,chain:s})),this.setStatus("connected",s);const A=F.getConnectedSocialProvider();A?Ee.sendEvent({type:"track",event:"SOCIAL_LOGIN_SUCCESS",address:this.getAddress(),properties:{provider:A,reconnect:!0}}):Ee.sendEvent({type:"track",event:"CONNECT_SUCCESS",address:this.getAddress(),properties:{method:"email",name:((N=(v=(w=(f=this.universalProvider)==null?void 0:f.session)==null?void 0:w.peer)==null?void 0:v.metadata)==null?void 0:N.name)||"Unknown",reconnect:!0,view:ue.state.view,walletRank:void 0}})}else V.getConnectorId(s)===U.CONNECTOR_ID.AUTH&&(this.setStatus("disconnected",s),F.removeConnectedNamespace(s));this.setLoading(!1,s)}async checkExistingTelegramSocialConnection(e){var s;try{if(!X.isTelegram())return;const n=F.getTelegramSocialProvider();if(!n||!X.isClient())return;const i=new URL(window.location.href).searchParams.get("result_uri");if(!i)return;n&&E.setAccountProp("socialProvider",n,e),await((s=this.authProvider)==null?void 0:s.init());const o=V.getAuthConnector();n&&o&&(this.setLoading(!0,e),await G.connectExternal({id:o.id,type:o.type,socialUri:i},o.chain),F.setConnectedSocialProvider(n),F.removeTelegramSocialProvider(),Ee.sendEvent({type:"track",event:"SOCIAL_LOGIN_SUCCESS",properties:{provider:n}}))}catch(n){this.setLoading(!1,e),console.error("checkExistingSTelegramocialConnection error",n)}try{const n=new URL(window.location.href);n.searchParams.delete("result_uri"),window.history.replaceState({},document.title,n.toString())}catch(n){console.error("tma social login failed",n)}}createAuthProvider(e){var l,d,u,h;if(!U.AUTH_CONNECTOR_SUPPORTED_CHAINS.includes(e))return;const n=(l=this.remoteFeatures)==null?void 0:l.email,r=Array.isArray((d=this.remoteFeatures)==null?void 0:d.socials)&&this.remoteFeatures.socials.length>0,i=n||r,a=wo.getActiveNamespaceConnectedToAuth()||e;!this.authProvider&&((u=this.options)!=null&&u.projectId)&&i&&(this.authProvider=Vi.getInstance({projectId:this.options.projectId,enableLogger:this.options.enableAuthLogger,chainId:(h=this.getCaipNetwork(a))==null?void 0:h.caipNetworkId,abortController:Pt.EmbeddedWalletAbortController,onTimeout:p=>{p==="iframe_load_failed"?Ot.open(Pt.ALERT_ERRORS.IFRAME_LOAD_FAILED,"error"):p==="iframe_request_timeout"?Ot.open(Pt.ALERT_ERRORS.IFRAME_REQUEST_TIMEOUT,"error"):p==="unverified_domain"&&Ot.open(Pt.ALERT_ERRORS.UNVERIFIED_DOMAIN,"error")},getActiveCaipNetwork:p=>ki(p),getCaipNetworks:p=>E.getCaipNetworks(p)}),ds.subscribeOpen(p=>{var g;!p&&this.isTransactionStackEmpty()&&((g=this.authProvider)==null||g.rejectRpcRequests())}));const c=e===E.state.activeChain&&$.state.enableReconnect;$.state.enableReconnect===!1?this.syncAuthConnectorTheme(this.authProvider):this.authProvider&&c&&(this.syncAuthConnector(this.authProvider,e),this.checkExistingTelegramSocialConnection(e))}createAuthProviderForAdapter(e){var s,n,r;this.createAuthProvider(e),this.authProvider&&((r=(n=(s=this.chainAdapters)==null?void 0:s[e])==null?void 0:n.setAuthProvider)==null||r.call(n,this.authProvider))}initControllers(e){super.initControllers(e),this.options.excludeWalletIds&&te.initializeExcludedWallets({ids:this.options.excludeWalletIds})}async switchCaipNetwork(e){var o,a,c;if(!e)return;const s=E.state.activeChain,n=e.chainNamespace,r=this.getAddressByChainNamespace(n);if(n===s&&((o=E.getAccountData(n))!=null&&o.caipAddress)){const l=this.getAdapter(n);await(l==null?void 0:l.switchNetwork({caipNetwork:e})),this.setCaipNetwork(e)}else{const d=He.getProviderId(s)===Lt.CONNECTOR_TYPE_AUTH,u=He.getProviderId(n),h=u===Lt.CONNECTOR_TYPE_AUTH,p=U.AUTH_CONNECTOR_SUPPORTED_CHAINS.includes(n);if(!n)throw new Error("AppKit:switchCaipNetwork - networkNamespace is required");if((d&&u===void 0||h)&&p)try{if(E.state.activeChain=e.chainNamespace,r){const g=this.getAdapter(n);await(g==null?void 0:g.switchNetwork({caipNetwork:e}))}else await((c=(a=this.connectionControllerClient)==null?void 0:a.connectExternal)==null?void 0:c.call(a,{id:U.CONNECTOR_ID.AUTH,provider:this.authProvider,chain:n,chainId:e.id,type:Lt.CONNECTOR_TYPE_AUTH,caipNetwork:e}));this.setCaipNetwork(e)}catch{const f=this.getAdapter(n);await(f==null?void 0:f.switchNetwork({caipNetwork:e}))}else if(u===Lt.CONNECTOR_TYPE_WALLET_CONNECT){if(!E.state.noAdapters){const g=this.getAdapter(n);await(g==null?void 0:g.switchNetwork({caipNetwork:e}))}this.setCaipNetwork(e),this.syncWalletConnectAccount()}else this.setCaipNetwork(e),r&&this.syncAccount({address:r,chainId:e.id,chainNamespace:n})}}async initialize(e){var s;await super.initialize(e),(s=this.chainNamespaces)==null||s.forEach(n=>{this.createAuthProviderForAdapter(n)}),await this.injectModalUi(),ds.set({initialized:!0})}async syncIdentity({address:e,chainId:s,chainNamespace:n}){var a;const r=`${n}:${s}`,i=(a=this.caipNetworks)==null?void 0:a.find(c=>c.caipNetworkId===r);if(i!=null&&i.testnet){this.setProfileName(null,n),this.setProfileImage(null,n);return}const o=V.getConnectorId(n)===U.CONNECTOR_ID.AUTH;try{const{name:c,avatar:l}=await this.fetchIdentity({address:e});!c&&o?await this.syncReownName(e,n):(this.setProfileName(c,n),this.setProfileImage(l,n))}catch{s!==1&&this.setProfileImage(null,n)}}syncConnectedWalletInfo(e){const s=He.getProviderId(e);if(s===Lt.CONNECTOR_TYPE_AUTH){const n=this.authProvider;if(n){const r=F.getConnectedSocialProvider()??"email",i=n.getEmail()??n.getUsername();this.setConnectedWalletInfo({name:s,identifier:i,social:r},e)}}else super.syncConnectedWalletInfo(e)}async injectModalUi(){if(X.isClient()&&!hf)try{const e={...Ne.DEFAULT_FEATURES,...this.options.features},s=this.remoteFeatures;if(await this.loadModalComponents(e,s),X.isClient()&&!document.querySelector("w3m-modal")){const r=document.createElement("w3m-modal");!$.state.disableAppend&&!$.state.enableEmbedded&&document.body.insertAdjacentElement("beforeend",r)}hf=!0}catch(e){console.error("Error injecting modal UI:",e)}}async loadModalComponents(e,s){if(!X.isClient())return;const n=[];(s.email||s.socials&&s.socials.length>0)&&n.push(Dt(()=>import("./embedded-wallet-2rN-oS7N.js"),__vite__mapDeps([11,12,3,13,14,2,15,16,17,18,19,20,21,22,23,24,5,6,7,8,9]))),s.email&&n.push(Dt(()=>import("./email-BGLr_-QZ.js"),__vite__mapDeps([25,12,3,26,23,16,22,14,15,21,27,19,2,5,6,7,8,9]))),s.socials&&n.push(Dt(()=>import("./socials-BgGTTjbV.js"),__vite__mapDeps([28,12,3,14,29,15,30,2,22,31,18,21,16,32,13,5,6,7,8,9,33]))),s.swaps&&s.swaps.length>0&&n.push(Dt(()=>import("./swaps-B7bIgKjW.js"),__vite__mapDeps([34,12,3,21,16,22,14,35,36,37,2,33,38,13,19,15,5,6,7,8,9]))),e.send&&n.push(Dt(()=>import("./send-DmpGLDx_.js"),__vite__mapDeps([39,12,3,21,16,22,14,40,15,41,23,38,13,33,37,2,19,42,43,5,6,7,8,9]))),e.receive&&n.push(Dt(()=>import("./receive-dmziTgvF.js"),__vite__mapDeps([44,12,3,14,13,32,5,6,7,8,9,2]))),s.onramp&&s.onramp.length>0&&n.push(Dt(()=>import("./onramp-DmW6Wpg-.js"),__vite__mapDeps([45,12,3,14,46,16,29,15,13,47,48,23,21,22,31,19,2,5,6,7,8,9]))),s.payWithExchange&&n.push(Dt(()=>import("./pay-with-exchange-C3dE_Jy4.js"),__vite__mapDeps([49,12,3,14,13,20,46,16,33,21,41,15,23,50,22,19,42,40,2,5,6,7,8,9]))),s.activity&&n.push(Dt(()=>import("./transactions-oExukfM1.js"),__vite__mapDeps([51,12,3,52,6,7,8,22,14,23,13,33,2,5,9]))),(e.pay||s.payments)&&n.push(Dt(()=>import("./index-DkatlhKa.js"),__vite__mapDeps([53,12,3,14,21,16,54,20,13,46,55,40,56,22,2,31,5,6,7,8,9]))),s.emailCapture&&n.push(Dt(()=>import("./data-capture-FB6me-7p.js"),__vite__mapDeps([57,12,3,26,23,16,10,2,5,6,7,8,9]))),await Promise.all([...n,Dt(()=>import("./index-g5szi6r5.js"),__vite__mapDeps([58,12,3,14,13,16,43,22,59,48,23,17,18,2,56,20,46,21,50,52,6,7,8,33,42,35,36,40,15,19,55,27,29,30,31,32,5,9,24,47])),Dt(()=>import("./w3m-modal-DLtaVZGd.js"),__vite__mapDeps([60,12,3,14,54,13,17,18,2,16,22,36,59,48,23,56,37,21,5,6,7,8,9]))])}}const Ak="1.8.15";function Sk(t){return new dy({...t,sdkVersion:X.generateSdkVersion(t.adapters??[],"html",Ak)})}const w2=Object.freeze(Object.defineProperty({__proto__:null,AppKit:dy,CoreHelperUtil:X,WcConstantsUtil:Li,createAppKit:Sk},Symbol.toStringTag,{value:"Module"}));export{Hi as $,yt as A,fe as B,E as C,p2 as D,Ee as E,Qi as F,F as G,cs as H,ae as I,le as J,Lt as K,te as L,Te as M,Yy as N,$ as O,lv as P,Pt as Q,ue as R,zs as S,Kt as T,dt as U,He as V,tt as W,Qy as X,Zi as Y,lt as Z,Ae as _,X as a,Rl as a0,bs as a1,Tr as a2,gn as a3,ha as a4,vs as a5,g2 as a6,qf as a7,ry as a8,pd as a9,hi as aa,Df as ab,uv as ac,dv as ad,Lf as ae,Lu as af,wv as ag,Vo as ah,bv as ai,gv as aj,Ps as ak,Ua as al,wo as am,Hn as an,Gr as ao,zv as ap,ki as aq,w2 as ar,o2 as b,i2 as c,Ne as d,Ff as e,c2 as f,a2 as g,l2 as h,_t as i,f2 as j,y2 as k,ba as l,h2 as m,qn as n,G as o,Ge as p,ls as q,m2 as r,At as s,Hv as t,Ot as u,wk as v,As as w,_d as x,V as y,Bf as z};
|